Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3346)

Unified Diff: cc/layers/picture_image_layer_impl_unittest.cc

Issue 271533011: cc: Move tiling management out of draw properties calculation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments + unit/perf test fails addressed Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/layers/picture_image_layer_impl_unittest.cc
diff --git a/cc/layers/picture_image_layer_impl_unittest.cc b/cc/layers/picture_image_layer_impl_unittest.cc
index 97d522aae36ebaad88e34f77254a6d90dc2565b2..c89f1532b1b734c4b66a56b8a1557798fb693c1e 100644
--- a/cc/layers/picture_image_layer_impl_unittest.cc
+++ b/cc/layers/picture_image_layer_impl_unittest.cc
@@ -70,6 +70,23 @@ class PictureImageLayerImplTest : public testing::Test {
host_impl_.pending_tree()->UpdateDrawProperties();
}
+ void SetupDrawPropertiesAndUpdateTilePriorities(
+ TestablePictureImageLayerImpl* layer,
+ float ideal_contents_scale,
+ float device_scale_factor,
+ float page_scale_factor,
+ float maximum_animation_contents_scale,
+ bool animating_transform_to_screen) {
+ layer->draw_properties().ideal_contents_scale = 1.f;
+ layer->draw_properties().device_scale = device_scale_factor;
+ layer->draw_properties().page_scale = page_scale_factor;
+ layer->draw_properties().maximum_animation_contents_scale =
+ maximum_animation_contents_scale;
+ layer->draw_properties().screen_space_transform_is_animating =
+ animating_transform_to_screen;
+ layer->UpdateTilePriorities();
+ }
+
protected:
FakeImplProxy proxy_;
FakeLayerTreeHostImpl host_impl_;
@@ -77,26 +94,6 @@ class PictureImageLayerImplTest : public testing::Test {
FakePictureLayerTilingClient tiling_client_;
};
-TEST_F(PictureImageLayerImplTest, CalculateContentsScale) {
- scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE));
- layer->SetDrawsContent(true);
-
- float contents_scale_x;
- float contents_scale_y;
- gfx::Size content_bounds;
- layer->CalculateContentsScale(2.f,
- 3.f,
- 4.f,
- 1.f,
- false,
- &contents_scale_x,
- &contents_scale_y,
- &content_bounds);
- EXPECT_FLOAT_EQ(1.f, contents_scale_x);
danakj 2014/05/21 15:01:00 The equivalent of this test would be to call Setup
- EXPECT_FLOAT_EQ(1.f, contents_scale_y);
- EXPECT_EQ(layer->bounds(), content_bounds);
-}
-
TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) {
scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE));
layer->SetBounds(gfx::Size(100, 200));
@@ -104,18 +101,8 @@ TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) {
UpdateDrawProperties();
- float contents_scale_x;
- float contents_scale_y;
- gfx::Size content_bounds;
- layer->CalculateContentsScale(2.f,
- 3.f,
- 4.f,
- 1.f,
- false,
- &contents_scale_x,
- &contents_scale_y,
- &content_bounds);
- layer->UpdateTilePriorities();
+ SetupDrawPropertiesAndUpdateTilePriorities(
+ layer.get(), 2.f, 3.f, 4.f, 1.f, false);
EXPECT_TRUE(layer->AreVisibleResourcesReady());
}
@@ -132,31 +119,24 @@ TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) {
const float page_scale_factor = 4.f;
const float maximum_animation_contents_scale = 1.f;
const bool animating_transform_to_screen = false;
- float contents_scale_x;
- float contents_scale_y;
- gfx::Size content_bounds;
- pending_layer->CalculateContentsScale(suggested_ideal_contents_scale,
- device_scale_factor,
- page_scale_factor,
- maximum_animation_contents_scale,
- animating_transform_to_screen,
- &contents_scale_x,
- &contents_scale_y,
- &content_bounds);
+ SetupDrawPropertiesAndUpdateTilePriorities(pending_layer.get(),
+ suggested_ideal_contents_scale,
+ device_scale_factor,
+ page_scale_factor,
+ maximum_animation_contents_scale,
+ animating_transform_to_screen);
// Push to active layer.
host_impl_.ActivatePendingTree();
scoped_ptr<TestablePictureImageLayerImpl> active_layer(
CreateLayer(1, ACTIVE_TREE));
pending_layer->PushPropertiesTo(active_layer.get());
- active_layer->CalculateContentsScale(suggested_ideal_contents_scale,
- device_scale_factor,
- page_scale_factor,
- maximum_animation_contents_scale,
- animating_transform_to_screen,
- &contents_scale_x,
- &contents_scale_y,
- &content_bounds);
+ SetupDrawPropertiesAndUpdateTilePriorities(active_layer.get(),
+ suggested_ideal_contents_scale,
+ device_scale_factor,
+ page_scale_factor,
+ maximum_animation_contents_scale,
+ animating_transform_to_screen);
// Create tile and resource.
active_layer->tilings()->tiling_at(0)->CreateAllTilesForTesting();
@@ -164,6 +144,7 @@ TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) {
active_layer->tilings()->tiling_at(0)->AllTilesForTesting());
// Draw.
+ active_layer->SetContentBounds(active_layer->bounds());
active_layer->draw_properties().visible_content_rect =
gfx::Rect(active_layer->bounds());
MockQuadCuller quad_culler;

Powered by Google App Engine
This is Rietveld 408576698