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

Side by Side Diff: cc/layer_impl.cc

Issue 11575018: cc: Add id->LayerImpl map to LayerTreeImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
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/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 "base/values.h" 9 #include "base/values.h"
10 #include "cc/debug_border_draw_quad.h" 10 #include "cc/debug_border_draw_quad.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 , m_isContainerForFixedPositionLayers(false) 49 , m_isContainerForFixedPositionLayers(false)
50 , m_fixedToContainerLayer(false) 50 , m_fixedToContainerLayer(false)
51 , m_drawDepth(0) 51 , m_drawDepth(0)
52 #ifndef NDEBUG 52 #ifndef NDEBUG
53 , m_betweenWillDrawAndDidDraw(false) 53 , m_betweenWillDrawAndDidDraw(false)
54 #endif 54 #endif
55 , m_layerAnimationController(LayerAnimationController::create(this)) 55 , m_layerAnimationController(LayerAnimationController::create(this))
56 { 56 {
57 DCHECK(m_layerId > 0); 57 DCHECK(m_layerId > 0);
58 DCHECK(m_layerTreeImpl); 58 DCHECK(m_layerTreeImpl);
59 m_layerTreeImpl->RegisterLayer(this);
59 } 60 }
60 61
61 LayerImpl::~LayerImpl() 62 LayerImpl::~LayerImpl()
62 { 63 {
63 #ifndef NDEBUG 64 #ifndef NDEBUG
64 DCHECK(!m_betweenWillDrawAndDidDraw); 65 DCHECK(!m_betweenWillDrawAndDidDraw);
65 #endif 66 #endif
67 m_layerTreeImpl->UnregisterLayer(this);
66 } 68 }
67 69
68 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) 70 void LayerImpl::addChild(scoped_ptr<LayerImpl> child)
69 { 71 {
70 child->setParent(this); 72 child->setParent(this);
71 DCHECK_EQ(layerTreeImpl(), child->layerTreeImpl()); 73 DCHECK_EQ(layerTreeImpl(), child->layerTreeImpl());
72 m_children.append(child.Pass()); 74 m_children.append(child.Pass());
73 layerTreeImpl()->SetNeedsUpdateDrawProperties(); 75 layerTreeImpl()->SetNeedsUpdateDrawProperties();
74 } 76 }
75 77
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 m_bounds = bounds; 489 m_bounds = bounds;
488 490
489 if (masksToBounds()) 491 if (masksToBounds())
490 noteLayerPropertyChangedForSubtree(); 492 noteLayerPropertyChangedForSubtree();
491 else 493 else
492 noteLayerPropertyChanged(); 494 noteLayerPropertyChanged();
493 } 495 }
494 496
495 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) 497 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer)
496 { 498 {
497 if (maskLayer) 499 int newLayerId = maskLayer ? maskLayer->id() : -1;
500
501 if (maskLayer) {
498 DCHECK_EQ(layerTreeImpl(), maskLayer->layerTreeImpl()); 502 DCHECK_EQ(layerTreeImpl(), maskLayer->layerTreeImpl());
499 m_maskLayer = maskLayer.Pass(); 503 DCHECK_NE(newLayerId, m_maskLayerId);
500 504 } else if (newLayerId == m_maskLayerId)
danakj 2012/12/13 23:57:11 This is "if (!maskLayer && newLayerId == m_maskLay
enne (OOO) 2012/12/14 00:21:12 No, I meant else if. This is the case where "if y
danakj 2012/12/14 00:23:15 OOhh. ok!
501 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
502 if (newLayerId == m_maskLayerId)
503 return; 505 return;
danakj 2012/12/13 23:57:11 If the ids match, we're going to free the maskLaye
504 506
507 m_maskLayer = maskLayer.Pass();
505 m_maskLayerId = newLayerId; 508 m_maskLayerId = newLayerId;
506 noteLayerPropertyChangedForSubtree(); 509 noteLayerPropertyChangedForSubtree();
507 } 510 }
508 511
512 scoped_ptr<LayerImpl> LayerImpl::takeMaskLayer()
513 {
514 m_maskLayerId = -1;
515 return m_maskLayer.Pass();
516 }
517
509 void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer) 518 void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer)
510 { 519 {
511 if (replicaLayer) 520 int newLayerId = replicaLayer ? replicaLayer->id() : -1;
521
522 if (replicaLayer) {
512 DCHECK_EQ(layerTreeImpl(), replicaLayer->layerTreeImpl()); 523 DCHECK_EQ(layerTreeImpl(), replicaLayer->layerTreeImpl());
513 m_replicaLayer = replicaLayer.Pass(); 524 DCHECK_NE(newLayerId, m_replicaLayerId);
514 525 } else if (newLayerId == m_replicaLayerId)
515 int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1;
516 if (newLayerId == m_replicaLayerId)
517 return; 526 return;
518 527
528 m_replicaLayer = replicaLayer.Pass();
519 m_replicaLayerId = newLayerId; 529 m_replicaLayerId = newLayerId;
520 noteLayerPropertyChangedForSubtree(); 530 noteLayerPropertyChangedForSubtree();
521 } 531 }
522 532
533 scoped_ptr<LayerImpl> LayerImpl::takeReplicaLayer()
534 {
535 m_replicaLayerId = -1;
536 return m_replicaLayer.Pass();
537 }
538
523 void LayerImpl::setDrawsContent(bool drawsContent) 539 void LayerImpl::setDrawsContent(bool drawsContent)
524 { 540 {
525 if (m_drawsContent == drawsContent) 541 if (m_drawsContent == drawsContent)
526 return; 542 return;
527 543
528 m_drawsContent = drawsContent; 544 m_drawsContent = drawsContent;
529 noteLayerPropertyChanged(); 545 noteLayerPropertyChanged();
530 } 546 }
531 547
532 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint) 548 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint)
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 784
769 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 785 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
770 { 786 {
771 if (!m_scrollbarAnimationController) 787 if (!m_scrollbarAnimationController)
772 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 788 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
773 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 789 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
774 m_scrollbarAnimationController->updateScrollOffset(this); 790 m_scrollbarAnimationController->updateScrollOffset(this);
775 } 791 }
776 792
777 } // namespace cc 793 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_impl_unittest.cc » ('j') | cc/layer_tree_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698