diff options
author | avallee@chromium.org <avallee@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 22:18:39 +0000 |
---|---|---|
committer | avallee@chromium.org <avallee@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 22:18:39 +0000 |
commit | bf9ed2c3a0080086f5458b7da164afb91c61e7d5 (patch) | |
tree | 39632a5086af62b4e8a2d9d3ecad65deaab768a0 /cc | |
parent | 3eb06e59ed487936852867ff537b4a3cdbef8b8f (diff) | |
download | chromium_src-bf9ed2c3a0080086f5458b7da164afb91c61e7d5.zip chromium_src-bf9ed2c3a0080086f5458b7da164afb91c61e7d5.tar.gz chromium_src-bf9ed2c3a0080086f5458b7da164afb91c61e7d5.tar.bz2 |
Support for drawing a debug border around animated layers
This is the groundwork for showing a border around the
animation bounds of a layer. The animation bounds are the
bounds of the layer transformed to screen space where layers
that have an animation instead transform by an "inflate"
step.
To follow, compute the animation bounds of layers when
needed.
+ Add debug rect code to show a lime green border around
layers that have animation bounds.
+ Add --show-layer-animation-bounds that will enable the
drawing of the green box.
BUG=
Review URL: https://codereview.chromium.org/92853002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/base/switches.cc | 4 | ||||
-rw-r--r-- | cc/base/switches.h | 2 | ||||
-rw-r--r-- | cc/debug/debug_colors.cc | 9 | ||||
-rw-r--r-- | cc/debug/debug_colors.h | 4 | ||||
-rw-r--r-- | cc/debug/debug_rect_history.cc | 27 | ||||
-rw-r--r-- | cc/debug/debug_rect_history.h | 3 | ||||
-rw-r--r-- | cc/debug/layer_tree_debug_state.cc | 7 | ||||
-rw-r--r-- | cc/debug/layer_tree_debug_state.h | 1 | ||||
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.cc | 6 | ||||
-rw-r--r-- | cc/layers/layer_impl.h | 6 |
10 files changed, 68 insertions, 1 deletions
diff --git a/cc/base/switches.cc b/cc/base/switches.cc index 6768ef4..d3d2d1d 100644 --- a/cc/base/switches.cc +++ b/cc/base/switches.cc @@ -97,6 +97,10 @@ const char kUIShowCompositedLayerBorders[] = "ui-show-layer-borders"; const char kShowFPSCounter[] = "show-fps-counter"; const char kUIShowFPSCounter[] = "ui-show-fps-counter"; +// Renders a border that represents the bounding box for the layer's animation. +const char kShowLayerAnimationBounds[] = "show-layer-animation-bounds"; +const char kUIShowLayerAnimationBounds[] = "ui-show-layer-animation-bounds"; + // Show rects in the HUD around layers whose properties have changed. const char kShowPropertyChangedRects[] = "show-property-changed-rects"; const char kUIShowPropertyChangedRects[] = "ui-show-property-changed-rects"; diff --git a/cc/base/switches.h b/cc/base/switches.h index 8526541..19cba57 100644 --- a/cc/base/switches.h +++ b/cc/base/switches.h @@ -53,6 +53,8 @@ CC_EXPORT extern const char kShowCompositedLayerBorders[]; CC_EXPORT extern const char kUIShowCompositedLayerBorders[]; CC_EXPORT extern const char kShowFPSCounter[]; CC_EXPORT extern const char kUIShowFPSCounter[]; +CC_EXPORT extern const char kShowLayerAnimationBounds[]; +CC_EXPORT extern const char kUIShowLayerAnimationBounds[]; CC_EXPORT extern const char kShowPropertyChangedRects[]; CC_EXPORT extern const char kUIShowPropertyChangedRects[]; CC_EXPORT extern const char kShowSurfaceDamageRects[]; diff --git a/cc/debug/debug_colors.cc b/cc/debug/debug_colors.cc index e6f3e28..9fee755 100644 --- a/cc/debug/debug_colors.cc +++ b/cc/debug/debug_colors.cc @@ -253,6 +253,15 @@ SkColor DebugColors::NonFastScrollableRectFillColor() { return SkColorSetARGB(30, 238, 163, 59); } +// Animation bounds are lime-green. +SkColor DebugColors::LayerAnimationBoundsBorderColor() { + return SkColorSetARGB(255, 112, 229, 0); +} +int DebugColors::LayerAnimationBoundsBorderWidth() { return 2; } +SkColor DebugColors::LayerAnimationBoundsFillColor() { + return SkColorSetARGB(30, 112, 229, 0); +} + // Non-Painted rects in cyan. SkColor DebugColors::NonPaintedFillColor() { return SK_ColorCYAN; } diff --git a/cc/debug/debug_colors.h b/cc/debug/debug_colors.h index a1335e3..9edfb37 100644 --- a/cc/debug/debug_colors.h +++ b/cc/debug/debug_colors.h @@ -106,6 +106,10 @@ class DebugColors { static int NonFastScrollableRectBorderWidth(); static SkColor NonFastScrollableRectFillColor(); + static SkColor LayerAnimationBoundsBorderColor(); + static int LayerAnimationBoundsBorderWidth(); + static SkColor LayerAnimationBoundsFillColor(); + static SkColor NonPaintedFillColor(); static SkColor MissingPictureFillColor(); static SkColor PictureBorderColor(); diff --git a/cc/debug/debug_rect_history.cc b/cc/debug/debug_rect_history.cc index b972b32..679beaf 100644 --- a/cc/debug/debug_rect_history.cc +++ b/cc/debug/debug_rect_history.cc @@ -58,6 +58,9 @@ void DebugRectHistory::SaveDebugRectsForCurrentFrame( if (debug_state.show_non_occluding_rects) SaveNonOccludingRects(non_occluding_screen_space_rects); + + if (debug_state.show_layer_animation_bounds_rects) + SaveLayerAnimationBoundsRects(render_surface_layer_list); } void DebugRectHistory::SavePaintRects(LayerImpl* layer) { @@ -232,4 +235,28 @@ void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) { } } +void DebugRectHistory::SaveLayerAnimationBoundsRects( + const LayerImplList& render_surface_layer_list) { + typedef LayerIterator<LayerImpl, + LayerImplList, + RenderSurfaceImpl, + LayerIteratorActions::FrontToBack> LayerIteratorType; + LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); + for (LayerIteratorType it = + LayerIteratorType::Begin(&render_surface_layer_list); + it != end; ++it) { + if (!it.represents_itself()) + continue; + gfx::BoxF inflated_bounds; + if (!(*it)->GetAnimationBounds(&inflated_bounds)) + continue; + + debug_rects_.push_back(DebugRect(ANIMATION_BOUNDS_RECT_TYPE, + gfx::RectF(inflated_bounds.x(), + inflated_bounds.y(), + inflated_bounds.width(), + inflated_bounds.height()))); + } +} + } // namespace cc diff --git a/cc/debug/debug_rect_history.h b/cc/debug/debug_rect_history.h index 346148a..0dae431 100644 --- a/cc/debug/debug_rect_history.h +++ b/cc/debug/debug_rect_history.h @@ -53,6 +53,7 @@ enum DebugRectType { TOUCH_EVENT_HANDLER_RECT_TYPE, WHEEL_EVENT_HANDLER_RECT_TYPE, NON_FAST_SCROLLABLE_RECT_TYPE, + ANIMATION_BOUNDS_RECT_TYPE, }; struct DebugRect { @@ -103,6 +104,8 @@ class DebugRectHistory { void SaveWheelEventHandlerRectsCallback(LayerImpl* layer); void SaveNonFastScrollableRects(LayerImpl* layer); void SaveNonFastScrollableRectsCallback(LayerImpl* layer); + void SaveLayerAnimationBoundsRects( + const LayerImplList& render_surface_layer_list); std::vector<DebugRect> debug_rects_; diff --git a/cc/debug/layer_tree_debug_state.cc b/cc/debug/layer_tree_debug_state.cc index 72c3a9f..95245e0 100644 --- a/cc/debug/layer_tree_debug_state.cc +++ b/cc/debug/layer_tree_debug_state.cc @@ -23,6 +23,7 @@ LayerTreeDebugState::LayerTreeDebugState() show_touch_event_handler_rects(false), show_wheel_event_handler_rects(false), show_non_fast_scrollable_rects(false), + show_layer_animation_bounds_rects(false), slow_down_raster_scale_factor(0), rasterize_only_visible_content(false), show_picture_borders(false), @@ -48,7 +49,8 @@ bool LayerTreeDebugState::ShowHudRects() const { show_surface_damage_rects || show_screen_space_rects || show_replica_screen_space_rects || show_occluding_rects || show_non_occluding_rects || show_touch_event_handler_rects || - show_wheel_event_handler_rects || show_non_fast_scrollable_rects; + show_wheel_event_handler_rects || show_non_fast_scrollable_rects || + show_layer_animation_bounds_rects; } bool LayerTreeDebugState::ShowMemoryStats() const { @@ -74,6 +76,8 @@ bool LayerTreeDebugState::Equal(const LayerTreeDebugState& a, b.show_wheel_event_handler_rects && a.show_non_fast_scrollable_rects == b.show_non_fast_scrollable_rects && + a.show_layer_animation_bounds_rects == + b.show_layer_animation_bounds_rects && a.slow_down_raster_scale_factor == b.slow_down_raster_scale_factor && a.rasterize_only_visible_content == b.rasterize_only_visible_content && @@ -99,6 +103,7 @@ LayerTreeDebugState LayerTreeDebugState::Unite(const LayerTreeDebugState& a, r.show_touch_event_handler_rects |= b.show_touch_event_handler_rects; r.show_wheel_event_handler_rects |= b.show_wheel_event_handler_rects; r.show_non_fast_scrollable_rects |= b.show_non_fast_scrollable_rects; + r.show_layer_animation_bounds_rects |= b.show_layer_animation_bounds_rects; if (b.slow_down_raster_scale_factor) r.slow_down_raster_scale_factor = b.slow_down_raster_scale_factor; diff --git a/cc/debug/layer_tree_debug_state.h b/cc/debug/layer_tree_debug_state.h index 1233a4e..24196de 100644 --- a/cc/debug/layer_tree_debug_state.h +++ b/cc/debug/layer_tree_debug_state.h @@ -29,6 +29,7 @@ class CC_EXPORT LayerTreeDebugState { bool show_touch_event_handler_rects; bool show_wheel_event_handler_rects; bool show_non_fast_scrollable_rects; + bool show_layer_animation_bounds_rects; int slow_down_raster_scale_factor; bool rasterize_only_visible_content; diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index b7437bf..61489ee 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -652,6 +652,12 @@ void HeadsUpDisplayLayerImpl::DrawDebugRects( stroke_width = DebugColors::NonFastScrollableRectBorderWidth(); label_text = "repaints on scroll"; break; + case ANIMATION_BOUNDS_RECT_TYPE: + stroke_color = DebugColors::LayerAnimationBoundsBorderColor(); + fill_color = DebugColors::LayerAnimationBoundsFillColor(); + stroke_width = DebugColors::LayerAnimationBoundsBorderWidth(); + label_text = "animation bounds"; + break; } gfx::RectF debug_layer_rect = gfx::ScaleRect(debug_rects[i].rect, diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 35147913..cfbd353 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -361,6 +361,12 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, float contents_scale_y() const { return draw_properties_.contents_scale_y; } void SetContentsScale(float contents_scale_x, float contents_scale_y); + // Computes a box in screen space that should entirely contain the layer's + // bounds through the entirety of the layer's current animation. Returns true + // and sets |out| to the inflation if there are animations that can inflate + // bounds in the path to the root layer. Returns false otherwise. + bool GetAnimationBounds(gfx::BoxF* out) const { return false; } + virtual void CalculateContentsScale(float ideal_contents_scale, float device_scale_factor, float page_scale_factor, |