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

Side by Side Diff: cc/layers/layer_unittest.cc

Issue 2128633002: cc: Set up the framework to restrict access to Layer internals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move out the inner struct. Created 4 years, 5 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
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/painted_scrollbar_layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
11 #include "cc/animation/animation_id_provider.h" 11 #include "cc/animation/animation_id_provider.h"
12 #include "cc/animation/keyframed_animation_curve.h" 12 #include "cc/animation/keyframed_animation_curve.h"
13 #include "cc/animation/mutable_properties.h" 13 #include "cc/animation/mutable_properties.h"
14 #include "cc/base/math_util.h" 14 #include "cc/base/math_util.h"
15 #include "cc/input/main_thread_scrolling_reason.h" 15 #include "cc/input/main_thread_scrolling_reason.h"
16 #include "cc/layers/layer_impl.h" 16 #include "cc/layers/layer_impl.h"
17 #include "cc/layers/solid_color_scrollbar_layer.h" 17 #include "cc/layers/solid_color_scrollbar_layer.h"
18 #include "cc/output/copy_output_request.h" 18 #include "cc/output/copy_output_request.h"
19 #include "cc/output/copy_output_result.h" 19 #include "cc/output/copy_output_result.h"
20 #include "cc/proto/layer.pb.h" 20 #include "cc/proto/layer.pb.h"
21 #include "cc/test/animation_test_common.h" 21 #include "cc/test/animation_test_common.h"
22 #include "cc/test/fake_impl_task_runner_provider.h" 22 #include "cc/test/fake_impl_task_runner_provider.h"
23 #include "cc/test/fake_layer_tree_host.h" 23 #include "cc/test/fake_layer_tree_host.h"
24 #include "cc/test/fake_layer_tree_host_client.h" 24 #include "cc/test/fake_layer_tree_host_client.h"
25 #include "cc/test/fake_layer_tree_host_impl.h" 25 #include "cc/test/fake_layer_tree_host_impl.h"
26 #include "cc/test/geometry_test_utils.h" 26 #include "cc/test/geometry_test_utils.h"
27 #include "cc/test/layer_internals_for_test.h"
27 #include "cc/test/layer_test_common.h" 28 #include "cc/test/layer_test_common.h"
28 #include "cc/test/test_gpu_memory_buffer_manager.h" 29 #include "cc/test/test_gpu_memory_buffer_manager.h"
29 #include "cc/test/test_shared_bitmap_manager.h" 30 #include "cc/test/test_shared_bitmap_manager.h"
30 #include "cc/test/test_task_graph_runner.h" 31 #include "cc/test/test_task_graph_runner.h"
31 #include "cc/trees/layer_tree_host.h" 32 #include "cc/trees/layer_tree_host.h"
32 #include "cc/trees/single_thread_proxy.h" 33 #include "cc/trees/single_thread_proxy.h"
33 #include "testing/gmock/include/gmock/gmock.h" 34 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 #include "third_party/skia/include/core/SkColor.h" 36 #include "third_party/skia/include/core/SkColor.h"
36 #include "ui/gfx/geometry/point3_f.h" 37 #include "ui/gfx/geometry/point3_f.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 123
123 // Serializes |src| to proto and back again to a Layer, then verifies that 124 // Serializes |src| to proto and back again to a Layer, then verifies that
124 // the two Layers are equal for serialization purposes. 125 // the two Layers are equal for serialization purposes.
125 void VerifyBaseLayerPropertiesSerializationAndDeserialization(Layer* src) { 126 void VerifyBaseLayerPropertiesSerializationAndDeserialization(Layer* src) {
126 // This is required to ensure that properties are serialized. 127 // This is required to ensure that properties are serialized.
127 src->SetNeedsPushProperties(); 128 src->SetNeedsPushProperties();
128 src->SetLayerTreeHost(layer_tree_host_.get()); 129 src->SetLayerTreeHost(layer_tree_host_.get());
129 130
130 // The following member is reset during serialization, so store the original 131 // The following member is reset during serialization, so store the original
131 // values. 132 // values.
132 gfx::Rect update_rect = src->update_rect_; 133 gfx::Rect update_rect = src->inputs_.update_rect;
133 134
134 // Serialize |src| to protobuf and read the first entry in the 135 // Serialize |src| to protobuf and read the first entry in the
135 // LayerUpdate. There are no descendants, so the serialization 136 // LayerUpdate. There are no descendants, so the serialization
136 // of |src| is the only entry. 137 // of |src| is the only entry.
137 proto::LayerUpdate layer_update; 138 proto::LayerUpdate layer_update;
138 src->ToLayerPropertiesProto(&layer_update); 139 src->ToLayerPropertiesProto(&layer_update);
139 ASSERT_EQ(1, layer_update.layers_size()); 140 ASSERT_EQ(1, layer_update.layers_size());
140 proto::LayerProperties props = layer_update.layers(0); 141 proto::LayerProperties props = layer_update.layers(0);
141 142
142 // The |dest| layer needs to be able to lookup the scroll and clip parents. 143 // The |dest| layer needs to be able to lookup the scroll and clip parents.
143 if (src->scroll_parent_) 144 if (src->inputs_.scroll_parent)
144 layer_tree_host_->RegisterLayer(src->scroll_parent_); 145 layer_tree_host_->RegisterLayer(src->inputs_.scroll_parent);
145 if (src->scroll_children_) { 146 if (src->scroll_children_) {
146 for (auto* child : *(src->scroll_children_)) 147 for (auto* child : *(src->scroll_children_))
147 layer_tree_host_->RegisterLayer(child); 148 layer_tree_host_->RegisterLayer(child);
148 } 149 }
149 if (src->clip_parent_) 150 if (src->inputs_.clip_parent)
150 layer_tree_host_->RegisterLayer(src->clip_parent_); 151 layer_tree_host_->RegisterLayer(src->inputs_.clip_parent);
151 if (src->clip_children_) { 152 if (src->clip_children_) {
152 for (auto* child : *(src->clip_children_)) 153 for (auto* child : *(src->clip_children_))
153 layer_tree_host_->RegisterLayer(child); 154 layer_tree_host_->RegisterLayer(child);
154 } 155 }
155 // Reset the LayerTreeHost registration for the |src| layer so 156 // Reset the LayerTreeHost registration for the |src| layer so
156 // it can be re-used for the |dest| layer. 157 // it can be re-used for the |dest| layer.
157 src->SetLayerTreeHost(nullptr); 158 src->SetLayerTreeHost(nullptr);
158 159
159 scoped_refptr<Layer> dest = Layer::Create(); 160 scoped_refptr<Layer> dest = Layer::Create();
160 dest->layer_id_ = src->layer_id_; 161 dest->inputs_.layer_id = src->inputs_.layer_id;
161 dest->SetLayerTreeHost(layer_tree_host_.get()); 162 dest->SetLayerTreeHost(layer_tree_host_.get());
162 dest->FromLayerPropertiesProto(props); 163 dest->FromLayerPropertiesProto(props);
163 164
164 // Verify that both layers are equal. 165 // Verify that both layers are equal.
165 EXPECT_EQ(src->transform_origin_, dest->transform_origin_); 166 EXPECT_EQ(src->inputs_.transform_origin, dest->inputs_.transform_origin);
166 EXPECT_EQ(src->background_color_, dest->background_color_); 167 EXPECT_EQ(src->inputs_.background_color, dest->inputs_.background_color);
167 EXPECT_EQ(src->bounds_, dest->bounds_); 168 EXPECT_EQ(src->inputs_.bounds, dest->inputs_.bounds);
168 EXPECT_EQ(src->transform_tree_index_, dest->transform_tree_index_); 169 EXPECT_EQ(src->transform_tree_index_, dest->transform_tree_index_);
169 EXPECT_EQ(src->effect_tree_index_, dest->effect_tree_index_); 170 EXPECT_EQ(src->effect_tree_index_, dest->effect_tree_index_);
170 EXPECT_EQ(src->clip_tree_index_, dest->clip_tree_index_); 171 EXPECT_EQ(src->clip_tree_index_, dest->clip_tree_index_);
171 EXPECT_EQ(src->offset_to_transform_parent_, 172 EXPECT_EQ(src->offset_to_transform_parent_,
172 dest->offset_to_transform_parent_); 173 dest->offset_to_transform_parent_);
173 EXPECT_EQ(src->double_sided_, dest->double_sided_); 174 EXPECT_EQ(src->inputs_.double_sided, dest->inputs_.double_sided);
174 EXPECT_EQ(src->draws_content_, dest->draws_content_); 175 EXPECT_EQ(src->draws_content_, dest->draws_content_);
175 EXPECT_EQ(src->hide_layer_and_subtree_, dest->hide_layer_and_subtree_); 176 EXPECT_EQ(src->inputs_.hide_layer_and_subtree,
176 EXPECT_EQ(src->masks_to_bounds_, dest->masks_to_bounds_); 177 dest->inputs_.hide_layer_and_subtree);
177 EXPECT_EQ(src->main_thread_scrolling_reasons_, 178 EXPECT_EQ(src->inputs_.masks_to_bounds, dest->inputs_.masks_to_bounds);
178 dest->main_thread_scrolling_reasons_); 179 EXPECT_EQ(src->inputs_.main_thread_scrolling_reasons,
179 EXPECT_EQ(src->non_fast_scrollable_region_, 180 dest->inputs_.main_thread_scrolling_reasons);
180 dest->non_fast_scrollable_region_); 181 EXPECT_EQ(src->inputs_.non_fast_scrollable_region,
181 EXPECT_EQ(src->touch_event_handler_region_, 182 dest->inputs_.non_fast_scrollable_region);
182 dest->touch_event_handler_region_); 183 EXPECT_EQ(src->inputs_.touch_event_handler_region,
183 EXPECT_EQ(src->contents_opaque_, dest->contents_opaque_); 184 dest->inputs_.touch_event_handler_region);
184 EXPECT_EQ(src->opacity_, dest->opacity_); 185 EXPECT_EQ(src->inputs_.contents_opaque, dest->inputs_.contents_opaque);
185 EXPECT_EQ(src->blend_mode_, dest->blend_mode_); 186 EXPECT_EQ(src->inputs_.opacity, dest->inputs_.opacity);
186 EXPECT_EQ(src->is_root_for_isolated_group_, 187 EXPECT_EQ(src->inputs_.blend_mode, dest->inputs_.blend_mode);
187 dest->is_root_for_isolated_group_); 188 EXPECT_EQ(src->inputs_.is_root_for_isolated_group,
188 EXPECT_EQ(src->position_, dest->position_); 189 dest->inputs_.is_root_for_isolated_group);
189 EXPECT_EQ(src->is_container_for_fixed_position_layers_, 190 EXPECT_EQ(src->inputs_.position, dest->inputs_.position);
190 dest->is_container_for_fixed_position_layers_); 191 EXPECT_EQ(src->inputs_.is_container_for_fixed_position_layers,
191 EXPECT_EQ(src->position_constraint_, dest->position_constraint_); 192 dest->inputs_.is_container_for_fixed_position_layers);
192 EXPECT_EQ(src->should_flatten_transform_, dest->should_flatten_transform_); 193 EXPECT_EQ(src->inputs_.position_constraint,
194 dest->inputs_.position_constraint);
195 EXPECT_EQ(src->inputs_.should_flatten_transform,
196 dest->inputs_.should_flatten_transform);
193 EXPECT_EQ(src->should_flatten_transform_from_property_tree_, 197 EXPECT_EQ(src->should_flatten_transform_from_property_tree_,
194 dest->should_flatten_transform_from_property_tree_); 198 dest->should_flatten_transform_from_property_tree_);
195 EXPECT_EQ(src->draw_blend_mode_, dest->draw_blend_mode_); 199 EXPECT_EQ(src->draw_blend_mode_, dest->draw_blend_mode_);
196 EXPECT_EQ(src->use_parent_backface_visibility_, 200 EXPECT_EQ(src->inputs_.use_parent_backface_visibility,
197 dest->use_parent_backface_visibility_); 201 dest->inputs_.use_parent_backface_visibility);
198 EXPECT_EQ(src->transform_, dest->transform_); 202 EXPECT_EQ(src->inputs_.transform, dest->inputs_.transform);
199 EXPECT_EQ(src->sorting_context_id_, dest->sorting_context_id_); 203 EXPECT_EQ(src->inputs_.sorting_context_id,
204 dest->inputs_.sorting_context_id);
200 EXPECT_EQ(src->num_descendants_that_draw_content_, 205 EXPECT_EQ(src->num_descendants_that_draw_content_,
201 dest->num_descendants_that_draw_content_); 206 dest->num_descendants_that_draw_content_);
202 EXPECT_EQ(src->scroll_clip_layer_id_, dest->scroll_clip_layer_id_); 207 EXPECT_EQ(src->inputs_.scroll_clip_layer_id,
203 EXPECT_EQ(src->user_scrollable_horizontal_, 208 dest->inputs_.scroll_clip_layer_id);
204 dest->user_scrollable_horizontal_); 209 EXPECT_EQ(src->inputs_.user_scrollable_horizontal,
205 EXPECT_EQ(src->user_scrollable_vertical_, dest->user_scrollable_vertical_); 210 dest->inputs_.user_scrollable_horizontal);
206 EXPECT_EQ(src->scroll_offset_, dest->scroll_offset_); 211 EXPECT_EQ(src->inputs_.user_scrollable_vertical,
207 EXPECT_EQ(update_rect, dest->update_rect_); 212 dest->inputs_.user_scrollable_vertical);
213 EXPECT_EQ(src->inputs_.scroll_offset, dest->inputs_.scroll_offset);
214 EXPECT_EQ(update_rect, dest->inputs_.update_rect);
208 215
209 if (src->scroll_parent_) { 216 if (src->inputs_.scroll_parent) {
210 ASSERT_TRUE(dest->scroll_parent_); 217 ASSERT_TRUE(dest->inputs_.scroll_parent);
211 EXPECT_EQ(src->scroll_parent_->id(), dest->scroll_parent_->id()); 218 EXPECT_EQ(src->inputs_.scroll_parent->id(),
219 dest->inputs_.scroll_parent->id());
212 } else { 220 } else {
213 EXPECT_FALSE(dest->scroll_parent_); 221 EXPECT_FALSE(dest->inputs_.scroll_parent);
214 } 222 }
215 if (src->scroll_children_) { 223 if (src->scroll_children_) {
216 ASSERT_TRUE(dest->scroll_children_); 224 ASSERT_TRUE(dest->scroll_children_);
217 EXPECT_EQ(*(src->scroll_children_), *(dest->scroll_children_)); 225 EXPECT_EQ(*(src->scroll_children_), *(dest->scroll_children_));
218 } else { 226 } else {
219 EXPECT_FALSE(dest->scroll_children_); 227 EXPECT_FALSE(dest->scroll_children_);
220 } 228 }
221 229
222 if (src->clip_parent_) { 230 if (src->inputs_.clip_parent) {
223 ASSERT_TRUE(dest->clip_parent_); 231 ASSERT_TRUE(dest->inputs_.clip_parent);
224 EXPECT_EQ(src->clip_parent_->id(), dest->clip_parent_->id()); 232 EXPECT_EQ(src->inputs_.clip_parent->id(),
233 dest->inputs_.clip_parent->id());
225 } else { 234 } else {
226 ASSERT_FALSE(dest->clip_parent_); 235 ASSERT_FALSE(dest->inputs_.clip_parent);
227 } 236 }
228 if (src->clip_children_) { 237 if (src->clip_children_) {
229 ASSERT_TRUE(dest->clip_children_); 238 ASSERT_TRUE(dest->clip_children_);
230 EXPECT_EQ(*(src->clip_children_), *(dest->clip_children_)); 239 EXPECT_EQ(*(src->clip_children_), *(dest->clip_children_));
231 } else { 240 } else {
232 EXPECT_FALSE(dest->clip_children_); 241 EXPECT_FALSE(dest->clip_children_);
233 } 242 }
234 243
235 // The following member should have been reset during serialization. 244 // The following member should have been reset during serialization.
236 EXPECT_EQ(gfx::Rect(), src->update_rect_); 245 EXPECT_EQ(gfx::Rect(), src->inputs_.update_rect);
237 246
238 // Before deleting |dest|, the LayerTreeHost must be unset. 247 // Before deleting |dest|, the LayerTreeHost must be unset.
239 dest->SetLayerTreeHost(nullptr); 248 dest->SetLayerTreeHost(nullptr);
240 249
241 // Cleanup scroll tree. 250 // Cleanup scroll tree.
242 if (src->scroll_parent_) 251 if (src->inputs_.scroll_parent)
243 layer_tree_host_->UnregisterLayer(src->scroll_parent_); 252 layer_tree_host_->UnregisterLayer(src->inputs_.scroll_parent);
244 src->scroll_parent_ = nullptr; 253 src->inputs_.scroll_parent = nullptr;
245 dest->scroll_parent_ = nullptr; 254 dest->inputs_.scroll_parent = nullptr;
246 if (src->scroll_children_) { 255 if (src->scroll_children_) {
247 for (auto* child : *(src->scroll_children_)) 256 for (auto* child : *(src->scroll_children_))
248 layer_tree_host_->UnregisterLayer(child); 257 layer_tree_host_->UnregisterLayer(child);
249 src->scroll_children_.reset(); 258 src->scroll_children_.reset();
250 dest->scroll_children_.reset(); 259 dest->scroll_children_.reset();
251 } 260 }
252 261
253 // Cleanup clip tree. 262 // Cleanup clip tree.
254 if (src->clip_parent_) 263 if (src->inputs_.clip_parent)
255 layer_tree_host_->UnregisterLayer(src->clip_parent_); 264 layer_tree_host_->UnregisterLayer(src->inputs_.clip_parent);
256 src->clip_parent_ = nullptr; 265 src->inputs_.clip_parent = nullptr;
257 dest->clip_parent_ = nullptr; 266 dest->inputs_.clip_parent = nullptr;
258 if (src->clip_children_) { 267 if (src->clip_children_) {
259 for (auto* child : *(src->clip_children_)) 268 for (auto* child : *(src->clip_children_))
260 layer_tree_host_->UnregisterLayer(child); 269 layer_tree_host_->UnregisterLayer(child);
261 src->clip_children_.reset(); 270 src->clip_children_.reset();
262 dest->clip_children_.reset(); 271 dest->clip_children_.reset();
263 } 272 }
264 } 273 }
265 274
266 void RunNoMembersChangedTest() { 275 void RunNoMembersChangedTest() {
267 scoped_refptr<Layer> layer = Layer::Create(); 276 scoped_refptr<Layer> layer = Layer::Create();
268 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); 277 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get());
269 } 278 }
270 279
271 void RunArbitraryMembersChangedTest() { 280 void RunArbitraryMembersChangedTest() {
272 scoped_refptr<Layer> layer = Layer::Create(); 281 scoped_refptr<Layer> layer = Layer::Create();
273 layer->transform_origin_ = gfx::Point3F(3.0f, 1.0f, 4.0f); 282 layer->inputs_.transform_origin = gfx::Point3F(3.0f, 1.0f, 4.0f);
274 layer->background_color_ = SK_ColorRED; 283 layer->inputs_.background_color = SK_ColorRED;
275 layer->bounds_ = gfx::Size(3, 14); 284 layer->inputs_.bounds = gfx::Size(3, 14);
276 layer->transform_tree_index_ = -1; 285 layer->transform_tree_index_ = -1;
277 layer->effect_tree_index_ = -1; 286 layer->effect_tree_index_ = -1;
278 layer->clip_tree_index_ = 71; 287 layer->clip_tree_index_ = 71;
279 layer->offset_to_transform_parent_ = gfx::Vector2dF(3.14f, 1.618f); 288 layer->offset_to_transform_parent_ = gfx::Vector2dF(3.14f, 1.618f);
280 layer->double_sided_ = true; 289 layer->inputs_.double_sided = true;
281 layer->draws_content_ = true; 290 layer->draws_content_ = true;
282 layer->hide_layer_and_subtree_ = false; 291 layer->inputs_.hide_layer_and_subtree = false;
283 layer->masks_to_bounds_ = true; 292 layer->inputs_.masks_to_bounds = true;
284 layer->main_thread_scrolling_reasons_ = 293 layer->inputs_.main_thread_scrolling_reasons =
285 MainThreadScrollingReason::kNotScrollingOnMain; 294 MainThreadScrollingReason::kNotScrollingOnMain;
286 layer->non_fast_scrollable_region_ = Region(gfx::Rect(5, 1, 14, 3)); 295 layer->inputs_.non_fast_scrollable_region = Region(gfx::Rect(5, 1, 14, 3));
287 layer->touch_event_handler_region_ = Region(gfx::Rect(3, 14, 1, 5)); 296 layer->inputs_.touch_event_handler_region = Region(gfx::Rect(3, 14, 1, 5));
288 layer->contents_opaque_ = true; 297 layer->inputs_.contents_opaque = true;
289 layer->opacity_ = 1.f; 298 layer->inputs_.opacity = 1.f;
290 layer->blend_mode_ = SkXfermode::kSrcOver_Mode; 299 layer->inputs_.blend_mode = SkXfermode::kSrcOver_Mode;
291 layer->is_root_for_isolated_group_ = true; 300 layer->inputs_.is_root_for_isolated_group = true;
292 layer->position_ = gfx::PointF(3.14f, 6.28f); 301 layer->inputs_.position = gfx::PointF(3.14f, 6.28f);
293 layer->is_container_for_fixed_position_layers_ = true; 302 layer->inputs_.is_container_for_fixed_position_layers = true;
294 LayerPositionConstraint pos_con; 303 LayerPositionConstraint pos_con;
295 pos_con.set_is_fixed_to_bottom_edge(true); 304 pos_con.set_is_fixed_to_bottom_edge(true);
296 layer->position_constraint_ = pos_con; 305 layer->inputs_.position_constraint = pos_con;
297 layer->should_flatten_transform_ = true; 306 layer->inputs_.should_flatten_transform = true;
298 layer->should_flatten_transform_from_property_tree_ = true; 307 layer->should_flatten_transform_from_property_tree_ = true;
299 layer->draw_blend_mode_ = SkXfermode::kSrcOut_Mode; 308 layer->draw_blend_mode_ = SkXfermode::kSrcOut_Mode;
300 layer->use_parent_backface_visibility_ = true; 309 layer->inputs_.use_parent_backface_visibility = true;
301 gfx::Transform transform; 310 gfx::Transform transform;
302 transform.Rotate(90); 311 transform.Rotate(90);
303 layer->transform_ = transform; 312 layer->inputs_.transform = transform;
304 layer->sorting_context_id_ = 0; 313 layer->inputs_.sorting_context_id = 0;
305 layer->num_descendants_that_draw_content_ = 5; 314 layer->num_descendants_that_draw_content_ = 5;
306 layer->scroll_clip_layer_id_ = Layer::INVALID_ID; 315 layer->inputs_.scroll_clip_layer_id = Layer::INVALID_ID;
307 layer->user_scrollable_horizontal_ = false; 316 layer->inputs_.user_scrollable_horizontal = false;
308 layer->user_scrollable_vertical_ = true; 317 layer->inputs_.user_scrollable_vertical = true;
309 layer->scroll_offset_ = gfx::ScrollOffset(3, 14); 318 layer->inputs_.scroll_offset = gfx::ScrollOffset(3, 14);
310 layer->update_rect_ = gfx::Rect(14, 15); 319 layer->inputs_.update_rect = gfx::Rect(14, 15);
311 320
312 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); 321 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get());
313 } 322 }
314 323
315 void RunAllMembersChangedTest() { 324 void RunAllMembersChangedTest() {
316 scoped_refptr<Layer> layer = Layer::Create(); 325 scoped_refptr<Layer> layer = Layer::Create();
317 layer->transform_origin_ = gfx::Point3F(3.0f, 1.0f, 4.0f); 326 layer->inputs_.transform_origin = gfx::Point3F(3.0f, 1.0f, 4.0f);
318 layer->background_color_ = SK_ColorRED; 327 layer->inputs_.background_color = SK_ColorRED;
319 layer->bounds_ = gfx::Size(3, 14); 328 layer->inputs_.bounds = gfx::Size(3, 14);
320 layer->transform_tree_index_ = 39; 329 layer->transform_tree_index_ = 39;
321 layer->effect_tree_index_ = 17; 330 layer->effect_tree_index_ = 17;
322 layer->clip_tree_index_ = 71; 331 layer->clip_tree_index_ = 71;
323 layer->offset_to_transform_parent_ = gfx::Vector2dF(3.14f, 1.618f); 332 layer->offset_to_transform_parent_ = gfx::Vector2dF(3.14f, 1.618f);
324 layer->double_sided_ = !layer->double_sided_; 333 layer->inputs_.double_sided = !layer->inputs_.double_sided;
325 layer->draws_content_ = !layer->draws_content_; 334 layer->draws_content_ = !layer->draws_content_;
326 layer->hide_layer_and_subtree_ = !layer->hide_layer_and_subtree_; 335 layer->inputs_.hide_layer_and_subtree =
327 layer->masks_to_bounds_ = !layer->masks_to_bounds_; 336 !layer->inputs_.hide_layer_and_subtree;
328 layer->main_thread_scrolling_reasons_ = 337 layer->inputs_.masks_to_bounds = !layer->inputs_.masks_to_bounds;
338 layer->inputs_.main_thread_scrolling_reasons =
329 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; 339 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects;
330 layer->non_fast_scrollable_region_ = Region(gfx::Rect(5, 1, 14, 3)); 340 layer->inputs_.non_fast_scrollable_region = Region(gfx::Rect(5, 1, 14, 3));
331 layer->touch_event_handler_region_ = Region(gfx::Rect(3, 14, 1, 5)); 341 layer->inputs_.touch_event_handler_region = Region(gfx::Rect(3, 14, 1, 5));
332 layer->contents_opaque_ = !layer->contents_opaque_; 342 layer->inputs_.contents_opaque = !layer->inputs_.contents_opaque;
333 layer->opacity_ = 3.14f; 343 layer->inputs_.opacity = 3.14f;
334 layer->blend_mode_ = SkXfermode::kSrcIn_Mode; 344 layer->inputs_.blend_mode = SkXfermode::kSrcIn_Mode;
335 layer->is_root_for_isolated_group_ = !layer->is_root_for_isolated_group_; 345 layer->inputs_.is_root_for_isolated_group =
336 layer->position_ = gfx::PointF(3.14f, 6.28f); 346 !layer->inputs_.is_root_for_isolated_group;
337 layer->is_container_for_fixed_position_layers_ = 347 layer->inputs_.position = gfx::PointF(3.14f, 6.28f);
338 !layer->is_container_for_fixed_position_layers_; 348 layer->inputs_.is_container_for_fixed_position_layers =
349 !layer->inputs_.is_container_for_fixed_position_layers;
339 LayerPositionConstraint pos_con; 350 LayerPositionConstraint pos_con;
340 pos_con.set_is_fixed_to_bottom_edge(true); 351 pos_con.set_is_fixed_to_bottom_edge(true);
341 layer->position_constraint_ = pos_con; 352 layer->inputs_.position_constraint = pos_con;
342 layer->should_flatten_transform_ = !layer->should_flatten_transform_; 353 layer->inputs_.should_flatten_transform =
354 !layer->inputs_.should_flatten_transform;
343 layer->should_flatten_transform_from_property_tree_ = 355 layer->should_flatten_transform_from_property_tree_ =
344 !layer->should_flatten_transform_from_property_tree_; 356 !layer->should_flatten_transform_from_property_tree_;
345 layer->draw_blend_mode_ = SkXfermode::kSrcOut_Mode; 357 layer->draw_blend_mode_ = SkXfermode::kSrcOut_Mode;
346 layer->use_parent_backface_visibility_ = 358 layer->inputs_.use_parent_backface_visibility =
347 !layer->use_parent_backface_visibility_; 359 !layer->inputs_.use_parent_backface_visibility;
348 gfx::Transform transform; 360 gfx::Transform transform;
349 transform.Rotate(90); 361 transform.Rotate(90);
350 layer->transform_ = transform; 362 layer->inputs_.transform = transform;
351 layer->sorting_context_id_ = 42; 363 layer->inputs_.sorting_context_id = 42;
352 layer->num_descendants_that_draw_content_ = 5; 364 layer->num_descendants_that_draw_content_ = 5;
353 layer->scroll_clip_layer_id_ = 17; 365 layer->inputs_.scroll_clip_layer_id = 17;
354 layer->user_scrollable_horizontal_ = !layer->user_scrollable_horizontal_; 366 layer->inputs_.user_scrollable_horizontal =
355 layer->user_scrollable_vertical_ = !layer->user_scrollable_vertical_; 367 !layer->inputs_.user_scrollable_horizontal;
356 layer->scroll_offset_ = gfx::ScrollOffset(3, 14); 368 layer->inputs_.user_scrollable_vertical =
357 layer->update_rect_ = gfx::Rect(14, 15); 369 !layer->inputs_.user_scrollable_vertical;
370 layer->inputs_.scroll_offset = gfx::ScrollOffset(3, 14);
371 layer->inputs_.update_rect = gfx::Rect(14, 15);
358 372
359 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); 373 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get());
360 } 374 }
361 375
362 void VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization( 376 void VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization(
363 scoped_refptr<SolidColorScrollbarLayer> source_scrollbar) { 377 scoped_refptr<SolidColorScrollbarLayer> source_scrollbar) {
364 proto::LayerProperties serialized_scrollbar; 378 proto::LayerProperties serialized_scrollbar;
365 source_scrollbar->LayerSpecificPropertiesToProto(&serialized_scrollbar); 379 source_scrollbar->LayerSpecificPropertiesToProto(&serialized_scrollbar);
366 380
367 scoped_refptr<SolidColorScrollbarLayer> deserialized_scrollbar = 381 scoped_refptr<SolidColorScrollbarLayer> deserialized_scrollbar =
368 SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL, -1, 382 SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL, -1,
369 -1, false, Layer::INVALID_ID); 383 -1, false, Layer::INVALID_ID);
370 deserialized_scrollbar->layer_id_ = source_scrollbar->layer_id_; 384 deserialized_scrollbar->inputs_.layer_id =
385 source_scrollbar->inputs_.layer_id;
371 386
372 // FromLayerSpecificPropertiesProto expects a non-null LayerTreeHost to be 387 // FromLayerSpecificPropertiesProto expects a non-null LayerTreeHost to be
373 // set. 388 // set.
374 deserialized_scrollbar->SetLayerTreeHost(layer_tree_host_.get()); 389 deserialized_scrollbar->SetLayerTreeHost(layer_tree_host_.get());
375 deserialized_scrollbar->FromLayerSpecificPropertiesProto( 390 deserialized_scrollbar->FromLayerSpecificPropertiesProto(
376 serialized_scrollbar); 391 serialized_scrollbar);
377 392
378 EXPECT_EQ(source_scrollbar->track_start_, 393 EXPECT_EQ(source_scrollbar->track_start_,
379 deserialized_scrollbar->track_start_); 394 deserialized_scrollbar->track_start_);
380 EXPECT_EQ(source_scrollbar->thumb_thickness_, 395 EXPECT_EQ(source_scrollbar->thumb_thickness_,
381 deserialized_scrollbar->thumb_thickness_); 396 deserialized_scrollbar->thumb_thickness_);
382 EXPECT_EQ(source_scrollbar->scroll_layer_id_, 397 EXPECT_EQ(source_scrollbar->scroll_layer_id_,
383 deserialized_scrollbar->scroll_layer_id_); 398 deserialized_scrollbar->scroll_layer_id_);
384 EXPECT_EQ(source_scrollbar->is_left_side_vertical_scrollbar_, 399 EXPECT_EQ(source_scrollbar->is_left_side_vertical_scrollbar_,
385 deserialized_scrollbar->is_left_side_vertical_scrollbar_); 400 deserialized_scrollbar->is_left_side_vertical_scrollbar_);
386 EXPECT_EQ(source_scrollbar->orientation_, 401 EXPECT_EQ(source_scrollbar->orientation_,
387 deserialized_scrollbar->orientation_); 402 deserialized_scrollbar->orientation_);
388 403
389 deserialized_scrollbar->SetLayerTreeHost(nullptr); 404 deserialized_scrollbar->SetLayerTreeHost(nullptr);
390 } 405 }
391 406
392 void RunScrollAndClipLayersTest() { 407 void RunScrollAndClipLayersTest() {
393 scoped_refptr<Layer> layer = Layer::Create(); 408 scoped_refptr<Layer> layer = Layer::Create();
394 409
395 scoped_refptr<Layer> scroll_parent = Layer::Create(); 410 scoped_refptr<Layer> scroll_parent = Layer::Create();
396 layer->scroll_parent_ = scroll_parent.get(); 411 layer->inputs_.scroll_parent = scroll_parent.get();
397 scoped_refptr<Layer> scroll_child = Layer::Create(); 412 scoped_refptr<Layer> scroll_child = Layer::Create();
398 layer->scroll_children_.reset(new std::set<Layer*>); 413 layer->scroll_children_.reset(new std::set<Layer*>);
399 layer->scroll_children_->insert(scroll_child.get()); 414 layer->scroll_children_->insert(scroll_child.get());
400 415
401 scoped_refptr<Layer> clip_parent = Layer::Create(); 416 scoped_refptr<Layer> clip_parent = Layer::Create();
402 layer->clip_parent_ = clip_parent.get(); 417 layer->inputs_.clip_parent = clip_parent.get();
403 layer->clip_children_.reset(new std::set<Layer*>); 418 layer->clip_children_.reset(new std::set<Layer*>);
404 scoped_refptr<Layer> clip_child1 = Layer::Create(); 419 scoped_refptr<Layer> clip_child1 = Layer::Create();
405 layer->clip_children_->insert(clip_child1.get()); 420 layer->clip_children_->insert(clip_child1.get());
406 scoped_refptr<Layer> clip_child2 = Layer::Create(); 421 scoped_refptr<Layer> clip_child2 = Layer::Create();
407 layer->clip_children_->insert(clip_child2.get()); 422 layer->clip_children_->insert(clip_child2.get());
408 423
409 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); 424 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get());
410 } 425 }
411 426
412 void RunHierarchyDeserializationWithLayerTreeHostTest() { 427 void RunHierarchyDeserializationWithLayerTreeHostTest() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 layer_tree_host_.get()); 550 layer_tree_host_.get());
536 551
537 // Ensure initial copy is correct. 552 // Ensure initial copy is correct.
538 ASSERT_EQ(2u, layer_dest_root->children().size()); 553 ASSERT_EQ(2u, layer_dest_root->children().size());
539 scoped_refptr<Layer> layer_dest_a = layer_dest_root->children()[0]; 554 scoped_refptr<Layer> layer_dest_a = layer_dest_root->children()[0];
540 EXPECT_EQ(layer_src_a->id(), layer_dest_a->id()); 555 EXPECT_EQ(layer_src_a->id(), layer_dest_a->id());
541 scoped_refptr<Layer> layer_dest_b = layer_dest_root->children()[1]; 556 scoped_refptr<Layer> layer_dest_b = layer_dest_root->children()[1];
542 EXPECT_EQ(layer_src_b->id(), layer_dest_b->id()); 557 EXPECT_EQ(layer_src_b->id(), layer_dest_b->id());
543 558
544 // Swap order of the children. 559 // Swap order of the children.
545 scoped_refptr<Layer> tmp_a = layer_src_root->children_[0]; 560 scoped_refptr<Layer> tmp_a = layer_src_root->inputs_.children[0];
546 layer_src_root->children_[0] = layer_src_root->children_[1]; 561 layer_src_root->inputs_.children[0] = layer_src_root->inputs_.children[1];
547 layer_src_root->children_[1] = tmp_a; 562 layer_src_root->inputs_.children[1] = tmp_a;
548 563
549 // Fake the fact that the destination layers have valid indexes. 564 // Fake the fact that the destination layers have valid indexes.
550 layer_dest_root->transform_tree_index_ = 33; 565 layer_dest_root->transform_tree_index_ = 33;
551 layer_dest_a->transform_tree_index_ = 42; 566 layer_dest_a->transform_tree_index_ = 42;
552 layer_dest_b->transform_tree_index_ = 24; 567 layer_dest_b->transform_tree_index_ = 24;
553 568
554 // Now serialize and deserialize again. 569 // Now serialize and deserialize again.
555 proto::LayerNode root_proto_2; 570 proto::LayerNode root_proto_2;
556 layer_src_root->ToLayerNodeProto(&root_proto_2); 571 layer_src_root->ToLayerNodeProto(&root_proto_2);
557 layer_dest_root->ClearLayerTreePropertiesForDeserializationAndAddToMap( 572 layer_dest_root->ClearLayerTreePropertiesForDeserializationAndAddToMap(
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 EXPECT_EQ(1, did_receive_first_result_from_this_source); 2200 EXPECT_EQ(1, did_receive_first_result_from_this_source);
2186 EXPECT_EQ(1, did_receive_result_from_different_source); 2201 EXPECT_EQ(1, did_receive_result_from_different_source);
2187 EXPECT_EQ(1, did_receive_result_from_anonymous_source); 2202 EXPECT_EQ(1, did_receive_result_from_anonymous_source);
2188 EXPECT_EQ(1, did_receive_second_result_from_this_source); 2203 EXPECT_EQ(1, did_receive_second_result_from_this_source);
2189 } 2204 }
2190 2205
2191 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) { 2206 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) {
2192 scoped_refptr<Layer> layer = Layer::Create(); 2207 scoped_refptr<Layer> layer = Layer::Create();
2193 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer)); 2208 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer));
2194 2209
2210 LayerInternalsForTest layer_internals(layer.get());
2211
2195 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); 2212 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1);
2196 layer->OnOpacityAnimated(0.5f); 2213 layer_internals.OnOpacityAnimated(0.5f);
2197 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 2214 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
2198 2215
2199 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); 2216 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1);
2200 gfx::Transform transform; 2217 gfx::Transform transform;
2201 transform.Rotate(45.0); 2218 transform.Rotate(45.0);
2202 layer->OnTransformAnimated(transform); 2219 layer_internals.OnTransformAnimated(transform);
2203 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 2220 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
2204 2221
2205 // Scroll offset animation should not schedule a layer update since it is 2222 // Scroll offset animation should not schedule a layer update since it is
2206 // handled similarly to normal compositor scroll updates. 2223 // handled similarly to normal compositor scroll updates.
2207 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(0); 2224 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(0);
2208 layer->OnScrollOffsetAnimated(gfx::ScrollOffset(10, 10)); 2225 layer_internals.OnScrollOffsetAnimated(gfx::ScrollOffset(10, 10));
2209 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 2226 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
2210 } 2227 }
2211 2228
2212 TEST_F(LayerTest, RecursiveHierarchySerialization) { 2229 TEST_F(LayerTest, RecursiveHierarchySerialization) {
2213 /* Testing serialization and deserialization of a tree that looks like this: 2230 /* Testing serialization and deserialization of a tree that looks like this:
2214 root 2231 root
2215 / \ 2232 / \
2216 a b 2233 a b
2217 \ 2234 \
2218 c 2235 c
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 2533 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
2517 2534
2518 test_layer->PushPropertiesTo(impl_layer.get()); 2535 test_layer->PushPropertiesTo(impl_layer.get());
2519 2536
2520 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); 2537 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id());
2521 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 2538 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
2522 } 2539 }
2523 2540
2524 } // namespace 2541 } // namespace
2525 } // namespace cc 2542 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/painted_scrollbar_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698