OLD | NEW |
---|---|
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "cc/animation/animation.h" | 10 #include "cc/animation/animation.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 return; | 114 return; |
115 if (layer_tree_host_) | 115 if (layer_tree_host_) |
116 layer_tree_host_->SetNeedsCommit(); | 116 layer_tree_host_->SetNeedsCommit(); |
117 } | 117 } |
118 | 118 |
119 void Layer::SetNeedsFullTreeSync() { | 119 void Layer::SetNeedsFullTreeSync() { |
120 if (layer_tree_host_) | 120 if (layer_tree_host_) |
121 layer_tree_host_->SetNeedsFullTreeSync(); | 121 layer_tree_host_->SetNeedsFullTreeSync(); |
122 } | 122 } |
123 | 123 |
124 bool Layer::IsPropertyChangeAllowed() const { | |
125 if (!layer_tree_host_) | |
126 return true; | |
127 | |
128 if (!layer_tree_host_->settings().strict_layer_property_change_checking) | |
129 return true; | |
130 | |
131 return !layer_tree_host_->in_paint_layer_contents(); | |
132 } | |
133 | |
124 gfx::Rect Layer::LayerRectToContentRect(const gfx::RectF& layer_rect) const { | 134 gfx::Rect Layer::LayerRectToContentRect(const gfx::RectF& layer_rect) const { |
125 gfx::RectF content_rect = | 135 gfx::RectF content_rect = |
126 gfx::ScaleRect(layer_rect, contents_scale_x(), contents_scale_y()); | 136 gfx::ScaleRect(layer_rect, contents_scale_x(), contents_scale_y()); |
127 // Intersect with content rect to avoid the extra pixel because for some | 137 // Intersect with content rect to avoid the extra pixel because for some |
128 // values x and y, ceil((x / y) * y) may be x + 1. | 138 // values x and y, ceil((x / y) * y) may be x + 1. |
129 content_rect.Intersect(gfx::Rect(content_bounds())); | 139 content_rect.Intersect(gfx::Rect(content_bounds())); |
130 return gfx::ToEnclosingRect(content_rect); | 140 return gfx::ToEnclosingRect(content_rect); |
131 } | 141 } |
132 | 142 |
133 bool Layer::BlocksPendingCommit() const { | 143 bool Layer::BlocksPendingCommit() const { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 return true; | 180 return true; |
171 } | 181 } |
172 return false; | 182 return false; |
173 } | 183 } |
174 | 184 |
175 void Layer::AddChild(scoped_refptr<Layer> child) { | 185 void Layer::AddChild(scoped_refptr<Layer> child) { |
176 InsertChild(child, children_.size()); | 186 InsertChild(child, children_.size()); |
177 } | 187 } |
178 | 188 |
179 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) { | 189 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) { |
190 CHECK(IsPropertyChangeAllowed()); | |
180 child->RemoveFromParent(); | 191 child->RemoveFromParent(); |
181 child->SetParent(this); | 192 child->SetParent(this); |
182 child->stacking_order_changed_ = true; | 193 child->stacking_order_changed_ = true; |
183 | 194 |
184 index = std::min(index, children_.size()); | 195 index = std::min(index, children_.size()); |
185 children_.insert(children_.begin() + index, child); | 196 children_.insert(children_.begin() + index, child); |
186 SetNeedsFullTreeSync(); | 197 SetNeedsFullTreeSync(); |
187 } | 198 } |
188 | 199 |
189 void Layer::RemoveFromParent() { | 200 void Layer::RemoveFromParent() { |
201 CHECK(IsPropertyChangeAllowed()); | |
190 if (parent_) | 202 if (parent_) |
191 parent_->RemoveChildOrDependent(this); | 203 parent_->RemoveChildOrDependent(this); |
192 } | 204 } |
193 | 205 |
194 void Layer::RemoveChildOrDependent(Layer* child) { | 206 void Layer::RemoveChildOrDependent(Layer* child) { |
195 if (mask_layer_ == child) { | 207 if (mask_layer_ == child) { |
196 mask_layer_->SetParent(NULL); | 208 mask_layer_->SetParent(NULL); |
197 mask_layer_ = NULL; | 209 mask_layer_ = NULL; |
198 SetNeedsFullTreeSync(); | 210 SetNeedsFullTreeSync(); |
199 return; | 211 return; |
(...skipping 14 matching lines...) Expand all Loading... | |
214 child->SetParent(NULL); | 226 child->SetParent(NULL); |
215 children_.erase(iter); | 227 children_.erase(iter); |
216 SetNeedsFullTreeSync(); | 228 SetNeedsFullTreeSync(); |
217 return; | 229 return; |
218 } | 230 } |
219 } | 231 } |
220 | 232 |
221 void Layer::ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer) { | 233 void Layer::ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer) { |
222 DCHECK(reference); | 234 DCHECK(reference); |
223 DCHECK_EQ(reference->parent(), this); | 235 DCHECK_EQ(reference->parent(), this); |
236 CHECK(IsPropertyChangeAllowed()); | |
224 | 237 |
225 if (reference == new_layer) | 238 if (reference == new_layer) |
226 return; | 239 return; |
227 | 240 |
228 int reference_index = IndexOfChild(reference); | 241 int reference_index = IndexOfChild(reference); |
229 if (reference_index == -1) { | 242 if (reference_index == -1) { |
230 NOTREACHED(); | 243 NOTREACHED(); |
231 return; | 244 return; |
232 } | 245 } |
233 | 246 |
234 reference->RemoveFromParent(); | 247 reference->RemoveFromParent(); |
235 | 248 |
236 if (new_layer) { | 249 if (new_layer) { |
237 new_layer->RemoveFromParent(); | 250 new_layer->RemoveFromParent(); |
238 InsertChild(new_layer, reference_index); | 251 InsertChild(new_layer, reference_index); |
239 } | 252 } |
240 } | 253 } |
241 | 254 |
242 int Layer::IndexOfChild(const Layer* reference) { | 255 int Layer::IndexOfChild(const Layer* reference) { |
243 for (size_t i = 0; i < children_.size(); ++i) { | 256 for (size_t i = 0; i < children_.size(); ++i) { |
244 if (children_[i] == reference) | 257 if (children_[i] == reference) |
245 return i; | 258 return i; |
246 } | 259 } |
247 return -1; | 260 return -1; |
248 } | 261 } |
249 | 262 |
250 void Layer::SetBounds(gfx::Size size) { | 263 void Layer::SetBounds(gfx::Size size) { |
264 CHECK(IsPropertyChangeAllowed()); | |
251 if (bounds() == size) | 265 if (bounds() == size) |
252 return; | 266 return; |
253 | 267 |
254 bool first_resize = bounds().IsEmpty() && !size.IsEmpty(); | 268 bool first_resize = bounds().IsEmpty() && !size.IsEmpty(); |
255 | 269 |
256 bounds_ = size; | 270 bounds_ = size; |
257 | 271 |
258 if (first_resize) | 272 if (first_resize) |
259 SetNeedsDisplay(); | 273 SetNeedsDisplay(); |
260 else | 274 else |
261 SetNeedsCommit(); | 275 SetNeedsCommit(); |
262 } | 276 } |
263 | 277 |
264 Layer* Layer::RootLayer() { | 278 Layer* Layer::RootLayer() { |
265 Layer* layer = this; | 279 Layer* layer = this; |
266 while (layer->parent()) | 280 while (layer->parent()) |
267 layer = layer->parent(); | 281 layer = layer->parent(); |
268 return layer; | 282 return layer; |
269 } | 283 } |
270 | 284 |
271 void Layer::RemoveAllChildren() { | 285 void Layer::RemoveAllChildren() { |
286 CHECK(IsPropertyChangeAllowed()); | |
272 while (children_.size()) { | 287 while (children_.size()) { |
273 Layer* layer = children_[0].get(); | 288 Layer* layer = children_[0].get(); |
274 DCHECK_EQ(this, layer->parent()); | 289 DCHECK_EQ(this, layer->parent()); |
275 layer->RemoveFromParent(); | 290 layer->RemoveFromParent(); |
276 } | 291 } |
277 } | 292 } |
278 | 293 |
279 void Layer::SetChildren(const LayerList& children) { | 294 void Layer::SetChildren(const LayerList& children) { |
295 CHECK(IsPropertyChangeAllowed()); | |
280 if (children == children_) | 296 if (children == children_) |
281 return; | 297 return; |
282 | 298 |
283 RemoveAllChildren(); | 299 RemoveAllChildren(); |
284 for (size_t i = 0; i < children.size(); ++i) | 300 for (size_t i = 0; i < children.size(); ++i) |
285 AddChild(children[i]); | 301 AddChild(children[i]); |
286 } | 302 } |
287 | 303 |
288 void Layer::SetAnchorPoint(gfx::PointF anchor_point) { | 304 void Layer::SetAnchorPoint(gfx::PointF anchor_point) { |
305 CHECK(IsPropertyChangeAllowed()); | |
289 if (anchor_point_ == anchor_point) | 306 if (anchor_point_ == anchor_point) |
290 return; | 307 return; |
291 anchor_point_ = anchor_point; | 308 anchor_point_ = anchor_point; |
292 SetNeedsCommit(); | 309 SetNeedsCommit(); |
293 } | 310 } |
294 | 311 |
295 void Layer::SetAnchorPointZ(float anchor_point_z) { | 312 void Layer::SetAnchorPointZ(float anchor_point_z) { |
313 CHECK(IsPropertyChangeAllowed()); | |
296 if (anchor_point_z_ == anchor_point_z) | 314 if (anchor_point_z_ == anchor_point_z) |
297 return; | 315 return; |
298 anchor_point_z_ = anchor_point_z; | 316 anchor_point_z_ = anchor_point_z; |
299 SetNeedsCommit(); | 317 SetNeedsCommit(); |
300 } | 318 } |
301 | 319 |
302 void Layer::SetBackgroundColor(SkColor background_color) { | 320 void Layer::SetBackgroundColor(SkColor background_color) { |
321 CHECK(IsPropertyChangeAllowed()); | |
303 if (background_color_ == background_color) | 322 if (background_color_ == background_color) |
304 return; | 323 return; |
305 background_color_ = background_color; | 324 background_color_ = background_color; |
306 SetNeedsCommit(); | 325 SetNeedsCommit(); |
307 } | 326 } |
308 | 327 |
309 void Layer::CalculateContentsScale( | 328 void Layer::CalculateContentsScale( |
310 float ideal_contents_scale, | 329 float ideal_contents_scale, |
311 bool animating_transform_to_screen, | 330 bool animating_transform_to_screen, |
312 float* contents_scale_x, | 331 float* contents_scale_x, |
313 float* contents_scale_y, | 332 float* contents_scale_y, |
314 gfx::Size* content_bounds) { | 333 gfx::Size* content_bounds) { |
315 *contents_scale_x = 1; | 334 *contents_scale_x = 1; |
316 *contents_scale_y = 1; | 335 *contents_scale_y = 1; |
317 *content_bounds = bounds(); | 336 *content_bounds = bounds(); |
318 } | 337 } |
319 | 338 |
320 void Layer::SetMasksToBounds(bool masks_to_bounds) { | 339 void Layer::SetMasksToBounds(bool masks_to_bounds) { |
340 CHECK(IsPropertyChangeAllowed()); | |
321 if (masks_to_bounds_ == masks_to_bounds) | 341 if (masks_to_bounds_ == masks_to_bounds) |
322 return; | 342 return; |
323 masks_to_bounds_ = masks_to_bounds; | 343 masks_to_bounds_ = masks_to_bounds; |
324 SetNeedsCommit(); | 344 SetNeedsCommit(); |
325 } | 345 } |
326 | 346 |
327 void Layer::SetMaskLayer(Layer* mask_layer) { | 347 void Layer::SetMaskLayer(Layer* mask_layer) { |
348 CHECK(IsPropertyChangeAllowed()); | |
328 if (mask_layer_ == mask_layer) | 349 if (mask_layer_ == mask_layer) |
329 return; | 350 return; |
330 if (mask_layer_) { | 351 if (mask_layer_) { |
331 DCHECK_EQ(this, mask_layer_->parent()); | 352 DCHECK_EQ(this, mask_layer_->parent()); |
332 mask_layer_->RemoveFromParent(); | 353 mask_layer_->RemoveFromParent(); |
333 } | 354 } |
334 mask_layer_ = mask_layer; | 355 mask_layer_ = mask_layer; |
335 if (mask_layer_) { | 356 if (mask_layer_) { |
336 DCHECK(!mask_layer_->parent()); | 357 DCHECK(!mask_layer_->parent()); |
337 mask_layer_->RemoveFromParent(); | 358 mask_layer_->RemoveFromParent(); |
338 mask_layer_->SetParent(this); | 359 mask_layer_->SetParent(this); |
339 mask_layer_->SetIsMask(true); | 360 mask_layer_->SetIsMask(true); |
340 } | 361 } |
341 SetNeedsFullTreeSync(); | 362 SetNeedsFullTreeSync(); |
342 } | 363 } |
343 | 364 |
344 void Layer::SetReplicaLayer(Layer* layer) { | 365 void Layer::SetReplicaLayer(Layer* layer) { |
366 CHECK(IsPropertyChangeAllowed()); | |
345 if (replica_layer_ == layer) | 367 if (replica_layer_ == layer) |
346 return; | 368 return; |
347 if (replica_layer_) { | 369 if (replica_layer_) { |
348 DCHECK_EQ(this, replica_layer_->parent()); | 370 DCHECK_EQ(this, replica_layer_->parent()); |
349 replica_layer_->RemoveFromParent(); | 371 replica_layer_->RemoveFromParent(); |
350 } | 372 } |
351 replica_layer_ = layer; | 373 replica_layer_ = layer; |
352 if (replica_layer_) { | 374 if (replica_layer_) { |
353 DCHECK(!replica_layer_->parent()); | 375 DCHECK(!replica_layer_->parent()); |
354 replica_layer_->RemoveFromParent(); | 376 replica_layer_->RemoveFromParent(); |
355 replica_layer_->SetParent(this); | 377 replica_layer_->SetParent(this); |
356 } | 378 } |
357 SetNeedsFullTreeSync(); | 379 SetNeedsFullTreeSync(); |
358 } | 380 } |
359 | 381 |
360 void Layer::SetFilters(const WebKit::WebFilterOperations& filters) { | 382 void Layer::SetFilters(const WebKit::WebFilterOperations& filters) { |
383 CHECK(IsPropertyChangeAllowed()); | |
361 if (filters_ == filters) | 384 if (filters_ == filters) |
362 return; | 385 return; |
363 DCHECK(!filter_); | 386 DCHECK(!filter_); |
364 filters_ = filters; | 387 filters_ = filters; |
365 SetNeedsCommit(); | 388 SetNeedsCommit(); |
366 if (!filters.isEmpty() && layer_tree_host_) | 389 if (!filters.isEmpty() && layer_tree_host_) |
367 layer_tree_host_->set_needs_filter_context(); | 390 layer_tree_host_->set_needs_filter_context(); |
368 } | 391 } |
369 | 392 |
370 void Layer::SetFilter(const skia::RefPtr<SkImageFilter>& filter) { | 393 void Layer::SetFilter(const skia::RefPtr<SkImageFilter>& filter) { |
394 CHECK(IsPropertyChangeAllowed()); | |
371 if (filter_.get() == filter.get()) | 395 if (filter_.get() == filter.get()) |
372 return; | 396 return; |
373 DCHECK(filters_.isEmpty()); | 397 DCHECK(filters_.isEmpty()); |
374 filter_ = filter; | 398 filter_ = filter; |
375 SetNeedsCommit(); | 399 SetNeedsCommit(); |
376 if (filter && layer_tree_host_) | 400 if (filter && layer_tree_host_) |
377 layer_tree_host_->set_needs_filter_context(); | 401 layer_tree_host_->set_needs_filter_context(); |
378 } | 402 } |
379 | 403 |
380 void Layer::SetBackgroundFilters(const WebKit::WebFilterOperations& filters) { | 404 void Layer::SetBackgroundFilters(const WebKit::WebFilterOperations& filters) { |
405 CHECK(IsPropertyChangeAllowed()); | |
381 if (background_filters_ == filters) | 406 if (background_filters_ == filters) |
382 return; | 407 return; |
383 background_filters_ = filters; | 408 background_filters_ = filters; |
384 SetNeedsCommit(); | 409 SetNeedsCommit(); |
385 if (!filters.isEmpty() && layer_tree_host_) | 410 if (!filters.isEmpty() && layer_tree_host_) |
386 layer_tree_host_->set_needs_filter_context(); | 411 layer_tree_host_->set_needs_filter_context(); |
387 } | 412 } |
388 | 413 |
389 void Layer::SetOpacity(float opacity) { | 414 void Layer::SetOpacity(float opacity) { |
415 CHECK(IsPropertyChangeAllowed()); | |
390 if (opacity_ == opacity) | 416 if (opacity_ == opacity) |
391 return; | 417 return; |
392 opacity_ = opacity; | 418 opacity_ = opacity; |
393 SetNeedsCommit(); | 419 SetNeedsCommit(); |
394 } | 420 } |
395 | 421 |
396 bool Layer::OpacityIsAnimating() const { | 422 bool Layer::OpacityIsAnimating() const { |
397 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); | 423 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); |
398 } | 424 } |
399 | 425 |
400 bool Layer::OpacityCanAnimateOnImplThread() const { | 426 bool Layer::OpacityCanAnimateOnImplThread() const { |
401 return false; | 427 return false; |
402 } | 428 } |
403 | 429 |
404 void Layer::SetContentsOpaque(bool opaque) { | 430 void Layer::SetContentsOpaque(bool opaque) { |
431 CHECK(IsPropertyChangeAllowed()); | |
405 if (contents_opaque_ == opaque) | 432 if (contents_opaque_ == opaque) |
406 return; | 433 return; |
407 contents_opaque_ = opaque; | 434 contents_opaque_ = opaque; |
408 SetNeedsCommit(); | 435 SetNeedsCommit(); |
409 } | 436 } |
410 | 437 |
411 void Layer::SetPosition(gfx::PointF position) { | 438 void Layer::SetPosition(gfx::PointF position) { |
439 CHECK(IsPropertyChangeAllowed()); | |
412 if (position_ == position) | 440 if (position_ == position) |
413 return; | 441 return; |
414 position_ = position; | 442 position_ = position; |
415 SetNeedsCommit(); | 443 SetNeedsCommit(); |
416 } | 444 } |
417 | 445 |
418 bool Layer::IsContainerForFixedPositionLayers() const { | 446 bool Layer::IsContainerForFixedPositionLayers() const { |
419 if (!transform_.IsIdentityOrTranslation()) | 447 if (!transform_.IsIdentityOrTranslation()) |
420 return true; | 448 return true; |
421 if (parent_ && !parent_->sublayer_transform_.IsIdentityOrTranslation()) | 449 if (parent_ && !parent_->sublayer_transform_.IsIdentityOrTranslation()) |
422 return true; | 450 return true; |
423 return is_container_for_fixed_position_layers_; | 451 return is_container_for_fixed_position_layers_; |
424 } | 452 } |
425 | 453 |
426 void Layer::SetSublayerTransform(const gfx::Transform& sublayer_transform) { | 454 void Layer::SetSublayerTransform(const gfx::Transform& sublayer_transform) { |
455 CHECK(IsPropertyChangeAllowed()); | |
427 if (sublayer_transform_ == sublayer_transform) | 456 if (sublayer_transform_ == sublayer_transform) |
428 return; | 457 return; |
429 sublayer_transform_ = sublayer_transform; | 458 sublayer_transform_ = sublayer_transform; |
430 SetNeedsCommit(); | 459 SetNeedsCommit(); |
431 } | 460 } |
432 | 461 |
433 void Layer::SetTransform(const gfx::Transform& transform) { | 462 void Layer::SetTransform(const gfx::Transform& transform) { |
463 CHECK(IsPropertyChangeAllowed()); | |
434 if (transform_ == transform) | 464 if (transform_ == transform) |
435 return; | 465 return; |
436 transform_ = transform; | 466 transform_ = transform; |
437 SetNeedsCommit(); | 467 SetNeedsCommit(); |
438 } | 468 } |
439 | 469 |
440 bool Layer::TransformIsAnimating() const { | 470 bool Layer::TransformIsAnimating() const { |
441 return layer_animation_controller_->IsAnimatingProperty(Animation::Transform); | 471 return layer_animation_controller_->IsAnimatingProperty(Animation::Transform); |
442 } | 472 } |
443 | 473 |
444 void Layer::SetScrollOffset(gfx::Vector2d scroll_offset) { | 474 void Layer::SetScrollOffset(gfx::Vector2d scroll_offset) { |
475 CHECK(IsPropertyChangeAllowed()); | |
445 if (scroll_offset_ == scroll_offset) | 476 if (scroll_offset_ == scroll_offset) |
446 return; | 477 return; |
447 scroll_offset_ = scroll_offset; | 478 scroll_offset_ = scroll_offset; |
448 if (layer_scroll_client_) | 479 if (layer_scroll_client_) |
449 layer_scroll_client_->didScroll(); | 480 layer_scroll_client_->didScroll(); |
450 SetNeedsCommit(); | 481 SetNeedsCommit(); |
451 } | 482 } |
452 | 483 |
453 void Layer::SetMaxScrollOffset(gfx::Vector2d max_scroll_offset) { | 484 void Layer::SetMaxScrollOffset(gfx::Vector2d max_scroll_offset) { |
485 CHECK(IsPropertyChangeAllowed()); | |
454 if (max_scroll_offset_ == max_scroll_offset) | 486 if (max_scroll_offset_ == max_scroll_offset) |
455 return; | 487 return; |
456 max_scroll_offset_ = max_scroll_offset; | 488 max_scroll_offset_ = max_scroll_offset; |
457 SetNeedsCommit(); | 489 SetNeedsCommit(); |
458 } | 490 } |
459 | 491 |
460 void Layer::SetScrollable(bool scrollable) { | 492 void Layer::SetScrollable(bool scrollable) { |
493 CHECK(IsPropertyChangeAllowed()); | |
461 if (scrollable_ == scrollable) | 494 if (scrollable_ == scrollable) |
462 return; | 495 return; |
463 scrollable_ = scrollable; | 496 scrollable_ = scrollable; |
464 SetNeedsCommit(); | 497 SetNeedsCommit(); |
465 } | 498 } |
466 | 499 |
467 void Layer::SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) { | 500 void Layer::SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) { |
501 CHECK(IsPropertyChangeAllowed()); | |
468 if (should_scroll_on_main_thread_ == should_scroll_on_main_thread) | 502 if (should_scroll_on_main_thread_ == should_scroll_on_main_thread) |
469 return; | 503 return; |
470 should_scroll_on_main_thread_ = should_scroll_on_main_thread; | 504 should_scroll_on_main_thread_ = should_scroll_on_main_thread; |
471 SetNeedsCommit(); | 505 SetNeedsCommit(); |
472 } | 506 } |
473 | 507 |
474 void Layer::SetHaveWheelEventHandlers(bool have_wheel_event_handlers) { | 508 void Layer::SetHaveWheelEventHandlers(bool have_wheel_event_handlers) { |
509 CHECK(IsPropertyChangeAllowed()); | |
475 if (have_wheel_event_handlers_ == have_wheel_event_handlers) | 510 if (have_wheel_event_handlers_ == have_wheel_event_handlers) |
476 return; | 511 return; |
477 have_wheel_event_handlers_ = have_wheel_event_handlers; | 512 have_wheel_event_handlers_ = have_wheel_event_handlers; |
478 SetNeedsCommit(); | 513 SetNeedsCommit(); |
479 } | 514 } |
480 | 515 |
481 void Layer::SetNonFastScrollableRegion(const Region& region) { | 516 void Layer::SetNonFastScrollableRegion(const Region& region) { |
517 CHECK(IsPropertyChangeAllowed()); | |
482 if (non_fast_scrollable_region_ == region) | 518 if (non_fast_scrollable_region_ == region) |
483 return; | 519 return; |
484 non_fast_scrollable_region_ = region; | 520 non_fast_scrollable_region_ = region; |
485 SetNeedsCommit(); | 521 SetNeedsCommit(); |
486 } | 522 } |
487 | 523 |
488 void Layer::SetTouchEventHandlerRegion(const Region& region) { | 524 void Layer::SetTouchEventHandlerRegion(const Region& region) { |
525 CHECK(IsPropertyChangeAllowed()); | |
489 if (touch_event_handler_region_ == region) | 526 if (touch_event_handler_region_ == region) |
490 return; | 527 return; |
491 touch_event_handler_region_ = region; | 528 touch_event_handler_region_ = region; |
492 } | 529 } |
493 | 530 |
494 void Layer::SetDrawCheckerboardForMissingTiles(bool checkerboard) { | 531 void Layer::SetDrawCheckerboardForMissingTiles(bool checkerboard) { |
532 CHECK(IsPropertyChangeAllowed()); | |
495 if (draw_checkerboard_for_missing_tiles_ == checkerboard) | 533 if (draw_checkerboard_for_missing_tiles_ == checkerboard) |
496 return; | 534 return; |
497 draw_checkerboard_for_missing_tiles_ = checkerboard; | 535 draw_checkerboard_for_missing_tiles_ = checkerboard; |
498 SetNeedsCommit(); | 536 SetNeedsCommit(); |
499 } | 537 } |
500 | 538 |
501 void Layer::SetForceRenderSurface(bool force) { | 539 void Layer::SetForceRenderSurface(bool force) { |
540 CHECK(IsPropertyChangeAllowed()); | |
502 if (force_render_surface_ == force) | 541 if (force_render_surface_ == force) |
503 return; | 542 return; |
504 force_render_surface_ = force; | 543 force_render_surface_ = force; |
505 SetNeedsCommit(); | 544 SetNeedsCommit(); |
506 } | 545 } |
507 | 546 |
508 void Layer::SetImplTransform(const gfx::Transform& transform) { | 547 void Layer::SetImplTransform(const gfx::Transform& transform) { |
548 CHECK(IsPropertyChangeAllowed()); | |
509 if (impl_transform_ == transform) | 549 if (impl_transform_ == transform) |
510 return; | 550 return; |
511 impl_transform_ = transform; | 551 impl_transform_ = transform; |
512 SetNeedsCommit(); | 552 SetNeedsCommit(); |
513 } | 553 } |
514 | 554 |
515 void Layer::SetDoubleSided(bool double_sided) { | 555 void Layer::SetDoubleSided(bool double_sided) { |
556 CHECK(IsPropertyChangeAllowed()); | |
516 if (double_sided_ == double_sided) | 557 if (double_sided_ == double_sided) |
517 return; | 558 return; |
518 double_sided_ = double_sided; | 559 double_sided_ = double_sided; |
519 SetNeedsCommit(); | 560 SetNeedsCommit(); |
520 } | 561 } |
521 | 562 |
522 void Layer::SetIsDrawable(bool is_drawable) { | 563 void Layer::SetIsDrawable(bool is_drawable) { |
564 CHECK(IsPropertyChangeAllowed()); | |
523 if (is_drawable_ == is_drawable) | 565 if (is_drawable_ == is_drawable) |
524 return; | 566 return; |
525 | 567 |
526 is_drawable_ = is_drawable; | 568 is_drawable_ = is_drawable; |
527 SetNeedsCommit(); | 569 SetNeedsCommit(); |
528 } | 570 } |
529 | 571 |
530 void Layer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { | 572 void Layer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { |
531 update_rect_.Union(dirty_rect); | 573 update_rect_.Union(dirty_rect); |
532 needs_display_ = true; | 574 needs_display_ = true; |
(...skipping 21 matching lines...) Expand all Loading... | |
554 | 596 |
555 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) | 597 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) |
556 return; | 598 return; |
557 | 599 |
558 // Only request a commit if we have a fixed positioned descendant. | 600 // Only request a commit if we have a fixed positioned descendant. |
559 if (DescendantIsFixedToContainerLayer()) | 601 if (DescendantIsFixedToContainerLayer()) |
560 SetNeedsCommit(); | 602 SetNeedsCommit(); |
561 } | 603 } |
562 | 604 |
563 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { | 605 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { |
564 if (position_constraint_ == constraint) | 606 CHECK(IsPropertyChangeAllowed()); |
565 return; | 607 if (position_constraint_ == constraint) |
566 position_constraint_ = constraint; | 608 return; |
567 SetNeedsCommit(); | 609 position_constraint_ = constraint; |
610 SetNeedsCommit(); | |
568 } | 611 } |
569 | 612 |
570 void Layer::PushPropertiesTo(LayerImpl* layer) { | 613 void Layer::PushPropertiesTo(LayerImpl* layer) { |
571 layer->SetAnchorPoint(anchor_point_); | 614 layer->SetAnchorPoint(anchor_point_); |
572 layer->SetAnchorPointZ(anchor_point_z_); | 615 layer->SetAnchorPointZ(anchor_point_z_); |
573 layer->SetBackgroundColor(background_color_); | 616 layer->SetBackgroundColor(background_color_); |
574 layer->SetBounds(bounds_); | 617 layer->SetBounds(last_bounds_); |
danakj
2013/04/12 16:44:40
I think this is problematic because if the bounds
| |
575 layer->SetContentBounds(content_bounds()); | 618 layer->SetContentBounds(content_bounds()); |
576 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 619 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
577 layer->SetDebugName(debug_name_); | 620 layer->SetDebugName(debug_name_); |
578 layer->SetDoubleSided(double_sided_); | 621 layer->SetDoubleSided(double_sided_); |
579 layer->SetDrawCheckerboardForMissingTiles( | 622 layer->SetDrawCheckerboardForMissingTiles( |
580 draw_checkerboard_for_missing_tiles_); | 623 draw_checkerboard_for_missing_tiles_); |
581 layer->SetForceRenderSurface(force_render_surface_); | 624 layer->SetForceRenderSurface(force_render_surface_); |
582 layer->SetDrawsContent(DrawsContent()); | 625 layer->SetDrawsContent(DrawsContent()); |
583 layer->SetFilters(filters()); | 626 layer->SetFilters(filters()); |
584 layer->SetFilter(filter()); | 627 layer->SetFilter(filter()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
643 } | 686 } |
644 | 687 |
645 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 688 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
646 return LayerImpl::Create(tree_impl, layer_id_); | 689 return LayerImpl::Create(tree_impl, layer_id_); |
647 } | 690 } |
648 | 691 |
649 bool Layer::DrawsContent() const { | 692 bool Layer::DrawsContent() const { |
650 return is_drawable_; | 693 return is_drawable_; |
651 } | 694 } |
652 | 695 |
696 void Layer::PrepareToUpdate() { | |
697 // Save layer properties that might change during Update(). | |
698 // PushProperties() should use these saved values. | |
699 last_bounds_ = bounds_; | |
700 } | |
701 | |
653 bool Layer::NeedMoreUpdates() { | 702 bool Layer::NeedMoreUpdates() { |
654 return false; | 703 return false; |
655 } | 704 } |
656 | 705 |
657 void Layer::SetDebugName(const std::string& debug_name) { | 706 void Layer::SetDebugName(const std::string& debug_name) { |
658 debug_name_ = debug_name; | 707 debug_name_ = debug_name; |
659 SetNeedsCommit(); | 708 SetNeedsCommit(); |
660 } | 709 } |
661 | 710 |
662 void Layer::SetRasterScale(float scale) { | 711 void Layer::SetRasterScale(float scale) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 | 847 |
799 ScrollbarLayer* Layer::ToScrollbarLayer() { | 848 ScrollbarLayer* Layer::ToScrollbarLayer() { |
800 return NULL; | 849 return NULL; |
801 } | 850 } |
802 | 851 |
803 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 852 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
804 return layer_tree_host_->rendering_stats_instrumentation(); | 853 return layer_tree_host_->rendering_stats_instrumentation(); |
805 } | 854 } |
806 | 855 |
807 } // namespace cc | 856 } // namespace cc |
OLD | NEW |