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)
41typedef struct CGContext PlatformGraphicsContext;
42#elif USE(CAIRO)
43namespace WebCore {
44class ContextShadow;
45class PlatformContextCairo;
46}
47typedef WebCore::PlatformContextCairo PlatformGraphicsContext;
48#elif PLATFORM(OPENVG)
49namespace WebCore {
50class SurfaceOpenVG;
51}
52typedef class WebCore::SurfaceOpenVG PlatformGraphicsContext;
53#elif PLATFORM(QT)
54#include <QPainter>
55namespace WebCore {
56class ContextShadow;
57}
58typedef QPainter PlatformGraphicsContext;
59#elif PLATFORM(WX)
60class wxGCDC;
61class 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)
80namespace WebCore {
81class PlatformGraphicsContext;
82}
83class SkPaint;
84struct SkPoint;
85#else
86namespace WebCore {
87class PlatformContextSkia;
88}
89typedef WebCore::PlatformContextSkia PlatformGraphicsContext;
90#endif
91#elif PLATFORM(HAIKU)
92class BView;
93typedef BView PlatformGraphicsContext;
94struct pattern;
95#elif OS(WINCE)
96typedef struct HDC__ PlatformGraphicsContext;
97#else
98typedef void PlatformGraphicsContext;
99#endif
100
101#if PLATFORM(WIN)
102#include "DIBPixelData.h"
103typedef struct HDC__* HDC;
104#if !USE(CG)
105// UInt8 is defined in CoreFoundation/CFBase.h
106typedef unsigned char UInt8;
107#endif
108#endif
109
110#if PLATFORM(QT) && defined(Q_WS_WIN)
111#include <windows.h>
112#endif
113
114namespace 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 {
162        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 filling
291        void setupFillPaint(SkPaint*);
292        // initialize a paint for stroking
293        void setupStrokePaint(SkPaint*);
294        // initialize a paint for a shadow, or if false is returned, the
295        // parameters are left untouched
296        bool setupShadowPaint(SkPaint* paint, SkPoint* offset);
297        // returns true if there is a valid (non-transparent) fill color
298        bool willFill() const;
299        // returns true if there is a valid (non-transparent) stroke color
300        bool willStroke() const;
301
302        /** platform-specific factory method to return a bitmap graphicscontext,
303         called by <canvas> when we need to draw offscreen. Caller is responsible for
304         deleting the context. Use drawOffscreenContext() to draw the context's image
305         onto another graphics context.
306         */
307        static GraphicsContext* createOffscreenContext(int width, int height);
308#endif
309
310        void save();
311        void restore();
312
313        // These draw methods will do both stroking and filling.
314        // FIXME: ...except drawRect(), which fills properly but always strokes
315        // using a 1-pixel stroke inset from the rect borders (of the correct
316        // stroke color).
317        void drawRect(const IntRect&);
318        void drawLine(const IntPoint&, const IntPoint&);
319        void drawEllipse(const IntRect&);
320        void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
321
322        void fillPath(const Path&);
323        void strokePath(const Path&);
324
325        // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
326        void strokeArc(const IntRect&, int startAngle, int angleSpan);
327
328        void fillRect(const FloatRect&);
329        void fillRect(const FloatRect&, const Color&, ColorSpace);
330        void fillRect(const FloatRect&, Generator&);
331        void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
332        void fillRoundedRect(const RoundedIntRect&, const Color&, ColorSpace);
333        void fillRectWithRoundedHole(const IntRect&, const RoundedIntRect& roundedHoleRect, const Color&, ColorSpace);
334
335        void clearRect(const FloatRect&);
336
337        void strokeRect(const FloatRect&, float lineWidth);
338
339        void drawImage(Image*, ColorSpace styleColorSpace, const IntPoint&, CompositeOperator = CompositeSourceOver);
340        void drawImage(Image*, ColorSpace styleColorSpace, const IntRect&, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
341        void drawImage(Image*, ColorSpace styleColorSpace, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver);
342        void drawImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
343        void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
344                       CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
345        void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize,
346                       CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
347        void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect,
348                            Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
349                            CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
350
351        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint&, CompositeOperator = CompositeSourceOver);
352        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntRect&, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
353        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver);
354        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
355        void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
356                             CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
357
358        void setImageInterpolationQuality(InterpolationQuality);
359        InterpolationQuality imageInterpolationQuality() const;
360
361        void clip(const IntRect&);
362        void clip(const FloatRect&);
363        void addRoundedRectClip(const RoundedIntRect&);
364        void addInnerRoundedRectClip(const IntRect&, int thickness);
365        void clipOut(const IntRect&);
366        void clipOutRoundedRect(const RoundedIntRect&);
367        void clipPath(const Path&, WindRule);
368        void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
369        void clipToImageBuffer(ImageBuffer*, const FloatRect&);
370
371        IntRect clipBounds() const;
372
373        TextDrawingModeFlags textDrawingMode() const;
374        void setTextDrawingMode(TextDrawingModeFlags);
375
376        void drawText(const Font&, const TextRun&, const FloatPoint&, int from = 0, int to = -1);
377        void drawEmphasisMarks(const Font&, const TextRun& , const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1);
378        void drawBidiText(const Font&, const TextRun&, const FloatPoint&);
379#if PLATFORM(ANDROID)
380        void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, int h, const Color& backgroundColor, ColorSpace, int from = 0, int to = -1, bool isActive = true);
381#else
382        void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, int h, const Color& backgroundColor, ColorSpace, int from = 0, int to = -1);
383#endif
384
385        enum RoundingMode {
386            RoundAllSides,
387            RoundOriginAndDimensions
388        };
389        FloatRect roundToDevicePixels(const FloatRect&, RoundingMode = RoundAllSides);
390
391        void drawLineForText(const FloatPoint&, float width, bool printing);
392        enum TextCheckingLineStyle {
393            TextCheckingSpellingLineStyle,
394            TextCheckingGrammarLineStyle,
395            TextCheckingReplacementLineStyle
396        };
397        void drawLineForTextChecking(const FloatPoint&, float width, TextCheckingLineStyle);
398
399        bool paintingDisabled() const;
400        void setPaintingDisabled(bool);
401
402        bool updatingControlTints() const;
403        void setUpdatingControlTints(bool);
404
405        void beginTransparencyLayer(float opacity);
406        void endTransparencyLayer();
407
408        bool hasShadow() const;
409        void setShadow(const FloatSize&, float blur, const Color&, ColorSpace);
410        // Legacy shadow blur radius is used for canvas, and -webkit-box-shadow.
411        // It has different treatment of radii > 8px.
412        void setLegacyShadow(const FloatSize&, float blur, const Color&, ColorSpace);
413
414        bool getShadow(FloatSize&, float&, Color&, ColorSpace&) const;
415        void clearShadow();
416
417        void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
418        void drawFocusRing(const Path&, int width, int offset, const Color&);
419
420        void setLineCap(LineCap);
421        void setLineDash(const DashArray&, float dashOffset);
422        void setLineJoin(LineJoin);
423        void setMiterLimit(float);
424
425        void setAlpha(float);
426#if USE(CAIRO)
427        float getAlpha();
428#endif
429
430        void setCompositeOperation(CompositeOperator);
431        CompositeOperator compositeOperation() const;
432
433        void clip(const Path&);
434
435        // This clip function is used only by <canvas> code. It allows
436        // implementations to handle clipping on the canvas differently since
437        // the discipline is different.
438        void canvasClip(const Path&);
439        void clipOut(const Path&);
440
441        void scale(const FloatSize&);
442        void rotate(float angleInRadians);
443        void translate(const FloatSize& size) { translate(size.width(), size.height()); }
444        void translate(float x, float y);
445
446        void setURLForRect(const KURL&, const IntRect&);
447
448        void concatCTM(const AffineTransform&);
449        void setCTM(const AffineTransform&);
450        AffineTransform getCTM() const;
451
452#if OS(WINCE) && !PLATFORM(QT)
453        void setBitmap(PassRefPtr<SharedBitmap>);
454        const AffineTransform& affineTransform() const;
455        AffineTransform& affineTransform();
456        void resetAffineTransform();
457        void fillRect(const FloatRect&, const Gradient*);
458        void drawText(const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point);
459        void drawFrameControl(const IntRect& rect, unsigned type, unsigned state);
460        void drawFocusRect(const IntRect& rect);
461        void paintTextField(const IntRect& rect, unsigned state);
462        void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp);
463        void drawBitmapPattern(SharedBitmap*, const FloatRect& tileRectIn, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize);
464        void drawIcon(HICON icon, const IntRect& dstRect, UINT flags);
465        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.
466        void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = false, bool mayCreateBitmap = true);    // The passed in HDC should be the one handed back by getWindowsContext.
467        void drawRoundCorner(bool newClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height);
468#elif PLATFORM(WIN)
469        GraphicsContext(HDC, bool hasAlpha = false); // FIXME: To be removed.
470        bool inTransparencyLayer() const;
471        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.
472        void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);    // The passed in HDC should be the one handed back by getWindowsContext.
473
474        // When set to true, child windows should be rendered into this context
475        // rather than allowing them just to render to the screen. Defaults to
476        // false.
477        // FIXME: This is a layering violation. GraphicsContext shouldn't know
478        // what a "window" is. It would be much more appropriate for this flag
479        // to be passed as a parameter alongside the GraphicsContext, but doing
480        // that would require lots of changes in cross-platform code that we
481        // aren't sure we want to make.
482        void setShouldIncludeChildWindows(bool);
483        bool shouldIncludeChildWindows() const;
484
485        class WindowsBitmap {
486            WTF_MAKE_NONCOPYABLE(WindowsBitmap);
487        public:
488            WindowsBitmap(HDC, IntSize);
489            ~WindowsBitmap();
490
491            HDC hdc() const { return m_hdc; }
492            UInt8* buffer() const { return m_pixelData.buffer(); }
493            unsigned bufferLength() const { return m_pixelData.bufferLength(); }
494            const IntSize& size() const { return m_pixelData.size(); }
495            unsigned bytesPerRow() const { return m_pixelData.bytesPerRow(); }
496            unsigned short bitsPerPixel() const { return m_pixelData.bitsPerPixel(); }
497            const DIBPixelData& windowsDIB() const { return m_pixelData; }
498
499        private:
500            HDC m_hdc;
501            HBITMAP m_bitmap;
502            DIBPixelData m_pixelData;
503        };
504
505        WindowsBitmap* createWindowsBitmap(IntSize);
506        // The bitmap should be non-premultiplied.
507        void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
508#endif
509
510#if (PLATFORM(QT) && defined(Q_WS_WIN)) || (PLATFORM(WX) && OS(WINDOWS))
511        HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
512        void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
513        bool shouldIncludeChildWindows() const { return false; }
514#endif
515
516#if PLATFORM(WX)
517        bool inTransparencyLayer() const { return false; }
518#endif
519
520#if PLATFORM(QT)
521        bool inTransparencyLayer() const;
522        void pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask);
523        void takeOwnershipOfPlatformContext();
524#endif
525
526#if PLATFORM(QT) || USE(CAIRO)
527        ContextShadow* contextShadow();
528#endif
529
530#if USE(CAIRO)
531        GraphicsContext(cairo_t*);
532#endif
533
534#if PLATFORM(GTK)
535        void setGdkExposeEvent(GdkEventExpose*);
536        GdkWindow* gdkWindow() const;
537        GdkEventExpose* gdkExposeEvent() const;
538#endif
539
540#if PLATFORM(HAIKU)
541        pattern getHaikuStrokeStyle();
542#endif
543
544        void setSharedGraphicsContext3D(SharedGraphicsContext3D*, DrawingBuffer*, const IntSize&);
545        void syncSoftwareCanvas();
546        void markDirtyRect(const IntRect&); // Hints that a portion of the backing store is dirty.
547
548    private:
549        void platformInit(PlatformGraphicsContext*);
550        void platformDestroy();
551
552#if PLATFORM(WIN) && !OS(WINCE)
553        void platformInit(HDC, bool hasAlpha = false);
554#endif
555
556        void savePlatformState();
557        void restorePlatformState();
558
559        void setPlatformTextDrawingMode(TextDrawingModeFlags);
560        void setPlatformFont(const Font& font);
561
562        void setPlatformStrokeColor(const Color&, ColorSpace);
563        void setPlatformStrokeStyle(StrokeStyle);
564        void setPlatformStrokeThickness(float);
565        void setPlatformStrokeGradient(Gradient*);
566        void setPlatformStrokePattern(Pattern*);
567
568        void setPlatformFillColor(const Color&, ColorSpace);
569        void setPlatformFillGradient(Gradient*);
570        void setPlatformFillPattern(Pattern*);
571
572        void setPlatformShouldAntialias(bool);
573        void setPlatformShouldSmoothFonts(bool);
574
575        void setPlatformShadow(const FloatSize&, float blur, const Color&, ColorSpace);
576        void clearPlatformShadow();
577
578        void setPlatformCompositeOperation(CompositeOperator);
579
580        static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle);
581
582        GraphicsContextPlatformPrivate* m_data;
583
584        GraphicsContextState m_state;
585        Vector<GraphicsContextState> m_stack;
586        bool m_updatingControlTints;
587    };
588
589} // namespace WebCore
590
591#endif // GraphicsContext_h
592