[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

mitz at apple.com mitz at apple.com
Thu Apr 8 01:09:32 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit c65278c0adce5918d94993f78a1959de6940cee3
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 15 05:10:59 2010 +0000

    <rdar://problem/6020083> -webkit-gradient slows down scrolling when page has horizontal scrollbar
    https://bugs.webkit.org/show_bug.cgi?id=19650
    
    Reviewed by Simon Fraser.
    
    * platform/graphics/GeneratedImage.cpp:
    (WebCore::GeneratedImage::drawPattern): Added call to adjustParametersForTiledDrawing(),
    letting the generator substitute the parameters with visually-equivalent values that
    are more efficient.
    * platform/graphics/Generator.h:
    (WebCore::Generator::adjustParametersForTiledDrawing): Added a base class implementation
    that does nothing.
    * platform/graphics/Gradient.cpp:
    (WebCore::Gradient::adjustParametersForTiledDrawing): Added. If the gradient is a horizontal
    or vertical linear gradient, changes to use a 1-pixel tall (or wide) tile.
    * platform/graphics/Gradient.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53318 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 562a366..6ed7bc1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-01-14  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Simon Fraser.
+
+        <rdar://problem/6020083> -webkit-gradient slows down scrolling when page has horizontal scrollbar
+        https://bugs.webkit.org/show_bug.cgi?id=19650
+
+        * platform/graphics/GeneratedImage.cpp:
+        (WebCore::GeneratedImage::drawPattern): Added call to adjustParametersForTiledDrawing(),
+        letting the generator substitute the parameters with visually-equivalent values that
+        are more efficient.
+        * platform/graphics/Generator.h:
+        (WebCore::Generator::adjustParametersForTiledDrawing): Added a base class implementation
+        that does nothing.
+        * platform/graphics/Gradient.cpp:
+        (WebCore::Gradient::adjustParametersForTiledDrawing): Added. If the gradient is a horizontal
+        or vertical linear gradient, changes to use a 1-pixel tall (or wide) tile.
+        * platform/graphics/Gradient.h:
+
 2010-01-14  Norbert Leser  <norbert.leser at nokia.com>
 
         Reviewed by Laszlo Gombos.
diff --git a/WebCore/platform/graphics/GeneratedImage.cpp b/WebCore/platform/graphics/GeneratedImage.cpp
index eec7ffb..8395aff 100644
--- a/WebCore/platform/graphics/GeneratedImage.cpp
+++ b/WebCore/platform/graphics/GeneratedImage.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -10,17 +10,17 @@
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
@@ -50,19 +50,24 @@ void GeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, co
 void GeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const TransformationMatrix& patternTransform,
                                  const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)
 {
+    // Allow the generator to provide visually-equivalent tiling parameters for better performance.
+    IntSize adjustedSize = m_size;
+    FloatRect adjustedSrcRect = srcRect;
+    m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
+
     // Create a BitmapImage and call drawPattern on it.
-    OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(m_size);
+    OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(adjustedSize);
     ASSERT(imageBuffer.get());
-    
+
     // Fill with the gradient.
     GraphicsContext* graphicsContext = imageBuffer->context();
-    graphicsContext->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
-    
+    graphicsContext->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_generator.get());
+
     // Grab the final image from the image buffer.
     Image* bitmap = imageBuffer->image();
-    
+
     // Now just call drawTiled on that image.
-    bitmap->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);
+    bitmap->drawPattern(context, adjustedSrcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);
 }
 
 }
diff --git a/WebCore/platform/graphics/Generator.h b/WebCore/platform/graphics/Generator.h
index a0af689..b64d051 100644
--- a/WebCore/platform/graphics/Generator.h
+++ b/WebCore/platform/graphics/Generator.h
@@ -38,6 +38,7 @@ public:
     virtual ~Generator() {};
     
     virtual void fill(GraphicsContext*, const FloatRect&) = 0;
+    virtual void adjustParametersForTiledDrawing(IntSize& /* size */, FloatRect& /* srcRect */) { }
 };
 
 } //namespace
diff --git a/WebCore/platform/graphics/Gradient.cpp b/WebCore/platform/graphics/Gradient.cpp
index 77a0d21..445c365 100644
--- a/WebCore/platform/graphics/Gradient.cpp
+++ b/WebCore/platform/graphics/Gradient.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2007 Alp Toker <alp at atoker.com>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,6 +28,8 @@
 #include "Gradient.h"
 
 #include "Color.h"
+#include "FloatRect.h"
+#include <wtf/UnusedParam.h>
 
 namespace WebCore {
 
@@ -62,6 +64,28 @@ Gradient::~Gradient()
     platformDestroy();
 }
 
+void Gradient::adjustParametersForTiledDrawing(IntSize& size, FloatRect& srcRect)
+{
+    if (m_radial)
+        return;
+
+    if (srcRect.isEmpty())
+        return;
+
+    if (m_p0.x() == m_p1.x()) {
+        size.setWidth(1);
+        srcRect.setWidth(1);
+        srcRect.setX(0);
+        return;
+    }
+    if (m_p0.y() != m_p1.y())
+        return;
+
+    size.setHeight(1);
+    srcRect.setHeight(1);
+    srcRect.setY(0);
+}
+
 void Gradient::addColorStop(float value, const Color& color)
 {
     float r;
diff --git a/WebCore/platform/graphics/Gradient.h b/WebCore/platform/graphics/Gradient.h
index 821b412..7546864 100644
--- a/WebCore/platform/graphics/Gradient.h
+++ b/WebCore/platform/graphics/Gradient.h
@@ -105,6 +105,8 @@ namespace WebCore {
         TransformationMatrix gradientSpaceTransform() { return m_gradientSpaceTransformation; }
 
         virtual void fill(GraphicsContext*, const FloatRect&);
+        virtual void adjustParametersForTiledDrawing(IntSize& size, FloatRect& srcRect);
+
         void setPlatformGradientSpaceTransform(const TransformationMatrix& gradientSpaceTransformation);
 
     private:

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list