Title: [101623] trunk/Source
Revision
101623
Author
[email protected]
Date
2011-11-30 23:40:05 -0800 (Wed, 30 Nov 2011)

Log Message

Source/WebCore: [Chromium] Improve tile invalidation
https://bugs.webkit.org/show_bug.cgi?id=71872

Patch by David Reveman <[email protected]> on 2011-11-30
Reviewed by James Robinson.

Virtualize LayerChromium::setNeedsDisplay so that dirty rectangles can
be handled directly by the TiledLayerChromium class. Replace
LayerChromium::dirtyRect() with LayerChromium::needsDisplay() and
remove unnecessary union of dirty rectangles. By invalidating existing
tiles using the initial dirty rectangles instead of their union we
avoid a large amount of unnecessary tile updates.

Update LayerChromiumTest.

* platform/graphics/chromium/Canvas2DLayerChromium.cpp:
(WebCore::Canvas2DLayerChromium::updateCompositorResources):
* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerChromium::paintContentsIfDirty):
* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayerChromium::setNeedsDisplayInRect):
* platform/graphics/chromium/ImageLayerChromium.cpp:
(WebCore::ImageLayerChromium::setContents):
(WebCore::ImageLayerChromium::paintContentsIfDirty):
* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::LayerChromium):
(WebCore::LayerChromium::setBounds):
(WebCore::LayerChromium::setNeedsDisplayRect):
* platform/graphics/chromium/LayerChromium.h:
(WebCore::LayerChromium::setNeedsDisplay):
(WebCore::LayerChromium::needsDisplay):
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::setNeedsDisplayRect):
(WebCore::TiledLayerChromium::invalidateRect):
* platform/graphics/chromium/TiledLayerChromium.h:
* platform/graphics/chromium/VideoLayerChromium.cpp:
(WebCore::VideoLayerChromium::updateCompositorResources):
* platform/graphics/chromium/WebGLLayerChromium.cpp:
(WebCore::WebGLLayerChromium::updateCompositorResources):

Source/WebKit/chromium: [Chromium] Improve tile invalidation.
https://bugs.webkit.org/show_bug.cgi?id=71872

Patch by David Reveman <[email protected]> on 2011-11-30
Reviewed by James Robinson.

Remove public API function WebContentLayer::invalidRect(). Add new
test case to
LayerChromiumTest.checkSetNeedsDisplayCausesCorrectBehavior that
verifies that calling setNeedsDisplay() on a LayerChromium with
empty bounds is handled correctly.

* public/WebContentLayer.h:
* src/WebContentLayer.cpp:
(WebKit::WebContentLayer::invalidateRect):
* src/WebMediaPlayerClientImpl.cpp:
(WebKit::WebMediaPlayerClientImpl::repaint):
* tests/LayerChromiumTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101622 => 101623)


--- trunk/Source/WebCore/ChangeLog	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/ChangeLog	2011-12-01 07:40:05 UTC (rev 101623)
@@ -1,3 +1,44 @@
+2011-11-30  David Reveman  <[email protected]>
+
+        [Chromium] Improve tile invalidation
+        https://bugs.webkit.org/show_bug.cgi?id=71872
+
+        Reviewed by James Robinson.
+
+        Virtualize LayerChromium::setNeedsDisplay so that dirty rectangles can
+        be handled directly by the TiledLayerChromium class. Replace
+        LayerChromium::dirtyRect() with LayerChromium::needsDisplay() and
+        remove unnecessary union of dirty rectangles. By invalidating existing
+        tiles using the initial dirty rectangles instead of their union we
+        avoid a large amount of unnecessary tile updates.
+
+        Update LayerChromiumTest.
+
+        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
+        (WebCore::Canvas2DLayerChromium::updateCompositorResources):
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::paintContentsIfDirty):
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::setNeedsDisplayInRect):
+        * platform/graphics/chromium/ImageLayerChromium.cpp:
+        (WebCore::ImageLayerChromium::setContents):
+        (WebCore::ImageLayerChromium::paintContentsIfDirty):
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::LayerChromium):
+        (WebCore::LayerChromium::setBounds):
+        (WebCore::LayerChromium::setNeedsDisplayRect):
+        * platform/graphics/chromium/LayerChromium.h:
+        (WebCore::LayerChromium::setNeedsDisplay):
+        (WebCore::LayerChromium::needsDisplay):
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::setNeedsDisplayRect):
+        (WebCore::TiledLayerChromium::invalidateRect):
+        * platform/graphics/chromium/TiledLayerChromium.h:
+        * platform/graphics/chromium/VideoLayerChromium.cpp:
+        (WebCore::VideoLayerChromium::updateCompositorResources):
+        * platform/graphics/chromium/WebGLLayerChromium.cpp:
+        (WebCore::WebGLLayerChromium::updateCompositorResources):
+
 2011-11-30  Alexey Proskuryakov  <[email protected]>
 
         SocketStreamHandleCFNet doesn't check for proxy errors

Modified: trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -67,7 +67,7 @@
 
 void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&)
 {
-    if (m_dirtyRect.isEmpty() || !drawsContent())
+    if (!m_needsDisplay || !drawsContent())
         return;
 
     if (m_context) {
@@ -82,7 +82,7 @@
     }
 
     m_updateRect = FloatRect(FloatPoint(), bounds());
-    resetNeedsDisplay();
+    m_needsDisplay = false;
 }
 
 void Canvas2DLayerChromium::contentChanged()

Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -104,12 +104,8 @@
     if (drawsContent())
         layerRect = visibleLayerRect();
 
-    IntRect dirty = enclosingIntRect(m_dirtyRect);
-    dirty.intersect(IntRect(IntPoint(), contentBounds()));
-    invalidateRect(dirty);
-
     prepareToUpdate(layerRect);
-    resetNeedsDisplay();
+    m_needsDisplay = false;
 }
 
 bool ContentLayerChromium::drawsContent() const

Modified: trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -325,7 +325,7 @@
 void GraphicsLayerChromium::setNeedsDisplayInRect(const FloatRect& rect)
 {
     if (drawsContent())
-        m_layer->setNeedsDisplay(rect);
+        m_layer->setNeedsDisplayRect(rect);
 }
 
 void GraphicsLayerChromium::setContentsRect(const IntRect& rect)

Modified: trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -163,20 +163,19 @@
 
     m_contents = contents;
     m_imageForCurrentFrame = m_contents->nativeImageForCurrentFrame();
-    m_dirtyRect = IntRect(IntPoint(0, 0), bounds());
     setNeedsDisplay();
     setOpaque(!m_contents->currentFrameHasAlpha());
 }
 
 void ImageLayerChromium::paintContentsIfDirty()
 {
-    if (!m_dirtyRect.isEmpty()) {
+    if (m_needsDisplay) {
         m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame());
         updateTileSizeAndTilingOption();
         IntRect paintRect(IntPoint(), contentBounds());
-        if (!m_dirtyRect.isEmpty()) {
+        if (m_needsDisplay) {
             invalidateRect(paintRect);
-            resetNeedsDisplay();
+            m_needsDisplay = false;
         }
     }
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -56,6 +56,7 @@
 
 LayerChromium::LayerChromium(CCLayerDelegate* delegate)
     : m_delegate(delegate)
+    , m_needsDisplay(false)
     , m_layerId(s_nextLayerId++)
     , m_parent(0)
     , m_scrollable(false)
@@ -214,7 +215,7 @@
     m_bounds = size;
 
     if (firstResize || m_pageScaleDirty)
-        setNeedsDisplay(FloatRect(0, 0, bounds().width(), bounds().height()));
+        setNeedsDisplayRect(FloatRect(0, 0, bounds().width(), bounds().height()));
     else
         setNeedsCommit();
 
@@ -258,27 +259,17 @@
     m_name = name;
 }
 
-void LayerChromium::setNeedsDisplay(const FloatRect& dirtyRect)
+void LayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
 {
     // Simply mark the contents as dirty. For non-root layers, the call to
     // setNeedsCommit will schedule a fresh compositing pass.
     // For the root layer, setNeedsCommit has no effect.
-    m_dirtyRect.unite(dirtyRect);
-    setNeedsCommit();
-}
+    if (!dirtyRect.isEmpty())
+        m_needsDisplay = true;
 
-void LayerChromium::setNeedsDisplay()
-{
-    m_dirtyRect.setLocation(FloatPoint());
-    m_dirtyRect.setSize(bounds());
     setNeedsCommit();
 }
 
-void LayerChromium::resetNeedsDisplay()
-{
-    m_dirtyRect = FloatRect();
-}
-
 void LayerChromium::pushPropertiesTo(CCLayerImpl* layer)
 {
     layer->setAnchorPoint(m_anchorPoint);

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2011-12-01 07:40:05 UTC (rev 101623)
@@ -105,10 +105,9 @@
     void setMaskLayer(LayerChromium* maskLayer) { m_maskLayer = maskLayer; setNeedsCommit(); }
     LayerChromium* maskLayer() const { return m_maskLayer.get(); }
 
-    void setNeedsDisplay(const FloatRect& dirtyRect);
-    void setNeedsDisplay();
-    const FloatRect& dirtyRect() const { return m_dirtyRect; }
-    void resetNeedsDisplay();
+    virtual void setNeedsDisplayRect(const FloatRect& dirtyRect);
+    void setNeedsDisplay() { setNeedsDisplayRect(FloatRect(FloatPoint(), contentBounds())); }
+    virtual bool needsDisplay() const { return m_needsDisplay; }
 
     void setOpacity(float opacity) { m_opacity = opacity; setNeedsCommit(); }
     float opacity() const { return m_opacity; }
@@ -218,8 +217,8 @@
 
     void setNeedsCommit();
 
-    // The dirty rect is the union of damaged regions that need repainting/updating.
-    FloatRect m_dirtyRect;
+    // This flag is set when layer need repainting/updating.
+    bool m_needsDisplay;
 
     // The update rect is the region of the compositor resource that was actually updated by the compositor.
     // For layers that may do updating outside the compositor's control (i.e. plugin layers), this information

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -284,13 +284,18 @@
     return tile.get();
 }
 
+void TiledLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
+{
+    IntRect dirty = enclosingIntRect(dirtyRect);
+    invalidateRect(dirty);
+    LayerChromium::setNeedsDisplayRect(dirtyRect);
+}
+
 void TiledLayerChromium::invalidateRect(const IntRect& contentRect)
 {
     if (!m_tiler || contentRect.isEmpty() || m_skipsDraw)
         return;
 
-    m_tiler->growLayerToContain(contentRect);
-
     // Dirty rects are always in layer space, as the layer could be repositioned
     // after invalidation.
     const IntRect layerRect = m_tiler->contentRectToLayerRect(contentRect);

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h	2011-12-01 07:40:05 UTC (rev 101623)
@@ -53,6 +53,8 @@
 
     virtual IntSize contentBounds() const;
 
+    virtual void setNeedsDisplayRect(const FloatRect&);
+
     // Reserves all existing and valid tile textures to protect them from being
     // recycled by the texture manager.
     void protectTileTextures(const IntRect& contentRect);

Modified: trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -83,7 +83,7 @@
     if (!m_delegate || !m_provider || !drawsContent())
         return;
 
-    if (m_dirtyRect.isEmpty() && texturesValid()) {
+    if (!m_needsDisplay && texturesValid()) {
         for (unsigned plane = 0; plane < m_planes; plane++) {
             ManagedTexture* tex = m_textures[plane].m_texture.get();
             if (!tex->reserve(tex->size(), tex->format())) {
@@ -118,7 +118,7 @@
         m_nativeTextureId = frame->textureId();
         m_nativeTextureSize = IntSize(frame->width(), frame->height());
         m_nativeTextureVisibleSize = IntSize(frame->width(), frame->height());
-        resetNeedsDisplay();
+        m_needsDisplay = false;
         m_provider->putCurrentFrame(frame);
         return;
     }
@@ -144,7 +144,7 @@
     ASSERT(m_planes <= MaxPlanes);
 
     m_updateRect = FloatRect(FloatPoint(), bounds());
-    resetNeedsDisplay();
+    m_needsDisplay = false;
 
     m_provider->putCurrentFrame(frame);
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp (101622 => 101623)


--- trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -71,7 +71,7 @@
     if (!drawsContent())
         return;
 
-    if (m_dirtyRect.isEmpty())
+    if (!m_needsDisplay)
         return;
 
     if (m_textureChanged) {
@@ -85,12 +85,12 @@
         m_textureChanged = false;
     }
     // Update the contents of the texture used by the compositor.
-    if (!m_dirtyRect.isEmpty() && m_textureUpdated) {
+    if (m_needsDisplay && m_textureUpdated) {
         // publishToPlatformLayer prepares the contents of the off-screen render target for use by the compositor.
         drawingBuffer()->publishToPlatformLayer();
         context()->markLayerComposited();
         m_updateRect = FloatRect(FloatPoint(), bounds());
-        resetNeedsDisplay();
+        m_needsDisplay = false;
         m_textureUpdated = false;
     }
 }

Modified: trunk/Source/WebKit/chromium/ChangeLog (101622 => 101623)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-12-01 07:40:05 UTC (rev 101623)
@@ -1,3 +1,23 @@
+2011-11-30  David Reveman  <[email protected]>
+
+        [Chromium] Improve tile invalidation.
+        https://bugs.webkit.org/show_bug.cgi?id=71872
+
+        Reviewed by James Robinson.
+
+        Remove public API function WebContentLayer::invalidRect(). Add new
+        test case to
+        LayerChromiumTest.checkSetNeedsDisplayCausesCorrectBehavior that
+        verifies that calling setNeedsDisplay() on a LayerChromium with
+        empty bounds is handled correctly.
+
+        * public/WebContentLayer.h:
+        * src/WebContentLayer.cpp:
+        (WebKit::WebContentLayer::invalidateRect):
+        * src/WebMediaPlayerClientImpl.cpp:
+        (WebKit::WebMediaPlayerClientImpl::repaint):
+        * tests/LayerChromiumTest.cpp:
+
 2011-11-30  Takashi Toyoshima  <[email protected]>
 
         Add didUpdateBufferedAmount callback to WebSocketClient API

Modified: trunk/Source/WebKit/chromium/public/WebContentLayer.h (101622 => 101623)


--- trunk/Source/WebKit/chromium/public/WebContentLayer.h	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebKit/chromium/public/WebContentLayer.h	2011-12-01 07:40:05 UTC (rev 101623)
@@ -60,9 +60,6 @@
     // Sets the entire layer as invalid, i.e. needs to update its content.
     WEBKIT_EXPORT void invalidate();
 
-    // Returns the region of the layer that is currently invalid.
-    WEBKIT_EXPORT WebFloatRect invalidRect() const;
-
 #if WEBKIT_IMPLEMENTATION
     WebContentLayer(const WTF::PassRefPtr<WebContentLayerImpl>&);
     WebContentLayer& operator=(const WTF::PassRefPtr<WebContentLayerImpl>&);

Modified: trunk/Source/WebKit/chromium/src/WebContentLayer.cpp (101622 => 101623)


--- trunk/Source/WebKit/chromium/src/WebContentLayer.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebKit/chromium/src/WebContentLayer.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -48,7 +48,7 @@
 
 void WebContentLayer::invalidateRect(const WebFloatRect& dirtyRect)
 {
-    unwrap<WebContentLayerImpl>()->setNeedsDisplay(dirtyRect);
+    unwrap<WebContentLayerImpl>()->setNeedsDisplayRect(dirtyRect);
 }
 
 void WebContentLayer::invalidate()
@@ -56,11 +56,6 @@
     unwrap<WebContentLayerImpl>()->setNeedsDisplay();
 }
 
-WebFloatRect WebContentLayer::invalidRect() const
-{
-    return WebFloatRect(constUnwrap<WebContentLayerImpl>()->dirtyRect());
-}
-
 WebContentLayer::WebContentLayer(const PassRefPtr<WebContentLayerImpl>& node)
     : WebLayer(node)
 {

Modified: trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp (101622 => 101623)


--- trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -148,7 +148,7 @@
     ASSERT(m_mediaPlayer);
 #if USE(ACCELERATED_COMPOSITING)
     if (m_videoLayer && supportsAcceleratedRendering())
-        m_videoLayer->setNeedsDisplay(IntRect(0, 0, m_videoLayer->bounds().width(), m_videoLayer->bounds().height()));
+        m_videoLayer->setNeedsDisplayRect(IntRect(0, 0, m_videoLayer->bounds().width(), m_videoLayer->bounds().height()));
 #endif
     m_mediaPlayer->repaint();
 }

Modified: trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp (101622 => 101623)


--- trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp	2011-12-01 07:38:49 UTC (rev 101622)
+++ trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp	2011-12-01 07:40:05 UTC (rev 101623)
@@ -532,7 +532,7 @@
 TEST_F(LayerChromiumTest, checkSetNeedsDisplayCausesCorrectBehavior)
 {
     // The semantics for setNeedsDisplay which are tested here:
-    //   1. creates a unioned dirtyRect appropriately.
+    //   1. sets needsDisplay flag appropriately.
     //   2. indirectly calls notifySyncRequired, exactly once for each call to setNeedsDisplay.
 
     MockLayerDelegate mockDelegate;
@@ -544,40 +544,45 @@
     FloatRect emptyDirtyRect = FloatRect(40.0f, 45.0f, 0, 0);
     FloatRect outOfBoundsDirtyRect = FloatRect(400.0f, 405.0f, 500.0f, 502.0f);
 
-    // Before anything, testLayer should have an empty dirty rect.
-    EXPECT_TRUE(testLayer->dirtyRect().isEmpty());
+    // Before anything, testLayer should not be dirty.
+    EXPECT_FALSE(testLayer->needsDisplay());
 
     // This is just initialization, but notifySyncRequired behavior is verified anyway to avoid warnings.
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
-    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->resetNeedsDisplay());
-    EXPECT_TRUE(testLayer->dirtyRect().isEmpty());
+    testLayer = LayerChromium::create(&mockDelegate);
+    EXPECT_FALSE(testLayer->needsDisplay());
 
     // The real test begins here.
 
-    // Case 1: basic
-    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay(dirty1));
-    EXPECT_FLOAT_RECT_EQ(dirty1, testLayer->dirtyRect());
+    // Case 1: needsDisplay flag should not change because of an empty dirty rect.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(emptyDirtyRect));
+    EXPECT_FALSE(testLayer->needsDisplay());
 
-    // Case 2: a second dirty rect should be unioned of dirty1 and dirty2.
-    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay(dirty2));
-    EXPECT_FLOAT_RECT_EQ(FloatRect(10.0f, 15.0f, 13.0f, 14.0f), testLayer->dirtyRect());
+    // Case 2: basic.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(dirty1));
+    EXPECT_TRUE(testLayer->needsDisplay());
 
-    // Case 3: dirty rect should not change because of an empty dirty rect.
-    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay(emptyDirtyRect));
-    EXPECT_FLOAT_RECT_EQ(FloatRect(10.0f, 15.0f, 13.0f, 14.0f), testLayer->dirtyRect());
+    // Case 3: a second dirty rect.
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(dirty2));
+    EXPECT_TRUE(testLayer->needsDisplay());
 
-    // Case 4: LayerChromium should accept dirty rects that go beyond its bounds
-    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay(outOfBoundsDirtyRect));
-    EXPECT_FLOAT_RECT_EQ(FloatRect(10.0f, 15.0f, 890.0f, 892.0f), testLayer->dirtyRect());
+    // Case 4: LayerChromium should accept dirty rects that go beyond its bounds.
+    testLayer = LayerChromium::create(&mockDelegate);
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(outOfBoundsDirtyRect));
+    EXPECT_TRUE(testLayer->needsDisplay());
 
-    // Case 5: setNeedsDisplay() without the dirty rect arg should cause the entire bounds to be dirty,
-    //         overriding any existing dirty rect.
+    // Case 5: setNeedsDisplay() without the dirty rect arg.
+    testLayer = LayerChromium::create(&mockDelegate);
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay());
-    EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, testBounds.width(), testBounds.height()), testLayer->dirtyRect());
+    EXPECT_TRUE(testLayer->needsDisplay());
 
-    // resetNeedsDisplay should empty the dirty rect, and NOT call notifySyncRequired.
-    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->resetNeedsDisplay());
-    EXPECT_TRUE(testLayer->dirtyRect().isEmpty());
+    // Case 6: setNeedsDisplay() without the dirty rect arg should not cause
+    // needsDisplay flag to change for LayerChromium with empty bounds.
+    testLayer = LayerChromium::create(&mockDelegate);
+    EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay());
+    EXPECT_FALSE(testLayer->needsDisplay());
 }
 
 TEST_F(LayerChromiumTest, checkSetNeedsDisplayWithNullDelegate)
@@ -590,13 +595,13 @@
     FloatRect dirty = FloatRect(10.0f, 15.0f, 1.0f, 2.0f);
 
     testLayer->setBounds(testBounds);
-    EXPECT_FLOAT_RECT_EQ(FloatRect(0.0f, 0.0f, 501.0f, 508.0f), testLayer->dirtyRect());
+    EXPECT_TRUE(testLayer->needsDisplay());
 
-    testLayer->resetNeedsDisplay();
-    EXPECT_TRUE(testLayer->dirtyRect().isEmpty());
+    testLayer = LayerChromium::create(0);
+    EXPECT_FALSE(testLayer->needsDisplay());
 
-    testLayer->setNeedsDisplay(dirty);
-    EXPECT_FLOAT_RECT_EQ(dirty, testLayer->dirtyRect());
+    testLayer->setNeedsDisplayRect(dirty);
+    EXPECT_TRUE(testLayer->needsDisplay());
 }
 
 TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior)
@@ -607,10 +612,10 @@
     RefPtr<LayerChromium> dummyLayer = LayerChromium::create(&m_silentDelegate); // just a dummy layer for this test case.
 
     // sanity check of initial test condition
-    EXPECT_TRUE(testLayer->dirtyRect().isEmpty());
+    EXPECT_FALSE(testLayer->needsDisplay());
 
     // Test properties that should not call needsDisplay and needsCommit when changed.
-    // notifySyncRequired should not be called, and the dirtyRect should remain still empty.
+    // notifySyncRequired should not be called, and the needsDisplay flag should remain false.
     EXPECT_CALL(initialDelegate, notifySyncRequired()).Times(0); // old delegate should not be used when setDelegate gives a new delegate.
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDelegate(&mockDelegate));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setName("Test Layer"));
@@ -625,10 +630,10 @@
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawTransform(TransformationMatrix()));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setScreenSpaceTransform(TransformationMatrix()));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawableContentRect(IntRect(4, 5, 6, 7)));
-    EXPECT_TRUE(testLayer->dirtyRect().isEmpty());
+    EXPECT_FALSE(testLayer->needsDisplay());
 
     // Next, test properties that should call setNeedsCommit (but not setNeedsDisplay)
-    // These properties should indirectly call notifySyncRequired, but the dirty rect should not change.
+    // These properties should indirectly call notifySyncRequired, but the needsDisplay flag should not change.
     // Note that for many of these properties it is important to test setting the property to a value that
     // is different than what the constructor initializes it to.
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setAnchorPoint(FloatPoint(1.23f, 4.56f)));
@@ -644,15 +649,13 @@
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setTransform(TransformationMatrix()));
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setDoubleSided(false));
 
-    // The above tests should not have caused a non-empty dirty rect.
-    EXPECT_TRUE(testLayer->dirtyRect().isEmpty());
+    // The above tests should not have caused a change to the needsDisplay flag.
+    EXPECT_FALSE(testLayer->needsDisplay());
 
     // Test properties that should call setNeedsDisplay
-    // These properties will call notifySyncRequired and change the dirty rect.
+    // These properties will call notifySyncRequired and change the needsDisplay flag.
     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(IntSize(5, 10)));
-    EXPECT_FLOAT_RECT_EQ(FloatRect(0.0f, 0.0f, 5.0f, 10.0f), testLayer->dirtyRect());
-    testLayer->resetNeedsDisplay();
-    EXPECT_TRUE(testLayer->dirtyRect().isEmpty());
+    EXPECT_TRUE(testLayer->needsDisplay());
 
     // FIXME: need to add a test for setLayerTreeHost with a non-null stubbed CCLayerTreeHost.
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to