diff options
-rw-r--r-- | cc/debug/debug_rect_history.cc | 101 | ||||
-rw-r--r-- | cc/debug/debug_rect_history.h | 5 | ||||
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.cc | 18 | ||||
-rw-r--r-- | cc/layers/render_surface_impl.cc | 3 | ||||
-rw-r--r-- | cc/output/direct_renderer.cc | 22 | ||||
-rw-r--r-- | cc/output/direct_renderer.h | 10 | ||||
-rw-r--r-- | cc/output/gl_renderer_unittest.cc | 12 | ||||
-rw-r--r-- | cc/output/renderer_pixeltest.cc | 4 | ||||
-rw-r--r-- | cc/quads/render_pass.cc | 8 | ||||
-rw-r--r-- | cc/quads/render_pass.h | 6 | ||||
-rw-r--r-- | cc/quads/render_pass_unittest.cc | 2 | ||||
-rw-r--r-- | cc/surfaces/surface_aggregator_unittest.cc | 2 | ||||
-rw-r--r-- | cc/trees/damage_tracker.cc | 74 | ||||
-rw-r--r-- | cc/trees/damage_tracker.h | 27 | ||||
-rw-r--r-- | cc/trees/damage_tracker_unittest.cc | 337 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_delegated.cc | 65 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura_unittest.cc | 6 | ||||
-rw-r--r-- | content/common/cc_messages.cc | 2 | ||||
-rw-r--r-- | content/common/cc_messages_unittest.cc | 6 | ||||
-rw-r--r-- | ui/compositor/layer_unittest.cc | 6 |
20 files changed, 374 insertions, 342 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 diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index d995229..2ef8a2f 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -599,25 +599,31 @@ void HeadsUpDisplayLayerImpl::DrawDebugRect( SkColor fill_color, float stroke_width, const std::string& label_text) const { - gfx::RectF debug_layer_rect = gfx::ScaleRect( + gfx::Rect debug_layer_rect = gfx::ScaleToEnclosingRect( rect.rect, 1.0 / contents_scale_x(), 1.0 / contents_scale_y()); - SkRect sk_rect = RectFToSkRect(debug_layer_rect); + SkIRect sk_rect = RectToSkIRect(debug_layer_rect); paint.setColor(fill_color); paint.setStyle(SkPaint::kFill_Style); - canvas->drawRect(sk_rect, paint); + canvas->drawIRect(sk_rect, paint); paint.setColor(stroke_color); paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(SkFloatToScalar(stroke_width)); - canvas->drawRect(sk_rect, paint); + canvas->drawIRect(sk_rect, paint); if (label_text.length()) { const int kFontHeight = 12; const int kPadding = 3; + // The debug_layer_rect may be huge, and converting to a floating point may + // be lossy, so intersect with the HUD layer bounds first to prevent that. + gfx::Rect clip_rect = debug_layer_rect; + clip_rect.Intersect(gfx::Rect(content_bounds())); + SkRect sk_clip_rect = RectToSkRect(clip_rect); + canvas->save(); - canvas->clipRect(sk_rect); - canvas->translate(sk_rect.x(), sk_rect.y()); + canvas->clipRect(sk_clip_rect); + canvas->translate(sk_clip_rect.x(), sk_clip_rect.y()); SkPaint label_paint = CreatePaint(); label_paint.setTextSize(kFontHeight); diff --git a/cc/layers/render_surface_impl.cc b/cc/layers/render_surface_impl.cc index ddb7158..fa7dcb8 100644 --- a/cc/layers/render_surface_impl.cc +++ b/cc/layers/render_surface_impl.cc @@ -130,7 +130,8 @@ void RenderSurfaceImpl::AppendRenderPasses(RenderPassSink* pass_sink) { scoped_ptr<RenderPass> pass = RenderPass::Create(layer_list_.size()); pass->SetNew(RenderPassId(), content_rect_, - damage_tracker_->current_damage_rect(), + gfx::IntersectRects(content_rect_, + damage_tracker_->current_damage_rect()), screen_space_transform_); pass_sink->AppendRenderPass(pass.Pass()); } diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc index 0eb2dcb..43a0412 100644 --- a/cc/output/direct_renderer.cc +++ b/cc/output/direct_renderer.cc @@ -118,8 +118,8 @@ void DirectRenderer::InitializeViewport(DrawingFrame* frame, } gfx::Rect DirectRenderer::MoveFromDrawToWindowSpace( - const gfx::RectF& draw_rect) const { - gfx::Rect window_rect = gfx::ToEnclosingRect(draw_rect); + const gfx::Rect& draw_rect) const { + gfx::Rect window_rect = draw_rect; window_rect -= current_draw_rect_.OffsetFromOrigin(); window_rect += current_viewport_rect_.OffsetFromOrigin(); if (FlippedFramebuffer()) @@ -254,9 +254,9 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, render_passes_in_draw_order->clear(); } -gfx::RectF DirectRenderer::ComputeScissorRectForRenderPass( +gfx::Rect DirectRenderer::ComputeScissorRectForRenderPass( const DrawingFrame* frame) { - gfx::RectF render_pass_scissor = frame->current_render_pass->output_rect; + gfx::Rect render_pass_scissor = frame->current_render_pass->output_rect; if (frame->root_damage_rect == frame->root_render_pass->output_rect || !frame->current_render_pass->copy_requests.empty()) @@ -266,9 +266,9 @@ gfx::RectF DirectRenderer::ComputeScissorRectForRenderPass( if (frame->current_render_pass->transform_to_root_target.GetInverse( &inverse_transform)) { // Only intersect inverse-projected damage if the transform is invertible. - gfx::RectF damage_rect_in_render_pass_space = - MathUtil::ProjectClippedRect(inverse_transform, - frame->root_damage_rect); + gfx::Rect damage_rect_in_render_pass_space = + MathUtil::ProjectEnclosingClippedRect(inverse_transform, + frame->root_damage_rect); render_pass_scissor.Intersect(damage_rect_in_render_pass_space); } @@ -308,9 +308,9 @@ void DirectRenderer::SetScissorStateForQuad(const DrawingFrame* frame, void DirectRenderer::SetScissorStateForQuadWithRenderPassScissor( const DrawingFrame* frame, const DrawQuad& quad, - const gfx::RectF& render_pass_scissor, + const gfx::Rect& render_pass_scissor, bool* should_skip_quad) { - gfx::RectF quad_scissor_rect = render_pass_scissor; + gfx::Rect quad_scissor_rect = render_pass_scissor; if (quad.isClipped()) quad_scissor_rect.Intersect(quad.clipRect()); @@ -326,7 +326,7 @@ void DirectRenderer::SetScissorStateForQuadWithRenderPassScissor( void DirectRenderer::SetScissorTestRectInDrawSpace( const DrawingFrame* frame, - const gfx::RectF& draw_space_rect) { + const gfx::Rect& draw_space_rect) { gfx::Rect window_space_rect = MoveFromDrawToWindowSpace(draw_space_rect); if (NeedDeviceClip(frame)) window_space_rect.Intersect(DeviceClipRectInWindowSpace(frame)); @@ -342,7 +342,7 @@ void DirectRenderer::DrawRenderPass(DrawingFrame* frame, return; bool using_scissor_as_optimization = Capabilities().using_partial_swap; - gfx::RectF render_pass_scissor; + gfx::Rect render_pass_scissor; bool draw_rect_covers_full_surface = true; if (frame->current_render_pass == frame->root_render_pass && !frame->device_viewport_rect.Contains( diff --git a/cc/output/direct_renderer.h b/cc/output/direct_renderer.h index fce36db..a1eacad 100644 --- a/cc/output/direct_renderer.h +++ b/cc/output/direct_renderer.h @@ -48,7 +48,7 @@ class CC_EXPORT DirectRenderer : public Renderer { const RenderPass* current_render_pass; const ScopedResource* current_texture; - gfx::RectF root_damage_rect; + gfx::Rect root_damage_rect; gfx::Rect device_viewport_rect; gfx::Rect device_clip_rect; @@ -78,19 +78,19 @@ class CC_EXPORT DirectRenderer : public Renderer { const gfx::Rect& draw_rect, const gfx::Rect& viewport_rect, const gfx::Size& surface_size); - gfx::Rect MoveFromDrawToWindowSpace(const gfx::RectF& draw_rect) const; + gfx::Rect MoveFromDrawToWindowSpace(const gfx::Rect& draw_rect) const; bool NeedDeviceClip(const DrawingFrame* frame) const; gfx::Rect DeviceClipRectInWindowSpace(const DrawingFrame* frame) const; - static gfx::RectF ComputeScissorRectForRenderPass(const DrawingFrame* frame); + static gfx::Rect ComputeScissorRectForRenderPass(const DrawingFrame* frame); void SetScissorStateForQuad(const DrawingFrame* frame, const DrawQuad& quad); void SetScissorStateForQuadWithRenderPassScissor( const DrawingFrame* frame, const DrawQuad& quad, - const gfx::RectF& render_pass_scissor, + const gfx::Rect& render_pass_scissor, bool* should_skip_quad); void SetScissorTestRectInDrawSpace(const DrawingFrame* frame, - const gfx::RectF& draw_space_rect); + const gfx::Rect& draw_space_rect); static gfx::Size RenderPassTextureSize(const RenderPass* render_pass); diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc index 5527af9..57ec984 100644 --- a/cc/output/gl_renderer_unittest.cc +++ b/cc/output/gl_renderer_unittest.cc @@ -1116,7 +1116,7 @@ TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { viewport_rect, gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); - root_pass->damage_rect = gfx::RectF(2.f, 2.f, 3.f, 3.f); + root_pass->damage_rect = gfx::Rect(2, 2, 3, 3); renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); renderer.DrawFrame(&render_passes_in_draw_order_, @@ -1136,7 +1136,7 @@ TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { viewport_rect, gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); - root_pass->damage_rect = gfx::RectF(root_pass->output_rect); + root_pass->damage_rect = root_pass->output_rect; renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); renderer.DrawFrame(&render_passes_in_draw_order_, @@ -1157,7 +1157,7 @@ TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { viewport_rect, gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); - root_pass->damage_rect = gfx::RectF(root_pass->output_rect); + root_pass->damage_rect = root_pass->output_rect; root_pass->has_transparent_background = false; renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); @@ -1180,7 +1180,7 @@ TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { viewport_rect, gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); - root_pass->damage_rect = gfx::RectF(root_pass->output_rect); + root_pass->damage_rect = root_pass->output_rect; renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); renderer.DrawFrame(&render_passes_in_draw_order_, @@ -1201,7 +1201,7 @@ TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { viewport_rect, gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); - root_pass->damage_rect = gfx::RectF(root_pass->output_rect); + root_pass->damage_rect = root_pass->output_rect; renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); renderer.DrawFrame(&render_passes_in_draw_order_, @@ -1223,7 +1223,7 @@ TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { viewport_rect, gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); - root_pass->damage_rect = gfx::RectF(root_pass->output_rect); + root_pass->damage_rect = root_pass->output_rect; renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); renderer.DrawFrame(&render_passes_in_draw_order_, diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc index b431c21..11eaab1 100644 --- a/cc/output/renderer_pixeltest.cc +++ b/cc/output/renderer_pixeltest.cc @@ -31,7 +31,7 @@ scoped_ptr<RenderPass> CreateTestRootRenderPass(RenderPass::Id id, const gfx::Rect& rect) { scoped_ptr<RenderPass> pass = RenderPass::Create(); const gfx::Rect output_rect = rect; - const gfx::RectF damage_rect = rect; + const gfx::Rect damage_rect = rect; const gfx::Transform transform_to_root_target; pass->SetNew(id, output_rect, damage_rect, transform_to_root_target); return pass.Pass(); @@ -43,7 +43,7 @@ scoped_ptr<RenderPass> CreateTestRenderPass( const gfx::Transform& transform_to_root_target) { scoped_ptr<RenderPass> pass = RenderPass::Create(); const gfx::Rect output_rect = rect; - const gfx::RectF damage_rect = rect; + const gfx::Rect damage_rect = rect; pass->SetNew(id, output_rect, damage_rect, transform_to_root_target); return pass.Pass(); } diff --git a/cc/quads/render_pass.cc b/cc/quads/render_pass.cc index 82deccd..a55faa7 100644 --- a/cc/quads/render_pass.cc +++ b/cc/quads/render_pass.cc @@ -110,10 +110,14 @@ void RenderPass::CopyAll(const ScopedPtrVector<RenderPass>& in, void RenderPass::SetNew(Id id, const gfx::Rect& output_rect, - const gfx::RectF& damage_rect, + const gfx::Rect& damage_rect, const gfx::Transform& transform_to_root_target) { DCHECK_GT(id.layer_id, 0); DCHECK_GE(id.index, 0); + DCHECK_GE(damage_rect.x(), output_rect.x()); + DCHECK_GE(damage_rect.y(), output_rect.y()); + DCHECK_LE(damage_rect.bottom(), output_rect.bottom()); + DCHECK_LE(damage_rect.right(), output_rect.right()); this->id = id; this->output_rect = output_rect; @@ -126,7 +130,7 @@ void RenderPass::SetNew(Id id, void RenderPass::SetAll(Id id, const gfx::Rect& output_rect, - const gfx::RectF& damage_rect, + const gfx::Rect& damage_rect, const gfx::Transform& transform_to_root_target, bool has_transparent_background) { DCHECK_GT(id.layer_id, 0); diff --git a/cc/quads/render_pass.h b/cc/quads/render_pass.h index 4285e53..1cbac05 100644 --- a/cc/quads/render_pass.h +++ b/cc/quads/render_pass.h @@ -77,12 +77,12 @@ class CC_EXPORT RenderPass { void SetNew(Id id, const gfx::Rect& output_rect, - const gfx::RectF& damage_rect, + const gfx::Rect& damage_rect, const gfx::Transform& transform_to_root_target); void SetAll(Id id, const gfx::Rect& output_rect, - const gfx::RectF& damage_rect, + const gfx::Rect& damage_rect, const gfx::Transform& transform_to_root_target, bool has_transparent_background); @@ -93,7 +93,7 @@ class CC_EXPORT RenderPass { // These are in the space of the render pass' physical pixels. gfx::Rect output_rect; - gfx::RectF damage_rect; + gfx::Rect damage_rect; // Transforms from the origin of the |output_rect| to the origin of the root // render pass' |output_rect|. diff --git a/cc/quads/render_pass_unittest.cc b/cc/quads/render_pass_unittest.cc index fd58523..f714dbe 100644 --- a/cc/quads/render_pass_unittest.cc +++ b/cc/quads/render_pass_unittest.cc @@ -28,7 +28,7 @@ struct RenderPassSize { SharedQuadStateList shared_quad_state_list; gfx::Transform transform_to_root_target; gfx::Rect output_rect; - gfx::RectF damage_rect; + gfx::Rect damage_rect; bool has_transparent_background; ScopedPtrVector<CopyOutputRequest> copy_callbacks; }; diff --git a/cc/surfaces/surface_aggregator_unittest.cc b/cc/surfaces/surface_aggregator_unittest.cc index 0e23389..3f2fbd8 100644 --- a/cc/surfaces/surface_aggregator_unittest.cc +++ b/cc/surfaces/surface_aggregator_unittest.cc @@ -480,7 +480,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) { Surface grandchild_surface(&manager_, NULL, surface_size); scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create(); gfx::Rect output_rect(surface_size); - gfx::RectF damage_rect(surface_size); + gfx::Rect damage_rect(surface_size); gfx::Transform transform_to_root_target; grandchild_pass->SetNew( pass_id, output_rect, damage_rect, transform_to_root_target); diff --git a/cc/trees/damage_tracker.cc b/cc/trees/damage_tracker.cc index 4d0e935..4074146 100644 --- a/cc/trees/damage_tracker.cc +++ b/cc/trees/damage_tracker.cc @@ -13,6 +13,7 @@ #include "cc/output/filter_operations.h" #include "cc/trees/layer_tree_host_common.h" #include "cc/trees/layer_tree_impl.h" +#include "ui/gfx/geometry/rect_conversions.h" namespace cc { @@ -25,20 +26,20 @@ DamageTracker::DamageTracker() DamageTracker::~DamageTracker() {} -static inline void ExpandRectWithFilters( - gfx::RectF* rect, const FilterOperations& filters) { +static inline void ExpandRectWithFilters(gfx::Rect* rect, + const FilterOperations& filters) { int top, right, bottom, left; filters.GetOutsets(&top, &right, &bottom, &left); rect->Inset(-left, -top, -right, -bottom); } static inline void ExpandDamageRectInsideRectWithFilters( - gfx::RectF* damage_rect, - const gfx::RectF& pre_filter_rect, + gfx::Rect* damage_rect, + const gfx::Rect& pre_filter_rect, const FilterOperations& filters) { - gfx::RectF expanded_damage_rect = *damage_rect; + gfx::Rect expanded_damage_rect = *damage_rect; ExpandRectWithFilters(&expanded_damage_rect, filters); - gfx::RectF filter_rect = pre_filter_rect; + gfx::Rect filter_rect = pre_filter_rect; ExpandRectWithFilters(&filter_rect, filters); expanded_damage_rect.Intersect(filter_rect); @@ -124,13 +125,13 @@ void DamageTracker::UpdateDamageTrackingState( // These functions cannot be bypassed with early-exits, even if we know what // the damage will be for this frame, because we need to update the damage // tracker state to correctly track the next frame. - gfx::RectF damage_from_active_layers = + gfx::Rect damage_from_active_layers = TrackDamageFromActiveLayers(layer_list, target_surface_layer_id); - gfx::RectF damage_from_surface_mask = + gfx::Rect damage_from_surface_mask = TrackDamageFromSurfaceMask(target_surface_mask_layer); - gfx::RectF damage_from_leftover_rects = TrackDamageFromLeftoverRects(); + gfx::Rect damage_from_leftover_rects = TrackDamageFromLeftoverRects(); - gfx::RectF damage_rect_for_this_update; + gfx::Rect damage_rect_for_this_update; if (target_surface_property_changed_only_from_descendant) { damage_rect_for_this_update = target_surface_content_rect; @@ -172,10 +173,10 @@ DamageTracker::RectMapData& DamageTracker::RectDataForLayer( return *it; } -gfx::RectF DamageTracker::TrackDamageFromActiveLayers( +gfx::Rect DamageTracker::TrackDamageFromActiveLayers( const LayerImplList& layer_list, int target_surface_layer_id) { - gfx::RectF damage_rect = gfx::RectF(); + gfx::Rect damage_rect; for (size_t layer_index = 0; layer_index < layer_list.size(); ++layer_index) { // Visit layers in back-to-front order. @@ -186,7 +187,6 @@ gfx::RectF DamageTracker::TrackDamageFromActiveLayers( // HUD damage rect visualization. if (layer == layer->layer_tree_impl()->hud_layer()) continue; - if (LayerTreeHostCommon::RenderSurfaceContributesToTarget<LayerImpl>( layer, target_surface_layer_id)) ExtendDamageForRenderSurface(layer, &damage_rect); @@ -197,9 +197,9 @@ gfx::RectF DamageTracker::TrackDamageFromActiveLayers( return damage_rect; } -gfx::RectF DamageTracker::TrackDamageFromSurfaceMask( +gfx::Rect DamageTracker::TrackDamageFromSurfaceMask( LayerImpl* target_surface_mask_layer) { - gfx::RectF damage_rect = gfx::RectF(); + gfx::Rect damage_rect; if (!target_surface_mask_layer) return damage_rect; @@ -209,8 +209,7 @@ gfx::RectF DamageTracker::TrackDamageFromSurfaceMask( // expected to be a common case. if (target_surface_mask_layer->LayerPropertyChanged() || !target_surface_mask_layer->update_rect().IsEmpty()) { - damage_rect = gfx::RectF(gfx::PointF(), - target_surface_mask_layer->bounds()); + damage_rect = gfx::Rect(target_surface_mask_layer->bounds()); } return damage_rect; @@ -220,12 +219,12 @@ void DamageTracker::PrepareRectHistoryForUpdate() { mailboxId_++; } -gfx::RectF DamageTracker::TrackDamageFromLeftoverRects() { +gfx::Rect DamageTracker::TrackDamageFromLeftoverRects() { // After computing damage for all active layers, any leftover items in the // current rect history correspond to layers/surfaces that no longer exist. // So, these regions are now exposed on the target surface. - gfx::RectF damage_rect = gfx::RectF(); + gfx::Rect damage_rect; SortedRectMap::iterator cur_pos = rect_history_.begin(); SortedRectMap::iterator copy_pos = cur_pos; @@ -261,7 +260,7 @@ gfx::RectF DamageTracker::TrackDamageFromLeftoverRects() { } void DamageTracker::ExtendDamageForLayer(LayerImpl* layer, - gfx::RectF* target_damage_rect) { + gfx::Rect* target_damage_rect) { // There are two ways that a layer can damage a region of the target surface: // 1. Property change (e.g. opacity, position, transforms): // - the entire region of the layer itself damages the surface. @@ -282,11 +281,10 @@ void DamageTracker::ExtendDamageForLayer(LayerImpl* layer, bool layer_is_new = false; RectMapData& data = RectDataForLayer(layer->id(), &layer_is_new); - gfx::RectF old_rect_in_target_space = data.rect_; + gfx::Rect old_rect_in_target_space = data.rect_; - gfx::RectF rect_in_target_space = MathUtil::MapClippedRect( - layer->draw_transform(), - gfx::RectF(gfx::PointF(), layer->content_bounds())); + gfx::Rect rect_in_target_space = MathUtil::MapEnclosingClippedRect( + layer->draw_transform(), gfx::Rect(layer->content_bounds())); data.Update(rect_in_target_space, mailboxId_); if (layer_is_new || layer->LayerPropertyChanged()) { @@ -300,16 +298,17 @@ void DamageTracker::ExtendDamageForLayer(LayerImpl* layer, } else if (!layer->update_rect().IsEmpty()) { // If the layer properties haven't changed, then the the target surface is // only affected by the layer's update area, which could be empty. - gfx::RectF update_content_rect = + gfx::Rect update_content_rect = layer->LayerRectToContentRect(layer->update_rect()); - gfx::RectF update_rect_in_target_space = - MathUtil::MapClippedRect(layer->draw_transform(), update_content_rect); + gfx::Rect update_rect_in_target_space = MathUtil::MapEnclosingClippedRect( + layer->draw_transform(), update_content_rect); target_damage_rect->Union(update_rect_in_target_space); } } void DamageTracker::ExtendDamageForRenderSurface( - LayerImpl* layer, gfx::RectF* target_damage_rect) { + LayerImpl* layer, + gfx::Rect* target_damage_rect) { // There are two ways a "descendant surface" can damage regions of the "target // surface": // 1. Property change: @@ -329,14 +328,14 @@ void DamageTracker::ExtendDamageForRenderSurface( bool surface_is_new = false; RectMapData& data = RectDataForLayer(layer->id(), &surface_is_new); - gfx::RectF old_surface_rect = data.rect_; + gfx::Rect old_surface_rect = data.rect_; // The drawableContextRect() already includes the replica if it exists. - gfx::RectF surface_rect_in_target_space = - render_surface->DrawableContentRect(); + gfx::Rect surface_rect_in_target_space = + gfx::ToEnclosingRect(render_surface->DrawableContentRect()); data.Update(surface_rect_in_target_space, mailboxId_); - gfx::RectF damage_rect_in_local_space; + gfx::Rect damage_rect_in_local_space; if (surface_is_new || render_surface->SurfacePropertyChanged()) { // The entire surface contributes damage. damage_rect_in_local_space = render_surface->content_rect(); @@ -353,14 +352,14 @@ void DamageTracker::ExtendDamageForRenderSurface( // its reflection if needed. if (!damage_rect_in_local_space.IsEmpty()) { const gfx::Transform& draw_transform = render_surface->draw_transform(); - gfx::RectF damage_rect_in_target_space = - MathUtil::MapClippedRect(draw_transform, damage_rect_in_local_space); + gfx::Rect damage_rect_in_target_space = MathUtil::MapEnclosingClippedRect( + draw_transform, damage_rect_in_local_space); target_damage_rect->Union(damage_rect_in_target_space); if (layer->replica_layer()) { const gfx::Transform& replica_draw_transform = render_surface->replica_draw_transform(); - target_damage_rect->Union(MathUtil::MapClippedRect( + target_damage_rect->Union(MathUtil::MapEnclosingClippedRect( replica_draw_transform, damage_rect_in_local_space)); } } @@ -376,9 +375,8 @@ void DamageTracker::ExtendDamageForRenderSurface( const gfx::Transform& replica_draw_transform = render_surface->replica_draw_transform(); - gfx::RectF replica_mask_layer_rect = MathUtil::MapClippedRect( - replica_draw_transform, - gfx::RectF(gfx::PointF(), replica_mask_layer->bounds())); + gfx::Rect replica_mask_layer_rect = MathUtil::MapEnclosingClippedRect( + replica_draw_transform, gfx::Rect(replica_mask_layer->bounds())); data.Update(replica_mask_layer_rect, mailboxId_); // In the current implementation, a change in the replica mask damages the diff --git a/cc/trees/damage_tracker.h b/cc/trees/damage_tracker.h index 3809447..37c4c6e 100644 --- a/cc/trees/damage_tracker.h +++ b/cc/trees/damage_tracker.h @@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "cc/base/cc_export.h" #include "cc/layers/layer_lists.h" -#include "ui/gfx/rect_f.h" +#include "ui/gfx/rect.h" class SkImageFilter; @@ -31,8 +31,8 @@ class CC_EXPORT DamageTracker { static scoped_ptr<DamageTracker> Create(); ~DamageTracker(); - void DidDrawDamagedArea() { current_damage_rect_ = gfx::RectF(); } - void AddDamageNextUpdate(const gfx::RectF& dmg) { + void DidDrawDamagedArea() { current_damage_rect_ = gfx::Rect(); } + void AddDamageNextUpdate(const gfx::Rect& dmg) { current_damage_rect_.Union(dmg); } void UpdateDamageTrackingState( @@ -43,28 +43,27 @@ class CC_EXPORT DamageTracker { LayerImpl* target_surface_mask_layer, const FilterOperations& filters); - gfx::RectF current_damage_rect() { return current_damage_rect_; } + gfx::Rect current_damage_rect() { return current_damage_rect_; } private: DamageTracker(); - gfx::RectF TrackDamageFromActiveLayers( - const LayerImplList& layer_list, - int target_surface_layer_id); - gfx::RectF TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); - gfx::RectF TrackDamageFromLeftoverRects(); + gfx::Rect TrackDamageFromActiveLayers(const LayerImplList& layer_list, + int target_surface_layer_id); + gfx::Rect TrackDamageFromSurfaceMask(LayerImpl* target_surface_mask_layer); + gfx::Rect TrackDamageFromLeftoverRects(); void PrepareRectHistoryForUpdate(); // These helper functions are used only in TrackDamageFromActiveLayers(). - void ExtendDamageForLayer(LayerImpl* layer, gfx::RectF* target_damage_rect); + void ExtendDamageForLayer(LayerImpl* layer, gfx::Rect* target_damage_rect); void ExtendDamageForRenderSurface(LayerImpl* layer, - gfx::RectF* target_damage_rect); + gfx::Rect* target_damage_rect); struct RectMapData { RectMapData() : layer_id_(0), mailboxId_(0) {} explicit RectMapData(int layer_id) : layer_id_(layer_id), mailboxId_(0) {} - void Update(const gfx::RectF& rect, unsigned int mailboxId) { + void Update(const gfx::Rect& rect, unsigned int mailboxId) { mailboxId_ = mailboxId; rect_ = rect; } @@ -75,7 +74,7 @@ class CC_EXPORT DamageTracker { int layer_id_; unsigned int mailboxId_; - gfx::RectF rect_; + gfx::Rect rect_; }; typedef std::vector<RectMapData> SortedRectMap; @@ -84,7 +83,7 @@ class CC_EXPORT DamageTracker { SortedRectMap rect_history_; unsigned int mailboxId_; - gfx::RectF current_damage_rect_; + gfx::Rect current_damage_rect_; DISALLOW_COPY_AND_ASSIGN(DamageTracker); }; diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc index 2dd52ca..9476955 100644 --- a/cc/trees/damage_tracker_unittest.cc +++ b/cc/trees/damage_tracker_unittest.cc @@ -16,7 +16,8 @@ #include "cc/trees/single_thread_proxy.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/effects/SkBlurImageFilter.h" -#include "ui/gfx/quad_f.h" +#include "ui/gfx/geometry/quad_f.h" +#include "ui/gfx/geometry/rect_conversions.h" namespace cc { namespace { @@ -196,10 +197,10 @@ TEST_F(DamageTrackerTest, SanityCheckTestTreeWithOneSurface) { EXPECT_EQ(1, root->render_surface()->layer_list()[0]->id()); EXPECT_EQ(2, root->render_surface()->layer_list()[1]->id()); - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 500.f, 500.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, SanityCheckTestTreeWithTwoSurfaces) { @@ -210,10 +211,10 @@ TEST_F(DamageTrackerTest, SanityCheckTestTreeWithTwoSurfaces) { LayerImpl* child1 = root->children()[0]; LayerImpl* child2 = root->children()[1]; - gfx::RectF child_damage_rect = - child1->render_surface()->damage_tracker()->current_damage_rect(); - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect child_damage_rect = + child1->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); ASSERT_TRUE(child1->render_surface()); EXPECT_FALSE(child2->render_surface()); @@ -222,8 +223,9 @@ TEST_F(DamageTrackerTest, SanityCheckTestTreeWithTwoSurfaces) { // The render surface for child1 only has a content_rect that encloses // grand_child1 and grand_child2, because child1 does not draw content. - EXPECT_FLOAT_RECT_EQ(gfx::RectF(190.f, 190.f, 16.f, 18.f), child_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 500.f, 500.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), + child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { @@ -238,9 +240,10 @@ TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { // Damage position on the surface should be: position of update_rect (10, 11) // relative to the child (100, 100). - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(110.f, 111.f, 12.f, 13.f), root_damage_rect); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), + root_damage_rect.ToString()); // CASE 2: The same update rect twice in a row still produces the same // damage. @@ -249,7 +252,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { EmulateDrawingOneFrame(root.get()); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(110.f, 111.f, 12.f, 13.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), + root_damage_rect.ToString()); // CASE 3: Setting a different update rect should cause damage on the new // update region, but no additional exposed old region. @@ -261,7 +265,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { // relative to the child (100, 100). root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(120.f, 125.f, 1.f, 2.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { @@ -281,10 +285,10 @@ TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { ASSERT_EQ(2u, root->render_surface()->layer_list().size()); // Damage should be the entire child layer in target_surface space. - gfx::RectF expected_rect = gfx::RectF(100.f, 100.f, 30.f, 30.f); - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); + gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); // CASE 2: If a layer moves due to property change, it damages both the new // location and the old (exposed) location. The old location is the @@ -304,7 +308,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { EmulateDrawingOneFrame(root.get()); // Expect damage to be the combination of the previous one and the new one. - expected_rect.Union(gfx::RectF(200, 230, 30, 30)); + expected_rect.Union(gfx::Rect(200, 230, 30, 30)); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); @@ -327,9 +331,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { // Sanity check that the layer actually moved to (85, 85), damaging its old // location and new location. - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(85.f, 85.f, 45.f, 45.f), root_damage_rect); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString()); // With the anchor on the layer's center, now we can test the rotation more // intuitively, since it applies about the layer's anchor. @@ -343,11 +347,11 @@ TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { // region. float expected_width = 30.f * sqrt(2.f); float expected_position = 100.f - 0.5f * expected_width; - gfx::RectF expected_rect( - expected_position, expected_position, expected_width, expected_width); + gfx::Rect expected_rect = gfx::ToEnclosingRect(gfx::RectF( + expected_position, expected_position, expected_width, expected_width)); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); + EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForPerspectiveClippedLayer) { @@ -394,10 +398,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForPerspectiveClippedLayer) { // The expected damage should cover the entire root surface (500x500), but we // don't care whether the damage rect was clamped or is larger than the // surface for this test. - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); - gfx::RectF damage_we_care_about = - gfx::RectF(gfx::PointF(), gfx::SizeF(500.f, 500.f)); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500)); EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); } @@ -424,22 +427,21 @@ TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { // Damage position on the surface should be: position of update_rect (1, 2) // relative to the child (300, 300), but expanded by the blur outsets. - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); - gfx::RectF expected_damage_rect = - gfx::RectF(301.f, 302.f, 3.f, 4.f); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect expected_damage_rect = gfx::Rect(301, 302, 3, 4); expected_damage_rect.Inset(-outset_left, -outset_top, -outset_right, -outset_bottom); - EXPECT_FLOAT_RECT_EQ(expected_damage_rect, root_damage_rect); + EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); LayerImpl* child = root->children()[0]; - gfx::RectF root_damage_rect, child_damage_rect; + gfx::Rect root_damage_rect, child_damage_rect; // Allow us to set damage on child too. child->SetDrawsContent(true); @@ -458,20 +460,22 @@ TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { root->render_surface()->damage_tracker()->current_damage_rect(); child_damage_rect = child->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(100.f, 100.f, 30.f, 30.f), root_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 30.f, 30.f), child_damage_rect); + EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), + root_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); // CASE 1: Setting the update rect should damage the whole surface (for now) ClearDamageForAllSurfaces(root.get()); - child->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 1.f)); + child->SetUpdateRect(gfx::RectF(1.f, 1.f)); EmulateDrawingOneFrame(root.get()); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); child_damage_rect = child->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(100.f, 100.f, 30.f, 30.f), root_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 30.f, 30.f), child_damage_rect); + EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), + root_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(30.f, 30.f).ToString(), child_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { @@ -499,19 +503,18 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { root->SetUpdateRect(gfx::RectF(297.f, 297.f, 2.f, 2.f)); EmulateDrawingOneFrame(root.get()); - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); // Damage position on the surface should be a composition of the damage on // the root and on child2. Damage on the root should be: position of // update_rect (297, 297), but expanded by the blur outsets. - gfx::RectF expected_damage_rect = - gfx::RectF(297.f, 297.f, 2.f, 2.f); + gfx::Rect expected_damage_rect = gfx::Rect(297, 297, 2, 2); expected_damage_rect.Inset(-outset_left, -outset_top, -outset_right, -outset_bottom); - EXPECT_FLOAT_RECT_EQ(expected_damage_rect, root_damage_rect); + EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); // CASE 2: Setting the update rect should cause the corresponding damage to // the surface, blurred based on the size of the child's background @@ -526,14 +529,13 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { // Damage position on the surface should be a composition of the damage on // the root and on child2. Damage on the root should be: position of // update_rect (297, 297), but expanded on the left/top by the blur outsets. - expected_damage_rect = - gfx::RectF(297.f, 297.f, 30.f, 30.f); + expected_damage_rect = gfx::Rect(297, 297, 30, 30); expected_damage_rect.Inset(-outset_left, -outset_top, 0, 0); - EXPECT_FLOAT_RECT_EQ(expected_damage_rect, root_damage_rect); + EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); // CASE 3: Setting this update rect outside the blurred content_bounds of the // blurred child1 will not cause it to be expanded. @@ -545,10 +547,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { root->render_surface()->damage_tracker()->current_damage_rect(); // Damage on the root should be: position of update_rect (30, 30), not // expanded. - expected_damage_rect = - gfx::RectF(30.f, 30.f, 2.f, 2.f); + expected_damage_rect = gfx::Rect(30, 30, 2, 2); - EXPECT_FLOAT_RECT_EQ(expected_damage_rect, root_damage_rect); + EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); // CASE 4: Setting this update rect inside the blurred content_bounds but // outside the original content_bounds of the blurred child1 will @@ -562,14 +563,13 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { // Damage on the root should be: position of update_rect (99, 99), expanded by // the blurring on child1, but since it is 1 pixel outside the layer, the // expanding should be reduced by 1. - expected_damage_rect = - gfx::RectF(99.f, 99.f, 1.f, 1.f); + expected_damage_rect = gfx::Rect(99, 99, 1, 1); expected_damage_rect.Inset(-outset_left + 1, -outset_top + 1, -outset_right, -outset_bottom); - EXPECT_FLOAT_RECT_EQ(expected_damage_rect, root_damage_rect); + EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); // CASE 5: Setting the update rect on child2, which is above child1, will // not get blurred by child1, so it does not need to get expanded. @@ -581,10 +581,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { root->render_surface()->damage_tracker()->current_damage_rect(); // Damage on child2 should be: position of update_rect offset by the child's // position (11, 11), and not expanded by anything. - expected_damage_rect = - gfx::RectF(11.f, 11.f, 1.f, 1.f); + expected_damage_rect = gfx::Rect(11, 11, 1, 1); - EXPECT_FLOAT_RECT_EQ(expected_damage_rect, root_damage_rect); + EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); // CASE 6: Setting the update rect on child1 will also blur the damage, so // that any pixels needed for the blur are redrawn in the current @@ -597,14 +596,13 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { root->render_surface()->damage_tracker()->current_damage_rect(); // Damage on child1 should be: position of update_rect offset by the child's // position (100, 100), and expanded by the damage. - expected_damage_rect = - gfx::RectF(100.f, 100.f, 1.f, 1.f); + expected_damage_rect = gfx::Rect(100, 100, 1, 1); expected_damage_rect.Inset(-outset_left, -outset_top, -outset_right, -outset_bottom); - EXPECT_FLOAT_RECT_EQ(expected_damage_rect, root_damage_rect); + EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) { @@ -630,9 +628,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) { // surfaces are tested elsewhere. ASSERT_EQ(3u, root->render_surface()->layer_list().size()); - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(400.f, 380.f, 6.f, 8.f), root_damage_rect); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + EXPECT_EQ(gfx::Rect(400, 380, 6, 8).ToString(), root_damage_rect.ToString()); // CASE 2: If the layer is removed, its entire old layer becomes exposed, not // just the last update rect. @@ -653,7 +651,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) { root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(100.f, 100.f, 30.f, 30.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), + root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) { @@ -685,9 +684,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) { // surfaces are tested elsewhere. ASSERT_EQ(3u, root->render_surface()->layer_list().size()); - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(400.f, 380.f, 6.f, 8.f), root_damage_rect); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + EXPECT_EQ(gfx::Rect(400, 380, 6, 8).ToString(), root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { @@ -711,16 +710,16 @@ TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { EmulateDrawingOneFrame(root.get()); // Damaging two layers simultaneously should cause combined damage. - // - child1 update rect in surface space: gfx::RectF(100.f, 100.f, 1.f, 2.f); - // - child2 update rect in surface space: gfx::RectF(400.f, 380.f, 3.f, 4.f); + // - child1 update rect in surface space: gfx::Rect(100, 100, 1, 2); + // - child2 update rect in surface space: gfx::Rect(400, 380, 3, 4); ClearDamageForAllSurfaces(root.get()); child1->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 2.f)); child2->SetUpdateRect(gfx::RectF(0.f, 0.f, 3.f, 4.f)); EmulateDrawingOneFrame(root.get()); - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ( - gfx::RectF(100.f, 100.f, 303.f, 284.f), root_damage_rect); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + EXPECT_EQ(gfx::Rect(100, 100, 303, 284).ToString(), + root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { @@ -728,8 +727,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { LayerImpl* child1 = root->children()[0]; LayerImpl* child2 = root->children()[1]; LayerImpl* grand_child1 = root->children()[0]->children()[0]; - gfx::RectF child_damage_rect; - gfx::RectF root_damage_rect; + gfx::Rect child_damage_rect; + gfx::Rect root_damage_rect; // CASE 1: Damage to a descendant surface should propagate properly to // ancestor surface. @@ -740,15 +739,15 @@ TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { child1->render_surface()->damage_tracker()->current_damage_rect(); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(200.f, 200.f, 6.f, 8.f), child_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(300.f, 300.f, 6.f, 8.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString()); // CASE 2: Same as previous case, but with additional damage elsewhere that // should be properly unioned. // - child1 surface damage in root surface space: - // gfx::RectF(300.f, 300.f, 6.f, 8.f); + // gfx::Rect(300, 300, 6, 8); // - child2 damage in root surface space: - // gfx::RectF(11.f, 11.f, 18.f, 18.f); + // gfx::Rect(11, 11, 18, 18); ClearDamageForAllSurfaces(root.get()); grand_child1->SetOpacity(0.7f); child2->SetOpacity(0.7f); @@ -757,8 +756,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { child1->render_surface()->damage_tracker()->current_damage_rect(); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(200.f, 200.f, 6.f, 8.f), child_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(11.f, 11.f, 295.f, 297.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(), + root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantLayer) { @@ -772,8 +772,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantLayer) { scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); LayerImpl* child1 = root->children()[0]; LayerImpl* grand_child1 = root->children()[0]->children()[0]; - gfx::RectF child_damage_rect; - gfx::RectF root_damage_rect; + gfx::Rect child_damage_rect; + gfx::Rect root_damage_rect; ClearDamageForAllSurfaces(root.get()); grand_child1->SetPosition(gfx::PointF(195.f, 205.f)); @@ -785,12 +785,14 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantLayer) { // The new surface bounds should be damaged entirely, even though only one of // the layers changed. - EXPECT_FLOAT_RECT_EQ(gfx::RectF(190.f, 190.f, 11.f, 23.f), child_damage_rect); + EXPECT_EQ(gfx::Rect(190, 190, 11, 23).ToString(), + child_damage_rect.ToString()); // Damage to the root surface should be the union of child1's *entire* render // surface (in target space), and its old exposed area (also in target // space). - EXPECT_FLOAT_RECT_EQ(gfx::RectF(290.f, 290.f, 16.f, 23.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(290, 290, 16, 23).ToString(), + root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromAncestorLayer) { @@ -807,8 +809,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromAncestorLayer) { scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); LayerImpl* child1 = root->children()[0]; - gfx::RectF child_damage_rect; - gfx::RectF root_damage_rect; + gfx::Rect child_damage_rect; + gfx::Rect root_damage_rect; ClearDamageForAllSurfaces(root.get()); child1->SetPosition(gfx::PointF(50.f, 50.f)); @@ -819,20 +821,22 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromAncestorLayer) { root->render_surface()->damage_tracker()->current_damage_rect(); // The new surface bounds should be damaged entirely. - EXPECT_FLOAT_RECT_EQ(gfx::RectF(190.f, 190.f, 16.f, 18.f), child_damage_rect); + EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), + child_damage_rect.ToString()); // The entire child1 surface and the old exposed child1 surface should damage // the root surface. - // - old child1 surface in target space: gfx::RectF(290.f, 290.f, 16.f, 18.f) - // - new child1 surface in target space: gfx::RectF(240.f, 240.f, 16.f, 18.f) - EXPECT_FLOAT_RECT_EQ(gfx::RectF(240.f, 240.f, 66.f, 68.f), root_damage_rect); + // - old child1 surface in target space: gfx::Rect(290, 290, 16, 18) + // - new child1 surface in target space: gfx::Rect(240, 240, 16, 18) + EXPECT_EQ(gfx::Rect(240, 240, 66, 68).ToString(), + root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); LayerImpl* child1 = root->children()[0]; - gfx::RectF child_damage_rect; - gfx::RectF root_damage_rect; + gfx::Rect child_damage_rect; + gfx::Rect root_damage_rect; // CASE 1: If a descendant surface disappears, its entire old area becomes // exposed. @@ -847,7 +851,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(290.f, 290.f, 16.f, 18.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), + root_damage_rect.ToString()); // CASE 2: If a descendant surface appears, its entire old area becomes // exposed. @@ -875,15 +880,17 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { child1->render_surface()->damage_tracker()->current_damage_rect(); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(190.f, 190.f, 16.f, 18.f), child_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(290.f, 290.f, 16.f, 18.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), + child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), + root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyNoDamageWhenNothingChanged) { scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); LayerImpl* child1 = root->children()[0]; - gfx::RectF child_damage_rect; - gfx::RectF root_damage_rect; + gfx::Rect child_damage_rect; + gfx::Rect root_damage_rect; // CASE 1: If nothing changes, the damage rect should be empty. // @@ -912,8 +919,8 @@ TEST_F(DamageTrackerTest, VerifyNoDamageWhenNothingChanged) { TEST_F(DamageTrackerTest, VerifyNoDamageForUpdateRectThatDoesNotDrawContent) { scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); LayerImpl* child1 = root->children()[0]; - gfx::RectF child_damage_rect; - gfx::RectF root_damage_rect; + gfx::Rect child_damage_rect; + gfx::Rect root_damage_rect; // In our specific tree, the update rect of child1 should not cause any // damage to any surface because it does not actually draw content. @@ -969,19 +976,19 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplica) { } EmulateDrawingOneFrame(root.get()); - gfx::RectF grand_child_damage_rect = - grand_child1->render_surface()->damage_tracker()-> - current_damage_rect(); - gfx::RectF child_damage_rect = - child1->render_surface()->damage_tracker()->current_damage_rect(); - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect grand_child_damage_rect = + grand_child1->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect child_damage_rect = + child1->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); // The grand_child surface damage should not include its own replica. The // child surface damage should include the normal and replica surfaces. - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 6.f, 8.f), grand_child_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(194.f, 200.f, 12.f, 8.f), child_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(294.f, 300.f, 12.f, 8.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(194, 200, 12, 8).ToString(), + child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(294, 300, 12, 8).ToString(), root_damage_rect.ToString()); // CASE 2: moving the descendant surface should cause both the original and // reflected areas to be damaged on the target. @@ -1004,11 +1011,13 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplica) { // The child surface damage should include normal and replica surfaces for // both old and new locations. - // - old location in target space: gfx::RectF(194.f, 200.f, 12.f, 8.f) - // - new location in target space: gfx::RectF(189.f, 205.f, 12.f, 8.f) - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 6.f, 8.f), grand_child_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(189.f, 200.f, 17.f, 13.f), child_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(289.f, 300.f, 17.f, 13.f), root_damage_rect); + // - old location in target space: gfx::Rect(194, 200, 12, 8) + // - new location in target space: gfx::Rect(189, 205, 12, 8) + EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(189, 200, 17, 13).ToString(), + child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(289, 300, 17, 13).ToString(), + root_damage_rect.ToString()); // CASE 3: removing the reflection should cause the entire region including // reflection to damage the target surface. @@ -1026,8 +1035,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplica) { root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(189.f, 205.f, 12.f, 8.f), child_damage_rect); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(289.f, 305.f, 12.f, 8.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(189, 205, 12, 8).ToString(), + child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(289, 305, 12, 8).ToString(), root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForMask) { @@ -1074,9 +1084,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { ClearDamageForAllSurfaces(root.get()); mask_layer->SetUpdateRect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); EmulateDrawingOneFrame(root.get()); - gfx::RectF child_damage_rect = - child->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 30.f, 30.f), child_damage_rect); + gfx::Rect child_damage_rect = + child->render_surface()->damage_tracker()->current_damage_rect(); + EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); // CASE 2: a property change on the mask layer should damage the entire // target surface. @@ -1096,7 +1106,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { EmulateDrawingOneFrame(root.get()); child_damage_rect = child->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 30.f, 30.f), child_damage_rect); + EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); // CASE 3: removing the mask also damages the entire target surface. // @@ -1120,7 +1130,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { child_damage_rect = child->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 30.f, 30.f), child_damage_rect); + EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForReplicaMask) { @@ -1169,14 +1179,13 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplicaMask) { replica_mask_layer->SetStackingOrderChanged(true); EmulateDrawingOneFrame(root.get()); - gfx::RectF grand_child_damage_rect = - grand_child1->render_surface()->damage_tracker()-> - current_damage_rect(); - gfx::RectF child_damage_rect = - child1->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect grand_child_damage_rect = + grand_child1->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect child_damage_rect = + child1->render_surface()->damage_tracker()->current_damage_rect(); EXPECT_TRUE(grand_child_damage_rect.IsEmpty()); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(194.f, 200.f, 6.f, 8.f), child_damage_rect); + EXPECT_EQ(gfx::Rect(194, 200, 6, 8).ToString(), child_damage_rect.ToString()); // CASE 2: removing the replica mask damages only the reflected region on the // target surface. @@ -1192,7 +1201,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplicaMask) { child1->render_surface()->damage_tracker()->current_damage_rect(); EXPECT_TRUE(grand_child_damage_rect.IsEmpty()); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(194.f, 200.f, 6.f, 8.f), child_damage_rect); + EXPECT_EQ(gfx::Rect(194, 200, 6, 8).ToString(), child_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForReplicaMaskWithAnchor) { @@ -1247,9 +1256,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplicaMaskWithAnchor) { EmulateDrawingOneFrame(root.get()); - gfx::RectF child_damage_rect = - child1->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(206.f, 200.f, 6.f, 8.f), child_damage_rect); + gfx::Rect child_damage_rect = + child1->render_surface()->damage_tracker()->current_damage_rect(); + EXPECT_EQ(gfx::Rect(206, 200, 6, 8).ToString(), child_damage_rect.ToString()); } TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { @@ -1262,25 +1271,24 @@ TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { ClearDamageForAllSurfaces(root.get()); child->SetUpdateRect(gfx::RectF(10, 11, 12, 13)); root->render_surface()->damage_tracker()->AddDamageNextUpdate( - gfx::RectF(15, 16, 32, 33)); + gfx::Rect(15, 16, 32, 33)); EmulateDrawingOneFrame(root.get()); - gfx::RectF root_damage_rect = + gfx::Rect root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ( - gfx::UnionRects(gfx::RectF(15, 16, 32, 33), - gfx::RectF(100+10, 100+11, 12, 13)), - root_damage_rect); + EXPECT_EQ(gfx::UnionRects(gfx::Rect(15, 16, 32, 33), + gfx::Rect(100 + 10, 100 + 11, 12, 13)).ToString(), + root_damage_rect.ToString()); // Case 2: An additional sanity check that adding damage works even when // nothing on the layer tree changed. // ClearDamageForAllSurfaces(root.get()); root->render_surface()->damage_tracker()->AddDamageNextUpdate( - gfx::RectF(30, 31, 14, 15)); + gfx::Rect(30, 31, 14, 15)); EmulateDrawingOneFrame(root.get()); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(30, 31, 14, 15), root_damage_rect); + EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); } TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { @@ -1302,8 +1310,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { NULL, FilterOperations()); - gfx::RectF damage_rect = - target_surface->damage_tracker()->current_damage_rect(); + gfx::Rect damage_rect = + target_surface->damage_tracker()->current_damage_rect(); EXPECT_TRUE(damage_rect.IsEmpty()); } @@ -1314,13 +1322,13 @@ TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { LayerImpl* child = root->children()[0]; ClearDamageForAllSurfaces(root.get()); - child->SetUpdateRect(gfx::RectF(10.f, 11.f, 1.f, 2.f)); + child->SetUpdateRect(gfx::Rect(10.f, 11.f, 1.f, 2.f)); EmulateDrawingOneFrame(root.get()); // Sanity check damage after the first frame; this isnt the actual test yet. - gfx::RectF root_damage_rect = - root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(110.f, 111.f, 1.f, 2.f), root_damage_rect); + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + EXPECT_EQ(gfx::Rect(110, 111, 1, 2).ToString(), root_damage_rect.ToString()); // New damage, without having cleared the previous damage, should be unioned // to the previous one. @@ -1328,7 +1336,8 @@ TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { EmulateDrawingOneFrame(root.get()); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(110.f, 111.f, 11.f, 16.f), root_damage_rect); + EXPECT_EQ(gfx::Rect(110, 111, 11, 16).ToString(), + root_damage_rect.ToString()); // If we notify the damage tracker that we drew the damaged area, then damage // should be emptied. @@ -1345,5 +1354,37 @@ TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { EXPECT_TRUE(root_damage_rect.IsEmpty()); } +TEST_F(DamageTrackerTest, HugeDamageRect) { + // This number is so large that we start losting floating point accuracy. + const int kBigNumber = 900000000; + // Walk over a range to find floating point inaccuracy boundaries that move + // toward the wrong direction. + const int kRange = 5000; + + for (int i = 0; i < kRange; ++i) { + scoped_ptr<LayerImpl> root = CreateTestTreeWithOneSurface(); + LayerImpl* child = root->children()[0]; + + gfx::Transform transform; + transform.Translate(-kBigNumber, -kBigNumber); + + // The child layer covers (0, 0, i, i) of the viewport, + // but has a huge negative position. + child->SetPosition(gfx::PointF()); + child->SetBounds(gfx::Size(kBigNumber + i, kBigNumber + i)); + child->SetContentBounds(gfx::Size(kBigNumber + i, kBigNumber + i)); + child->SetTransform(transform); + EmulateDrawingOneFrame(root.get()); + + // The expected damage should cover the visible part of the child layer, + // which is (0, 0, i, i) in the viewport. + gfx::Rect root_damage_rect = + root->render_surface()->damage_tracker()->current_damage_rect(); + gfx::Rect damage_we_care_about = gfx::Rect(i, i); + EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); + EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); + } +} + } // namespace } // namespace cc diff --git a/cc/trees/layer_tree_host_unittest_delegated.cc b/cc/trees/layer_tree_host_unittest_delegated.cc index 6ba1df4..7cf8e69 100644 --- a/cc/trees/layer_tree_host_unittest_delegated.cc +++ b/cc/trees/layer_tree_host_unittest_delegated.cc @@ -257,7 +257,7 @@ class LayerTreeHostDelegatedTestCaseSingleDelegatedLayer virtual void SetupTree() OVERRIDE { root_ = Layer::Create(); root_->SetAnchorPoint(gfx::PointF()); - root_->SetBounds(gfx::Size(10, 10)); + root_->SetBounds(gfx::Size(15, 15)); layer_tree_host()->SetRootLayer(root_); LayerTreeHostDelegatedTest::SetupTree(); @@ -720,7 +720,7 @@ class LayerTreeHostDelegatedTestLayerUsesFrameDamage if (!first_draw_for_source_frame_) return draw_result; - gfx::RectF damage_rect; + gfx::Rect damage_rect; if (!frame->has_no_damage) { damage_rect = frame->render_passes.back()->damage_rect; } else { @@ -731,85 +731,66 @@ class LayerTreeHostDelegatedTestLayerUsesFrameDamage switch (host_impl->active_tree()->source_frame_number()) { case 0: // First frame is damaged because of viewport resize. - EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(15, 15).ToString(), damage_rect.ToString()); break; case 1: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 2: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 3: - EXPECT_EQ(gfx::RectF(1.f, 1.f, 5.f, 3.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(1, 1, 5, 3).ToString(), damage_rect.ToString()); break; case 4: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 0.f, 0.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 5: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 6: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 0.f, 0.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 7: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 6.f, 6.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(6, 6).ToString(), damage_rect.ToString()); break; case 8: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 0.f, 0.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 9: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 6.f, 6.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(6, 6).ToString(), damage_rect.ToString()); break; case 10: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 0.f, 0.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 11: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 12: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 0.f, 0.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 13: - EXPECT_EQ(gfx::RectF(2.f, 2.f, 4.f, 4.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(2, 2, 4, 4).ToString(), damage_rect.ToString()); break; case 14: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 0.f, 0.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect().ToString(), damage_rect.ToString()); break; case 15: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 16: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 17: - EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(10, 10).ToString(), damage_rect.ToString()); break; case 18: - EXPECT_EQ(gfx::UnionRects(gfx::RectF(5.f, 0.f, 10.f, 10.f), - gfx::RectF(4.f, 0.f, 1.f, 1.f)).ToString(), + EXPECT_EQ(gfx::UnionRects(gfx::Rect(5, 0, 10, 10), + gfx::Rect(4, 0, 1, 1)).ToString(), damage_rect.ToString()); break; case 19: - EXPECT_EQ(gfx::RectF(3.f, 3.f, 6.f, 1.f).ToString(), - damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(3, 3, 6, 1).ToString(), damage_rect.ToString()); EndTest(); break; } diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc index 412e565..81137d9 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc @@ -849,10 +849,8 @@ scoped_ptr<cc::CompositorFrame> MakeDelegatedFrame(float scale_factor, frame->delegated_frame_data.reset(new cc::DelegatedFrameData); scoped_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); - pass->SetNew(cc::RenderPass::Id(1, 1), - gfx::Rect(size), - gfx::RectF(damage), - gfx::Transform()); + pass->SetNew( + cc::RenderPass::Id(1, 1), gfx::Rect(size), damage, gfx::Transform()); frame->delegated_frame_data->render_pass_list.push_back(pass.Pass()); return frame.Pass(); } diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc index 5279d4c..1e1e6df 100644 --- a/content/common/cc_messages.cc +++ b/content/common/cc_messages.cc @@ -402,7 +402,7 @@ bool ParamTraits<cc::RenderPass>::Read( const Message* m, PickleIterator* iter, param_type* p) { cc::RenderPass::Id id(-1, -1); gfx::Rect output_rect; - gfx::RectF damage_rect; + gfx::Rect damage_rect; gfx::Transform transform_to_root_target; bool has_transparent_background; size_t shared_quad_state_list_size; diff --git a/content/common/cc_messages_unittest.cc b/content/common/cc_messages_unittest.cc index fb32ddf..89f510d 100644 --- a/content/common/cc_messages_unittest.cc +++ b/content/common/cc_messages_unittest.cc @@ -437,7 +437,7 @@ TEST_F(CCMessagesTest, AllQuads) { scoped_ptr<RenderPass> pass_in = RenderPass::Create(); pass_in->SetAll(arbitrary_id, arbitrary_rect1, - arbitrary_rectf1, + arbitrary_rect2, arbitrary_matrix, arbitrary_bool1); @@ -458,7 +458,7 @@ TEST_F(CCMessagesTest, AllQuads) { scoped_ptr<RenderPass> pass_cmp = RenderPass::Create(); pass_cmp->SetAll(arbitrary_id, arbitrary_rect1, - arbitrary_rectf1, + arbitrary_rect2, arbitrary_matrix, arbitrary_bool1); @@ -535,7 +535,7 @@ TEST_F(CCMessagesTest, UnusedSharedQuadStates) { scoped_ptr<RenderPass> pass_in = RenderPass::Create(); pass_in->SetAll(RenderPass::Id(1, 1), gfx::Rect(100, 100), - gfx::RectF(), + gfx::Rect(), gfx::Transform(), false); diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc index 6105b7c..4c838a3 100644 --- a/ui/compositor/layer_unittest.cc +++ b/ui/compositor/layer_unittest.cc @@ -1355,10 +1355,8 @@ TEST_F(LayerWithDelegateTest, SetBoundsWhenInvisible) { static scoped_ptr<cc::DelegatedFrameData> MakeFrameData(gfx::Size size) { scoped_ptr<cc::DelegatedFrameData> frame_data(new cc::DelegatedFrameData); scoped_ptr<cc::RenderPass> render_pass(cc::RenderPass::Create()); - render_pass->SetNew(cc::RenderPass::Id(1, 1), - gfx::Rect(size), - gfx::RectF(), - gfx::Transform()); + render_pass->SetNew( + cc::RenderPass::Id(1, 1), gfx::Rect(size), gfx::Rect(), gfx::Transform()); frame_data->render_pass_list.push_back(render_pass.Pass()); return frame_data.Pass(); } |