Title: [99295] trunk/Source
Revision
99295
Author
[email protected]
Date
2011-11-04 10:45:28 -0700 (Fri, 04 Nov 2011)

Log Message

[chromium] Implement checkerboarding for missing layer tiles
https://bugs.webkit.org/show_bug.cgi?id=69585

Reviewed by James Robinson.

Source/WebCore:

For tiles that have no texture or haven't even been created yet,
draw using the background color of the layer.

The only background color set is currently the non-composited content,
and all other layers use transparent black by default.

* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::pushPropertiesTo):
* platform/graphics/chromium/NonCompositedContentHost.cpp:
(WebCore::NonCompositedContentHost::setBackgroundColor):
* platform/graphics/chromium/NonCompositedContentHost.h:
* platform/graphics/chromium/cc/CCLayerImpl.cpp:
(WebCore::CCLayerImpl::setBackgroundColor):
* platform/graphics/chromium/cc/CCLayerImpl.h:
(WebCore::CCLayerImpl::backgroundColor):
* platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
(WebCore::CCTiledLayerImpl::drawTiles):

Source/WebKit/chromium:

To pipe the background color of the document to the non-composited
host, set it during paint. This may be more frequent than necessary,
but it'll catch all style changes.

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::nonCompositedContentHost):
(WebKit::WebViewImplContentPainter::paint):
* src/WebViewImpl.h:
* tests/CCLayerImplTest.cpp:
(WebCore::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (99294 => 99295)


--- trunk/Source/WebCore/ChangeLog	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebCore/ChangeLog	2011-11-04 17:45:28 UTC (rev 99295)
@@ -1,3 +1,28 @@
+2011-11-03  Adrienne Walker  <[email protected]>
+
+        [chromium] Implement checkerboarding for missing layer tiles
+        https://bugs.webkit.org/show_bug.cgi?id=69585
+
+        Reviewed by James Robinson.
+
+        For tiles that have no texture or haven't even been created yet,
+        draw using the background color of the layer.
+
+        The only background color set is currently the non-composited content,
+        and all other layers use transparent black by default.
+
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::pushPropertiesTo):
+        * platform/graphics/chromium/NonCompositedContentHost.cpp:
+        (WebCore::NonCompositedContentHost::setBackgroundColor):
+        * platform/graphics/chromium/NonCompositedContentHost.h:
+        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
+        (WebCore::CCLayerImpl::setBackgroundColor):
+        * platform/graphics/chromium/cc/CCLayerImpl.h:
+        (WebCore::CCLayerImpl::backgroundColor):
+        * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
+        (WebCore::CCTiledLayerImpl::drawTiles):
+
 2011-11-04  Nico Weber  <[email protected]>
 
         [chromium] Remove most exit time destructors

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


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2011-11-04 17:45:28 UTC (rev 99295)
@@ -278,6 +278,7 @@
 {
     layer->setAnchorPoint(m_anchorPoint);
     layer->setAnchorPointZ(m_anchorPointZ);
+    layer->setBackgroundColor(m_backgroundColor);
     layer->setBounds(m_bounds);
     layer->setContentBounds(contentBounds());
     layer->setDebugBorderColor(m_debugBorderColor);

Modified: trunk/Source/WebCore/platform/graphics/chromium/NonCompositedContentHost.cpp (99294 => 99295)


--- trunk/Source/WebCore/platform/graphics/chromium/NonCompositedContentHost.cpp	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebCore/platform/graphics/chromium/NonCompositedContentHost.cpp	2011-11-04 17:45:28 UTC (rev 99295)
@@ -49,6 +49,14 @@
 {
 }
 
+void NonCompositedContentHost::setBackgroundColor(const Color& color)
+{
+    if (color.isValid())
+        m_graphicsLayer->platformLayer()->setBackgroundColor(color);
+    else
+        m_graphicsLayer->platformLayer()->setBackgroundColor(Color::white);
+}
+
 void NonCompositedContentHost::setScrollLayer(GraphicsLayer* layer)
 {
     m_graphicsLayer->setNeedsDisplay();

Modified: trunk/Source/WebCore/platform/graphics/chromium/NonCompositedContentHost.h (99294 => 99295)


--- trunk/Source/WebCore/platform/graphics/chromium/NonCompositedContentHost.h	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebCore/platform/graphics/chromium/NonCompositedContentHost.h	2011-11-04 17:45:28 UTC (rev 99295)
@@ -35,6 +35,7 @@
 
 namespace WebCore {
 
+class Color;
 class GraphicsLayer;
 class GraphicsContext;
 class IntPoint;
@@ -52,6 +53,7 @@
     virtual ~NonCompositedContentHost();
 
     void invalidateRect(const IntRect&);
+    void setBackgroundColor(const Color&);
     void setScrollLayer(GraphicsLayer*);
     void setViewport(const IntSize& viewportSize, const IntSize& contentsSize, const IntPoint& scrollPosition);
     void protectVisibleTileTextures();

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp (99294 => 99295)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp	2011-11-04 17:45:28 UTC (rev 99295)
@@ -289,6 +289,14 @@
     }
 }
 
+void CCLayerImpl::setBackgroundColor(const Color& backgroundColor)
+{
+    if (m_backgroundColor != backgroundColor) {
+        m_backgroundColor = backgroundColor;
+        m_layerPropertyChanged = true;
+    }
+}
+
 void CCLayerImpl::setMasksToBounds(bool masksToBounds)
 {
     if (m_masksToBounds != masksToBounds) {

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h (99294 => 99295)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h	2011-11-04 17:45:28 UTC (rev 99295)
@@ -89,6 +89,9 @@
     void setAnchorPointZ(float);
     float anchorPointZ() const { return m_anchorPointZ; }
 
+    void setBackgroundColor(const Color&);
+    Color backgroundColor() const { return m_backgroundColor; }
+
     void setMasksToBounds(bool);
     bool masksToBounds() const { return m_masksToBounds; }
 
@@ -214,6 +217,7 @@
     IntSize m_contentBounds;
     IntPoint m_scrollPosition;
     IntSize m_maxScrollPosition;
+    Color m_backgroundColor;
 
     // Whether the "back" of this layer should draw.
     bool m_doubleSided;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp (99294 => 99295)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp	2011-11-04 17:45:28 UTC (rev 99295)
@@ -241,14 +241,10 @@
 
         for (int i = left; i <= right; ++i) {
             DrawableTile* tile = tileAt(i, j);
-            if (!tile || !tile->textureId())
-                continue;
 
-            context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId());
-
             // Don't use tileContentRect here, as that contains the full
             // rect with border texels which shouldn't be drawn.
-            IntRect tileRect = m_tiler->tileBounds(tile->i(), tile->j());
+            IntRect tileRect = m_tiler->tileBounds(i, j);
             IntRect displayRect = tileRect;
             tileRect.intersect(layerRect);
 
@@ -276,7 +272,7 @@
             clampRect.inflateY(-clampY);
             FloatSize clampOffset = clampRect.minXMinYCorner() - FloatRect(tileRect).minXMinYCorner();
 
-            FloatPoint texOffset = m_tiler->textureOffset(tile->i(), tile->j()) + clampOffset + FloatSize(displayOffset);
+            FloatPoint texOffset = m_tiler->textureOffset(i, j) + clampOffset + FloatSize(displayOffset);
             float tileWidth = static_cast<float>(m_tiler->tileSize().width());
             float tileHeight = static_cast<float>(m_tiler->tileSize().height());
 
@@ -339,12 +335,30 @@
 
             GLC(context, context->uniform4f(program->vertexShader().vertexTexTransformLocation(), vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY));
 
-            layerRenderer->drawTexturedQuad(globalTransform,
-                                            tileRect.width(), tileRect.height(), opacity, quad,
-                                            program->vertexShader().matrixLocation(),
-                                            program->fragmentShader().alphaLocation(),
-                                            program->vertexShader().pointLocation());
+            if (tile && tile->textureId()) {
+                context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId());
+                layerRenderer->drawTexturedQuad(globalTransform,
+                                                tileRect.width(), tileRect.height(), opacity, quad,
+                                                program->vertexShader().matrixLocation(),
+                                                program->fragmentShader().alphaLocation(),
+                                                program->vertexShader().pointLocation());
+            } else {
+                TransformationMatrix tileTransform = globalTransform;
+                tileTransform.translate(tileRect.x() + tileRect.width() / 2.0, tileRect.y() + tileRect.height() / 2.0);
 
+                const LayerChromium::BorderProgram* solidColorProgram = layerRenderer->borderProgram();
+                GLC(context, context->useProgram(solidColorProgram->program()));
+
+                GLC(context, context->uniform4f(solidColorProgram->fragmentShader().colorLocation(), backgroundColor().red(), backgroundColor().green(), backgroundColor().blue(), backgroundColor().alpha()));
+
+                layerRenderer->drawTexturedQuad(tileTransform,
+                                                tileRect.width(), tileRect.height(), opacity, quad,
+                                                program->vertexShader().matrixLocation(),
+                                                -1, -1);
+
+                GLC(context, context->useProgram(program->program()));
+            }
+
             prevEdgeX = edgeX;
             // Reverse direction.
             prevEdgeX.scale(-1);

Modified: trunk/Source/WebKit/chromium/ChangeLog (99294 => 99295)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-11-04 17:45:28 UTC (rev 99295)
@@ -1,3 +1,21 @@
+2011-11-03  Adrienne Walker  <[email protected]>
+
+        [chromium] Implement checkerboarding for missing layer tiles
+        https://bugs.webkit.org/show_bug.cgi?id=69585
+
+        Reviewed by James Robinson.
+
+        To pipe the background color of the document to the non-composited
+        host, set it during paint. This may be more frequent than necessary,
+        but it'll catch all style changes.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::nonCompositedContentHost):
+        (WebKit::WebViewImplContentPainter::paint):
+        * src/WebViewImpl.h:
+        * tests/CCLayerImplTest.cpp:
+        (WebCore::TEST):
+
 2011-11-04  Fady Samuel  <[email protected]>
 
         [Chromium] Expose deviceScaleFactor to WebKit API

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (99294 => 99295)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-11-04 17:45:28 UTC (rev 99295)
@@ -2577,6 +2577,12 @@
     m_nonCompositedContentHost->invalidateRect(dirtyRect);
     setRootLayerNeedsDisplay();
 }
+
+WebCore::NonCompositedContentHost* WebViewImpl::nonCompositedContentHost()
+{
+    return m_nonCompositedContentHost.get();
+}
+
 #if ENABLE(REQUEST_ANIMATION_FRAME)
 void WebViewImpl::scheduleAnimation()
 {
@@ -2611,6 +2617,9 @@
         double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart);
         PlatformSupport::histogramCustomCounts("Renderer4.AccelRootPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
         PlatformSupport::histogramCustomCounts("Renderer4.AccelRootPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
+
+        m_webViewImpl->nonCompositedContentHost()->setBackgroundColor(view->documentBackgroundColor());
+
     }
 
 private:

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (99294 => 99295)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2011-11-04 17:45:28 UTC (rev 99295)
@@ -382,6 +382,7 @@
     void setRootLayerNeedsDisplay();
     void scrollRootLayerRect(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& clipRect);
     void invalidateRootLayerRect(const WebCore::IntRect&);
+    WebCore::NonCompositedContentHost* nonCompositedContentHost();
 #endif
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     void scheduleAnimation();

Modified: trunk/Source/WebKit/chromium/tests/CCLayerImplTest.cpp (99294 => 99295)


--- trunk/Source/WebKit/chromium/tests/CCLayerImplTest.cpp	2011-11-04 17:41:15 UTC (rev 99294)
+++ trunk/Source/WebKit/chromium/tests/CCLayerImplTest.cpp	2011-11-04 17:45:28 UTC (rev 99295)
@@ -116,6 +116,7 @@
     EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setDebugBorderColor(arbitraryColor));
     EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setDebugBorderWidth(arbitraryNumber));
     EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setDrawsContent(true));
+    EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setBackgroundColor(Color::gray));
 
     // Special case: check that sublayer transform changes all layer's descendants, but not the layer itself.
     root->resetLayerPropertyChanged();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to