Title: [121361] trunk/Source/WebCore
Revision
121361
Author
[email protected]
Date
2012-06-27 13:31:27 -0700 (Wed, 27 Jun 2012)

Log Message

[chromium] Allow screen space rects and occluding rects to be visualized for debugging.
https://bugs.webkit.org/show_bug.cgi?id=90012

Patch by Ian Vollick <[email protected]> on 2012-06-27
Reviewed by Adrienne Walker.

No new tests. No new functionality.

* platform/graphics/chromium/cc/CCDebugRectHistory.cpp:
(WebCore::CCDebugRectHistory::enabled):
(WebCore::CCDebugRectHistory::saveDebugRectsForCurrentFrame):
(WebCore::CCDebugRectHistory::saveScreenSpaceRects):
(WebCore):
(WebCore::CCDebugRectHistory::saveOccludingRects):
* platform/graphics/chromium/cc/CCDebugRectHistory.h:
(WebCore):
(CCDebugRectHistory):
* platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
(WebCore::CCHeadsUpDisplay::showDebugRects):
(WebCore::CCHeadsUpDisplay::draw):
(WebCore::CCHeadsUpDisplay::drawDebugRects):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore::CCLayerTreeSettings::CCLayerTreeSettings):
(CCLayerTreeSettings):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
(WebCore::CCLayerTreeHostImpl::drawLayers):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(FrameData):
* platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
(WebCore::::CCOcclusionTrackerBase):
(WebCore::addOcclusionBehindLayer):
(WebCore::::markOccludedBehindLayer):
* platform/graphics/chromium/cc/CCOcclusionTracker.h:
(CCOcclusionTrackerBase):
(WebCore::CCOcclusionTrackerBase::setOccludingScreenSpaceRectsContainer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121360 => 121361)


--- trunk/Source/WebCore/ChangeLog	2012-06-27 20:22:32 UTC (rev 121360)
+++ trunk/Source/WebCore/ChangeLog	2012-06-27 20:31:27 UTC (rev 121361)
@@ -1,3 +1,41 @@
+2012-06-27  Ian Vollick  <[email protected]>
+
+        [chromium] Allow screen space rects and occluding rects to be visualized for debugging.
+        https://bugs.webkit.org/show_bug.cgi?id=90012
+
+        Reviewed by Adrienne Walker.
+
+        No new tests. No new functionality.
+
+        * platform/graphics/chromium/cc/CCDebugRectHistory.cpp:
+        (WebCore::CCDebugRectHistory::enabled):
+        (WebCore::CCDebugRectHistory::saveDebugRectsForCurrentFrame):
+        (WebCore::CCDebugRectHistory::saveScreenSpaceRects):
+        (WebCore):
+        (WebCore::CCDebugRectHistory::saveOccludingRects):
+        * platform/graphics/chromium/cc/CCDebugRectHistory.h:
+        (WebCore):
+        (CCDebugRectHistory):
+        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
+        (WebCore::CCHeadsUpDisplay::showDebugRects):
+        (WebCore::CCHeadsUpDisplay::draw):
+        (WebCore::CCHeadsUpDisplay::drawDebugRects):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore::CCLayerTreeSettings::CCLayerTreeSettings):
+        (CCLayerTreeSettings):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
+        (WebCore::CCLayerTreeHostImpl::drawLayers):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (FrameData):
+        * platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
+        (WebCore::::CCOcclusionTrackerBase):
+        (WebCore::addOcclusionBehindLayer):
+        (WebCore::::markOccludedBehindLayer):
+        * platform/graphics/chromium/cc/CCOcclusionTracker.h:
+        (CCOcclusionTrackerBase):
+        (WebCore::CCOcclusionTrackerBase::setOccludingScreenSpaceRectsContainer):
+
 2012-06-27  Anthony Scian  <[email protected]>
 
         Web Inspector [JSC]: Implement ScriptCallStack::stackTrace

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCDebugRectHistory.cpp (121360 => 121361)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCDebugRectHistory.cpp	2012-06-27 20:22:32 UTC (rev 121360)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCDebugRectHistory.cpp	2012-06-27 20:31:27 UTC (rev 121361)
@@ -40,10 +40,10 @@
 
 bool CCDebugRectHistory::enabled(const CCLayerTreeSettings& settings)
 {
-    return settings.showPaintRects || settings.showPropertyChangedRects || settings.showSurfaceDamageRects;
+    return settings.showPaintRects || settings.showPropertyChangedRects || settings.showSurfaceDamageRects || settings.showScreenSpaceRects || settings.showReplicaScreenSpaceRects || settings.showOccludingRects;
 }
 
-void CCDebugRectHistory::saveDebugRectsForCurrentFrame(CCLayerImpl* rootLayer, const Vector<CCLayerImpl*>& renderSurfaceLayerList, const CCLayerTreeSettings& settings)
+void CCDebugRectHistory::saveDebugRectsForCurrentFrame(CCLayerImpl* rootLayer, const Vector<CCLayerImpl*>& renderSurfaceLayerList, const Vector<IntRect>& occludingScreenSpaceRects, const CCLayerTreeSettings& settings)
 {
     // For now, clear all rects from previous frames. In the future we may want to store
     // all debug rects for a history of many frames.
@@ -57,6 +57,12 @@
 
     if (settings.showSurfaceDamageRects)
         saveSurfaceDamageRects(renderSurfaceLayerList);
+
+    if (settings.showScreenSpaceRects)
+        saveScreenSpaceRects(renderSurfaceLayerList);
+
+    if (settings.showOccludingRects)
+        saveOccludingRects(occludingScreenSpaceRects);
 }
 
 
@@ -104,6 +110,26 @@
     }
 }
 
+void CCDebugRectHistory::saveScreenSpaceRects(const Vector<CCLayerImpl* >& renderSurfaceLayerList)
+{
+    for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
+        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex];
+        CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface();
+        ASSERT(renderSurface);
+
+        m_debugRects.append(CCDebugRect(ScreenSpaceRectType, CCMathUtil::mapClippedRect(renderSurface->screenSpaceTransform(), renderSurface->contentRect())));
+
+        if (renderSurfaceLayer->replicaLayer())
+            m_debugRects.append(CCDebugRect(ReplicaScreenSpaceRectType, CCMathUtil::mapClippedRect(renderSurface->replicaScreenSpaceTransform(), renderSurface->contentRect())));
+    }
+}
+
+void CCDebugRectHistory::saveOccludingRects(const Vector<IntRect>& occludingRects)
+{
+    for (size_t i = 0; i < occludingRects.size(); ++i)
+        m_debugRects.append(CCDebugRect(OccludingRectType, occludingRects[i]));
+}
+
 } // namespace WebCore
 
 #endif // USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCDebugRectHistory.h (121360 => 121361)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCDebugRectHistory.h	2012-06-27 20:22:32 UTC (rev 121360)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCDebugRectHistory.h	2012-06-27 20:31:27 UTC (rev 121361)
@@ -28,6 +28,7 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include "FloatRect.h"
+#include "IntRect.h"
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/Vector.h>
@@ -37,7 +38,7 @@
 class CCLayerImpl;
 struct CCLayerTreeSettings;
 
-// There are currently three types of debug rects:
+// There are currently six types of debug rects:
 //
 // - Paint rects (update rects): regions of a layer that needed to be re-uploaded to the
 //   texture resource; in most cases implying that WebCore had to repaint them, too.
@@ -50,7 +51,13 @@
 //   layers and surfaces that contribute to it. This includes (1) paint rects, (2) property-
 //   changed rects, and (3) newly exposed areas.
 //
-enum DebugRectType { PaintRectType, PropertyChangedRectType, SurfaceDamageRectType };
+// - Screen space rects: this is the region the contents occupy in screen space.
+//
+// - Replica screen space rects: this is the region the replica's contents occupy in screen space.
+//
+// - Occluding rects: these are the regions that contribute to the occluded region.
+//
+enum DebugRectType { PaintRectType, PropertyChangedRectType, SurfaceDamageRectType, ScreenSpaceRectType, ReplicaScreenSpaceRectType, OccludingRectType };
 
 struct CCDebugRect {
     CCDebugRect(DebugRectType newType, FloatRect newRect)
@@ -75,7 +82,7 @@
     bool enabled(const CCLayerTreeSettings&);
 
     // Note: Saving debug rects must happen before layers' change tracking is reset.
-    void saveDebugRectsForCurrentFrame(CCLayerImpl* rootLayer, const Vector<CCLayerImpl*>& renderSurfaceLayerList, const CCLayerTreeSettings&);
+    void saveDebugRectsForCurrentFrame(CCLayerImpl* rootLayer, const Vector<CCLayerImpl*>& renderSurfaceLayerList, const Vector<IntRect>& occludingScreenSpaceRects, const CCLayerTreeSettings&);
 
     const Vector<CCDebugRect>& debugRects() { return m_debugRects; }
 
@@ -85,6 +92,8 @@
     void savePaintRects(CCLayerImpl*);
     void savePropertyChangedRects(const Vector<CCLayerImpl*>& renderSurfaceLayerList);
     void saveSurfaceDamageRects(const Vector<CCLayerImpl* >& renderSurfaceLayerList);
+    void saveScreenSpaceRects(const Vector<CCLayerImpl* >& renderSurfaceLayerList);
+    void saveOccludingRects(const Vector<IntRect>& occludingScreenSpaceRects);
 
     Vector<CCDebugRect> m_debugRects;
 };

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp (121360 => 121361)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp	2012-06-27 20:22:32 UTC (rev 121360)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp	2012-06-27 20:31:27 UTC (rev 121361)
@@ -63,7 +63,7 @@
 
 bool CCHeadsUpDisplay::showDebugRects(const CCLayerTreeSettings& settings) const
 {
-    return settings.showPaintRects || settings.showPropertyChangedRects || settings.showSurfaceDamageRects;
+    return settings.showPaintRects || settings.showPropertyChangedRects || settings.showSurfaceDamageRects || settings.showScreenSpaceRects || settings.showReplicaScreenSpaceRects || settings.showOccludingRects;
 }
 
 void CCHeadsUpDisplay::draw(CCLayerTreeHostImpl* layerTreeHostImpl)
@@ -81,8 +81,8 @@
     // Use a fullscreen texture only if we need to...
     IntSize hudSize;
     if (showPlatformLayerTree(settings) || showDebugRects(settings)) {
-        hudSize.setWidth(min(2048, layerTreeHostImpl->viewportSize().width()));
-        hudSize.setHeight(min(2048, layerTreeHostImpl->viewportSize().height()));
+        hudSize.setWidth(min(2048, layerTreeHostImpl->deviceViewportSize().width()));
+        hudSize.setHeight(min(2048, layerTreeHostImpl->deviceViewportSize().height()));
     } else {
         hudSize.setWidth(512);
         hudSize.setHeight(128);
@@ -244,6 +244,27 @@
             context->fillRect(debugRects[i].rect, Color(200, 100, 0, 30), ColorSpaceDeviceRGB);
             context->strokeRect(debugRects[i].rect, 2.0);
         }
+
+        if (debugRects[i].type == ReplicaScreenSpaceRectType) {
+            // Screen space rects in green.
+            context->setStrokeColor(Color(100, 200, 0, 255), ColorSpaceDeviceRGB);
+            context->fillRect(debugRects[i].rect, Color(100, 200, 0, 30), ColorSpaceDeviceRGB);
+            context->strokeRect(debugRects[i].rect, 2.0);
+        }
+
+        if (debugRects[i].type == ScreenSpaceRectType) {
+            // Screen space rects in purple.
+            context->setStrokeColor(Color(100, 0, 200, 255), ColorSpaceDeviceRGB);
+            context->fillRect(debugRects[i].rect, Color(100, 0, 200, 10), ColorSpaceDeviceRGB);
+            context->strokeRect(debugRects[i].rect, 2.0);
+        }
+
+        if (debugRects[i].type == OccludingRectType) {
+            // Occluding rects in a reddish color.
+            context->setStrokeColor(Color(200, 0, 100, 255), ColorSpaceDeviceRGB);
+            context->fillRect(debugRects[i].rect, Color(200, 0, 100, 10), ColorSpaceDeviceRGB);
+            context->strokeRect(debugRects[i].rect, 2.0);
+        }
     }
 }
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (121360 => 121361)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-06-27 20:22:32 UTC (rev 121360)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-06-27 20:31:27 UTC (rev 121361)
@@ -85,6 +85,9 @@
             , showPaintRects(false)
             , showPropertyChangedRects(false)
             , showSurfaceDamageRects(false)
+            , showScreenSpaceRects(false)
+            , showReplicaScreenSpaceRects(false)
+            , showOccludingRects(false)
             , refreshRate(0)
             , maxPartialTextureUpdates(std::numeric_limits<size_t>::max())
             , defaultTileSize(IntSize(256, 256))
@@ -98,6 +101,9 @@
     bool showPaintRects;
     bool showPropertyChangedRects;
     bool showSurfaceDamageRects;
+    bool showScreenSpaceRects;
+    bool showReplicaScreenSpaceRects;
+    bool showOccludingRects;
     double refreshRate;
     size_t maxPartialTextureUpdates;
     IntSize defaultTileSize;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (121360 => 121361)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-06-27 20:22:32 UTC (rev 121360)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-06-27 20:31:27 UTC (rev 121361)
@@ -294,6 +294,9 @@
     CCOcclusionTrackerImpl occlusionTracker(enclosingIntRect(m_rootScissorRect), recordMetricsForFrame);
     occlusionTracker.setMinimumTrackingSize(CCOcclusionTrackerImpl::preferredMinimumTrackingSize());
 
+    if (settings().showOccludingRects)
+        occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingScreenSpaceRects);
+
     // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk.
     typedef CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
 
@@ -512,7 +515,7 @@
     }
 
     if (m_debugRectHistory->enabled(settings()))
-        m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, settings());
+        m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, settings());
 
     if (m_headsUpDisplay->enabled(settings()))
         m_headsUpDisplay->draw(this);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (121360 => 121361)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-06-27 20:22:32 UTC (rev 121360)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-06-27 20:31:27 UTC (rev 121361)
@@ -82,6 +82,7 @@
     virtual void scheduleAnimation();
 
     struct FrameData {
+        Vector<IntRect> occludingScreenSpaceRects;
         CCRenderPassList renderPasses;
         CCRenderPassList skippedPasses;
         CCLayerList* renderSurfaceLayerList;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp (121360 => 121361)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp	2012-06-27 20:22:32 UTC (rev 121360)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp	2012-06-27 20:31:27 UTC (rev 121361)
@@ -45,6 +45,7 @@
 CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::CCOcclusionTrackerBase(IntRect scissorRectInScreenSpace, bool recordMetricsForFrame)
     : m_scissorRectInScreenSpace(scissorRectInScreenSpace)
     , m_overdrawMetrics(CCOverdrawMetrics::create(recordMetricsForFrame))
+    , m_occludingScreenSpaceRects(0)
 {
 }
 
@@ -307,7 +308,7 @@
 
 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling.
 template<typename LayerType>
-static inline void addOcclusionBehindLayer(Region& region, const LayerType* layer, const WebTransformationMatrix& transform, const Region& opaqueContents, const IntRect& scissorRect, const IntSize& minimumTrackingSize)
+static inline void addOcclusionBehindLayer(Region& region, const LayerType* layer, const WebTransformationMatrix& transform, const Region& opaqueContents, const IntRect& scissorRect, const IntSize& minimumTrackingSize, Vector<IntRect>* occludingScreenSpaceRects)
 {
     ASSERT(layer->visibleLayerRect().contains(opaqueContents.bounds()));
 
@@ -322,8 +323,11 @@
     for (size_t i = 0; i < contentRects.size(); ++i) {
         IntRect transformedRect = enclosedIntRect(transform.mapRect(FloatRect(contentRects[i])));
         transformedRect.intersect(scissorRect);
-        if (transformedRect.width() >= minimumTrackingSize.width() || transformedRect.height() >= minimumTrackingSize.height())
+        if (transformedRect.width() >= minimumTrackingSize.width() || transformedRect.height() >= minimumTrackingSize.height()) {
+            if (occludingScreenSpaceRects)
+                occludingScreenSpaceRects->append(transformedRect);
             region.unite(transformedRect);
+        }
     }
 }
 
@@ -347,7 +351,7 @@
 
     IntRect scissorInTarget = layerScissorRectInTargetSurface(layer);
     if (layerTransformsToTargetKnown(layer))
-        addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInTarget, layer, contentToTargetSurfaceTransform<LayerType>(layer), opaqueContents, scissorInTarget, m_minimumTrackingSize);
+        addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInTarget, layer, contentToTargetSurfaceTransform<LayerType>(layer), opaqueContents, scissorInTarget, m_minimumTrackingSize, 0);
 
     // We must clip the occlusion within the layer's scissorInTarget within screen space as well. If the scissor rect can't be moved to screen space and
     // remain rectilinear, then we don't add any occlusion in screen space.
@@ -360,7 +364,7 @@
         if (clipped || !scissorInScreenQuad.isRectilinear())
             return;
         IntRect scissorInScreenRect = intersection(m_scissorRectInScreenSpace, enclosedIntRect(scissorInScreenQuad.boundingBox()));
-        addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInScreen, layer, contentToScreenSpaceTransform<LayerType>(layer), opaqueContents, scissorInScreenRect, m_minimumTrackingSize);
+        addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInScreen, layer, contentToScreenSpaceTransform<LayerType>(layer), opaqueContents, scissorInScreenRect, m_minimumTrackingSize, m_occludingScreenSpaceRects);
     }
 }
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.h (121360 => 121361)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.h	2012-06-27 20:22:32 UTC (rev 121360)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.h	2012-06-27 20:31:27 UTC (rev 121361)
@@ -72,6 +72,9 @@
 
     static IntSize preferredMinimumTrackingSize() { return IntSize(160, 160); }
 
+    // The following is used for visualization purposes.
+    void setOccludingScreenSpaceRectsContainer(Vector<IntRect>* rects) { m_occludingScreenSpaceRects = rects; }
+
 protected:
     struct StackObject {
         StackObject() : surface(0) { }
@@ -111,6 +114,9 @@
     IntRect m_scissorRectInScreenSpace;
     OwnPtr<CCOverdrawMetrics> m_overdrawMetrics;
     IntSize m_minimumTrackingSize;
+
+    // This is used for visualizing the occlusion tracking process.
+    Vector<IntRect>* m_occludingScreenSpaceRects;
 };
 
 typedef CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium> CCOcclusionTracker;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to