Title: [148953] trunk/Source/WebCore
Revision
148953
Author
[email protected]
Date
2013-04-23 02:02:03 -0700 (Tue, 23 Apr 2013)

Log Message

[Texmap] Don't paint to an intermediate surface when the result is going to be clipped out completely.
https://bugs.webkit.org/show_bug.cgi?id=115015

Patch by Noam Rosenthal <[email protected]> on 2013-04-23
Reviewed by Allan Sandfeld Jensen.

Maintain a clipBounds rectangle in TextureMapper, and test it against the bounds of an intermediate
surface before it is painted.
This allows us to opt out completely of painting into the surface if the result is going to be optimized
out by the GPU clipping.

Covered by tests in compositing/overlap-blending.

* platform/graphics/texmap/TextureMapper.h:
(TextureMapper):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::clipBounds):
(WebCore):
* platform/graphics/texmap/TextureMapperGL.h:
* platform/graphics/texmap/TextureMapperImageBuffer.h:
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintUsingOverlapRegions):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (148952 => 148953)


--- trunk/Source/WebCore/ChangeLog	2013-04-23 08:58:25 UTC (rev 148952)
+++ trunk/Source/WebCore/ChangeLog	2013-04-23 09:02:03 UTC (rev 148953)
@@ -1,5 +1,29 @@
 2013-04-23  Noam Rosenthal  <[email protected]>
 
+        [Texmap] Don't paint to an intermediate surface when the result is going to be clipped out completely.
+        https://bugs.webkit.org/show_bug.cgi?id=115015
+
+        Reviewed by Allan Sandfeld Jensen.
+
+        Maintain a clipBounds rectangle in TextureMapper, and test it against the bounds of an intermediate
+        surface before it is painted.
+        This allows us to opt out completely of painting into the surface if the result is going to be optimized
+        out by the GPU clipping.
+
+        Covered by tests in compositing/overlap-blending.
+
+        * platform/graphics/texmap/TextureMapper.h:
+        (TextureMapper):
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::clipBounds):
+        (WebCore):
+        * platform/graphics/texmap/TextureMapperGL.h:
+        * platform/graphics/texmap/TextureMapperImageBuffer.h:
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::paintUsingOverlapRegions):
+
+2013-04-23  Noam Rosenthal  <[email protected]>
+
         [Coordinated Graphics] Remove the lockAnimations code path
         https://bugs.webkit.org/show_bug.cgi?id=114899
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h (148952 => 148953)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h	2013-04-23 08:58:25 UTC (rev 148952)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h	2013-04-23 09:02:03 UTC (rev 148953)
@@ -147,6 +147,7 @@
     GraphicsContext* graphicsContext() { return m_context; }
     virtual void beginClip(const TransformationMatrix&, const FloatRect&) = 0;
     virtual void endClip() = 0;
+    virtual IntRect clipBounds() = 0;
     virtual PassRefPtr<BitmapTexture> createTexture() = 0;
 
     void setImageInterpolationQuality(InterpolationQuality quality) { m_interpolationQuality = quality; }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (148952 => 148953)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2013-04-23 08:58:25 UTC (rev 148952)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2013-04-23 09:02:03 UTC (rev 148953)
@@ -1198,6 +1198,11 @@
     clipStack().applyIfNeeded(m_context3D.get());
 }
 
+IntRect TextureMapperGL::clipBounds()
+{
+    return clipStack().current().scissorBox;
+}
+
 PassRefPtr<BitmapTexture> TextureMapperGL::createTexture()
 {
     BitmapTextureGL* texture = new BitmapTextureGL(this);

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (148952 => 148953)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2013-04-23 08:58:25 UTC (rev 148952)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2013-04-23 09:02:03 UTC (rev 148953)
@@ -64,6 +64,7 @@
     virtual void beginPainting(PaintFlags = 0) OVERRIDE;
     virtual void endPainting() OVERRIDE;
     virtual void endClip() OVERRIDE;
+    virtual IntRect clipBounds() OVERRIDE;
     virtual IntSize maxTextureSize() const OVERRIDE { return IntSize(2000, 2000); }
     virtual PassRefPtr<BitmapTexture> createTexture() OVERRIDE;
     inline GraphicsContext3D* graphicsContext3D() const { return m_context3D.get(); }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h (148952 => 148953)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h	2013-04-23 08:58:25 UTC (rev 148952)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h	2013-04-23 09:02:03 UTC (rev 148953)
@@ -60,6 +60,7 @@
     virtual void beginClip(const TransformationMatrix&, const FloatRect&) OVERRIDE;
     virtual void bindSurface(BitmapTexture* surface) OVERRIDE { m_currentSurface = surface;}
     virtual void endClip() OVERRIDE { graphicsContext()->restore(); }
+    virtual IntRect clipBounds() OVERRIDE { return currentContext()->clipBounds(); }
     virtual IntSize maxTextureSize() const;
     virtual PassRefPtr<BitmapTexture> createTexture() OVERRIDE { return BitmapTextureImageBuffer::create(); }
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (148952 => 148953)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2013-04-23 08:58:25 UTC (rev 148952)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2013-04-23 09:02:03 UTC (rev 148953)
@@ -359,11 +359,13 @@
         return;
     }
 
-    Vector<IntRect> rects;
-
     nonOverlapRegion.translate(options.offset);
-    rects = nonOverlapRegion.rects();
+    Vector<IntRect> rects = nonOverlapRegion.rects();
     for (size_t i = 0; i < rects.size(); ++i) {
+        IntRect rect = rects[i];
+        if (!rect.intersects(options.textureMapper->clipBounds()))
+            continue;
+
         options.textureMapper->beginClip(TransformationMatrix(), rects[i]);
         paintSelfAndChildrenWithReplica(options);
         options.textureMapper->endClip();
@@ -371,13 +373,17 @@
 
     rects = overlapRegion.rects();
     IntSize maxTextureSize = options.textureMapper->maxTextureSize();
-    IntRect rect;
+    IntRect adjustedClipBounds(options.textureMapper->clipBounds());
+    adjustedClipBounds.move(-options.offset);
     for (size_t i = 0; i < rects.size(); ++i) {
-        rect = rects[i];
+        IntRect rect = rects[i];
         for (int x = rect.x(); x < rect.maxX(); x += maxTextureSize.width()) {
             for (int y = rect.y(); y < rect.maxY(); y += maxTextureSize.height()) {
                 IntRect tileRect(IntPoint(x, y), maxTextureSize);
                 tileRect.intersect(rect);
+                if (!tileRect.intersects(adjustedClipBounds))
+                    continue;
+
                 paintWithIntermediateSurface(options, tileRect);
             }
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to