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

Side by Side 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: Updated PictureLayerImplTest.LayerEvictionTileIterator test. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/picture_image_layer_impl.h" 5 #include "cc/layers/picture_image_layer_impl.h"
6 6
7 #include "cc/layers/append_quads_data.h" 7 #include "cc/layers/append_quads_data.h"
8 #include "cc/resources/tile_priority.h" 8 #include "cc/resources/tile_priority.h"
9 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 case PENDING_TREE: 53 case PENDING_TREE:
54 tree = host_impl_.pending_tree(); 54 tree = host_impl_.pending_tree();
55 break; 55 break;
56 case NUM_TREES: 56 case NUM_TREES:
57 NOTREACHED(); 57 NOTREACHED();
58 break; 58 break;
59 } 59 }
60 TestablePictureImageLayerImpl* layer = 60 TestablePictureImageLayerImpl* layer =
61 new TestablePictureImageLayerImpl(tree, id); 61 new TestablePictureImageLayerImpl(tree, id);
62 layer->SetBounds(gfx::Size(100, 200)); 62 layer->SetBounds(gfx::Size(100, 200));
63 layer->SetContentBounds(gfx::Size(100, 200));
63 layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_, 64 layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_,
64 layer->bounds())); 65 layer->bounds()));
65 layer->pile_ = tiling_client_.pile(); 66 layer->pile_ = tiling_client_.pile();
66 return make_scoped_ptr(layer); 67 return make_scoped_ptr(layer);
67 } 68 }
68 69
69 void UpdateDrawProperties() { 70 void UpdateDrawProperties() {
70 host_impl_.pending_tree()->UpdateDrawProperties(); 71 host_impl_.pending_tree()->UpdateDrawProperties();
71 } 72 }
72 73
74 void SetupDrawPropertiesAndUpdateTilePriorities(
75 TestablePictureImageLayerImpl* layer,
76 float ideal_contents_scale,
77 float device_scale_factor,
78 float page_scale_factor,
79 float maximum_animation_contents_scale,
80 bool animating_transform_to_screen) {
81 layer->draw_properties().ideal_contents_scale = 1.f;
enne (OOO) 2014/05/27 21:41:21 Why is this 1? Shouldn't it be ideal_contents_scal
82 layer->draw_properties().device_scale_factor = device_scale_factor;
83 layer->draw_properties().page_scale_factor = page_scale_factor;
84 layer->draw_properties().maximum_animation_contents_scale =
85 maximum_animation_contents_scale;
86 layer->draw_properties().screen_space_transform_is_animating =
87 animating_transform_to_screen;
88 layer->UpdateTilePriorities();
89 }
90
73 protected: 91 protected:
74 FakeImplProxy proxy_; 92 FakeImplProxy proxy_;
75 FakeLayerTreeHostImpl host_impl_; 93 FakeLayerTreeHostImpl host_impl_;
76 TestSharedBitmapManager shared_bitmap_manager_; 94 TestSharedBitmapManager shared_bitmap_manager_;
77 FakePictureLayerTilingClient tiling_client_; 95 FakePictureLayerTilingClient tiling_client_;
78 }; 96 };
79 97
80 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { 98 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) {
81 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); 99 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE));
82 layer->SetDrawsContent(true); 100 layer->SetDrawsContent(true);
83 101
84 float contents_scale_x; 102 SetupDrawPropertiesAndUpdateTilePriorities(
85 float contents_scale_y; 103 layer.get(), 2.f, 3.f, 4.f, 1.f, false);
86 gfx::Size content_bounds; 104 EXPECT_FLOAT_EQ(1.f, layer->contents_scale_x());
87 layer->CalculateContentsScale(2.f, 105 EXPECT_FLOAT_EQ(1.f, layer->contents_scale_y());
88 3.f, 106 EXPECT_FLOAT_EQ(1.f, layer->MaximumTilingContentScale());
89 4.f,
90 1.f,
91 false,
92 &contents_scale_x,
93 &contents_scale_y,
94 &content_bounds);
95 EXPECT_FLOAT_EQ(1.f, contents_scale_x);
96 EXPECT_FLOAT_EQ(1.f, contents_scale_y);
97 EXPECT_EQ(layer->bounds(), content_bounds);
98 } 107 }
99 108
100 TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) { 109 TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) {
101 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); 110 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE));
102 layer->SetBounds(gfx::Size(100, 200)); 111 layer->SetBounds(gfx::Size(100, 200));
103 layer->SetDrawsContent(true); 112 layer->SetDrawsContent(true);
104 113
105 UpdateDrawProperties(); 114 UpdateDrawProperties();
106 115
107 float contents_scale_x; 116 SetupDrawPropertiesAndUpdateTilePriorities(
108 float contents_scale_y; 117 layer.get(), 2.f, 3.f, 4.f, 1.f, false);
109 gfx::Size content_bounds;
110 layer->CalculateContentsScale(2.f,
111 3.f,
112 4.f,
113 1.f,
114 false,
115 &contents_scale_x,
116 &contents_scale_y,
117 &content_bounds);
118 layer->UpdateTilePriorities();
119 118
120 EXPECT_TRUE(layer->AreVisibleResourcesReady()); 119 EXPECT_TRUE(layer->AreVisibleResourcesReady());
121 } 120 }
122 121
123 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { 122 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) {
124 scoped_ptr<TestablePictureImageLayerImpl> pending_layer( 123 scoped_ptr<TestablePictureImageLayerImpl> pending_layer(
125 CreateLayer(1, PENDING_TREE)); 124 CreateLayer(1, PENDING_TREE));
126 pending_layer->SetDrawsContent(true); 125 pending_layer->SetDrawsContent(true);
127 126
128 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal 127 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal
129 // to the content scale used by PictureImageLayerImpl. 128 // to the content scale used by PictureImageLayerImpl.
130 const float suggested_ideal_contents_scale = 2.f; 129 const float suggested_ideal_contents_scale = 2.f;
131 const float device_scale_factor = 3.f; 130 const float device_scale_factor = 3.f;
132 const float page_scale_factor = 4.f; 131 const float page_scale_factor = 4.f;
133 const float maximum_animation_contents_scale = 1.f; 132 const float maximum_animation_contents_scale = 1.f;
134 const bool animating_transform_to_screen = false; 133 const bool animating_transform_to_screen = false;
135 float contents_scale_x; 134 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer.get(),
136 float contents_scale_y; 135 suggested_ideal_contents_scale,
137 gfx::Size content_bounds; 136 device_scale_factor,
138 pending_layer->CalculateContentsScale(suggested_ideal_contents_scale, 137 page_scale_factor,
139 device_scale_factor, 138 maximum_animation_contents_scale,
140 page_scale_factor, 139 animating_transform_to_screen);
141 maximum_animation_contents_scale,
142 animating_transform_to_screen,
143 &contents_scale_x,
144 &contents_scale_y,
145 &content_bounds);
146 140
147 // Push to active layer. 141 // Push to active layer.
148 host_impl_.ActivatePendingTree(); 142 host_impl_.ActivatePendingTree();
149 scoped_ptr<TestablePictureImageLayerImpl> active_layer( 143 scoped_ptr<TestablePictureImageLayerImpl> active_layer(
150 CreateLayer(1, ACTIVE_TREE)); 144 CreateLayer(1, ACTIVE_TREE));
151 pending_layer->PushPropertiesTo(active_layer.get()); 145 pending_layer->PushPropertiesTo(active_layer.get());
152 active_layer->CalculateContentsScale(suggested_ideal_contents_scale, 146 SetupDrawPropertiesAndUpdateTilePriorities(active_layer.get(),
153 device_scale_factor, 147 suggested_ideal_contents_scale,
154 page_scale_factor, 148 device_scale_factor,
155 maximum_animation_contents_scale, 149 page_scale_factor,
156 animating_transform_to_screen, 150 maximum_animation_contents_scale,
157 &contents_scale_x, 151 animating_transform_to_screen);
158 &contents_scale_y,
159 &content_bounds);
160 152
161 // Create tile and resource. 153 // Create tile and resource.
162 active_layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 154 active_layer->tilings()->tiling_at(0)->CreateAllTilesForTesting();
163 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( 155 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(
164 active_layer->tilings()->tiling_at(0)->AllTilesForTesting()); 156 active_layer->tilings()->tiling_at(0)->AllTilesForTesting());
165 157
166 // Draw. 158 // Draw.
167 active_layer->draw_properties().visible_content_rect = 159 active_layer->draw_properties().visible_content_rect =
168 gfx::Rect(active_layer->bounds()); 160 gfx::Rect(active_layer->bounds());
169 MockQuadCuller quad_culler; 161 MockQuadCuller quad_culler;
170 AppendQuadsData data; 162 AppendQuadsData data;
171 active_layer->WillDraw(DRAW_MODE_SOFTWARE, NULL); 163 active_layer->WillDraw(DRAW_MODE_SOFTWARE, NULL);
172 active_layer->AppendQuads(&quad_culler, &data); 164 active_layer->AppendQuads(&quad_culler, &data);
173 active_layer->DidDraw(NULL); 165 active_layer->DidDraw(NULL);
174 166
175 EXPECT_EQ(DrawQuad::TILED_CONTENT, quad_culler.quad_list()[0]->material); 167 EXPECT_EQ(DrawQuad::TILED_CONTENT, quad_culler.quad_list()[0]->material);
176 168
177 // Tiles are ready at correct scale, so should not set had_incomplete_tile. 169 // Tiles are ready at correct scale, so should not set had_incomplete_tile.
178 EXPECT_FALSE(data.had_incomplete_tile); 170 EXPECT_FALSE(data.had_incomplete_tile);
179 } 171 }
180 172
181 } // namespace 173 } // namespace
182 } // namespace cc 174 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698