1 | /* |
2 | * Copyright (C) 2006 Apple Inc. All rights reserved. |
3 | * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 | * Copyright (C) 2008 Brent Fulgham <bfulgham@gmail.com> |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions |
8 | * are met: |
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 copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
14 | * |
15 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #pragma once |
29 | |
30 | #include "GraphicsContext.h" |
31 | |
32 | #if USE(CAIRO) |
33 | |
34 | #include "PlatformContextCairo.h" |
35 | #include "RefPtrCairo.h" |
36 | #include <cairo.h> |
37 | #include <math.h> |
38 | #include <memory> |
39 | #include <stdio.h> |
40 | |
41 | #if PLATFORM(WIN) |
42 | #include <cairo-win32.h> |
43 | #endif |
44 | |
45 | namespace WebCore { |
46 | |
47 | class GraphicsContextPlatformPrivate { |
48 | public: |
49 | GraphicsContextPlatformPrivate(PlatformContextCairo& platformContext) |
50 | : platformContext(platformContext) |
51 | { |
52 | } |
53 | |
54 | GraphicsContextPlatformPrivate(std::unique_ptr<PlatformContextCairo>&& platformContext) |
55 | : ownedPlatformContext(WTFMove(platformContext)) |
56 | , platformContext(*ownedPlatformContext) |
57 | { |
58 | } |
59 | |
60 | #if PLATFORM(WIN) |
61 | // On Windows, we need to update the HDC for form controls to draw in the right place. |
62 | void save(); |
63 | void restore(); |
64 | void flush(); |
65 | void clip(const FloatRect&); |
66 | void clip(const Path&); |
67 | void scale(const FloatSize&); |
68 | void rotate(float); |
69 | void translate(float, float); |
70 | void concatCTM(const AffineTransform&); |
71 | void setCTM(const AffineTransform&); |
72 | void syncContext(cairo_t* cr); |
73 | #else |
74 | // On everything else, we do nothing. |
75 | void save() { } |
76 | void restore() { } |
77 | void flush() { } |
78 | void clip(const FloatRect&) { } |
79 | void clip(const Path&) { } |
80 | void scale(const FloatSize&) { } |
81 | void rotate(float) { } |
82 | void translate(float, float) { } |
83 | void concatCTM(const AffineTransform&) { } |
84 | void setCTM(const AffineTransform&) { } |
85 | void syncContext(cairo_t*) { } |
86 | #endif |
87 | |
88 | std::unique_ptr<PlatformContextCairo> ownedPlatformContext; |
89 | PlatformContextCairo& platformContext; |
90 | |
91 | #if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) |
92 | // NOTE: These may note be needed: review and remove once Cairo implementation is complete |
93 | HDC m_hdc { 0 }; |
94 | bool m_shouldIncludeChildWindows { false }; |
95 | #endif |
96 | }; |
97 | |
98 | } // namespace WebCore |
99 | |
100 | #endif // USE(CAIRO) |
101 | |