summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authoregraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-29 01:11:58 +0000
committeregraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-29 01:11:58 +0000
commit65319e205a77622ef623346a22cd50a1ad837044 (patch)
tree3cdffabd4950d0658145eaa9bcf1cdc9cb54f469 /cc
parent09185be19c2517df1d33fcfc486c230f7168ac80 (diff)
downloadchromium_src-65319e205a77622ef623346a22cd50a1ad837044.zip
chromium_src-65319e205a77622ef623346a22cd50a1ad837044.tar.gz
chromium_src-65319e205a77622ef623346a22cd50a1ad837044.tar.bz2
cc: Add debug rects for touch and wheel event handler regions and slow scrolling areas
This change adds new debug rect types to show regions with touch or wheel event handlers as well as areas that scroll slowly. Each rect type also displays a label in the top left corner to make them easier to identify. BUG=253552 Review URL: https://chromiumcodereview.appspot.com/17599002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209252 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/debug/debug_colors.cc36
-rw-r--r--cc/debug/debug_colors.h12
-rw-r--r--cc/debug/debug_rect_history.cc71
-rw-r--r--cc/debug/debug_rect_history.h9
-rw-r--r--cc/debug/layer_tree_debug_state.cc15
-rw-r--r--cc/debug/layer_tree_debug_state.h3
-rw-r--r--cc/layers/heads_up_display_layer_impl.cc55
-rw-r--r--cc/trees/layer_tree_host_common.h28
8 files changed, 228 insertions, 1 deletions
diff --git a/cc/debug/debug_colors.cc b/cc/debug/debug_colors.cc
index bb0514c..5ffa729 100644
--- a/cc/debug/debug_colors.cc
+++ b/cc/debug/debug_colors.cc
@@ -243,6 +243,42 @@ SkColor DebugColors::NonOccludingRectFillColor() {
return SkColorSetARGB(10, 200, 0, 100);
}
+// Touch-event-handler rects in yellow.
+SkColor DebugColors::TouchEventHandlerRectBorderColor() {
+ return SkColorSetARGB(255, 239, 229, 60);
+}
+int DebugColors::TouchEventHandlerRectBorderWidth(
+ const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::TouchEventHandlerRectFillColor() {
+ return SkColorSetARGB(30, 239, 229, 60);
+}
+
+// Wheel-event-handler rects in green.
+SkColor DebugColors::WheelEventHandlerRectBorderColor() {
+ return SkColorSetARGB(255, 189, 209, 57);
+}
+int DebugColors::WheelEventHandlerRectBorderWidth(
+ const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::WheelEventHandlerRectFillColor() {
+ return SkColorSetARGB(30, 189, 209, 57);
+}
+
+// Non-fast-scrollable rects in orange.
+SkColor DebugColors::NonFastScrollableRectBorderColor() {
+ return SkColorSetARGB(255, 238, 163, 59);
+}
+int DebugColors::NonFastScrollableRectBorderWidth(
+ const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::NonFastScrollableRectFillColor() {
+ return SkColorSetARGB(30, 238, 163, 59);
+}
+
// 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 407aa65..be2cf8d 100644
--- a/cc/debug/debug_colors.h
+++ b/cc/debug/debug_colors.h
@@ -95,6 +95,18 @@ class DebugColors {
static int NonOccludingRectBorderWidth(const LayerTreeImpl* tree_impl);
static SkColor NonOccludingRectFillColor();
+ static SkColor TouchEventHandlerRectBorderColor();
+ static int TouchEventHandlerRectBorderWidth(const LayerTreeImpl* tree_impl);
+ static SkColor TouchEventHandlerRectFillColor();
+
+ static SkColor WheelEventHandlerRectBorderColor();
+ static int WheelEventHandlerRectBorderWidth(const LayerTreeImpl* tree_impl);
+ static SkColor WheelEventHandlerRectFillColor();
+
+ static SkColor NonFastScrollableRectBorderColor();
+ static int NonFastScrollableRectBorderWidth(const LayerTreeImpl* tree_impl);
+ static SkColor NonFastScrollableRectFillColor();
+
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 7eaf6ab..24ba86e 100644
--- a/cc/debug/debug_rect_history.cc
+++ b/cc/debug/debug_rect_history.cc
@@ -9,6 +9,7 @@
#include "cc/layers/render_surface_impl.h"
#include "cc/trees/damage_tracker.h"
#include "cc/trees/layer_tree_host.h"
+#include "cc/trees/layer_tree_host_common.h"
namespace cc {
@@ -31,6 +32,15 @@ void DebugRectHistory::SaveDebugRectsForCurrentFrame(
// store all debug rects for a history of many frames.
debug_rects_.clear();
+ if (debug_state.show_touch_event_handler_rects)
+ SaveTouchEventHandlerRects(root_layer);
+
+ if (debug_state.show_wheel_event_handler_rects)
+ SaveWheelEventHandlerRects(root_layer);
+
+ if (debug_state.show_non_fast_scrollable_rects)
+ SaveNonFastScrollableRects(root_layer);
+
if (debug_state.show_paint_rects)
SavePaintRects(root_layer);
@@ -162,4 +172,65 @@ void DebugRectHistory::SaveNonOccludingRects(
}
}
+void DebugRectHistory::SaveTouchEventHandlerRects(LayerImpl* layer) {
+ LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>(
+ layer,
+ base::Bind(&DebugRectHistory::SaveTouchEventHandlerRectsCallback,
+ base::Unretained(this)));
+}
+
+void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) {
+ for (Region::Iterator iter(layer->touch_event_handler_region());
+ iter.has_rect();
+ iter.next()) {
+ gfx::RectF touch_rect = gfx::ScaleRect(iter.rect(),
+ layer->contents_scale_x(),
+ layer->contents_scale_y());
+ debug_rects_.push_back(DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE,
+ MathUtil::MapClippedRect(
+ layer->screen_space_transform(),
+ touch_rect)));
+ }
+}
+
+void DebugRectHistory::SaveWheelEventHandlerRects(LayerImpl* layer) {
+ LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>(
+ layer,
+ base::Bind(&DebugRectHistory::SaveWheelEventHandlerRectsCallback,
+ base::Unretained(this)));
+}
+
+void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) {
+ if (!layer->have_wheel_event_handlers())
+ return;
+
+ gfx::RectF wheel_rect = gfx::RectF(layer->content_bounds());
+ wheel_rect.Scale(layer->contents_scale_x(), layer->contents_scale_y());
+ debug_rects_.push_back(DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE,
+ MathUtil::MapClippedRect(
+ layer->screen_space_transform(),
+ wheel_rect)));
+}
+
+void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) {
+ LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>(
+ layer,
+ base::Bind(&DebugRectHistory::SaveNonFastScrollableRectsCallback,
+ base::Unretained(this)));
+}
+
+void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) {
+ for (Region::Iterator iter(layer->non_fast_scrollable_region());
+ iter.has_rect();
+ iter.next()) {
+ gfx::RectF scroll_rect = gfx::ScaleRect(iter.rect(),
+ layer->contents_scale_x(),
+ layer->contents_scale_y());
+ debug_rects_.push_back(DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE,
+ MathUtil::MapClippedRect(
+ layer->screen_space_transform(),
+ scroll_rect)));
+ }
+}
+
} // namespace cc
diff --git a/cc/debug/debug_rect_history.h b/cc/debug/debug_rect_history.h
index c95b62e..346148a 100644
--- a/cc/debug/debug_rect_history.h
+++ b/cc/debug/debug_rect_history.h
@@ -50,6 +50,9 @@ enum DebugRectType {
REPLICA_SCREEN_SPACE_RECT_TYPE,
OCCLUDING_RECT_TYPE,
NONOCCLUDING_RECT_TYPE,
+ TOUCH_EVENT_HANDLER_RECT_TYPE,
+ WHEEL_EVENT_HANDLER_RECT_TYPE,
+ NON_FAST_SCROLLABLE_RECT_TYPE,
};
struct DebugRect {
@@ -94,6 +97,12 @@ class DebugRectHistory {
const std::vector<gfx::Rect>& occluding_screen_space_rects);
void SaveNonOccludingRects(
const std::vector<gfx::Rect>& non_occluding_screen_space_rects);
+ void SaveTouchEventHandlerRects(LayerImpl* layer);
+ void SaveTouchEventHandlerRectsCallback(LayerImpl* layer);
+ void SaveWheelEventHandlerRects(LayerImpl* layer);
+ void SaveWheelEventHandlerRectsCallback(LayerImpl* layer);
+ void SaveNonFastScrollableRects(LayerImpl* layer);
+ void SaveNonFastScrollableRectsCallback(LayerImpl* layer);
std::vector<DebugRect> debug_rects_;
diff --git a/cc/debug/layer_tree_debug_state.cc b/cc/debug/layer_tree_debug_state.cc
index 897d692..72c3a9f 100644
--- a/cc/debug/layer_tree_debug_state.cc
+++ b/cc/debug/layer_tree_debug_state.cc
@@ -20,6 +20,9 @@ LayerTreeDebugState::LayerTreeDebugState()
show_replica_screen_space_rects(false),
show_occluding_rects(false),
show_non_occluding_rects(false),
+ show_touch_event_handler_rects(false),
+ show_wheel_event_handler_rects(false),
+ show_non_fast_scrollable_rects(false),
slow_down_raster_scale_factor(0),
rasterize_only_visible_content(false),
show_picture_borders(false),
@@ -44,7 +47,8 @@ bool LayerTreeDebugState::ShowHudRects() const {
return show_paint_rects || show_property_changed_rects ||
show_surface_damage_rects || show_screen_space_rects ||
show_replica_screen_space_rects || show_occluding_rects ||
- show_non_occluding_rects;
+ show_non_occluding_rects || show_touch_event_handler_rects ||
+ show_wheel_event_handler_rects || show_non_fast_scrollable_rects;
}
bool LayerTreeDebugState::ShowMemoryStats() const {
@@ -64,6 +68,12 @@ bool LayerTreeDebugState::Equal(const LayerTreeDebugState& a,
b.show_replica_screen_space_rects &&
a.show_occluding_rects == b.show_occluding_rects &&
a.show_non_occluding_rects == b.show_non_occluding_rects &&
+ a.show_touch_event_handler_rects ==
+ b.show_touch_event_handler_rects &&
+ a.show_wheel_event_handler_rects ==
+ b.show_wheel_event_handler_rects &&
+ a.show_non_fast_scrollable_rects ==
+ b.show_non_fast_scrollable_rects &&
a.slow_down_raster_scale_factor == b.slow_down_raster_scale_factor &&
a.rasterize_only_visible_content ==
b.rasterize_only_visible_content &&
@@ -86,6 +96,9 @@ LayerTreeDebugState LayerTreeDebugState::Unite(const LayerTreeDebugState& a,
r.show_replica_screen_space_rects |= b.show_replica_screen_space_rects;
r.show_occluding_rects |= b.show_occluding_rects;
r.show_non_occluding_rects |= b.show_non_occluding_rects;
+ 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;
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 f367364..1233a4e 100644
--- a/cc/debug/layer_tree_debug_state.h
+++ b/cc/debug/layer_tree_debug_state.h
@@ -26,6 +26,9 @@ class CC_EXPORT LayerTreeDebugState {
bool show_replica_screen_space_rects;
bool show_occluding_rects;
bool show_non_occluding_rects;
+ bool show_touch_event_handler_rects;
+ bool show_wheel_event_handler_rects;
+ bool show_non_fast_scrollable_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 98487b4..f31ef7b 100644
--- a/cc/layers/heads_up_display_layer_impl.cc
+++ b/cc/layers/heads_up_display_layer_impl.cc
@@ -589,6 +589,7 @@ void HeadsUpDisplayLayerImpl::DrawDebugRects(
SkColor stroke_color = 0;
SkColor fill_color = 0;
float stroke_width = 0.f;
+ std::string label_text;
switch (debug_rects[i].type) {
case PAINT_RECT_TYPE:
@@ -631,6 +632,27 @@ void HeadsUpDisplayLayerImpl::DrawDebugRects(
stroke_width =
DebugColors::NonOccludingRectBorderWidth(layer_tree_impl());
break;
+ case TOUCH_EVENT_HANDLER_RECT_TYPE:
+ stroke_color = DebugColors::TouchEventHandlerRectBorderColor();
+ fill_color = DebugColors::TouchEventHandlerRectFillColor();
+ stroke_width =
+ DebugColors::TouchEventHandlerRectBorderWidth(layer_tree_impl());
+ label_text = "touch event listener";
+ break;
+ case WHEEL_EVENT_HANDLER_RECT_TYPE:
+ stroke_color = DebugColors::WheelEventHandlerRectBorderColor();
+ fill_color = DebugColors::WheelEventHandlerRectFillColor();
+ stroke_width =
+ DebugColors::WheelEventHandlerRectBorderWidth(layer_tree_impl());
+ label_text = "mousewheel event listener";
+ break;
+ case NON_FAST_SCROLLABLE_RECT_TYPE:
+ stroke_color = DebugColors::NonFastScrollableRectBorderColor();
+ fill_color = DebugColors::NonFastScrollableRectFillColor();
+ stroke_width =
+ DebugColors::NonFastScrollableRectBorderWidth(layer_tree_impl());
+ label_text = "repaints on scroll";
+ break;
}
const gfx::RectF& rect = debug_rects[i].rect;
@@ -644,6 +666,39 @@ void HeadsUpDisplayLayerImpl::DrawDebugRects(
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(SkFloatToScalar(stroke_width));
canvas->drawRect(sk_rect, paint);
+
+ if (label_text.length()) {
+ const int kFontHeight = 12;
+ const int kPadding = 3;
+ const float device_scale_factor =
+ layer_tree_impl()->device_scale_factor();
+
+ canvas->save();
+ canvas->clipRect(sk_rect);
+ canvas->translate(sk_rect.x(), sk_rect.y());
+ canvas->scale(device_scale_factor, device_scale_factor);
+
+ SkPaint label_paint = CreatePaint();
+ label_paint.setTextSize(kFontHeight);
+ label_paint.setTypeface(typeface_.get());
+ label_paint.setColor(stroke_color);
+
+ const SkScalar label_text_width =
+ label_paint.measureText(label_text.c_str(), label_text.length());
+ canvas->drawRect(SkRect::MakeWH(label_text_width + 2 * kPadding,
+ kFontHeight + 2 * kPadding),
+ label_paint);
+
+ label_paint.setAntiAlias(true);
+ label_paint.setColor(SkColorSetARGB(255, 50, 50, 50));
+ canvas->drawText(label_text.c_str(),
+ label_text.length(),
+ kPadding,
+ kFontHeight * 0.8f + kPadding,
+ label_paint);
+
+ canvas->restore();
+ }
}
canvas->restore();
diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h
index 15c1180..789ba1e 100644
--- a/cc/trees/layer_tree_host_common.h
+++ b/cc/trees/layer_tree_host_common.h
@@ -7,6 +7,7 @@
#include <vector>
+#include "base/bind.h"
#include "base/memory/ref_counted.h"
#include "cc/base/cc_export.h"
#include "cc/base/scoped_ptr_vector.h"
@@ -65,9 +66,16 @@ class CC_EXPORT LayerTreeHostCommon {
static bool RenderSurfaceContributesToTarget(LayerType*,
int target_surface_layer_id);
+ // TODO(egraether): Remove this implementation and replace it with the
+ // Callback version everywhere.
template <class Function, typename LayerType>
static void CallFunctionForSubtree(LayerType* root_layer);
+ template <typename LayerType>
+ static void CallFunctionForSubtree(
+ LayerType* root_layer,
+ const base::Callback<void(LayerType* layer)>& function);
+
// Returns a layer with the given id if one exists in the subtree starting
// from the given root layer (including mask and replica layers).
template <typename LayerType>
@@ -156,6 +164,26 @@ void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* root_layer) {
}
}
+template <typename LayerType>
+void LayerTreeHostCommon::CallFunctionForSubtree(
+ LayerType* root_layer,
+ const base::Callback<void(LayerType* layer)>& function) {
+ function.Run(root_layer);
+
+ if (LayerType* mask_layer = root_layer->mask_layer())
+ function.Run(mask_layer);
+ if (LayerType* replica_layer = root_layer->replica_layer()) {
+ function.Run(replica_layer);
+ if (LayerType* mask_layer = replica_layer->mask_layer())
+ function.Run(mask_layer);
+ }
+
+ for (size_t i = 0; i < root_layer->children().size(); ++i) {
+ CallFunctionForSubtree(get_child_as_raw_ptr(root_layer->children(), i),
+ function);
+ }
+}
+
} // namespace cc
#endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_