[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

eric at webkit.org eric at webkit.org
Thu Feb 4 21:36:11 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 4211b058944dc71b6b00d9472b91ae7a62e2da46
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 2 05:36:40 2010 +0000

    2010-02-01  Stephen White  <senorblanco at chromium.org>
    
            Reviewed by Eric Seidel.
    
            Fix for Pattern transformations in Chromium/Skia.  This required
            reworking Pattern a bit to be more like the Gradient implementation.
            In particular, it now holds an m_pattern reference to the
            platform-specific implementation, and passes along changes to the
            m_patternSpaceTransformation, in the same way that Gradient does for
            m_gradientSpaceTransformation.  This is necessary since Skia creates the
            platform-specific pattern (SkShader) once, rather than recreating it
            on each draw.
            For platforms other than Skia, m_pattern is unused, they will
            continue to use the static createPlatformPattern(), and the new
            notification functions are stubbed out.  Other platforms can switch to
            the new implementation if they so choose.
    
            https://bugs.webkit.org/show_bug.cgi?id=24534
    
            Covered by svg/custom/pattern-y-offset.svg,
            svg/custom/pattern-cycle-detection.svg, and many more.
    
            * platform/graphics/Pattern.cpp:
            (WebCore::Pattern::Pattern):
            Initializer for m_pattern.
            (WebCore::Pattern::~Pattern):
            call platformDestroy().
            (WebCore::Pattern::setPatternSpaceTransform):
            Pass along the transform via setPlatformPatternSpaceTransform().
            (WebCore::Pattern::platformDestroy):
            (WebCore::Pattern::setPlatformPatternSpaceTransform):
            Stub implementations for non-skia platforms.
            * platform/graphics/Pattern.h:
            * platform/graphics/skia/GraphicsContextSkia.cpp:
            (WebCore::GraphicsContext::setPlatformFillPattern):
            (WebCore::GraphicsContext::setPlatformStrokePattern):
            Call platformPattern() instead of static version.
            Since Pattern now owns its SkShader, no need to unref here.
            * platform/graphics/skia/PatternSkia.cpp:
            (WebCore::Pattern::platformDestroy):
            Unref the SkShader on destroy.
            (WebCore::Pattern::platformPattern):
            Create the platform pattern (SkShader) once, and cache it.
            (WebCore::Pattern::setPlatformPatternSpaceTransform):
            Set the shader's local matrix from the m_patternSpaceTransformation.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54203 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2cd3f3f..c79f9e4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,49 @@
+2010-02-01  Stephen White  <senorblanco at chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        Fix for Pattern transformations in Chromium/Skia.  This required 
+        reworking Pattern a bit to be more like the Gradient implementation.
+        In particular, it now holds an m_pattern reference to the
+        platform-specific implementation, and passes along changes to the
+        m_patternSpaceTransformation, in the same way that Gradient does for
+        m_gradientSpaceTransformation.  This is necessary since Skia creates the
+        platform-specific pattern (SkShader) once, rather than recreating it
+        on each draw.
+        For platforms other than Skia, m_pattern is unused, they will
+        continue to use the static createPlatformPattern(), and the new
+        notification functions are stubbed out.  Other platforms can switch to
+        the new implementation if they so choose.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24534 
+
+        Covered by svg/custom/pattern-y-offset.svg,
+        svg/custom/pattern-cycle-detection.svg, and many more.
+
+        * platform/graphics/Pattern.cpp:
+        (WebCore::Pattern::Pattern):
+        Initializer for m_pattern.
+        (WebCore::Pattern::~Pattern):
+        call platformDestroy().
+        (WebCore::Pattern::setPatternSpaceTransform):
+        Pass along the transform via setPlatformPatternSpaceTransform().
+        (WebCore::Pattern::platformDestroy):
+        (WebCore::Pattern::setPlatformPatternSpaceTransform):
+        Stub implementations for non-skia platforms.
+        * platform/graphics/Pattern.h:
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::GraphicsContext::setPlatformFillPattern):
+        (WebCore::GraphicsContext::setPlatformStrokePattern):
+        Call platformPattern() instead of static version.
+        Since Pattern now owns its SkShader, no need to unref here.
+        * platform/graphics/skia/PatternSkia.cpp:
+        (WebCore::Pattern::platformDestroy):
+        Unref the SkShader on destroy.
+        (WebCore::Pattern::platformPattern):
+        Create the platform pattern (SkShader) once, and cache it.
+        (WebCore::Pattern::setPlatformPatternSpaceTransform):
+        Set the shader's local matrix from the m_patternSpaceTransformation.
+
 2010-02-01  Daniel Bates  <dbates at webkit.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/platform/graphics/Pattern.cpp b/WebCore/platform/graphics/Pattern.cpp
index d388bd7..3409d16 100644
--- a/WebCore/platform/graphics/Pattern.cpp
+++ b/WebCore/platform/graphics/Pattern.cpp
@@ -35,12 +35,32 @@ Pattern::Pattern(Image* image, bool repeatX, bool repeatY)
     : m_tileImage(image)
     , m_repeatX(repeatX)
     , m_repeatY(repeatY)
+#if PLATFORM(SKIA)
+    , m_pattern(0)
+#endif
 {
     ASSERT(image);
 }
 
 Pattern::~Pattern()
 {
+    platformDestroy();
 }
 
+void Pattern::setPatternSpaceTransform(const TransformationMatrix& patternSpaceTransformation)
+{
+    m_patternSpaceTransformation = patternSpaceTransformation;
+    setPlatformPatternSpaceTransform();
+}
+
+#if !PLATFORM(SKIA)
+void Pattern::platformDestroy()
+{
+}
+
+void Pattern::setPlatformPatternSpaceTransform()
+{
+}
+#endif
+
 }
diff --git a/WebCore/platform/graphics/Pattern.h b/WebCore/platform/graphics/Pattern.h
index f7f612a..b0188b9 100644
--- a/WebCore/platform/graphics/Pattern.h
+++ b/WebCore/platform/graphics/Pattern.h
@@ -74,9 +74,16 @@ namespace WebCore {
 
         Image* tileImage() const { return m_tileImage.get(); }
 
+        void platformDestroy();
+
         // Pattern space is an abstract space that maps to the default user space by the transformation 'userSpaceTransformation' 
+#if PLATFORM(SKIA)
+        PlatformPatternPtr platformPattern(const TransformationMatrix& userSpaceTransformation);
+#else
         PlatformPatternPtr createPlatformPattern(const TransformationMatrix& userSpaceTransformation) const;
-        void setPatternSpaceTransform(const TransformationMatrix& patternSpaceTransformation) { m_patternSpaceTransformation = patternSpaceTransformation; }
+#endif
+        void setPatternSpaceTransform(const TransformationMatrix& patternSpaceTransformation);
+        void setPlatformPatternSpaceTransform();
 
     private:
         Pattern(Image*, bool repeatX, bool repeatY);
@@ -85,6 +92,7 @@ namespace WebCore {
         bool m_repeatX;
         bool m_repeatY;
         TransformationMatrix m_patternSpaceTransformation;
+        PlatformPatternPtr m_pattern;
     };
 
 } //namespace
diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
index 08b27cf..bd97ca2 100644
--- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
+++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
@@ -997,9 +997,7 @@ void GraphicsContext::setPlatformFillPattern(Pattern* pattern)
     if (paintingDisabled())
         return;
 
-    SkShader* pat = pattern->createPlatformPattern(getCTM());
-    platformContext()->setFillShader(pat);
-    pat->safeUnref();
+    platformContext()->setFillShader(pattern->platformPattern(getCTM()));
 }
 
 void GraphicsContext::setPlatformShadow(const IntSize& size,
@@ -1084,9 +1082,7 @@ void GraphicsContext::setPlatformStrokePattern(Pattern* pattern)
     if (paintingDisabled())
         return;
 
-    SkShader* pat = pattern->createPlatformPattern(getCTM());
-    platformContext()->setStrokeShader(pat);
-    pat->safeUnref();
+    platformContext()->setStrokeShader(pattern->platformPattern(getCTM()));
 }
 
 void GraphicsContext::setPlatformTextDrawingMode(int mode)
diff --git a/WebCore/platform/graphics/skia/PatternSkia.cpp b/WebCore/platform/graphics/skia/PatternSkia.cpp
index 11b5cf1..b98825b 100644
--- a/WebCore/platform/graphics/skia/PatternSkia.cpp
+++ b/WebCore/platform/graphics/skia/PatternSkia.cpp
@@ -40,8 +40,17 @@
 
 namespace WebCore {
 
-PlatformPatternPtr Pattern::createPlatformPattern(const TransformationMatrix& patternTransform) const
+void Pattern::platformDestroy()
 {
+    m_pattern->safeUnref();
+    m_pattern = 0;
+}
+
+PlatformPatternPtr Pattern::platformPattern(const TransformationMatrix& patternTransform)
+{
+    if (m_pattern)
+        return m_pattern;
+
     // Note: patternTransform is ignored since it seems to be applied elsewhere
     // (when the pattern is used?). Applying it to the pattern (i.e.
     // shader->setLocalMatrix) results in a double transformation. This can be
@@ -53,31 +62,42 @@ PlatformPatternPtr Pattern::createPlatformPattern(const TransformationMatrix& pa
     SkBitmap* bm = m_tileImage->nativeImageForCurrentFrame();
     // If we don't have a bitmap, return a transparent shader.
     if (!bm)
-        return new SkColorShader(SkColorSetARGB(0, 0, 0, 0));
+        m_pattern = new SkColorShader(SkColorSetARGB(0, 0, 0, 0));
 
-    if (m_repeatX && m_repeatY)
-        return SkShader::CreateBitmapShader(*bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
+    else if (m_repeatX && m_repeatY)
+        m_pattern = SkShader::CreateBitmapShader(*bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
 
-    // Skia does not have a "draw the tile only once" option. Clamp_TileMode
-    // repeats the last line of the image after drawing one tile. To avoid
-    // filling the space with arbitrary pixels, this workaround forces the
-    // image to have a line of transparent pixels on the "repeated" edge(s),
-    // thus causing extra space to be transparent filled.
-    SkShader::TileMode tileModeX = m_repeatX ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode;
-    SkShader::TileMode tileModeY = m_repeatY ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode;
-    int expandW = m_repeatX ? 0 : 1;
-    int expandH = m_repeatY ? 0 : 1;
+    else {
 
-    // Create a transparent bitmap 1 pixel wider and/or taller than the
-    // original, then copy the orignal into it.
-    // FIXME: Is there a better way to pad (not scale) an image in skia?
-    SkBitmap bm2;
-    bm2.setConfig(bm->config(), bm->width() + expandW, bm->height() + expandH);
-    bm2.allocPixels();
-    bm2.eraseARGB(0x00, 0x00, 0x00, 0x00);
-    SkCanvas canvas(bm2);
-    canvas.drawBitmap(*bm, 0, 0);
-    return SkShader::CreateBitmapShader(bm2, tileModeX, tileModeY);
+        // Skia does not have a "draw the tile only once" option. Clamp_TileMode
+        // repeats the last line of the image after drawing one tile. To avoid
+        // filling the space with arbitrary pixels, this workaround forces the
+        // image to have a line of transparent pixels on the "repeated" edge(s),
+        // thus causing extra space to be transparent filled.
+        SkShader::TileMode tileModeX = m_repeatX ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode;
+        SkShader::TileMode tileModeY = m_repeatY ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode;
+        int expandW = m_repeatX ? 0 : 1;
+        int expandH = m_repeatY ? 0 : 1;
+
+        // Create a transparent bitmap 1 pixel wider and/or taller than the
+        // original, then copy the orignal into it.
+        // FIXME: Is there a better way to pad (not scale) an image in skia?
+        SkBitmap bm2;
+        bm2.setConfig(bm->config(), bm->width() + expandW, bm->height() + expandH);
+        bm2.allocPixels();
+        bm2.eraseARGB(0x00, 0x00, 0x00, 0x00);
+        SkCanvas canvas(bm2);
+        canvas.drawBitmap(*bm, 0, 0);
+        m_pattern = SkShader::CreateBitmapShader(bm2, tileModeX, tileModeY);
+    }
+    m_pattern->setLocalMatrix(m_patternSpaceTransformation);
+    return m_pattern;
+}
+
+void Pattern::setPlatformPatternSpaceTransform()
+{
+    if (m_pattern)
+        m_pattern->setLocalMatrix(m_patternSpaceTransformation);
 }
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list