summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/debug_rect_history.cc210
-rw-r--r--cc/debug_rect_history.h99
-rw-r--r--cc/heads_up_display_layer_impl.cc22
-rw-r--r--cc/layer_tree_host_impl.cc4
4 files changed, 195 insertions, 140 deletions
diff --git a/cc/debug_rect_history.cc b/cc/debug_rect_history.cc
index 639eb76..6ad7cc6 100644
--- a/cc/debug_rect_history.cc
+++ b/cc/debug_rect_history.cc
@@ -12,119 +12,153 @@
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 layer_index = 0;
+ layer_index < layer_list.size();
+ ++layer_index) {
+ LayerImpl* layer = layer_list[layer_index];
+
+ if (LayerTreeHostCommon::renderSurfaceContributesToTarget<LayerImpl>(
+ layer, render_surface_layer->id()))
+ continue;
+
+ if (layer->LayerIsAlwaysDamaged())
+ continue;
+
+ if (layer->LayerPropertyChanged() ||
+ layer->LayerSurfacePropertyChanged()) {
+ debug_rects_.push_back(
+ 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()) {
+ 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)
+ 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
diff --git a/cc/debug_rect_history.h b/cc/debug_rect_history.h
index d4b1979..0092b9d 100644
--- a/cc/debug_rect_history.h
+++ b/cc/debug_rect_history.h
@@ -18,64 +18,85 @@ class LayerTreeDebugState;
// 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 they had to be repainted, too.
+// - Paint rects (update rects): regions of a layer that needed to be
+// re-uploaded to the texture resource; in most cases implying that they had to
+// be repainted, too.
//
-// - Property-changed rects: enclosing bounds of layers that cause changes to the screen
-// even if the layer did not change internally. (For example, if the layer's opacity or
-// position changes.)
+// - Property-changed rects: enclosing bounds of layers that cause changes to
+// the screen even if the layer did not change internally. (For example, if the
+// layer's opacity or position changes.)
//
-// - Surface damage rects: the aggregate damage on a target surface that is caused by all
-// layers and surfaces that contribute to it. This includes (1) paint rects, (2) property-
-// changed rects, and (3) newly exposed areas.
+// - Surface damage rects: the aggregate damage on a target surface that is
+// caused by all layers and surfaces that contribute to it. This includes (1)
+// paint rects, (2) property- changed rects, and (3) newly exposed areas.
//
// - 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.
+// - 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.
+// - Occluding rects: these are the regions that contribute to the occluded
+// region.
//
// - 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 };
+enum DebugRectType {
+ PAINT_RECT_TYPE,
+ PROPERTY_CHANGED_RECT_TYPE,
+ SURFACE_DAMAGE_RECT_TYPE,
+ SCREEN_SPACE_RECT_TYPE,
+ REPLICA_SCREEN_SPACE_RECT_TYPE,
+ OCCLUDING_RECT_TYPE,
+ NONOCCLUDING_RECT_TYPE,
+};
struct DebugRect {
- DebugRect(DebugRectType newType, gfx::RectF newRect)
- : type(newType)
- , rect(newRect) { }
+ DebugRect(DebugRectType new_type, gfx::RectF new_rect)
+ : type(new_type), rect(new_rect) {}
- DebugRectType type;
- gfx::RectF rect;
+ DebugRectType type;
+ gfx::RectF rect;
};
// This class maintains a history of rects of various types that can be used
// for debugging purposes. The overhead of collecting rects is performed only if
// the appropriate LayerTreeSettings are enabled.
class DebugRectHistory {
-public:
- static scoped_ptr<DebugRectHistory> create();
-
- ~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 std::vector<gfx::Rect>& nonOccludingScreenSpaceRects, const LayerTreeDebugState& debugState);
-
- const std::vector<DebugRect>& debugRects() { return m_debugRects; }
-
-private:
- DebugRectHistory();
-
- void savePaintRects(LayerImpl*);
- void savePropertyChangedRects(const std::vector<LayerImpl*>& renderSurfaceLayerList);
- 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;
-
- DISALLOW_COPY_AND_ASSIGN(DebugRectHistory);
+ public:
+ static scoped_ptr<DebugRectHistory> Create();
+
+ ~DebugRectHistory();
+
+ // Note: Saving debug rects must happen before layers' change tracking is
+ // reset.
+ void 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);
+
+ const std::vector<DebugRect>& debug_rects() { return debug_rects_; }
+
+ private:
+ DebugRectHistory();
+
+ void SavePaintRects(LayerImpl* layer);
+ void SavePropertyChangedRects(
+ const std::vector<LayerImpl*>& render_surface_layer_list);
+ void SaveSurfaceDamageRects(
+ const std::vector<LayerImpl*>& render_surface_layer_list);
+ void SaveScreenSpaceRects(
+ const std::vector<LayerImpl*>& render_surface_layer_list);
+ void SaveOccludingRects(
+ const std::vector<gfx::Rect>& occluding_screen_space_rects);
+ void SaveNonOccludingRects(
+ const std::vector<gfx::Rect>& non_occluding_screen_space_rects);
+
+ std::vector<DebugRect> debug_rects_;
+
+ DISALLOW_COPY_AND_ASSIGN(DebugRectHistory);
};
} // namespace cc
diff --git a/cc/heads_up_display_layer_impl.cc b/cc/heads_up_display_layer_impl.cc
index 71d6f71..70b0896 100644
--- a/cc/heads_up_display_layer_impl.cc
+++ b/cc/heads_up_display_layer_impl.cc
@@ -479,57 +479,57 @@ SkRect HeadsUpDisplayLayerImpl::drawPaintTimeDisplay(SkCanvas* canvas, const Pai
void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory* debugRectHistory) const
{
- const std::vector<DebugRect>& debugRects = debugRectHistory->debugRects();
+ const std::vector<DebugRect>& debug_rects = debugRectHistory->debug_rects();
float rectScale = 1 / layer_tree_impl()->device_scale_factor();
SkPaint paint = createPaint();
canvas->save();
canvas->scale(rectScale, rectScale);
- for (size_t i = 0; i < debugRects.size(); ++i) {
+ for (size_t i = 0; i < debug_rects.size(); ++i) {
SkColor strokeColor = 0;
SkColor fillColor = 0;
float strokeWidth = 0;
- switch (debugRects[i].type) {
- case PaintRectType:
+ switch (debug_rects[i].type) {
+ case PAINT_RECT_TYPE:
strokeColor = DebugColors::PaintRectBorderColor();
fillColor = DebugColors::PaintRectFillColor();
strokeWidth = DebugColors::PaintRectBorderWidth(layer_tree_impl());
break;
- case PropertyChangedRectType:
+ case PROPERTY_CHANGED_RECT_TYPE:
strokeColor = DebugColors::PropertyChangedRectBorderColor();
fillColor = DebugColors::PropertyChangedRectFillColor();
strokeWidth = DebugColors::PropertyChangedRectBorderWidth(layer_tree_impl());
break;
- case SurfaceDamageRectType:
+ case SURFACE_DAMAGE_RECT_TYPE:
strokeColor = DebugColors::SurfaceDamageRectBorderColor();
fillColor = DebugColors::SurfaceDamageRectFillColor();
strokeWidth = DebugColors::SurfaceDamageRectBorderWidth(layer_tree_impl());
break;
- case ReplicaScreenSpaceRectType:
+ case REPLICA_SCREEN_SPACE_RECT_TYPE:
strokeColor = DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor();
fillColor = DebugColors::ScreenSpaceSurfaceReplicaRectFillColor();
strokeWidth = DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth(layer_tree_impl());
break;
- case ScreenSpaceRectType:
+ case SCREEN_SPACE_RECT_TYPE:
strokeColor = DebugColors::ScreenSpaceLayerRectBorderColor();
fillColor = DebugColors::ScreenSpaceLayerRectFillColor();
strokeWidth = DebugColors::ScreenSpaceLayerRectBorderWidth(layer_tree_impl());
break;
- case OccludingRectType:
+ case OCCLUDING_RECT_TYPE:
strokeColor = DebugColors::OccludingRectBorderColor();
fillColor = DebugColors::OccludingRectFillColor();
strokeWidth = DebugColors::OccludingRectBorderWidth(layer_tree_impl());
break;
- case NonOccludingRectType:
+ case NONOCCLUDING_RECT_TYPE:
strokeColor = DebugColors::NonOccludingRectBorderColor();
fillColor = DebugColors::NonOccludingRectFillColor();
strokeWidth = DebugColors::NonOccludingRectBorderWidth(layer_tree_impl());
break;
}
- const gfx::RectF& rect = debugRects[i].rect;
+ const gfx::RectF& rect = debug_rects[i].rect;
SkRect skRect = SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
paint.setColor(fillColor);
paint.setStyle(SkPaint::kFill_Style);
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 3c13252..7c42e04 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -165,7 +165,7 @@ LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings,
fps_counter_(FrameRateCounter::create(proxy_->HasImplThread())),
paint_time_counter_(PaintTimeCounter::create()),
memory_history_(MemoryHistory::Create()),
- debug_rect_history_(DebugRectHistory::create()),
+ debug_rect_history_(DebugRectHistory::Create()),
num_impl_thread_scrolls_(0),
num_main_thread_scrolls_(0),
cumulative_num_layers_drawn_(0),
@@ -946,7 +946,7 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame) {
}
if (debug_state_.showHudRects()) {
- debug_rect_history_->saveDebugRectsForCurrentFrame(
+ debug_rect_history_->SaveDebugRectsForCurrentFrame(
active_tree_->root_layer(),
*frame->render_surface_layer_list,
frame->occluding_screen_space_rects,