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

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 data from embedder into 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
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"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 // Serializes |src| to proto and back again to a Layer, then verifies that 123 // Serializes |src| to proto and back again to a Layer, then verifies that
124 // the two Layers are equal for serialization purposes. 124 // the two Layers are equal for serialization purposes.
125 void VerifyBaseLayerPropertiesSerializationAndDeserialization(Layer* src) { 125 void VerifyBaseLayerPropertiesSerializationAndDeserialization(Layer* src) {
126 // This is required to ensure that properties are serialized. 126 // This is required to ensure that properties are serialized.
127 src->SetNeedsPushProperties(); 127 src->SetNeedsPushProperties();
128 src->SetLayerTreeHost(layer_tree_host_.get()); 128 src->SetLayerTreeHost(layer_tree_host_.get());
129 129
130 // The following member is reset during serialization, so store the original 130 // The following member is reset during serialization, so store the original
131 // values. 131 // values.
132 gfx::Rect update_rect = src->update_rect_; 132 gfx::Rect update_rect = src->inputs_.data.update_rect;
133 133
134 // Serialize |src| to protobuf and read the first entry in the 134 // Serialize |src| to protobuf and read the first entry in the
135 // LayerUpdate. There are no descendants, so the serialization 135 // LayerUpdate. There are no descendants, so the serialization
136 // of |src| is the only entry. 136 // of |src| is the only entry.
137 proto::LayerUpdate layer_update; 137 proto::LayerUpdate layer_update;
138 src->ToLayerPropertiesProto(&layer_update); 138 src->ToLayerPropertiesProto(&layer_update);
139 ASSERT_EQ(1, layer_update.layers_size()); 139 ASSERT_EQ(1, layer_update.layers_size());
140 proto::LayerProperties props = layer_update.layers(0); 140 proto::LayerProperties props = layer_update.layers(0);
141 141
142 // The |dest| layer needs to be able to lookup the scroll and clip parents. 142 // The |dest| layer needs to be able to lookup the scroll and clip parents.
143 if (src->scroll_parent_) 143 if (src->inputs_.data.scroll_parent)
144 layer_tree_host_->RegisterLayer(src->scroll_parent_); 144 layer_tree_host_->RegisterLayer(src->inputs_.data.scroll_parent);
145 if (src->scroll_children_) { 145 if (src->scroll_children_) {
146 for (auto* child : *(src->scroll_children_)) 146 for (auto* child : *(src->scroll_children_))
147 layer_tree_host_->RegisterLayer(child); 147 layer_tree_host_->RegisterLayer(child);
148 } 148 }
149 if (src->clip_parent_) 149 if (src->inputs_.data.clip_parent)
150 layer_tree_host_->RegisterLayer(src->clip_parent_); 150 layer_tree_host_->RegisterLayer(src->inputs_.data.clip_parent);
151 if (src->clip_children_) { 151 if (src->clip_children_) {
152 for (auto* child : *(src->clip_children_)) 152 for (auto* child : *(src->clip_children_))
153 layer_tree_host_->RegisterLayer(child); 153 layer_tree_host_->RegisterLayer(child);
154 } 154 }
155 // Reset the LayerTreeHost registration for the |src| layer so 155 // Reset the LayerTreeHost registration for the |src| layer so
156 // it can be re-used for the |dest| layer. 156 // it can be re-used for the |dest| layer.
157 src->SetLayerTreeHost(nullptr); 157 src->SetLayerTreeHost(nullptr);
158 158
159 scoped_refptr<Layer> dest = Layer::Create(); 159 scoped_refptr<Layer> dest = Layer::Create();
160 dest->layer_id_ = src->layer_id_; 160 dest->inputs_.data.layer_id = src->inputs_.data.layer_id;
161 dest->SetLayerTreeHost(layer_tree_host_.get()); 161 dest->SetLayerTreeHost(layer_tree_host_.get());
162 dest->FromLayerPropertiesProto(props); 162 dest->FromLayerPropertiesProto(props);
163 163
164 // Verify that both layers are equal. 164 // Verify that both layers are equal.
165 EXPECT_EQ(src->transform_origin_, dest->transform_origin_); 165 EXPECT_EQ(src->inputs_.data.transform_origin,
166 EXPECT_EQ(src->background_color_, dest->background_color_); 166 dest->inputs_.data.transform_origin);
167 EXPECT_EQ(src->bounds_, dest->bounds_); 167 EXPECT_EQ(src->inputs_.data.background_color,
168 dest->inputs_.data.background_color);
169 EXPECT_EQ(src->inputs_.data.bounds, dest->inputs_.data.bounds);
168 EXPECT_EQ(src->transform_tree_index_, dest->transform_tree_index_); 170 EXPECT_EQ(src->transform_tree_index_, dest->transform_tree_index_);
169 EXPECT_EQ(src->effect_tree_index_, dest->effect_tree_index_); 171 EXPECT_EQ(src->effect_tree_index_, dest->effect_tree_index_);
170 EXPECT_EQ(src->clip_tree_index_, dest->clip_tree_index_); 172 EXPECT_EQ(src->clip_tree_index_, dest->clip_tree_index_);
171 EXPECT_EQ(src->offset_to_transform_parent_, 173 EXPECT_EQ(src->offset_to_transform_parent_,
172 dest->offset_to_transform_parent_); 174 dest->offset_to_transform_parent_);
173 EXPECT_EQ(src->double_sided_, dest->double_sided_); 175 EXPECT_EQ(src->inputs_.data.double_sided, dest->inputs_.data.double_sided);
174 EXPECT_EQ(src->draws_content_, dest->draws_content_); 176 EXPECT_EQ(src->draws_content_, dest->draws_content_);
175 EXPECT_EQ(src->hide_layer_and_subtree_, dest->hide_layer_and_subtree_); 177 EXPECT_EQ(src->inputs_.data.hide_layer_and_subtree,
176 EXPECT_EQ(src->masks_to_bounds_, dest->masks_to_bounds_); 178 dest->inputs_.data.hide_layer_and_subtree);
177 EXPECT_EQ(src->main_thread_scrolling_reasons_, 179 EXPECT_EQ(src->inputs_.data.masks_to_bounds,
178 dest->main_thread_scrolling_reasons_); 180 dest->inputs_.data.masks_to_bounds);
179 EXPECT_EQ(src->non_fast_scrollable_region_, 181 EXPECT_EQ(src->inputs_.data.main_thread_scrolling_reasons,
180 dest->non_fast_scrollable_region_); 182 dest->inputs_.data.main_thread_scrolling_reasons);
181 EXPECT_EQ(src->touch_event_handler_region_, 183 EXPECT_EQ(src->inputs_.data.non_fast_scrollable_region,
182 dest->touch_event_handler_region_); 184 dest->inputs_.data.non_fast_scrollable_region);
183 EXPECT_EQ(src->contents_opaque_, dest->contents_opaque_); 185 EXPECT_EQ(src->inputs_.data.touch_event_handler_region,
184 EXPECT_EQ(src->opacity_, dest->opacity_); 186 dest->inputs_.data.touch_event_handler_region);
185 EXPECT_EQ(src->blend_mode_, dest->blend_mode_); 187 EXPECT_EQ(src->inputs_.data.contents_opaque,
186 EXPECT_EQ(src->is_root_for_isolated_group_, 188 dest->inputs_.data.contents_opaque);
187 dest->is_root_for_isolated_group_); 189 EXPECT_EQ(src->inputs_.data.opacity, dest->inputs_.data.opacity);
188 EXPECT_EQ(src->position_, dest->position_); 190 EXPECT_EQ(src->inputs_.data.blend_mode, dest->inputs_.data.blend_mode);
189 EXPECT_EQ(src->is_container_for_fixed_position_layers_, 191 EXPECT_EQ(src->inputs_.data.is_root_for_isolated_group,
190 dest->is_container_for_fixed_position_layers_); 192 dest->inputs_.data.is_root_for_isolated_group);
191 EXPECT_EQ(src->position_constraint_, dest->position_constraint_); 193 EXPECT_EQ(src->inputs_.data.position, dest->inputs_.data.position);
192 EXPECT_EQ(src->should_flatten_transform_, dest->should_flatten_transform_); 194 EXPECT_EQ(src->inputs_.data.is_container_for_fixed_position_layers,
195 dest->inputs_.data.is_container_for_fixed_position_layers);
196 EXPECT_EQ(src->inputs_.data.position_constraint,
197 dest->inputs_.data.position_constraint);
198 EXPECT_EQ(src->inputs_.data.should_flatten_transform,
199 dest->inputs_.data.should_flatten_transform);
193 EXPECT_EQ(src->should_flatten_transform_from_property_tree_, 200 EXPECT_EQ(src->should_flatten_transform_from_property_tree_,
194 dest->should_flatten_transform_from_property_tree_); 201 dest->should_flatten_transform_from_property_tree_);
195 EXPECT_EQ(src->draw_blend_mode_, dest->draw_blend_mode_); 202 EXPECT_EQ(src->draw_blend_mode_, dest->draw_blend_mode_);
196 EXPECT_EQ(src->use_parent_backface_visibility_, 203 EXPECT_EQ(src->inputs_.data.use_parent_backface_visibility,
197 dest->use_parent_backface_visibility_); 204 dest->inputs_.data.use_parent_backface_visibility);
198 EXPECT_EQ(src->transform_, dest->transform_); 205 EXPECT_EQ(src->inputs_.data.transform, dest->inputs_.data.transform);
199 EXPECT_EQ(src->sorting_context_id_, dest->sorting_context_id_); 206 EXPECT_EQ(src->inputs_.data.sorting_context_id,
207 dest->inputs_.data.sorting_context_id);
200 EXPECT_EQ(src->num_descendants_that_draw_content_, 208 EXPECT_EQ(src->num_descendants_that_draw_content_,
201 dest->num_descendants_that_draw_content_); 209 dest->num_descendants_that_draw_content_);
202 EXPECT_EQ(src->scroll_clip_layer_id_, dest->scroll_clip_layer_id_); 210 EXPECT_EQ(src->inputs_.data.scroll_clip_layer_id,
203 EXPECT_EQ(src->user_scrollable_horizontal_, 211 dest->inputs_.data.scroll_clip_layer_id);
204 dest->user_scrollable_horizontal_); 212 EXPECT_EQ(src->inputs_.data.user_scrollable_horizontal,
205 EXPECT_EQ(src->user_scrollable_vertical_, dest->user_scrollable_vertical_); 213 dest->inputs_.data.user_scrollable_horizontal);
206 EXPECT_EQ(src->scroll_offset_, dest->scroll_offset_); 214 EXPECT_EQ(src->inputs_.data.user_scrollable_vertical,
207 EXPECT_EQ(update_rect, dest->update_rect_); 215 dest->inputs_.data.user_scrollable_vertical);
216 EXPECT_EQ(src->inputs_.data.scroll_offset,
217 dest->inputs_.data.scroll_offset);
218 EXPECT_EQ(update_rect, dest->inputs_.data.update_rect);
208 219
209 if (src->scroll_parent_) { 220 if (src->inputs_.data.scroll_parent) {
210 ASSERT_TRUE(dest->scroll_parent_); 221 ASSERT_TRUE(dest->inputs_.data.scroll_parent);
211 EXPECT_EQ(src->scroll_parent_->id(), dest->scroll_parent_->id()); 222 EXPECT_EQ(src->inputs_.data.scroll_parent->id(),
223 dest->inputs_.data.scroll_parent->id());
212 } else { 224 } else {
213 EXPECT_FALSE(dest->scroll_parent_); 225 EXPECT_FALSE(dest->inputs_.data.scroll_parent);
214 } 226 }
215 if (src->scroll_children_) { 227 if (src->scroll_children_) {
216 ASSERT_TRUE(dest->scroll_children_); 228 ASSERT_TRUE(dest->scroll_children_);
217 EXPECT_EQ(*(src->scroll_children_), *(dest->scroll_children_)); 229 EXPECT_EQ(*(src->scroll_children_), *(dest->scroll_children_));
218 } else { 230 } else {
219 EXPECT_FALSE(dest->scroll_children_); 231 EXPECT_FALSE(dest->scroll_children_);
220 } 232 }
221 233
222 if (src->clip_parent_) { 234 if (src->inputs_.data.clip_parent) {
223 ASSERT_TRUE(dest->clip_parent_); 235 ASSERT_TRUE(dest->inputs_.data.clip_parent);
224 EXPECT_EQ(src->clip_parent_->id(), dest->clip_parent_->id()); 236 EXPECT_EQ(src->inputs_.data.clip_parent->id(),
237 dest->inputs_.data.clip_parent->id());
225 } else { 238 } else {
226 ASSERT_FALSE(dest->clip_parent_); 239 ASSERT_FALSE(dest->inputs_.data.clip_parent);
227 } 240 }
228 if (src->clip_children_) { 241 if (src->clip_children_) {
229 ASSERT_TRUE(dest->clip_children_); 242 ASSERT_TRUE(dest->clip_children_);
230 EXPECT_EQ(*(src->clip_children_), *(dest->clip_children_)); 243 EXPECT_EQ(*(src->clip_children_), *(dest->clip_children_));
231 } else { 244 } else {
232 EXPECT_FALSE(dest->clip_children_); 245 EXPECT_FALSE(dest->clip_children_);
233 } 246 }
234 247
235 // The following member should have been reset during serialization. 248 // The following member should have been reset during serialization.
236 EXPECT_EQ(gfx::Rect(), src->update_rect_); 249 EXPECT_EQ(gfx::Rect(), src->inputs_.data.update_rect);
237 250
238 // Before deleting |dest|, the LayerTreeHost must be unset. 251 // Before deleting |dest|, the LayerTreeHost must be unset.
239 dest->SetLayerTreeHost(nullptr); 252 dest->SetLayerTreeHost(nullptr);
240 253
241 // Cleanup scroll tree. 254 // Cleanup scroll tree.
242 if (src->scroll_parent_) 255 if (src->inputs_.data.scroll_parent)
243 layer_tree_host_->UnregisterLayer(src->scroll_parent_); 256 layer_tree_host_->UnregisterLayer(src->inputs_.data.scroll_parent);
244 src->scroll_parent_ = nullptr; 257 src->inputs_.data.scroll_parent = nullptr;
245 dest->scroll_parent_ = nullptr; 258 dest->inputs_.data.scroll_parent = nullptr;
246 if (src->scroll_children_) { 259 if (src->scroll_children_) {
247 for (auto* child : *(src->scroll_children_)) 260 for (auto* child : *(src->scroll_children_))
248 layer_tree_host_->UnregisterLayer(child); 261 layer_tree_host_->UnregisterLayer(child);
249 src->scroll_children_.reset(); 262 src->scroll_children_.reset();
250 dest->scroll_children_.reset(); 263 dest->scroll_children_.reset();
251 } 264 }
252 265
253 // Cleanup clip tree. 266 // Cleanup clip tree.
254 if (src->clip_parent_) 267 if (src->inputs_.data.clip_parent)
255 layer_tree_host_->UnregisterLayer(src->clip_parent_); 268 layer_tree_host_->UnregisterLayer(src->inputs_.data.clip_parent);
256 src->clip_parent_ = nullptr; 269 src->inputs_.data.clip_parent = nullptr;
257 dest->clip_parent_ = nullptr; 270 dest->inputs_.data.clip_parent = nullptr;
258 if (src->clip_children_) { 271 if (src->clip_children_) {
259 for (auto* child : *(src->clip_children_)) 272 for (auto* child : *(src->clip_children_))
260 layer_tree_host_->UnregisterLayer(child); 273 layer_tree_host_->UnregisterLayer(child);
261 src->clip_children_.reset(); 274 src->clip_children_.reset();
262 dest->clip_children_.reset(); 275 dest->clip_children_.reset();
263 } 276 }
264 } 277 }
265 278
266 void RunNoMembersChangedTest() { 279 void RunNoMembersChangedTest() {
267 scoped_refptr<Layer> layer = Layer::Create(); 280 scoped_refptr<Layer> layer = Layer::Create();
268 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); 281 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get());
269 } 282 }
270 283
271 void RunArbitraryMembersChangedTest() { 284 void RunArbitraryMembersChangedTest() {
272 scoped_refptr<Layer> layer = Layer::Create(); 285 scoped_refptr<Layer> layer = Layer::Create();
273 layer->transform_origin_ = gfx::Point3F(3.0f, 1.0f, 4.0f); 286 layer->inputs_.data.transform_origin = gfx::Point3F(3.0f, 1.0f, 4.0f);
274 layer->background_color_ = SK_ColorRED; 287 layer->inputs_.data.background_color = SK_ColorRED;
275 layer->bounds_ = gfx::Size(3, 14); 288 layer->inputs_.data.bounds = gfx::Size(3, 14);
276 layer->transform_tree_index_ = -1; 289 layer->transform_tree_index_ = -1;
277 layer->effect_tree_index_ = -1; 290 layer->effect_tree_index_ = -1;
278 layer->clip_tree_index_ = 71; 291 layer->clip_tree_index_ = 71;
279 layer->offset_to_transform_parent_ = gfx::Vector2dF(3.14f, 1.618f); 292 layer->offset_to_transform_parent_ = gfx::Vector2dF(3.14f, 1.618f);
280 layer->double_sided_ = true; 293 layer->inputs_.data.double_sided = true;
281 layer->draws_content_ = true; 294 layer->draws_content_ = true;
282 layer->hide_layer_and_subtree_ = false; 295 layer->inputs_.data.hide_layer_and_subtree = false;
283 layer->masks_to_bounds_ = true; 296 layer->inputs_.data.masks_to_bounds = true;
284 layer->main_thread_scrolling_reasons_ = 297 layer->inputs_.data.main_thread_scrolling_reasons =
285 MainThreadScrollingReason::kNotScrollingOnMain; 298 MainThreadScrollingReason::kNotScrollingOnMain;
286 layer->non_fast_scrollable_region_ = Region(gfx::Rect(5, 1, 14, 3)); 299 layer->inputs_.data.non_fast_scrollable_region =
287 layer->touch_event_handler_region_ = Region(gfx::Rect(3, 14, 1, 5)); 300 Region(gfx::Rect(5, 1, 14, 3));
288 layer->contents_opaque_ = true; 301 layer->inputs_.data.touch_event_handler_region =
289 layer->opacity_ = 1.f; 302 Region(gfx::Rect(3, 14, 1, 5));
290 layer->blend_mode_ = SkXfermode::kSrcOver_Mode; 303 layer->inputs_.data.contents_opaque = true;
291 layer->is_root_for_isolated_group_ = true; 304 layer->inputs_.data.opacity = 1.f;
292 layer->position_ = gfx::PointF(3.14f, 6.28f); 305 layer->inputs_.data.blend_mode = SkXfermode::kSrcOver_Mode;
293 layer->is_container_for_fixed_position_layers_ = true; 306 layer->inputs_.data.is_root_for_isolated_group = true;
307 layer->inputs_.data.position = gfx::PointF(3.14f, 6.28f);
308 layer->inputs_.data.is_container_for_fixed_position_layers = true;
294 LayerPositionConstraint pos_con; 309 LayerPositionConstraint pos_con;
295 pos_con.set_is_fixed_to_bottom_edge(true); 310 pos_con.set_is_fixed_to_bottom_edge(true);
296 layer->position_constraint_ = pos_con; 311 layer->inputs_.data.position_constraint = pos_con;
297 layer->should_flatten_transform_ = true; 312 layer->inputs_.data.should_flatten_transform = true;
298 layer->should_flatten_transform_from_property_tree_ = true; 313 layer->should_flatten_transform_from_property_tree_ = true;
299 layer->draw_blend_mode_ = SkXfermode::kSrcOut_Mode; 314 layer->draw_blend_mode_ = SkXfermode::kSrcOut_Mode;
300 layer->use_parent_backface_visibility_ = true; 315 layer->inputs_.data.use_parent_backface_visibility = true;
301 gfx::Transform transform; 316 gfx::Transform transform;
302 transform.Rotate(90); 317 transform.Rotate(90);
303 layer->transform_ = transform; 318 layer->inputs_.data.transform = transform;
304 layer->sorting_context_id_ = 0; 319 layer->inputs_.data.sorting_context_id = 0;
305 layer->num_descendants_that_draw_content_ = 5; 320 layer->num_descendants_that_draw_content_ = 5;
306 layer->scroll_clip_layer_id_ = Layer::INVALID_ID; 321 layer->inputs_.data.scroll_clip_layer_id = Layer::INVALID_ID;
307 layer->user_scrollable_horizontal_ = false; 322 layer->inputs_.data.user_scrollable_horizontal = false;
308 layer->user_scrollable_vertical_ = true; 323 layer->inputs_.data.user_scrollable_vertical = true;
309 layer->scroll_offset_ = gfx::ScrollOffset(3, 14); 324 layer->inputs_.data.scroll_offset = gfx::ScrollOffset(3, 14);
310 layer->update_rect_ = gfx::Rect(14, 15); 325 layer->inputs_.data.update_rect = gfx::Rect(14, 15);
311 326
312 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); 327 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get());
313 } 328 }
314 329
315 void RunAllMembersChangedTest() { 330 void RunAllMembersChangedTest() {
316 scoped_refptr<Layer> layer = Layer::Create(); 331 scoped_refptr<Layer> layer = Layer::Create();
317 layer->transform_origin_ = gfx::Point3F(3.0f, 1.0f, 4.0f); 332 layer->inputs_.data.transform_origin = gfx::Point3F(3.0f, 1.0f, 4.0f);
318 layer->background_color_ = SK_ColorRED; 333 layer->inputs_.data.background_color = SK_ColorRED;
319 layer->bounds_ = gfx::Size(3, 14); 334 layer->inputs_.data.bounds = gfx::Size(3, 14);
320 layer->transform_tree_index_ = 39; 335 layer->transform_tree_index_ = 39;
321 layer->effect_tree_index_ = 17; 336 layer->effect_tree_index_ = 17;
322 layer->clip_tree_index_ = 71; 337 layer->clip_tree_index_ = 71;
323 layer->offset_to_transform_parent_ = gfx::Vector2dF(3.14f, 1.618f); 338 layer->offset_to_transform_parent_ = gfx::Vector2dF(3.14f, 1.618f);
324 layer->double_sided_ = !layer->double_sided_; 339 layer->inputs_.data.double_sided = !layer->inputs_.data.double_sided;
325 layer->draws_content_ = !layer->draws_content_; 340 layer->draws_content_ = !layer->draws_content_;
326 layer->hide_layer_and_subtree_ = !layer->hide_layer_and_subtree_; 341 layer->inputs_.data.hide_layer_and_subtree =
327 layer->masks_to_bounds_ = !layer->masks_to_bounds_; 342 !layer->inputs_.data.hide_layer_and_subtree;
328 layer->main_thread_scrolling_reasons_ = 343 layer->inputs_.data.masks_to_bounds = !layer->inputs_.data.masks_to_bounds;
344 layer->inputs_.data.main_thread_scrolling_reasons =
329 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; 345 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects;
330 layer->non_fast_scrollable_region_ = Region(gfx::Rect(5, 1, 14, 3)); 346 layer->inputs_.data.non_fast_scrollable_region =
331 layer->touch_event_handler_region_ = Region(gfx::Rect(3, 14, 1, 5)); 347 Region(gfx::Rect(5, 1, 14, 3));
332 layer->contents_opaque_ = !layer->contents_opaque_; 348 layer->inputs_.data.touch_event_handler_region =
333 layer->opacity_ = 3.14f; 349 Region(gfx::Rect(3, 14, 1, 5));
334 layer->blend_mode_ = SkXfermode::kSrcIn_Mode; 350 layer->inputs_.data.contents_opaque = !layer->inputs_.data.contents_opaque;
335 layer->is_root_for_isolated_group_ = !layer->is_root_for_isolated_group_; 351 layer->inputs_.data.opacity = 3.14f;
336 layer->position_ = gfx::PointF(3.14f, 6.28f); 352 layer->inputs_.data.blend_mode = SkXfermode::kSrcIn_Mode;
337 layer->is_container_for_fixed_position_layers_ = 353 layer->inputs_.data.is_root_for_isolated_group =
338 !layer->is_container_for_fixed_position_layers_; 354 !layer->inputs_.data.is_root_for_isolated_group;
355 layer->inputs_.data.position = gfx::PointF(3.14f, 6.28f);
356 layer->inputs_.data.is_container_for_fixed_position_layers =
357 !layer->inputs_.data.is_container_for_fixed_position_layers;
339 LayerPositionConstraint pos_con; 358 LayerPositionConstraint pos_con;
340 pos_con.set_is_fixed_to_bottom_edge(true); 359 pos_con.set_is_fixed_to_bottom_edge(true);
341 layer->position_constraint_ = pos_con; 360 layer->inputs_.data.position_constraint = pos_con;
342 layer->should_flatten_transform_ = !layer->should_flatten_transform_; 361 layer->inputs_.data.should_flatten_transform =
362 !layer->inputs_.data.should_flatten_transform;
343 layer->should_flatten_transform_from_property_tree_ = 363 layer->should_flatten_transform_from_property_tree_ =
344 !layer->should_flatten_transform_from_property_tree_; 364 !layer->should_flatten_transform_from_property_tree_;
345 layer->draw_blend_mode_ = SkXfermode::kSrcOut_Mode; 365 layer->draw_blend_mode_ = SkXfermode::kSrcOut_Mode;
346 layer->use_parent_backface_visibility_ = 366 layer->inputs_.data.use_parent_backface_visibility =
347 !layer->use_parent_backface_visibility_; 367 !layer->inputs_.data.use_parent_backface_visibility;
348 gfx::Transform transform; 368 gfx::Transform transform;
349 transform.Rotate(90); 369 transform.Rotate(90);
350 layer->transform_ = transform; 370 layer->inputs_.data.transform = transform;
351 layer->sorting_context_id_ = 42; 371 layer->inputs_.data.sorting_context_id = 42;
352 layer->num_descendants_that_draw_content_ = 5; 372 layer->num_descendants_that_draw_content_ = 5;
353 layer->scroll_clip_layer_id_ = 17; 373 layer->inputs_.data.scroll_clip_layer_id = 17;
354 layer->user_scrollable_horizontal_ = !layer->user_scrollable_horizontal_; 374 layer->inputs_.data.user_scrollable_horizontal =
355 layer->user_scrollable_vertical_ = !layer->user_scrollable_vertical_; 375 !layer->inputs_.data.user_scrollable_horizontal;
356 layer->scroll_offset_ = gfx::ScrollOffset(3, 14); 376 layer->inputs_.data.user_scrollable_vertical =
357 layer->update_rect_ = gfx::Rect(14, 15); 377 !layer->inputs_.data.user_scrollable_vertical;
378 layer->inputs_.data.scroll_offset = gfx::ScrollOffset(3, 14);
379 layer->inputs_.data.update_rect = gfx::Rect(14, 15);
358 380
359 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); 381 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get());
360 } 382 }
361 383
362 void VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization( 384 void VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization(
363 scoped_refptr<SolidColorScrollbarLayer> source_scrollbar) { 385 scoped_refptr<SolidColorScrollbarLayer> source_scrollbar) {
364 proto::LayerProperties serialized_scrollbar; 386 proto::LayerProperties serialized_scrollbar;
365 source_scrollbar->LayerSpecificPropertiesToProto(&serialized_scrollbar); 387 source_scrollbar->LayerSpecificPropertiesToProto(&serialized_scrollbar);
366 388
367 scoped_refptr<SolidColorScrollbarLayer> deserialized_scrollbar = 389 scoped_refptr<SolidColorScrollbarLayer> deserialized_scrollbar =
368 SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL, -1, 390 SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL, -1,
369 -1, false, Layer::INVALID_ID); 391 -1, false, Layer::INVALID_ID);
370 deserialized_scrollbar->layer_id_ = source_scrollbar->layer_id_; 392 deserialized_scrollbar->inputs_.data.layer_id =
393 source_scrollbar->inputs_.data.layer_id;
371 394
372 // FromLayerSpecificPropertiesProto expects a non-null LayerTreeHost to be 395 // FromLayerSpecificPropertiesProto expects a non-null LayerTreeHost to be
373 // set. 396 // set.
374 deserialized_scrollbar->SetLayerTreeHost(layer_tree_host_.get()); 397 deserialized_scrollbar->SetLayerTreeHost(layer_tree_host_.get());
375 deserialized_scrollbar->FromLayerSpecificPropertiesProto( 398 deserialized_scrollbar->FromLayerSpecificPropertiesProto(
376 serialized_scrollbar); 399 serialized_scrollbar);
377 400
378 EXPECT_EQ(source_scrollbar->track_start_, 401 EXPECT_EQ(source_scrollbar->track_start_,
379 deserialized_scrollbar->track_start_); 402 deserialized_scrollbar->track_start_);
380 EXPECT_EQ(source_scrollbar->thumb_thickness_, 403 EXPECT_EQ(source_scrollbar->thumb_thickness_,
381 deserialized_scrollbar->thumb_thickness_); 404 deserialized_scrollbar->thumb_thickness_);
382 EXPECT_EQ(source_scrollbar->scroll_layer_id_, 405 EXPECT_EQ(source_scrollbar->scroll_layer_id_,
383 deserialized_scrollbar->scroll_layer_id_); 406 deserialized_scrollbar->scroll_layer_id_);
384 EXPECT_EQ(source_scrollbar->is_left_side_vertical_scrollbar_, 407 EXPECT_EQ(source_scrollbar->is_left_side_vertical_scrollbar_,
385 deserialized_scrollbar->is_left_side_vertical_scrollbar_); 408 deserialized_scrollbar->is_left_side_vertical_scrollbar_);
386 EXPECT_EQ(source_scrollbar->orientation_, 409 EXPECT_EQ(source_scrollbar->orientation_,
387 deserialized_scrollbar->orientation_); 410 deserialized_scrollbar->orientation_);
388 411
389 deserialized_scrollbar->SetLayerTreeHost(nullptr); 412 deserialized_scrollbar->SetLayerTreeHost(nullptr);
390 } 413 }
391 414
392 void RunScrollAndClipLayersTest() { 415 void RunScrollAndClipLayersTest() {
393 scoped_refptr<Layer> layer = Layer::Create(); 416 scoped_refptr<Layer> layer = Layer::Create();
394 417
395 scoped_refptr<Layer> scroll_parent = Layer::Create(); 418 scoped_refptr<Layer> scroll_parent = Layer::Create();
396 layer->scroll_parent_ = scroll_parent.get(); 419 layer->inputs_.data.scroll_parent = scroll_parent.get();
397 scoped_refptr<Layer> scroll_child = Layer::Create(); 420 scoped_refptr<Layer> scroll_child = Layer::Create();
398 layer->scroll_children_.reset(new std::set<Layer*>); 421 layer->scroll_children_.reset(new std::set<Layer*>);
399 layer->scroll_children_->insert(scroll_child.get()); 422 layer->scroll_children_->insert(scroll_child.get());
400 423
401 scoped_refptr<Layer> clip_parent = Layer::Create(); 424 scoped_refptr<Layer> clip_parent = Layer::Create();
402 layer->clip_parent_ = clip_parent.get(); 425 layer->inputs_.data.clip_parent = clip_parent.get();
403 layer->clip_children_.reset(new std::set<Layer*>); 426 layer->clip_children_.reset(new std::set<Layer*>);
404 scoped_refptr<Layer> clip_child1 = Layer::Create(); 427 scoped_refptr<Layer> clip_child1 = Layer::Create();
405 layer->clip_children_->insert(clip_child1.get()); 428 layer->clip_children_->insert(clip_child1.get());
406 scoped_refptr<Layer> clip_child2 = Layer::Create(); 429 scoped_refptr<Layer> clip_child2 = Layer::Create();
407 layer->clip_children_->insert(clip_child2.get()); 430 layer->clip_children_->insert(clip_child2.get());
408 431
409 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); 432 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get());
410 } 433 }
411 434
412 void RunHierarchyDeserializationWithLayerTreeHostTest() { 435 void RunHierarchyDeserializationWithLayerTreeHostTest() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 layer_tree_host_.get()); 558 layer_tree_host_.get());
536 559
537 // Ensure initial copy is correct. 560 // Ensure initial copy is correct.
538 ASSERT_EQ(2u, layer_dest_root->children().size()); 561 ASSERT_EQ(2u, layer_dest_root->children().size());
539 scoped_refptr<Layer> layer_dest_a = layer_dest_root->children()[0]; 562 scoped_refptr<Layer> layer_dest_a = layer_dest_root->children()[0];
540 EXPECT_EQ(layer_src_a->id(), layer_dest_a->id()); 563 EXPECT_EQ(layer_src_a->id(), layer_dest_a->id());
541 scoped_refptr<Layer> layer_dest_b = layer_dest_root->children()[1]; 564 scoped_refptr<Layer> layer_dest_b = layer_dest_root->children()[1];
542 EXPECT_EQ(layer_src_b->id(), layer_dest_b->id()); 565 EXPECT_EQ(layer_src_b->id(), layer_dest_b->id());
543 566
544 // Swap order of the children. 567 // Swap order of the children.
545 scoped_refptr<Layer> tmp_a = layer_src_root->children_[0]; 568 scoped_refptr<Layer> tmp_a = layer_src_root->inputs_.data.children[0];
546 layer_src_root->children_[0] = layer_src_root->children_[1]; 569 layer_src_root->inputs_.data.children[0] =
547 layer_src_root->children_[1] = tmp_a; 570 layer_src_root->inputs_.data.children[1];
571 layer_src_root->inputs_.data.children[1] = tmp_a;
548 572
549 // Fake the fact that the destination layers have valid indexes. 573 // Fake the fact that the destination layers have valid indexes.
550 layer_dest_root->transform_tree_index_ = 33; 574 layer_dest_root->transform_tree_index_ = 33;
551 layer_dest_a->transform_tree_index_ = 42; 575 layer_dest_a->transform_tree_index_ = 42;
552 layer_dest_b->transform_tree_index_ = 24; 576 layer_dest_b->transform_tree_index_ = 24;
553 577
554 // Now serialize and deserialize again. 578 // Now serialize and deserialize again.
555 proto::LayerNode root_proto_2; 579 proto::LayerNode root_proto_2;
556 layer_src_root->ToLayerNodeProto(&root_proto_2); 580 layer_src_root->ToLayerNodeProto(&root_proto_2);
557 layer_dest_root->ClearLayerTreePropertiesForDeserializationAndAddToMap( 581 layer_dest_root->ClearLayerTreePropertiesForDeserializationAndAddToMap(
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 2540 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
2517 2541
2518 test_layer->PushPropertiesTo(impl_layer.get()); 2542 test_layer->PushPropertiesTo(impl_layer.get());
2519 2543
2520 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); 2544 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id());
2521 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 2545 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
2522 } 2546 }
2523 2547
2524 } // namespace 2548 } // namespace
2525 } // namespace cc 2549 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698