1 | /* |
2 | * Copyright (C) 2017 Metrological Group B.V. |
3 | * Copyright (C) 2017 Igalia S.L. |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
8 | * |
9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above |
12 | * copyright notice, this list of conditions and the following |
13 | * disclaimer in the documentation and/or other materials provided |
14 | * with the distribution. |
15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
28 | |
29 | #pragma once |
30 | |
31 | #include "NicosiaPaintingContext.h" |
32 | |
33 | #if USE(CAIRO) |
34 | |
35 | #include <wtf/RefPtr.h> |
36 | |
37 | typedef struct _cairo cairo_t; |
38 | typedef struct _cairo_surface cairo_surface_t; |
39 | |
40 | namespace WebCore { |
41 | class GraphicsContext; |
42 | class PlatformContextCairo; |
43 | } |
44 | |
45 | namespace Nicosia { |
46 | |
47 | class PaintingContextCairo final { |
48 | public: |
49 | class ForPainting final : public PaintingContext { |
50 | public: |
51 | explicit ForPainting(Buffer&); |
52 | virtual ~ForPainting(); |
53 | |
54 | private: |
55 | WebCore::GraphicsContext& graphicsContext() override; |
56 | void replay(const PaintingOperations&) override; |
57 | |
58 | struct { |
59 | RefPtr<cairo_surface_t> surface; |
60 | RefPtr<cairo_t> context; |
61 | } m_cairo; |
62 | std::unique_ptr<WebCore::PlatformContextCairo> m_platformContext; |
63 | std::unique_ptr<WebCore::GraphicsContext> m_graphicsContext; |
64 | |
65 | #ifndef NDEBUG |
66 | bool m_deletionComplete { false }; |
67 | #endif |
68 | }; |
69 | |
70 | class ForRecording final : public PaintingContext { |
71 | public: |
72 | ForRecording(PaintingOperations&); |
73 | virtual ~ForRecording(); |
74 | |
75 | private: |
76 | WebCore::GraphicsContext& graphicsContext() override; |
77 | void replay(const PaintingOperations&) override; |
78 | |
79 | std::unique_ptr<WebCore::GraphicsContext> m_graphicsContext; |
80 | }; |
81 | }; |
82 | |
83 | } // namespace Nicosia |
84 | |
85 | #endif // USE(CAIRO) |
86 | |