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

Side by Side Diff: cc/layer_impl.cc

Issue 11472021: cc: Pass LayerTreeHostImpl to LayerImpl constructor (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 "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"
11 #include "cc/layer_tree_host_impl.h" 11 #include "cc/layer_tree_host_impl.h"
12 #include "cc/math_util.h" 12 #include "cc/math_util.h"
13 #include "cc/proxy.h" 13 #include "cc/proxy.h"
14 #include "cc/quad_sink.h" 14 #include "cc/quad_sink.h"
15 #include "cc/scrollbar_animation_controller.h" 15 #include "cc/scrollbar_animation_controller.h"
16 #include "ui/gfx/point_conversions.h" 16 #include "ui/gfx/point_conversions.h"
17 #include "ui/gfx/rect_conversions.h" 17 #include "ui/gfx/rect_conversions.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 LayerImpl::LayerImpl(int id) 21 LayerImpl::LayerImpl(LayerTreeHostImpl* hostImpl, int id)
22 : m_parent(0) 22 : m_parent(0)
23 , m_maskLayerId(-1) 23 , m_maskLayerId(-1)
24 , m_replicaLayerId(-1) 24 , m_replicaLayerId(-1)
25 , m_layerId(id) 25 , m_layerId(id)
26 , m_layerTreeHostImpl(0) 26 , m_layerTreeHostImpl(hostImpl)
27 , m_anchorPoint(0.5, 0.5) 27 , m_anchorPoint(0.5, 0.5)
28 , m_anchorPointZ(0) 28 , m_anchorPointZ(0)
29 , m_contentsScaleX(1.0) 29 , m_contentsScaleX(1.0)
30 , m_contentsScaleY(1.0) 30 , m_contentsScaleY(1.0)
31 , m_scrollable(false) 31 , m_scrollable(false)
32 , m_shouldScrollOnMainThread(false) 32 , m_shouldScrollOnMainThread(false)
33 , m_haveWheelEventHandlers(false) 33 , m_haveWheelEventHandlers(false)
34 , m_backgroundColor(0) 34 , m_backgroundColor(0)
35 , m_doubleSided(true) 35 , m_doubleSided(true)
36 , m_layerPropertyChanged(false) 36 , m_layerPropertyChanged(false)
37 , m_layerSurfacePropertyChanged(false) 37 , m_layerSurfacePropertyChanged(false)
38 , m_masksToBounds(false) 38 , m_masksToBounds(false)
39 , m_contentsOpaque(false) 39 , m_contentsOpaque(false)
40 , m_opacity(1.0) 40 , m_opacity(1.0)
41 , m_preserves3D(false) 41 , m_preserves3D(false)
42 , m_useParentBackfaceVisibility(false) 42 , m_useParentBackfaceVisibility(false)
43 , m_drawCheckerboardForMissingTiles(false) 43 , m_drawCheckerboardForMissingTiles(false)
44 , m_useLCDText(false) 44 , m_useLCDText(false)
45 , m_drawsContent(false) 45 , m_drawsContent(false)
46 , m_forceRenderSurface(false) 46 , m_forceRenderSurface(false)
47 , m_isContainerForFixedPositionLayers(false) 47 , m_isContainerForFixedPositionLayers(false)
48 , m_fixedToContainerLayer(false) 48 , m_fixedToContainerLayer(false)
49 , m_drawDepth(0) 49 , m_drawDepth(0)
50 #ifndef NDEBUG 50 #ifndef NDEBUG
51 , m_betweenWillDrawAndDidDraw(false) 51 , m_betweenWillDrawAndDidDraw(false)
52 #endif 52 #endif
53 , m_layerAnimationController(LayerAnimationController::create(this)) 53 , m_layerAnimationController(LayerAnimationController::create(this))
54 { 54 {
55 DCHECK(m_layerId > 0); 55 DCHECK(m_layerId > 0);
56 DCHECK(m_layerTreeHostImpl);
56 } 57 }
57 58
58 LayerImpl::~LayerImpl() 59 LayerImpl::~LayerImpl()
59 { 60 {
60 #ifndef NDEBUG 61 #ifndef NDEBUG
61 DCHECK(!m_betweenWillDrawAndDidDraw); 62 DCHECK(!m_betweenWillDrawAndDidDraw);
62 #endif 63 #endif
63 } 64 }
64 65
65 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) 66 void LayerImpl::addChild(scoped_ptr<LayerImpl> child)
66 { 67 {
67 child->setParent(this); 68 child->setParent(this);
69 DCHECK_EQ(layerTreeHostImpl(), child->layerTreeHostImpl());
68 m_children.append(child.Pass()); 70 m_children.append(child.Pass());
69 } 71 }
70 72
71 void LayerImpl::removeFromParent() 73 void LayerImpl::removeFromParent()
72 { 74 {
73 if (!m_parent) 75 if (!m_parent)
74 return; 76 return;
75 77
76 LayerImpl* parent = m_parent; 78 LayerImpl* parent = m_parent;
77 m_parent = 0; 79 m_parent = 0;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 void LayerImpl::didDraw(ResourceProvider*) 141 void LayerImpl::didDraw(ResourceProvider*)
140 { 142 {
141 #ifndef NDEBUG 143 #ifndef NDEBUG
142 DCHECK(m_betweenWillDrawAndDidDraw); 144 DCHECK(m_betweenWillDrawAndDidDraw);
143 m_betweenWillDrawAndDidDraw = false; 145 m_betweenWillDrawAndDidDraw = false;
144 #endif 146 #endif
145 } 147 }
146 148
147 bool LayerImpl::showDebugBorders() const 149 bool LayerImpl::showDebugBorders() const
148 { 150 {
149 if (!m_layerTreeHostImpl)
150 return false;
151 return m_layerTreeHostImpl->debugState().showDebugBorders; 151 return m_layerTreeHostImpl->debugState().showDebugBorders;
152 } 152 }
153 153
154 void LayerImpl::getDebugBorderProperties(SkColor* color, float* width) const 154 void LayerImpl::getDebugBorderProperties(SkColor* color, float* width) const
155 { 155 {
156 if (m_drawsContent) { 156 if (m_drawsContent) {
157 *color = DebugColors::ContentLayerBorderColor(); 157 *color = DebugColors::ContentLayerBorderColor();
158 *width = DebugColors::ContentLayerBorderWidth(m_layerTreeHostImpl); 158 *width = DebugColors::ContentLayerBorderWidth(m_layerTreeHostImpl);
159 return; 159 return;
160 } 160 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 m_bounds = bounds; 443 m_bounds = bounds;
444 444
445 if (masksToBounds()) 445 if (masksToBounds())
446 noteLayerPropertyChangedForSubtree(); 446 noteLayerPropertyChangedForSubtree();
447 else 447 else
448 m_layerPropertyChanged = true; 448 m_layerPropertyChanged = true;
449 } 449 }
450 450
451 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) 451 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer)
452 { 452 {
453 if (maskLayer)
454 DCHECK_EQ(layerTreeHostImpl(), maskLayer->layerTreeHostImpl());
453 m_maskLayer = maskLayer.Pass(); 455 m_maskLayer = maskLayer.Pass();
454 456
455 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; 457 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
456 if (newLayerId == m_maskLayerId) 458 if (newLayerId == m_maskLayerId)
457 return; 459 return;
458 460
459 m_maskLayerId = newLayerId; 461 m_maskLayerId = newLayerId;
460 noteLayerPropertyChangedForSubtree(); 462 noteLayerPropertyChangedForSubtree();
461 } 463 }
462 464
463 void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer) 465 void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer)
464 { 466 {
467 if (replicaLayer)
468 DCHECK_EQ(layerTreeHostImpl(), replicaLayer->layerTreeHostImpl());
465 m_replicaLayer = replicaLayer.Pass(); 469 m_replicaLayer = replicaLayer.Pass();
466 470
467 int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1; 471 int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1;
468 if (newLayerId == m_replicaLayerId) 472 if (newLayerId == m_replicaLayerId)
469 return; 473 return;
470 474
471 m_replicaLayerId = newLayerId; 475 m_replicaLayerId = newLayerId;
472 noteLayerPropertyChangedForSubtree(); 476 noteLayerPropertyChangedForSubtree();
473 } 477 }
474 478
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 720
717 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 721 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
718 { 722 {
719 if (!m_scrollbarAnimationController) 723 if (!m_scrollbarAnimationController)
720 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 724 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
721 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 725 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
722 m_scrollbarAnimationController->updateScrollOffset(this); 726 m_scrollbarAnimationController->updateScrollOffset(this);
723 } 727 }
724 728
725 } // namespace cc 729 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_impl_unittest.cc » ('j') | cc/test/fake_impl_proxy.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698