Changeset 73492 in webkit


Ignore:
Timestamp:
Dec 8, 2010 12:05:17 AM (13 years ago)
Author:
reni@webkit.org
Message:

2010-12-08 Renata Hodovan <reni@webkit.org>

Reviewed by Andreas Kling.

GraphicsContext: Merge m_common and m_data
https://bugs.webkit.org/show_bug.cgi?id=49914

Move data members from GraphicsContextPrivate into GraphicsContext. So GraphicsContextPlatform.h
and m_common became unnecessary. They are removed.
Add two methods to GraphicsContext: platformInit() and platformDestroy(), which
make the constructor of GraphicsContext clearer.
Besides add a getter to the private GraphicsContext::m_state member, because some inline
functions in cairo need it.

No new test is needed, because this is a refactoring.

  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::GraphicsContext): (WebCore::GraphicsContext::~GraphicsContext): (WebCore::GraphicsContext::save): (WebCore::GraphicsContext::restore): (WebCore::GraphicsContext::setStrokeThickness): (WebCore::GraphicsContext::setStrokeStyle): (WebCore::GraphicsContext::setStrokeColor): (WebCore::GraphicsContext::setShadow): (WebCore::GraphicsContext::clearShadow): (WebCore::GraphicsContext::getShadow): (WebCore::GraphicsContext::strokeThickness): (WebCore::GraphicsContext::strokeStyle): (WebCore::GraphicsContext::strokeColor): (WebCore::GraphicsContext::strokeColorSpace): (WebCore::GraphicsContext::fillRule): (WebCore::GraphicsContext::setFillRule): (WebCore::GraphicsContext::setFillColor): (WebCore::GraphicsContext::fillColor): (WebCore::GraphicsContext::fillColorSpace): (WebCore::GraphicsContext::setShouldAntialias): (WebCore::GraphicsContext::shouldAntialias): (WebCore::GraphicsContext::state): (WebCore::GraphicsContext::setStrokePattern): (WebCore::GraphicsContext::setFillPattern): (WebCore::GraphicsContext::setStrokeGradient): (WebCore::GraphicsContext::setFillGradient): (WebCore::GraphicsContext::fillGradient): (WebCore::GraphicsContext::strokeGradient): (WebCore::GraphicsContext::fillPattern): (WebCore::GraphicsContext::strokePattern): (WebCore::GraphicsContext::setShadowsIgnoreTransforms): (WebCore::GraphicsContext::updatingControlTints): (WebCore::GraphicsContext::setUpdatingControlTints): (WebCore::GraphicsContext::setPaintingDisabled): (WebCore::GraphicsContext::paintingDisabled): (WebCore::GraphicsContext::textDrawingMode): (WebCore::GraphicsContext::setTextDrawingMode):
  • platform/graphics/GraphicsContext.h: (WebCore::GraphicsContextState::GraphicsContextState):
  • platform/graphics/GraphicsContextPrivate.h: Removed.
  • platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::setPlatformFill): (WebCore::setPlatformStroke): (WebCore::drawPathShadow): (WebCore::fillCurrentCairoPath): (WebCore::strokeCurrentCairoPath): (WebCore::GraphicsContext::platformInit): (WebCore::GraphicsContext::platformDestroy): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::fillRect): (WebCore::GraphicsContext::setPlatformShadow): (WebCore::GraphicsContext::strokeRect): (WebCore::GraphicsContext::setAlpha): (WebCore::GraphicsContext::getAlpha):
  • platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::platformInit): (WebCore::GraphicsContext::platformDestroy): (WebCore::GraphicsContext::applyStrokePattern): (WebCore::GraphicsContext::applyFillPattern): (WebCore::GraphicsContext::drawPath): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::fillRect): (WebCore::GraphicsContext::setPlatformShadow): (WebCore::GraphicsContext::strokeRect):
  • platform/graphics/haiku/GraphicsContextHaiku.cpp: (WebCore::GraphicsContext::platformInit): (WebCore::GraphicsContext::platformDestroy):
  • platform/graphics/openvg/GraphicsContextOpenVG.cpp: (WebCore::GraphicsContext::platformInit): (WebCore::GraphicsContext::platformDestroy): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::clip): (WebCore::GraphicsContext::clipOut): (WebCore::GraphicsContext::addInnerRoundedRectClip):
  • platform/graphics/qt/GraphicsContextQt.cpp: (WebCore::GraphicsContext::platformInit): (WebCore::GraphicsContext::platformDestroy): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::fillRect): (WebCore::GraphicsContext::setPlatformShadow):
  • platform/graphics/skia/GraphicsContextSkia.cpp: (WebCore::GraphicsContext::platformInit): (WebCore::GraphicsContext::platformDestroy): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::setPlatformShadow):
  • platform/graphics/win/GraphicsContextCGWin.cpp: (WebCore::GraphicsContext::platformInit):
  • platform/graphics/win/GraphicsContextCairoWin.cpp: (WebCore::GraphicsContext::platformInit):
  • platform/graphics/wince/GraphicsContextWinCE.cpp: (WebCore::GraphicsContext::platformInit): (WebCore::GraphicsContext::platformDestroy): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::fillRect):
  • platform/graphics/wx/GraphicsContextWx.cpp: (WebCore::GraphicsContext::platformInit): (WebCore::GraphicsContext::platformDestroy):
Location:
trunk/WebCore
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r73491 r73492  
     12010-12-08  Renata Hodovan  <reni@webkit.org>
     2
     3        Reviewed by Andreas Kling.
     4
     5        GraphicsContext: Merge m_common and m_data
     6        https://bugs.webkit.org/show_bug.cgi?id=49914
     7
     8        Move data members from GraphicsContextPrivate into GraphicsContext. So GraphicsContextPlatform.h
     9        and m_common became unnecessary. They are removed.
     10        Add two methods to GraphicsContext: platformInit() and platformDestroy(), which
     11        make the constructor of GraphicsContext clearer.
     12        Besides add a getter to the private GraphicsContext::m_state member, because some inline
     13        functions in cairo need it.
     14
     15        No new test is needed, because this is a refactoring.
     16
     17        * WebCore.xcodeproj/project.pbxproj:
     18        * platform/graphics/GraphicsContext.cpp:
     19        (WebCore::GraphicsContext::GraphicsContext):
     20        (WebCore::GraphicsContext::~GraphicsContext):
     21        (WebCore::GraphicsContext::save):
     22        (WebCore::GraphicsContext::restore):
     23        (WebCore::GraphicsContext::setStrokeThickness):
     24        (WebCore::GraphicsContext::setStrokeStyle):
     25        (WebCore::GraphicsContext::setStrokeColor):
     26        (WebCore::GraphicsContext::setShadow):
     27        (WebCore::GraphicsContext::clearShadow):
     28        (WebCore::GraphicsContext::getShadow):
     29        (WebCore::GraphicsContext::strokeThickness):
     30        (WebCore::GraphicsContext::strokeStyle):
     31        (WebCore::GraphicsContext::strokeColor):
     32        (WebCore::GraphicsContext::strokeColorSpace):
     33        (WebCore::GraphicsContext::fillRule):
     34        (WebCore::GraphicsContext::setFillRule):
     35        (WebCore::GraphicsContext::setFillColor):
     36        (WebCore::GraphicsContext::fillColor):
     37        (WebCore::GraphicsContext::fillColorSpace):
     38        (WebCore::GraphicsContext::setShouldAntialias):
     39        (WebCore::GraphicsContext::shouldAntialias):
     40        (WebCore::GraphicsContext::state):
     41        (WebCore::GraphicsContext::setStrokePattern):
     42        (WebCore::GraphicsContext::setFillPattern):
     43        (WebCore::GraphicsContext::setStrokeGradient):
     44        (WebCore::GraphicsContext::setFillGradient):
     45        (WebCore::GraphicsContext::fillGradient):
     46        (WebCore::GraphicsContext::strokeGradient):
     47        (WebCore::GraphicsContext::fillPattern):
     48        (WebCore::GraphicsContext::strokePattern):
     49        (WebCore::GraphicsContext::setShadowsIgnoreTransforms):
     50        (WebCore::GraphicsContext::updatingControlTints):
     51        (WebCore::GraphicsContext::setUpdatingControlTints):
     52        (WebCore::GraphicsContext::setPaintingDisabled):
     53        (WebCore::GraphicsContext::paintingDisabled):
     54        (WebCore::GraphicsContext::textDrawingMode):
     55        (WebCore::GraphicsContext::setTextDrawingMode):
     56        * platform/graphics/GraphicsContext.h:
     57        (WebCore::GraphicsContextState::GraphicsContextState):
     58        * platform/graphics/GraphicsContextPrivate.h: Removed.
     59        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     60        (WebCore::setPlatformFill):
     61        (WebCore::setPlatformStroke):
     62        (WebCore::drawPathShadow):
     63        (WebCore::fillCurrentCairoPath):
     64        (WebCore::strokeCurrentCairoPath):
     65        (WebCore::GraphicsContext::platformInit):
     66        (WebCore::GraphicsContext::platformDestroy):
     67        (WebCore::GraphicsContext::fillPath):
     68        (WebCore::GraphicsContext::strokePath):
     69        (WebCore::GraphicsContext::fillRect):
     70        (WebCore::GraphicsContext::setPlatformShadow):
     71        (WebCore::GraphicsContext::strokeRect):
     72        (WebCore::GraphicsContext::setAlpha):
     73        (WebCore::GraphicsContext::getAlpha):
     74        * platform/graphics/cg/GraphicsContextCG.cpp:
     75        (WebCore::GraphicsContext::platformInit):
     76        (WebCore::GraphicsContext::platformDestroy):
     77        (WebCore::GraphicsContext::applyStrokePattern):
     78        (WebCore::GraphicsContext::applyFillPattern):
     79        (WebCore::GraphicsContext::drawPath):
     80        (WebCore::GraphicsContext::fillPath):
     81        (WebCore::GraphicsContext::strokePath):
     82        (WebCore::GraphicsContext::fillRect):
     83        (WebCore::GraphicsContext::setPlatformShadow):
     84        (WebCore::GraphicsContext::strokeRect):
     85        * platform/graphics/haiku/GraphicsContextHaiku.cpp:
     86        (WebCore::GraphicsContext::platformInit):
     87        (WebCore::GraphicsContext::platformDestroy):
     88        * platform/graphics/openvg/GraphicsContextOpenVG.cpp:
     89        (WebCore::GraphicsContext::platformInit):
     90        (WebCore::GraphicsContext::platformDestroy):
     91        (WebCore::GraphicsContext::fillPath):
     92        (WebCore::GraphicsContext::strokePath):
     93        (WebCore::GraphicsContext::clip):
     94        (WebCore::GraphicsContext::clipOut):
     95        (WebCore::GraphicsContext::addInnerRoundedRectClip):
     96        * platform/graphics/qt/GraphicsContextQt.cpp:
     97        (WebCore::GraphicsContext::platformInit):
     98        (WebCore::GraphicsContext::platformDestroy):
     99        (WebCore::GraphicsContext::fillPath):
     100        (WebCore::GraphicsContext::strokePath):
     101        (WebCore::GraphicsContext::fillRect):
     102        (WebCore::GraphicsContext::setPlatformShadow):
     103        * platform/graphics/skia/GraphicsContextSkia.cpp:
     104        (WebCore::GraphicsContext::platformInit):
     105        (WebCore::GraphicsContext::platformDestroy):
     106        (WebCore::GraphicsContext::fillPath):
     107        (WebCore::GraphicsContext::setPlatformShadow):
     108        * platform/graphics/win/GraphicsContextCGWin.cpp:
     109        (WebCore::GraphicsContext::platformInit):
     110        * platform/graphics/win/GraphicsContextCairoWin.cpp:
     111        (WebCore::GraphicsContext::platformInit):
     112        * platform/graphics/wince/GraphicsContextWinCE.cpp:
     113        (WebCore::GraphicsContext::platformInit):
     114        (WebCore::GraphicsContext::platformDestroy):
     115        (WebCore::GraphicsContext::fillPath):
     116        (WebCore::GraphicsContext::fillRect):
     117        * platform/graphics/wx/GraphicsContextWx.cpp:
     118        (WebCore::GraphicsContext::platformInit):
     119        (WebCore::GraphicsContext::platformDestroy):
     120
    11212010-12-07  Anton Muhin  <antonm@chromium.org>
    2122
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r73485 r73492  
    39273927                A8F5C0B80F9285AC0098E06B /* RenderSVGModelObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A8F5C0B60F9285AC0098E06B /* RenderSVGModelObject.h */; };
    39283928                A8F5C0B90F9285AC0098E06B /* RenderSVGModelObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8F5C0B70F9285AC0098E06B /* RenderSVGModelObject.cpp */; };
    3929                 A8FA6E5D0E4CFDED00D5CF49 /* Pattern.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */; };
     3929                A8FA6E5D0E4CFDED00D5CF49 /* Pattern.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */; settings = {ATTRIBUTES = (Private, ); }; };
    39303930                A8FA6E5E0E4CFDED00D5CF49 /* Pattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */; };
    39313931                A9C6E4E30D745E05006442E9 /* DOMMimeType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9C6E4E10D745E05006442E9 /* DOMMimeType.cpp */; };
  • trunk/WebCore/platform/graphics/GraphicsContext.cpp

    r73284 r73492  
    3030#include "Font.h"
    3131#include "Generator.h"
    32 #include "GraphicsContextPrivate.h"
    3332#include "ImageBuffer.h"
    3433
     
    7574};
    7675
    77 GraphicsContextPrivate* GraphicsContext::createGraphicsContextPrivate()
    78 {
    79     return new GraphicsContextPrivate;
    80 }
    81 
    82 void GraphicsContext::destroyGraphicsContextPrivate(GraphicsContextPrivate* deleteMe)
    83 {
    84     delete deleteMe;
     76GraphicsContext::GraphicsContext(PlatformGraphicsContext* platformGraphicsContext)
     77{
     78    platformInit(platformGraphicsContext);
     79}
     80
     81GraphicsContext::~GraphicsContext()
     82{
     83    platformDestroy();
    8584}
    8685
     
    9089        return;
    9190
    92     m_common->stack.append(m_common->state);
     91    m_stack.append(m_state);
    9392
    9493    savePlatformState();
     
    10099        return;
    101100
    102     if (m_common->stack.isEmpty()) {
     101    if (m_stack.isEmpty()) {
    103102        LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
    104103        return;
    105104    }
    106     m_common->state = m_common->stack.last();
    107     m_common->stack.removeLast();
     105    m_state = m_stack.last();
     106    m_stack.removeLast();
    108107
    109108    restorePlatformState();
     
    112111void GraphicsContext::setStrokeThickness(float thickness)
    113112{
    114     m_common->state.strokeThickness = thickness;
     113    m_state.strokeThickness = thickness;
    115114    setPlatformStrokeThickness(thickness);
    116115}
     
    118117void GraphicsContext::setStrokeStyle(const StrokeStyle& style)
    119118{
    120     m_common->state.strokeStyle = style;
     119    m_state.strokeStyle = style;
    121120    setPlatformStrokeStyle(style);
    122121}
     
    124123void GraphicsContext::setStrokeColor(const Color& color, ColorSpace colorSpace)
    125124{
    126     m_common->state.strokeColor = color;
    127     m_common->state.strokeColorSpace = colorSpace;
    128     m_common->state.strokeGradient.clear();
    129     m_common->state.strokePattern.clear();
     125    m_state.strokeColor = color;
     126    m_state.strokeColorSpace = colorSpace;
     127    m_state.strokeGradient.clear();
     128    m_state.strokePattern.clear();
    130129    setPlatformStrokeColor(color, colorSpace);
    131130}
     
    133132void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color& color, ColorSpace colorSpace)
    134133{
    135     m_common->state.shadowOffset = offset;
    136     m_common->state.shadowBlur = blur;
    137     m_common->state.shadowColor = color;
     134    m_state.shadowOffset = offset;
     135    m_state.shadowBlur = blur;
     136    m_state.shadowColor = color;
    138137    setPlatformShadow(offset, blur, color, colorSpace);
    139138}
     
    141140void GraphicsContext::clearShadow()
    142141{
    143     m_common->state.shadowOffset = FloatSize();
    144     m_common->state.shadowBlur = 0;
    145     m_common->state.shadowColor = Color();
     142    m_state.shadowOffset = FloatSize();
     143    m_state.shadowBlur = 0;
     144    m_state.shadowColor = Color();
    146145    clearPlatformShadow();
    147146}
     
    149148bool GraphicsContext::getShadow(FloatSize& offset, float& blur, Color& color) const
    150149{
    151     offset = m_common->state.shadowOffset;
    152     blur = m_common->state.shadowBlur;
    153     color = m_common->state.shadowColor;
     150    offset = m_state.shadowOffset;
     151    blur = m_state.shadowBlur;
     152    color = m_state.shadowColor;
    154153
    155154    return color.isValid() && color.alpha() && (blur || offset.width() || offset.height());
     
    158157float GraphicsContext::strokeThickness() const
    159158{
    160     return m_common->state.strokeThickness;
     159    return m_state.strokeThickness;
    161160}
    162161
    163162StrokeStyle GraphicsContext::strokeStyle() const
    164163{
    165     return m_common->state.strokeStyle;
     164    return m_state.strokeStyle;
    166165}
    167166
    168167Color GraphicsContext::strokeColor() const
    169168{
    170     return m_common->state.strokeColor;
     169    return m_state.strokeColor;
    171170}
    172171
    173172ColorSpace GraphicsContext::strokeColorSpace() const
    174173{
    175     return m_common->state.strokeColorSpace;
     174    return m_state.strokeColorSpace;
    176175}
    177176
    178177WindRule GraphicsContext::fillRule() const
    179178{
    180     return m_common->state.fillRule;
     179    return m_state.fillRule;
    181180}
    182181
    183182void GraphicsContext::setFillRule(WindRule fillRule)
    184183{
    185     m_common->state.fillRule = fillRule;
     184    m_state.fillRule = fillRule;
    186185}
    187186
    188187void GraphicsContext::setFillColor(const Color& color, ColorSpace colorSpace)
    189188{
    190     m_common->state.fillColor = color;
    191     m_common->state.fillColorSpace = colorSpace;
    192     m_common->state.fillGradient.clear();
    193     m_common->state.fillPattern.clear();
     189    m_state.fillColor = color;
     190    m_state.fillColorSpace = colorSpace;
     191    m_state.fillGradient.clear();
     192    m_state.fillPattern.clear();
    194193    setPlatformFillColor(color, colorSpace);
    195194}
     
    197196Color GraphicsContext::fillColor() const
    198197{
    199     return m_common->state.fillColor;
     198    return m_state.fillColor;
    200199}
    201200
    202201ColorSpace GraphicsContext::fillColorSpace() const
    203202{
    204     return m_common->state.fillColorSpace;
     203    return m_state.fillColorSpace;
    205204}
    206205
    207206void GraphicsContext::setShouldAntialias(bool b)
    208207{
    209     m_common->state.shouldAntialias = b;
     208    m_state.shouldAntialias = b;
    210209    setPlatformShouldAntialias(b);
    211210}
     
    213212bool GraphicsContext::shouldAntialias() const
    214213{
    215     return m_common->state.shouldAntialias;
     214    return m_state.shouldAntialias;
     215}
     216
     217const GraphicsContextState& GraphicsContext::state() const
     218{
     219    return m_state;
    216220}
    217221
     
    223227        return;
    224228    }
    225     m_common->state.strokeGradient.clear();
    226     m_common->state.strokePattern = pattern;
    227     setPlatformStrokePattern(m_common->state.strokePattern.get());
     229    m_state.strokeGradient.clear();
     230    m_state.strokePattern = pattern;
     231    setPlatformStrokePattern(m_state.strokePattern.get());
    228232}
    229233
     
    235239        return;
    236240    }
    237     m_common->state.fillGradient.clear();
    238     m_common->state.fillPattern = pattern;
    239     setPlatformFillPattern(m_common->state.fillPattern.get());
     241    m_state.fillGradient.clear();
     242    m_state.fillPattern = pattern;
     243    setPlatformFillPattern(m_state.fillPattern.get());
    240244}
    241245
     
    247251        return;
    248252    }
    249     m_common->state.strokeGradient = gradient;
    250     m_common->state.strokePattern.clear();
    251     setPlatformStrokeGradient(m_common->state.strokeGradient.get());
     253    m_state.strokeGradient = gradient;
     254    m_state.strokePattern.clear();
     255    setPlatformStrokeGradient(m_state.strokeGradient.get());
    252256}
    253257
     
    259263        return;
    260264    }
    261     m_common->state.fillGradient = gradient;
    262     m_common->state.fillPattern.clear();
    263     setPlatformFillGradient(m_common->state.fillGradient.get());
     265    m_state.fillGradient = gradient;
     266    m_state.fillPattern.clear();
     267    setPlatformFillGradient(m_state.fillGradient.get());
    264268}
    265269
    266270Gradient* GraphicsContext::fillGradient() const
    267271{
    268     return m_common->state.fillGradient.get();
     272    return m_state.fillGradient.get();
    269273}
    270274
    271275Gradient* GraphicsContext::strokeGradient() const
    272276{
    273     return m_common->state.strokeGradient.get();
     277    return m_state.strokeGradient.get();
    274278}
    275279
    276280Pattern* GraphicsContext::fillPattern() const
    277281{
    278     return m_common->state.fillPattern.get();
     282    return m_state.fillPattern.get();
    279283}
    280284
    281285Pattern* GraphicsContext::strokePattern() const
    282286{
    283     return m_common->state.strokePattern.get();
     287    return m_state.strokePattern.get();
    284288}
    285289
    286290void GraphicsContext::setShadowsIgnoreTransforms(bool ignoreTransforms)
    287291{
    288     m_common->state.shadowsIgnoreTransforms = ignoreTransforms;
     292    m_state.shadowsIgnoreTransforms = ignoreTransforms;
    289293}
    290294
    291295bool GraphicsContext::updatingControlTints() const
    292296{
    293     return m_common->m_updatingControlTints;
     297    return m_updatingControlTints;
    294298}
    295299
     
    297301{
    298302    setPaintingDisabled(b);
    299     m_common->m_updatingControlTints = b;
     303    m_updatingControlTints = b;
    300304}
    301305
    302306void GraphicsContext::setPaintingDisabled(bool f)
    303307{
    304     m_common->state.paintingDisabled = f;
     308    m_state.paintingDisabled = f;
    305309}
    306310
    307311bool GraphicsContext::paintingDisabled() const
    308312{
    309     return m_common->state.paintingDisabled;
     313    return m_state.paintingDisabled;
    310314}
    311315
     
    529533TextDrawingModeFlags GraphicsContext::textDrawingMode() const
    530534{
    531     return m_common->state.textDrawingMode;
     535    return m_state.textDrawingMode;
    532536}
    533537
    534538void GraphicsContext::setTextDrawingMode(TextDrawingModeFlags mode)
    535539{
    536     m_common->state.textDrawingMode = mode;
     540    m_state.textDrawingMode = mode;
    537541    if (paintingDisabled())
    538542        return;
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r73379 r73492  
    3131#include "DashArray.h"
    3232#include "FloatRect.h"
     33#include "Gradient.h"
    3334#include "Image.h"
    3435#include "IntRect.h"
    3536#include "Path.h"
     37#include "Pattern.h"
    3638#include "TextDirection.h"
    3739#include <wtf/Noncopyable.h>
     
    118120    class Font;
    119121    class Generator;
    120     class Gradient;
    121122    class GraphicsContextPlatformPrivate;
    122     class GraphicsContextPrivate;
    123123    class ImageBuffer;
    124124    class KURL;
    125     class Pattern;
    126125    class SharedGraphicsContext3D;
    127126    class TextRun;
     
    150149    };
    151150
     151    struct GraphicsContextState {
     152        GraphicsContextState()
     153            : strokeThickness(0)
     154            , shadowBlur(0)
     155#if PLATFORM(CAIRO)
     156            , globalAlpha(1)
     157#endif
     158            , textDrawingMode(TextModeFill)
     159            , strokeColor(Color::black)
     160            , fillColor(Color::black)
     161            , strokeStyle(SolidStroke)
     162            , fillRule(RULE_NONZERO)
     163            , strokeColorSpace(ColorSpaceDeviceRGB)
     164            , fillColorSpace(ColorSpaceDeviceRGB)
     165            , shouldAntialias(true)
     166            , paintingDisabled(false)
     167            , shadowsIgnoreTransforms(false)
     168        {
     169        }
     170
     171        RefPtr<Gradient> strokeGradient;
     172        RefPtr<Pattern> strokePattern;
     173       
     174        RefPtr<Gradient> fillGradient;
     175        RefPtr<Pattern> fillPattern;
     176
     177        FloatSize shadowOffset;
     178
     179        float strokeThickness;
     180        float shadowBlur;
     181
     182#if PLATFORM(CAIRO)
     183        float globalAlpha;
     184#endif
     185        TextDrawingModeFlags textDrawingMode;
     186
     187        Color strokeColor;
     188        Color fillColor;
     189        Color shadowColor;
     190
     191        StrokeStyle strokeStyle;
     192        WindRule fillRule;
     193
     194        ColorSpace strokeColorSpace;
     195        ColorSpace fillColorSpace;
     196
     197        bool shouldAntialias;
     198        bool paintingDisabled;
     199        bool shadowsIgnoreTransforms;
     200    };
     201
    152202    class GraphicsContext : public Noncopyable {
    153203    public:
     
    189239        void setShouldAntialias(bool);
    190240        bool shouldAntialias() const;
     241
     242        const GraphicsContextState& state() const;
    191243
    192244#if PLATFORM(CG)
     
    342394        void drawRoundCorner(bool newClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height);
    343395#elif PLATFORM(WIN)
    344         GraphicsContext(HDC, bool hasAlpha = false); // FIXME: To be removed.
     396        void platformInit(HDC, bool hasAlpha = false);
    345397        bool inTransparencyLayer() const;
    346398        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.
     
    419471
    420472    private:
     473        void platformInit(PlatformGraphicsContext*);
     474        void platformDestroy();
     475
    421476        void savePlatformState();
    422477        void restorePlatformState();
     
    442497        static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, const StrokeStyle&);
    443498
    444         static GraphicsContextPrivate* createGraphicsContextPrivate();
    445         static void destroyGraphicsContextPrivate(GraphicsContextPrivate*);
    446 
    447         GraphicsContextPrivate* m_common;
    448         GraphicsContextPlatformPrivate* m_data; // Deprecated; m_commmon can just be downcasted. To be removed.
     499        GraphicsContextPlatformPrivate* m_data;
     500
     501        GraphicsContextState m_state;
     502        Vector<GraphicsContextState> m_stack;
     503        bool m_updatingControlTints;
    449504    };
    450505
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r73490 r73492  
    4242#include "Font.h"
    4343#include "GraphicsContextPlatformPrivateCairo.h"
    44 #include "GraphicsContextPrivate.h"
    4544#include "OwnPtrCairo.h"
    4645#include "IntRect.h"
     
    7069namespace WebCore {
    7170
    72 static inline void setPlatformFill(GraphicsContext* context, cairo_t* cr, GraphicsContextPrivate* gcp)
     71static inline void setPlatformFill(GraphicsContext* context, cairo_t* cr)
    7372{
    7473    cairo_pattern_t* pattern = 0;
    7574    cairo_save(cr);
    76     if (gcp->state.fillPattern) {
     75   
     76    const GraphicsContextState& state = context->state();
     77    if (state.fillPattern) {
    7778        AffineTransform affine;
    78         pattern = gcp->state.fillPattern->createPlatformPattern(affine);
     79        pattern = state.fillPattern->createPlatformPattern(affine);
    7980        cairo_set_source(cr, pattern);
    80     } else if (gcp->state.fillGradient)
    81         cairo_set_source(cr, gcp->state.fillGradient->platformGradient());
     81    } else if (state.fillGradient)
     82        cairo_set_source(cr, state.fillGradient->platformGradient());
    8283    else
    8384        setSourceRGBAFromColor(cr, context->fillColor());
    8485    cairo_clip_preserve(cr);
    85     cairo_paint_with_alpha(cr, gcp->state.globalAlpha);
     86    cairo_paint_with_alpha(cr, state.globalAlpha);
    8687    cairo_restore(cr);
    8788    if (pattern)
     
    8990}
    9091
    91 static inline void setPlatformStroke(GraphicsContext* context, cairo_t* cr, GraphicsContextPrivate* gcp)
     92static inline void setPlatformStroke(GraphicsContext* context, cairo_t* cr)
    9293{
    9394    cairo_pattern_t* pattern = 0;
    9495    cairo_save(cr);
    95     if (gcp->state.strokePattern) {
     96   
     97    const GraphicsContextState& state = context->state();
     98    if (state.strokePattern) {
    9699        AffineTransform affine;
    97         pattern = gcp->state.strokePattern->createPlatformPattern(affine);
     100        pattern = state.strokePattern->createPlatformPattern(affine);
    98101        cairo_set_source(cr, pattern);
    99     } else if (gcp->state.strokeGradient)
    100         cairo_set_source(cr, gcp->state.strokeGradient->platformGradient());
     102    } else if (state.strokeGradient)
     103        cairo_set_source(cr, state.strokeGradient->platformGradient());
    101104    else  {
    102         Color strokeColor = colorWithOverrideAlpha(context->strokeColor().rgb(), context->strokeColor().alpha() / 255.f * gcp->state.globalAlpha);
     105        Color strokeColor = colorWithOverrideAlpha(context->strokeColor().rgb(), context->strokeColor().alpha() / 255.f * state.globalAlpha);
    103106        setSourceRGBAFromColor(cr, strokeColor);
    104107    }
    105     if (gcp->state.globalAlpha < 1.0f && (gcp->state.strokePattern || gcp->state.strokeGradient)) {
     108    if (state.globalAlpha < 1.0f && (state.strokePattern || state.strokeGradient)) {
    106109        cairo_push_group(cr);
    107         cairo_paint_with_alpha(cr, gcp->state.globalAlpha);
     110        cairo_paint_with_alpha(cr, state.globalAlpha);
    108111        cairo_pop_group_to_source(cr);
    109112    }
     
    137140};
    138141
    139 static inline void drawPathShadow(GraphicsContext* context, GraphicsContextPrivate* contextPrivate, PathDrawingStyle drawingStyle)
     142static inline void drawPathShadow(GraphicsContext* context, PathDrawingStyle drawingStyle)
    140143{
    141144    ContextShadow* shadow = context->contextShadow();
     
    173176
    174177    if (drawingStyle & Fill)
    175         setPlatformFill(context, shadowContext, contextPrivate);
     178        setPlatformFill(context, shadowContext);
    176179    if (drawingStyle & Stroke)
    177         setPlatformStroke(context, shadowContext, contextPrivate);
     180        setPlatformStroke(context, shadowContext);
    178181
    179182    shadow->endShadowLayer(cairoContext);
    180183}
    181184
    182 static void fillCurrentCairoPath(GraphicsContext* context, GraphicsContextPrivate* gcp, cairo_t* cairoContext)
     185static void fillCurrentCairoPath(GraphicsContext* context, cairo_t* cairoContext)
    183186{
    184187    cairo_set_fill_rule(cairoContext, context->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
    185     drawPathShadow(context, gcp, Fill);
    186 
    187     setPlatformFill(context, cairoContext, gcp);
     188    drawPathShadow(context, Fill);
     189
     190    setPlatformFill(context, cairoContext);
    188191    cairo_new_path(cairoContext);
    189192}
    190193
    191 static void strokeCurrentCairoPath(GraphicsContext* context, GraphicsContextPrivate* gcp, cairo_t* cairoContext)
    192 {
    193     drawPathShadow(context, gcp, Stroke);
    194     setPlatformStroke(context, cairoContext, gcp);
     194static void strokeCurrentCairoPath(GraphicsContext* context, cairo_t* cairoContext)
     195{
     196    drawPathShadow(context, Stroke);
     197    setPlatformStroke(context, cairoContext);
    195198    cairo_new_path(cairoContext);
    196199}
    197200
    198 GraphicsContext::GraphicsContext(PlatformGraphicsContext* cr)
    199     : m_common(createGraphicsContextPrivate())
    200     , m_data(new GraphicsContextPlatformPrivate)
    201 {
     201void GraphicsContext::platformInit(PlatformGraphicsContext* cr)
     202{
     203    m_data = new GraphicsContextPlatformPrivate;
    202204    m_data->cr = cairo_reference(cr);
    203205    m_data->syncContext(cr);
     
    205207}
    206208
    207 GraphicsContext::~GraphicsContext()
    208 {
    209     destroyGraphicsContextPrivate(m_common);
     209void GraphicsContext::platformDestroy()
     210{
    210211    delete m_data;
    211212}
     
    533534    cairo_t* cr = m_data->cr;
    534535    setPathOnCairoContext(cr, path.platformPath()->context());
    535     fillCurrentCairoPath(this, m_common, cr);
     536    fillCurrentCairoPath(this, cr);
    536537}
    537538
     
    543544    cairo_t* cr = m_data->cr;
    544545    setPathOnCairoContext(cr, path.platformPath()->context());
    545     strokeCurrentCairoPath(this, m_common, cr);
     546    strokeCurrentCairoPath(this, cr);
    546547}
    547548
     
    554555    cairo_save(cr);
    555556    cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
    556     fillCurrentCairoPath(this, m_common, cr);
     557    fillCurrentCairoPath(this, cr);
    557558    cairo_restore(cr);
    558559}
     
    864865{
    865866    // Cairo doesn't support shadows natively, they are drawn manually in the draw* functions
    866     if (m_common->state.shadowsIgnoreTransforms) {
     867    if (m_state.shadowsIgnoreTransforms) {
    867868        // Meaning that this graphics context is associated with a CanvasRenderingContext
    868869        // We flip the height since CG and HTML5 Canvas have opposite Y axis
    869         m_common->state.shadowOffset = FloatSize(size.width(), -size.height());
     870        m_state.shadowOffset = FloatSize(size.width(), -size.height());
    870871        m_data->shadow = ContextShadow(color, blur, FloatSize(size.width(), -size.height()));
    871872    } else
     
    930931    cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
    931932    cairo_set_line_width(cr, width);
    932     strokeCurrentCairoPath(this, m_common, cr);
     933    strokeCurrentCairoPath(this, cr);
    933934    cairo_restore(cr);
    934935}
     
    989990void GraphicsContext::setAlpha(float alpha)
    990991{
    991     m_common->state.globalAlpha = alpha;
     992    m_state.globalAlpha = alpha;
    992993}
    993994
    994995float GraphicsContext::getAlpha()
    995996{
    996     return m_common->state.globalAlpha;
     997    return m_state.globalAlpha;
    997998}
    998999
  • trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r73394 r73492  
    3232#include "FloatConversion.h"
    3333#include "GraphicsContextPlatformPrivateCG.h"
    34 #include "GraphicsContextPrivate.h"
    3534#include "ImageBuffer.h"
    3635#include "KURL.h"
     
    109108}
    110109
    111 GraphicsContext::GraphicsContext(CGContextRef cgContext)
    112     : m_common(createGraphicsContextPrivate())
    113     , m_data(new GraphicsContextPlatformPrivate(cgContext))
    114 {
     110void GraphicsContext::platformInit(CGContextRef cgContext)
     111{
     112    m_data = new GraphicsContextPlatformPrivate(cgContext);
    115113    setPaintingDisabled(!cgContext);
    116114    if (cgContext) {
     
    121119}
    122120
    123 GraphicsContext::~GraphicsContext()
    124 {
    125     destroyGraphicsContextPrivate(m_common);
     121void GraphicsContext::platformDestroy()
     122{
    126123    delete m_data;
    127124}
     
    454451    CGContextRef cgContext = platformContext();
    455452
    456     RetainPtr<CGPatternRef> platformPattern(AdoptCF, m_common->state.strokePattern->createPlatformPattern(getCTM()));
     453    RetainPtr<CGPatternRef> platformPattern(AdoptCF, m_state.strokePattern->createPlatformPattern(getCTM()));
    457454    if (!platformPattern)
    458455        return;
     
    469466    CGContextRef cgContext = platformContext();
    470467
    471     RetainPtr<CGPatternRef> platformPattern(AdoptCF, m_common->state.fillPattern->createPlatformPattern(getCTM()));
     468    RetainPtr<CGPatternRef> platformPattern(AdoptCF, m_state.fillPattern->createPlatformPattern(getCTM()));
    472469    if (!platformPattern)
    473470        return;
     
    513510
    514511    CGContextRef context = platformContext();
    515     const GraphicsContextState& state = m_common->state;
     512    const GraphicsContextState& state = m_state;
    516513
    517514    if (state.fillGradient || state.strokeGradient) {
     
    554551    CGContextAddPath(context, path.platformPath());
    555552
    556     if (m_common->state.fillGradient) {
     553    if (m_state.fillGradient) {
    557554        CGContextSaveGState(context);
    558555        if (fillRule() == RULE_EVENODD)
     
    560557        else
    561558            CGContextClip(context);
    562         CGContextConcatCTM(context, m_common->state.fillGradient->gradientSpaceTransform());
    563         m_common->state.fillGradient->paint(this);
     559        CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());
     560        m_state.fillGradient->paint(this);
    564561        CGContextRestoreGState(context);
    565562        return;
    566563    }
    567564
    568     if (m_common->state.fillPattern)
     565    if (m_state.fillPattern)
    569566        applyFillPattern();
    570567    fillPathWithFillRule(context, fillRule());
     
    581578    CGContextAddPath(context, path.platformPath());
    582579
    583     if (m_common->state.strokeGradient) {
     580    if (m_state.strokeGradient) {
    584581        CGContextSaveGState(context);
    585582        CGContextReplacePathWithStrokedPath(context);
    586583        CGContextClip(context);
    587         CGContextConcatCTM(context, m_common->state.strokeGradient->gradientSpaceTransform());
    588         m_common->state.strokeGradient->paint(this);
     584        CGContextConcatCTM(context, m_state.strokeGradient->gradientSpaceTransform());
     585        m_state.strokeGradient->paint(this);
    589586        CGContextRestoreGState(context);
    590587        return;
    591588    }
    592589
    593     if (m_common->state.strokePattern)
     590    if (m_state.strokePattern)
    594591        applyStrokePattern();
    595592    CGContextStrokePath(context);
     
    603600    CGContextRef context = platformContext();
    604601
    605     if (m_common->state.fillGradient) {
     602    if (m_state.fillGradient) {
    606603        CGContextSaveGState(context);
    607604        CGContextClipToRect(context, rect);
    608         CGContextConcatCTM(context, m_common->state.fillGradient->gradientSpaceTransform());
    609         m_common->state.fillGradient->paint(this);
     605        CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());
     606        m_state.fillGradient->paint(this);
    610607        CGContextRestoreGState(context);
    611608        return;
    612609    }
    613610
    614     if (m_common->state.fillPattern)
     611    if (m_state.fillPattern)
    615612        applyFillPattern();
    616613    CGContextFillRect(context, rect);
     
    742739    CGContextRef context = platformContext();
    743740
    744     if (!m_common->state.shadowsIgnoreTransforms) {
     741    if (!m_state.shadowsIgnoreTransforms) {
    745742        CGAffineTransform userToBaseCTM = wkGetUserToBaseCTM(context);
    746743
     
    817814    CGContextRef context = platformContext();
    818815
    819     if (m_common->state.strokeGradient) {
     816    if (m_state.strokeGradient) {
    820817        CGContextSaveGState(context);
    821818        setStrokeThickness(lineWidth);
     
    823820        CGContextReplacePathWithStrokedPath(context);
    824821        CGContextClip(context);
    825         m_common->state.strokeGradient->paint(this);
     822        m_state.strokeGradient->paint(this);
    826823        CGContextRestoreGState(context);
    827824        return;
    828825    }
    829826
    830     if (m_common->state.strokePattern)
     827    if (m_state.strokePattern)
    831828        applyStrokePattern();
    832829    CGContextStrokeRectWithWidth(context, r, lineWidth);
  • trunk/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp

    r72926 r73492  
    6363}
    6464
    65 GraphicsContext::GraphicsContext(PlatformGraphicsContext* context)
    66     : m_common(createGraphicsContextPrivate())
    67     , m_data(new GraphicsContextPlatformPrivate(context))
    68 {
     65void GraphicsContext::platformInit(PlatformGraphicsContext* context)
     66{
     67    m_data = new GraphicsContextPlatformPrivate(context);
    6968    setPaintingDisabled(!context);
    7069}
    7170
    72 GraphicsContext::~GraphicsContext()
    73 {
    74     destroyGraphicsContextPrivate(m_common);
     71void GraphicsContext::platformDestroy()
     72{
    7573    delete m_data;
    7674}
  • trunk/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp

    r73184 r73492  
    2222
    2323#include "AffineTransform.h"
    24 #include "GraphicsContextPrivate.h"
    2524#include "KURL.h"
    2625#include "NotImplemented.h"
     
    5049};
    5150
    52 GraphicsContext::GraphicsContext(SurfaceOpenVG* surface)
    53     : m_common(createGraphicsContextPrivate())
    54     , m_data(surface ? new GraphicsContextPlatformPrivate(surface) : 0)
    55 {
     51void GraphicsContext::platformInit(SurfaceOpenVG* surface)
     52{
     53    m_data = surface ? new GraphicsContextPlatformPrivate(surface) : 0;
    5654    setPaintingDisabled(!surface);
    5755}
    5856
    59 GraphicsContext::~GraphicsContext()
    60 {
    61     destroyGraphicsContextPrivate(m_common);
     57void GraphicsContext::platformDestroy()
     58{
    6259    delete m_data;
    6360}
     
    145142        return;
    146143
    147     m_data->drawPath(path, VG_FILL_PATH, m_common->state.fillRule);
     144    m_data->drawPath(path, VG_FILL_PATH, m_state.fillRule);
    148145}
    149146
     
    153150        return;
    154151
    155     m_data->drawPath(path, VG_STROKE_PATH, m_common->state.fillRule);
     152    m_data->drawPath(path, VG_STROKE_PATH, m_state.fillRule);
    156153}
    157154
     
    381378        return;
    382379
    383     m_data->clipPath(path, PainterOpenVG::IntersectClip, m_common->state.fillRule);
     380    m_data->clipPath(path, PainterOpenVG::IntersectClip, m_state.fillRule);
    384381}
    385382
     
    394391        return;
    395392
    396     m_data->clipPath(path, PainterOpenVG::SubtractClip, m_common->state.fillRule);
     393    m_data->clipPath(path, PainterOpenVG::SubtractClip, m_state.fillRule);
    397394}
    398395
     
    428425    Path path;
    429426    path.addRect(rect);
    430     m_data->clipPath(path, PainterOpenVG::SubtractClip, m_common->state.fillRule);
     427    m_data->clipPath(path, PainterOpenVG::SubtractClip, m_state.fillRule);
    431428}
    432429
     
    451448        rect.width() - (thickness * 2), rect.height() - (thickness * 2)));
    452449
    453     m_data->clipPath(path, PainterOpenVG::IntersectClip, m_common->state.fillRule);
     450    m_data->clipPath(path, PainterOpenVG::IntersectClip, m_state.fillRule);
    454451}
    455452
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r73362 r73492  
    4747#include "FloatConversion.h"
    4848#include "Font.h"
    49 #include "GraphicsContextPrivate.h"
    5049#include "ImageBuffer.h"
    5150#include "NotImplemented.h"
     
    225224};
    226225
    227 
    228226GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p, const QColor& initialSolidColor)
    229227    : antiAliasingForRectsAndLines(false)
     
    254252}
    255253
    256 GraphicsContext::GraphicsContext(PlatformGraphicsContext* painter)
    257     : m_common(createGraphicsContextPrivate())
    258     , m_data(new GraphicsContextPlatformPrivate(painter, fillColor()))
    259 {
     254void GraphicsContext::platformInit(PlatformGraphicsContext* painter)
     255{
     256    m_data = new GraphicsContextPlatformPrivate(painter, fillColor());
     257
    260258    setPaintingDisabled(!painter);
    261259
     
    272270}
    273271
    274 GraphicsContext::~GraphicsContext()
     272void GraphicsContext::platformDestroy()
    275273{
    276274    while (!m_data->layers.isEmpty())
    277275        endTransparencyLayer();
    278276
    279     destroyGraphicsContextPrivate(m_common);
    280277    delete m_data;
    281278}
     
    511508        ContextShadow* shadow = contextShadow();
    512509        if (shadow->m_type != ContextShadow::BlurShadow
    513             && !m_common->state.fillPattern && !m_common->state.fillGradient)
     510            && !m_state.fillPattern && !m_state.fillGradient)
    514511        {
    515512            QPointF offset = shadow->offset();
     
    538535
    539536    }
    540     if (m_common->state.fillPattern) {
     537    if (m_state.fillPattern) {
    541538        AffineTransform affine;
    542         p->fillPath(platformPath, QBrush(m_common->state.fillPattern->createPlatformPattern(affine)));
    543     } else if (m_common->state.fillGradient) {
    544         QBrush brush(*m_common->state.fillGradient->platformGradient());
    545         brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform());
     539        p->fillPath(platformPath, QBrush(m_state.fillPattern->createPlatformPattern(affine)));
     540    } else if (m_state.fillGradient) {
     541        QBrush brush(*m_state.fillGradient->platformGradient());
     542        brush.setTransform(m_state.fillGradient->gradientSpaceTransform());
    546543        p->fillPath(platformPath, brush);
    547544    } else
     
    563560
    564561        if (shadow->m_type != ContextShadow::BlurShadow
    565             && !m_common->state.strokePattern && !m_common->state.strokeGradient)
     562            && !m_state.strokePattern && !m_state.strokeGradient)
    566563        {
    567564            QPen shadowPen(pen);
     
    594591    }
    595592
    596     if (m_common->state.strokePattern) {
     593    if (m_state.strokePattern) {
    597594        AffineTransform affine;
    598         pen.setBrush(QBrush(m_common->state.strokePattern->createPlatformPattern(affine)));
     595        pen.setBrush(QBrush(m_state.strokePattern->createPlatformPattern(affine)));
    599596        p->setPen(pen);
    600597        p->strokePath(platformPath, pen);
    601     } else if (m_common->state.strokeGradient) {
    602         QBrush brush(*m_common->state.strokeGradient->platformGradient());
    603         brush.setTransform(m_common->state.strokeGradient->gradientSpaceTransform());
     598    } else if (m_state.strokeGradient) {
     599        QBrush brush(*m_state.strokeGradient->platformGradient());
     600        brush.setTransform(m_state.strokeGradient->gradientSpaceTransform());
    604601        pen.setBrush(brush);
    605602        p->setPen(pen);
     
    685682    ContextShadow* shadow = contextShadow();
    686683
    687     if (m_common->state.fillPattern) {
     684    if (m_state.fillPattern) {
    688685        AffineTransform affine;
    689         QBrush brush(m_common->state.fillPattern->createPlatformPattern(affine));
    690         QPixmap* image = m_common->state.fillPattern->tileImage()->nativeImageForCurrentFrame();
     686        QBrush brush(m_state.fillPattern->createPlatformPattern(affine));
     687        QPixmap* image = m_state.fillPattern->tileImage()->nativeImageForCurrentFrame();
    691688        QPainter* shadowPainter = m_data->hasShadow() ? shadow->beginShadowLayer(p, normalizedRect) : 0;
    692689        if (shadowPainter) {
    693             drawRepeatPattern(shadowPainter, image, normalizedRect, m_common->state.fillPattern->repeatX(), m_common->state.fillPattern->repeatY());
     690            drawRepeatPattern(shadowPainter, image, normalizedRect, m_state.fillPattern->repeatX(), m_state.fillPattern->repeatY());
    694691            shadowPainter->setCompositionMode(QPainter::CompositionMode_SourceIn);
    695692            shadowPainter->fillRect(normalizedRect, shadow->m_color);
    696693            shadow->endShadowLayer(p);
    697694        }
    698         drawRepeatPattern(p, image, normalizedRect, m_common->state.fillPattern->repeatX(), m_common->state.fillPattern->repeatY());
    699     } else if (m_common->state.fillGradient) {
    700         QBrush brush(*m_common->state.fillGradient->platformGradient());
    701         brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform());
     695        drawRepeatPattern(p, image, normalizedRect, m_state.fillPattern->repeatX(), m_state.fillPattern->repeatY());
     696    } else if (m_state.fillGradient) {
     697        QBrush brush(*m_state.fillGradient->platformGradient());
     698        brush.setTransform(m_state.fillGradient->gradientSpaceTransform());
    702699        QPainter* shadowPainter = m_data->hasShadow() ? shadow->beginShadowLayer(p, normalizedRect) : 0;
    703700        if (shadowPainter) {
     
    970967    // functions
    971968
    972     if (m_common->state.shadowsIgnoreTransforms) {
     969    if (m_state.shadowsIgnoreTransforms) {
    973970        // Meaning that this graphics context is associated with a CanvasRenderingContext
    974971        // We flip the height since CG and HTML5 Canvas have opposite Y axis
    975         m_common->state.shadowOffset = FloatSize(size.width(), -size.height());
     972        m_state.shadowOffset = FloatSize(size.width(), -size.height());
    976973        m_data->shadow = ContextShadow(color, blur, FloatSize(size.width(), -size.height()));
    977974    } else {
  • trunk/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp

    r73291 r73492  
    3838#include "Gradient.h"
    3939#include "GraphicsContextPlatformPrivate.h"
    40 #include "GraphicsContextPrivate.h"
    4140#include "ImageBuffer.h"
    4241#include "IntRect.h"
     
    220219// This may be called with a NULL pointer to create a graphics context that has
    221220// no painting.
    222 GraphicsContext::GraphicsContext(PlatformGraphicsContext* gc)
    223     : m_common(createGraphicsContextPrivate())
    224     , m_data(new GraphicsContextPlatformPrivate(gc))
    225 {
     221void GraphicsContext::platformInit(PlatformGraphicsContext* gc)
     222{
     223    m_data = new GraphicsContextPlatformPrivate(gc);
    226224    setPaintingDisabled(!gc || !platformContext()->canvas());
    227225}
    228226
    229 GraphicsContext::~GraphicsContext()
     227void GraphicsContext::platformDestroy()
    230228{
    231229    delete m_data;
    232     this->destroyGraphicsContextPrivate(m_common);
    233230}
    234231
     
    743740    platformContext()->prepareForSoftwareDraw();
    744741
    745     const GraphicsContextState& state = m_common->state;
     742    const GraphicsContextState& state = m_state;
    746743    path.setFillType(state.fillRule == RULE_EVENODD ?
    747744        SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);
     
    10721069    // TODO(tc): This still does not address the issue that shadows
    10731070    // within canvas elements should ignore transforms.
    1074     if (m_common->state.shadowsIgnoreTransforms)  {
     1071    if (m_state.shadowsIgnoreTransforms)  {
    10751072        // Currently only the GraphicsContext associated with the
    10761073        // CanvasRenderingContext for HTMLCanvasElement have shadows ignore
  • trunk/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp

    r72528 r73492  
    6262}
    6363
    64 GraphicsContext::GraphicsContext(HDC hdc, bool hasAlpha)
    65     : m_common(createGraphicsContextPrivate())
    66     , m_data(new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha)))
    67 {
     64void GraphicsContext::platformInit(HDC hdc, bool hasAlpha)
     65{
     66    m_data = new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha));
    6867    CGContextRelease(m_data->m_cgContext.get());
    6968    m_data->m_hdc = hdc;
  • trunk/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp

    r67125 r73492  
    6565}
    6666
    67 GraphicsContext::GraphicsContext(HDC dc, bool hasAlpha)
    68     : m_common(createGraphicsContextPrivate())
    69     , m_data(new GraphicsContextPlatformPrivate)
     67void GraphicsContext::platformInit(HDC dc, bool hasAlpha)
    7068{
     69    m_data = new GraphicsContextPlatformPrivate;
     70
    7171    if (dc) {
    7272        m_data->cr = createCairoContextWithHDC(dc, hasAlpha);
  • trunk/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp

    r73284 r73492  
    2929#include "GlyphBuffer.h"
    3030#include "Gradient.h"
    31 #include "GraphicsContextPrivate.h"
    3231#include "NotImplemented.h"
    3332#include "Path.h"
     
    581580
    582581
    583 GraphicsContext::GraphicsContext(PlatformGraphicsContext* dc)
    584 : m_common(createGraphicsContextPrivate())
    585 , m_data(new GraphicsContextPlatformPrivate(dc))
    586 {
    587 }
    588 
    589 GraphicsContext::~GraphicsContext()
    590 {
    591     destroyGraphicsContextPrivate(m_common);
     582void GraphicsContext::platformInit(PlatformGraphicsContext* dc)
     583{
     584    m_data = new GraphicsContextPlatformPrivate(dc);
     585}
     586
     587void GraphicsContext::platformDestroy()
     588{
    592589    delete m_data;
    593590}
     
    13171314void GraphicsContext::fillPath(const Path& path)
    13181315{
    1319     Color c = m_common->state.fillGradient
    1320         ? gradientAverageColor(m_common->state.fillGradient.get())
     1316    Color c = m_state.fillGradient
     1317        ? gradientAverageColor(m_state.fillGradient.get())
    13211318        : fillColor();
    13221319
     
    14881485    savePlatformState();
    14891486
    1490     if (m_common->state.fillGradient)
    1491         fillRect(rect, m_common->state.fillGradient.get());
     1487    if (m_state.fillGradient)
     1488        fillRect(rect, m_state.fillGradient.get());
    14921489    else
    14931490        fillRect(rect, fillColor(), ColorSpaceDeviceRGB);
  • trunk/WebCore/platform/graphics/wx/GraphicsContextWx.cpp

    r73129 r73492  
    113113
    114114
    115 GraphicsContext::GraphicsContext(PlatformGraphicsContext* context)
    116     : m_common(createGraphicsContextPrivate())
    117     , m_data(new GraphicsContextPlatformPrivate)
    118 {   
     115void GraphicsContext::platformInit(PlatformGraphicsContext* context)
     116{
     117    m_data = new GraphicsContextPlatformPrivate;
    119118    setPaintingDisabled(!context);
     119
    120120    if (context) {
    121121        // Make sure the context starts in sync with our state.
     
    130130}
    131131
    132 GraphicsContext::~GraphicsContext()
    133 {
    134     destroyGraphicsContextPrivate(m_common);
     132void GraphicsContext::platformDestroy()
     133{
    135134    delete m_data;
    136135}
Note: See TracChangeset for help on using the changeset viewer.