• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3  * Copyright (C) 2008-2009 Torch Mobile, Inc.
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  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef GraphicsContext_h
28 #define GraphicsContext_h
29 
30 #include "ColorSpace.h"
31 #include "DashArray.h"
32 #include "FloatRect.h"
33 #include "Gradient.h"
34 #include "Image.h"
35 #include "Path.h"
36 #include "Pattern.h"
37 #include <wtf/Noncopyable.h>
38 #include <wtf/PassOwnPtr.h>
39 
40 #if USE(CG)
41 typedef struct CGContext PlatformGraphicsContext;
42 #elif USE(CAIRO)
43 namespace WebCore {
44 class ContextShadow;
45 class PlatformContextCairo;
46 }
47 typedef WebCore::PlatformContextCairo PlatformGraphicsContext;
48 #elif PLATFORM(OPENVG)
49 namespace WebCore {
50 class SurfaceOpenVG;
51 }
52 typedef class WebCore::SurfaceOpenVG PlatformGraphicsContext;
53 #elif PLATFORM(QT)
54 #include <QPainter>
55 namespace WebCore {
56 class ContextShadow;
57 }
58 typedef QPainter PlatformGraphicsContext;
59 #elif PLATFORM(WX)
60 class wxGCDC;
61 class wxWindowDC;
62 
63 // wxGraphicsContext allows us to support Path, etc.
64 // but on some platforms, e.g. Linux, it requires fairly
65 // new software.
66 #if USE(WXGC)
67 // On OS X, wxGCDC is just a typedef for wxDC, so use wxDC explicitly to make
68 // the linker happy.
69 #ifdef __APPLE__
70     class wxDC;
71     typedef wxDC PlatformGraphicsContext;
72 #else
73     typedef wxGCDC PlatformGraphicsContext;
74 #endif
75 #else
76     typedef wxWindowDC PlatformGraphicsContext;
77 #endif
78 #elif USE(SKIA)
79 #if PLATFORM(ANDROID)
80 namespace WebCore {
81 class PlatformGraphicsContext;
82 }
83 class SkPaint;
84 struct SkPoint;
85 #else
86 namespace WebCore {
87 class PlatformContextSkia;
88 }
89 typedef WebCore::PlatformContextSkia PlatformGraphicsContext;
90 #endif
91 #elif PLATFORM(HAIKU)
92 class BView;
93 typedef BView PlatformGraphicsContext;
94 struct pattern;
95 #elif OS(WINCE)
96 typedef struct HDC__ PlatformGraphicsContext;
97 #else
98 typedef void PlatformGraphicsContext;
99 #endif
100 
101 #if PLATFORM(WIN)
102 #include "DIBPixelData.h"
103 typedef struct HDC__* HDC;
104 #if !USE(CG)
105 // UInt8 is defined in CoreFoundation/CFBase.h
106 typedef unsigned char UInt8;
107 #endif
108 #endif
109 
110 #if PLATFORM(QT) && defined(Q_WS_WIN)
111 #include <windows.h>
112 #endif
113 
114 namespace WebCore {
115 
116 #if OS(WINCE) && !PLATFORM(QT)
117     class SharedBitmap;
118     class SimpleFontData;
119     class GlyphBuffer;
120 #endif
121 
122     const int cMisspellingLineThickness = 3;
123     const int cMisspellingLinePatternWidth = 4;
124     const int cMisspellingLinePatternGapWidth = 1;
125 
126     class AffineTransform;
127     class DrawingBuffer;
128     class Font;
129     class Generator;
130     class GraphicsContextPlatformPrivate;
131     class ImageBuffer;
132     class IntRect;
133     class RoundedIntRect;
134     class KURL;
135     class SharedGraphicsContext3D;
136     class TextRun;
137 
138     enum TextDrawingMode {
139         TextModeInvisible = 0,
140         TextModeFill      = 1 << 0,
141         TextModeStroke    = 1 << 1,
142         TextModeClip      = 1 << 2
143     };
144     typedef unsigned TextDrawingModeFlags;
145 
146     enum StrokeStyle {
147         NoStroke,
148         SolidStroke,
149         DottedStroke,
150         DashedStroke
151     };
152 
153     enum InterpolationQuality {
154         InterpolationDefault,
155         InterpolationNone,
156         InterpolationLow,
157         InterpolationMedium,
158         InterpolationHigh
159     };
160 
161     struct GraphicsContextState {
GraphicsContextStateGraphicsContextState162         GraphicsContextState()
163             : strokeThickness(0)
164             , shadowBlur(0)
165 #if USE(CAIRO)
166             , globalAlpha(1)
167 #endif
168             , textDrawingMode(TextModeFill)
169             , strokeColor(Color::black)
170             , fillColor(Color::black)
171             , strokeStyle(SolidStroke)
172             , fillRule(RULE_NONZERO)
173             , strokeColorSpace(ColorSpaceDeviceRGB)
174             , fillColorSpace(ColorSpaceDeviceRGB)
175             , shadowColorSpace(ColorSpaceDeviceRGB)
176             , compositeOperator(CompositeSourceOver)
177             , shouldAntialias(true)
178             , shouldSmoothFonts(true)
179             , paintingDisabled(false)
180             , shadowsIgnoreTransforms(false)
181 #if USE(CG)
182             // Core Graphics incorrectly renders shadows with radius > 8px (<rdar://problem/8103442>),
183             // but we need to preserve this buggy behavior for canvas and -webkit-box-shadow.
184             , shadowsUseLegacyRadius(false)
185 #endif
186         {
187         }
188 
189         RefPtr<Gradient> strokeGradient;
190         RefPtr<Pattern> strokePattern;
191 
192         RefPtr<Gradient> fillGradient;
193         RefPtr<Pattern> fillPattern;
194 
195         FloatSize shadowOffset;
196 
197         float strokeThickness;
198         float shadowBlur;
199 
200 #if USE(CAIRO)
201         float globalAlpha;
202 #endif
203         TextDrawingModeFlags textDrawingMode;
204 
205         Color strokeColor;
206         Color fillColor;
207         Color shadowColor;
208 
209         StrokeStyle strokeStyle;
210         WindRule fillRule;
211 
212         ColorSpace strokeColorSpace;
213         ColorSpace fillColorSpace;
214         ColorSpace shadowColorSpace;
215 
216         CompositeOperator compositeOperator;
217 
218         bool shouldAntialias : 1;
219         bool shouldSmoothFonts : 1;
220         bool paintingDisabled : 1;
221         bool shadowsIgnoreTransforms : 1;
222 #if USE(CG)
223         bool shadowsUseLegacyRadius : 1;
224 #endif
225     };
226 
227     class GraphicsContext {
228         WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED;
229     public:
230         GraphicsContext(PlatformGraphicsContext*);
231         ~GraphicsContext();
232 
233 #if !OS(WINCE) || PLATFORM(QT)
234         PlatformGraphicsContext* platformContext() const;
235 #endif
236 
237         float strokeThickness() const;
238         void setStrokeThickness(float);
239         StrokeStyle strokeStyle() const;
240         void setStrokeStyle(StrokeStyle);
241         Color strokeColor() const;
242         ColorSpace strokeColorSpace() const;
243         void setStrokeColor(const Color&, ColorSpace);
244 
245         void setStrokePattern(PassRefPtr<Pattern>);
246         Pattern* strokePattern() const;
247 
248         void setStrokeGradient(PassRefPtr<Gradient>);
249         Gradient* strokeGradient() const;
250 
251         WindRule fillRule() const;
252         void setFillRule(WindRule);
253         Color fillColor() const;
254         ColorSpace fillColorSpace() const;
255         void setFillColor(const Color&, ColorSpace);
256 
257         void setFillPattern(PassRefPtr<Pattern>);
258         Pattern* fillPattern() const;
259 
260         void setFillGradient(PassRefPtr<Gradient>);
261         Gradient* fillGradient() const;
262 
263         void setShadowsIgnoreTransforms(bool);
264         bool shadowsIgnoreTransforms() const;
265 
266         void setShouldAntialias(bool);
267         bool shouldAntialias() const;
268 
269         void setShouldSmoothFonts(bool);
270         bool shouldSmoothFonts() const;
271 
272         const GraphicsContextState& state() const;
273 
274 #if USE(CG)
275         void applyStrokePattern();
276         void applyFillPattern();
277         void drawPath(const Path&);
278 
279         // Allow font smoothing (LCD antialiasing). Not part of the graphics state.
280         void setAllowsFontSmoothing(bool);
281 
282         void setIsCALayerContext(bool);
283         bool isCALayerContext() const;
284 
285         void setIsAcceleratedContext(bool);
286         bool isAcceleratedContext() const;
287 #endif
288 
289 #if PLATFORM(ANDROID)
290         // initialize a paint for bitmaps
291         void setupBitmapPaint(SkPaint*);
292         // initialize a paint for filling
293         void setupFillPaint(SkPaint*);
294         // initialize a paint for stroking
295         void setupStrokePaint(SkPaint*);
296         // initialize a paint for a shadow, or if false is returned, the
297         // parameters are left untouched
298         bool setupShadowPaint(SkPaint* paint, SkPoint* offset);
299         // returns true if there is a valid (non-transparent) fill color
300         bool willFill() const;
301         // returns true if there is a valid (non-transparent) stroke color
302         bool willStroke() const;
303 
304         // may return NULL, since we lazily allocate the path. This is the path
305         // that is drawn by drawPath()
306         const SkPath* getCurrPath() const;
307 
308         /** platform-specific factory method to return a bitmap graphicscontext,
309          called by <canvas> when we need to draw offscreen. Caller is responsible for
310          deleting the context. Use drawOffscreenContext() to draw the context's image
311          onto another graphics context.
312          */
313         static GraphicsContext* createOffscreenContext(int width, int height);
314 #endif
315 
316         void save();
317         void restore();
318 
319         // These draw methods will do both stroking and filling.
320         // FIXME: ...except drawRect(), which fills properly but always strokes
321         // using a 1-pixel stroke inset from the rect borders (of the correct
322         // stroke color).
323         void drawRect(const IntRect&);
324         void drawLine(const IntPoint&, const IntPoint&);
325         void drawEllipse(const IntRect&);
326         void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
327 
328         void fillPath(const Path&);
329         void strokePath(const Path&);
330 
331         // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
332         void strokeArc(const IntRect&, int startAngle, int angleSpan);
333 
334         void fillRect(const FloatRect&);
335         void fillRect(const FloatRect&, const Color&, ColorSpace);
336         void fillRect(const FloatRect&, Generator&);
337         void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
338         void fillRoundedRect(const RoundedIntRect&, const Color&, ColorSpace);
339         void fillRectWithRoundedHole(const IntRect&, const RoundedIntRect& roundedHoleRect, const Color&, ColorSpace);
340 
341         void clearRect(const FloatRect&);
342 
343         void strokeRect(const FloatRect&, float lineWidth);
344 
345         void drawImage(Image*, ColorSpace styleColorSpace, const IntPoint&, CompositeOperator = CompositeSourceOver);
346         void drawImage(Image*, ColorSpace styleColorSpace, const IntRect&, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
347         void drawImage(Image*, ColorSpace styleColorSpace, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver);
348         void drawImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
349         void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
350                        CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
351         void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize,
352                        CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
353         void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect,
354                             Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
355                             CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
356 
357         void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint&, CompositeOperator = CompositeSourceOver);
358         void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntRect&, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
359         void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver);
360         void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
361         void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
362                              CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
363 
364         void setImageInterpolationQuality(InterpolationQuality);
365         InterpolationQuality imageInterpolationQuality() const;
366 
367         void clip(const IntRect&);
368         void clip(const FloatRect&);
369         void addRoundedRectClip(const RoundedIntRect&);
370         void addInnerRoundedRectClip(const IntRect&, int thickness);
371         void clipOut(const IntRect&);
372         void clipOutRoundedRect(const RoundedIntRect&);
373         void clipPath(const Path&, WindRule);
374         void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
375         void clipToImageBuffer(ImageBuffer*, const FloatRect&);
376 
377         IntRect clipBounds() const;
378 
379         TextDrawingModeFlags textDrawingMode() const;
380         void setTextDrawingMode(TextDrawingModeFlags);
381 
382         void drawText(const Font&, const TextRun&, const FloatPoint&, int from = 0, int to = -1);
383         void drawEmphasisMarks(const Font&, const TextRun& , const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1);
384         void drawBidiText(const Font&, const TextRun&, const FloatPoint&);
385         void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, int h, const Color& backgroundColor, ColorSpace, int from = 0, int to = -1);
386 
387         enum RoundingMode {
388             RoundAllSides,
389             RoundOriginAndDimensions
390         };
391         FloatRect roundToDevicePixels(const FloatRect&, RoundingMode = RoundAllSides);
392 
393         void drawLineForText(const FloatPoint&, float width, bool printing);
394         enum TextCheckingLineStyle {
395             TextCheckingSpellingLineStyle,
396             TextCheckingGrammarLineStyle,
397             TextCheckingReplacementLineStyle
398         };
399         void drawLineForTextChecking(const FloatPoint&, float width, TextCheckingLineStyle);
400 
401         bool paintingDisabled() const;
402         void setPaintingDisabled(bool);
403 
404         bool updatingControlTints() const;
405         void setUpdatingControlTints(bool);
406 
407         void beginTransparencyLayer(float opacity);
408         void endTransparencyLayer();
409 
410         bool hasShadow() const;
411         void setShadow(const FloatSize&, float blur, const Color&, ColorSpace);
412         // Legacy shadow blur radius is used for canvas, and -webkit-box-shadow.
413         // It has different treatment of radii > 8px.
414         void setLegacyShadow(const FloatSize&, float blur, const Color&, ColorSpace);
415 
416         bool getShadow(FloatSize&, float&, Color&, ColorSpace&) const;
417         void clearShadow();
418 
419         void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
420         void drawFocusRing(const Path&, int width, int offset, const Color&);
421 
422         void setLineCap(LineCap);
423         void setLineDash(const DashArray&, float dashOffset);
424         void setLineJoin(LineJoin);
425         void setMiterLimit(float);
426 
427         void setAlpha(float);
428 #if USE(CAIRO)
429         float getAlpha();
430 #endif
431 
432         void setCompositeOperation(CompositeOperator);
433         CompositeOperator compositeOperation() const;
434 
435         void clip(const Path&);
436 
437         // This clip function is used only by <canvas> code. It allows
438         // implementations to handle clipping on the canvas differently since
439         // the discipline is different.
440         void canvasClip(const Path&);
441         void clipOut(const Path&);
442 
443         void scale(const FloatSize&);
444         void rotate(float angleInRadians);
translate(const FloatSize & size)445         void translate(const FloatSize& size) { translate(size.width(), size.height()); }
446         void translate(float x, float y);
447 
448         void setURLForRect(const KURL&, const IntRect&);
449 
450         void concatCTM(const AffineTransform&);
451         void setCTM(const AffineTransform&);
452         AffineTransform getCTM() const;
453 
454 #if OS(WINCE) && !PLATFORM(QT)
455         void setBitmap(PassRefPtr<SharedBitmap>);
456         const AffineTransform& affineTransform() const;
457         AffineTransform& affineTransform();
458         void resetAffineTransform();
459         void fillRect(const FloatRect&, const Gradient*);
460         void drawText(const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point);
461         void drawFrameControl(const IntRect& rect, unsigned type, unsigned state);
462         void drawFocusRect(const IntRect& rect);
463         void paintTextField(const IntRect& rect, unsigned state);
464         void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp);
465         void drawBitmapPattern(SharedBitmap*, const FloatRect& tileRectIn, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize);
466         void drawIcon(HICON icon, const IntRect& dstRect, UINT flags);
467         HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = false, bool mayCreateBitmap = true); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
468         void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = false, bool mayCreateBitmap = true);    // The passed in HDC should be the one handed back by getWindowsContext.
469         void drawRoundCorner(bool newClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height);
470 #elif PLATFORM(WIN)
471         GraphicsContext(HDC, bool hasAlpha = false); // FIXME: To be removed.
472         bool inTransparencyLayer() const;
473         HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
474         void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);    // The passed in HDC should be the one handed back by getWindowsContext.
475 
476         // When set to true, child windows should be rendered into this context
477         // rather than allowing them just to render to the screen. Defaults to
478         // false.
479         // FIXME: This is a layering violation. GraphicsContext shouldn't know
480         // what a "window" is. It would be much more appropriate for this flag
481         // to be passed as a parameter alongside the GraphicsContext, but doing
482         // that would require lots of changes in cross-platform code that we
483         // aren't sure we want to make.
484         void setShouldIncludeChildWindows(bool);
485         bool shouldIncludeChildWindows() const;
486 
487         class WindowsBitmap {
488             WTF_MAKE_NONCOPYABLE(WindowsBitmap);
489         public:
490             WindowsBitmap(HDC, IntSize);
491             ~WindowsBitmap();
492 
hdc()493             HDC hdc() const { return m_hdc; }
buffer()494             UInt8* buffer() const { return m_pixelData.buffer(); }
bufferLength()495             unsigned bufferLength() const { return m_pixelData.bufferLength(); }
size()496             const IntSize& size() const { return m_pixelData.size(); }
bytesPerRow()497             unsigned bytesPerRow() const { return m_pixelData.bytesPerRow(); }
bitsPerPixel()498             unsigned short bitsPerPixel() const { return m_pixelData.bitsPerPixel(); }
windowsDIB()499             const DIBPixelData& windowsDIB() const { return m_pixelData; }
500 
501         private:
502             HDC m_hdc;
503             HBITMAP m_bitmap;
504             DIBPixelData m_pixelData;
505         };
506 
507         WindowsBitmap* createWindowsBitmap(IntSize);
508         // The bitmap should be non-premultiplied.
509         void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
510 #endif
511 
512 #if (PLATFORM(QT) && defined(Q_WS_WIN)) || (PLATFORM(WX) && OS(WINDOWS))
513         HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
514         void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
shouldIncludeChildWindows()515         bool shouldIncludeChildWindows() const { return false; }
516 #endif
517 
518 #if PLATFORM(WX)
inTransparencyLayer()519         bool inTransparencyLayer() const { return false; }
520 #endif
521 
522 #if PLATFORM(QT)
523         bool inTransparencyLayer() const;
524         void pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask);
525         void takeOwnershipOfPlatformContext();
526 #endif
527 
528 #if PLATFORM(QT) || USE(CAIRO)
529         ContextShadow* contextShadow();
530 #endif
531 
532 #if USE(CAIRO)
533         GraphicsContext(cairo_t*);
534 #endif
535 
536 #if PLATFORM(GTK)
537         void setGdkExposeEvent(GdkEventExpose*);
538         GdkWindow* gdkWindow() const;
539         GdkEventExpose* gdkExposeEvent() const;
540 #endif
541 
542 #if PLATFORM(HAIKU)
543         pattern getHaikuStrokeStyle();
544 #endif
545 
546         void setSharedGraphicsContext3D(SharedGraphicsContext3D*, DrawingBuffer*, const IntSize&);
547         void syncSoftwareCanvas();
548         void markDirtyRect(const IntRect&); // Hints that a portion of the backing store is dirty.
549 
550     private:
551         void platformInit(PlatformGraphicsContext*);
552         void platformDestroy();
553 
554 #if PLATFORM(WIN) && !OS(WINCE)
555         void platformInit(HDC, bool hasAlpha = false);
556 #endif
557 
558         void savePlatformState();
559         void restorePlatformState();
560 
561         void setPlatformTextDrawingMode(TextDrawingModeFlags);
562         void setPlatformFont(const Font& font);
563 
564         void setPlatformStrokeColor(const Color&, ColorSpace);
565         void setPlatformStrokeStyle(StrokeStyle);
566         void setPlatformStrokeThickness(float);
567         void setPlatformStrokeGradient(Gradient*);
568         void setPlatformStrokePattern(Pattern*);
569 
570         void setPlatformFillColor(const Color&, ColorSpace);
571         void setPlatformFillGradient(Gradient*);
572         void setPlatformFillPattern(Pattern*);
573 
574         void setPlatformShouldAntialias(bool);
575         void setPlatformShouldSmoothFonts(bool);
576 
577         void setPlatformShadow(const FloatSize&, float blur, const Color&, ColorSpace);
578         void clearPlatformShadow();
579 
580         void setPlatformCompositeOperation(CompositeOperator);
581 
582         static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle);
583 
584         GraphicsContextPlatformPrivate* m_data;
585 
586         GraphicsContextState m_state;
587         Vector<GraphicsContextState> m_stack;
588         bool m_updatingControlTints;
589     };
590 
591 } // namespace WebCore
592 
593 #endif // GraphicsContext_h
594