Changeset 35966 in webkit


Ignore:
Timestamp:
Aug 28, 2008 5:04:40 AM (16 years ago)
Author:
eric@webkit.org
Message:

Reviewed by Oliver Hunt.

Add stroke/fill Gradient and Pattern support to GraphicsContext and update <canvas> to use it.
https://bugs.webkit.org/show_bug.cgi?id=20373

Changed pattern() to canvasPattern() on CanvasStyle to match canvasGradient()

Made Generator (aka Gradient) RefCounted so that GraphicsContext didn't
have to store large Gradient objects in the GraphicsContextState

Made Pattern RefCounted for the same reason.

Many updates to GraphicsContext to support easier drawing with
Patterns and Gradients.

  • WebCore.xcodeproj/project.pbxproj: Add pre-existing GraphicsContextPrivate.h
  • bindings/js/JSCanvasRenderingContext2DCustom.cpp: (WebCore::toJS):
  • css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::createGradient):
  • css/CSSGradientValue.h:
  • html/CanvasGradient.cpp: (WebCore::CanvasGradient::CanvasGradient):
  • html/CanvasGradient.h: (WebCore::CanvasGradient::gradient): (WebCore::CanvasGradient::addColorStop): (WebCore::CanvasGradient::getColor):
  • html/CanvasPattern.cpp:
  • html/CanvasPattern.h: (WebCore::CanvasPattern::pattern): (WebCore::CanvasPattern::originClean):
  • html/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::State::State): (WebCore::CanvasRenderingContext2D::setStrokeStyle): (WebCore::CanvasRenderingContext2D::setFillStyle): (WebCore::CanvasRenderingContext2D::fill): (WebCore::CanvasRenderingContext2D::stroke): (WebCore::CanvasRenderingContext2D::fillRect): (WebCore::CanvasRenderingContext2D::strokeRect):
  • html/CanvasRenderingContext2D.h:
  • html/CanvasStyle.cpp: (WebCore::CanvasStyle::applyStrokeColor): (WebCore::CanvasStyle::applyFillColor):
  • html/CanvasStyle.h:
  • platform/graphics/GeneratedImage.h: (WebCore::GeneratedImage::GeneratedImage):
  • platform/graphics/Generator.h:
  • platform/graphics/Gradient.h: (WebCore::Gradient::create):
  • platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::fillRule): (WebCore::GraphicsContext::setFillRule): (WebCore::GraphicsContext::setStrokePattern): (WebCore::GraphicsContext::setFillPattern): (WebCore::GraphicsContext::setStrokeGradient): (WebCore::GraphicsContext::setFillGradient):
  • platform/graphics/GraphicsContext.h:
  • platform/graphics/GraphicsContextPrivate.h: (WebCore::): (WebCore::GraphicsContextState::GraphicsContextState):
  • platform/graphics/GraphicsTypes.h:
  • platform/graphics/Path.h:
  • platform/graphics/Pattern.h: (WebCore::Pattern::create): (WebCore::Pattern::tileImage):
  • platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::GraphicsContext::drawRect): (WebCore::GraphicsContext::drawEllipse): (WebCore::GraphicsContext::drawConvexPolygon): (WebCore::calculateDrawingMode): (WebCore::GraphicsContext::drawPath): (WebCore::fillPathWithFillRule): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::fillRect): (WebCore::GraphicsContext::fillRoundedRect): (WebCore::GraphicsContext::setPlatformStrokePattern): (WebCore::GraphicsContext::setPlatformFillPattern): (WebCore::GraphicsContext::setPlatformStrokeGradient): (WebCore::GraphicsContext::setPlatformFillGradient):
Location:
trunk/WebCore
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r35964 r35966  
     12008-08-27  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Add stroke/fill Gradient and Pattern support to GraphicsContext and update <canvas> to use it.
     6        https://bugs.webkit.org/show_bug.cgi?id=20373
     7
     8        Changed pattern() to canvasPattern() on CanvasStyle to match canvasGradient()
     9       
     10        Made Generator (aka Gradient) RefCounted so that GraphicsContext didn't
     11        have to store large Gradient objects in the GraphicsContextState
     12       
     13        Made Pattern RefCounted for the same reason.
     14       
     15        Many updates to GraphicsContext to support easier drawing with
     16        Patterns and Gradients.
     17
     18        * WebCore.xcodeproj/project.pbxproj: Add pre-existing GraphicsContextPrivate.h
     19        * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
     20        (WebCore::toJS):
     21        * css/CSSGradientValue.cpp:
     22        (WebCore::CSSGradientValue::createGradient):
     23        * css/CSSGradientValue.h:
     24        * html/CanvasGradient.cpp:
     25        (WebCore::CanvasGradient::CanvasGradient):
     26        * html/CanvasGradient.h:
     27        (WebCore::CanvasGradient::gradient):
     28        (WebCore::CanvasGradient::addColorStop):
     29        (WebCore::CanvasGradient::getColor):
     30        * html/CanvasPattern.cpp:
     31        * html/CanvasPattern.h:
     32        (WebCore::CanvasPattern::pattern):
     33        (WebCore::CanvasPattern::originClean):
     34        * html/CanvasRenderingContext2D.cpp:
     35        (WebCore::CanvasRenderingContext2D::State::State):
     36        (WebCore::CanvasRenderingContext2D::setStrokeStyle):
     37        (WebCore::CanvasRenderingContext2D::setFillStyle):
     38        (WebCore::CanvasRenderingContext2D::fill):
     39        (WebCore::CanvasRenderingContext2D::stroke):
     40        (WebCore::CanvasRenderingContext2D::fillRect):
     41        (WebCore::CanvasRenderingContext2D::strokeRect):
     42        * html/CanvasRenderingContext2D.h:
     43        * html/CanvasStyle.cpp:
     44        (WebCore::CanvasStyle::applyStrokeColor):
     45        (WebCore::CanvasStyle::applyFillColor):
     46        * html/CanvasStyle.h:
     47        * platform/graphics/GeneratedImage.h:
     48        (WebCore::GeneratedImage::GeneratedImage):
     49        * platform/graphics/Generator.h:
     50        * platform/graphics/Gradient.h:
     51        (WebCore::Gradient::create):
     52        * platform/graphics/GraphicsContext.cpp:
     53        (WebCore::GraphicsContext::fillRule):
     54        (WebCore::GraphicsContext::setFillRule):
     55        (WebCore::GraphicsContext::setStrokePattern):
     56        (WebCore::GraphicsContext::setFillPattern):
     57        (WebCore::GraphicsContext::setStrokeGradient):
     58        (WebCore::GraphicsContext::setFillGradient):
     59        * platform/graphics/GraphicsContext.h:
     60        * platform/graphics/GraphicsContextPrivate.h:
     61        (WebCore::):
     62        (WebCore::GraphicsContextState::GraphicsContextState):
     63        * platform/graphics/GraphicsTypes.h:
     64        * platform/graphics/Path.h:
     65        * platform/graphics/Pattern.h:
     66        (WebCore::Pattern::create):
     67        (WebCore::Pattern::tileImage):
     68        * platform/graphics/cg/GraphicsContextCG.cpp:
     69        (WebCore::GraphicsContext::drawRect):
     70        (WebCore::GraphicsContext::drawEllipse):
     71        (WebCore::GraphicsContext::drawConvexPolygon):
     72        (WebCore::calculateDrawingMode):
     73        (WebCore::GraphicsContext::drawPath):
     74        (WebCore::fillPathWithFillRule):
     75        (WebCore::GraphicsContext::fillPath):
     76        (WebCore::GraphicsContext::strokePath):
     77        (WebCore::GraphicsContext::fillRect):
     78        (WebCore::GraphicsContext::fillRoundedRect):
     79        (WebCore::GraphicsContext::setPlatformStrokePattern):
     80        (WebCore::GraphicsContext::setPlatformFillPattern):
     81        (WebCore::GraphicsContext::setPlatformStrokeGradient):
     82        (WebCore::GraphicsContext::setPlatformFillGradient):
     83
    1842008-08-20  Eric Seidel  <eric@webkit.org>
    285
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r35939 r35966  
    22942294                A88DD4870B4629A300C02990 /* PathTraversalState.h in Headers */ = {isa = PBXBuildFile; fileRef = A88DD4860B4629A300C02990 /* PathTraversalState.h */; };
    22952295                A88DD4890B4629B000C02990 /* PathTraversalState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A88DD4880B4629B000C02990 /* PathTraversalState.cpp */; };
     2296                A88FE3340E5EEE87008D8C0F /* GraphicsContextPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A88FE3330E5EEE87008D8C0F /* GraphicsContextPrivate.h */; };
    22962297                A89943280B42338800D7C802 /* BitmapImage.h in Headers */ = {isa = PBXBuildFile; fileRef = A89943260B42338700D7C802 /* BitmapImage.h */; };
    22972298                A89943290B42338800D7C802 /* BitmapImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A89943270B42338700D7C802 /* BitmapImage.cpp */; };
     
    66646665                A88DD4860B4629A300C02990 /* PathTraversalState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PathTraversalState.h; sourceTree = "<group>"; };
    66656666                A88DD4880B4629B000C02990 /* PathTraversalState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PathTraversalState.cpp; sourceTree = "<group>"; };
     6667                A88FE3330E5EEE87008D8C0F /* GraphicsContextPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextPrivate.h; sourceTree = "<group>"; };
    66666668                A89943260B42338700D7C802 /* BitmapImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitmapImage.h; sourceTree = "<group>"; };
    66676669                A89943270B42338700D7C802 /* BitmapImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitmapImage.cpp; sourceTree = "<group>"; };
     
    1222412226                                BC53C6070DA56C570021EB5D /* Gradient.cpp */,
    1222512227                                BC53C5F40DA56B920021EB5D /* Gradient.h */,
     12228                                A88FE3330E5EEE87008D8C0F /* GraphicsContextPrivate.h */,
    1222612229                                B2A015920AF6CD53006BCE0E /* GraphicsContext.cpp */,
    1222712230                                B2A015930AF6CD53006BCE0E /* GraphicsContext.h */,
     
    1544115444                                08A484780E5272C500C3FE76 /* ScriptElement.h in Headers */,
    1544215445                                A8FA6E5D0E4CFDED00D5CF49 /* Pattern.h in Headers */,
     15446                                A88FE3340E5EEE87008D8C0F /* GraphicsContextPrivate.h in Headers */,
    1544315447                        );
    1544415448                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp

    r35291 r35966  
    4545    if (style->canvasGradient())
    4646        return toJS(exec, style->canvasGradient());
    47     if (style->pattern())
    48         return toJS(exec, style->pattern());
     47    if (style->canvasPattern())
     48        return toJS(exec, style->canvasPattern());
    4949    return jsString(exec, style->color());
    5050}
  • trunk/WebCore/css/CSSGradientValue.cpp

    r32263 r35966  
    7272}
    7373
    74 Gradient* CSSGradientValue::createGradient(RenderObject* renderer, const IntSize& size)
     74PassRefPtr<Gradient> CSSGradientValue::createGradient(RenderObject* renderer, const IntSize& size)
    7575{
    7676    ASSERT(!size.isEmpty());
     
    8181    FloatPoint secondPoint = resolvePoint(m_secondX.get(), m_secondY.get(), size, zoomFactor);
    8282   
    83     Gradient* gradient = 0;
     83    RefPtr<Gradient> gradient;
    8484    if (m_type == CSSLinearGradient)
    85         gradient = new Gradient(firstPoint, secondPoint);
     85        gradient = Gradient::create(firstPoint, secondPoint);
    8686    else {
    8787        float firstRadius = resolveRadius(m_firstRadius.get(), zoomFactor);
    8888        float secondRadius = resolveRadius(m_secondRadius.get(), zoomFactor);
    89         gradient = new Gradient(firstPoint, firstRadius, secondPoint, secondRadius);
     89        gradient = Gradient::create(firstPoint, firstRadius, secondPoint, secondRadius);
    9090    }
    9191
     
    102102    gradient->setStopsSorted(true);
    103103
    104     return gradient;
     104    return gradient.release();
    105105}
    106106
  • trunk/WebCore/css/CSSGradientValue.h

    r34627 r35966  
    8383   
    8484    // Create the gradient for a given size.
    85     Gradient* createGradient(RenderObject*, const IntSize&);
     85    PassRefPtr<Gradient> createGradient(RenderObject*, const IntSize&);
    8686   
    8787    // Resolve points/radii to front end values.
  • trunk/WebCore/html/CanvasGradient.cpp

    r34366 r35966  
    3333
    3434CanvasGradient::CanvasGradient(const FloatPoint& p0, const FloatPoint& p1)
    35     : m_gradient(p0, p1)
     35    : m_gradient(Gradient::create(p0, p1))
    3636{
    3737}
    3838
    3939CanvasGradient::CanvasGradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1)
    40     : m_gradient(p0, r0, p1, r1)
     40    : m_gradient(Gradient::create(p0, r0, p1, r1))
    4141{
    4242}
  • trunk/WebCore/html/CanvasGradient.h

    r34432 r35966  
    4747        }
    4848       
    49         Gradient& gradient() { return m_gradient; }
     49        Gradient* gradient() const { return m_gradient.get(); }
    5050
    51         void addColorStop(float value, const String& color) { m_gradient.addColorStop(value, color); }
     51        void addColorStop(float value, const String& color) { m_gradient->addColorStop(value, color); }
    5252
    53         void getColor(float value, float* r, float* g, float* b, float* a) const { m_gradient.getColor(value, r, g, b, a); }
     53        void getColor(float value, float* r, float* g, float* b, float* a) const { m_gradient->getColor(value, r, g, b, a); }
    5454
    5555    private:
     
    5757        CanvasGradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1);
    5858       
    59         Gradient m_gradient;
     59        RefPtr<Gradient> m_gradient;
    6060    };
    6161
  • trunk/WebCore/html/CanvasPattern.cpp

    r35732 r35966  
    5959
    6060CanvasPattern::CanvasPattern(Image* image, bool repeatX, bool repeatY, bool originClean)
    61     : m_pattern(image, repeatX, repeatY)
     61    : m_pattern(Pattern::create(image, repeatX, repeatY))
    6262    , m_originClean(originClean)
    6363{
  • trunk/WebCore/html/CanvasPattern.h

    r35732 r35966  
    4646            return adoptRef(new CanvasPattern(image, repeatX, repeatY, originClean));
    4747        }
    48        
    49         const Pattern& pattern() { return m_pattern; }
     48
     49        Pattern* pattern() const { return m_pattern.get(); }
    5050
    5151        bool originClean() const { return m_originClean; }
     
    5454        CanvasPattern(Image*, bool repeatX, bool repeatY, bool originClean);
    5555
    56         Pattern m_pattern;
     56        RefPtr<Pattern> m_pattern;
    5757        bool m_originClean;
    5858    };
  • trunk/WebCore/html/CanvasRenderingContext2D.cpp

    r35955 r35966  
    33 * Copyright (C) 2007 Trolltech ASA
    44 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
     5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
    56 *
    67 * Redistribution and use in source and binary forms, with or without
     
    102103    , m_globalAlpha(1)
    103104    , m_globalComposite(CompositeSourceOver)
    104     , m_appliedStrokePattern(false)
    105     , m_appliedFillPattern(false)
    106105{
    107106}
     
    142141
    143142    if (m_canvas->originClean()) {
    144         if (CanvasPattern* pattern = style->pattern()) {
     143        if (CanvasPattern* pattern = style->canvasPattern()) {
    145144            if (!pattern->originClean())
    146145                m_canvas->setOriginTainted();
     
    153152        return;
    154153    state().m_strokeStyle->applyStrokeColor(c);
    155     state().m_appliedStrokePattern = false;
    156154}
    157155
     
    167165 
    168166    if (m_canvas->originClean()) {
    169         if (CanvasPattern* pattern = style->pattern()) {
     167        if (CanvasPattern* pattern = style->canvasPattern()) {
    170168            if (!pattern->originClean())
    171169                m_canvas->setOriginTainted();
     
    178176        return;
    179177    state().m_fillStyle->applyFillColor(c);
    180     state().m_appliedFillPattern = false;
    181178}
    182179
     
    543540        willDraw(m_path.boundingRect());
    544541
    545 #if PLATFORM(CG)
    546     if (state().m_fillStyle->canvasGradient()) {
    547         // Shading works on the entire clip region, so convert the current path to a clip.
    548         c->save();
    549         CGContextClip(c->platformContext());
    550         CGContextDrawShading(c->platformContext(), state().m_fillStyle->canvasGradient()->gradient().platformGradient());       
    551         c->restore();
    552     } else {
    553         if (state().m_fillStyle->pattern())
    554             applyFillPattern();
    555         CGContextFillPath(c->platformContext());
    556     }
    557 #elif PLATFORM(QT)
    558     QPainterPath* path = m_path.platformPath();
    559     QPainter* p = static_cast<QPainter*>(c->platformContext());
    560     if (state().m_fillStyle->canvasGradient()) {
    561         p->fillPath(*path, QBrush(*(state().m_fillStyle->canvasGradient()->gradient().platformGradient())));
    562     } else {
    563         if (state().m_fillStyle->pattern())
    564             applyFillPattern();
    565         p->fillPath(*path, p->brush());
    566     }
    567 #elif PLATFORM(CAIRO)
    568     cairo_t* cr = c->platformContext();
    569     cairo_save(cr);
    570 
    571     if (state().m_fillStyle->canvasGradient()) {
    572         cairo_set_source(cr, state().m_fillStyle->canvasGradient()->gradient().platformGradient());
    573         cairo_fill(cr);
    574     } else {
    575         if (state().m_fillStyle->pattern())
    576             applyFillPattern();
    577         else {
    578             float red, green, blue, alpha;
    579             c->fillColor().getRGBA(red, green, blue, alpha);
    580             cairo_set_source_rgba(cr, red, green, blue, alpha);
    581         }
    582         cairo_fill(cr);
    583     }
    584     cairo_restore(cr);
    585 #endif
     542    c->fillPath();
    586543
    587544#if ENABLE(DASHBOARD_SUPPORT)
     
    606563        willDraw(boundingRect);
    607564    }
    608    
    609     // FIXME: Do this through platform-independent GraphicsContext API.
    610 #if PLATFORM(CG)
    611     if (state().m_strokeStyle->canvasGradient()) {
    612         // Shading works on the entire clip region, so convert the current path to a clip.
    613         c->save();
    614         CGContextReplacePathWithStrokedPath(c->platformContext());
    615         CGContextClip(c->platformContext());
    616         CGContextDrawShading(c->platformContext(), state().m_strokeStyle->canvasGradient()->gradient().platformGradient());       
    617         c->restore();
    618     } else {
    619         if (state().m_strokeStyle->pattern())
    620             applyStrokePattern();
    621         CGContextStrokePath(c->platformContext());
    622     }
    623 #elif PLATFORM(QT)
    624     QPainterPath* path = m_path.platformPath();
    625     QPainter* p = static_cast<QPainter*>(c->platformContext());
    626     if (state().m_strokeStyle->canvasGradient()) {
    627         p->save();
    628         p->setBrush(*(state().m_strokeStyle->canvasGradient()->gradient().platformGradient()));
    629         p->strokePath(*path, p->pen());
    630         p->restore();
    631     } else {
    632         if (state().m_strokeStyle->pattern())
    633             applyStrokePattern();
    634         p->strokePath(*path, p->pen());
    635     }
    636 #elif PLATFORM(CAIRO)
    637     cairo_t* cr = c->platformContext();
    638     cairo_save(cr);
    639     if (state().m_strokeStyle->canvasGradient()) {
    640         cairo_set_source(cr, state().m_strokeStyle->canvasGradient()->gradient().platformGradient());
    641         c->addPath(m_path);
    642         cairo_stroke(cr);
    643     } else {
    644         if (state().m_strokeStyle->pattern())
    645             applyStrokePattern();
    646         else {
    647             float red, green, blue, alpha;
    648             c->strokeColor().getRGBA(red, green, blue, alpha);
    649             cairo_set_source_rgba(cr, red, green, blue, alpha);
    650         }
    651         c->addPath(m_path);
    652         cairo_stroke(cr);
    653     }
    654     cairo_restore(cr);
    655 #endif
     565
     566    c->strokePath();
    656567
    657568#if ENABLE(DASHBOARD_SUPPORT)
     
    710621    willDraw(rect);
    711622
    712     // FIXME: Do this through platform-independent GraphicsContext API.
    713 #if PLATFORM(CG)
    714     if (state().m_fillStyle->canvasGradient()) {
    715         c->save();
    716         state().m_fillStyle->canvasGradient()->gradient().fill(c, rect);
    717         c->restore();
    718     } else {
    719         if (state().m_fillStyle->pattern())
    720             applyFillPattern();
    721         CGContextFillRect(c->platformContext(), rect);
    722     }
    723 #elif PLATFORM(QT)
    724     QPainter* p = static_cast<QPainter*>(c->platformContext());
    725     if (state().m_fillStyle->canvasGradient()) {
    726         p->fillRect(rect, QBrush(*(state().m_fillStyle->canvasGradient()->gradient().platformGradient())));
    727     } else {
    728         if (state().m_fillStyle->pattern())
    729             applyFillPattern();
    730         p->fillRect(rect, p->brush());
    731     }
    732 #elif PLATFORM(CAIRO)
    733     cairo_t* cr = c->platformContext();
    734     cairo_save(cr);
    735     if (state().m_fillStyle->canvasGradient()) {
    736         state().m_fillStyle->canvasGradient()->gradient().fill(c, rect);
    737     } else {
    738         if (state().m_fillStyle->pattern()) {
    739             applyFillPattern();
    740             cairo_rectangle(cr, x, y, width, height);
    741             cairo_fill(cr);
    742         } else
    743             c->fillRect(rect, c->fillColor());
    744     }
    745    
    746     cairo_restore(cr);
    747 #endif
     623    c->save();
     624    c->fillRect(rect);
     625    c->restore();
    748626}
    749627
     
    772650    boundingRect.inflate(lineWidth / 2);
    773651    willDraw(boundingRect);
    774 
    775     // FIXME: No support for gradients!
    776     if (state().m_strokeStyle->pattern())
    777         applyStrokePattern();
    778652
    779653    c->strokeRect(rect, lineWidth);
     
    11751049}
    11761050
    1177 void CanvasRenderingContext2D::applyStrokePattern()
    1178 {
    1179     GraphicsContext* c = drawingContext();
    1180     if (!c)
    1181         return;
    1182 
    1183     // FIXME: Can this check be moved into GraphicsContext? or removed?
    1184 #if PLATFORM(CG)
    1185     // Check for case where the pattern is already set.
    1186     AffineTransform ctm = c->getCTM();
    1187     if (state().m_appliedStrokePattern && ctm == state().m_strokeStylePatternTransform)
    1188         return;
    1189 #endif
    1190 
    1191     CanvasPattern* pattern = state().m_strokeStyle->pattern();
    1192     if (!pattern)
    1193         return;
    1194 
    1195     c->applyStrokePattern(pattern->pattern());
    1196 
    1197 #if PLATFORM(CG)
    1198     state().m_strokeStylePatternTransform = ctm;
    1199 #endif
    1200     state().m_appliedStrokePattern = true;
    1201 }
    1202 
    1203 void CanvasRenderingContext2D::applyFillPattern()
    1204 {
    1205     GraphicsContext* c = drawingContext();
    1206     if (!c)
    1207         return;
    1208 
    1209     // FIXME: Can this check be moved into GraphicsContext? or removed?
    1210 #if PLATFORM(CG)
    1211     // Check for case where the pattern is already set.
    1212     AffineTransform ctm = c->getCTM();
    1213     if (state().m_appliedFillPattern && ctm == state().m_fillStylePatternTransform)
    1214         return;
    1215 #endif
    1216 
    1217     CanvasPattern* pattern = state().m_fillStyle->pattern();
    1218     if (!pattern)
    1219         return;
    1220 
    1221     c->applyFillPattern(pattern->pattern());
    1222 
    1223 #if PLATFORM(CG)
    1224     state().m_fillStylePatternTransform = ctm;
    1225 #endif
    1226     state().m_appliedFillPattern = true;
    1227 }
    1228 
    12291051static PassRefPtr<ImageData> createEmptyImageData(const IntSize& size)
    12301052{
  • trunk/WebCore/html/CanvasRenderingContext2D.h

    r35732 r35966  
    192192            float m_globalAlpha;
    193193            CompositeOperator m_globalComposite;
    194             bool m_appliedStrokePattern;
    195             bool m_appliedFillPattern;
    196194            AffineTransform m_transform;
    197 #if PLATFORM(CG)
    198             AffineTransform m_strokeStylePatternTransform;
    199             AffineTransform m_fillStylePatternTransform;
    200 #endif
    201195        };
    202196        Path m_path;
  • trunk/WebCore/html/CanvasStyle.cpp

    r35766 r35966  
    33 * Copyright (C) 2007 Trolltech ASA
    44 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
     5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
    56 *
    67 * Redistribution and use in source and binary forms, with or without
     
    142143        }
    143144        case Gradient:
     145            context->setStrokeGradient(canvasGradient()->gradient());
     146            break;
    144147        case ImagePattern:
     148            context->setStrokePattern(canvasPattern()->pattern());
    145149            break;
    146150    }
     
    188192        }
    189193        case Gradient:
     194            context->setFillGradient(canvasGradient()->gradient());
     195            break;
    190196        case ImagePattern:
     197            context->setFillPattern(canvasPattern()->pattern());
    191198            break;
    192199    }
  • trunk/WebCore/html/CanvasStyle.h

    r35730 r35966  
    4848        String color() const { return m_color; }
    4949        CanvasGradient* canvasGradient() const { return m_gradient.get(); }
    50         CanvasPattern* pattern() const { return m_pattern.get(); }
     50        CanvasPattern* canvasPattern() const { return m_pattern.get(); }
    5151
    52         // These do nothing for gradients or patterns.
    5352        void applyFillColor(GraphicsContext*);
    5453        void applyStrokeColor(GraphicsContext*);
  • trunk/WebCore/platform/graphics/GeneratedImage.h

    r35934 r35966  
    3131#include "Generator.h"
    3232#include "IntSize.h"
    33 #include <wtf/OwnPtr.h>
     33#include <wtf/RefPtr.h>
    3434
    3535namespace WebCore {
     
    3737class GeneratedImage : public Image {
    3838public:
    39     GeneratedImage(Generator* generator, const IntSize& size)
    40     : m_size(size)
     39    GeneratedImage(PassRefPtr<Generator> generator, const IntSize& size)
     40        : m_generator(generator)
     41        , m_size(size)
    4142    {
    42         m_generator.set(generator);
    4343    }
    4444    virtual ~GeneratedImage() {}
     
    6464   
    6565protected:
    66     OwnPtr<Generator> m_generator;
     66    RefPtr<Generator> m_generator;
    6767    IntSize m_size;
    6868};
  • trunk/WebCore/platform/graphics/Generator.h

    r31830 r35966  
    2727#define Generator_h
    2828
    29 #include <wtf/Noncopyable.h>
     29#include <wtf/RefCounted.h>
    3030
    3131namespace WebCore {
     
    3434class GraphicsContext;
    3535
    36 class Generator : Noncopyable {
     36class Generator : public RefCounted<Generator> {
    3737public:
    3838    virtual ~Generator() {};
  • trunk/WebCore/platform/graphics/Gradient.h

    r35852 r35966  
    3131
    3232#include "FloatPoint.h"
     33#include <wtf/PassRefPtr.h>
    3334#include <wtf/Vector.h>
    3435
     
    5960    class Gradient : public Generator {
    6061    public:
    61         Gradient(const FloatPoint& p0, const FloatPoint& p1);
    62         Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1);
     62        static PassRefPtr<Gradient> create(const FloatPoint& p0, const FloatPoint& p1)
     63        {
     64            return adoptRef(new Gradient(p0, p1));
     65        }
     66        static PassRefPtr<Gradient> create(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1)
     67        {
     68            return adoptRef(new Gradient(p0, r0, p1, r1));
     69        }
    6370        virtual ~Gradient();
    6471
     
    7683            float blue;
    7784            float alpha;
    78            
     85
    7986            ColorStop() : stop(0), red(0), green(0), blue(0), alpha(0) { }
    8087            ColorStop(float s, float r, float g, float b, float a) : stop(s), red(r), green(g), blue(b), alpha(a) { }
     
    8693
    8794    private:
     95        Gradient(const FloatPoint& p0, const FloatPoint& p1);
     96        Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1);
     97
    8898        void platformInit() { m_gradient = 0; }
    8999        void platformDestroy();
  • trunk/WebCore/platform/graphics/GraphicsContext.cpp

    r35301 r35966  
    135135void GraphicsContext::setStrokeColor(const Color& color)
    136136{
     137    m_common->state.strokeColorSpace = SolidColorSpace;
    137138    m_common->state.strokeColor = color;
    138139    setPlatformStrokeColor(color);
     
    179180}
    180181
     182WindRule GraphicsContext::fillRule() const
     183{
     184    return m_common->state.fillRule;
     185}
     186
     187void GraphicsContext::setFillRule(WindRule fillRule)
     188{
     189    m_common->state.fillRule = fillRule;
     190}
     191
    181192void GraphicsContext::setFillColor(const Color& color)
    182193{
     194    m_common->state.fillColorSpace = SolidColorSpace;
    183195    m_common->state.fillColor = color;
    184196    setPlatformFillColor(color);
     
    188200{
    189201    return m_common->state.fillColor;
     202}
     203
     204void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
     205{
     206    ASSERT(pattern);
     207    if (!pattern) {
     208        setStrokeColor(Color::black);
     209        return;
     210    }
     211    m_common->state.strokeColorSpace = PatternColorSpace;
     212    m_common->state.strokePattern = pattern;
     213    setPlatformStrokePattern(m_common->state.strokePattern.get());
     214}
     215
     216void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern)
     217{
     218    ASSERT(pattern);
     219    if (!pattern) {
     220        setFillColor(Color::black);
     221        return;
     222    }
     223    m_common->state.fillColorSpace = PatternColorSpace;
     224    m_common->state.fillPattern = pattern;
     225    setPlatformFillPattern(m_common->state.fillPattern.get());
     226}
     227
     228void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient)
     229{
     230    ASSERT(gradient);
     231    if (!gradient) {
     232        setStrokeColor(Color::black);
     233        return;
     234    }
     235    m_common->state.strokeColorSpace = GradientColorSpace;
     236    m_common->state.strokeGradient = gradient;
     237    setPlatformStrokeGradient(m_common->state.strokeGradient.get());
     238}
     239
     240void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient)
     241{
     242    ASSERT(gradient);
     243    if (!gradient) {
     244        setFillColor(Color::black);
     245        return;
     246    }
     247    m_common->state.fillColorSpace = GradientColorSpace;
     248    m_common->state.fillGradient = gradient;
     249    setPlatformFillGradient(m_common->state.fillGradient.get());
    190250}
    191251
     
    427487#endif
    428488
    429 #if !PLATFORM(CG) && !PLATFORM(CAIRO)
    430 // Other platforms need to implement this.
    431 void GraphicsContext::clipToImageBuffer(const FloatRect&, const ImageBuffer*)
    432 {
    433     notImplemented();
    434 }
    435 #endif
    436 
    437489#if !PLATFORM(QT) && !PLATFORM(CAIRO)
    438490void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle&)
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r35897 r35966  
    9595    class Font;
    9696    class Generator;
     97    class Gradient;
    9798    class GraphicsContextPrivate;
    9899    class GraphicsContextPlatformPrivate;
     
    140141        Color strokeColor() const;
    141142        void setStrokeColor(const Color&);
    142 
     143        void setStrokePattern(PassRefPtr<Pattern>);
     144        void setStrokeGradient(PassRefPtr<Gradient>);
     145
     146        WindRule fillRule() const;
     147        void setFillRule(WindRule);
    143148        Color fillColor() const;
    144149        void setFillColor(const Color&);
    145 
    146         void applyStrokePattern(const Pattern&);
    147         void applyFillPattern(const Pattern&);
     150        void setFillPattern(PassRefPtr<Pattern>);
     151        void setFillGradient(PassRefPtr<Gradient>);
    148152
    149153        void save();
    150154        void restore();
    151        
     155
    152156        // These draw methods will do both stroking and filling.
    153157        void drawRect(const IntRect&);
     
    156160        void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
    157161
     162        void drawPath();
     163        void fillPath();
     164        void strokePath();
     165
    158166        // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
    159167        void strokeArc(const IntRect&, int startAngle, int angleSpan);
    160        
    161         void fillRect(const IntRect&, const Color&);
     168
     169        void fillRect(const FloatRect&);
    162170        void fillRect(const FloatRect&, const Color&);
    163171        void fillRect(const FloatRect&, Generator&);
    164172        void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&);
     173
    165174        void clearRect(const FloatRect&);
     175
     176        void strokeRect(const FloatRect&);
    166177        void strokeRect(const FloatRect&, float lineWidth);
    167178
     
    178189                            CompositeOperator = CompositeSourceOver);
    179190
    180 #if PLATFORM(CG)
    181191        void setImageInterpolationQuality(InterpolationQuality);
    182192        InterpolationQuality imageInterpolationQuality() const;
    183 #else
    184         void setImageInterpolationQuality(InterpolationQuality) {}
    185         InterpolationQuality imageInterpolationQuality() const { return InterpolationDefault; }
    186 #endif
    187193
    188194        void clip(const FloatRect&);
     
    289295#if PLATFORM(QT)
    290296        bool inTransparencyLayer() const;
    291         void setFillRule(WindRule);
    292297        PlatformPath* currentPath();
    293298#endif
     
    302307        void savePlatformState();
    303308        void restorePlatformState();
     309
    304310        void setPlatformTextDrawingMode(int);
     311        void setPlatformFont(const Font& font);
     312
    305313        void setPlatformStrokeColor(const Color&);
     314        void setPlatformStrokePattern(Pattern*);
     315        void setPlatformStrokeGradient(Gradient*);
    306316        void setPlatformStrokeStyle(const StrokeStyle&);
    307317        void setPlatformStrokeThickness(float);
     318
    308319        void setPlatformFillColor(const Color&);
    309         void setPlatformFont(const Font& font);
     320        void setPlatformFillPattern(Pattern*);
     321        void setPlatformFillGradient(Gradient*);
     322
    310323        void setPlatformShadow(const IntSize&, int blur, const Color&);
    311324        void clearPlatformShadow();
  • trunk/WebCore/platform/graphics/GraphicsContextPrivate.h

    r31246 r35966  
    2828
    2929#include "Font.h"
     30#include "Gradient.h"
     31#include "Pattern.h"
    3032
    3133namespace WebCore {
    3234
     35// FIXME: This is a place-holder until we decide to add
     36// real color space support to WebCore.  At that time, ColorSpace will be a
     37// class and instances will be held  off of Colors.   There will be
     38// special singleton Gradient and Pattern color spaces to mark when
     39// a fill or stroke is using a gradient or pattern instead of a solid color.
     40// https://bugs.webkit.org/show_bug.cgi?id=20558
     41    enum ColorSpace {
     42        SolidColorSpace,
     43        PatternColorSpace,
     44        GradientColorSpace
     45    };
     46
    3347    struct GraphicsContextState {
    3448        GraphicsContextState()
    35             : strokeStyle(SolidStroke)
     49            : textDrawingMode(cTextFill)
     50            , strokeStyle(SolidStroke)
    3651            , strokeThickness(0)
     52            , strokeColorSpace(SolidColorSpace)
    3753            , strokeColor(Color::black)
     54            , fillRule(RULE_NONZERO)
     55            , fillColorSpace(SolidColorSpace)
    3856            , fillColor(Color::black)
    39             , textDrawingMode(cTextFill)
    4057            , paintingDisabled(false)
    4158            , shadowBlur(0)
     
    4461
    4562        Font font;
     63        int textDrawingMode;
     64       
    4665        StrokeStyle strokeStyle;
    4766        float strokeThickness;
     67        ColorSpace strokeColorSpace;
    4868        Color strokeColor;
     69        RefPtr<Gradient> strokeGradient;
     70        RefPtr<Pattern> strokePattern;
     71       
     72        WindRule fillRule;
     73        ColorSpace fillColorSpace;
    4974        Color fillColor;
    50         int textDrawingMode;
     75        RefPtr<Gradient> fillGradient;
     76        RefPtr<Pattern> fillPattern;
     77
    5178        bool paintingDisabled;
     79       
    5280        IntSize shadowSize;
    5381        unsigned shadowBlur;
  • trunk/WebCore/platform/graphics/GraphicsTypes.h

    r28877 r35966  
    6666    bool parseLineJoin(const String&, LineJoin&);
    6767
    68 }
     68} // namespace WebCore
    6969
    7070#endif
  • trunk/WebCore/platform/graphics/Path.h

    r35852 r35966  
    9999        void moveTo(const FloatPoint&);
    100100        void addLineTo(const FloatPoint&);
    101         void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point);
    102         void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint&);
     101        void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& endPoint);
     102        void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& endPoint);
    103103        void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
    104104        void closeSubpath();
     
    109109
    110110        void translate(const FloatSize&);
    111 
    112         void setWindingRule(WindRule rule) { m_rule = rule; }
    113         WindRule windingRule() const { return m_rule; }
    114111
    115112        String debugString() const;
     
    129126    private:
    130127        PlatformPath* m_path;
    131         WindRule m_rule;
    132128    };
    133129
  • trunk/WebCore/platform/graphics/Pattern.h

    r35852 r35966  
    2828#define Pattern_h
    2929
    30 #include <wtf/Noncopyable.h>
     30#include <wtf/PassRefPtr.h>
     31#include <wtf/RefCounted.h>
    3132#include <wtf/RefPtr.h>
    3233
     
    5758    class Image;
    5859
    59     class Pattern : Noncopyable {
     60    class Pattern : public RefCounted<Pattern> {
    6061    public:
    61         Pattern(Image*, bool repeatX, bool repeatY);
     62        static PassRefPtr<Pattern> create(Image* tileImage, bool repeatX, bool repeatY)
     63        {
     64            return adoptRef(new Pattern(tileImage, repeatX, repeatY));
     65        }
     66        virtual ~Pattern();
    6267
    63         virtual ~Pattern();
    64        
    6568        Image* tileImage() const { return m_tileImage.get(); }
    6669
     
    6871
    6972    private:
     73        Pattern(Image*, bool repeatX, bool repeatY);
     74
    7075        RefPtr<Image> m_tileImage;
    7176        bool m_repeatX;
  • trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r35869 r35966  
    11/*
    22 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
     3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3031#include "AffineTransform.h"
    3132#include "FloatConversion.h"
     33#include "GraphicsContextPrivate.h"
    3234#include "GraphicsContextPlatformPrivateCG.h"
    3335#include "ImageBuffer.h"
     
    108110void GraphicsContext::drawRect(const IntRect& rect)
    109111{
     112    // FIXME: this function does not handle patterns and gradients
     113    // like drawPath does, it probably should.
    110114    if (paintingDisabled())
    111115        return;
     
    262266    CGContextClosePath(context);
    263267
    264     if (fillColor().alpha()) {
    265         if (strokeStyle() != NoStroke)
    266             // stroke and fill
    267             CGContextDrawPath(context, kCGPathFillStroke);
    268         else
    269             CGContextFillPath(context);
    270     } else if (strokeStyle() != NoStroke)
    271         CGContextStrokePath(context);
     268    drawPath();
    272269}
    273270
     
    382379    CGContextClosePath(context);
    383380
    384     if (fillColor().alpha()) {
    385         if (strokeStyle() != NoStroke)
    386             CGContextDrawPath(context, kCGPathEOFillStroke);
     381    drawPath();
     382
     383    CGContextRestoreGState(context);
     384}
     385
     386static inline bool calculateDrawingMode(const GraphicsContextState& state, CGPathDrawingMode& mode)
     387{
     388    bool shouldFill = state.fillColorSpace == PatternColorSpace || state.fillColor.alpha();
     389    bool shouldStroke = state.strokeColorSpace == PatternColorSpace || (state.strokeStyle != NoStroke && state.strokeColor.alpha());
     390    bool useEOFill = state.fillRule == RULE_EVENODD;
     391
     392    if (shouldFill) {
     393        if (shouldStroke) {
     394            if (useEOFill)
     395                mode = kCGPathEOFillStroke;
     396            else
     397                mode = kCGPathFillStroke;
     398        } else { // fill, no stroke
     399            if (useEOFill)
     400                mode = kCGPathEOFill;
     401            else
     402                mode = kCGPathFill;
     403        }
     404    } else if (shouldStroke) // no fill, just stroke
     405        mode = kCGPathStroke;
     406
     407    return shouldFill || shouldStroke;
     408}
     409
     410void GraphicsContext::drawPath()
     411{
     412    if (paintingDisabled())
     413        return;
     414
     415    CGContextRef context = platformContext();
     416    const GraphicsContextState& state = m_common->state;
     417
     418    if (state.fillColorSpace == GradientColorSpace || state.strokeColorSpace == GradientColorSpace) {
     419        // We don't have any optimized way to fill & stroke a path using gradients
     420        fillPath();
     421        strokePath();
     422        return;
     423    }
     424
     425    CGPathDrawingMode drawingMode;
     426    if (calculateDrawingMode(state, drawingMode))
     427        CGContextDrawPath(context, drawingMode);
     428}
     429
     430static inline void fillPathWithFillRule(CGContextRef context, WindRule fillRule)
     431{
     432    if (fillRule == RULE_EVENODD)
     433        CGContextEOFillPath(context);
     434    else
     435        CGContextFillPath(context);
     436}
     437
     438void GraphicsContext::fillPath()
     439{
     440    if (paintingDisabled())
     441        return;
     442
     443    CGContextRef context = platformContext();
     444    switch (m_common->state.fillColorSpace) {
     445    case SolidColorSpace:
     446        if (!fillColor().alpha())
     447            return;
     448        // fall through
     449    case PatternColorSpace:
     450        fillPathWithFillRule(context, fillRule());
     451        break;
     452    case GradientColorSpace:
     453        if (fillRule() == RULE_EVENODD)
     454            CGContextEOClip(context);
    387455        else
    388             CGContextEOFillPath(context);
    389     } else
     456            CGContextClip(context);
     457        CGContextDrawShading(context, m_common->state.fillGradient->platformGradient());
     458        break;
     459    }
     460}
     461
     462void GraphicsContext::strokePath()
     463{
     464    if (paintingDisabled())
     465        return;
     466
     467    CGContextRef context = platformContext();
     468    switch (m_common->state.strokeColorSpace) {
     469    case SolidColorSpace:
     470        if (!fillColor().alpha())
     471            return;
     472        // fall through
     473    case PatternColorSpace:
    390474        CGContextStrokePath(context);
    391 
    392     CGContextRestoreGState(context);
    393 }
    394 
    395 void GraphicsContext::fillRect(const IntRect& rect, const Color& color)
     475        break;
     476    case GradientColorSpace:
     477        CGContextReplacePathWithStrokedPath(context);
     478        CGContextClip(context);
     479        CGContextDrawShading(context, m_common->state.strokeGradient->platformGradient());
     480        break;
     481    }
     482}
     483
     484void GraphicsContext::fillRect(const FloatRect& rect)
     485{
     486    if (paintingDisabled())
     487        return;
     488    switch (m_common->state.fillColorSpace) {
     489    case SolidColorSpace:
     490        if (fillColor().alpha())
     491            CGContextFillRect(platformContext(), rect);
     492        break;
     493    case PatternColorSpace:
     494        CGContextFillRect(platformContext(), rect);
     495        break;
     496    case GradientColorSpace:
     497        clip(rect);
     498        CGContextDrawShading(platformContext(), m_common->state.fillGradient->platformGradient());
     499        break;
     500    }
     501}
     502
     503void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
    396504{
    397505    if (paintingDisabled())
     
    408516}
    409517
    410 void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
    411 {
    412     if (paintingDisabled())
    413         return;
    414     if (color.alpha()) {
    415         CGContextRef context = platformContext();
    416         Color oldFillColor = fillColor();
    417         if (oldFillColor != color)
    418             setCGFillColor(context, color);
    419         CGContextFillRect(context, rect);
    420         if (oldFillColor != color)
    421             setCGFillColor(context, oldFillColor);
    422     }
    423 }
    424 
    425518void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
    426519{
     
    434527
    435528    addPath(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight));
    436     CGContextFillPath(context);
     529    fillPath();
    437530
    438531    if (oldFillColor != color)
    439532        setCGFillColor(context, oldFillColor);
    440533}
    441 
    442534
    443535void GraphicsContext::clip(const FloatRect& rect)
     
    9111003}
    9121004
    913 void GraphicsContext::applyStrokePattern(const Pattern& pattern)
    914 {
    915     CGPatternRef platformPattern = pattern.createPlatformPattern(getCTM());
     1005// FIXME: It is unclear if setting patterns on the CGContext at
     1006// setStrokePattern/setFillPattern time is safe.  Our Pattern object currently
     1007// depends on the CTM for CGShading creation, thus setting a pattern and then
     1008// transforming the GraphicsContext may cause the pattern to draw incorrectly.
     1009// I believe we can fix our Pattern object to not depend on the CTM.
     1010void GraphicsContext::setPlatformStrokePattern(Pattern* pattern)
     1011{
     1012    if (paintingDisabled())
     1013        return;
     1014    CGPatternRef platformPattern = pattern->createPlatformPattern(getCTM());
    9161015    if (!platformPattern)
    9171016        return;
     
    9261025}
    9271026
    928 void GraphicsContext::applyFillPattern(const Pattern& pattern)
    929 {
    930     CGPatternRef platformPattern = pattern.createPlatformPattern(getCTM());
     1027void GraphicsContext::setPlatformFillPattern(Pattern* pattern)
     1028{
     1029    if (paintingDisabled())
     1030        return;
     1031    CGPatternRef platformPattern = pattern->createPlatformPattern(getCTM());
    9311032    if (!platformPattern)
    9321033        return;
     
    9391040    CGContextSetFillPattern(platformContext(), platformPattern, &patternAlpha);
    9401041    CGPatternRelease(platformPattern);
     1042}
     1043
     1044void GraphicsContext::setPlatformStrokeGradient(Gradient*)
     1045{
     1046    // CoreGraphics does not support setting a "stroke gradient", only
     1047    // filling a clip region with a gradient, which we do at draw time
     1048}
     1049
     1050void GraphicsContext::setPlatformFillGradient(Gradient*)
     1051{
     1052    // CoreGraphics does not support setting a "fill gradient", only
     1053    // filling a clip region with a gradient, which we do at draw time
    9411054}
    9421055
Note: See TracChangeset for help on using the changeset viewer.