2011-04-11 Vangelis Kokkevis <vangelis@chromium.org>
authorvangelis@chromium.org <vangelis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2011 06:03:51 +0000 (06:03 +0000)
committervangelis@chromium.org <vangelis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2011 06:03:51 +0000 (06:03 +0000)
        Reviewed by James Robinson.

        Adding a test which verifies that compositing image layers
        update correctly when their contents change.
        https://bugs.webkit.org/show_bug.cgi?id=58181

        * compositing/images/content-image-change-expected.txt: Added.
        * compositing/images/content-image-change.html: Added.
        * platform/chromium/test_expectations.txt:
        * platform/mac/compositing/images/content-image-change-expected.checksum: Added.
        * platform/mac/compositing/images/content-image-change-expected.png: Added.
2011-04-11  Vangelis Kokkevis  <vangelis@chromium.org>

        Reviewed by James Robinson.

        [chromium] Properly invalidate the contents of ImageLayerChromium's
        when the actual image contents change.
        https://bugs.webkit.org/show_bug.cgi?id=58181

        Test: compositing/images/content-image-change.html

        * platform/graphics/chromium/ContentLayerChromium.cpp:
        (WebCore::ContentLayerChromium::updateTexture):
        * platform/graphics/chromium/ImageLayerChromium.cpp:
        (WebCore::ImageLayerChromium::ImageLayerChromium):
        (WebCore::ImageLayerChromium::setContents):
        (WebCore::ImageLayerChromium::paintContentsIfDirty):
        * platform/graphics/chromium/ImageLayerChromium.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83558 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/compositing/images/content-image-change-expected.txt [new file with mode: 0644]
LayoutTests/compositing/images/content-image-change.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/compositing/images/content-image-change-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/compositing/images/content-image-change-expected.png [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h

index a3dc912..47abaa5 100644 (file)
@@ -1,3 +1,17 @@
+2011-04-11  Vangelis Kokkevis  <vangelis@chromium.org>
+
+        Reviewed by James Robinson.
+
+        Adding a test which verifies that compositing image layers
+        update correctly when their contents change.
+        https://bugs.webkit.org/show_bug.cgi?id=58181
+
+        * compositing/images/content-image-change-expected.txt: Added.
+        * compositing/images/content-image-change.html: Added.
+        * platform/chromium/test_expectations.txt:
+        * platform/mac/compositing/images/content-image-change-expected.checksum: Added.
+        * platform/mac/compositing/images/content-image-change-expected.png: Added.
+
 2011-04-11  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/LayoutTests/compositing/images/content-image-change-expected.txt b/LayoutTests/compositing/images/content-image-change-expected.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/LayoutTests/compositing/images/content-image-change.html b/LayoutTests/compositing/images/content-image-change.html
new file mode 100644 (file)
index 0000000..9c796e7
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE>
+<html>
+<head>
+<title>Image layer content change</title>
+
+<style type="text/css" media="screen">
+    #image {
+        width: 200px;
+        height: 200px;
+        -webkit-transform: translateZ(0);
+    }
+</style>
+<script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController) {
+        layoutTestController.waitUntilDone();
+        layoutTestController.dumpAsText(true);
+    }
+    function doTest()
+    {
+        var image = document.getElementById("image");
+
+        window.setTimeout(function() {
+            // Change the contents to green.
+            image.src =  "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADElEQVR4nGNg+M8AAAICAQB7CYF4AAAAAElFTkSuQmCC"
+            if (window.layoutTestController) {
+                window.setTimeout(function() {
+                    layoutTestController.notifyDone();
+                }, 0);
+            }
+        }, 0);
+    }
+
+    window.addEventListener('load', doTest, false);
+</script>
+</head>
+<body>
+<!-- When the test is done, there should only be a green square on the page -->
+
+<!-- Start with a red image -->
+<img id="image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC" />
+
+</body>
+</html>
index 8942710..d9c37a3 100644 (file)
@@ -2854,6 +2854,9 @@ WONTFIX GPU MAC LEOPARD : compositing = IMAGE PASS
 WONTFIX GPU MAC LEOPARD : platform/chromium/compositing = IMAGE PASS
 WONTFIX GPU MAC LEOPARD : media = IMAGE PASS
 
+// Will need windows and linux baselines
+BUGWK58182 GPU : compositing/images/content-image-change.html = PASS FAIL
+
 // The picture does not match the video in the test.
 BUGWK55519 GPU WIN LINUX : compositing/video/video-background-color.html = IMAGE+TEXT
 BUGWK55519 GPU MAC : compositing/video/video-background-color.html = IMAGE
diff --git a/LayoutTests/platform/mac/compositing/images/content-image-change-expected.checksum b/LayoutTests/platform/mac/compositing/images/content-image-change-expected.checksum
new file mode 100644 (file)
index 0000000..81ecf81
--- /dev/null
@@ -0,0 +1 @@
+109e6fe93cf270312fe30f132e38e950
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/compositing/images/content-image-change-expected.png b/LayoutTests/platform/mac/compositing/images/content-image-change-expected.png
new file mode 100644 (file)
index 0000000..99685fb
Binary files /dev/null and b/LayoutTests/platform/mac/compositing/images/content-image-change-expected.png differ
index 44c54e6..1947660 100644 (file)
@@ -1,3 +1,21 @@
+2011-04-11  Vangelis Kokkevis  <vangelis@chromium.org>
+
+        Reviewed by James Robinson.
+
+        [chromium] Properly invalidate the contents of ImageLayerChromium's
+        when the actual image contents change.
+        https://bugs.webkit.org/show_bug.cgi?id=58181
+
+        Test: compositing/images/content-image-change.html
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::updateTexture):
+        * platform/graphics/chromium/ImageLayerChromium.cpp:
+        (WebCore::ImageLayerChromium::ImageLayerChromium):
+        (WebCore::ImageLayerChromium::setContents):
+        (WebCore::ImageLayerChromium::paintContentsIfDirty):
+        * platform/graphics/chromium/ImageLayerChromium.h:
+
 2011-04-11  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dan Bernstein.
index 4ea9c92..b9bfc60 100644 (file)
@@ -192,6 +192,9 @@ void ContentLayerChromium::updateTexture(const uint8_t* pixels, const IntSize& s
     if (!m_contentsTexture->isValid(size, GraphicsContext3D::RGBA))
         m_uploadUpdateRect = IntRect(IntPoint(0, 0), size);
 
+    if (m_uploadUpdateRect.isEmpty())
+        return;
+
     if (!m_contentsTexture->reserve(size, GraphicsContext3D::RGBA)) {
         m_skipsDraw = true;
         return;
index 60c1332..81053e4 100644 (file)
@@ -47,16 +47,23 @@ PassRefPtr<ImageLayerChromium> ImageLayerChromium::create(GraphicsLayerChromium*
 
 ImageLayerChromium::ImageLayerChromium(GraphicsLayerChromium* owner)
     : ContentLayerChromium(owner)
+    , m_imageForCurrentFrame(0)
     , m_contents(0)
 {
 }
 
 void ImageLayerChromium::setContents(Image* contents)
 {
-    // Check if the image has changed.
-    if (m_contents == contents)
+    // setContents() currently gets called whenever there is any
+    // style change that affects the layer even if that change doesn't
+    // affect the actual contents of the image (e.g. a CSS animation).
+    // With this check in place we avoid unecessary texture uploads.
+    if ((m_contents == contents) && (m_contents->nativeImageForCurrentFrame() == m_imageForCurrentFrame))
         return;
+
     m_contents = contents;
+    m_imageForCurrentFrame = m_contents->nativeImageForCurrentFrame();
+    m_dirtyRect = IntRect(IntPoint(0, 0), bounds());
     setNeedsDisplay();
 }
 
@@ -72,7 +79,10 @@ void ImageLayerChromium::paintContentsIfDirty()
         return;
     }
 
-    m_decodedImage.updateFromImage(m_contents->nativeImageForCurrentFrame());
+    if (!m_dirtyRect.isEmpty()) {
+        m_decodedImage.updateFromImage(m_contents->nativeImageForCurrentFrame());
+        m_uploadUpdateRect = IntRect(IntPoint(0, 0), m_decodedImage.size());
+    }
 }
 
 void ImageLayerChromium::updateTextureIfNeeded()
index 6addabc..3b1f425 100644 (file)
@@ -64,6 +64,7 @@ private:
     ImageLayerChromium(GraphicsLayerChromium* owner);
 
     PlatformImage m_decodedImage;
+    NativeImagePtr m_imageForCurrentFrame;
     RefPtr<Image> m_contents;
 };