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

Side by Side Diff: cc/layer_impl.cc

Issue 11529003: [cc] Route LayerImpl::layerTreeHostImpl() calls through 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
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_tree_debug_state.h » ('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 "base/values.h" 9 #include "base/values.h"
10 #include "cc/debug_border_draw_quad.h" 10 #include "cc/debug_border_draw_quad.h"
11 #include "cc/debug_colors.h" 11 #include "cc/debug_colors.h"
12 #include "cc/layer_tree_host_impl.h" 12 #include "cc/layer_tree_debug_state.h"
13 #include "cc/layer_tree_impl.h" 13 #include "cc/layer_tree_impl.h"
14 #include "cc/layer_tree_settings.h"
14 #include "cc/math_util.h" 15 #include "cc/math_util.h"
15 #include "cc/proxy.h" 16 #include "cc/proxy.h"
16 #include "cc/quad_sink.h" 17 #include "cc/quad_sink.h"
17 #include "cc/scrollbar_animation_controller.h" 18 #include "cc/scrollbar_animation_controller.h"
18 #include "ui/gfx/point_conversions.h" 19 #include "ui/gfx/point_conversions.h"
19 #include "ui/gfx/rect_conversions.h" 20 #include "ui/gfx/rect_conversions.h"
20 21
21 namespace cc { 22 namespace cc {
22 23
23 LayerImpl::LayerImpl(LayerTreeImpl* treeImpl, int id) 24 LayerImpl::LayerImpl(LayerTreeImpl* treeImpl, int id)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
66 } 67 }
67 68
68 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) 69 void LayerImpl::addChild(scoped_ptr<LayerImpl> child)
69 { 70 {
70 child->setParent(this); 71 child->setParent(this);
71 DCHECK_EQ(layerTreeHostImpl(), child->layerTreeHostImpl()); 72 DCHECK_EQ(layerTreeImpl(), child->layerTreeImpl());
72 m_children.append(child.Pass()); 73 m_children.append(child.Pass());
73 layerTreeHostImpl()->setNeedsUpdateDrawProperties(); 74 layerTreeImpl()->SetNeedsUpdateDrawProperties();
74 } 75 }
75 76
76 scoped_ptr<LayerImpl> LayerImpl::removeChild(LayerImpl* child) 77 scoped_ptr<LayerImpl> LayerImpl::removeChild(LayerImpl* child)
77 { 78 {
78 for (size_t i = 0; i < m_children.size(); ++i) { 79 for (size_t i = 0; i < m_children.size(); ++i) {
79 if (m_children[i] == child) { 80 if (m_children[i] == child) {
80 scoped_ptr<LayerImpl> ret = m_children.take(i); 81 scoped_ptr<LayerImpl> ret = m_children.take(i);
81 m_children.remove(i); 82 m_children.remove(i);
82 layerTreeHostImpl()->setNeedsUpdateDrawProperties(); 83 layerTreeImpl()->SetNeedsUpdateDrawProperties();
83 return ret.Pass(); 84 return ret.Pass();
84 } 85 }
85 } 86 }
86 return scoped_ptr<LayerImpl>(); 87 return scoped_ptr<LayerImpl>();
87 } 88 }
88 89
89 void LayerImpl::removeAllChildren() 90 void LayerImpl::removeAllChildren()
90 { 91 {
91 m_children.clear(); 92 m_children.clear();
92 layerTreeHostImpl()->setNeedsUpdateDrawProperties(); 93 layerTreeImpl()->SetNeedsUpdateDrawProperties();
93 } 94 }
94 95
95 void LayerImpl::clearChildList() 96 void LayerImpl::clearChildList()
96 { 97 {
97 if (m_children.isEmpty()) 98 if (m_children.isEmpty())
98 return; 99 return;
99 100
100 m_children.clear(); 101 m_children.clear();
101 layerTreeHostImpl()->setNeedsUpdateDrawProperties(); 102 layerTreeImpl()->SetNeedsUpdateDrawProperties();
102 } 103 }
103 104
104 void LayerImpl::createRenderSurface() 105 void LayerImpl::createRenderSurface()
105 { 106 {
106 DCHECK(!m_drawProperties.render_surface); 107 DCHECK(!m_drawProperties.render_surface);
107 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this )); 108 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this ));
108 m_drawProperties.render_target = this; 109 m_drawProperties.render_target = this;
109 } 110 }
110 111
111 int LayerImpl::descendantsDrawContent() 112 int LayerImpl::descendantsDrawContent()
112 { 113 {
113 int result = 0; 114 int result = 0;
114 for (size_t i = 0; i < m_children.size(); ++i) { 115 for (size_t i = 0; i < m_children.size(); ++i) {
115 if (m_children[i]->drawsContent()) 116 if (m_children[i]->drawsContent())
116 ++result; 117 ++result;
117 result += m_children[i]->descendantsDrawContent(); 118 result += m_children[i]->descendantsDrawContent();
118 if (result > 1) 119 if (result > 1)
119 return result; 120 return result;
120 } 121 }
121 return result; 122 return result;
122 } 123 }
123 124
124 LayerTreeHostImpl* LayerImpl::layerTreeHostImpl() const {
125 return m_layerTreeImpl->layer_tree_host_impl();
126 }
127
128 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const 125 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const
129 { 126 {
130 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); 127 scoped_ptr<SharedQuadState> state = SharedQuadState::Create();
131 state->SetAll(m_drawProperties.target_space_transform, 128 state->SetAll(m_drawProperties.target_space_transform,
132 m_drawProperties.visible_content_rect, 129 m_drawProperties.visible_content_rect,
133 m_drawProperties.drawable_content_rect, 130 m_drawProperties.drawable_content_rect,
134 m_drawProperties.clip_rect, 131 m_drawProperties.clip_rect,
135 m_drawProperties.is_clipped, 132 m_drawProperties.is_clipped,
136 m_drawProperties.opacity); 133 m_drawProperties.opacity);
137 return state.Pass(); 134 return state.Pass();
(...skipping 11 matching lines...) Expand all
149 void LayerImpl::didDraw(ResourceProvider*) 146 void LayerImpl::didDraw(ResourceProvider*)
150 { 147 {
151 #ifndef NDEBUG 148 #ifndef NDEBUG
152 DCHECK(m_betweenWillDrawAndDidDraw); 149 DCHECK(m_betweenWillDrawAndDidDraw);
153 m_betweenWillDrawAndDidDraw = false; 150 m_betweenWillDrawAndDidDraw = false;
154 #endif 151 #endif
155 } 152 }
156 153
157 bool LayerImpl::showDebugBorders() const 154 bool LayerImpl::showDebugBorders() const
158 { 155 {
159 return layerTreeHostImpl()->debugState().showDebugBorders; 156 return layerTreeImpl()->debug_state().showDebugBorders;
160 } 157 }
161 158
162 void LayerImpl::getDebugBorderProperties(SkColor* color, float* width) const 159 void LayerImpl::getDebugBorderProperties(SkColor* color, float* width) const
163 { 160 {
164 if (m_drawsContent) { 161 if (m_drawsContent) {
165 *color = DebugColors::ContentLayerBorderColor(); 162 *color = DebugColors::ContentLayerBorderColor();
166 *width = DebugColors::ContentLayerBorderWidth(layerTreeHostImpl()); 163 *width = DebugColors::ContentLayerBorderWidth(layerTreeImpl());
167 return; 164 return;
168 } 165 }
169 166
170 if (m_masksToBounds) { 167 if (m_masksToBounds) {
171 *color = DebugColors::MaskingLayerBorderColor(); 168 *color = DebugColors::MaskingLayerBorderColor();
172 *width = DebugColors::MaskingLayerBorderWidth(layerTreeHostImpl()); 169 *width = DebugColors::MaskingLayerBorderWidth(layerTreeImpl());
173 return; 170 return;
174 } 171 }
175 172
176 *color = DebugColors::ContainerLayerBorderColor(); 173 *color = DebugColors::ContainerLayerBorderColor();
177 *width = DebugColors::ContainerLayerBorderWidth(layerTreeHostImpl()); 174 *width = DebugColors::ContainerLayerBorderWidth(layerTreeImpl());
178 } 175 }
179 176
180 void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState* sharedQuadState, AppendQuadsData& appendQuadsData) const 177 void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState* sharedQuadState, AppendQuadsData& appendQuadsData) const
181 { 178 {
182 if (!showDebugBorders()) 179 if (!showDebugBorders())
183 return; 180 return;
184 181
185 SkColor color; 182 SkColor color;
186 float width; 183 float width;
187 getDebugBorderProperties(&color, &width); 184 getDebugBorderProperties(&color, &width);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 if (!scrollable()) { 261 if (!scrollable()) {
265 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); 262 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable");
266 return InputHandlerClient::ScrollIgnored; 263 return InputHandlerClient::ScrollIgnored;
267 } 264 }
268 265
269 return InputHandlerClient::ScrollStarted; 266 return InputHandlerClient::ScrollStarted;
270 } 267 }
271 268
272 bool LayerImpl::drawCheckerboardForMissingTiles() const 269 bool LayerImpl::drawCheckerboardForMissingTiles() const
273 { 270 {
274 return m_drawCheckerboardForMissingTiles && !layerTreeHostImpl()->settings() .backgroundColorInsteadOfCheckerboard; 271 return m_drawCheckerboardForMissingTiles && !layerTreeImpl()->settings().bac kgroundColorInsteadOfCheckerboard;
275 } 272 }
276 273
277 gfx::Rect LayerImpl::layerRectToContentRect(const gfx::RectF& layerRect) const 274 gfx::Rect LayerImpl::layerRectToContentRect(const gfx::RectF& layerRect) const
278 { 275 {
279 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content sScaleY()); 276 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content sScaleY());
280 // Intersect with content rect to avoid the extra pixel because for some 277 // Intersect with content rect to avoid the extra pixel because for some
281 // values x and y, ceil((x / y) * y) may be x + 1. 278 // values x and y, ceil((x / y) * y) may be x + 1.
282 contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds())); 279 contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds()));
283 return gfx::ToEnclosingRect(contentRect); 280 return gfx::ToEnclosingRect(contentRect);
284 } 281 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 return true; 404 return true;
408 current = current->m_parent; 405 current = current->m_parent;
409 } 406 }
410 407
411 return false; 408 return false;
412 } 409 }
413 410
414 void LayerImpl::noteLayerSurfacePropertyChanged() 411 void LayerImpl::noteLayerSurfacePropertyChanged()
415 { 412 {
416 m_layerSurfacePropertyChanged = true; 413 m_layerSurfacePropertyChanged = true;
417 layerTreeHostImpl()->setNeedsUpdateDrawProperties(); 414 layerTreeImpl()->SetNeedsUpdateDrawProperties();
418 } 415 }
419 416
420 void LayerImpl::noteLayerPropertyChanged() 417 void LayerImpl::noteLayerPropertyChanged()
421 { 418 {
422 m_layerPropertyChanged = true; 419 m_layerPropertyChanged = true;
423 layerTreeHostImpl()->setNeedsUpdateDrawProperties(); 420 layerTreeImpl()->SetNeedsUpdateDrawProperties();
424 } 421 }
425 422
426 void LayerImpl::noteLayerPropertyChangedForSubtree() 423 void LayerImpl::noteLayerPropertyChangedForSubtree()
427 { 424 {
428 noteLayerPropertyChanged(); 425 noteLayerPropertyChanged();
429 noteLayerPropertyChangedForDescendants(); 426 noteLayerPropertyChangedForDescendants();
430 } 427 }
431 428
432 void LayerImpl::noteLayerPropertyChangedForDescendants() 429 void LayerImpl::noteLayerPropertyChangedForDescendants()
433 { 430 {
434 layerTreeHostImpl()->setNeedsUpdateDrawProperties(); 431 layerTreeImpl()->SetNeedsUpdateDrawProperties();
435 for (size_t i = 0; i < m_children.size(); ++i) 432 for (size_t i = 0; i < m_children.size(); ++i)
436 m_children[i]->noteLayerPropertyChangedForSubtree(); 433 m_children[i]->noteLayerPropertyChangedForSubtree();
437 } 434 }
438 435
439 const char* LayerImpl::layerTypeAsString() const 436 const char* LayerImpl::layerTypeAsString() const
440 { 437 {
441 return "Layer"; 438 return "Layer";
442 } 439 }
443 440
444 void LayerImpl::resetAllChangeTrackingForSubtree() 441 void LayerImpl::resetAllChangeTrackingForSubtree()
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 497
501 if (masksToBounds()) 498 if (masksToBounds())
502 noteLayerPropertyChangedForSubtree(); 499 noteLayerPropertyChangedForSubtree();
503 else 500 else
504 noteLayerPropertyChanged(); 501 noteLayerPropertyChanged();
505 } 502 }
506 503
507 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) 504 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer)
508 { 505 {
509 if (maskLayer) 506 if (maskLayer)
510 DCHECK_EQ(layerTreeHostImpl(), maskLayer->layerTreeHostImpl()); 507 DCHECK_EQ(layerTreeImpl(), maskLayer->layerTreeImpl());
511 m_maskLayer = maskLayer.Pass(); 508 m_maskLayer = maskLayer.Pass();
512 509
513 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; 510 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
514 if (newLayerId == m_maskLayerId) 511 if (newLayerId == m_maskLayerId)
515 return; 512 return;
516 513
517 m_maskLayerId = newLayerId; 514 m_maskLayerId = newLayerId;
518 noteLayerPropertyChangedForSubtree(); 515 noteLayerPropertyChangedForSubtree();
519 } 516 }
520 517
521 void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer) 518 void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer)
522 { 519 {
523 if (replicaLayer) 520 if (replicaLayer)
524 DCHECK_EQ(layerTreeHostImpl(), replicaLayer->layerTreeHostImpl()); 521 DCHECK_EQ(layerTreeImpl(), replicaLayer->layerTreeImpl());
525 m_replicaLayer = replicaLayer.Pass(); 522 m_replicaLayer = replicaLayer.Pass();
526 523
527 int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1; 524 int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1;
528 if (newLayerId == m_replicaLayerId) 525 if (newLayerId == m_replicaLayerId)
529 return; 526 return;
530 527
531 m_replicaLayerId = newLayerId; 528 m_replicaLayerId = newLayerId;
532 noteLayerPropertyChangedForSubtree(); 529 noteLayerPropertyChangedForSubtree();
533 } 530 }
534 531
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 void LayerImpl::didLoseOutputSurface() 733 void LayerImpl::didLoseOutputSurface()
737 { 734 {
738 } 735 }
739 736
740 void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset) 737 void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
741 { 738 {
742 if (m_maxScrollOffset == maxScrollOffset) 739 if (m_maxScrollOffset == maxScrollOffset)
743 return; 740 return;
744 m_maxScrollOffset = maxScrollOffset; 741 m_maxScrollOffset = maxScrollOffset;
745 742
746 layerTreeHostImpl()->setNeedsUpdateDrawProperties(); 743 layerTreeImpl()->SetNeedsUpdateDrawProperties();
747 744
748 if (!m_scrollbarAnimationController) 745 if (!m_scrollbarAnimationController)
749 return; 746 return;
750 m_scrollbarAnimationController->updateScrollOffset(this); 747 m_scrollbarAnimationController->updateScrollOffset(this);
751 } 748 }
752 749
753 ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer() 750 ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer()
754 { 751 {
755 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori zontalScrollbarLayer() : 0; 752 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori zontalScrollbarLayer() : 0;
756 } 753 }
(...skipping 23 matching lines...) Expand all
780 777
781 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 778 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
782 { 779 {
783 if (!m_scrollbarAnimationController) 780 if (!m_scrollbarAnimationController)
784 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 781 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
785 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 782 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
786 m_scrollbarAnimationController->updateScrollOffset(this); 783 m_scrollbarAnimationController->updateScrollOffset(this);
787 } 784 }
788 785
789 } // namespace cc 786 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_tree_debug_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698