[chromium] Improved composited debug borders
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2012 21:45:58 +0000 (21:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2012 21:45:58 +0000 (21:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82071

Patch by Dana Jansens <danakj@chromium.org> on 2012-03-23
Reviewed by Adrienne Walker.

Fix the problem with missing debug borders. Since we append quads
to the list front to back now, we draw the quads in the list from
back to front of the list. Which means if the debug quad is added
after the layer it is drawing around, the layer can draw over top
of its debug quad. Reverse the ordering when appending to fix it.

Make the border red around tiles that are checkerboarded. Missing
tiles in non-root layers are drawn clear, so this makes them more
visible.

Put a blue border around each render surface, and a purple border
on their replicas.

No new tests.

* platform/graphics/chromium/cc/CCRenderPass.cpp:
(WebCore):
(WebCore::CCRenderPass::appendQuadsForLayer):
(WebCore::CCRenderPass::appendQuadsForRenderSurfaceLayer):
* platform/graphics/chromium/cc/CCRenderSurface.cpp:
(WebCore::CCRenderSurface::hasReplica):
(WebCore):
(WebCore::CCRenderSurface::createReplicaSharedQuadState):
* platform/graphics/chromium/cc/CCRenderSurface.h:
(CCRenderSurface):
* platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
(WebCore):
(WebCore::CCTiledLayerImpl::appendQuads):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp
Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp
Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h
Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp

index 4acd3fc0d18cd3fa9b4ae11f3f71b61e643bfd8e..3cf940b64e4fbf99e1d77da783a7f34f30674217 100644 (file)
@@ -1,3 +1,39 @@
+2012-03-23  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Improved composited debug borders
+        https://bugs.webkit.org/show_bug.cgi?id=82071
+
+        Reviewed by Adrienne Walker.
+
+        Fix the problem with missing debug borders. Since we append quads
+        to the list front to back now, we draw the quads in the list from
+        back to front of the list. Which means if the debug quad is added
+        after the layer it is drawing around, the layer can draw over top
+        of its debug quad. Reverse the ordering when appending to fix it.
+
+        Make the border red around tiles that are checkerboarded. Missing
+        tiles in non-root layers are drawn clear, so this makes them more
+        visible.
+
+        Put a blue border around each render surface, and a purple border
+        on their replicas.
+
+        No new tests.
+
+        * platform/graphics/chromium/cc/CCRenderPass.cpp:
+        (WebCore):
+        (WebCore::CCRenderPass::appendQuadsForLayer):
+        (WebCore::CCRenderPass::appendQuadsForRenderSurfaceLayer):
+        * platform/graphics/chromium/cc/CCRenderSurface.cpp:
+        (WebCore::CCRenderSurface::hasReplica):
+        (WebCore):
+        (WebCore::CCRenderSurface::createReplicaSharedQuadState):
+        * platform/graphics/chromium/cc/CCRenderSurface.h:
+        (CCRenderSurface):
+        * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
+        (WebCore):
+        (WebCore::CCTiledLayerImpl::appendQuads):
+
 2012-03-23  Simon Fraser  <simon.fraser@apple.com>
 
         Move code that calls setAcceleratesDrawing() on GraphicsLayers into RenderLayerBacking
index cf47b6cb87a43760210307dcdf9069071e4a4e0c..1704a616d5b3134c9ac9a8461da8a4db2ff10eb7 100644 (file)
@@ -28,6 +28,7 @@
 #include "cc/CCRenderPass.h"
 
 #include "cc/CCDamageTracker.h"
+#include "cc/CCDebugBorderDrawQuad.h"
 #include "cc/CCLayerImpl.h"
 #include "cc/CCQuadCuller.h"
 #include "cc/CCRenderSurfaceDrawQuad.h"
 
 namespace WebCore {
 
+static const int debugSurfaceBorderWidth = 2;
+static const int debugSurfaceBorderAlpha = 100;
+static const int debugSurfaceBorderColorRed = 0;
+static const int debugSurfaceBorderColorGreen = 0;
+static const int debugSurfaceBorderColorBlue = 255;
+static const int debugReplicaBorderColorRed = 160;
+static const int debugReplicaBorderColorGreen = 0;
+static const int debugReplicaBorderColorBlue = 255;
+
 PassOwnPtr<CCRenderPass> CCRenderPass::create(CCRenderSurface* targetSurface)
 {
     return adoptPtr(new CCRenderPass(targetSurface));
@@ -51,8 +61,8 @@ void CCRenderPass::appendQuadsForLayer(CCLayerImpl* layer, CCOcclusionTrackerImp
     CCQuadCuller quadCuller(m_quadList, layer, occlusionTracker);
 
     OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState();
-    layer->appendQuads(quadCuller, sharedQuadState.get(), usedCheckerboard);
     layer->appendDebugBorderQuad(quadCuller, sharedQuadState.get());
+    layer->appendQuads(quadCuller, sharedQuadState.get(), usedCheckerboard);
     m_sharedQuadStateList.append(sharedQuadState.release());
 }
 
@@ -62,6 +72,18 @@ void CCRenderPass::appendQuadsForRenderSurfaceLayer(CCLayerImpl* layer)
     // not be handled specially here.
     CCRenderSurface* surface = layer->renderSurface();
     OwnPtr<CCSharedQuadState> sharedQuadState = surface->createSharedQuadState();
+
+    if (layer->hasDebugBorders()) {
+        Color color(debugSurfaceBorderColorRed, debugSurfaceBorderColorGreen, debugSurfaceBorderColorBlue, debugSurfaceBorderAlpha);
+        m_quadList.append(CCDebugBorderDrawQuad::create(sharedQuadState.get(), surface->contentRect(), color, debugSurfaceBorderWidth));
+        if (surface->hasReplica()) {
+            OwnPtr<CCSharedQuadState> sharedQuadState = surface->createReplicaSharedQuadState();
+            Color color(debugReplicaBorderColorRed, debugReplicaBorderColorGreen, debugReplicaBorderColorBlue, debugSurfaceBorderAlpha);
+            m_quadList.append(CCDebugBorderDrawQuad::create(sharedQuadState.get(), surface->contentRect(), color, debugSurfaceBorderWidth));
+            m_sharedQuadStateList.append(sharedQuadState.release());
+        }
+    }
+
     m_quadList.append(CCRenderSurfaceDrawQuad::create(sharedQuadState.get(), surface->contentRect(), layer, surfaceDamageRect()));
     m_sharedQuadStateList.append(sharedQuadState.release());
 }
index 363b5e80e92f129998800ec0750baca12dbad354..4288bcbb16bbf472ede16642306e97be179a445f 100644 (file)
@@ -268,6 +268,11 @@ int CCRenderSurface::owningLayerId() const
     return m_owningLayer ? m_owningLayer->id() : 0;
 }
 
+bool CCRenderSurface::hasReplica()
+{
+    return m_owningLayer->replicaLayer();
+}
+
 void CCRenderSurface::setClipRect(const IntRect& clipRect)
 {
     if (m_clipRect == clipRect)
@@ -311,5 +316,11 @@ PassOwnPtr<CCSharedQuadState> CCRenderSurface::createSharedQuadState() const
     return CCSharedQuadState::create(originTransform(), drawTransform(), contentRect(), clipRect(), drawOpacity(), isOpaque);
 }
 
+PassOwnPtr<CCSharedQuadState> CCRenderSurface::createReplicaSharedQuadState() const
+{
+    bool isOpaque = false;
+    return CCSharedQuadState::create(replicaOriginTransform(), replicaDrawTransform(), contentRect(), clipRect(), drawOpacity(), isOpaque);
+}
+
 }
 #endif // USE(ACCELERATED_COMPOSITING)
index f26bd4e327cd1ebb11eb59da2a357ab88c2ae36e..9f714c5c0803a73f93a43a29f1cc05c07d193c8d 100644 (file)
@@ -126,6 +126,8 @@ public:
 
     int owningLayerId() const;
 
+    bool hasReplica();
+
     void resetPropertyChangedFlag() { m_surfacePropertyChanged = false; }
     bool surfacePropertyChanged() const;
     bool surfacePropertyChangedOnlyFromDescendant() const;
@@ -133,6 +135,7 @@ public:
     CCDamageTracker* damageTracker() const { return m_damageTracker.get(); }
 
     PassOwnPtr<CCSharedQuadState> createSharedQuadState() const;
+    PassOwnPtr<CCSharedQuadState> createReplicaSharedQuadState() const;
 
 private:
     void drawLayer(LayerRendererChromium*, CCLayerImpl*, const TransformationMatrix&, const SkBitmap& filterBitmap);
index 3f7b0b3ac219a760775a5ebf0018dfd894237779..560e33af2c7e3101fec6f478561a9b2cb1928f34 100644 (file)
@@ -42,6 +42,12 @@ namespace WebCore {
 
 static const int debugTileBorderWidth = 1;
 static const int debugTileBorderAlpha = 100;
+static const int debugTileBorderColorRed = 80;
+static const int debugTileBorderColorGreen = 200;
+static const int debugTileBorderColorBlue = 200;
+static const int debugTileBorderMissingTileColorRed = 255;
+static const int debugTileBorderMissingTileColorGreen = 0;
+static const int debugTileBorderMissingTileColorBlue = 0;
 
 class ManagedTexture;
 
@@ -137,6 +143,23 @@ void CCTiledLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadSta
 
     int left, top, right, bottom;
     m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
+
+    if (hasDebugBorders()) {
+        for (int j = top; j <= bottom; ++j) {
+            for (int i = left; i <= right; ++i) {
+                DrawableTile* tile = tileAt(i, j);
+                IntRect tileRect = m_tiler->tileBounds(i, j);
+                Color borderColor;
+
+                if (!tile || !tile->textureId())
+                    borderColor = Color(debugTileBorderMissingTileColorRed, debugTileBorderMissingTileColorGreen, debugTileBorderMissingTileColorBlue, debugTileBorderAlpha);
+                else
+                    borderColor = Color(debugTileBorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue, debugTileBorderAlpha);
+                quadList.append(CCDebugBorderDrawQuad::create(sharedQuadState, tileRect, borderColor, debugTileBorderWidth));
+            }
+        }
+    }
+
     for (int j = top; j <= bottom; ++j) {
         for (int i = left; i <= right; ++i) {
             DrawableTile* tile = tileAt(i, j);
@@ -173,11 +196,6 @@ void CCTiledLayerImpl::appendQuads(CCQuadCuller& quadList, const CCSharedQuadSta
 
             const GC3Dint textureFilter = m_tiler->hasBorderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST;
             quadList.append(CCTileDrawQuad::create(sharedQuadState, tileRect, tileOpaqueRect, tile->textureId(), textureOffset, textureSize, textureFilter, contentsSwizzled(), leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA));
-
-            if (hasDebugBorders()) {
-                Color color(debugBorderColor().red(), debugBorderColor().green(), debugBorderColor().blue(), debugTileBorderAlpha);
-                quadList.append(CCDebugBorderDrawQuad::create(sharedQuadState, tileRect, color, debugTileBorderWidth));
-            }
         }
     }
 }