Title: [174382] trunk/Source/WebCore
Revision
174382
Author
[email protected]
Date
2014-10-06 20:28:32 -0700 (Mon, 06 Oct 2014)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (174381 => 174382)


--- trunk/Source/WebCore/ChangeLog	2014-10-07 03:10:05 UTC (rev 174381)
+++ trunk/Source/WebCore/ChangeLog	2014-10-07 03:28:32 UTC (rev 174382)
@@ -1,3 +1,31 @@
+2014-10-06  Andreas Kling  <[email protected]>
+
+        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  <[email protected]>
 
         [EFL] Restore previous scroll position using restoreViewState()

Modified: trunk/Source/WebCore/html/canvas/CanvasPattern.h (174381 => 174382)


--- trunk/Source/WebCore/html/canvas/CanvasPattern.h	2014-10-07 03:10:05 UTC (rev 174381)
+++ trunk/Source/WebCore/html/canvas/CanvasPattern.h	2014-10-07 03:28:32 UTC (rev 174382)
@@ -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 @@
 
     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;
 };
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (174381 => 174382)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2014-10-07 03:10:05 UTC (rev 174381)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2014-10-07 03:28:32 UTC (rev 174382)
@@ -335,26 +335,16 @@
     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)

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (174381 => 174382)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2014-10-07 03:10:05 UTC (rev 174381)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2014-10-07 03:28:32 UTC (rev 174382)
@@ -234,7 +234,7 @@
         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 @@
         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>);

Modified: trunk/Source/WebCore/platform/graphics/Pattern.cpp (174381 => 174382)


--- trunk/Source/WebCore/platform/graphics/Pattern.cpp	2014-10-07 03:10:05 UTC (rev 174381)
+++ trunk/Source/WebCore/platform/graphics/Pattern.cpp	2014-10-07 03:28:32 UTC (rev 174382)
@@ -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)

Modified: trunk/Source/WebCore/platform/graphics/Pattern.h (174381 => 174382)


--- trunk/Source/WebCore/platform/graphics/Pattern.h	2014-10-07 03:10:05 UTC (rev 174381)
+++ trunk/Source/WebCore/platform/graphics/Pattern.h	2014-10-07 03:28:32 UTC (rev 174382)
@@ -51,7 +51,7 @@
 
 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(); }

Modified: trunk/Source/WebCore/platform/graphics/filters/FETile.cpp (174381 => 174382)


--- trunk/Source/WebCore/platform/graphics/filters/FETile.cpp	2014-10-07 03:10:05 UTC (rev 174381)
+++ trunk/Source/WebCore/platform/graphics/filters/FETile.cpp	2014-10-07 03:28:32 UTC (rev 174382)
@@ -71,13 +71,13 @@
     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()));
 }
 

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp (174381 => 174382)


--- trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp	2014-10-07 03:10:05 UTC (rev 174381)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp	2014-10-07 03:28:32 UTC (rev 174382)
@@ -69,7 +69,7 @@
     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());
 }

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp (174381 => 174382)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp	2014-10-07 03:10:05 UTC (rev 174381)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp	2014-10-07 03:28:32 UTC (rev 174382)
@@ -154,13 +154,13 @@
 
     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);
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to