summaryrefslogtreecommitdiffstats
path: root/cc/layers
diff options
context:
space:
mode:
authorDana Jansens <danakj@google.com>2015-06-17 18:33:14 -0700
committerDana Jansens <danakj@google.com>2015-06-18 01:34:04 +0000
commitc46d374132867eceba26a27e346353086436ee03 (patch)
tree3194cd20a23c9c4ae005657be429c59b94deec48 /cc/layers
parentc38dbd49c2f0ccc9b684c5bbcf6be41bca8ea8ae (diff)
downloadchromium_src-c46d374132867eceba26a27e346353086436ee03.zip
chromium_src-c46d374132867eceba26a27e346353086436ee03.tar.gz
chromium_src-c46d374132867eceba26a27e346353086436ee03.tar.bz2
cc: Remove the layer content_bounds() and use bounds() instead.
And remove the content_bounds from DrawProperties. They are always equal now (outside of some legacy tests). R=enne@chromium.org, enne, vmpstr BUG=413479 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1179133004. Cr-Commit-Position: refs/heads/master@{#334979}
Diffstat (limited to 'cc/layers')
-rw-r--r--cc/layers/contents_scaling_layer.cc64
-rw-r--r--cc/layers/contents_scaling_layer.h39
-rw-r--r--cc/layers/contents_scaling_layer_unittest.cc83
-rw-r--r--cc/layers/delegated_renderer_layer_impl.cc16
-rw-r--r--cc/layers/delegated_renderer_layer_impl_unittest.cc52
-rw-r--r--cc/layers/draw_properties.h1
-rw-r--r--cc/layers/io_surface_layer_impl.cc6
-rw-r--r--cc/layers/layer.cc6
-rw-r--r--cc/layers/layer.h1
-rw-r--r--cc/layers/layer_impl.cc63
-rw-r--r--cc/layers/layer_impl.h5
-rw-r--r--cc/layers/layer_impl_unittest.cc6
-rw-r--r--cc/layers/nine_patch_layer_impl.cc4
-rw-r--r--cc/layers/render_surface_impl.cc7
-rw-r--r--cc/layers/scrollbar_layer_unittest.cc6
-rw-r--r--cc/layers/solid_color_layer_impl.cc10
-rw-r--r--cc/layers/solid_color_scrollbar_layer_impl.cc4
-rw-r--r--cc/layers/texture_layer_impl.cc6
-rw-r--r--cc/layers/ui_resource_layer_impl.cc4
-rw-r--r--cc/layers/video_layer_impl.cc2
20 files changed, 73 insertions, 312 deletions
diff --git a/cc/layers/contents_scaling_layer.cc b/cc/layers/contents_scaling_layer.cc
deleted file mode 100644
index 10d5793..0000000
--- a/cc/layers/contents_scaling_layer.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "cc/layers/contents_scaling_layer.h"
-#include "cc/trees/layer_tree_host.h"
-#include "ui/gfx/geometry/size_conversions.h"
-
-namespace cc {
-
-gfx::Size ContentsScalingLayer::ComputeContentBoundsForScale(
- float scale_x,
- float scale_y) const {
- return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale_x, scale_y));
-}
-
-ContentsScalingLayer::ContentsScalingLayer(const LayerSettings& settings)
- : Layer(settings),
- last_update_contents_scale_x_(0.f),
- last_update_contents_scale_y_(0.f) {
-}
-
-ContentsScalingLayer::~ContentsScalingLayer() {
-}
-
-void ContentsScalingLayer::CalculateContentsScale(
- float ideal_contents_scale,
- float* contents_scale_x,
- float* contents_scale_y,
- gfx::Size* content_bounds) {
- float old_contents_scale_x = *contents_scale_x;
- float old_contents_scale_y = *contents_scale_y;
- gfx::Size old_content_bounds = *content_bounds;
- *contents_scale_x = ideal_contents_scale;
- *contents_scale_y = ideal_contents_scale;
- *content_bounds = ComputeContentBoundsForScale(
- ideal_contents_scale,
- ideal_contents_scale);
-
- if (!layer_tree_host())
- return;
-
- if (old_contents_scale_x != *contents_scale_x ||
- old_contents_scale_y != *contents_scale_y ||
- old_content_bounds != *content_bounds) {
- layer_tree_host()->property_trees()->needs_rebuild = true;
- }
-}
-
-bool ContentsScalingLayer::Update(ResourceUpdateQueue* queue) {
- bool updated = Layer::Update(queue);
-
- if (draw_properties().contents_scale_x == last_update_contents_scale_x_ &&
- draw_properties().contents_scale_y == last_update_contents_scale_y_)
- return updated;
-
- last_update_contents_scale_x_ = draw_properties().contents_scale_x;
- last_update_contents_scale_y_ = draw_properties().contents_scale_y;
- // Invalidate the whole layer if scale changed.
- SetNeedsDisplayRect(gfx::Rect(paint_properties().bounds));
- return updated;
-}
-
-} // namespace cc
diff --git a/cc/layers/contents_scaling_layer.h b/cc/layers/contents_scaling_layer.h
deleted file mode 100644
index 6ad3f35..0000000
--- a/cc/layers/contents_scaling_layer.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_LAYERS_CONTENTS_SCALING_LAYER_H_
-#define CC_LAYERS_CONTENTS_SCALING_LAYER_H_
-
-#include "cc/base/cc_export.h"
-#include "cc/layers/layer.h"
-
-namespace cc {
-
-// Base class for layers that need contents scale.
-// The content bounds are determined by bounds and scale of the contents.
-class CC_EXPORT ContentsScalingLayer : public Layer {
- public:
- void CalculateContentsScale(float ideal_contents_scale,
- float* contents_scale_x,
- float* contents_scale_y,
- gfx::Size* content_bounds) override;
-
- bool Update(ResourceUpdateQueue* queue) override;
-
- protected:
- explicit ContentsScalingLayer(const LayerSettings& settings);
- ~ContentsScalingLayer() override;
-
- gfx::Size ComputeContentBoundsForScale(float scale_x, float scale_y) const;
-
- private:
- float last_update_contents_scale_x_;
- float last_update_contents_scale_y_;
-
- DISALLOW_COPY_AND_ASSIGN(ContentsScalingLayer);
-};
-
-} // namespace cc
-
-#endif // CC_LAYERS_CONTENTS_SCALING_LAYER_H__
diff --git a/cc/layers/contents_scaling_layer_unittest.cc b/cc/layers/contents_scaling_layer_unittest.cc
deleted file mode 100644
index 567b21e..0000000
--- a/cc/layers/contents_scaling_layer_unittest.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "cc/layers/contents_scaling_layer.h"
-
-#include <vector>
-
-#include "cc/test/fake_layer_tree_host.h"
-#include "cc/test/geometry_test_utils.h"
-#include "cc/test/test_task_graph_runner.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace cc {
-namespace {
-
-class MockContentsScalingLayer : public ContentsScalingLayer {
- public:
- explicit MockContentsScalingLayer(const LayerSettings& settings)
- : ContentsScalingLayer(settings) {}
-
- void SetNeedsDisplayRect(const gfx::Rect& dirty_rect) override {
- last_needs_display_rect_ = dirty_rect;
- ContentsScalingLayer::SetNeedsDisplayRect(dirty_rect);
- }
-
- const gfx::Rect& LastNeedsDisplayRect() const {
- return last_needs_display_rect_;
- }
-
- private:
- ~MockContentsScalingLayer() override {}
-
- gfx::Rect last_needs_display_rect_;
-};
-
-static void CalcDrawProps(FakeLayerTreeHost* host, float device_scale_factor) {
- RenderSurfaceLayerList render_surface_layer_list;
- LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- host->root_layer(), gfx::Size(500, 500), &render_surface_layer_list);
- inputs.device_scale_factor = device_scale_factor;
- LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-}
-
-TEST(ContentsScalingLayerTest, CheckContentsBounds) {
- LayerSettings layer_settings;
-
- FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
- TestTaskGraphRunner task_graph_runner;
- scoped_ptr<FakeLayerTreeHost> host =
- FakeLayerTreeHost::Create(&client, &task_graph_runner);
-
- scoped_refptr<MockContentsScalingLayer> test_layer =
- make_scoped_refptr(new MockContentsScalingLayer(layer_settings));
-
- scoped_refptr<Layer> root = Layer::Create(layer_settings);
- root->AddChild(test_layer);
- host->SetRootLayer(root);
-
- test_layer->SetBounds(gfx::Size(320, 240));
-
- CalcDrawProps(host.get(), 1.f);
- EXPECT_FLOAT_EQ(1.f, test_layer->contents_scale_x());
- EXPECT_FLOAT_EQ(1.f, test_layer->contents_scale_y());
- EXPECT_EQ(320, test_layer->content_bounds().width());
- EXPECT_EQ(240, test_layer->content_bounds().height());
-
- CalcDrawProps(host.get(), 2.f);
- EXPECT_EQ(640, test_layer->content_bounds().width());
- EXPECT_EQ(480, test_layer->content_bounds().height());
-
- test_layer->SetBounds(gfx::Size(10, 20));
- CalcDrawProps(host.get(), 2.f);
- EXPECT_EQ(20, test_layer->content_bounds().width());
- EXPECT_EQ(40, test_layer->content_bounds().height());
-
- CalcDrawProps(host.get(), 1.33f);
- EXPECT_EQ(14, test_layer->content_bounds().width());
- EXPECT_EQ(27, test_layer->content_bounds().height());
-}
-
-} // namespace
-} // namespace cc
diff --git a/cc/layers/delegated_renderer_layer_impl.cc b/cc/layers/delegated_renderer_layer_impl.cc
index e48cab7..01ae74f 100644
--- a/cc/layers/delegated_renderer_layer_impl.cc
+++ b/cc/layers/delegated_renderer_layer_impl.cc
@@ -351,22 +351,16 @@ void DelegatedRendererLayerImpl::AppendRainbowDebugBorder(
for (int i = 0;; ++i) {
// For horizontal lines.
int x = kStripeWidth * i;
- int width = std::min(kStripeWidth, content_bounds().width() - x - 1);
+ int width = std::min(kStripeWidth, bounds().width() - x - 1);
// For vertical lines.
int y = kStripeHeight * i;
- int height = std::min(kStripeHeight, content_bounds().height() - y - 1);
+ int height = std::min(kStripeHeight, bounds().height() - y - 1);
gfx::Rect top(x, 0, width, border_width);
- gfx::Rect bottom(x,
- content_bounds().height() - border_width,
- width,
- border_width);
+ gfx::Rect bottom(x, bounds().height() - border_width, width, border_width);
gfx::Rect left(0, y, border_width, height);
- gfx::Rect right(content_bounds().width() - border_width,
- y,
- border_width,
- height);
+ gfx::Rect right(bounds().width() - border_width, y, border_width, height);
if (top.IsEmpty() && left.IsEmpty())
break;
@@ -395,7 +389,7 @@ void DelegatedRendererLayerImpl::AppendRainbowDebugBorder(
colors[i % kNumColors],
static_cast<uint8_t>(SkColorGetA(colors[i % kNumColors]) *
kFillOpacity));
- gfx::Rect fill_rect(x, 0, width, content_bounds().height());
+ gfx::Rect fill_rect(x, 0, width, bounds().height());
solid_quad->SetNew(shared_quad_state, fill_rect, fill_rect, fill_color,
force_anti_aliasing_off);
}
diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc
index eea9237..b5743dd 100644
--- a/cc/layers/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc
@@ -642,7 +642,7 @@ class DelegatedRendererLayerImplTestTransform
RenderPassList delegated_render_passes;
- gfx::Size child_pass_content_bounds(7, 7);
+ gfx::Size child_pass_bounds(7, 7);
gfx::Rect child_pass_rect(20, 20, 7, 7);
gfx::Transform child_pass_transform;
child_pass_transform.Scale(0.8f, 0.8f);
@@ -657,14 +657,10 @@ class DelegatedRendererLayerImplTestTransform
gfx::Transform());
SharedQuadState* shared_quad_state =
pass->CreateAndAppendSharedQuadState();
- shared_quad_state->SetAll(child_pass_transform,
- child_pass_content_bounds,
- child_pass_rect,
- child_pass_clip_rect,
- child_pass_clipped,
- 1.f,
- SkXfermode::kSrcOver_Mode,
- 0);
+ shared_quad_state->SetAll(child_pass_transform, child_pass_bounds,
+ child_pass_rect, child_pass_clip_rect,
+ child_pass_clipped, 1.f,
+ SkXfermode::kSrcOver_Mode, 0);
SolidColorDrawQuad* color_quad;
color_quad = pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
@@ -682,7 +678,7 @@ class DelegatedRendererLayerImplTestTransform
false);
}
- gfx::Size root_pass_content_bounds(100, 100);
+ gfx::Size root_pass_bounds(100, 100);
gfx::Rect root_pass_rect(0, 0, 100, 100);
gfx::Transform root_pass_transform;
root_pass_transform.Scale(1.5, 1.5);
@@ -695,13 +691,9 @@ class DelegatedRendererLayerImplTestTransform
root_pass_rect,
gfx::Transform());
SharedQuadState* shared_quad_state = pass->CreateAndAppendSharedQuadState();
- shared_quad_state->SetAll(root_pass_transform,
- root_pass_content_bounds,
- root_pass_rect,
- root_pass_clip_rect,
- root_pass_clipped,
- 1.f,
- SkXfermode::kSrcOver_Mode,
+ shared_quad_state->SetAll(root_pass_transform, root_pass_bounds,
+ root_pass_rect, root_pass_clip_rect,
+ root_pass_clipped, 1.f, SkXfermode::kSrcOver_Mode,
0);
RenderPassDrawQuad* render_pass_quad =
@@ -1079,7 +1071,7 @@ class DelegatedRendererLayerImplTestClip
RenderPassList delegated_render_passes;
- gfx::Size child_pass_content_bounds(7, 7);
+ gfx::Size child_pass_bounds(7, 7);
gfx::Rect child_pass_rect(20, 20, 7, 7);
gfx::Transform child_pass_transform;
gfx::Rect child_pass_clip_rect(21, 21, 3, 3);
@@ -1092,14 +1084,10 @@ class DelegatedRendererLayerImplTestClip
gfx::Transform());
SharedQuadState* shared_quad_state =
pass->CreateAndAppendSharedQuadState();
- shared_quad_state->SetAll(child_pass_transform,
- child_pass_content_bounds,
- child_pass_rect,
- child_pass_clip_rect,
- child_pass_clipped,
- 1.f,
- SkXfermode::kSrcOver_Mode,
- 0);
+ shared_quad_state->SetAll(child_pass_transform, child_pass_bounds,
+ child_pass_rect, child_pass_clip_rect,
+ child_pass_clipped, 1.f,
+ SkXfermode::kSrcOver_Mode, 0);
SolidColorDrawQuad* color_quad;
color_quad = pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
@@ -1117,7 +1105,7 @@ class DelegatedRendererLayerImplTestClip
false);
}
- gfx::Size root_pass_content_bounds(50, 50);
+ gfx::Size root_pass_bounds(50, 50);
gfx::Rect root_pass_rect(0, 0, 50, 50);
gfx::Transform root_pass_transform;
gfx::Rect root_pass_clip_rect(5, 5, 40, 40);
@@ -1128,13 +1116,9 @@ class DelegatedRendererLayerImplTestClip
root_pass_rect,
gfx::Transform());
SharedQuadState* shared_quad_state = pass->CreateAndAppendSharedQuadState();
- shared_quad_state->SetAll(root_pass_transform,
- root_pass_content_bounds,
- root_pass_rect,
- root_pass_clip_rect,
- root_pass_clipped,
- 1.f,
- SkXfermode::kSrcOver_Mode,
+ shared_quad_state->SetAll(root_pass_transform, root_pass_bounds,
+ root_pass_rect, root_pass_clip_rect,
+ root_pass_clipped, 1.f, SkXfermode::kSrcOver_Mode,
0);
RenderPassDrawQuad* render_pass_quad =
diff --git a/cc/layers/draw_properties.h b/cc/layers/draw_properties.h
index ecb2b66..ab1b166 100644
--- a/cc/layers/draw_properties.h
+++ b/cc/layers/draw_properties.h
@@ -100,7 +100,6 @@ struct CC_EXPORT DrawProperties {
// and not always the one used.
float contents_scale_x;
float contents_scale_y;
- gfx::Size content_bounds;
// Number of descendants with a clip parent that is our ancestor. NB - this
// does not include our clip children because they are clipped by us.
diff --git a/cc/layers/io_surface_layer_impl.cc b/cc/layers/io_surface_layer_impl.cc
index a7da986..234d3f3 100644
--- a/cc/layers/io_surface_layer_impl.cc
+++ b/cc/layers/io_surface_layer_impl.cc
@@ -66,10 +66,10 @@ void IOSurfaceLayerImpl::AppendQuads(
render_pass->CreateAndAppendSharedQuadState();
PopulateSharedQuadState(shared_quad_state);
- AppendDebugBorderQuad(
- render_pass, content_bounds(), shared_quad_state, append_quads_data);
+ AppendDebugBorderQuad(render_pass, bounds(), shared_quad_state,
+ append_quads_data);
- gfx::Rect quad_rect(content_bounds());
+ gfx::Rect quad_rect(bounds());
gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect());
gfx::Rect visible_quad_rect =
draw_properties().occlusion_in_content_space.GetUnoccludedContentRect(
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 731ae6e..d1c173e 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -240,12 +240,12 @@ bool Layer::IsPropertyChangeAllowed() const {
return !layer_tree_host_->in_paint_layer_contents();
}
+// TODO(danakj): Remove this after impl_side_painting.
gfx::Rect Layer::LayerRectToContentRect(const gfx::Rect& layer_rect) const {
- gfx::Rect content_rect = gfx::ScaleToEnclosingRect(
- layer_rect, contents_scale_x(), contents_scale_y());
+ gfx::Rect content_rect = layer_rect;
// 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()));
+ content_rect.Intersect(gfx::Rect(bounds()));
return content_rect;
}
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index e7e0f8a..d344c2d 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -400,7 +400,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
// subclasses of ContentsScalingLayer.
float contents_scale_x() const { return draw_properties_.contents_scale_x; }
float contents_scale_y() const { return draw_properties_.contents_scale_y; }
- gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
virtual void CalculateContentsScale(float ideal_contents_scale,
float* contents_scale_x,
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index 2eb027a..d4b1089 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -283,11 +283,11 @@ void LayerImpl::ClearRenderSurfaceLayerList() {
}
void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const {
- state->SetAll(
- draw_properties_.target_space_transform, draw_properties_.content_bounds,
- draw_properties_.visible_content_rect, draw_properties_.clip_rect,
- draw_properties_.is_clipped, draw_properties_.opacity,
- draw_properties_.blend_mode, sorting_context_id_);
+ state->SetAll(draw_properties_.target_space_transform, bounds(),
+ draw_properties_.visible_content_rect,
+ draw_properties_.clip_rect, draw_properties_.is_clipped,
+ draw_properties_.opacity, draw_properties_.blend_mode,
+ sorting_context_id_);
}
void LayerImpl::PopulateScaledSharedQuadState(SharedQuadState* state,
@@ -295,13 +295,12 @@ void LayerImpl::PopulateScaledSharedQuadState(SharedQuadState* state,
gfx::Transform scaled_draw_transform =
draw_properties_.target_space_transform;
scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale);
- gfx::Size scaled_content_bounds =
- gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale));
+ gfx::Size scaled_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale));
gfx::Rect scaled_visible_content_rect =
gfx::ScaleToEnclosingRect(visible_content_rect(), scale);
- scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds));
+ scaled_visible_content_rect.Intersect(gfx::Rect(scaled_bounds));
- state->SetAll(scaled_draw_transform, scaled_content_bounds,
+ state->SetAll(scaled_draw_transform, scaled_bounds,
scaled_visible_content_rect, draw_properties().clip_rect,
draw_properties().is_clipped, draw_properties().opacity,
draw_properties().blend_mode, sorting_context_id_);
@@ -344,22 +343,18 @@ void LayerImpl::GetDebugBorderProperties(SkColor* color, float* width) const {
void LayerImpl::AppendDebugBorderQuad(
RenderPass* render_pass,
- const gfx::Size& content_bounds,
+ const gfx::Size& bounds,
const SharedQuadState* shared_quad_state,
AppendQuadsData* append_quads_data) const {
SkColor color;
float width;
GetDebugBorderProperties(&color, &width);
- AppendDebugBorderQuad(render_pass,
- content_bounds,
- shared_quad_state,
- append_quads_data,
- color,
- width);
+ AppendDebugBorderQuad(render_pass, bounds, shared_quad_state,
+ append_quads_data, color, width);
}
void LayerImpl::AppendDebugBorderQuad(RenderPass* render_pass,
- const gfx::Size& content_bounds,
+ const gfx::Size& bounds,
const SharedQuadState* shared_quad_state,
AppendQuadsData* append_quads_data,
SkColor color,
@@ -367,7 +362,7 @@ void LayerImpl::AppendDebugBorderQuad(RenderPass* render_pass,
if (!ShowDebugBorders())
return;
- gfx::Rect quad_rect(content_bounds);
+ gfx::Rect quad_rect(bounds);
gfx::Rect visible_quad_rect(quad_rect);
DebugBorderDrawQuad* debug_border_quad =
render_pass->CreateAndAppendDrawQuad<DebugBorderDrawQuad>();
@@ -515,13 +510,11 @@ InputHandler::ScrollStatus LayerImpl::TryScroll(
return InputHandler::SCROLL_STARTED;
}
+// TODO(danakj): Remove this after impl_side_painting.
gfx::Rect LayerImpl::LayerRectToContentRect(
const gfx::RectF& layer_rect) const {
- gfx::RectF content_rect =
- gfx::ScaleRect(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()));
+ gfx::RectF content_rect = layer_rect;
+ content_rect.Intersect(gfx::Rect(bounds()));
return gfx::ToEnclosingRect(content_rect);
}
@@ -537,7 +530,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
layer->SetTransformOrigin(transform_origin_);
layer->SetBackgroundColor(background_color_);
layer->SetBounds(bounds_);
- layer->SetContentBounds(content_bounds());
+ layer->SetContentBounds(bounds_);
layer->SetContentsScale(contents_scale_x(), contents_scale_y());
layer->SetDoubleSided(double_sided_);
layer->SetDrawCheckerboardForMissingTiles(
@@ -1155,12 +1148,8 @@ void LayerImpl::AddDamageRect(const gfx::RectF& damage_rect) {
damage_rect_ = gfx::UnionRects(damage_rect_, damage_rect);
}
+// TODO(danakj): Remove this after impl_side_painting.
void LayerImpl::SetContentBounds(const gfx::Size& content_bounds) {
- if (this->content_bounds() == content_bounds)
- return;
-
- draw_properties_.content_bounds = content_bounds;
- NoteLayerPropertyChanged();
}
void LayerImpl::SetContentsScale(float contents_scale_x,
@@ -1558,9 +1547,7 @@ void LayerImpl::AsValueInto(base::trace_event::TracedValue* state) const {
bool clipped;
gfx::QuadF layer_quad = MathUtil::MapQuad(
- screen_space_transform(),
- gfx::QuadF(gfx::Rect(content_bounds())),
- &clipped);
+ screen_space_transform(), gfx::QuadF(gfx::Rect(bounds())), &clipped);
MathUtil::AddToTracedValue("layer_quad", layer_quad, state);
if (!touch_event_handler_region_.IsEmpty()) {
state->BeginArray("touch_event_handler_region");
@@ -1568,14 +1555,14 @@ void LayerImpl::AsValueInto(base::trace_event::TracedValue* state) const {
state->EndArray();
}
if (have_wheel_event_handlers_) {
- gfx::Rect wheel_rect(content_bounds());
+ gfx::Rect wheel_rect(bounds());
Region wheel_region(wheel_rect);
state->BeginArray("wheel_event_handler_region");
wheel_region.AsValueInto(state);
state->EndArray();
}
if (have_scroll_event_handlers_) {
- gfx::Rect scroll_rect(content_bounds());
+ gfx::Rect scroll_rect(bounds());
Region scroll_region(scroll_rect);
state->BeginArray("scroll_event_handler_region");
scroll_region.AsValueInto(state);
@@ -1699,18 +1686,16 @@ Region LayerImpl::GetInvalidationRegion() {
gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const {
return MathUtil::MapEnclosingClippedRect(
- draw_properties_.target_space_transform,
- gfx::Rect(draw_properties_.content_bounds));
+ draw_properties_.target_space_transform, gfx::Rect(bounds()));
}
gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const {
gfx::Transform scaled_draw_transform =
draw_properties_.target_space_transform;
scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale);
- gfx::Size scaled_content_bounds =
- gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale));
+ gfx::Size scaled_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale));
return MathUtil::MapEnclosingClippedRect(scaled_draw_transform,
- gfx::Rect(scaled_content_bounds));
+ gfx::Rect(scaled_bounds));
}
} // namespace cc
diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h
index 458961a..258e27a 100644
--- a/cc/layers/layer_impl.h
+++ b/cc/layers/layer_impl.h
@@ -422,7 +422,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
void SetContentBounds(const gfx::Size& content_bounds);
- gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
float contents_scale_x() const { return draw_properties_.contents_scale_x; }
float contents_scale_y() const { return draw_properties_.contents_scale_y; }
@@ -672,11 +671,11 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
virtual void GetDebugBorderProperties(SkColor* color, float* width) const;
void AppendDebugBorderQuad(RenderPass* render_pass,
- const gfx::Size& content_bounds,
+ const gfx::Size& bounds,
const SharedQuadState* shared_quad_state,
AppendQuadsData* append_quads_data) const;
void AppendDebugBorderQuad(RenderPass* render_pass,
- const gfx::Size& content_bounds,
+ const gfx::Size& bounds,
const SharedQuadState* shared_quad_state,
AppendQuadsData* append_quads_data,
SkColor color,
diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc
index 5a794ab..2255646 100644
--- a/cc/layers/layer_impl_unittest.cc
+++ b/cc/layers/layer_impl_unittest.cc
@@ -174,7 +174,6 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetTransform(arbitrary_transform));
// Changing these properties only affects the layer itself.
- EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetContentBounds(arbitrary_size));
EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
root->SetContentsScale(arbitrary_number, arbitrary_number));
EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true));
@@ -229,8 +228,6 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {
root->PushScrollOffsetFromMainThread(
gfx::ScrollOffset(arbitrary_vector2d)));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
- root->SetContentBounds(arbitrary_size));
- EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
root->SetContentsScale(arbitrary_number, arbitrary_number));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetOpacity(arbitrary_number));
@@ -327,7 +324,6 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
layer->SetDoubleSided(false)); // constructor initializes it to "true".
- VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentBounds(arbitrary_size));
VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
layer->SetContentsScale(arbitrary_number, arbitrary_number));
VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true));
@@ -352,8 +348,6 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
layer->SetDoubleSided(false)); // constructor initializes it to "true".
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
- layer->SetContentBounds(arbitrary_size));
- VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
layer->SetContentsScale(arbitrary_number, arbitrary_number));
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true));
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
diff --git a/cc/layers/nine_patch_layer_impl.cc b/cc/layers/nine_patch_layer_impl.cc
index 117056a..b31382f 100644
--- a/cc/layers/nine_patch_layer_impl.cc
+++ b/cc/layers/nine_patch_layer_impl.cc
@@ -88,8 +88,8 @@ void NinePatchLayerImpl::AppendQuads(
render_pass->CreateAndAppendSharedQuadState();
PopulateSharedQuadState(shared_quad_state);
- AppendDebugBorderQuad(
- render_pass, content_bounds(), shared_quad_state, append_quads_data);
+ AppendDebugBorderQuad(render_pass, bounds(), shared_quad_state,
+ append_quads_data);
if (!ui_resource_id_)
return;
diff --git a/cc/layers/render_surface_impl.cc b/cc/layers/render_surface_impl.cc
index 7aa4330..22f311d 100644
--- a/cc/layers/render_surface_impl.cc
+++ b/cc/layers/render_surface_impl.cc
@@ -186,10 +186,9 @@ void RenderSurfaceImpl::AppendQuads(RenderPass* render_pass,
gfx::Vector2dF owning_layer_draw_scale =
MathUtil::ComputeTransform2dScaleComponents(
owning_layer_->draw_transform(), 1.f);
- gfx::SizeF unclipped_mask_target_size = gfx::ScaleSize(
- owning_layer_->content_bounds(),
- owning_layer_draw_scale.x(),
- owning_layer_draw_scale.y());
+ gfx::SizeF unclipped_mask_target_size =
+ gfx::ScaleSize(owning_layer_->bounds(), owning_layer_draw_scale.x(),
+ owning_layer_draw_scale.y());
mask_uv_scale = gfx::Vector2dF(
content_rect_.width() / unclipped_mask_target_size.width(),
content_rect_.height() / unclipped_mask_target_size.height());
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc
index dc432cc..fca8a8e 100644
--- a/cc/layers/scrollbar_layer_unittest.cc
+++ b/cc/layers/scrollbar_layer_unittest.cc
@@ -730,7 +730,6 @@ class ScrollbarLayerTestResourceCreationAndRelease : public ScrollbarLayerTest {
layer_tree_root->SetScrollOffset(gfx::ScrollOffset(10, 20));
layer_tree_root->SetBounds(gfx::Size(100, 200));
content_layer->SetBounds(gfx::Size(100, 200));
- scrollbar_layer->draw_properties().content_bounds = gfx::Size(100, 200);
scrollbar_layer->draw_properties().visible_content_rect =
gfx::Rect(0, 0, 100, 200);
scrollbar_layer->CreateRenderSurface();
@@ -796,7 +795,6 @@ TEST_F(ScrollbarLayerTestResourceCreationAndRelease, TestResourceUpdate) {
layer_tree_root->SetBounds(gfx::Size(100, 200));
content_layer->SetBounds(gfx::Size(100, 200));
- scrollbar_layer->draw_properties().content_bounds = gfx::Size(100, 200);
scrollbar_layer->draw_properties().visible_content_rect =
gfx::Rect(0, 0, 100, 200);
@@ -935,8 +933,6 @@ class ScaledScrollbarLayerTestResourceCreation : public ScrollbarLayerTest {
gfx::ScaleSize(scrollbar_layer->bounds(), test_scale, test_scale);
gfx::PointF scaled_location =
gfx::ScalePoint(scrollbar_layer->position(), test_scale, test_scale);
- scrollbar_layer->draw_properties().content_bounds =
- gfx::Size(scaled_size.width(), scaled_size.height());
scrollbar_layer->draw_properties().contents_scale_x = test_scale;
scrollbar_layer->draw_properties().contents_scale_y = test_scale;
scrollbar_layer->draw_properties().visible_content_rect =
@@ -1007,8 +1003,6 @@ class ScaledScrollbarLayerTestScaledRasterization : public ScrollbarLayerTest {
gfx::ScaleSize(scrollbar_layer->bounds(), test_scale, test_scale);
gfx::PointF scaled_location =
gfx::ScalePoint(scrollbar_layer->position(), test_scale, test_scale);
- scrollbar_layer->draw_properties().content_bounds =
- gfx::Size(scaled_size.width(), scaled_size.height());
scrollbar_layer->draw_properties().contents_scale_x = test_scale;
scrollbar_layer->draw_properties().contents_scale_y = test_scale;
scrollbar_layer->draw_properties().visible_content_rect =
diff --git a/cc/layers/solid_color_layer_impl.cc b/cc/layers/solid_color_layer_impl.cc
index 2762497..b85012a 100644
--- a/cc/layers/solid_color_layer_impl.cc
+++ b/cc/layers/solid_color_layer_impl.cc
@@ -69,14 +69,14 @@ void SolidColorLayerImpl::AppendQuads(
render_pass->CreateAndAppendSharedQuadState();
PopulateSharedQuadState(shared_quad_state);
- AppendDebugBorderQuad(
- render_pass, content_bounds(), shared_quad_state, append_quads_data);
+ AppendDebugBorderQuad(render_pass, bounds(), shared_quad_state,
+ append_quads_data);
// TODO(hendrikw): We need to pass the visible content rect rather than
- // |content_bounds()| here.
+ // |bounds()| here.
AppendSolidQuads(render_pass, draw_properties().occlusion_in_content_space,
- shared_quad_state, gfx::Rect(content_bounds()),
- background_color(), append_quads_data);
+ shared_quad_state, gfx::Rect(bounds()), background_color(),
+ append_quads_data);
}
const char* SolidColorLayerImpl::LayerTypeAsString() const {
diff --git a/cc/layers/solid_color_scrollbar_layer_impl.cc b/cc/layers/solid_color_scrollbar_layer_impl.cc
index fa1849e..0b78de7 100644
--- a/cc/layers/solid_color_scrollbar_layer_impl.cc
+++ b/cc/layers/solid_color_scrollbar_layer_impl.cc
@@ -100,8 +100,8 @@ void SolidColorScrollbarLayerImpl::AppendQuads(
render_pass->CreateAndAppendSharedQuadState();
PopulateSharedQuadState(shared_quad_state);
- AppendDebugBorderQuad(
- render_pass, content_bounds(), shared_quad_state, append_quads_data);
+ AppendDebugBorderQuad(render_pass, bounds(), shared_quad_state,
+ append_quads_data);
gfx::Rect thumb_quad_rect(ComputeThumbQuadRect());
gfx::Rect visible_quad_rect =
diff --git a/cc/layers/texture_layer_impl.cc b/cc/layers/texture_layer_impl.cc
index d0e6b19..ba31c6d 100644
--- a/cc/layers/texture_layer_impl.cc
+++ b/cc/layers/texture_layer_impl.cc
@@ -146,14 +146,14 @@ void TextureLayerImpl::AppendQuads(RenderPass* render_pass,
render_pass->CreateAndAppendSharedQuadState();
PopulateSharedQuadState(shared_quad_state);
- AppendDebugBorderQuad(
- render_pass, content_bounds(), shared_quad_state, append_quads_data);
+ AppendDebugBorderQuad(render_pass, bounds(), shared_quad_state,
+ append_quads_data);
SkColor bg_color = blend_background_color_ ?
background_color() : SK_ColorTRANSPARENT;
bool opaque = contents_opaque() || (SkColorGetA(bg_color) == 0xFF);
- gfx::Rect quad_rect(content_bounds());
+ gfx::Rect quad_rect(bounds());
gfx::Rect opaque_rect = opaque ? quad_rect : gfx::Rect();
gfx::Rect visible_quad_rect =
draw_properties().occlusion_in_content_space.GetUnoccludedContentRect(
diff --git a/cc/layers/ui_resource_layer_impl.cc b/cc/layers/ui_resource_layer_impl.cc
index 80fd461..9fb703e 100644
--- a/cc/layers/ui_resource_layer_impl.cc
+++ b/cc/layers/ui_resource_layer_impl.cc
@@ -98,8 +98,8 @@ void UIResourceLayerImpl::AppendQuads(
render_pass->CreateAndAppendSharedQuadState();
PopulateSharedQuadState(shared_quad_state);
- AppendDebugBorderQuad(
- render_pass, content_bounds(), shared_quad_state, append_quads_data);
+ AppendDebugBorderQuad(render_pass, bounds(), shared_quad_state,
+ append_quads_data);
if (!ui_resource_id_)
return;
diff --git a/cc/layers/video_layer_impl.cc b/cc/layers/video_layer_impl.cc
index 1ef13a0..665541e 100644
--- a/cc/layers/video_layer_impl.cc
+++ b/cc/layers/video_layer_impl.cc
@@ -139,7 +139,7 @@ void VideoLayerImpl::AppendQuads(RenderPass* render_pass,
DCHECK(frame_.get());
gfx::Transform transform = draw_transform();
- gfx::Size rotated_size = content_bounds();
+ gfx::Size rotated_size = bounds();
switch (video_rotation_) {
case media::VIDEO_ROTATION_90: