2 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2008-2009 Torch Mobile, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
14 * THIS SOFTWARE IS PROVIDED BY APPLE 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 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.
27 #ifndef GraphicsContext_h
28 #define GraphicsContext_h
30 #include "ColorSpace.h"
31 #include "DashArray.h"
32 #include "FloatRect.h"
36 #include "ImageOrientation.h"
39 #include <wtf/Noncopyable.h>
40 #include <wtf/PassOwnPtr.h>
43 typedef struct CGContext PlatformGraphicsContext;
46 class PlatformContextCairo;
48 typedef WebCore::PlatformContextCairo PlatformGraphicsContext;
50 typedef struct HDC__ PlatformGraphicsContext;
52 typedef void PlatformGraphicsContext;
56 #include "DIBPixelData.h"
57 typedef struct HDC__* HDC;
59 // UInt8 is defined in CoreFoundation/CFBase.h
60 typedef unsigned char UInt8;
72 const int cMisspellingLineThickness = 3;
73 const int cMisspellingLinePatternWidth = 4;
74 const int cMisspellingLinePatternGapWidth = 1;
76 class AffineTransform;
78 class FloatRoundedRect;
80 class GraphicsContextPlatformPrivate;
85 class GraphicsContext3D;
87 class TransformationMatrix;
92 enum TextDrawingMode {
93 TextModeFill = 1 << 0,
94 TextModeStroke = 1 << 1,
95 #if ENABLE(LETTERPRESS)
96 TextModeLetterpress = 1 << 2,
99 typedef unsigned TextDrawingModeFlags;
110 enum InterpolationQuality {
111 InterpolationDefault,
118 struct GraphicsContextState {
119 GraphicsContextState()
122 , textDrawingMode(TextModeFill)
123 , strokeColor(Color::black)
124 , fillColor(Color::black)
125 , strokeStyle(SolidStroke)
126 , fillRule(RULE_NONZERO)
127 , strokeColorSpace(ColorSpaceDeviceRGB)
128 , fillColorSpace(ColorSpaceDeviceRGB)
129 , shadowColorSpace(ColorSpaceDeviceRGB)
130 , compositeOperator(CompositeSourceOver)
131 , blendMode(BlendModeNormal)
133 , emojiDrawingEnabled(true)
134 , shouldUseContextColors(true)
136 , shouldAntialias(true)
137 , shouldSmoothFonts(true)
138 , shouldSubpixelQuantizeFonts(true)
139 , paintingDisabled(false)
140 , shadowsIgnoreTransforms(false)
142 // Core Graphics incorrectly renders shadows with radius > 8px (<rdar://problem/8103442>),
143 // but we need to preserve this buggy behavior for canvas and -webkit-box-shadow.
144 , shadowsUseLegacyRadius(false)
146 , drawLuminanceMask(false)
150 RefPtr<Gradient> strokeGradient;
151 RefPtr<Pattern> strokePattern;
153 RefPtr<Gradient> fillGradient;
154 RefPtr<Pattern> fillPattern;
156 FloatSize shadowOffset;
158 float strokeThickness;
161 TextDrawingModeFlags textDrawingMode;
167 StrokeStyle strokeStyle;
170 ColorSpace strokeColorSpace;
171 ColorSpace fillColorSpace;
172 ColorSpace shadowColorSpace;
174 CompositeOperator compositeOperator;
178 bool emojiDrawingEnabled : 1;
179 bool shouldUseContextColors : 1;
181 bool shouldAntialias : 1;
182 bool shouldSmoothFonts : 1;
183 bool shouldSubpixelQuantizeFonts : 1;
184 bool paintingDisabled : 1;
185 bool shadowsIgnoreTransforms : 1;
187 bool shadowsUseLegacyRadius : 1;
189 bool drawLuminanceMask : 1;
193 WEBCORE_EXPORT void setStrokeAndFillColor(PlatformGraphicsContext*, CGColorRef);
196 struct ImagePaintingOptions {
197 ImagePaintingOptions(CompositeOperator compositeOperator = CompositeSourceOver, BlendMode blendMode = BlendModeNormal, ImageOrientationDescription orientationDescription = ImageOrientationDescription(), bool useLowQualityScale = false)
198 : m_compositeOperator(compositeOperator)
199 , m_blendMode(blendMode)
200 , m_orientationDescription(orientationDescription)
201 , m_useLowQualityScale(useLowQualityScale)
205 ImagePaintingOptions(ImageOrientationDescription orientationDescription, bool useLowQualityScale = false, CompositeOperator compositeOperator = CompositeSourceOver, BlendMode blendMode = BlendModeNormal)
206 : m_compositeOperator(compositeOperator)
207 , m_blendMode(blendMode)
208 , m_orientationDescription(orientationDescription)
209 , m_useLowQualityScale(useLowQualityScale)
213 ImagePaintingOptions(bool useLowQualityScale, ImageOrientationDescription orientationDescription = ImageOrientationDescription(), CompositeOperator compositeOperator = CompositeSourceOver, BlendMode blendMode = BlendModeNormal)
214 : m_compositeOperator(compositeOperator)
215 , m_blendMode(blendMode)
216 , m_orientationDescription(orientationDescription)
217 , m_useLowQualityScale(useLowQualityScale)
221 CompositeOperator m_compositeOperator;
222 BlendMode m_blendMode;
223 ImageOrientationDescription m_orientationDescription;
224 bool m_useLowQualityScale;
227 class GraphicsContext {
228 WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED;
231 WEBCORE_EXPORT GraphicsContext(PlatformGraphicsContext*);
233 WEBCORE_EXPORT GraphicsContext(PlatformGraphicsContext*, bool shouldUseContextColors = true);
235 WEBCORE_EXPORT ~GraphicsContext();
237 WEBCORE_EXPORT PlatformGraphicsContext* platformContext() const;
239 float strokeThickness() const;
240 void setStrokeThickness(float);
241 StrokeStyle strokeStyle() const;
242 void setStrokeStyle(StrokeStyle);
243 Color strokeColor() const;
244 ColorSpace strokeColorSpace() const;
245 WEBCORE_EXPORT void setStrokeColor(const Color&, ColorSpace);
247 void setStrokePattern(PassRefPtr<Pattern>);
248 Pattern* strokePattern() const;
250 void setStrokeGradient(PassRefPtr<Gradient>);
251 Gradient* strokeGradient() const;
253 WindRule fillRule() const;
254 void setFillRule(WindRule);
255 Color fillColor() const;
256 ColorSpace fillColorSpace() const;
257 WEBCORE_EXPORT void setFillColor(const Color&, ColorSpace);
259 void setFillPattern(PassRefPtr<Pattern>);
260 Pattern* fillPattern() const;
262 WEBCORE_EXPORT void setFillGradient(PassRefPtr<Gradient>);
263 Gradient* fillGradient() const;
265 void setShadowsIgnoreTransforms(bool);
266 bool shadowsIgnoreTransforms() const;
268 WEBCORE_EXPORT void setShouldAntialias(bool);
269 bool shouldAntialias() const;
271 WEBCORE_EXPORT void setShouldSmoothFonts(bool);
272 bool shouldSmoothFonts() const;
274 // Normally CG enables subpixel-quantization because it improves the performance of aligning glyphs.
275 // In some cases we have to disable to to ensure a high-quality output of the glyphs.
276 void setShouldSubpixelQuantizeFonts(bool);
277 bool shouldSubpixelQuantizeFonts() const;
279 const GraphicsContextState& state() const;
282 void applyStrokePattern();
283 void applyFillPattern();
284 void drawPath(const Path&);
286 WEBCORE_EXPORT void drawNativeImage(PassNativeImagePtr, const FloatSize& selfSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
288 // Allow font smoothing (LCD antialiasing). Not part of the graphics state.
289 void setAllowsFontSmoothing(bool);
291 WEBCORE_EXPORT void setIsCALayerContext(bool);
292 bool isCALayerContext() const;
294 WEBCORE_EXPORT void setIsAcceleratedContext(bool);
296 bool isAcceleratedContext() const;
298 WEBCORE_EXPORT void save();
299 WEBCORE_EXPORT void restore();
301 // These draw methods will do both stroking and filling.
302 // FIXME: ...except drawRect(), which fills properly but always strokes
303 // using a 1-pixel stroke inset from the rect borders (of the correct
305 void drawRect(const FloatRect&, float borderThickness = 1);
306 void drawLine(const FloatPoint&, const FloatPoint&);
309 void drawJoinedLines(CGPoint points[], unsigned count, bool antialias, CGLineCap = kCGLineCapButt);
312 void drawEllipse(const IntRect&);
314 void drawEllipse(const FloatRect&);
315 void drawRaisedEllipse(const FloatRect&, const Color& ellipseColor, ColorSpace ellipseColorSpace, const Color& shadowColor, ColorSpace shadowColorSpace);
317 void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
319 WEBCORE_EXPORT void fillPath(const Path&);
320 void strokePath(const Path&);
322 void fillEllipse(const FloatRect&);
323 void strokeEllipse(const FloatRect&);
325 WEBCORE_EXPORT void fillRect(const FloatRect&);
326 WEBCORE_EXPORT void fillRect(const FloatRect&, const Color&, ColorSpace);
327 void fillRect(const FloatRect&, Gradient&);
328 void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator, BlendMode = BlendModeNormal);
329 void fillRoundedRect(const FloatRoundedRect&, const Color&, ColorSpace, BlendMode = BlendModeNormal);
330 void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&, ColorSpace);
332 WEBCORE_EXPORT void clearRect(const FloatRect&);
334 WEBCORE_EXPORT void strokeRect(const FloatRect&, float lineWidth);
336 WEBCORE_EXPORT void drawImage(Image*, ColorSpace, const FloatPoint& destination, const ImagePaintingOptions& = ImagePaintingOptions());
337 void drawImage(Image*, ColorSpace, const FloatRect& destination, const ImagePaintingOptions& = ImagePaintingOptions());
338 void drawImage(Image*, ColorSpace, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = ImagePaintingOptions());
340 void drawTiledImage(Image*, ColorSpace, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize,
341 const ImagePaintingOptions& = ImagePaintingOptions());
342 void drawTiledImage(Image*, ColorSpace, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor,
343 Image::TileRule, Image::TileRule, const ImagePaintingOptions& = ImagePaintingOptions());
345 void drawImageBuffer(ImageBuffer*, ColorSpace, const FloatPoint& destination, const ImagePaintingOptions& = ImagePaintingOptions());
346 void drawImageBuffer(ImageBuffer*, ColorSpace, const FloatRect& destination, const ImagePaintingOptions& = ImagePaintingOptions());
347 void drawImageBuffer(ImageBuffer*, ColorSpace, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = ImagePaintingOptions());
349 WEBCORE_EXPORT void setImageInterpolationQuality(InterpolationQuality);
350 InterpolationQuality imageInterpolationQuality() const;
352 WEBCORE_EXPORT void clip(const IntRect&);
353 WEBCORE_EXPORT void clip(const FloatRect&);
354 void clipRoundedRect(const FloatRoundedRect&);
356 void clipOut(const FloatRect&);
357 void clipOutRoundedRect(const FloatRoundedRect&);
358 void clipPath(const Path&, WindRule);
359 void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
360 void clipToImageBuffer(ImageBuffer*, const FloatRect&);
362 IntRect clipBounds() const;
364 TextDrawingModeFlags textDrawingMode() const;
365 void setTextDrawingMode(TextDrawingModeFlags);
368 bool emojiDrawingEnabled();
369 WEBCORE_EXPORT void setEmojiDrawingEnabled(bool);
373 void drawText(const Font&, const TextRun&, const FloatPoint&, int from = 0, int to = -1);
375 float drawText(const Font&, const TextRun&, const FloatPoint&, int from = 0, int to = -1);
377 void drawGlyphs(const Font&, const SimpleFontData&, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint&);
378 void drawEmphasisMarks(const Font&, const TextRun& , const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1);
380 void drawBidiText(const Font&, const TextRun&, const FloatPoint&, Font::CustomFontNotReadyAction = Font::DoNotPaintIfFontNotReady);
382 WEBCORE_EXPORT float drawBidiText(const Font&, const TextRun&, const FloatPoint&, Font::CustomFontNotReadyAction = Font::DoNotPaintIfFontNotReady, BidiStatus* = 0, int length = -1);
386 RoundOriginAndDimensions
388 FloatRect roundToDevicePixels(const FloatRect&, RoundingMode = RoundAllSides);
390 FloatRect computeLineBoundsForText(const FloatPoint&, float width, bool printing);
391 WEBCORE_EXPORT void drawLineForText(const FloatPoint&, float width, bool printing, bool doubleLines = false);
392 void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines = false);
393 enum DocumentMarkerLineStyle {
395 TextCheckingDictationPhraseWithAlternativesLineStyle,
397 DocumentMarkerSpellingLineStyle,
398 DocumentMarkerGrammarLineStyle,
399 DocumentMarkerAutocorrectionReplacementLineStyle,
400 DocumentMarkerDictationAlternativesLineStyle
402 static void updateDocumentMarkerResources();
403 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarkerLineStyle);
405 WEBCORE_EXPORT bool paintingDisabled() const;
406 void setPaintingDisabled(bool);
408 WEBCORE_EXPORT bool updatingControlTints() const;
409 void setUpdatingControlTints(bool);
411 WEBCORE_EXPORT void beginTransparencyLayer(float opacity);
412 WEBCORE_EXPORT void endTransparencyLayer();
413 bool isInTransparencyLayer() const;
415 bool hasShadow() const;
416 WEBCORE_EXPORT void setShadow(const FloatSize&, float blur, const Color&, ColorSpace);
417 // Legacy shadow blur radius is used for canvas, and -webkit-box-shadow.
418 // It has different treatment of radii > 8px.
419 void setLegacyShadow(const FloatSize&, float blur, const Color&, ColorSpace);
421 bool getShadow(FloatSize&, float&, Color&, ColorSpace&) const;
422 WEBCORE_EXPORT void clearShadow();
424 bool hasBlurredShadow() const;
426 bool mustUseShadowBlur() const;
429 void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
430 void drawFocusRing(const Path&, int width, int offset, const Color&);
432 void drawFocusRing(const Vector<IntRect>&, int width, int offset, double timeOffset, bool& needsRedraw);
435 void setLineCap(LineCap);
436 void setLineDash(const DashArray&, float dashOffset);
437 void setLineJoin(LineJoin);
438 void setMiterLimit(float);
440 void setAlpha(float);
442 WEBCORE_EXPORT void setCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal);
443 CompositeOperator compositeOperation() const;
444 BlendMode blendModeOperation() const;
446 void setDrawLuminanceMask(bool);
447 bool drawLuminanceMask() const;
449 WEBCORE_EXPORT void clip(const Path&, WindRule = RULE_EVENODD);
451 // This clip function is used only by <canvas> code. It allows
452 // implementations to handle clipping on the canvas differently since
453 // the discipline is different.
454 void canvasClip(const Path&, WindRule = RULE_EVENODD);
455 void clipOut(const Path&);
457 WEBCORE_EXPORT void scale(const FloatSize&);
458 void rotate(float angleInRadians);
459 void translate(const FloatSize& size) { translate(size.width(), size.height()); }
460 WEBCORE_EXPORT void translate(float x, float y);
462 void setURLForRect(const URL&, const IntRect&);
464 void concatCTM(const AffineTransform&);
465 void setCTM(const AffineTransform&);
467 enum IncludeDeviceScale { DefinitelyIncludeDeviceScale, PossiblyIncludeDeviceScale };
468 AffineTransform getCTM(IncludeDeviceScale includeScale = PossiblyIncludeDeviceScale) const;
470 #if ENABLE(3D_RENDERING) && USE(TEXTURE_MAPPER)
471 // This is needed when using accelerated-compositing in software mode, like in TextureMapper.
472 void concat3DTransform(const TransformationMatrix&);
473 void set3DTransform(const TransformationMatrix&);
474 TransformationMatrix get3DTransform() const;
476 // Create an image buffer compatible with this context, with suitable resolution
477 // for drawing into the buffer and then into this context.
478 std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, bool hasAlpha = true) const;
479 bool isCompatibleWithBuffer(ImageBuffer*) const;
481 // This function applies the device scale factor to the context, making the context capable of
482 // acting as a base-level context for a HiDPI environment.
483 WEBCORE_EXPORT void applyDeviceScaleFactor(float);
484 void platformApplyDeviceScaleFactor(float);
487 HDC getWindowsContext(const IntRect&, bool supportAlphaBlend, bool mayCreateBitmap); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
488 void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend, bool mayCreateBitmap); // The passed in HDC should be the one handed back by getWindowsContext.
491 void setBitmap(PassRefPtr<SharedBitmap>);
492 const AffineTransform& affineTransform() const;
493 AffineTransform& affineTransform();
494 void resetAffineTransform();
495 void fillRect(const FloatRect&, const Gradient*);
496 void drawText(const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point);
497 void drawFrameControl(const IntRect& rect, unsigned type, unsigned state);
498 void drawFocusRect(const IntRect& rect);
499 void paintTextField(const IntRect& rect, unsigned state);
500 void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode);
501 void drawBitmapPattern(SharedBitmap*, const FloatRect& tileRectIn, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize);
502 void drawIcon(HICON icon, const IntRect& dstRect, UINT flags);
503 void drawRoundCorner(bool newClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height);
505 GraphicsContext(HDC, bool hasAlpha = false); // FIXME: To be removed.
507 // When set to true, child windows should be rendered into this context
508 // rather than allowing them just to render to the screen. Defaults to
510 // FIXME: This is a layering violation. GraphicsContext shouldn't know
511 // what a "window" is. It would be much more appropriate for this flag
512 // to be passed as a parameter alongside the GraphicsContext, but doing
513 // that would require lots of changes in cross-platform code that we
514 // aren't sure we want to make.
515 void setShouldIncludeChildWindows(bool);
516 bool shouldIncludeChildWindows() const;
518 class WindowsBitmap {
519 WTF_MAKE_NONCOPYABLE(WindowsBitmap);
521 WindowsBitmap(HDC, const IntSize&);
524 HDC hdc() const { return m_hdc; }
525 UInt8* buffer() const { return m_pixelData.buffer(); }
526 unsigned bufferLength() const { return m_pixelData.bufferLength(); }
527 const IntSize& size() const { return m_pixelData.size(); }
528 unsigned bytesPerRow() const { return m_pixelData.bytesPerRow(); }
529 unsigned short bitsPerPixel() const { return m_pixelData.bitsPerPixel(); }
530 const DIBPixelData& windowsDIB() const { return m_pixelData; }
535 DIBPixelData m_pixelData;
538 PassOwnPtr<WindowsBitmap> createWindowsBitmap(const IntSize&);
539 // The bitmap should be non-premultiplied.
540 void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
542 #else // PLATFORM(WIN)
543 bool shouldIncludeChildWindows() const { return false; }
544 #endif // PLATFORM(WIN)
545 #endif // OS(WINDOWS)
548 GraphicsContext(cairo_t*);
552 void setGdkExposeEvent(GdkEventExpose*);
553 GdkWindow* gdkWindow() const;
554 GdkEventExpose* gdkExposeEvent() const;
557 static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle);
560 void platformInit(PlatformGraphicsContext*, bool shouldUseContextColors = false);
561 void platformDestroy();
563 #if PLATFORM(WIN) && !USE(WINGDI)
564 void platformInit(HDC, bool hasAlpha = false);
567 void savePlatformState();
568 void restorePlatformState();
570 void setPlatformTextDrawingMode(TextDrawingModeFlags);
572 void setPlatformStrokeColor(const Color&, ColorSpace);
573 void setPlatformStrokeStyle(StrokeStyle);
574 void setPlatformStrokeThickness(float);
576 void setPlatformFillColor(const Color&, ColorSpace);
578 void setPlatformShouldAntialias(bool);
579 void setPlatformShouldSmoothFonts(bool);
581 void setPlatformShadow(const FloatSize&, float blur, const Color&, ColorSpace);
582 void clearPlatformShadow();
584 void setPlatformCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal);
586 void beginPlatformTransparencyLayer(float opacity);
587 void endPlatformTransparencyLayer();
588 static bool supportsTransparencyLayers();
590 void fillEllipseAsPath(const FloatRect&);
591 void strokeEllipseAsPath(const FloatRect&);
593 void platformFillEllipse(const FloatRect&);
594 void platformStrokeEllipse(const FloatRect&);
596 void platformFillRoundedRect(const FloatRoundedRect&, const Color&, ColorSpace);
598 FloatRect computeLineBoundsAndAntialiasingModeForText(const FloatPoint&, float width, bool printing, bool& shouldAntialias, Color&);
600 GraphicsContextPlatformPrivate* m_data;
602 GraphicsContextState m_state;
603 Vector<GraphicsContextState> m_stack;
604 bool m_updatingControlTints;
605 unsigned m_transparencyCount;
608 class GraphicsContextStateSaver {
609 WTF_MAKE_FAST_ALLOCATED;
611 GraphicsContextStateSaver(GraphicsContext& context, bool saveAndRestore = true)
613 , m_saveAndRestore(saveAndRestore)
615 if (m_saveAndRestore)
619 ~GraphicsContextStateSaver()
621 if (m_saveAndRestore)
627 ASSERT(!m_saveAndRestore);
629 m_saveAndRestore = true;
634 ASSERT(m_saveAndRestore);
636 m_saveAndRestore = false;
639 GraphicsContext* context() const { return &m_context; }
642 GraphicsContext& m_context;
643 bool m_saveAndRestore;
646 } // namespace WebCore
648 #endif // GraphicsContext_h