1 | /* |
2 | * Copyright (C) 2008 Google Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #ifndef ImageBufferDataCairo_h |
27 | #define ImageBufferDataCairo_h |
28 | |
29 | #if USE(CAIRO) |
30 | |
31 | #include "PlatformContextCairo.h" |
32 | #include "RefPtrCairo.h" |
33 | |
34 | #if ENABLE(ACCELERATED_2D_CANVAS) |
35 | #include "PlatformLayer.h" |
36 | #include "TextureMapper.h" |
37 | #include "TextureMapperPlatformLayer.h" |
38 | #include "TextureMapperPlatformLayerProxyProvider.h" |
39 | #endif |
40 | |
41 | #if ENABLE(ACCELERATED_2D_CANVAS) && USE(NICOSIA) |
42 | #include "NicosiaContentLayerTextureMapperImpl.h" |
43 | #endif |
44 | |
45 | namespace WebCore { |
46 | |
47 | class IntSize; |
48 | class TextureMapperPlatformLayerProxy; |
49 | |
50 | class ImageBufferData |
51 | #if ENABLE(ACCELERATED_2D_CANVAS) |
52 | #if USE(NICOSIA) |
53 | : public Nicosia::ContentLayerTextureMapperImpl::Client |
54 | #else |
55 | : public PlatformLayer |
56 | #endif |
57 | #endif |
58 | { |
59 | public: |
60 | ImageBufferData(const IntSize&, RenderingMode); |
61 | virtual ~ImageBufferData(); |
62 | |
63 | RefPtr<cairo_surface_t> m_surface; |
64 | PlatformContextCairo m_platformContext; |
65 | std::unique_ptr<GraphicsContext> m_context; |
66 | IntSize m_size; |
67 | RenderingMode m_renderingMode; |
68 | |
69 | #if ENABLE(ACCELERATED_2D_CANVAS) |
70 | void createCairoGLSurface(); |
71 | |
72 | #if USE(COORDINATED_GRAPHICS) |
73 | #if USE(NICOSIA) |
74 | void swapBuffersIfNeeded() override; |
75 | #else |
76 | RefPtr<TextureMapperPlatformLayerProxy> proxy() const override; |
77 | void swapBuffersIfNeeded() override; |
78 | #endif |
79 | void createCompositorBuffer(); |
80 | |
81 | RefPtr<cairo_surface_t> m_compositorSurface; |
82 | uint32_t m_compositorTexture; |
83 | RefPtr<cairo_t> m_compositorCr; |
84 | |
85 | #if USE(NICOSIA) |
86 | RefPtr<Nicosia::ContentLayer> m_nicosiaLayer; |
87 | #else |
88 | RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy; |
89 | #endif |
90 | #else |
91 | virtual void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity); |
92 | #endif |
93 | uint32_t m_texture; |
94 | #endif |
95 | }; |
96 | |
97 | } // namespace WebCore |
98 | |
99 | #endif // USE(CAIRO) |
100 | |
101 | #endif // ImageBufferDataCairo_h |
102 | |