diff options
author | danakj <danakj@chromium.org> | 2014-10-10 20:24:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-11 03:24:59 +0000 |
commit | 19f0c9e018cc431eb60fa49615192dd091622fef (patch) | |
tree | 486462476d75939d5ca7b2e6d44c1e5badd21711 /cc/layers | |
parent | e22bac1a138a221ce4ba4d121f69827cc65b9a87 (diff) | |
download | chromium_src-19f0c9e018cc431eb60fa49615192dd091622fef.zip chromium_src-19f0c9e018cc431eb60fa49615192dd091622fef.tar.gz chromium_src-19f0c9e018cc431eb60fa49615192dd091622fef.tar.bz2 |
cc: Stop converting update rect from int to float to int.
Layer::SetNeedsDisplay() would turn the int bounds() into a float RectF
just for PictureLayer to turn it back into an int Rect. This is silly.
If PictureLayer is just going to use ints, we might as well use ints
throughout. So convert update_rect_ from a RectF to a Rect.
R=enne
BUG=342848
Review URL: https://codereview.chromium.org/647253002
Cr-Commit-Position: refs/heads/master@{#299233}
Diffstat (limited to 'cc/layers')
-rw-r--r-- | cc/layers/contents_scaling_layer_unittest.cc | 6 | ||||
-rw-r--r-- | cc/layers/delegated_renderer_layer_impl.cc | 4 | ||||
-rw-r--r-- | cc/layers/layer.cc | 12 | ||||
-rw-r--r-- | cc/layers/layer.h | 10 | ||||
-rw-r--r-- | cc/layers/layer_impl.cc | 6 | ||||
-rw-r--r-- | cc/layers/layer_impl.h | 7 | ||||
-rw-r--r-- | cc/layers/layer_impl_unittest.cc | 2 | ||||
-rw-r--r-- | cc/layers/layer_perftest.cc | 2 | ||||
-rw-r--r-- | cc/layers/layer_unittest.cc | 13 | ||||
-rw-r--r-- | cc/layers/picture_layer.cc | 9 | ||||
-rw-r--r-- | cc/layers/picture_layer.h | 2 | ||||
-rw-r--r-- | cc/layers/solid_color_scrollbar_layer.cc | 2 | ||||
-rw-r--r-- | cc/layers/solid_color_scrollbar_layer.h | 2 | ||||
-rw-r--r-- | cc/layers/texture_layer.cc | 2 | ||||
-rw-r--r-- | cc/layers/texture_layer.h | 2 | ||||
-rw-r--r-- | cc/layers/tiled_layer.cc | 5 | ||||
-rw-r--r-- | cc/layers/tiled_layer.h | 2 | ||||
-rw-r--r-- | cc/layers/video_layer_impl.cc | 2 |
18 files changed, 45 insertions, 45 deletions
diff --git a/cc/layers/contents_scaling_layer_unittest.cc b/cc/layers/contents_scaling_layer_unittest.cc index 8cbd517..9865079 100644 --- a/cc/layers/contents_scaling_layer_unittest.cc +++ b/cc/layers/contents_scaling_layer_unittest.cc @@ -18,19 +18,19 @@ class MockContentsScalingLayer : public ContentsScalingLayer { MockContentsScalingLayer() : ContentsScalingLayer() {} - virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) override { + virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect) override { last_needs_display_rect_ = dirty_rect; ContentsScalingLayer::SetNeedsDisplayRect(dirty_rect); } - const gfx::RectF& LastNeedsDisplayRect() const { + const gfx::Rect& LastNeedsDisplayRect() const { return last_needs_display_rect_; } private: virtual ~MockContentsScalingLayer() {} - gfx::RectF last_needs_display_rect_; + gfx::Rect last_needs_display_rect_; }; static void CalcDrawProps(FakeLayerTreeHost* host, float device_scale_factor) { diff --git a/cc/layers/delegated_renderer_layer_impl.cc b/cc/layers/delegated_renderer_layer_impl.cc index 60ad06b..c6692d1 100644 --- a/cc/layers/delegated_renderer_layer_impl.cc +++ b/cc/layers/delegated_renderer_layer_impl.cc @@ -17,6 +17,7 @@ #include "cc/quads/solid_color_draw_quad.h" #include "cc/trees/layer_tree_impl.h" #include "cc/trees/occlusion.h" +#include "ui/gfx/geometry/rect_conversions.h" namespace cc { @@ -149,7 +150,8 @@ void DelegatedRendererLayerImpl::SetFrameData( gfx::RectF damage_in_layer = damage_in_frame; damage_in_layer.Scale(inverse_device_scale_factor_); SetUpdateRect(gfx::IntersectRects( - gfx::UnionRects(update_rect(), damage_in_layer), gfx::Rect(bounds()))); + gfx::UnionRects(update_rect(), gfx::ToEnclosingRect(damage_in_layer)), + gfx::Rect(bounds()))); SetRenderPasses(&render_pass_list); have_render_passes_to_push_ = true; diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index 1d70225..dd71307 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -202,13 +202,13 @@ bool Layer::IsPropertyChangeAllowed() const { return !layer_tree_host_->in_paint_layer_contents(); } -gfx::Rect Layer::LayerRectToContentRect(const gfx::RectF& layer_rect) const { - gfx::RectF content_rect = - gfx::ScaleRect(layer_rect, contents_scale_x(), contents_scale_y()); +gfx::Rect Layer::LayerRectToContentRect(const gfx::Rect& layer_rect) const { + gfx::Rect content_rect = gfx::ScaleToEnclosingRect( + layer_rect, contents_scale_x(), contents_scale_y()); // Intersect with content rect to avoid the extra pixel because for some // values x and y, ceil((x / y) * y) may be x + 1. content_rect.Intersect(gfx::Rect(content_bounds())); - return gfx::ToEnclosingRect(content_rect); + return content_rect; } skia::RefPtr<SkPicture> Layer::GetPicture() const { @@ -795,7 +795,7 @@ void Layer::SetHideLayerAndSubtree(bool hide) { SetNeedsCommit(); } -void Layer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { +void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { if (dirty_rect.IsEmpty()) return; @@ -1003,7 +1003,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { // Reset any state that should be cleared for the next update. stacking_order_changed_ = false; - update_rect_ = gfx::RectF(); + update_rect_ = gfx::Rect(); needs_push_properties_ = false; num_dependents_need_push_properties_ = 0; diff --git a/cc/layers/layer.h b/cc/layers/layer.h index ed0d0cd..dd41669 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -124,8 +124,8 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, Layer* mask_layer() { return mask_layer_.get(); } const Layer* mask_layer() const { return mask_layer_.get(); } - virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect); - void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::RectF(bounds())); } + virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect); + void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::Rect(bounds())); } void SetOpacity(float opacity); float opacity() const { return opacity_; } @@ -422,7 +422,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, virtual ScrollbarLayerInterface* ToScrollbarLayer(); - gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const; + gfx::Rect LayerRectToContentRect(const gfx::Rect& layer_rect) const; virtual skia::RefPtr<SkPicture> GetPicture() const; @@ -430,7 +430,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } - void ResetNeedsDisplayForTesting() { update_rect_ = gfx::RectF(); } + void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } RenderingStatsInstrumentation* rendering_stats_instrumentation() const; @@ -524,7 +524,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, // outside the compositor's control (i.e. plugin layers), this information // is not available and the update rect will remain empty. // Note this rect is in layer space (not content space). - gfx::RectF update_rect_; + gfx::Rect update_rect_; scoped_refptr<Layer> mask_layer_; diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 23c7a0d..dd7b359 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -599,7 +599,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { // Reset any state that should be cleared for the next update. stacking_order_changed_ = false; - update_rect_ = gfx::RectF(); + update_rect_ = gfx::Rect(); needs_push_properties_ = false; num_dependents_need_push_properties_ = 0; } @@ -716,7 +716,7 @@ const char* LayerImpl::LayerTypeAsString() const { void LayerImpl::ResetAllChangeTrackingForSubtree() { layer_property_changed_ = false; - update_rect_ = gfx::RectF(); + update_rect_ = gfx::Rect(); damage_rect_ = gfx::RectF(); if (draw_properties_.render_surface) @@ -1032,7 +1032,7 @@ bool LayerImpl::TransformIsAnimatingOnImplOnly() const { return transform_animation && transform_animation->is_impl_only(); } -void LayerImpl::SetUpdateRect(const gfx::RectF& update_rect) { +void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) { update_rect_ = update_rect; SetNeedsPushProperties(); } diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 02b00d8..b7f3822 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -471,9 +471,8 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, bool transform_is_invertible() const { return transform_is_invertible_; } // Note this rect is in layer space (not content space). - void SetUpdateRect(const gfx::RectF& update_rect); - - const gfx::RectF& update_rect() const { return update_rect_; } + void SetUpdateRect(const gfx::Rect& update_rect); + gfx::Rect update_rect() const { return update_rect_; } void AddDamageRect(const gfx::RectF& damage_rect); @@ -688,7 +687,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, // Rect indicating what was repainted/updated during update. // Note that plugin layers bypass this and leave it empty. // Uses layer (not content) space. - gfx::RectF update_rect_; + gfx::Rect update_rect_; // This rect is in layer space. gfx::RectF damage_rect_; diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc index ccb6c7c..f0d0bb3 100644 --- a/cc/layers/layer_impl_unittest.cc +++ b/cc/layers/layer_impl_unittest.cc @@ -139,7 +139,7 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { // These properties are internal, and should not be considered "change" when // they are used. EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( - root->SetUpdateRect(arbitrary_rect_f)); + root->SetUpdateRect(arbitrary_rect)); EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size)); // Changing these properties affects the entire subtree of layers. diff --git a/cc/layers/layer_perftest.cc b/cc/layers/layer_perftest.cc index e85d95a..c9b8a40 100644 --- a/cc/layers/layer_perftest.cc +++ b/cc/layers/layer_perftest.cc @@ -75,7 +75,7 @@ TEST_F(LayerPerfTest, PushPropertiesTo) { // Properties changed. timer_.Reset(); do { - test_layer->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); + test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); test_layer->SetTransformOrigin(gfx::Point3F(0.f, 0.f, transform_origin_z)); test_layer->SetContentsOpaque(contents_opaque); test_layer->SetDoubleSided(double_sided); diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc index a6ff2e0..4c93d42 100644 --- a/cc/layers/layer_unittest.cc +++ b/cc/layers/layer_unittest.cc @@ -536,10 +536,9 @@ TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) { gfx::Size test_bounds = gfx::Size(501, 508); - gfx::RectF dirty1 = gfx::RectF(10.f, 15.f, 1.f, 2.f); - gfx::RectF dirty2 = gfx::RectF(20.f, 25.f, 3.f, 4.f); - gfx::RectF empty_dirty_rect = gfx::RectF(40.f, 45.f, 0.f, 0.f); - gfx::RectF out_of_bounds_dirty_rect = gfx::RectF(400.f, 405.f, 500.f, 502.f); + gfx::Rect dirty1 = gfx::Rect(10, 15, 1, 2); + gfx::Rect dirty2 = gfx::Rect(20, 25, 3, 4); + gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); // Before anything, test_layer should not be dirty. EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); @@ -649,14 +648,14 @@ TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(test_layer)); - test_layer->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); + test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); test_layer->PushPropertiesTo(impl_layer.get()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), impl_layer->update_rect()); // The LayerImpl's update_rect() should be accumulated here, since we did not // do anything to clear it. - test_layer->SetNeedsDisplayRect(gfx::RectF(10.f, 10.f, 5.f, 5.f)); + test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); test_layer->PushPropertiesTo(impl_layer.get()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 15.f, 15.f), impl_layer->update_rect()); @@ -664,7 +663,7 @@ TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { // If we do clear the LayerImpl side, then the next update_rect() should be // fresh without accumulation. impl_layer->ResetAllChangeTrackingForSubtree(); - test_layer->SetNeedsDisplayRect(gfx::RectF(10.f, 10.f, 5.f, 5.f)); + test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); test_layer->PushPropertiesTo(impl_layer.get()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), impl_layer->update_rect()); diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index befef49..7573471 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -68,12 +68,11 @@ void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { } } -void PictureLayer::SetNeedsDisplayRect(const gfx::RectF& layer_rect) { - gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); - if (!rect.IsEmpty()) { +void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { + if (!layer_rect.IsEmpty()) { // Clamp invalidation to the layer bounds. - rect.Intersect(gfx::Rect(bounds())); - pending_invalidation_.Union(rect); + pending_invalidation_.Union( + gfx::IntersectRects(layer_rect, gfx::Rect(bounds()))); } Layer::SetNeedsDisplayRect(layer_rect); } diff --git a/cc/layers/picture_layer.h b/cc/layers/picture_layer.h index 170ca33..e0f6d15 100644 --- a/cc/layers/picture_layer.h +++ b/cc/layers/picture_layer.h @@ -28,7 +28,7 @@ class CC_EXPORT PictureLayer : public Layer { LayerTreeImpl* tree_impl) override; virtual void SetLayerTreeHost(LayerTreeHost* host) override; virtual void PushPropertiesTo(LayerImpl* layer) override; - virtual void SetNeedsDisplayRect(const gfx::RectF& layer_rect) override; + virtual void SetNeedsDisplayRect(const gfx::Rect& layer_rect) override; virtual bool Update(ResourceUpdateQueue* queue, const OcclusionTracker<Layer>* occlusion) override; virtual void SetIsMask(bool is_mask) override; diff --git a/cc/layers/solid_color_scrollbar_layer.cc b/cc/layers/solid_color_scrollbar_layer.cc index 98b23a4..b2c1ed4 100644 --- a/cc/layers/solid_color_scrollbar_layer.cc +++ b/cc/layers/solid_color_scrollbar_layer.cc @@ -68,7 +68,7 @@ void SolidColorScrollbarLayer::PushScrollClipPropertiesTo(LayerImpl* layer) { clip_layer_id_); } -void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::RectF&) { +void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::Rect& rect) { // Never needs repaint. } diff --git a/cc/layers/solid_color_scrollbar_layer.h b/cc/layers/solid_color_scrollbar_layer.h index de46c54..0e48173 100644 --- a/cc/layers/solid_color_scrollbar_layer.h +++ b/cc/layers/solid_color_scrollbar_layer.h @@ -31,7 +31,7 @@ class CC_EXPORT SolidColorScrollbarLayer : public ScrollbarLayerInterface, virtual void PushPropertiesTo(LayerImpl* layer) override; virtual void PushScrollClipPropertiesTo(LayerImpl* layer) override; - virtual void SetNeedsDisplayRect(const gfx::RectF&) override; + virtual void SetNeedsDisplayRect(const gfx::Rect& rect) override; // ScrollbarLayerInterface virtual int ScrollLayerId() const override; diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc index eee4ea6..122aa3b 100644 --- a/cc/layers/texture_layer.cc +++ b/cc/layers/texture_layer.cc @@ -173,7 +173,7 @@ void TextureLayer::SetTextureMailboxWithoutReleaseCallback( mailbox, release.Pass(), requires_commit, allow_mailbox_reuse); } -void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { +void TextureLayer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { Layer::SetNeedsDisplayRect(dirty_rect); if (rate_limit_context_ && client_ && layer_tree_host() && DrawsContent()) diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h index 735fed9..61791ac 100644 --- a/cc/layers/texture_layer.h +++ b/cc/layers/texture_layer.h @@ -134,7 +134,7 @@ class CC_EXPORT TextureLayer : public Layer { // TODO(danakj): Remove this when pepper doesn't need it. crbug.com/350204 void SetTextureMailboxWithoutReleaseCallback(const TextureMailbox& mailbox); - virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) override; + virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect) override; virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) override; virtual bool Update(ResourceUpdateQueue* queue, diff --git a/cc/layers/tiled_layer.cc b/cc/layers/tiled_layer.cc index d6f4116..e4d5f7c 100644 --- a/cc/layers/tiled_layer.cc +++ b/cc/layers/tiled_layer.cc @@ -288,7 +288,7 @@ UpdatableTile* TiledLayer::CreateTile(int i, int j) { return added_tile; } -void TiledLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { +void TiledLayer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { InvalidateContentRect(LayerRectToContentRect(dirty_rect)); ContentsScalingLayer::SetNeedsDisplayRect(dirty_rect); } @@ -464,7 +464,8 @@ void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect, // paint_rect from content space to layer space. float width_scale = 1 / draw_properties().contents_scale_x; float height_scale = 1 / draw_properties().contents_scale_y; - update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale); + update_rect_ = + gfx::ScaleToEnclosingRect(update_rect, width_scale, height_scale); // Calling PrepareToUpdate() calls into WebKit to paint, which may have the // side effect of disabling compositing, which causes our reference to the diff --git a/cc/layers/tiled_layer.h b/cc/layers/tiled_layer.h index e8ac89b..8a765d0 100644 --- a/cc/layers/tiled_layer.h +++ b/cc/layers/tiled_layer.h @@ -28,7 +28,7 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer { virtual void SetIsMask(bool is_mask) override; virtual void PushPropertiesTo(LayerImpl* layer) override; virtual void ReduceMemoryUsage() override; - virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) override; + virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect) override; virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) override; virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) override; diff --git a/cc/layers/video_layer_impl.cc b/cc/layers/video_layer_impl.cc index 39f5492..8251a09 100644 --- a/cc/layers/video_layer_impl.cc +++ b/cc/layers/video_layer_impl.cc @@ -363,7 +363,7 @@ void VideoLayerImpl::ReleaseResources() { } void VideoLayerImpl::SetNeedsRedraw() { - SetUpdateRect(gfx::UnionRects(update_rect(), gfx::RectF(bounds()))); + SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); layer_tree_impl()->SetNeedsRedraw(); } |