Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2193)

Unified Diff: cc/debug_rect_history.cc

Issue 12522005: cc: Chromify DebugRectHistory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/debug_rect_history.h ('k') | cc/heads_up_display_layer_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/debug_rect_history.cc
diff --git a/cc/debug_rect_history.cc b/cc/debug_rect_history.cc
index 639eb76b90e5d42c291395eeb9330737af265b80..599171a64a71ffbe11a8c1ff96802b5998122889 100644
--- a/cc/debug_rect_history.cc
+++ b/cc/debug_rect_history.cc
@@ -12,119 +12,150 @@
namespace cc {
// static
-scoped_ptr<DebugRectHistory> DebugRectHistory::create() {
+scoped_ptr<DebugRectHistory> DebugRectHistory::Create() {
return make_scoped_ptr(new DebugRectHistory());
}
-DebugRectHistory::DebugRectHistory()
-{
-}
+DebugRectHistory::DebugRectHistory() {}
-DebugRectHistory::~DebugRectHistory()
-{
-}
+DebugRectHistory::~DebugRectHistory() {}
-void DebugRectHistory::saveDebugRectsForCurrentFrame(LayerImpl* rootLayer, const std::vector<LayerImpl*>& renderSurfaceLayerList, const std::vector<gfx::Rect>& occludingScreenSpaceRects, const std::vector<gfx::Rect>& nonOccludingScreenSpaceRects, const LayerTreeDebugState& debugState)
-{
- // 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.
- m_debugRects.clear();
+void DebugRectHistory::SaveDebugRectsForCurrentFrame(
+ LayerImpl* root_layer,
+ const std::vector<LayerImpl*>& render_surface_layer_list,
+ const std::vector<gfx::Rect>& occluding_screen_space_rects,
+ const std::vector<gfx::Rect>& non_occluding_screen_space_rects,
+ const LayerTreeDebugState& debug_state) {
+ // 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.
+ debug_rects_.clear();
- if (debugState.showPaintRects)
- savePaintRects(rootLayer);
+ if (debug_state.showPaintRects)
+ SavePaintRects(root_layer);
- if (debugState.showPropertyChangedRects)
- savePropertyChangedRects(renderSurfaceLayerList);
+ if (debug_state.showPropertyChangedRects)
+ SavePropertyChangedRects(render_surface_layer_list);
- if (debugState.showSurfaceDamageRects)
- saveSurfaceDamageRects(renderSurfaceLayerList);
+ if (debug_state.showSurfaceDamageRects)
+ SaveSurfaceDamageRects(render_surface_layer_list);
- if (debugState.showScreenSpaceRects)
- saveScreenSpaceRects(renderSurfaceLayerList);
+ if (debug_state.showScreenSpaceRects)
+ SaveScreenSpaceRects(render_surface_layer_list);
- if (debugState.showOccludingRects)
- saveOccludingRects(occludingScreenSpaceRects);
+ if (debug_state.showOccludingRects)
+ SaveOccludingRects(occluding_screen_space_rects);
- if (debugState.showNonOccludingRects)
- saveNonOccludingRects(nonOccludingScreenSpaceRects);
+ if (debug_state.showNonOccludingRects)
+ SaveNonOccludingRects(non_occluding_screen_space_rects);
}
-
-void DebugRectHistory::savePaintRects(LayerImpl* layer)
-{
- // We would like to visualize where any layer's paint rect (update rect) has changed,
- // regardless of whether this layer is skipped for actual drawing or not. Therefore
- // we traverse recursively over all layers, not just the render surface list.
-
- if (!layer->update_rect().IsEmpty() && layer->DrawsContent()) {
- float widthScale = layer->content_bounds().width() / static_cast<float>(layer->bounds().width());
- float heightScale = layer->content_bounds().height() / static_cast<float>(layer->bounds().height());
- gfx::RectF updateContentRect = gfx::ScaleRect(layer->update_rect(), widthScale, heightScale);
- m_debugRects.push_back(DebugRect(PaintRectType, MathUtil::mapClippedRect(layer->screen_space_transform(), updateContentRect)));
- }
-
- for (unsigned i = 0; i < layer->children().size(); ++i)
- savePaintRects(layer->children()[i]);
+void DebugRectHistory::SavePaintRects(LayerImpl* layer) {
+ // We would like to visualize where any layer's paint rect (update rect) has
+ // changed, regardless of whether this layer is skipped for actual drawing or
+ // not. Therefore we traverse recursively over all layers, not just the render
+ // surface list.
+
+ if (!layer->update_rect().IsEmpty() && layer->DrawsContent()) {
+ float width_scale = layer->content_bounds().width() /
+ static_cast<float>(layer->bounds().width());
+ float height_scale = layer->content_bounds().height() /
+ static_cast<float>(layer->bounds().height());
+ gfx::RectF update_content_rect =
+ gfx::ScaleRect(layer->update_rect(), width_scale, height_scale);
+ debug_rects_.push_back(
+ DebugRect(PAINT_RECT_TYPE,
+ MathUtil::mapClippedRect(layer->screen_space_transform(),
+ update_content_rect)));
+ }
+
+ for (unsigned i = 0; i < layer->children().size(); ++i)
+ SavePaintRects(layer->children()[i]);
}
-void DebugRectHistory::savePropertyChangedRects(const std::vector<LayerImpl*>& renderSurfaceLayerList)
-{
- for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
- LayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex];
- RenderSurfaceImpl* renderSurface = renderSurfaceLayer->render_surface();
- DCHECK(renderSurface);
-
- const std::vector<LayerImpl*>& layerList = renderSurface->layer_list();
- for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
- LayerImpl* layer = layerList[layerIndex];
-
- if (LayerTreeHostCommon::renderSurfaceContributesToTarget<LayerImpl>(layer, renderSurfaceLayer->id()))
- continue;
-
- if (layer->LayerIsAlwaysDamaged())
- continue;
-
- if (layer->LayerPropertyChanged() || layer->LayerSurfacePropertyChanged())
- m_debugRects.push_back(DebugRect(PropertyChangedRectType, MathUtil::mapClippedRect(layer->screen_space_transform(), gfx::RectF(gfx::PointF(), layer->content_bounds()))));
- }
+void DebugRectHistory::SavePropertyChangedRects(
+ const std::vector<LayerImpl*>& render_surface_layer_list) {
+ for (int surface_index = render_surface_layer_list.size() - 1;
+ surface_index >= 0;
+ --surface_index) {
+ LayerImpl* render_surface_layer = render_surface_layer_list[surface_index];
+ RenderSurfaceImpl* render_surface = render_surface_layer->render_surface();
+ DCHECK(render_surface);
+
+ const std::vector<LayerImpl*>& layer_list = render_surface->layer_list();
+ for (unsigned layerIndex = 0; layerIndex < layer_list.size();
danakj 2013/03/14 02:14:38 layer_index the script's bad with for loops :(
danakj 2013/03/14 02:14:38 1 statement per line?
enne (OOO) 2013/03/14 02:47:14 Done.
+ ++layerIndex) {
+ LayerImpl* layer = layer_list[layerIndex];
+
+ if (LayerTreeHostCommon::renderSurfaceContributesToTarget<LayerImpl>(
+ layer, render_surface_layer->id()))
+ continue;
+
+ if (layer->LayerIsAlwaysDamaged())
+ continue;
+
+ if (layer->LayerPropertyChanged() || layer->LayerSurfacePropertyChanged())
+ debug_rects_.push_back(
danakj 2013/03/14 02:14:38 {}
enne (OOO) 2013/03/14 02:47:14 Done.
+ DebugRect(PROPERTY_CHANGED_RECT_TYPE,
+ MathUtil::mapClippedRect(
+ layer->screen_space_transform(),
+ gfx::RectF(gfx::PointF(), layer->content_bounds()))));
}
+ }
}
-void DebugRectHistory::saveSurfaceDamageRects(const std::vector<LayerImpl* >& renderSurfaceLayerList)
-{
- for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
- LayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex];
- RenderSurfaceImpl* renderSurface = renderSurfaceLayer->render_surface();
- DCHECK(renderSurface);
-
- m_debugRects.push_back(DebugRect(SurfaceDamageRectType, MathUtil::mapClippedRect(renderSurface->screen_space_transform(), renderSurface->damage_tracker()->current_damage_rect())));
- }
+void DebugRectHistory::SaveSurfaceDamageRects(
+ const std::vector<LayerImpl*>& render_surface_layer_list) {
+ for (int surface_index = render_surface_layer_list.size() - 1;
+ surface_index >= 0;
+ --surface_index) {
+ LayerImpl* render_surface_layer = render_surface_layer_list[surface_index];
+ RenderSurfaceImpl* render_surface = render_surface_layer->render_surface();
+ DCHECK(render_surface);
+
+ debug_rects_.push_back(DebugRect(
+ SURFACE_DAMAGE_RECT_TYPE,
+ MathUtil::mapClippedRect(
+ render_surface->screen_space_transform(),
+ render_surface->damage_tracker()->current_damage_rect())));
+ }
}
-void DebugRectHistory::saveScreenSpaceRects(const std::vector<LayerImpl* >& renderSurfaceLayerList)
-{
- for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
- LayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex];
- RenderSurfaceImpl* renderSurface = renderSurfaceLayer->render_surface();
- DCHECK(renderSurface);
-
- m_debugRects.push_back(DebugRect(ScreenSpaceRectType, MathUtil::mapClippedRect(renderSurface->screen_space_transform(), renderSurface->content_rect())));
-
- if (renderSurfaceLayer->replica_layer())
- m_debugRects.push_back(DebugRect(ReplicaScreenSpaceRectType, MathUtil::mapClippedRect(renderSurface->replica_screen_space_transform(), renderSurface->content_rect())));
- }
+void DebugRectHistory::SaveScreenSpaceRects(
+ const std::vector<LayerImpl*>& render_surface_layer_list) {
+ for (int surface_index = render_surface_layer_list.size() - 1;
+ surface_index >= 0;
+ --surface_index) {
+ LayerImpl* render_surface_layer = render_surface_layer_list[surface_index];
+ RenderSurfaceImpl* render_surface = render_surface_layer->render_surface();
+ DCHECK(render_surface);
+
+ debug_rects_.push_back(DebugRect(
+ SCREEN_SPACE_RECT_TYPE,
+ MathUtil::mapClippedRect(render_surface->screen_space_transform(),
+ render_surface->content_rect())));
+
+ if (render_surface_layer->replica_layer())
danakj 2013/03/14 02:14:38 {}
enne (OOO) 2013/03/14 02:47:14 Done.
+ debug_rects_.push_back(
+ DebugRect(REPLICA_SCREEN_SPACE_RECT_TYPE,
+ MathUtil::mapClippedRect(
+ render_surface->replica_screen_space_transform(),
+ render_surface->content_rect())));
+ }
}
-void DebugRectHistory::saveOccludingRects(const std::vector<gfx::Rect>& occludingRects)
-{
- for (size_t i = 0; i < occludingRects.size(); ++i)
- m_debugRects.push_back(DebugRect(OccludingRectType, occludingRects[i]));
+void DebugRectHistory::SaveOccludingRects(
+ const std::vector<gfx::Rect>& occluding_rects) {
+ for (size_t i = 0; i < occluding_rects.size(); ++i) {
danakj 2013/03/14 02:14:38 no {}
enne (OOO) 2013/03/14 02:47:14 "In general, curly braces are not required for sin
+ debug_rects_.push_back(DebugRect(OCCLUDING_RECT_TYPE, occluding_rects[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]));
+void DebugRectHistory::SaveNonOccludingRects(
+ const std::vector<gfx::Rect>& non_occluding_rects) {
+ for (size_t i = 0; i < non_occluding_rects.size(); ++i) {
+ debug_rects_.push_back(
+ DebugRect(NONOCCLUDING_RECT_TYPE, non_occluding_rects[i]));
+ }
}
} // namespace cc
« no previous file with comments | « cc/debug_rect_history.h ('k') | cc/heads_up_display_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698