Changeset 191118 in webkit


Ignore:
Timestamp:
Oct 15, 2015, 10:23:32 AM (10 years ago)
Author:
Simon Fraser
Message:

Un-indent contents of the WebCore namespace
in GraphicsContext.h. No code changes.

  • platform/graphics/GraphicsContext.h:
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r191117 r191118  
     12015-10-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Un-indent contents of the WebCore namespace
     4        in GraphicsContext.h. No code changes.
     5
     6        * platform/graphics/GraphicsContext.h:
     7
    182015-10-14  Simon Fraser  <simon.fraser@apple.com>
    29
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r191117 r191118  
    6565
    6666#if USE(WINGDI)
    67     class SharedBitmap;
    68     class Font;
    69     class GlyphBuffer;
    70 #endif
    71 
    72     const int cMisspellingLineThickness = 3;
    73     const int cMisspellingLinePatternWidth = 4;
    74     const int cMisspellingLinePatternGapWidth = 1;
    75 
    76     class AffineTransform;
    77     class FloatRoundedRect;
    78     class Gradient;
    79     class GraphicsContextPlatformPrivate;
    80     class ImageBuffer;
    81     class IntRect;
    82     class RoundedRect;
    83     class URL;
    84     class GraphicsContext3D;
    85     class TextRun;
    86     class TransformationMatrix;
    87 
    88     enum TextDrawingMode {
    89         TextModeFill = 1 << 0,
    90         TextModeStroke = 1 << 1,
     67class SharedBitmap;
     68class Font;
     69class GlyphBuffer;
     70#endif
     71
     72const int cMisspellingLineThickness = 3;
     73const int cMisspellingLinePatternWidth = 4;
     74const int cMisspellingLinePatternGapWidth = 1;
     75
     76class AffineTransform;
     77class FloatRoundedRect;
     78class Gradient;
     79class GraphicsContextPlatformPrivate;
     80class ImageBuffer;
     81class IntRect;
     82class RoundedRect;
     83class URL;
     84class GraphicsContext3D;
     85class TextRun;
     86class TransformationMatrix;
     87
     88enum TextDrawingMode {
     89    TextModeFill = 1 << 0,
     90    TextModeStroke = 1 << 1,
    9191#if ENABLE(LETTERPRESS)
    92         TextModeLetterpress = 1 << 2,
    93 #endif
     92    TextModeLetterpress = 1 << 2,
     93#endif
     94};
     95typedef unsigned TextDrawingModeFlags;
     96
     97enum StrokeStyle {
     98    NoStroke,
     99    SolidStroke,
     100    DottedStroke,
     101    DashedStroke,
     102    DoubleStroke,
     103    WavyStroke,
     104};
     105
     106enum InterpolationQuality {
     107    InterpolationDefault,
     108    InterpolationNone,
     109    InterpolationLow,
     110    InterpolationMedium,
     111    InterpolationHigh
     112};
     113
     114struct GraphicsContextState {
     115    GraphicsContextState()
     116        : shouldAntialias(true)
     117        , shouldSmoothFonts(true)
     118        , antialiasedFontDilationEnabled(true)
     119        , shouldSubpixelQuantizeFonts(true)
     120        , paintingDisabled(false)
     121        , shadowsIgnoreTransforms(false)
     122#if USE(CG)
     123        // Core Graphics incorrectly renders shadows with radius > 8px (<rdar://problem/8103442>),
     124        // but we need to preserve this buggy behavior for canvas and -webkit-box-shadow.
     125        , shadowsUseLegacyRadius(false)
     126#endif
     127        , drawLuminanceMask(false)
     128    {
     129    }
     130
     131    RefPtr<Gradient> strokeGradient;
     132    RefPtr<Pattern> strokePattern;
     133   
     134    RefPtr<Gradient> fillGradient;
     135    RefPtr<Pattern> fillPattern;
     136
     137    FloatSize shadowOffset;
     138
     139    float strokeThickness { 0 };
     140    float shadowBlur { 0 };
     141
     142    TextDrawingModeFlags textDrawingMode { TextModeFill };
     143
     144    Color strokeColor { Color::black };
     145    Color fillColor { Color::black };
     146    Color shadowColor;
     147
     148    StrokeStyle strokeStyle { SolidStroke };
     149    WindRule fillRule { RULE_NONZERO };
     150
     151    ColorSpace strokeColorSpace { ColorSpaceDeviceRGB };
     152    ColorSpace fillColorSpace { ColorSpaceDeviceRGB };
     153    ColorSpace shadowColorSpace { ColorSpaceDeviceRGB };
     154
     155    float alpha { 1 };
     156    CompositeOperator compositeOperator { CompositeSourceOver };
     157    BlendMode blendMode { BlendModeNormal };
     158
     159    bool shouldAntialias : 1;
     160    bool shouldSmoothFonts : 1;
     161    bool antialiasedFontDilationEnabled : 1;
     162    bool shouldSubpixelQuantizeFonts : 1;
     163    bool paintingDisabled : 1;
     164    bool shadowsIgnoreTransforms : 1;
     165#if USE(CG)
     166    bool shadowsUseLegacyRadius : 1;
     167#endif
     168    bool drawLuminanceMask : 1;
     169};
     170
     171struct ImagePaintingOptions {
     172    ImagePaintingOptions(CompositeOperator compositeOperator = CompositeSourceOver, BlendMode blendMode = BlendModeNormal, ImageOrientationDescription orientationDescription = ImageOrientationDescription(), bool useLowQualityScale = false)
     173        : m_compositeOperator(compositeOperator)
     174        , m_blendMode(blendMode)
     175        , m_orientationDescription(orientationDescription)
     176        , m_useLowQualityScale(useLowQualityScale)
     177    {
     178    }
     179
     180    ImagePaintingOptions(ImageOrientationDescription orientationDescription, bool useLowQualityScale = false, CompositeOperator compositeOperator = CompositeSourceOver, BlendMode blendMode = BlendModeNormal)
     181        : m_compositeOperator(compositeOperator)
     182        , m_blendMode(blendMode)
     183        , m_orientationDescription(orientationDescription)
     184        , m_useLowQualityScale(useLowQualityScale)
     185    {
     186    }
     187
     188    ImagePaintingOptions(bool useLowQualityScale, ImageOrientationDescription orientationDescription = ImageOrientationDescription(), CompositeOperator compositeOperator = CompositeSourceOver, BlendMode blendMode = BlendModeNormal)
     189        : m_compositeOperator(compositeOperator)
     190        , m_blendMode(blendMode)
     191        , m_orientationDescription(orientationDescription)
     192        , m_useLowQualityScale(useLowQualityScale)
     193    {
     194    }
     195
     196    CompositeOperator m_compositeOperator;
     197    BlendMode m_blendMode;
     198    ImageOrientationDescription m_orientationDescription;
     199    bool m_useLowQualityScale;
     200};
     201
     202class GraphicsContext {
     203    WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED;
     204public:
     205    WEBCORE_EXPORT GraphicsContext(PlatformGraphicsContext*);
     206    WEBCORE_EXPORT ~GraphicsContext();
     207
     208    WEBCORE_EXPORT PlatformGraphicsContext* platformContext() const;
     209
     210    void setStrokeThickness(float);
     211    float strokeThickness() const { return m_state.strokeThickness; }
     212
     213    void setStrokeStyle(StrokeStyle);
     214    StrokeStyle strokeStyle() const { return m_state.strokeStyle; }
     215
     216    WEBCORE_EXPORT void setStrokeColor(const Color&, ColorSpace);
     217    Color strokeColor() const { return m_state.strokeColor; }
     218    ColorSpace strokeColorSpace() const { return m_state.strokeColorSpace; }
     219
     220    void setStrokePattern(Ref<Pattern>&&);
     221    Pattern* strokePattern() const { return m_state.strokePattern.get(); }
     222
     223    void setStrokeGradient(Ref<Gradient>&&);
     224    Gradient* strokeGradient() const { return m_state.strokeGradient.get(); }
     225
     226    void setFillRule(WindRule fillRule) { m_state.fillRule = fillRule; }
     227    WindRule fillRule() const { return m_state.fillRule; }
     228
     229    WEBCORE_EXPORT void setFillColor(const Color&, ColorSpace);
     230    Color fillColor() const { return m_state.fillColor; }
     231    ColorSpace fillColorSpace() const { return m_state.fillColorSpace; }
     232
     233    void setFillPattern(Ref<Pattern>&&);
     234    Pattern* fillPattern() const { return m_state.fillPattern.get(); }
     235
     236    WEBCORE_EXPORT void setFillGradient(Ref<Gradient>&&);
     237    Gradient* fillGradient() const { return m_state.fillGradient.get(); }
     238
     239    void setShadowsIgnoreTransforms(bool shadowsIgnoreTransforms) { m_state.shadowsIgnoreTransforms = shadowsIgnoreTransforms; }
     240    bool shadowsIgnoreTransforms() const { return m_state.shadowsIgnoreTransforms; }
     241
     242    WEBCORE_EXPORT void setShouldAntialias(bool);
     243    bool shouldAntialias() const { return m_state.shouldAntialias; }
     244
     245    WEBCORE_EXPORT void setAntialiasedFontDilationEnabled(bool);
     246    bool antialiasedFontDilationEnabled() const { return m_state.antialiasedFontDilationEnabled; }
     247
     248    WEBCORE_EXPORT void setShouldSmoothFonts(bool);
     249    bool shouldSmoothFonts() const { return m_state.shouldSmoothFonts; }
     250
     251    // Normally CG enables subpixel-quantization because it improves the performance of aligning glyphs.
     252    // In some cases we have to disable to to ensure a high-quality output of the glyphs.
     253    void setShouldSubpixelQuantizeFonts(bool shouldSubpixelQuantizeFonts) { m_state.shouldSubpixelQuantizeFonts = shouldSubpixelQuantizeFonts; }
     254    bool shouldSubpixelQuantizeFonts() const { return m_state.shouldSubpixelQuantizeFonts; }
     255
     256    const GraphicsContextState& state() const { return m_state; }
     257
     258#if USE(CG)
     259    void applyStrokePattern();
     260    void applyFillPattern();
     261    void drawPath(const Path&);
     262
     263    WEBCORE_EXPORT void drawNativeImage(PassNativeImagePtr, const FloatSize& selfSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
     264
     265    void clipToNativeImage(PassNativeImagePtr, const FloatRect& destRect, const FloatSize& bufferSize);
     266
     267    // Allow font smoothing (LCD antialiasing). Not part of the graphics state.
     268    void setAllowsFontSmoothing(bool);
     269   
     270    WEBCORE_EXPORT void setIsCALayerContext(bool);
     271    bool isCALayerContext() const;
     272
     273    WEBCORE_EXPORT void setIsAcceleratedContext(bool);
     274#endif
     275    bool isAcceleratedContext() const;
     276    RenderingMode renderingMode() const { return isAcceleratedContext() ? Accelerated : Unaccelerated; }
     277
     278    WEBCORE_EXPORT void save();
     279    WEBCORE_EXPORT void restore();
     280
     281    // These draw methods will do both stroking and filling.
     282    // FIXME: ...except drawRect(), which fills properly but always strokes
     283    // using a 1-pixel stroke inset from the rect borders (of the correct
     284    // stroke color).
     285    void drawRect(const FloatRect&, float borderThickness = 1);
     286    void drawLine(const FloatPoint&, const FloatPoint&);
     287
     288#if PLATFORM(IOS)
     289    void drawJoinedLines(CGPoint points[], unsigned count, bool antialias, CGLineCap = kCGLineCapButt);
     290#endif
     291
     292    void drawEllipse(const FloatRect&);
     293    void drawRaisedEllipse(const FloatRect&, const Color& ellipseColor, ColorSpace ellipseColorSpace, const Color& shadowColor, ColorSpace shadowColorSpace);
     294    void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
     295
     296    WEBCORE_EXPORT void fillPath(const Path&);
     297    void strokePath(const Path&);
     298
     299    void fillEllipse(const FloatRect&);
     300    void strokeEllipse(const FloatRect&);
     301
     302    WEBCORE_EXPORT void fillRect(const FloatRect&);
     303    WEBCORE_EXPORT void fillRect(const FloatRect&, const Color&, ColorSpace);
     304    void fillRect(const FloatRect&, Gradient&);
     305    void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator, BlendMode = BlendModeNormal);
     306    void fillRoundedRect(const FloatRoundedRect&, const Color&, ColorSpace, BlendMode = BlendModeNormal);
     307    void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&, ColorSpace);
     308
     309    WEBCORE_EXPORT void clearRect(const FloatRect&);
     310
     311    WEBCORE_EXPORT void strokeRect(const FloatRect&, float lineWidth);
     312
     313    WEBCORE_EXPORT void drawImage(Image&, ColorSpace, const FloatPoint& destination, const ImagePaintingOptions& = ImagePaintingOptions());
     314    WEBCORE_EXPORT void drawImage(Image&, ColorSpace, const FloatRect& destination, const ImagePaintingOptions& = ImagePaintingOptions());
     315    void drawImage(Image&, ColorSpace, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = ImagePaintingOptions());
     316
     317    void drawTiledImage(Image&, ColorSpace, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& = ImagePaintingOptions());
     318    void drawTiledImage(Image&, ColorSpace, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor,
     319        Image::TileRule, Image::TileRule, const ImagePaintingOptions& = ImagePaintingOptions());
     320
     321    WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, ColorSpace, const FloatPoint& destination, const ImagePaintingOptions& = ImagePaintingOptions());
     322    void drawImageBuffer(ImageBuffer&, ColorSpace, const FloatRect& destination, const ImagePaintingOptions& = ImagePaintingOptions());
     323    void drawImageBuffer(ImageBuffer&, ColorSpace, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = ImagePaintingOptions());
     324
     325    void drawPattern(Image&, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, ColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal);
     326
     327    WEBCORE_EXPORT void setImageInterpolationQuality(InterpolationQuality);
     328    InterpolationQuality imageInterpolationQuality() const;
     329
     330    WEBCORE_EXPORT void clip(const IntRect&);
     331    WEBCORE_EXPORT void clip(const FloatRect&);
     332    void clipRoundedRect(const FloatRoundedRect&);
     333
     334    void clipOut(const FloatRect&);
     335    void clipOutRoundedRect(const FloatRoundedRect&);
     336    void clipPath(const Path&, WindRule);
     337    void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
     338    void clipToImageBuffer(ImageBuffer&, const FloatRect&);
     339   
     340    IntRect clipBounds() const;
     341
     342    void setTextDrawingMode(TextDrawingModeFlags);
     343    TextDrawingModeFlags textDrawingMode() const { return m_state.textDrawingMode; }
     344
     345    float drawText(const FontCascade&, const TextRun&, const FloatPoint&, int from = 0, int to = -1);
     346    void drawGlyphs(const FontCascade&, const Font&, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint&);
     347    void drawEmphasisMarks(const FontCascade&, const TextRun& , const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1);
     348    void drawBidiText(const FontCascade&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction = FontCascade::DoNotPaintIfFontNotReady);
     349
     350    enum RoundingMode {
     351        RoundAllSides,
     352        RoundOriginAndDimensions
    94353    };
    95     typedef unsigned TextDrawingModeFlags;
    96 
    97     enum StrokeStyle {
    98         NoStroke,
    99         SolidStroke,
    100         DottedStroke,
    101         DashedStroke,
    102         DoubleStroke,
    103         WavyStroke,
     354    FloatRect roundToDevicePixels(const FloatRect&, RoundingMode = RoundAllSides);
     355
     356    FloatRect computeLineBoundsForText(const FloatPoint&, float width, bool printing);
     357    WEBCORE_EXPORT void drawLineForText(const FloatPoint&, float width, bool printing, bool doubleLines = false);
     358    void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines = false);
     359    enum DocumentMarkerLineStyle {
     360#if PLATFORM(IOS)
     361        TextCheckingDictationPhraseWithAlternativesLineStyle,
     362#endif
     363        DocumentMarkerSpellingLineStyle,
     364        DocumentMarkerGrammarLineStyle,
     365        DocumentMarkerAutocorrectionReplacementLineStyle,
     366        DocumentMarkerDictationAlternativesLineStyle
    104367    };
    105 
    106     enum InterpolationQuality {
    107         InterpolationDefault,
    108         InterpolationNone,
    109         InterpolationLow,
    110         InterpolationMedium,
    111         InterpolationHigh
    112     };
    113 
    114     struct GraphicsContextState {
    115         GraphicsContextState()
    116             : shouldAntialias(true)
    117             , shouldSmoothFonts(true)
    118             , antialiasedFontDilationEnabled(true)
    119             , shouldSubpixelQuantizeFonts(true)
    120             , paintingDisabled(false)
    121             , shadowsIgnoreTransforms(false)
    122 #if USE(CG)
    123             // Core Graphics incorrectly renders shadows with radius > 8px (<rdar://problem/8103442>),
    124             // but we need to preserve this buggy behavior for canvas and -webkit-box-shadow.
    125             , shadowsUseLegacyRadius(false)
    126 #endif
    127             , drawLuminanceMask(false)
    128         {
    129         }
    130 
    131         RefPtr<Gradient> strokeGradient;
    132         RefPtr<Pattern> strokePattern;
    133        
    134         RefPtr<Gradient> fillGradient;
    135         RefPtr<Pattern> fillPattern;
    136 
    137         FloatSize shadowOffset;
    138 
    139         float strokeThickness { 0 };
    140         float shadowBlur { 0 };
    141 
    142         TextDrawingModeFlags textDrawingMode { TextModeFill };
    143 
    144         Color strokeColor { Color::black };
    145         Color fillColor { Color::black };
    146         Color shadowColor;
    147 
    148         StrokeStyle strokeStyle { SolidStroke };
    149         WindRule fillRule { RULE_NONZERO };
    150 
    151         ColorSpace strokeColorSpace { ColorSpaceDeviceRGB };
    152         ColorSpace fillColorSpace { ColorSpaceDeviceRGB };
    153         ColorSpace shadowColorSpace { ColorSpaceDeviceRGB };
    154 
    155         float alpha { 1 };
    156         CompositeOperator compositeOperator { CompositeSourceOver };
    157         BlendMode blendMode { BlendModeNormal };
    158 
    159         bool shouldAntialias : 1;
    160         bool shouldSmoothFonts : 1;
    161         bool antialiasedFontDilationEnabled : 1;
    162         bool shouldSubpixelQuantizeFonts : 1;
    163         bool paintingDisabled : 1;
    164         bool shadowsIgnoreTransforms : 1;
    165 #if USE(CG)
    166         bool shadowsUseLegacyRadius : 1;
    167 #endif
    168         bool drawLuminanceMask : 1;
    169     };
    170 
    171     struct ImagePaintingOptions {
    172         ImagePaintingOptions(CompositeOperator compositeOperator = CompositeSourceOver, BlendMode blendMode = BlendModeNormal, ImageOrientationDescription orientationDescription = ImageOrientationDescription(), bool useLowQualityScale = false)
    173             : m_compositeOperator(compositeOperator)
    174             , m_blendMode(blendMode)
    175             , m_orientationDescription(orientationDescription)
    176             , m_useLowQualityScale(useLowQualityScale)
    177         {
    178         }
    179 
    180         ImagePaintingOptions(ImageOrientationDescription orientationDescription, bool useLowQualityScale = false, CompositeOperator compositeOperator = CompositeSourceOver, BlendMode blendMode = BlendModeNormal)
    181             : m_compositeOperator(compositeOperator)
    182             , m_blendMode(blendMode)
    183             , m_orientationDescription(orientationDescription)
    184             , m_useLowQualityScale(useLowQualityScale)
    185         {
    186         }
    187 
    188         ImagePaintingOptions(bool useLowQualityScale, ImageOrientationDescription orientationDescription = ImageOrientationDescription(), CompositeOperator compositeOperator = CompositeSourceOver, BlendMode blendMode = BlendModeNormal)
    189             : m_compositeOperator(compositeOperator)
    190             , m_blendMode(blendMode)
    191             , m_orientationDescription(orientationDescription)
    192             , m_useLowQualityScale(useLowQualityScale)
    193         {
    194         }
    195 
    196         CompositeOperator m_compositeOperator;
    197         BlendMode m_blendMode;
    198         ImageOrientationDescription m_orientationDescription;
    199         bool m_useLowQualityScale;
    200     };
    201 
    202     class GraphicsContext {
    203         WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED;
    204     public:
    205         WEBCORE_EXPORT GraphicsContext(PlatformGraphicsContext*);
    206         WEBCORE_EXPORT ~GraphicsContext();
    207 
    208         WEBCORE_EXPORT PlatformGraphicsContext* platformContext() const;
    209 
    210         void setStrokeThickness(float);
    211         float strokeThickness() const { return m_state.strokeThickness; }
    212 
    213         void setStrokeStyle(StrokeStyle);
    214         StrokeStyle strokeStyle() const { return m_state.strokeStyle; }
    215 
    216         WEBCORE_EXPORT void setStrokeColor(const Color&, ColorSpace);
    217         Color strokeColor() const { return m_state.strokeColor; }
    218         ColorSpace strokeColorSpace() const { return m_state.strokeColorSpace; }
    219 
    220         void setStrokePattern(Ref<Pattern>&&);
    221         Pattern* strokePattern() const { return m_state.strokePattern.get(); }
    222 
    223         void setStrokeGradient(Ref<Gradient>&&);
    224         Gradient* strokeGradient() const { return m_state.strokeGradient.get(); }
    225 
    226         void setFillRule(WindRule fillRule) { m_state.fillRule = fillRule; }
    227         WindRule fillRule() const { return m_state.fillRule; }
    228    
    229         WEBCORE_EXPORT void setFillColor(const Color&, ColorSpace);
    230         Color fillColor() const { return m_state.fillColor; }
    231         ColorSpace fillColorSpace() const { return m_state.fillColorSpace; }
    232 
    233         void setFillPattern(Ref<Pattern>&&);
    234         Pattern* fillPattern() const { return m_state.fillPattern.get(); }
    235 
    236         WEBCORE_EXPORT void setFillGradient(Ref<Gradient>&&);
    237         Gradient* fillGradient() const { return m_state.fillGradient.get(); }
    238 
    239         void setShadowsIgnoreTransforms(bool shadowsIgnoreTransforms) { m_state.shadowsIgnoreTransforms = shadowsIgnoreTransforms; }
    240         bool shadowsIgnoreTransforms() const { return m_state.shadowsIgnoreTransforms; }
    241 
    242         WEBCORE_EXPORT void setShouldAntialias(bool);
    243         bool shouldAntialias() const { return m_state.shouldAntialias; }
    244 
    245         WEBCORE_EXPORT void setAntialiasedFontDilationEnabled(bool);
    246         bool antialiasedFontDilationEnabled() const { return m_state.antialiasedFontDilationEnabled; }
    247 
    248         WEBCORE_EXPORT void setShouldSmoothFonts(bool);
    249         bool shouldSmoothFonts() const { return m_state.shouldSmoothFonts; }
    250 
    251         // Normally CG enables subpixel-quantization because it improves the performance of aligning glyphs.
    252         // In some cases we have to disable to to ensure a high-quality output of the glyphs.
    253         void setShouldSubpixelQuantizeFonts(bool shouldSubpixelQuantizeFonts) { m_state.shouldSubpixelQuantizeFonts = shouldSubpixelQuantizeFonts; }
    254         bool shouldSubpixelQuantizeFonts() const { return m_state.shouldSubpixelQuantizeFonts; }
    255 
    256         const GraphicsContextState& state() const { return m_state; }
    257 
    258 #if USE(CG)
    259         void applyStrokePattern();
    260         void applyFillPattern();
    261         void drawPath(const Path&);
    262 
    263         WEBCORE_EXPORT void drawNativeImage(PassNativeImagePtr, const FloatSize& selfSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
    264 
    265         void clipToNativeImage(PassNativeImagePtr, const FloatRect& destRect, const FloatSize& bufferSize);
    266 
    267         // Allow font smoothing (LCD antialiasing). Not part of the graphics state.
    268         void setAllowsFontSmoothing(bool);
    269        
    270         WEBCORE_EXPORT void setIsCALayerContext(bool);
    271         bool isCALayerContext() const;
    272 
    273         WEBCORE_EXPORT void setIsAcceleratedContext(bool);
    274 #endif
    275         bool isAcceleratedContext() const;
    276         RenderingMode renderingMode() const { return isAcceleratedContext() ? Accelerated : Unaccelerated; }
    277 
    278         WEBCORE_EXPORT void save();
    279         WEBCORE_EXPORT void restore();
    280 
    281         // These draw methods will do both stroking and filling.
    282         // FIXME: ...except drawRect(), which fills properly but always strokes
    283         // using a 1-pixel stroke inset from the rect borders (of the correct
    284         // stroke color).
    285         void drawRect(const FloatRect&, float borderThickness = 1);
    286         void drawLine(const FloatPoint&, const FloatPoint&);
    287 
    288 #if PLATFORM(IOS)
    289         void drawJoinedLines(CGPoint points[], unsigned count, bool antialias, CGLineCap = kCGLineCapButt);
    290 #endif
    291 
    292         void drawEllipse(const FloatRect&);
    293         void drawRaisedEllipse(const FloatRect&, const Color& ellipseColor, ColorSpace ellipseColorSpace, const Color& shadowColor, ColorSpace shadowColorSpace);
    294         void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
    295 
    296         WEBCORE_EXPORT void fillPath(const Path&);
    297         void strokePath(const Path&);
    298 
    299         void fillEllipse(const FloatRect&);
    300         void strokeEllipse(const FloatRect&);
    301 
    302         WEBCORE_EXPORT void fillRect(const FloatRect&);
    303         WEBCORE_EXPORT void fillRect(const FloatRect&, const Color&, ColorSpace);
    304         void fillRect(const FloatRect&, Gradient&);
    305         void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator, BlendMode = BlendModeNormal);
    306         void fillRoundedRect(const FloatRoundedRect&, const Color&, ColorSpace, BlendMode = BlendModeNormal);
    307         void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&, ColorSpace);
    308 
    309         WEBCORE_EXPORT void clearRect(const FloatRect&);
    310 
    311         WEBCORE_EXPORT void strokeRect(const FloatRect&, float lineWidth);
    312 
    313         WEBCORE_EXPORT void drawImage(Image&, ColorSpace, const FloatPoint& destination, const ImagePaintingOptions& = ImagePaintingOptions());
    314         WEBCORE_EXPORT void drawImage(Image&, ColorSpace, const FloatRect& destination, const ImagePaintingOptions& = ImagePaintingOptions());
    315         void drawImage(Image&, ColorSpace, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = ImagePaintingOptions());
    316 
    317         void drawTiledImage(Image&, ColorSpace, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& = ImagePaintingOptions());
    318         void drawTiledImage(Image&, ColorSpace, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor,
    319             Image::TileRule, Image::TileRule, const ImagePaintingOptions& = ImagePaintingOptions());
    320 
    321         WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, ColorSpace, const FloatPoint& destination, const ImagePaintingOptions& = ImagePaintingOptions());
    322         void drawImageBuffer(ImageBuffer&, ColorSpace, const FloatRect& destination, const ImagePaintingOptions& = ImagePaintingOptions());
    323         void drawImageBuffer(ImageBuffer&, ColorSpace, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = ImagePaintingOptions());
    324 
    325         void drawPattern(Image&, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, ColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal);
    326 
    327         WEBCORE_EXPORT void setImageInterpolationQuality(InterpolationQuality);
    328         InterpolationQuality imageInterpolationQuality() const;
    329 
    330         WEBCORE_EXPORT void clip(const IntRect&);
    331         WEBCORE_EXPORT void clip(const FloatRect&);
    332         void clipRoundedRect(const FloatRoundedRect&);
    333 
    334         void clipOut(const FloatRect&);
    335         void clipOutRoundedRect(const FloatRoundedRect&);
    336         void clipPath(const Path&, WindRule);
    337         void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
    338         void clipToImageBuffer(ImageBuffer&, const FloatRect&);
    339        
    340         IntRect clipBounds() const;
    341 
    342         void setTextDrawingMode(TextDrawingModeFlags);
    343         TextDrawingModeFlags textDrawingMode() const { return m_state.textDrawingMode; }
    344 
    345         float drawText(const FontCascade&, const TextRun&, const FloatPoint&, int from = 0, int to = -1);
    346         void drawGlyphs(const FontCascade&, const Font&, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint&);
    347         void drawEmphasisMarks(const FontCascade&, const TextRun& , const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1);
    348         void drawBidiText(const FontCascade&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction = FontCascade::DoNotPaintIfFontNotReady);
    349 
    350         enum RoundingMode {
    351             RoundAllSides,
    352             RoundOriginAndDimensions
    353         };
    354         FloatRect roundToDevicePixels(const FloatRect&, RoundingMode = RoundAllSides);
    355 
    356         FloatRect computeLineBoundsForText(const FloatPoint&, float width, bool printing);
    357         WEBCORE_EXPORT void drawLineForText(const FloatPoint&, float width, bool printing, bool doubleLines = false);
    358         void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines = false);
    359         enum DocumentMarkerLineStyle {
    360 #if PLATFORM(IOS)
    361             TextCheckingDictationPhraseWithAlternativesLineStyle,
    362 #endif
    363             DocumentMarkerSpellingLineStyle,
    364             DocumentMarkerGrammarLineStyle,
    365             DocumentMarkerAutocorrectionReplacementLineStyle,
    366             DocumentMarkerDictationAlternativesLineStyle
    367         };
    368         static void updateDocumentMarkerResources();
    369         void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarkerLineStyle);
    370 
    371         void setPaintingDisabled(bool paintingDisabled) { m_state.paintingDisabled = paintingDisabled; }
    372         bool paintingDisabled() const { return m_state.paintingDisabled; }
    373 
    374         void setUpdatingControlTints(bool);
    375         bool updatingControlTints() const { return m_updatingControlTints; }
    376 
    377         WEBCORE_EXPORT void beginTransparencyLayer(float opacity);
    378         WEBCORE_EXPORT void endTransparencyLayer();
    379         bool isInTransparencyLayer() const { return (m_transparencyCount > 0) && supportsTransparencyLayers(); }
    380 
    381         WEBCORE_EXPORT void setShadow(const FloatSize&, float blur, const Color&, ColorSpace);
    382         // Legacy shadow blur radius is used for canvas, and -webkit-box-shadow.
    383         // It has different treatment of radii > 8px.
    384         void setLegacyShadow(const FloatSize&, float blur, const Color&, ColorSpace);
    385 
    386         WEBCORE_EXPORT void clearShadow();
    387         bool getShadow(FloatSize&, float&, Color&, ColorSpace&) const;
    388 
    389         bool hasVisibleShadow() const { return m_state.shadowColor.isValid() && m_state.shadowColor.alpha(); }
    390         bool hasShadow() const { return hasVisibleShadow() && (m_state.shadowBlur || m_state.shadowOffset.width() || m_state.shadowOffset.height()); }
    391         bool hasBlurredShadow() const { return hasVisibleShadow() && m_state.shadowBlur; }
     368    static void updateDocumentMarkerResources();
     369    void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarkerLineStyle);
     370
     371    void setPaintingDisabled(bool paintingDisabled) { m_state.paintingDisabled = paintingDisabled; }
     372    bool paintingDisabled() const { return m_state.paintingDisabled; }
     373
     374    void setUpdatingControlTints(bool);
     375    bool updatingControlTints() const { return m_updatingControlTints; }
     376
     377    WEBCORE_EXPORT void beginTransparencyLayer(float opacity);
     378    WEBCORE_EXPORT void endTransparencyLayer();
     379    bool isInTransparencyLayer() const { return (m_transparencyCount > 0) && supportsTransparencyLayers(); }
     380
     381    WEBCORE_EXPORT void setShadow(const FloatSize&, float blur, const Color&, ColorSpace);
     382    // Legacy shadow blur radius is used for canvas, and -webkit-box-shadow.
     383    // It has different treatment of radii > 8px.
     384    void setLegacyShadow(const FloatSize&, float blur, const Color&, ColorSpace);
     385
     386    WEBCORE_EXPORT void clearShadow();
     387    bool getShadow(FloatSize&, float&, Color&, ColorSpace&) const;
     388
     389    bool hasVisibleShadow() const { return m_state.shadowColor.isValid() && m_state.shadowColor.alpha(); }
     390    bool hasShadow() const { return hasVisibleShadow() && (m_state.shadowBlur || m_state.shadowOffset.width() || m_state.shadowOffset.height()); }
     391    bool hasBlurredShadow() const { return hasVisibleShadow() && m_state.shadowBlur; }
    392392
    393393#if USE(CAIRO)
    394         bool mustUseShadowBlur() const;
    395 #endif
    396 
    397         void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
    398         void drawFocusRing(const Path&, int width, int offset, const Color&);
     394    bool mustUseShadowBlur() const;
     395#endif
     396
     397    void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
     398    void drawFocusRing(const Path&, int width, int offset, const Color&);
    399399#if PLATFORM(MAC)
    400         void drawFocusRing(const Vector<IntRect>&, int width, int offset, double timeOffset, bool& needsRedraw);
    401 #endif
    402 
    403         void setLineCap(LineCap);
    404         void setLineDash(const DashArray&, float dashOffset);
    405         void setLineJoin(LineJoin);
    406         void setMiterLimit(float);
    407 
    408         void setAlpha(float);
    409         float alpha() const { return m_state.alpha; }
    410 
    411         WEBCORE_EXPORT void setCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal);
    412         CompositeOperator compositeOperation() const { return m_state.compositeOperator; }
    413         BlendMode blendModeOperation() const { return m_state.blendMode; }
    414 
    415         void setDrawLuminanceMask(bool drawLuminanceMask) { m_state.drawLuminanceMask = drawLuminanceMask; }
    416         bool drawLuminanceMask() const { return m_state.drawLuminanceMask; }
    417 
    418         WEBCORE_EXPORT void clip(const Path&, WindRule = RULE_EVENODD);
    419 
    420         // This clip function is used only by <canvas> code. It allows
    421         // implementations to handle clipping on the canvas differently since
    422         // the discipline is different.
    423         void canvasClip(const Path&, WindRule = RULE_EVENODD);
    424         void clipOut(const Path&);
    425 
    426         WEBCORE_EXPORT void scale(const FloatSize&);
    427         void rotate(float angleInRadians);
    428         void translate(const FloatSize& size) { translate(size.width(), size.height()); }
    429         WEBCORE_EXPORT void translate(float x, float y);
    430 
    431         void setURLForRect(const URL&, const IntRect&);
    432 
    433         void concatCTM(const AffineTransform&);
    434         void setCTM(const AffineTransform&);
    435 
    436         enum IncludeDeviceScale { DefinitelyIncludeDeviceScale, PossiblyIncludeDeviceScale };
    437         AffineTransform getCTM(IncludeDeviceScale includeScale = PossiblyIncludeDeviceScale) const;
     400    void drawFocusRing(const Vector<IntRect>&, int width, int offset, double timeOffset, bool& needsRedraw);
     401#endif
     402
     403    void setLineCap(LineCap);
     404    void setLineDash(const DashArray&, float dashOffset);
     405    void setLineJoin(LineJoin);
     406    void setMiterLimit(float);
     407
     408    void setAlpha(float);
     409    float alpha() const { return m_state.alpha; }
     410
     411    WEBCORE_EXPORT void setCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal);
     412    CompositeOperator compositeOperation() const { return m_state.compositeOperator; }
     413    BlendMode blendModeOperation() const { return m_state.blendMode; }
     414
     415    void setDrawLuminanceMask(bool drawLuminanceMask) { m_state.drawLuminanceMask = drawLuminanceMask; }
     416    bool drawLuminanceMask() const { return m_state.drawLuminanceMask; }
     417
     418    WEBCORE_EXPORT void clip(const Path&, WindRule = RULE_EVENODD);
     419
     420    // This clip function is used only by <canvas> code. It allows
     421    // implementations to handle clipping on the canvas differently since
     422    // the discipline is different.
     423    void canvasClip(const Path&, WindRule = RULE_EVENODD);
     424    void clipOut(const Path&);
     425
     426    WEBCORE_EXPORT void scale(const FloatSize&);
     427    void rotate(float angleInRadians);
     428    void translate(const FloatSize& size) { translate(size.width(), size.height()); }
     429    WEBCORE_EXPORT void translate(float x, float y);
     430
     431    void setURLForRect(const URL&, const IntRect&);
     432
     433    void concatCTM(const AffineTransform&);
     434    void setCTM(const AffineTransform&);
     435
     436    enum IncludeDeviceScale { DefinitelyIncludeDeviceScale, PossiblyIncludeDeviceScale };
     437    AffineTransform getCTM(IncludeDeviceScale includeScale = PossiblyIncludeDeviceScale) const;
    438438
    439439#if ENABLE(3D_TRANSFORMS) && USE(TEXTURE_MAPPER)
    440         // This is needed when using accelerated-compositing in software mode, like in TextureMapper.
    441         void concat3DTransform(const TransformationMatrix&);
    442         void set3DTransform(const TransformationMatrix&);
    443         TransformationMatrix get3DTransform() const;
    444 #endif
    445         // Create an image buffer compatible with this context, with suitable resolution
    446         // for drawing into the buffer and then into this context.
    447         std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, bool hasAlpha = true) const;
    448         bool isCompatibleWithBuffer(ImageBuffer&) const;
    449 
    450         // This function applies the device scale factor to the context, making the context capable of
    451         // acting as a base-level context for a HiDPI environment.
    452         WEBCORE_EXPORT void applyDeviceScaleFactor(float);
    453         void platformApplyDeviceScaleFactor(float);
     440    // This is needed when using accelerated-compositing in software mode, like in TextureMapper.
     441    void concat3DTransform(const TransformationMatrix&);
     442    void set3DTransform(const TransformationMatrix&);
     443    TransformationMatrix get3DTransform() const;
     444#endif
     445    // Create an image buffer compatible with this context, with suitable resolution
     446    // for drawing into the buffer and then into this context.
     447    std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, bool hasAlpha = true) const;
     448    bool isCompatibleWithBuffer(ImageBuffer&) const;
     449
     450    // This function applies the device scale factor to the context, making the context capable of
     451    // acting as a base-level context for a HiDPI environment.
     452    WEBCORE_EXPORT void applyDeviceScaleFactor(float);
     453    void platformApplyDeviceScaleFactor(float);
    454454
    455455#if OS(WINDOWS)
    456         HDC getWindowsContext(const IntRect&, bool supportAlphaBlend, bool mayCreateBitmap); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
    457         void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend, bool mayCreateBitmap); // The passed in HDC should be the one handed back by getWindowsContext.
    458         HDC hdc() const;
     456    HDC getWindowsContext(const IntRect&, bool supportAlphaBlend, bool mayCreateBitmap); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
     457    void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend, bool mayCreateBitmap); // The passed in HDC should be the one handed back by getWindowsContext.
     458    HDC hdc() const;
    459459#if PLATFORM(WIN)
    460460#if USE(WINGDI)
    461         void setBitmap(PassRefPtr<SharedBitmap>);
    462         const AffineTransform& affineTransform() const;
    463         AffineTransform& affineTransform();
    464         void resetAffineTransform();
    465         void fillRect(const FloatRect&, const Gradient*);
    466         void drawText(const Font&, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint&);
    467         void drawFrameControl(const IntRect& rect, unsigned type, unsigned state);
    468         void drawFocusRect(const IntRect& rect);
    469         void paintTextField(const IntRect& rect, unsigned state);
    470         void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode);
    471         void drawBitmapPattern(SharedBitmap*, const FloatRect& tileRectIn, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize);
    472         void drawIcon(HICON icon, const IntRect& dstRect, UINT flags);
    473         void drawRoundCorner(bool newClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height);
     461    void setBitmap(PassRefPtr<SharedBitmap>);
     462    const AffineTransform& affineTransform() const;
     463    AffineTransform& affineTransform();
     464    void resetAffineTransform();
     465    void fillRect(const FloatRect&, const Gradient*);
     466    void drawText(const Font&, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint&);
     467    void drawFrameControl(const IntRect& rect, unsigned type, unsigned state);
     468    void drawFocusRect(const IntRect& rect);
     469    void paintTextField(const IntRect& rect, unsigned state);
     470    void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode);
     471    void drawBitmapPattern(SharedBitmap*, const FloatRect& tileRectIn, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize);
     472    void drawIcon(HICON icon, const IntRect& dstRect, UINT flags);
     473    void drawRoundCorner(bool newClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height);
    474474#else
    475         GraphicsContext(HDC, bool hasAlpha = false); // FIXME: To be removed.
    476 
    477         // When set to true, child windows should be rendered into this context
    478         // rather than allowing them just to render to the screen. Defaults to
    479         // false.
    480         // FIXME: This is a layering violation. GraphicsContext shouldn't know
    481         // what a "window" is. It would be much more appropriate for this flag
    482         // to be passed as a parameter alongside the GraphicsContext, but doing
    483         // that would require lots of changes in cross-platform code that we
    484         // aren't sure we want to make.
    485         void setShouldIncludeChildWindows(bool);
    486         bool shouldIncludeChildWindows() const;
    487 
    488         class WindowsBitmap {
    489             WTF_MAKE_NONCOPYABLE(WindowsBitmap);
    490         public:
    491             WindowsBitmap(HDC, const IntSize&);
    492             ~WindowsBitmap();
    493 
    494             HDC hdc() const { return m_hdc; }
    495             UInt8* buffer() const { return m_pixelData.buffer(); }
    496             unsigned bufferLength() const { return m_pixelData.bufferLength(); }
    497             const IntSize& size() const { return m_pixelData.size(); }
    498             unsigned bytesPerRow() const { return m_pixelData.bytesPerRow(); }
    499             unsigned short bitsPerPixel() const { return m_pixelData.bitsPerPixel(); }
    500             const DIBPixelData& windowsDIB() const { return m_pixelData; }
    501 
    502         private:
    503             HDC m_hdc;
    504             HBITMAP m_bitmap;
    505             DIBPixelData m_pixelData;
    506         };
    507 
    508         std::unique_ptr<WindowsBitmap> createWindowsBitmap(const IntSize&);
    509         // The bitmap should be non-premultiplied.
    510         void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
     475    GraphicsContext(HDC, bool hasAlpha = false); // FIXME: To be removed.
     476
     477    // When set to true, child windows should be rendered into this context
     478    // rather than allowing them just to render to the screen. Defaults to
     479    // false.
     480    // FIXME: This is a layering violation. GraphicsContext shouldn't know
     481    // what a "window" is. It would be much more appropriate for this flag
     482    // to be passed as a parameter alongside the GraphicsContext, but doing
     483    // that would require lots of changes in cross-platform code that we
     484    // aren't sure we want to make.
     485    void setShouldIncludeChildWindows(bool);
     486    bool shouldIncludeChildWindows() const;
     487
     488    class WindowsBitmap {
     489        WTF_MAKE_NONCOPYABLE(WindowsBitmap);
     490    public:
     491        WindowsBitmap(HDC, const IntSize&);
     492        ~WindowsBitmap();
     493
     494        HDC hdc() const { return m_hdc; }
     495        UInt8* buffer() const { return m_pixelData.buffer(); }
     496        unsigned bufferLength() const { return m_pixelData.bufferLength(); }
     497        const IntSize& size() const { return m_pixelData.size(); }
     498        unsigned bytesPerRow() const { return m_pixelData.bytesPerRow(); }
     499        unsigned short bitsPerPixel() const { return m_pixelData.bitsPerPixel(); }
     500        const DIBPixelData& windowsDIB() const { return m_pixelData; }
     501
     502    private:
     503        HDC m_hdc;
     504        HBITMAP m_bitmap;
     505        DIBPixelData m_pixelData;
     506    };
     507
     508    std::unique_ptr<WindowsBitmap> createWindowsBitmap(const IntSize&);
     509    // The bitmap should be non-premultiplied.
     510    void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
    511511#endif
    512512#else // PLATFORM(WIN)
    513         bool shouldIncludeChildWindows() const { return false; }
     513    bool shouldIncludeChildWindows() const { return false; }
    514514#endif // PLATFORM(WIN)
    515515#endif // OS(WINDOWS)
    516516
    517517#if USE(CAIRO)
    518         GraphicsContext(cairo_t*);
    519 #endif
    520 
    521         static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle);
    522 
    523     private:
    524         void platformInit(PlatformGraphicsContext*);
    525         void platformDestroy();
     518    GraphicsContext(cairo_t*);
     519#endif
     520
     521    static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle);
     522
     523private:
     524    void platformInit(PlatformGraphicsContext*);
     525    void platformDestroy();
    526526
    527527#if PLATFORM(WIN) && !USE(WINGDI)
    528         void platformInit(HDC, bool hasAlpha = false);
    529 #endif
    530 
    531         void savePlatformState();
    532         void restorePlatformState();
    533 
    534         void setPlatformTextDrawingMode(TextDrawingModeFlags);
    535 
    536         void setPlatformStrokeColor(const Color&, ColorSpace);
    537         void setPlatformStrokeStyle(StrokeStyle);
    538         void setPlatformStrokeThickness(float);
    539 
    540         void setPlatformFillColor(const Color&, ColorSpace);
    541 
    542         void setPlatformShouldAntialias(bool);
    543         void setPlatformShouldSmoothFonts(bool);
    544 
    545         void setPlatformShadow(const FloatSize&, float blur, const Color&, ColorSpace);
    546         void clearPlatformShadow();
    547 
    548         void setPlatformAlpha(float);
    549         void setPlatformCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal);
    550 
    551         void beginPlatformTransparencyLayer(float opacity);
    552         void endPlatformTransparencyLayer();
    553         static bool supportsTransparencyLayers();
    554 
    555         void fillEllipseAsPath(const FloatRect&);
    556         void strokeEllipseAsPath(const FloatRect&);
    557 
    558         void platformFillEllipse(const FloatRect&);
    559         void platformStrokeEllipse(const FloatRect&);
    560 
    561         void platformFillRoundedRect(const FloatRoundedRect&, const Color&, ColorSpace);
    562 
    563         FloatRect computeLineBoundsAndAntialiasingModeForText(const FloatPoint&, float width, bool printing, bool& shouldAntialias, Color&);
    564 
    565         GraphicsContextPlatformPrivate* m_data;
    566 
    567         GraphicsContextState m_state;
    568         Vector<GraphicsContextState, 1> m_stack;
    569         bool m_updatingControlTints;
    570         unsigned m_transparencyCount;
    571     };
    572 
    573     class GraphicsContextStateSaver {
    574         WTF_MAKE_FAST_ALLOCATED;
    575     public:
    576         GraphicsContextStateSaver(GraphicsContext& context, bool saveAndRestore = true)
    577         : m_context(context)
    578         , m_saveAndRestore(saveAndRestore)
    579         {
    580             if (m_saveAndRestore)
    581                 m_context.save();
    582         }
    583        
    584         ~GraphicsContextStateSaver()
    585         {
    586             if (m_saveAndRestore)
    587                 m_context.restore();
    588         }
    589        
    590         void save()
    591         {
    592             ASSERT(!m_saveAndRestore);
     528    void platformInit(HDC, bool hasAlpha = false);
     529#endif
     530
     531    void savePlatformState();
     532    void restorePlatformState();
     533
     534    void setPlatformTextDrawingMode(TextDrawingModeFlags);
     535
     536    void setPlatformStrokeColor(const Color&, ColorSpace);
     537    void setPlatformStrokeStyle(StrokeStyle);
     538    void setPlatformStrokeThickness(float);
     539
     540    void setPlatformFillColor(const Color&, ColorSpace);
     541
     542    void setPlatformShouldAntialias(bool);
     543    void setPlatformShouldSmoothFonts(bool);
     544
     545    void setPlatformShadow(const FloatSize&, float blur, const Color&, ColorSpace);
     546    void clearPlatformShadow();
     547
     548    void setPlatformAlpha(float);
     549    void setPlatformCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal);
     550
     551    void beginPlatformTransparencyLayer(float opacity);
     552    void endPlatformTransparencyLayer();
     553    static bool supportsTransparencyLayers();
     554
     555    void fillEllipseAsPath(const FloatRect&);
     556    void strokeEllipseAsPath(const FloatRect&);
     557
     558    void platformFillEllipse(const FloatRect&);
     559    void platformStrokeEllipse(const FloatRect&);
     560
     561    void platformFillRoundedRect(const FloatRoundedRect&, const Color&, ColorSpace);
     562
     563    FloatRect computeLineBoundsAndAntialiasingModeForText(const FloatPoint&, float width, bool printing, bool& shouldAntialias, Color&);
     564
     565    GraphicsContextPlatformPrivate* m_data;
     566
     567    GraphicsContextState m_state;
     568    Vector<GraphicsContextState, 1> m_stack;
     569    bool m_updatingControlTints;
     570    unsigned m_transparencyCount;
     571};
     572
     573class GraphicsContextStateSaver {
     574    WTF_MAKE_FAST_ALLOCATED;
     575public:
     576    GraphicsContextStateSaver(GraphicsContext& context, bool saveAndRestore = true)
     577    : m_context(context)
     578    , m_saveAndRestore(saveAndRestore)
     579    {
     580        if (m_saveAndRestore)
    593581            m_context.save();
    594             m_saveAndRestore = true;
    595         }
    596 
    597         void restore()
    598         {
    599             ASSERT(m_saveAndRestore);
     582    }
     583   
     584    ~GraphicsContextStateSaver()
     585    {
     586        if (m_saveAndRestore)
    600587            m_context.restore();
    601             m_saveAndRestore = false;
    602         }
    603        
    604         GraphicsContext* context() const { return &m_context; }
    605 
    606     private:
    607         GraphicsContext& m_context;
    608         bool m_saveAndRestore;
    609     };
     588    }
     589   
     590    void save()
     591    {
     592        ASSERT(!m_saveAndRestore);
     593        m_context.save();
     594        m_saveAndRestore = true;
     595    }
     596
     597    void restore()
     598    {
     599        ASSERT(m_saveAndRestore);
     600        m_context.restore();
     601        m_saveAndRestore = false;
     602    }
     603   
     604    GraphicsContext* context() const { return &m_context; }
     605
     606private:
     607    GraphicsContext& m_context;
     608    bool m_saveAndRestore;
     609};
    610610
    611611} // namespace WebCore
    612612
    613613#endif // GraphicsContext_h
    614 
Note: See TracChangeset for help on using the changeset viewer.