[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

jamesr at google.com jamesr at google.com
Wed Dec 22 13:15:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7fc9d09fc6f748825875df3761a489d9d2b13fa7
Author: jamesr at google.com <jamesr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Sep 9 23:15:29 2010 +0000

    2010-09-09  Vincent Scheib  <scheib at chromium.org>
    
            Reviewed by James Robinson.
    
            [Chromium] Minimize uploads in canvas 2d mixed mode rendering
            https://bugs.webkit.org/show_bug.cgi?id=45476
    
            No new tests - change is for performance, logic fixes only apparent when running hardware acceleration.
    
            - Enumeration values fixed, "CavasWillDraw" -> "CanvasDidDraw".
            - markDirtyRect() plumbed through GraphicsContext to PlatformContextSkia.
            - Texture::updateSubRect() added to allow uploading only a dirty rect.
            - Logic fix in ImageBuffer::draw(), caused canvas to canvas copies to be incorrect.
    
            * html/canvas/CanvasRenderingContext2D.cpp:
            (WebCore::CanvasRenderingContext2D::setAllAttributesToDefault):
            (WebCore::CanvasRenderingContext2D::strokeRect):
            (WebCore::CanvasRenderingContext2D::drawImage):
            (WebCore::CanvasRenderingContext2D::didDraw):
              - Logic fix for drawingContext()->markDirtyRect() call.
            (WebCore::CanvasRenderingContext2D::putImageData):
            (WebCore::CanvasRenderingContext2D::drawTextInternal):
              - Logic fix for calls to "didDraw()", use peer method first.
            * html/canvas/CanvasRenderingContext2D.h:
            * platform/graphics/GraphicsContext.cpp:
            (WebCore::GraphicsContext::drawImageBuffer):
            (WebCore::GraphicsContext::markDirtyRect):
            * platform/graphics/GraphicsContext.h:
            * platform/graphics/gpu/Texture.cpp:
            (WebCore::Texture::create):
            (WebCore::Texture::load):
            (WebCore::Texture::updateSubRect):
            * platform/graphics/gpu/Texture.h:
            * platform/graphics/gpu/TilingData.h:
            (WebCore::TilingData::borderTexels):
            * platform/graphics/skia/GraphicsContextSkia.cpp:
            (WebCore::GraphicsContext::clipConvexPolygon):
            (WebCore::GraphicsContext::markDirtyRect):
            * platform/graphics/skia/ImageBufferSkia.cpp:
            (WebCore::ImageBuffer::draw):
            * platform/graphics/skia/PlatformContextSkia.cpp:
            (WebCore::PlatformContextSkia::State::cloneInheritedProperties):
            (WebCore::PlatformContextSkia::drawRect):
            (WebCore::PlatformContextSkia::setFillColor):
            (WebCore::PlatformContextSkia::setStrokeColor):
            (WebCore::PlatformContextSkia::markDirtyRect):
            (WebCore::PlatformContextSkia::uploadSoftwareToHardware):
            * platform/graphics/skia/PlatformContextSkia.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67123 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 86a573a..644af26 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,52 @@
+2010-09-09  Vincent Scheib  <scheib at chromium.org>
+
+        Reviewed by James Robinson.
+
+        [Chromium] Minimize uploads in canvas 2d mixed mode rendering
+        https://bugs.webkit.org/show_bug.cgi?id=45476
+
+        No new tests - change is for performance, logic fixes only apparent when running hardware acceleration.
+
+        - Enumeration values fixed, "CavasWillDraw" -> "CanvasDidDraw".
+        - markDirtyRect() plumbed through GraphicsContext to PlatformContextSkia.
+        - Texture::updateSubRect() added to allow uploading only a dirty rect.
+        - Logic fix in ImageBuffer::draw(), caused canvas to canvas copies to be incorrect.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::setAllAttributesToDefault):
+        (WebCore::CanvasRenderingContext2D::strokeRect):
+        (WebCore::CanvasRenderingContext2D::drawImage):
+        (WebCore::CanvasRenderingContext2D::didDraw):
+          - Logic fix for drawingContext()->markDirtyRect() call.
+        (WebCore::CanvasRenderingContext2D::putImageData):
+        (WebCore::CanvasRenderingContext2D::drawTextInternal):
+          - Logic fix for calls to "didDraw()", use peer method first.
+        * html/canvas/CanvasRenderingContext2D.h:
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::drawImageBuffer):
+        (WebCore::GraphicsContext::markDirtyRect):
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/gpu/Texture.cpp:
+        (WebCore::Texture::create):
+        (WebCore::Texture::load):
+        (WebCore::Texture::updateSubRect):
+        * platform/graphics/gpu/Texture.h:
+        * platform/graphics/gpu/TilingData.h:
+        (WebCore::TilingData::borderTexels):
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::GraphicsContext::clipConvexPolygon):
+        (WebCore::GraphicsContext::markDirtyRect):
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::ImageBuffer::draw):
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        (WebCore::PlatformContextSkia::State::cloneInheritedProperties):
+        (WebCore::PlatformContextSkia::drawRect):
+        (WebCore::PlatformContextSkia::setFillColor):
+        (WebCore::PlatformContextSkia::setStrokeColor):
+        (WebCore::PlatformContextSkia::markDirtyRect):
+        (WebCore::PlatformContextSkia::uploadSoftwareToHardware):
+        * platform/graphics/skia/PlatformContextSkia.h:
+
 2010-09-08  Darin Adler  <darin at apple.com>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index 791ad04..338960c 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -25,7 +25,7 @@
  * 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. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
@@ -219,7 +219,7 @@ void CanvasRenderingContext2D::restore()
     c->restore();
 }
 
-void CanvasRenderingContext2D::setAllAttributesToDefault() 
+void CanvasRenderingContext2D::setAllAttributesToDefault()
 {
     state().m_globalAlpha = 1;
     state().m_shadowOffset = FloatSize();
@@ -943,7 +943,7 @@ void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float h
 {
     if (!validateRectForCanvas(x, y, width, height))
         return;
- 
+
     if (!(lineWidth >= 0))
         return;
 
@@ -1276,7 +1276,7 @@ void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, const
         return;
     if (!state().m_invertibleCTM)
         return;
- 
+
     FloatRect sourceRect = c->roundToDevicePixels(srcRect);
     FloatRect destRect = c->roundToDevicePixels(dstRect);
 
@@ -1510,12 +1510,12 @@ void CanvasRenderingContext2D::didDraw(const FloatRect& r, unsigned options)
         return;
 
     FloatRect dirtyRect = r;
-    if (options & CanvasWillDrawApplyTransform) {
+    if (options & CanvasDidDrawApplyTransform) {
         AffineTransform ctm = state().m_transform;
         dirtyRect = ctm.mapRect(r);
     }
 
-    if (options & CanvasWillDrawApplyShadow && alphaChannel(state().m_shadowColor)) {
+    if (options & CanvasDidDrawApplyShadow && alphaChannel(state().m_shadowColor)) {
         // The shadow gets applied after transformation
         FloatRect shadowRect(dirtyRect);
         shadowRect.move(state().m_shadowOffset);
@@ -1523,12 +1523,16 @@ void CanvasRenderingContext2D::didDraw(const FloatRect& r, unsigned options)
         dirtyRect.unite(shadowRect);
     }
 
-    if (options & CanvasWillDrawApplyClip) {
+    if (options & CanvasDidDrawApplyClip) {
         // FIXME: apply the current clip to the rectangle. Unfortunately we can't get the clip
         // back out of the GraphicsContext, so to take clip into account for incremental painting,
         // we'd have to keep the clip path around.
     }
 
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    if (isAccelerated())
+        drawingContext()->markDirtyRect(enclosingIntRect(dirtyRect));
+#endif
 #if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING)
     // If we are drawing to hardware and we have a composited layer, just call rendererContentChanged().
     RenderBox* renderBox = canvas()->renderBox();
@@ -1658,7 +1662,7 @@ void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
     IntPoint destPoint(destOffset.width(), destOffset.height());
 
     buffer->putUnmultipliedImageData(data, sourceRect, destPoint);
-    didDraw(sourceRect, 0); // ignore transform, shadow and clip
+    didDraw(sourceRect, CanvasDidDrawApplyNone); // ignore transform, shadow and clip
 }
 
 String CanvasRenderingContext2D::font() const
@@ -1878,11 +1882,11 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
     c->drawBidiText(font, textRun, location);
 
     if (fill)
-        canvas()->didDraw(textRect);
+        didDraw(textRect);
     else {
         // When stroking text, pointy miters can extend outside of textRect, so we
         // punt and dirty the whole canvas.
-        canvas()->didDraw(FloatRect(0, 0, canvas()->width(), canvas()->height()));
+        didDraw(FloatRect(0, 0, canvas()->width(), canvas()->height()));
     }
 
 #if PLATFORM(QT)
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.h b/WebCore/html/canvas/CanvasRenderingContext2D.h
index d9d8597..91b6549 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.h
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.h
@@ -20,7 +20,7 @@
  * 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. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef CanvasRenderingContext2D_h
@@ -264,14 +264,15 @@ private:
 
     void applyShadow();
 
-    enum CanvasWillDrawOption {
-        CanvasWillDrawApplyTransform = 1,
-        CanvasWillDrawApplyShadow = 1 << 1,
-        CanvasWillDrawApplyClip = 1 << 2,
-        CanvasWillDrawApplyAll = 0xffffffff
+    enum CanvasDidDrawOption {
+        CanvasDidDrawApplyNone = 0,
+        CanvasDidDrawApplyTransform = 1,
+        CanvasDidDrawApplyShadow = 1 << 1,
+        CanvasDidDrawApplyClip = 1 << 2,
+        CanvasDidDrawApplyAll = 0xffffffff
     };
 
-    void didDraw(const FloatRect&, unsigned options = CanvasWillDrawApplyAll);
+    void didDraw(const FloatRect&, unsigned options = CanvasDidDrawApplyAll);
 
     GraphicsContext* drawingContext() const;
 
diff --git a/WebCore/platform/graphics/GraphicsContext.cpp b/WebCore/platform/graphics/GraphicsContext.cpp
index ea6c448..2c94bec 100644
--- a/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/WebCore/platform/graphics/GraphicsContext.cpp
@@ -467,7 +467,7 @@ void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS
 {
     if (paintingDisabled() || !image)
         return;
-        
+
     float tsw = src.width();
     float tsh = src.height();
     float tw = dest.width();
@@ -489,7 +489,7 @@ void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS
     }
 
     image->draw(this, styleColorSpace, dest, src, op, useLowQualityScale);
-    
+
     if (useLowQualityScale)
         restore();
 }
@@ -579,6 +579,10 @@ void GraphicsContext::setSharedGraphicsContext3D(SharedGraphicsContext3D*, Drawi
 void GraphicsContext::syncSoftwareCanvas()
 {
 }
+
+void GraphicsContext::markDirtyRect(const IntRect&)
+{
+}
 #endif
 
 
diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h
index c3b20a9..cb045e1 100644
--- a/WebCore/platform/graphics/GraphicsContext.h
+++ b/WebCore/platform/graphics/GraphicsContext.h
@@ -21,7 +21,7 @@
  * 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. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef GraphicsContext_h
@@ -424,6 +424,7 @@ namespace WebCore {
 
         void setSharedGraphicsContext3D(SharedGraphicsContext3D*, DrawingBuffer*, const IntSize&);
         void syncSoftwareCanvas();
+        void markDirtyRect(const IntRect&); // Hints that a portion of the backing store is dirty.
 
     private:
         void savePlatformState();
diff --git a/WebCore/platform/graphics/gpu/Texture.cpp b/WebCore/platform/graphics/gpu/Texture.cpp
index 36e4ad5..c2c3804 100644
--- a/WebCore/platform/graphics/gpu/Texture.cpp
+++ b/WebCore/platform/graphics/gpu/Texture.cpp
@@ -32,11 +32,15 @@
 
 #include "Texture.h"
 
+#include "FloatRect.h"
 #include "GraphicsContext3D.h"
 #include "IntRect.h"
 
+#include <algorithm>
 #include <wtf/OwnArrayPtr.h>
 
+using namespace std;
+
 namespace WebCore {
 
 
@@ -82,7 +86,6 @@ PassRefPtr<Texture> Texture::create(GraphicsContext3D* context, Format format, i
 {
     int maxTextureSize = 0;
     context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize);
-
     TilingData tiling(maxTextureSize, width, height, true);
     int numTiles = tiling.numTiles();
 
@@ -137,6 +140,11 @@ static uint32_t* copySubRect(uint32_t* src, int srcX, int srcY, uint32_t* dst, i
 
 void Texture::load(void* pixels)
 {
+    updateSubRect(pixels, IntRect(0, 0, m_tiles.totalSizeX(), m_tiles.totalSizeY()));
+}
+
+void Texture::updateSubRect(void* pixels, const IntRect updateRect)
+{
     uint32_t* pixels32 = static_cast<uint32_t*>(pixels);
     unsigned int glFormat = 0;
     unsigned int glType = 0;
@@ -146,26 +154,42 @@ void Texture::load(void* pixels)
         ASSERT(glFormat == GraphicsContext3D::RGBA && glType == GraphicsContext3D::UNSIGNED_BYTE);
         // FIXME:  This could use PBO's to save doing an extra copy here.
     }
-    OwnArrayPtr<uint32_t> tempBuff(new uint32_t[m_tiles.maxTextureSize() * m_tiles.maxTextureSize()]);
+    int tempBuffSize = // Temporary buffer size is the smaller of the max texture size or the updateRect
+        min(m_tiles.maxTextureSize(), m_tiles.borderTexels() + updateRect.width()) *
+        min(m_tiles.maxTextureSize(), m_tiles.borderTexels() + updateRect.height());
+    OwnArrayPtr<uint32_t> tempBuff(new uint32_t[tempBuffSize]);
 
-    for (int i = 0; i < m_tiles.numTiles(); i++) {
-        IntRect tileBoundsWithBorder = m_tiles.tileBoundsWithBorder(i);
+    for (int tile = 0; tile < m_tiles.numTiles(); tile++) {
+        // Intersect with tile
+        IntRect tileBoundsWithBorder = m_tiles.tileBoundsWithBorder(tile);
 
+        IntRect updateRectIntersected = updateRect;
+        updateRectIntersected.intersect(tileBoundsWithBorder);
+
+        IntRect dstRect = updateRectIntersected;
+        dstRect.move(-tileBoundsWithBorder.x(), -tileBoundsWithBorder.y());
+
+        if (updateRectIntersected.isEmpty())
+            continue;
+
+        // Copy sub rectangle out of larger pixel data
         uint32_t* uploadBuff = 0;
         if (swizzle) {
             uploadBuff = copySubRect<true>(
-            pixels32, tileBoundsWithBorder.x(), tileBoundsWithBorder.y(),
-            tempBuff.get(), tileBoundsWithBorder.width(), tileBoundsWithBorder.height(), m_tiles.totalSizeX());
+            pixels32, updateRectIntersected.x(), updateRectIntersected.y(),
+            tempBuff.get(), updateRectIntersected.width(), updateRectIntersected.height(), m_tiles.totalSizeX());
         } else {
             uploadBuff = copySubRect<false>(
-            pixels32, tileBoundsWithBorder.x(), tileBoundsWithBorder.y(),
-            tempBuff.get(), tileBoundsWithBorder.width(), tileBoundsWithBorder.height(), m_tiles.totalSizeX());
+            pixels32, updateRectIntersected.x(), updateRectIntersected.y(),
+            tempBuff.get(), updateRectIntersected.width(), updateRectIntersected.height(), m_tiles.totalSizeX());
         }
 
-        m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_tileTextureIds->at(i));
-        m_context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, 0, 0,
-            tileBoundsWithBorder.width(),
-            tileBoundsWithBorder.height(), glFormat, glType, uploadBuff);
+        m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_tileTextureIds->at(tile));
+        m_context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0 /* level */,
+            dstRect.x(),
+            dstRect.y(),
+            updateRectIntersected.width(),
+            updateRectIntersected.height(), glFormat, glType, uploadBuff);
     }
 }
 
diff --git a/WebCore/platform/graphics/gpu/Texture.h b/WebCore/platform/graphics/gpu/Texture.h
index 7e4a72b..eda475e 100644
--- a/WebCore/platform/graphics/gpu/Texture.h
+++ b/WebCore/platform/graphics/gpu/Texture.h
@@ -41,6 +41,8 @@
 namespace WebCore {
 class GraphicsContext3D;
 
+class IntRect;
+
 class Texture : public RefCounted<Texture> {
 public:
     ~Texture();
@@ -48,6 +50,7 @@ public:
     static PassRefPtr<Texture> create(GraphicsContext3D*, Format, int width, int height);
     void bindTile(int tile);
     void load(void* pixels);
+    void updateSubRect(void* pixels, const IntRect);
     Format format() const { return m_format; }
     const TilingData& tiles() const { return m_tiles; }
 private:
diff --git a/WebCore/platform/graphics/gpu/TilingData.h b/WebCore/platform/graphics/gpu/TilingData.h
index f12e66e..1bdc51a 100644
--- a/WebCore/platform/graphics/gpu/TilingData.h
+++ b/WebCore/platform/graphics/gpu/TilingData.h
@@ -44,6 +44,7 @@ public:
     int maxTextureSize() const { return m_maxTextureSize; }
     int totalSizeX() const { return m_totalSizeX; }
     int totalSizeY() const { return m_totalSizeY; }
+    int borderTexels() const { return m_borderTexels; }
 
     int numTiles() const { return numTilesX() * numTilesY(); }
     int numTilesX() const { return m_numTilesX; }
diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
index 4eb80aa..d618c19 100644
--- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
+++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
@@ -1,10 +1,10 @@
 /*
  * Copyright (c) 2006, Google Inc. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * met:
- * 
+ *
  *     * Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
  *     * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
  *     * Neither the name of Google Inc. nor the names of its
  * contributors may be used to endorse or promote products derived from
  * this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -65,7 +65,7 @@ namespace {
 inline int fastMod(int value, int max)
 {
     int sign = SkExtractSign(value);
-    
+
     value = SkApplySign(value, sign);
     if (value >= max)
         value %= max;
@@ -499,7 +499,7 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin
 
     if (numPoints <= 1)
         return;
-    
+
     // FIXME: IMPLEMENT!!
 }
 
@@ -1250,4 +1250,9 @@ void GraphicsContext::setSharedGraphicsContext3D(SharedGraphicsContext3D* contex
     platformContext()->setSharedGraphicsContext3D(context, framebuffer, size);
 }
 
+void GraphicsContext::markDirtyRect(const IntRect& rect)
+{
+    platformContext()->markDirtyRect(rect);
+}
+
 }  // namespace WebCore
diff --git a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
index bb89ac5..9c96673 100644
--- a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
@@ -117,6 +117,7 @@ void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, con
             FloatRect destRectFlipped(destRect);
             destRectFlipped.setY(destRect.y() + destRect.height());
             destRectFlipped.setHeight(-destRect.height());
+            context->platformContext()->prepareForHardwareDraw();
             context->platformContext()->gpuCanvas()->drawTexturedRect(sourceTexture, m_size, srcRect, destRectFlipped, styleColorSpace, op);
             return;
         }
diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
index 7c58518..f0d6548 100644
--- a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
+++ b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
@@ -1,10 +1,10 @@
 /*
  * Copyright (c) 2008, Google Inc. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * met:
- * 
+ *
  *     * Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
  *     * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
  *     * Neither the name of Google Inc. nor the names of its
  * contributors may be used to endorse or promote products derived from
  * this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -187,7 +187,7 @@ PlatformContextSkia::State PlatformContextSkia::State::cloneInheritedProperties(
     PlatformContextSkia::State state(*this);
 
     // Everything is inherited except for the clip paths.
-    state.m_antiAliasClipPaths.clear();  
+    state.m_antiAliasClipPaths.clear();
 
     return state;
 }
@@ -339,7 +339,7 @@ void PlatformContextSkia::drawRect(SkRect rect)
         // We do a fill of four rects to simulate the stroke of a border.
         SkColor oldFillColor = m_state->m_fillColor;
 
-        // setFillColor() will set the shader to NULL, so save a ref to it now. 
+        // setFillColor() will set the shader to NULL, so save a ref to it now.
         SkShader* oldFillShader = m_state->m_fillShader;
         oldFillShader->safeRef();
         setFillColor(m_state->m_strokeColor);
@@ -464,7 +464,7 @@ void PlatformContextSkia::setXfermodeMode(SkXfermode::Mode pdm)
 void PlatformContextSkia::setFillColor(SkColor color)
 {
     m_state->m_fillColor = color;
-    setFillShader(NULL);
+    setFillShader(0);
 }
 
 SkDrawLooper* PlatformContextSkia::getDrawLooper() const
@@ -485,7 +485,7 @@ void PlatformContextSkia::setStrokeStyle(StrokeStyle strokeStyle)
 void PlatformContextSkia::setStrokeColor(SkColor strokeColor)
 {
     m_state->m_strokeColor = strokeColor;
-    setStrokeShader(NULL);
+    setStrokeShader(0);
 }
 
 float PlatformContextSkia::getStrokeThickness() const
@@ -802,6 +802,23 @@ void PlatformContextSkia::syncSoftwareCanvas() const
     m_backingStoreState = Software;
 }
 
+void PlatformContextSkia::markDirtyRect(const IntRect& rect)
+{
+    if (!m_useGPU)
+        return;
+
+    switch (m_backingStoreState) {
+    case Software:
+    case Mixed:
+        m_softwareDirtyRect.unite(rect);
+        return;
+    case Hardware:
+        return;
+    default:
+        ASSERT_NOT_REACHED();
+    }
+}
+
 void PlatformContextSkia::uploadSoftwareToHardware(CompositeOperator op) const
 {
     const SkBitmap& bitmap = m_canvas->getDevice()->accessBitmap(false);
@@ -809,10 +826,11 @@ void PlatformContextSkia::uploadSoftwareToHardware(CompositeOperator op) const
     SharedGraphicsContext3D* context = m_gpuCanvas->context();
     if (!m_uploadTexture || m_uploadTexture->tiles().totalSizeX() < bitmap.width() || m_uploadTexture->tiles().totalSizeY() < bitmap.height())
         m_uploadTexture = context->createTexture(Texture::BGRA8, bitmap.width(), bitmap.height());
-    m_uploadTexture->load(bitmap.getPixels());
-    IntRect rect(0, 0, bitmap.width(), bitmap.height());
+
+    m_uploadTexture->updateSubRect(bitmap.getPixels(), m_softwareDirtyRect);
     AffineTransform identity;
-    gpuCanvas()->drawTexturedRect(m_uploadTexture.get(), rect, rect, identity, 1.0, DeviceColorSpace, op);
+    gpuCanvas()->drawTexturedRect(m_uploadTexture.get(), m_softwareDirtyRect, m_softwareDirtyRect, identity, 1.0, DeviceColorSpace, op);
+    m_softwareDirtyRect.setWidth(0); // Clear dirty rect.
 }
 
 void PlatformContextSkia::readbackHardwareToSoftware() const
diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.h b/WebCore/platform/graphics/skia/PlatformContextSkia.h
index cb9aa71..e6d5875 100644
--- a/WebCore/platform/graphics/skia/PlatformContextSkia.h
+++ b/WebCore/platform/graphics/skia/PlatformContextSkia.h
@@ -1,10 +1,10 @@
 /*
  * Copyright (c) 2008, Google Inc. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * met:
- * 
+ *
  *     * Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
  *     * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
  *     * Neither the name of Google Inc. nor the names of its
  * contributors may be used to endorse or promote products derived from
  * this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -194,6 +194,7 @@ public:
     void prepareForHardwareDraw() const;
     // Call to force the skia::PlatformCanvas to contain all rendering results.
     void syncSoftwareCanvas() const;
+    void markDirtyRect(const IntRect& rect);
 
 private:
 #if OS(LINUX) || OS(WINDOWS)
@@ -222,7 +223,7 @@ private:
     // Current path in global coordinates.
     SkPath m_path;
 
-    // Stores image sizes for a hint to compute image resampling modes. 
+    // Stores image sizes for a hint to compute image resampling modes.
     // Values are used in ImageSkia.cpp
     IntSize m_imageResamplingHintSrcSize;
     FloatSize m_imageResamplingHintDstSize;
@@ -233,6 +234,7 @@ private:
     OwnPtr<GLES2Canvas> m_gpuCanvas;
     mutable enum { None, Software, Mixed, Hardware } m_backingStoreState;
     mutable RefPtr<Texture> m_uploadTexture;
+    mutable IntRect m_softwareDirtyRect;
 };
 
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list