summaryrefslogtreecommitdiffstats
path: root/cc/debug
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 18:12:18 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 18:12:18 +0000
commitb4ead7bdfe512cee69862f8b79200b88d41d7317 (patch)
tree0d30671c758e273fcd79c9c52d68cf567411f389 /cc/debug
parent2056c3b91cd582ef0d4281f19d1e35215a4732ab (diff)
downloadchromium_src-b4ead7bdfe512cee69862f8b79200b88d41d7317.zip
chromium_src-b4ead7bdfe512cee69862f8b79200b88d41d7317.tar.gz
chromium_src-b4ead7bdfe512cee69862f8b79200b88d41d7317.tar.bz2
cc: Change damage tracking from floats to integers.
Damage rects can become huge when layers clip the viewport, and in some cases become so large that we reach inaccurate floating point representation of the whole-number portion, which we fail to handle correctly when doing gfx::ToEnclosingRect. Int/float conversions are also slow, and the GL_SCISSOR wants integers eventually anyway, so keeping track of partial-pixel damage is not buying us much here. So convert the DamageTracker to use integer rects. Also change cc::RenderSurfaceImpl to export a damage_rect that is contained inside the output_rect for the RenderPass, and add DCHECKs to cc::RenderPass to ensure we don't send pointlessly large damage_rects to the cc::Renderer. Tests: DamageTrackerTest.HugeDamageRect R=enne@chromium.org, piman@chromium.org BUG=355514 Review URL: https://codereview.chromium.org/226183007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262160 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/debug')
-rw-r--r--cc/debug/debug_rect_history.cc101
-rw-r--r--cc/debug/debug_rect_history.h5
2 files changed, 56 insertions, 50 deletions
diff --git a/cc/debug/debug_rect_history.cc b/cc/debug/debug_rect_history.cc
index 219fe06..e8792e7 100644
--- a/cc/debug/debug_rect_history.cc
+++ b/cc/debug/debug_rect_history.cc
@@ -12,6 +12,7 @@
#include "cc/trees/damage_tracker.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_host_common.h"
+#include "ui/gfx/geometry/rect_conversions.h"
namespace cc {
@@ -80,12 +81,12 @@ void DebugRectHistory::SavePaintRects(LayerImpl* layer) {
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);
+ gfx::Rect update_content_rect = gfx::ScaleToEnclosingRect(
+ gfx::ToEnclosingRect(layer->update_rect()), width_scale, height_scale);
debug_rects_.push_back(
DebugRect(PAINT_RECT_TYPE,
- MathUtil::MapClippedRect(layer->screen_space_transform(),
- update_content_rect)));
+ MathUtil::MapEnclosingClippedRect(
+ layer->screen_space_transform(), update_content_rect)));
}
for (unsigned i = 0; i < layer->children().size(); ++i)
@@ -115,13 +116,14 @@ void DebugRectHistory::SavePropertyChangedRects(
if (layer == hud_layer)
continue;
- if (layer->LayerPropertyChanged()) {
- debug_rects_.push_back(
- DebugRect(PROPERTY_CHANGED_RECT_TYPE,
- MathUtil::MapEnclosingClippedRect(
- layer->screen_space_transform(),
- gfx::Rect(layer->content_bounds()))));
- }
+ if (!layer->LayerPropertyChanged())
+ continue;
+
+ debug_rects_.push_back(
+ DebugRect(PROPERTY_CHANGED_RECT_TYPE,
+ MathUtil::MapEnclosingClippedRect(
+ layer->screen_space_transform(),
+ gfx::Rect(layer->content_bounds()))));
}
}
}
@@ -137,7 +139,7 @@ void DebugRectHistory::SaveSurfaceDamageRects(
debug_rects_.push_back(DebugRect(
SURFACE_DAMAGE_RECT_TYPE,
- MathUtil::MapClippedRect(
+ MathUtil::MapEnclosingClippedRect(
render_surface->screen_space_transform(),
render_surface->damage_tracker()->current_damage_rect())));
}
@@ -152,15 +154,16 @@ void DebugRectHistory::SaveScreenSpaceRects(
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())));
+ debug_rects_.push_back(
+ DebugRect(SCREEN_SPACE_RECT_TYPE,
+ MathUtil::MapEnclosingClippedRect(
+ 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(
+ MathUtil::MapEnclosingClippedRect(
render_surface->replica_screen_space_transform(),
render_surface->content_rect())));
}
@@ -192,13 +195,12 @@ 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)));
+ gfx::Rect touch_rect = gfx::ScaleToEnclosingRect(
+ iter.rect(), layer->contents_scale_x(), layer->contents_scale_y());
+ debug_rects_.push_back(
+ DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE,
+ MathUtil::MapEnclosingClippedRect(
+ layer->screen_space_transform(), touch_rect)));
}
}
@@ -213,12 +215,14 @@ 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)));
+ gfx::Rect wheel_rect =
+ gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()),
+ layer->contents_scale_x(),
+ layer->contents_scale_y());
+ debug_rects_.push_back(
+ DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE,
+ MathUtil::MapEnclosingClippedRect(
+ layer->screen_space_transform(), wheel_rect)));
}
void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) {
@@ -232,11 +236,14 @@ void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) {
if (!layer->have_scroll_event_handlers())
return;
- gfx::RectF scroll_rect = gfx::RectF(layer->content_bounds());
- scroll_rect.Scale(layer->contents_scale_x(), layer->contents_scale_y());
- debug_rects_.push_back(DebugRect(
- SCROLL_EVENT_HANDLER_RECT_TYPE,
- MathUtil::MapClippedRect(layer->screen_space_transform(), scroll_rect)));
+ gfx::Rect scroll_rect =
+ gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()),
+ layer->contents_scale_x(),
+ layer->contents_scale_y());
+ debug_rects_.push_back(
+ DebugRect(SCROLL_EVENT_HANDLER_RECT_TYPE,
+ MathUtil::MapEnclosingClippedRect(
+ layer->screen_space_transform(), scroll_rect)));
}
void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) {
@@ -250,13 +257,12 @@ 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)));
+ gfx::Rect scroll_rect = gfx::ScaleToEnclosingRect(
+ iter.rect(), layer->contents_scale_x(), layer->contents_scale_y());
+ debug_rects_.push_back(
+ DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE,
+ MathUtil::MapEnclosingClippedRect(
+ layer->screen_space_transform(), scroll_rect)));
}
}
@@ -276,11 +282,12 @@ void DebugRectHistory::SaveLayerAnimationBoundsRects(
if (!LayerUtils::GetAnimationBounds(**it, &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())));
+ debug_rects_.push_back(
+ DebugRect(ANIMATION_BOUNDS_RECT_TYPE,
+ gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(),
+ inflated_bounds.y(),
+ inflated_bounds.width(),
+ inflated_bounds.height()))));
}
}
diff --git a/cc/debug/debug_rect_history.h b/cc/debug/debug_rect_history.h
index 381fe0c..278b208 100644
--- a/cc/debug/debug_rect_history.h
+++ b/cc/debug/debug_rect_history.h
@@ -10,7 +10,6 @@
#include "base/memory/scoped_ptr.h"
#include "cc/layers/layer_lists.h"
#include "ui/gfx/rect.h"
-#include "ui/gfx/rect_f.h"
namespace cc {
@@ -58,11 +57,11 @@ enum DebugRectType {
};
struct DebugRect {
- DebugRect(DebugRectType new_type, const gfx::RectF& new_rect)
+ DebugRect(DebugRectType new_type, const gfx::Rect& new_rect)
: type(new_type), rect(new_rect) {}
DebugRectType type;
- gfx::RectF rect;
+ gfx::Rect rect;
};
// This class maintains a history of rects of various types that can be used