• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 Apple Computer, 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 COMPUTER, 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 COMPUTER, 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 #ifndef GraphicsContextPlatformPrivateCairo_h
29 #define GraphicsContextPlatformPrivateCairo_h
30 
31 #include "GraphicsContext.h"
32 
33 #include "ContextShadow.h"
34 #include "PlatformContextCairo.h"
35 #include "RefPtrCairo.h"
36 #include <cairo.h>
37 #include <math.h>
38 #include <stdio.h>
39 #include <wtf/MathExtras.h>
40 
41 #if PLATFORM(GTK)
42 #include <pango/pango.h>
43 typedef struct _GdkExposeEvent GdkExposeEvent;
44 #elif PLATFORM(WIN)
45 #include <cairo-win32.h>
46 #endif
47 
48 namespace WebCore {
49 
50 class GraphicsContextPlatformPrivate {
51 public:
GraphicsContextPlatformPrivate(PlatformContextCairo * newPlatformContext)52     GraphicsContextPlatformPrivate(PlatformContextCairo* newPlatformContext)
53         : platformContext(newPlatformContext)
54 #if PLATFORM(GTK)
55         , expose(0)
56 #elif PLATFORM(WIN)
57         // NOTE:  These may note be needed: review and remove once Cairo implementation is complete
58         , m_hdc(0)
59         , m_transparencyCount(0)
60         , m_shouldIncludeChildWindows(false)
61 #endif
62     {
63     }
64 
~GraphicsContextPlatformPrivate()65     virtual ~GraphicsContextPlatformPrivate()
66     {
67     }
68 
69 #if PLATFORM(WIN)
70     // On Windows, we need to update the HDC for form controls to draw in the right place.
71     void save();
72     void restore();
73     void flush();
74     void clip(const FloatRect&);
75     void clip(const Path&);
76     void scale(const FloatSize&);
77     void rotate(float);
78     void translate(float, float);
79     void concatCTM(const AffineTransform&);
80     void setCTM(const AffineTransform&);
beginTransparencyLayer()81     void beginTransparencyLayer() { m_transparencyCount++; }
endTransparencyLayer()82     void endTransparencyLayer() { m_transparencyCount--; }
83     void syncContext(cairo_t* cr);
84 #else
85     // On everything else, we do nothing.
save()86     void save() {}
restore()87     void restore() {}
flush()88     void flush() {}
clip(const FloatRect &)89     void clip(const FloatRect&) {}
clip(const Path &)90     void clip(const Path&) {}
scale(const FloatSize &)91     void scale(const FloatSize&) {}
rotate(float)92     void rotate(float) {}
translate(float,float)93     void translate(float, float) {}
concatCTM(const AffineTransform &)94     void concatCTM(const AffineTransform&) {}
setCTM(const AffineTransform &)95     void setCTM(const AffineTransform&) {}
beginTransparencyLayer()96     void beginTransparencyLayer() {}
endTransparencyLayer()97     void endTransparencyLayer() {}
syncContext(cairo_t * cr)98     void syncContext(cairo_t* cr) {}
99 #endif
100 
101     PlatformContextCairo* platformContext;
102     Vector<float> layers;
103     ContextShadow shadow;
104     Vector<ContextShadow> shadowStack;
105 
106 #if PLATFORM(GTK)
107     GdkEventExpose* expose;
108 #elif PLATFORM(WIN)
109     HDC m_hdc;
110     unsigned m_transparencyCount;
111     bool m_shouldIncludeChildWindows;
112 #endif
113 };
114 
115 // This is a specialized private section for the Cairo GraphicsContext, which knows how
116 // to clean up the heap allocated PlatformContextCairo that we must use for the top-level
117 // GraphicsContext.
118 class GraphicsContextPlatformPrivateToplevel : public GraphicsContextPlatformPrivate {
119 public:
GraphicsContextPlatformPrivateToplevel(PlatformContextCairo * platformContext)120     GraphicsContextPlatformPrivateToplevel(PlatformContextCairo* platformContext)
121         : GraphicsContextPlatformPrivate(platformContext)
122     {
123     }
124 
~GraphicsContextPlatformPrivateToplevel()125     virtual ~GraphicsContextPlatformPrivateToplevel()
126     {
127         delete platformContext;
128     }
129 };
130 
131 
132 } // namespace WebCore
133 
134 #endif // GraphicsContextPlatformPrivateCairo_h
135