CanvasPattern always has an internal WebCore::Pattern.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 03:28:32 +0000 (03:28 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 03:28:32 +0000 (03:28 +0000)
<https://webkit.org/b/137456>

Use more Ref & PassRef for CanvasPattern and Pattern.

Removed some impossible null checks in GraphicsContext that
got exposed as compile errors with these changes.

Reviewed by Anders Carlsson.

* html/canvas/CanvasPattern.h:
(WebCore::CanvasPattern::pattern):
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::setStrokePattern):
(WebCore::GraphicsContext::setFillPattern):
* platform/graphics/GraphicsContext.h:
* platform/graphics/Pattern.cpp:
(WebCore::Pattern::create):
* platform/graphics/Pattern.h:
* platform/graphics/filters/FETile.cpp:
(WebCore::FETile::platformApplySoftware):
* rendering/svg/RenderSVGPath.cpp:
(WebCore::useStrokeStyleToFill):
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::applyResource):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174382 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/canvas/CanvasPattern.h
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/Pattern.cpp
Source/WebCore/platform/graphics/Pattern.h
Source/WebCore/platform/graphics/filters/FETile.cpp
Source/WebCore/rendering/svg/RenderSVGPath.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp

index 9c7fb89..7ebbd46 100644 (file)
@@ -1,3 +1,31 @@
+2014-10-06  Andreas Kling  <akling@apple.com>
+
+        CanvasPattern always has an internal WebCore::Pattern.
+        <https://webkit.org/b/137456>
+
+        Use more Ref & PassRef for CanvasPattern and Pattern.
+
+        Removed some impossible null checks in GraphicsContext that
+        got exposed as compile errors with these changes.
+
+        Reviewed by Anders Carlsson.
+
+        * html/canvas/CanvasPattern.h:
+        (WebCore::CanvasPattern::pattern):
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::setStrokePattern):
+        (WebCore::GraphicsContext::setFillPattern):
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/Pattern.cpp:
+        (WebCore::Pattern::create):
+        * platform/graphics/Pattern.h:
+        * platform/graphics/filters/FETile.cpp:
+        (WebCore::FETile::platformApplySoftware):
+        * rendering/svg/RenderSVGPath.cpp:
+        (WebCore::useStrokeStyleToFill):
+        * rendering/svg/RenderSVGResourcePattern.cpp:
+        (WebCore::RenderSVGResourcePattern::applyResource):
+
 2014-10-06  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         [EFL] Restore previous scroll position using restoreViewState()
index e24f1fa..0ea0bc9 100644 (file)
@@ -28,8 +28,8 @@
 
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
+#include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
@@ -45,14 +45,15 @@ public:
 
     static void parseRepetitionType(const String&, bool& repeatX, bool& repeatY, ExceptionCode&);
 
-    Pattern* pattern() const { return m_pattern.get(); }
+    Pattern& pattern() { return m_pattern.get(); }
+    const Pattern& pattern() const { return m_pattern.get(); }
 
     bool originClean() const { return m_originClean; }
 
 private:
     CanvasPattern(PassRefPtr<Image>, bool repeatX, bool repeatY, bool originClean);
 
-    RefPtr<Pattern> m_pattern;
+    Ref<Pattern> m_pattern;
     bool m_originClean;
 };
 
index f408725..c6a0bfd 100644 (file)
@@ -335,26 +335,16 @@ const GraphicsContextState& GraphicsContext::state() const
     return m_state;
 }
 
-void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
+void GraphicsContext::setStrokePattern(PassRef<Pattern> pattern)
 {
-    ASSERT(pattern);
-    if (!pattern) {
-        setStrokeColor(Color::black, ColorSpaceDeviceRGB);
-        return;
-    }
     m_state.strokeGradient.clear();
-    m_state.strokePattern = pattern;
+    m_state.strokePattern = WTF::move(pattern);
 }
 
-void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern)
+void GraphicsContext::setFillPattern(PassRef<Pattern> pattern)
 {
-    ASSERT(pattern);
-    if (!pattern) {
-        setFillColor(Color::black, ColorSpaceDeviceRGB);
-        return;
-    }
     m_state.fillGradient.clear();
-    m_state.fillPattern = pattern;
+    m_state.fillPattern = WTF::move(pattern);
 }
 
 void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient)
index 7f2a033..b771720 100644 (file)
@@ -234,7 +234,7 @@ namespace WebCore {
         ColorSpace strokeColorSpace() const;
         WEBCORE_EXPORT void setStrokeColor(const Color&, ColorSpace);
 
-        void setStrokePattern(PassRefPtr<Pattern>);
+        void setStrokePattern(PassRef<Pattern>);
         Pattern* strokePattern() const;
 
         void setStrokeGradient(PassRefPtr<Gradient>);
@@ -246,7 +246,7 @@ namespace WebCore {
         ColorSpace fillColorSpace() const;
         WEBCORE_EXPORT void setFillColor(const Color&, ColorSpace);
 
-        void setFillPattern(PassRefPtr<Pattern>);
+        void setFillPattern(PassRef<Pattern>);
         Pattern* fillPattern() const;
 
         WEBCORE_EXPORT void setFillGradient(PassRefPtr<Gradient>);
index 23d8cdf..9e114c6 100644 (file)
@@ -31,9 +31,9 @@
 
 namespace WebCore {
 
-PassRefPtr<Pattern> Pattern::create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY)
+PassRef<Pattern> Pattern::create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY)
 {
-    return adoptRef(new Pattern(tileImage, repeatX, repeatY));
+    return adoptRef(*new Pattern(tileImage, repeatX, repeatY));
 }
 
 Pattern::Pattern(PassRefPtr<Image> image, bool repeatX, bool repeatY)
index edb00b1..e7736d3 100644 (file)
@@ -51,7 +51,7 @@ class Image;
 
 class Pattern : public RefCounted<Pattern> {
 public:
-    static PassRefPtr<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY);
+    static PassRef<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY);
     virtual ~Pattern();
 
     Image* tileImage() const { return m_tileImage.get(); }
index 150497f..5e2177c 100644 (file)
@@ -71,13 +71,13 @@ void FETile::platformApplySoftware()
     tileImageContext->translate(-inMaxEffectLocation.x(), -inMaxEffectLocation.y());
     tileImageContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, in->absolutePaintRect().location());
 
-    RefPtr<Pattern> pattern = Pattern::create(tileImage->copyImage(CopyBackingStore), true, true);
+    auto pattern = Pattern::create(tileImage->copyImage(CopyBackingStore), true, true);
 
     AffineTransform patternTransform;
     patternTransform.translate(inMaxEffectLocation.x() - maxEffectLocation.x(), inMaxEffectLocation.y() - maxEffectLocation.y());
-    pattern->setPatternSpaceTransform(patternTransform);
+    pattern.get().setPatternSpaceTransform(patternTransform);
     GraphicsContext* filterContext = resultImage->context();
-    filterContext->setFillPattern(pattern);
+    filterContext->setFillPattern(WTF::move(pattern));
     filterContext->fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()));
 }
 
index 71a162b..ced0fea 100644 (file)
@@ -69,7 +69,7 @@ static void useStrokeStyleToFill(GraphicsContext* context)
     if (Gradient* gradient = context->strokeGradient())
         context->setFillGradient(gradient);
     else if (Pattern* pattern = context->strokePattern())
-        context->setFillPattern(pattern);
+        context->setFillPattern(*pattern);
     else
         context->setFillColor(context->strokeColor(), context->strokeColorSpace());
 }
index 0b535e2..b0248c4 100644 (file)
@@ -154,13 +154,13 @@ bool RenderSVGResourcePattern::applyResource(RenderElement& renderer, const Rend
 
     if (resourceMode & ApplyToFillMode) {
         context->setAlpha(svgStyle.fillOpacity());
-        context->setFillPattern(patternData->pattern);
+        context->setFillPattern(*patternData->pattern);
         context->setFillRule(svgStyle.fillRule());
     } else if (resourceMode & ApplyToStrokeMode) {
         if (svgStyle.vectorEffect() == VE_NON_SCALING_STROKE)
             patternData->pattern->setPatternSpaceTransform(transformOnNonScalingStroke(&renderer, patternData->transform));
         context->setAlpha(svgStyle.strokeOpacity());
-        context->setStrokePattern(patternData->pattern);
+        context->setStrokePattern(*patternData->pattern);
         SVGRenderSupport::applyStrokeStyleToContext(context, style, renderer);
     }