[chromium] Improved composited debug borders
[WebKit-https.git] / Source / WebCore / platform / graphics / chromium / cc / CCRenderPass.cpp
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());
 }