diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-15 01:51:10 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-15 01:51:10 +0000 |
commit | 4d8804ea89be1e0877ca4afe2d577f903a28f574 (patch) | |
tree | bea4f83fe959f0d38b9713930d16a7b0f707e6b4 /cc | |
parent | 3dce37234c2bdbd6f5114eca99ef65bf661f6fb9 (diff) | |
download | chromium_src-4d8804ea89be1e0877ca4afe2d577f903a28f574.zip chromium_src-4d8804ea89be1e0877ca4afe2d577f903a28f574.tar.gz chromium_src-4d8804ea89be1e0877ca4afe2d577f903a28f574.tar.bz2 |
cc: Visualize non-occluding rects in composited layers.
Adds a new flag to show non-occluding rects. When this flag is on, then for any
layer which could have been occluding, but isn't we show a rectangle on the
screen.
This means for layers that have 3d transforms and would never be occluding, we
don't draw rectangles. For axis aligned rectangles with opacity < 1, we don't
draw rectangles.
But when a layer has opacity=1, is axis aligned, but its contents are not
considered opaque, then we draw a rect to warn the user that this area could
have been occluding if only its contents had been considered opaque.
New command-line flag:
--show-nonoccluding-rects
R=jamesr,enne
BUG=160643
Review URL: https://codereview.chromium.org/11377122
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167816 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/debug_rect_history.cc | 11 | ||||
-rw-r--r-- | cc/debug_rect_history.h | 8 | ||||
-rw-r--r-- | cc/heads_up_display_layer_impl.cc | 7 | ||||
-rw-r--r-- | cc/layer_tree_host.cc | 2 | ||||
-rw-r--r-- | cc/layer_tree_host.h | 3 | ||||
-rw-r--r-- | cc/layer_tree_host_impl.cc | 4 | ||||
-rw-r--r-- | cc/layer_tree_host_impl.h | 1 | ||||
-rw-r--r-- | cc/occlusion_tracker.cc | 19 | ||||
-rw-r--r-- | cc/occlusion_tracker.h | 2 | ||||
-rw-r--r-- | cc/switches.cc | 4 | ||||
-rw-r--r-- | cc/switches.h | 1 |
11 files changed, 53 insertions, 9 deletions
diff --git a/cc/debug_rect_history.cc b/cc/debug_rect_history.cc index 02ece2c..6d7fa8a 100644 --- a/cc/debug_rect_history.cc +++ b/cc/debug_rect_history.cc @@ -24,7 +24,7 @@ DebugRectHistory::~DebugRectHistory() { } -void DebugRectHistory::saveDebugRectsForCurrentFrame(LayerImpl* rootLayer, const std::vector<LayerImpl*>& renderSurfaceLayerList, const std::vector<gfx::Rect>& occludingScreenSpaceRects, const LayerTreeSettings& settings) +void DebugRectHistory::saveDebugRectsForCurrentFrame(LayerImpl* rootLayer, const std::vector<LayerImpl*>& renderSurfaceLayerList, const std::vector<gfx::Rect>& occludingScreenSpaceRects, const std::vector<gfx::Rect>& nonOccludingScreenSpaceRects, const LayerTreeSettings& 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. @@ -44,6 +44,9 @@ void DebugRectHistory::saveDebugRectsForCurrentFrame(LayerImpl* rootLayer, const if (settings.showOccludingRects) saveOccludingRects(occludingScreenSpaceRects); + + if (settings.showNonOccludingRects) + saveNonOccludingRects(nonOccludingScreenSpaceRects); } @@ -118,4 +121,10 @@ void DebugRectHistory::saveOccludingRects(const std::vector<gfx::Rect>& occludin m_debugRects.push_back(DebugRect(OccludingRectType, occludingRects[i])); } +void DebugRectHistory::saveNonOccludingRects(const std::vector<gfx::Rect>& nonOccludingRects) +{ + for (size_t i = 0; i < nonOccludingRects.size(); ++i) + m_debugRects.push_back(DebugRect(NonOccludingRectType, nonOccludingRects[i])); +} + } // namespace cc diff --git a/cc/debug_rect_history.h b/cc/debug_rect_history.h index ff2ea8d..b8c5077 100644 --- a/cc/debug_rect_history.h +++ b/cc/debug_rect_history.h @@ -35,7 +35,10 @@ struct LayerTreeSettings; // // - Occluding rects: these are the regions that contribute to the occluded region. // -enum DebugRectType { PaintRectType, PropertyChangedRectType, SurfaceDamageRectType, ScreenSpaceRectType, ReplicaScreenSpaceRectType, OccludingRectType }; +// - Non-Occluding rects: these are the regions of composited layers that do not +// contribute to the occluded region. +// +enum DebugRectType { PaintRectType, PropertyChangedRectType, SurfaceDamageRectType, ScreenSpaceRectType, ReplicaScreenSpaceRectType, OccludingRectType, NonOccludingRectType }; struct DebugRect { DebugRect(DebugRectType newType, gfx::RectF newRect) @@ -56,7 +59,7 @@ public: ~DebugRectHistory(); // Note: Saving debug rects must happen before layers' change tracking is reset. - void saveDebugRectsForCurrentFrame(LayerImpl* rootLayer, const std::vector<LayerImpl*>& renderSurfaceLayerList, const std::vector<gfx::Rect>& occludingScreenSpaceRects, const LayerTreeSettings&); + void saveDebugRectsForCurrentFrame(LayerImpl* rootLayer, const std::vector<LayerImpl*>& renderSurfaceLayerList, const std::vector<gfx::Rect>& occludingScreenSpaceRects, const std::vector<gfx::Rect>& nonOccludingScreenSpaceRects, const LayerTreeSettings&); const std::vector<DebugRect>& debugRects() { return m_debugRects; } @@ -68,6 +71,7 @@ private: void saveSurfaceDamageRects(const std::vector<LayerImpl* >& renderSurfaceLayerList); void saveScreenSpaceRects(const std::vector<LayerImpl* >& renderSurfaceLayerList); void saveOccludingRects(const std::vector<gfx::Rect>& occludingScreenSpaceRects); + void saveNonOccludingRects(const std::vector<gfx::Rect>& nonOccludingScreenSpaceRects); std::vector<DebugRect> m_debugRects; diff --git a/cc/heads_up_display_layer_impl.cc b/cc/heads_up_display_layer_impl.cc index f687f01..53ace3a 100644 --- a/cc/heads_up_display_layer_impl.cc +++ b/cc/heads_up_display_layer_impl.cc @@ -345,7 +345,12 @@ void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory* fillColor = SkColorSetARGB(10, 100, 0, 200); break; case OccludingRectType: - // Occluding rects in a reddish color. + // Occluding rects in pink. + strokeColor = SkColorSetARGB(255, 245, 136, 255); + fillColor = SkColorSetARGB(10, 245, 136, 255); + break; + case NonOccludingRectType: + // Non-Occluding rects in a reddish color. strokeColor = SkColorSetARGB(255, 200, 0, 100); fillColor = SkColorSetARGB(10, 200, 0, 100); break; diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc index d261bfb..2bafa67 100644 --- a/cc/layer_tree_host.cc +++ b/cc/layer_tree_host.cc @@ -46,6 +46,7 @@ LayerTreeSettings::LayerTreeSettings() , showScreenSpaceRects(false) , showReplicaScreenSpaceRects(false) , showOccludingRects(false) + , showNonOccludingRects(false) , renderVSyncEnabled(true) , perTilePaintingEnabled(false) , partialSwapEnabled(false) @@ -65,6 +66,7 @@ LayerTreeSettings::LayerTreeSettings() showScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switches::kShowScreenSpaceRects); showReplicaScreenSpaceRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switches::kShowReplicaScreenSpaceRects); showOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switches::kShowOccludingRects); + showNonOccludingRects = CommandLine::ForCurrentProcess()->HasSwitch(cc::switches::kShowNonOccludingRects); partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePartialSwap); backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->HasSwitch(switches::kBackgroundColorInsteadOfCheckerboard); showOverdrawInTracing = CommandLine::ForCurrentProcess()->HasSwitch(switches::kTraceOverdraw); diff --git a/cc/layer_tree_host.h b/cc/layer_tree_host.h index aea6ea3b..5056345 100644 --- a/cc/layer_tree_host.h +++ b/cc/layer_tree_host.h @@ -63,6 +63,7 @@ struct CC_EXPORT LayerTreeSettings { bool showScreenSpaceRects; bool showReplicaScreenSpaceRects; bool showOccludingRects; + bool showNonOccludingRects; bool renderVSyncEnabled; bool perTilePaintingEnabled; bool partialSwapEnabled; @@ -77,7 +78,7 @@ struct CC_EXPORT LayerTreeSettings { gfx::Size minimumOcclusionTrackingSize; bool showDebugInfo() const { return showPlatformLayerTree || showDebugRects(); } - bool showDebugRects() const { return showPaintRects || showPropertyChangedRects || showSurfaceDamageRects || showScreenSpaceRects || showReplicaScreenSpaceRects || showOccludingRects; } + bool showDebugRects() const { return showPaintRects || showPropertyChangedRects || showSurfaceDamageRects || showScreenSpaceRects || showReplicaScreenSpaceRects || showOccludingRects || showNonOccludingRects; } }; // Provides information on an Impl's rendering capabilities back to the LayerTreeHost diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index 0982469..69eb10b 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -389,6 +389,8 @@ bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) if (settings().showOccludingRects) occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingScreenSpaceRects); + if (settings().showNonOccludingRects) + occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccludingScreenSpaceRects); // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk. typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; @@ -693,7 +695,7 @@ void LayerTreeHostImpl::drawLayers(const FrameData& frame) m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); if (m_settings.showDebugRects()) - m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, settings()); + m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOccludingScreenSpaceRects, settings()); // Because the contents of the HUD depend on everything else in the frame, the contents // of its texture are updated as the last thing before the frame is drawn. diff --git a/cc/layer_tree_host_impl.h b/cc/layer_tree_host_impl.h index 1b64eb9..800f7eb 100644 --- a/cc/layer_tree_host_impl.h +++ b/cc/layer_tree_host_impl.h @@ -124,6 +124,7 @@ public: ~FrameData(); std::vector<gfx::Rect> occludingScreenSpaceRects; + std::vector<gfx::Rect> nonOccludingScreenSpaceRects; RenderPassList renderPasses; RenderPassIdHashMap renderPassesById; LayerList* renderSurfaceLayerList; diff --git a/cc/occlusion_tracker.cc b/cc/occlusion_tracker.cc index b131c08..e00cc13 100644 --- a/cc/occlusion_tracker.cc +++ b/cc/occlusion_tracker.cc @@ -23,6 +23,7 @@ OcclusionTrackerBase<LayerType, RenderSurfaceType>::OcclusionTrackerBase(gfx::Re : m_rootTargetRect(rootTargetRect) , m_overdrawMetrics(OverdrawMetrics::create(recordMetricsForFrame)) , m_occludingScreenSpaceRects(0) + , m_nonOccludingScreenSpaceRects(0) { } @@ -248,7 +249,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::leaveToRenderTarget(con // 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 gfx::Rect& clipRectInTarget, const gfx::Size& minimumTrackingSize, std::vector<gfx::Rect>* occludingScreenSpaceRects) +static inline void addOcclusionBehindLayer(Region& region, const LayerType* layer, const WebTransformationMatrix& transform, const Region& opaqueContents, const gfx::Rect& clipRectInTarget, const gfx::Size& minimumTrackingSize, std::vector<gfx::Rect>* occludingScreenSpaceRects, std::vector<gfx::Rect>* nonOccludingScreenSpaceRects) { DCHECK(layer->visibleContentRect().Contains(opaqueContents.bounds())); @@ -268,6 +269,18 @@ static inline void addOcclusionBehindLayer(Region& region, const LayerType* laye region.Union(transformedRect); } } + + if (nonOccludingScreenSpaceRects) { + Region nonOpaqueContents = SubtractRegions(gfx::Rect(layer->contentBounds()), opaqueContents); + for (Region::Iterator nonOpaqueContentRects(nonOpaqueContents); nonOpaqueContentRects.has_rect(); nonOpaqueContentRects.next()) { + // We've already checked for clipping in the mapQuad call above, these calls should not clip anything further. + gfx::Rect transformedRect = gfx::ToEnclosedRect(MathUtil::mapClippedRect(transform, gfx::RectF(nonOpaqueContentRects.rect()))); + transformedRect.Intersect(clipRectInTarget); + if (transformedRect.IsEmpty()) + continue; + nonOccludingScreenSpaceRects->push_back(transformedRect); + } + } } template<typename LayerType, typename RenderSurfaceType> @@ -290,7 +303,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer gfx::Rect clipRectInTarget = layerClipRectInTarget(layer); if (layerTransformsToTargetKnown(layer)) - addOcclusionBehindLayer<LayerType>(m_stack.back().occlusionInTarget, layer, layer->drawTransform(), opaqueContents, clipRectInTarget, m_minimumTrackingSize, 0); + addOcclusionBehindLayer<LayerType>(m_stack.back().occlusionInTarget, layer, layer->drawTransform(), opaqueContents, clipRectInTarget, m_minimumTrackingSize, 0, 0); // We must clip the occlusion within the layer's clipRectInTarget within screen space as well. If the clip rect can't be moved to screen space and // remain rectilinear, then we don't add any occlusion in screen space. @@ -303,7 +316,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer if (clipped || !clipQuadInScreen.IsRectilinear()) return; gfx::Rect clipRectInScreen = gfx::IntersectRects(m_rootTargetRect, gfx::ToEnclosedRect(clipQuadInScreen.BoundingBox())); - addOcclusionBehindLayer<LayerType>(m_stack.back().occlusionInScreen, layer, layer->screenSpaceTransform(), opaqueContents, clipRectInScreen, m_minimumTrackingSize, m_occludingScreenSpaceRects); + addOcclusionBehindLayer<LayerType>(m_stack.back().occlusionInScreen, layer, layer->screenSpaceTransform(), opaqueContents, clipRectInScreen, m_minimumTrackingSize, m_occludingScreenSpaceRects, m_nonOccludingScreenSpaceRects); } } diff --git a/cc/occlusion_tracker.h b/cc/occlusion_tracker.h index bd4e198..7698103 100644 --- a/cc/occlusion_tracker.h +++ b/cc/occlusion_tracker.h @@ -53,6 +53,7 @@ public: // The following is used for visualization purposes. void setOccludingScreenSpaceRectsContainer(std::vector<gfx::Rect>* rects) { m_occludingScreenSpaceRects = rects; } + void setNonOccludingScreenSpaceRectsContainer(std::vector<gfx::Rect>* rects) { m_nonOccludingScreenSpaceRects = rects; } protected: struct StackObject { @@ -96,6 +97,7 @@ private: // This is used for visualizing the occlusion tracking process. std::vector<gfx::Rect>* m_occludingScreenSpaceRects; + std::vector<gfx::Rect>* m_nonOccludingScreenSpaceRects; DISALLOW_COPY_AND_ASSIGN(OcclusionTrackerBase); }; diff --git a/cc/switches.cc b/cc/switches.cc index aa21f54..4094ff0 100644 --- a/cc/switches.cc +++ b/cc/switches.cc @@ -44,6 +44,10 @@ const char kShowReplicaScreenSpaceRects[] = "show-replica-screenspace-rects"; // considered occluding the pixels behind it. const char kShowOccludingRects[] = "show-occluding-rects"; +// Show rects in the HUD wherever something is not known to be drawn opaque and +// is not considered to be occluding the pixels behind it. +const char kShowNonOccludingRects[] = "show-nonoccluding-rects"; + // Show metrics about overdraw in about:tracing recordings, such as the number // of pixels culled, and the number of pixels drawn, for each frame. const char kTraceOverdraw[] = "trace-overdraw"; diff --git a/cc/switches.h b/cc/switches.h index 347c495..31e5cb6a 100644 --- a/cc/switches.h +++ b/cc/switches.h @@ -27,6 +27,7 @@ CC_EXPORT extern const char kShowSurfaceDamageRects[]; CC_EXPORT extern const char kShowScreenSpaceRects[]; CC_EXPORT extern const char kShowReplicaScreenSpaceRects[]; CC_EXPORT extern const char kShowOccludingRects[]; +CC_EXPORT extern const char kShowNonOccludingRects[]; CC_EXPORT extern const char kTraceOverdraw[]; } // namespace switches |