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

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: Rebase 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
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_preserves3D(false) 40 , m_preserves3D(false)
41 , m_useParentBackfaceVisibility(false) 41 , m_useParentBackfaceVisibility(false)
42 , m_drawCheckerboardForMissingTiles(false) 42 , m_drawCheckerboardForMissingTiles(false)
43 , m_useLCDText(false) 43 , m_useLCDText(false)
44 , m_drawsContent(false) 44 , m_drawsContent(false)
45 , m_forceRenderSurface(false) 45 , m_forceRenderSurface(false)
46 , m_isContainerForFixedPositionLayers(false) 46 , m_isContainerForFixedPositionLayers(false)
47 , m_fixedToContainerLayer(false) 47 , m_fixedToContainerLayer(false)
48 , m_drawDepth(0) 48 , m_drawDepth(0)
49 #ifndef NDEBUG 49 #ifndef NDEBUG
50 , m_betweenWillDrawAndDidDraw(false) 50 , m_betweenWillDrawAndDidDraw(false)
51 #endif 51 #endif
52 , m_layerAnimationController(LayerAnimationController::create()) 52 , m_layerAnimationController(LayerAnimationController::create())
53 { 53 {
54 DCHECK(m_layerId > 0); 54 DCHECK(m_layerId > 0);
55 DCHECK(m_layerTreeHostImpl);
55 m_layerAnimationController->setId(m_layerId); 56 m_layerAnimationController->setId(m_layerId);
57 m_layerAnimationController->setAnimationRegistrar(hostImpl);
56 } 58 }
57 59
58 LayerImpl::~LayerImpl() 60 LayerImpl::~LayerImpl()
59 { 61 {
60 #ifndef NDEBUG 62 #ifndef NDEBUG
61 DCHECK(!m_betweenWillDrawAndDidDraw); 63 DCHECK(!m_betweenWillDrawAndDidDraw);
62 #endif 64 #endif
63 } 65 }
64 66
65 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) 67 void LayerImpl::addChild(scoped_ptr<LayerImpl> child)
66 { 68 {
67 child->setParent(this); 69 child->setParent(this);
70 DCHECK_EQ(layerTreeHostImpl(), child->layerTreeHostImpl());
68 m_children.append(child.Pass()); 71 m_children.append(child.Pass());
69 } 72 }
70 73
71 void LayerImpl::removeFromParent() 74 void LayerImpl::removeFromParent()
72 { 75 {
73 if (!m_parent) 76 if (!m_parent)
74 return; 77 return;
75 78
76 LayerImpl* parent = m_parent; 79 LayerImpl* parent = m_parent;
77 m_parent = 0; 80 m_parent = 0;
(...skipping 30 matching lines...) Expand all
108 for (size_t i = 0; i < m_children.size(); ++i) { 111 for (size_t i = 0; i < m_children.size(); ++i) {
109 if (m_children[i]->drawsContent()) 112 if (m_children[i]->drawsContent())
110 ++result; 113 ++result;
111 result += m_children[i]->descendantsDrawContent(); 114 result += m_children[i]->descendantsDrawContent();
112 if (result > 1) 115 if (result > 1)
113 return result; 116 return result;
114 } 117 }
115 return result; 118 return result;
116 } 119 }
117 120
118 void LayerImpl::setLayerTreeHostImpl(LayerTreeHostImpl* hostImpl)
119 {
120 m_layerTreeHostImpl = hostImpl;
121 m_layerAnimationController->setAnimationRegistrar(hostImpl);
122 }
123
124 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const 121 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const
125 { 122 {
126 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); 123 scoped_ptr<SharedQuadState> state = SharedQuadState::Create();
127 state->SetAll(m_drawProperties.target_space_transform, 124 state->SetAll(m_drawProperties.target_space_transform,
128 m_drawProperties.visible_content_rect, 125 m_drawProperties.visible_content_rect,
129 m_drawProperties.drawable_content_rect, 126 m_drawProperties.drawable_content_rect,
130 m_drawProperties.clip_rect, 127 m_drawProperties.clip_rect,
131 m_drawProperties.is_clipped, 128 m_drawProperties.is_clipped,
132 m_drawProperties.opacity); 129 m_drawProperties.opacity);
133 return state.Pass(); 130 return state.Pass();
(...skipping 11 matching lines...) Expand all
145 void LayerImpl::didDraw(ResourceProvider*) 142 void LayerImpl::didDraw(ResourceProvider*)
146 { 143 {
147 #ifndef NDEBUG 144 #ifndef NDEBUG
148 DCHECK(m_betweenWillDrawAndDidDraw); 145 DCHECK(m_betweenWillDrawAndDidDraw);
149 m_betweenWillDrawAndDidDraw = false; 146 m_betweenWillDrawAndDidDraw = false;
150 #endif 147 #endif
151 } 148 }
152 149
153 bool LayerImpl::showDebugBorders() const 150 bool LayerImpl::showDebugBorders() const
154 { 151 {
155 if (!m_layerTreeHostImpl)
156 return false;
157 return m_layerTreeHostImpl->debugState().showDebugBorders; 152 return m_layerTreeHostImpl->debugState().showDebugBorders;
158 } 153 }
159 154
160 void LayerImpl::getDebugBorderProperties(SkColor* color, float* width) const 155 void LayerImpl::getDebugBorderProperties(SkColor* color, float* width) const
161 { 156 {
162 if (m_drawsContent) { 157 if (m_drawsContent) {
163 *color = DebugColors::ContentLayerBorderColor(); 158 *color = DebugColors::ContentLayerBorderColor();
164 *width = DebugColors::ContentLayerBorderWidth(m_layerTreeHostImpl); 159 *width = DebugColors::ContentLayerBorderWidth(m_layerTreeHostImpl);
165 return; 160 return;
166 } 161 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 m_bounds = bounds; 424 m_bounds = bounds;
430 425
431 if (masksToBounds()) 426 if (masksToBounds())
432 noteLayerPropertyChangedForSubtree(); 427 noteLayerPropertyChangedForSubtree();
433 else 428 else
434 m_layerPropertyChanged = true; 429 m_layerPropertyChanged = true;
435 } 430 }
436 431
437 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) 432 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer)
438 { 433 {
434 if (maskLayer)
435 DCHECK_EQ(layerTreeHostImpl(), maskLayer->layerTreeHostImpl());
439 m_maskLayer = maskLayer.Pass(); 436 m_maskLayer = maskLayer.Pass();
440 437
441 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; 438 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
442 if (newLayerId == m_maskLayerId) 439 if (newLayerId == m_maskLayerId)
443 return; 440 return;
444 441
445 m_maskLayerId = newLayerId; 442 m_maskLayerId = newLayerId;
446 noteLayerPropertyChangedForSubtree(); 443 noteLayerPropertyChangedForSubtree();
447 } 444 }
448 445
449 void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer) 446 void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer)
450 { 447 {
448 if (replicaLayer)
449 DCHECK_EQ(layerTreeHostImpl(), replicaLayer->layerTreeHostImpl());
451 m_replicaLayer = replicaLayer.Pass(); 450 m_replicaLayer = replicaLayer.Pass();
452 451
453 int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1; 452 int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1;
454 if (newLayerId == m_replicaLayerId) 453 if (newLayerId == m_replicaLayerId)
455 return; 454 return;
456 455
457 m_replicaLayerId = newLayerId; 456 m_replicaLayerId = newLayerId;
458 noteLayerPropertyChangedForSubtree(); 457 noteLayerPropertyChangedForSubtree();
459 } 458 }
460 459
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 707
709 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 708 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
710 { 709 {
711 if (!m_scrollbarAnimationController) 710 if (!m_scrollbarAnimationController)
712 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 711 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
713 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 712 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
714 m_scrollbarAnimationController->updateScrollOffset(this); 713 m_scrollbarAnimationController->updateScrollOffset(this);
715 } 714 }
716 715
717 } // namespace cc 716 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698