OLD | NEW |
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/layer_impl.h" | 5 #include "cc/layer_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "cc/debug_border_draw_quad.h" | 9 #include "cc/debug_border_draw_quad.h" |
10 #include "cc/debug_colors.h" | 10 #include "cc/debug_colors.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #ifndef NDEBUG | 62 #ifndef NDEBUG |
63 DCHECK(!m_betweenWillDrawAndDidDraw); | 63 DCHECK(!m_betweenWillDrawAndDidDraw); |
64 #endif | 64 #endif |
65 } | 65 } |
66 | 66 |
67 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) | 67 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) |
68 { | 68 { |
69 child->setParent(this); | 69 child->setParent(this); |
70 DCHECK_EQ(layerTreeHostImpl(), child->layerTreeHostImpl()); | 70 DCHECK_EQ(layerTreeHostImpl(), child->layerTreeHostImpl()); |
71 m_children.append(child.Pass()); | 71 m_children.append(child.Pass()); |
| 72 m_layerTreeHostImpl->setNeedsUpdateDrawProperties(); |
72 } | 73 } |
73 | 74 |
74 void LayerImpl::removeFromParent() | 75 void LayerImpl::removeFromParent() |
75 { | 76 { |
76 if (!m_parent) | 77 if (!m_parent) |
77 return; | 78 return; |
78 | 79 |
79 LayerImpl* parent = m_parent; | 80 LayerImpl* parent = m_parent; |
80 m_parent = 0; | 81 m_parent = 0; |
81 | 82 |
82 for (size_t i = 0; i < parent->m_children.size(); ++i) { | 83 for (size_t i = 0; i < parent->m_children.size(); ++i) { |
83 if (parent->m_children[i] == this) { | 84 if (parent->m_children[i] == this) { |
84 parent->m_children.remove(i); | 85 parent->m_children.remove(i); |
| 86 m_layerTreeHostImpl->setNeedsUpdateDrawProperties(); |
85 return; | 87 return; |
86 } | 88 } |
87 } | 89 } |
88 } | 90 } |
89 | 91 |
90 void LayerImpl::removeAllChildren() | 92 void LayerImpl::removeAllChildren() |
91 { | 93 { |
92 while (m_children.size()) | 94 while (m_children.size()) |
93 m_children[0]->removeFromParent(); | 95 m_children[0]->removeFromParent(); |
94 } | 96 } |
95 | 97 |
96 void LayerImpl::clearChildList() | 98 void LayerImpl::clearChildList() |
97 { | 99 { |
98 m_children.clear(); | 100 m_children.clear(); |
| 101 m_layerTreeHostImpl->setNeedsUpdateDrawProperties(); |
99 } | 102 } |
100 | 103 |
101 void LayerImpl::createRenderSurface() | 104 void LayerImpl::createRenderSurface() |
102 { | 105 { |
103 DCHECK(!m_drawProperties.render_surface); | 106 DCHECK(!m_drawProperties.render_surface); |
104 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this
)); | 107 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this
)); |
105 m_drawProperties.render_target = this; | 108 m_drawProperties.render_target = this; |
106 } | 109 } |
107 | 110 |
108 int LayerImpl::descendantsDrawContent() | 111 int LayerImpl::descendantsDrawContent() |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 LayerImpl* current = this->m_parent; | 365 LayerImpl* current = this->m_parent; |
363 while (current && !current->m_drawProperties.render_surface) { | 366 while (current && !current->m_drawProperties.render_surface) { |
364 if (current->m_layerSurfacePropertyChanged) | 367 if (current->m_layerSurfacePropertyChanged) |
365 return true; | 368 return true; |
366 current = current->m_parent; | 369 current = current->m_parent; |
367 } | 370 } |
368 | 371 |
369 return false; | 372 return false; |
370 } | 373 } |
371 | 374 |
| 375 void LayerImpl::noteLayerSurfacePropertyChanged() |
| 376 { |
| 377 m_layerSurfacePropertyChanged = true; |
| 378 m_layerTreeHostImpl->setNeedsUpdateDrawProperties(); |
| 379 } |
| 380 |
| 381 void LayerImpl::noteLayerPropertyChanged() |
| 382 { |
| 383 m_layerPropertyChanged = true; |
| 384 m_layerTreeHostImpl->setNeedsUpdateDrawProperties(); |
| 385 } |
| 386 |
372 void LayerImpl::noteLayerPropertyChangedForSubtree() | 387 void LayerImpl::noteLayerPropertyChangedForSubtree() |
373 { | 388 { |
374 m_layerPropertyChanged = true; | 389 noteLayerPropertyChanged(); |
375 noteLayerPropertyChangedForDescendants(); | 390 noteLayerPropertyChangedForDescendants(); |
376 } | 391 } |
377 | 392 |
378 void LayerImpl::noteLayerPropertyChangedForDescendants() | 393 void LayerImpl::noteLayerPropertyChangedForDescendants() |
379 { | 394 { |
380 for (size_t i = 0; i < m_children.size(); ++i) | 395 for (size_t i = 0; i < m_children.size(); ++i) |
381 m_children[i]->noteLayerPropertyChangedForSubtree(); | 396 m_children[i]->noteLayerPropertyChangedForSubtree(); |
382 } | 397 } |
383 | 398 |
384 const char* LayerImpl::layerTypeAsString() const | 399 const char* LayerImpl::layerTypeAsString() const |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 void LayerImpl::setBounds(const gfx::Size& bounds) | 434 void LayerImpl::setBounds(const gfx::Size& bounds) |
420 { | 435 { |
421 if (m_bounds == bounds) | 436 if (m_bounds == bounds) |
422 return; | 437 return; |
423 | 438 |
424 m_bounds = bounds; | 439 m_bounds = bounds; |
425 | 440 |
426 if (masksToBounds()) | 441 if (masksToBounds()) |
427 noteLayerPropertyChangedForSubtree(); | 442 noteLayerPropertyChangedForSubtree(); |
428 else | 443 else |
429 m_layerPropertyChanged = true; | 444 noteLayerPropertyChanged(); |
430 } | 445 } |
431 | 446 |
432 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) | 447 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) |
433 { | 448 { |
434 if (maskLayer) | 449 if (maskLayer) |
435 DCHECK_EQ(layerTreeHostImpl(), maskLayer->layerTreeHostImpl()); | 450 DCHECK_EQ(layerTreeHostImpl(), maskLayer->layerTreeHostImpl()); |
436 m_maskLayer = maskLayer.Pass(); | 451 m_maskLayer = maskLayer.Pass(); |
437 | 452 |
438 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; | 453 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; |
439 if (newLayerId == m_maskLayerId) | 454 if (newLayerId == m_maskLayerId) |
(...skipping 16 matching lines...) Expand all Loading... |
456 m_replicaLayerId = newLayerId; | 471 m_replicaLayerId = newLayerId; |
457 noteLayerPropertyChangedForSubtree(); | 472 noteLayerPropertyChangedForSubtree(); |
458 } | 473 } |
459 | 474 |
460 void LayerImpl::setDrawsContent(bool drawsContent) | 475 void LayerImpl::setDrawsContent(bool drawsContent) |
461 { | 476 { |
462 if (m_drawsContent == drawsContent) | 477 if (m_drawsContent == drawsContent) |
463 return; | 478 return; |
464 | 479 |
465 m_drawsContent = drawsContent; | 480 m_drawsContent = drawsContent; |
466 m_layerPropertyChanged = true; | 481 noteLayerPropertyChanged(); |
467 } | 482 } |
468 | 483 |
469 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint) | 484 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint) |
470 { | 485 { |
471 if (m_anchorPoint == anchorPoint) | 486 if (m_anchorPoint == anchorPoint) |
472 return; | 487 return; |
473 | 488 |
474 m_anchorPoint = anchorPoint; | 489 m_anchorPoint = anchorPoint; |
475 noteLayerPropertyChangedForSubtree(); | 490 noteLayerPropertyChangedForSubtree(); |
476 } | 491 } |
477 | 492 |
478 void LayerImpl::setAnchorPointZ(float anchorPointZ) | 493 void LayerImpl::setAnchorPointZ(float anchorPointZ) |
479 { | 494 { |
480 if (m_anchorPointZ == anchorPointZ) | 495 if (m_anchorPointZ == anchorPointZ) |
481 return; | 496 return; |
482 | 497 |
483 m_anchorPointZ = anchorPointZ; | 498 m_anchorPointZ = anchorPointZ; |
484 noteLayerPropertyChangedForSubtree(); | 499 noteLayerPropertyChangedForSubtree(); |
485 } | 500 } |
486 | 501 |
487 void LayerImpl::setBackgroundColor(SkColor backgroundColor) | 502 void LayerImpl::setBackgroundColor(SkColor backgroundColor) |
488 { | 503 { |
489 if (m_backgroundColor == backgroundColor) | 504 if (m_backgroundColor == backgroundColor) |
490 return; | 505 return; |
491 | 506 |
492 m_backgroundColor = backgroundColor; | 507 m_backgroundColor = backgroundColor; |
493 m_layerPropertyChanged = true; | 508 noteLayerPropertyChanged(); |
494 } | 509 } |
495 | 510 |
496 void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters) | 511 void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters) |
497 { | 512 { |
498 if (m_filters == filters) | 513 if (m_filters == filters) |
499 return; | 514 return; |
500 | 515 |
501 DCHECK(!m_filter); | 516 DCHECK(!m_filter); |
502 m_filters = filters; | 517 m_filters = filters; |
503 noteLayerPropertyChangedForSubtree(); | 518 noteLayerPropertyChangedForSubtree(); |
504 } | 519 } |
505 | 520 |
506 void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgrou
ndFilters) | 521 void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgrou
ndFilters) |
507 { | 522 { |
508 if (m_backgroundFilters == backgroundFilters) | 523 if (m_backgroundFilters == backgroundFilters) |
509 return; | 524 return; |
510 | 525 |
511 m_backgroundFilters = backgroundFilters; | 526 m_backgroundFilters = backgroundFilters; |
512 m_layerPropertyChanged = true; | 527 noteLayerPropertyChanged(); |
513 } | 528 } |
514 | 529 |
515 void LayerImpl::setFilter(const skia::RefPtr<SkImageFilter>& filter) | 530 void LayerImpl::setFilter(const skia::RefPtr<SkImageFilter>& filter) |
516 { | 531 { |
517 if (m_filter.get() == filter.get()) | 532 if (m_filter.get() == filter.get()) |
518 return; | 533 return; |
519 | 534 |
520 DCHECK(m_filters.isEmpty()); | 535 DCHECK(m_filters.isEmpty()); |
521 m_filter = filter; | 536 m_filter = filter; |
522 noteLayerPropertyChangedForSubtree(); | 537 noteLayerPropertyChangedForSubtree(); |
(...skipping 14 matching lines...) Expand all Loading... |
537 return; | 552 return; |
538 | 553 |
539 m_contentsOpaque = opaque; | 554 m_contentsOpaque = opaque; |
540 noteLayerPropertyChangedForSubtree(); | 555 noteLayerPropertyChangedForSubtree(); |
541 } | 556 } |
542 | 557 |
543 void LayerImpl::setOpacity(float opacity) | 558 void LayerImpl::setOpacity(float opacity) |
544 { | 559 { |
545 if (!m_layerAnimationController->setOpacity(opacity)) | 560 if (!m_layerAnimationController->setOpacity(opacity)) |
546 return; | 561 return; |
547 m_layerSurfacePropertyChanged = true; | 562 |
| 563 noteLayerSurfacePropertyChanged(); |
548 } | 564 } |
549 | 565 |
550 float LayerImpl::opacity() const | 566 float LayerImpl::opacity() const |
551 { | 567 { |
552 return m_layerAnimationController->opacity(); | 568 return m_layerAnimationController->opacity(); |
553 } | 569 } |
554 | 570 |
555 bool LayerImpl::opacityIsAnimating() const | 571 bool LayerImpl::opacityIsAnimating() const |
556 { | 572 { |
557 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); | 573 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); |
(...skipping 24 matching lines...) Expand all Loading... |
582 | 598 |
583 m_sublayerTransform = sublayerTransform; | 599 m_sublayerTransform = sublayerTransform; |
584 // sublayer transform does not affect the current layer; it affects only its
children. | 600 // sublayer transform does not affect the current layer; it affects only its
children. |
585 noteLayerPropertyChangedForDescendants(); | 601 noteLayerPropertyChangedForDescendants(); |
586 } | 602 } |
587 | 603 |
588 void LayerImpl::setTransform(const gfx::Transform& transform) | 604 void LayerImpl::setTransform(const gfx::Transform& transform) |
589 { | 605 { |
590 if (!m_layerAnimationController->setTransform(transform)) | 606 if (!m_layerAnimationController->setTransform(transform)) |
591 return; | 607 return; |
592 m_layerSurfacePropertyChanged = true; | 608 |
| 609 noteLayerSurfacePropertyChanged(); |
593 } | 610 } |
594 | 611 |
595 const gfx::Transform& LayerImpl::transform() const | 612 const gfx::Transform& LayerImpl::transform() const |
596 { | 613 { |
597 return m_layerAnimationController->transform(); | 614 return m_layerAnimationController->transform(); |
598 } | 615 } |
599 | 616 |
600 bool LayerImpl::transformIsAnimating() const | 617 bool LayerImpl::transformIsAnimating() const |
601 { | 618 { |
602 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); | 619 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); |
603 } | 620 } |
604 | 621 |
605 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) | 622 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) |
606 { | 623 { |
607 if (m_contentBounds == contentBounds) | 624 if (m_contentBounds == contentBounds) |
608 return; | 625 return; |
609 | 626 |
610 m_contentBounds = contentBounds; | 627 m_contentBounds = contentBounds; |
611 m_layerPropertyChanged = true; | 628 noteLayerPropertyChanged(); |
612 } | 629 } |
613 | 630 |
614 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) | 631 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) |
615 { | 632 { |
616 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY
) | 633 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY
) |
617 return; | 634 return; |
618 | 635 |
619 m_contentsScaleX = contentsScaleX; | 636 m_contentsScaleX = contentsScaleX; |
620 m_contentsScaleY = contentsScaleY; | 637 m_contentsScaleY = contentsScaleY; |
621 m_layerPropertyChanged = true; | 638 noteLayerPropertyChanged(); |
622 } | 639 } |
623 | 640 |
624 void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset) | 641 void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset) |
625 { | 642 { |
626 if (m_scrollOffset == scrollOffset) | 643 if (m_scrollOffset == scrollOffset) |
627 return; | 644 return; |
628 | 645 |
629 m_scrollOffset = scrollOffset; | 646 m_scrollOffset = scrollOffset; |
630 noteLayerPropertyChangedForSubtree(); | 647 noteLayerPropertyChangedForSubtree(); |
631 } | 648 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 | 724 |
708 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 725 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
709 { | 726 { |
710 if (!m_scrollbarAnimationController) | 727 if (!m_scrollbarAnimationController) |
711 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 728 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
712 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 729 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
713 m_scrollbarAnimationController->updateScrollOffset(this); | 730 m_scrollbarAnimationController->updateScrollOffset(this); |
714 } | 731 } |
715 | 732 |
716 } // namespace cc | 733 } // namespace cc |
OLD | NEW |