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

Side by Side Diff: cc/layer_impl.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months 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 "config.h" 5 #include "config.h"
6 6
7 #include "CCLayerImpl.h" 7 #include "CCLayerImpl.h"
8 8
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "CCDebugBorderDrawQuad.h" 10 #include "CCDebugBorderDrawQuad.h"
11 #include "CCLayerSorter.h" 11 #include "CCLayerSorter.h"
12 #include "CCMathUtil.h" 12 #include "CCMathUtil.h"
13 #include "CCProxy.h" 13 #include "CCProxy.h"
14 #include "CCQuadSink.h" 14 #include "CCQuadSink.h"
15 #include "CCScrollbarAnimationController.h" 15 #include "CCScrollbarAnimationController.h"
16 #include "CCSettings.h" 16 #include "CCSettings.h"
17 #include "TraceEvent.h" 17 #include "TraceEvent.h"
18 18
19 using WebKit::WebTransformationMatrix; 19 using WebKit::WebTransformationMatrix;
20 20
21 namespace cc { 21 namespace cc {
22 22
23 CCLayerImpl::CCLayerImpl(int id) 23 LayerImpl::LayerImpl(int id)
24 : m_parent(0) 24 : m_parent(0)
25 , m_maskLayerId(-1) 25 , m_maskLayerId(-1)
26 , m_replicaLayerId(-1) 26 , m_replicaLayerId(-1)
27 , m_layerId(id) 27 , m_layerId(id)
28 , m_layerTreeHostImpl(0) 28 , m_layerTreeHostImpl(0)
29 , m_anchorPoint(0.5, 0.5) 29 , m_anchorPoint(0.5, 0.5)
30 , m_anchorPointZ(0) 30 , m_anchorPointZ(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)
(...skipping 16 matching lines...) Expand all
50 , m_drawDepth(0) 50 , m_drawDepth(0)
51 , m_drawOpacity(0) 51 , m_drawOpacity(0)
52 , m_drawOpacityIsAnimating(false) 52 , m_drawOpacityIsAnimating(false)
53 , m_debugBorderColor(0) 53 , m_debugBorderColor(0)
54 , m_debugBorderWidth(0) 54 , m_debugBorderWidth(0)
55 , m_drawTransformIsAnimating(false) 55 , m_drawTransformIsAnimating(false)
56 , m_screenSpaceTransformIsAnimating(false) 56 , m_screenSpaceTransformIsAnimating(false)
57 #ifndef NDEBUG 57 #ifndef NDEBUG
58 , m_betweenWillDrawAndDidDraw(false) 58 , m_betweenWillDrawAndDidDraw(false)
59 #endif 59 #endif
60 , m_layerAnimationController(CCLayerAnimationController::create(this)) 60 , m_layerAnimationController(LayerAnimationController::create(this))
61 { 61 {
62 ASSERT(CCProxy::isImplThread()); 62 ASSERT(Proxy::isImplThread());
63 ASSERT(m_layerId > 0); 63 ASSERT(m_layerId > 0);
64 } 64 }
65 65
66 CCLayerImpl::~CCLayerImpl() 66 LayerImpl::~LayerImpl()
67 { 67 {
68 ASSERT(CCProxy::isImplThread()); 68 ASSERT(Proxy::isImplThread());
69 #ifndef NDEBUG 69 #ifndef NDEBUG
70 ASSERT(!m_betweenWillDrawAndDidDraw); 70 ASSERT(!m_betweenWillDrawAndDidDraw);
71 #endif 71 #endif
72 } 72 }
73 73
74 void CCLayerImpl::addChild(scoped_ptr<CCLayerImpl> child) 74 void LayerImpl::addChild(scoped_ptr<LayerImpl> child)
75 { 75 {
76 child->setParent(this); 76 child->setParent(this);
77 m_children.append(child.Pass()); 77 m_children.append(child.Pass());
78 } 78 }
79 79
80 void CCLayerImpl::removeFromParent() 80 void LayerImpl::removeFromParent()
81 { 81 {
82 if (!m_parent) 82 if (!m_parent)
83 return; 83 return;
84 84
85 CCLayerImpl* parent = m_parent; 85 LayerImpl* parent = m_parent;
86 m_parent = 0; 86 m_parent = 0;
87 87
88 for (size_t i = 0; i < parent->m_children.size(); ++i) { 88 for (size_t i = 0; i < parent->m_children.size(); ++i) {
89 if (parent->m_children[i] == this) { 89 if (parent->m_children[i] == this) {
90 parent->m_children.remove(i); 90 parent->m_children.remove(i);
91 return; 91 return;
92 } 92 }
93 } 93 }
94 } 94 }
95 95
96 void CCLayerImpl::removeAllChildren() 96 void LayerImpl::removeAllChildren()
97 { 97 {
98 while (m_children.size()) 98 while (m_children.size())
99 m_children[0]->removeFromParent(); 99 m_children[0]->removeFromParent();
100 } 100 }
101 101
102 void CCLayerImpl::clearChildList() 102 void LayerImpl::clearChildList()
103 { 103 {
104 m_children.clear(); 104 m_children.clear();
105 } 105 }
106 106
107 void CCLayerImpl::createRenderSurface() 107 void LayerImpl::createRenderSurface()
108 { 108 {
109 ASSERT(!m_renderSurface); 109 ASSERT(!m_renderSurface);
110 m_renderSurface = make_scoped_ptr(new CCRenderSurface(this)); 110 m_renderSurface = make_scoped_ptr(new RenderSurfaceImpl(this));
111 setRenderTarget(this); 111 setRenderTarget(this);
112 } 112 }
113 113
114 bool CCLayerImpl::descendantDrawsContent() 114 bool LayerImpl::descendantDrawsContent()
115 { 115 {
116 for (size_t i = 0; i < m_children.size(); ++i) { 116 for (size_t i = 0; i < m_children.size(); ++i) {
117 if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsConte nt()) 117 if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsConte nt())
118 return true; 118 return true;
119 } 119 }
120 return false; 120 return false;
121 } 121 }
122 122
123 scoped_ptr<CCSharedQuadState> CCLayerImpl::createSharedQuadState() const 123 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const
124 { 124 {
125 return CCSharedQuadState::create(m_drawTransform, m_visibleContentRect, m_dr awableContentRect, m_drawOpacity, m_contentsOpaque); 125 return SharedQuadState::create(m_drawTransform, m_visibleContentRect, m_draw ableContentRect, m_drawOpacity, m_contentsOpaque);
126 } 126 }
127 127
128 void CCLayerImpl::willDraw(CCResourceProvider*) 128 void LayerImpl::willDraw(ResourceProvider*)
129 { 129 {
130 #ifndef NDEBUG 130 #ifndef NDEBUG
131 // willDraw/didDraw must be matched. 131 // willDraw/didDraw must be matched.
132 ASSERT(!m_betweenWillDrawAndDidDraw); 132 ASSERT(!m_betweenWillDrawAndDidDraw);
133 m_betweenWillDrawAndDidDraw = true; 133 m_betweenWillDrawAndDidDraw = true;
134 #endif 134 #endif
135 } 135 }
136 136
137 void CCLayerImpl::didDraw(CCResourceProvider*) 137 void LayerImpl::didDraw(ResourceProvider*)
138 { 138 {
139 #ifndef NDEBUG 139 #ifndef NDEBUG
140 ASSERT(m_betweenWillDrawAndDidDraw); 140 ASSERT(m_betweenWillDrawAndDidDraw);
141 m_betweenWillDrawAndDidDraw = false; 141 m_betweenWillDrawAndDidDraw = false;
142 #endif 142 #endif
143 } 143 }
144 144
145 void CCLayerImpl::appendDebugBorderQuad(CCQuadSink& quadList, const CCSharedQuad State* sharedQuadState, CCAppendQuadsData& appendQuadsData) const 145 void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState* sharedQuadState, AppendQuadsData& appendQuadsData) const
146 { 146 {
147 if (!hasDebugBorders()) 147 if (!hasDebugBorders())
148 return; 148 return;
149 149
150 IntRect contentRect(IntPoint(), contentBounds()); 150 IntRect contentRect(IntPoint(), contentBounds());
151 quadList.append(CCDebugBorderDrawQuad::create(sharedQuadState, contentRect, debugBorderColor(), debugBorderWidth()).PassAs<CCDrawQuad>(), appendQuadsData); 151 quadList.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect, de bugBorderColor(), debugBorderWidth()).PassAs<DrawQuad>(), appendQuadsData);
152 } 152 }
153 153
154 bool CCLayerImpl::hasContributingDelegatedRenderPasses() const 154 bool LayerImpl::hasContributingDelegatedRenderPasses() const
155 { 155 {
156 return false; 156 return false;
157 } 157 }
158 158
159 CCRenderPass::Id CCLayerImpl::firstContributingRenderPassId() const 159 RenderPass::Id LayerImpl::firstContributingRenderPassId() const
160 { 160 {
161 return CCRenderPass::Id(0, 0); 161 return RenderPass::Id(0, 0);
162 } 162 }
163 163
164 CCRenderPass::Id CCLayerImpl::nextContributingRenderPassId(CCRenderPass::Id) con st 164 RenderPass::Id LayerImpl::nextContributingRenderPassId(RenderPass::Id) const
165 { 165 {
166 return CCRenderPass::Id(0, 0); 166 return RenderPass::Id(0, 0);
167 } 167 }
168 168
169 CCResourceProvider::ResourceId CCLayerImpl::contentsResourceId() const 169 ResourceProvider::ResourceId LayerImpl::contentsResourceId() const
170 { 170 {
171 ASSERT_NOT_REACHED(); 171 ASSERT_NOT_REACHED();
172 return 0; 172 return 0;
173 } 173 }
174 174
175 FloatSize CCLayerImpl::scrollBy(const FloatSize& scroll) 175 FloatSize LayerImpl::scrollBy(const FloatSize& scroll)
176 { 176 {
177 IntSize minDelta = -toSize(m_scrollPosition); 177 IntSize minDelta = -toSize(m_scrollPosition);
178 IntSize maxDelta = m_maxScrollPosition - toSize(m_scrollPosition); 178 IntSize maxDelta = m_maxScrollPosition - toSize(m_scrollPosition);
179 // Clamp newDelta so that position + delta stays within scroll bounds. 179 // Clamp newDelta so that position + delta stays within scroll bounds.
180 FloatSize newDelta = (m_scrollDelta + scroll).expandedTo(minDelta).shrunkTo( maxDelta); 180 FloatSize newDelta = (m_scrollDelta + scroll).expandedTo(minDelta).shrunkTo( maxDelta);
181 FloatSize unscrolled = m_scrollDelta + scroll - newDelta; 181 FloatSize unscrolled = m_scrollDelta + scroll - newDelta;
182 182
183 if (m_scrollDelta == newDelta) 183 if (m_scrollDelta == newDelta)
184 return unscrolled; 184 return unscrolled;
185 185
186 m_scrollDelta = newDelta; 186 m_scrollDelta = newDelta;
187 if (m_scrollbarAnimationController) 187 if (m_scrollbarAnimationController)
188 m_scrollbarAnimationController->updateScrollOffset(this); 188 m_scrollbarAnimationController->updateScrollOffset(this);
189 noteLayerPropertyChangedForSubtree(); 189 noteLayerPropertyChangedForSubtree();
190 190
191 return unscrolled; 191 return unscrolled;
192 } 192 }
193 193
194 CCInputHandlerClient::ScrollStatus CCLayerImpl::tryScroll(const IntPoint& viewpo rtPoint, CCInputHandlerClient::ScrollInputType type) const 194 InputHandlerClient::ScrollStatus LayerImpl::tryScroll(const IntPoint& viewportPo int, InputHandlerClient::ScrollInputType type) const
195 { 195 {
196 if (shouldScrollOnMainThread()) { 196 if (shouldScrollOnMainThread()) {
197 TRACE_EVENT0("cc", "CCLayerImpl::tryScroll: Failed shouldScrollOnMainThr ead"); 197 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed shouldScrollOnMainThrea d");
198 return CCInputHandlerClient::ScrollOnMainThread; 198 return InputHandlerClient::ScrollOnMainThread;
199 } 199 }
200 200
201 if (!screenSpaceTransform().isInvertible()) { 201 if (!screenSpaceTransform().isInvertible()) {
202 TRACE_EVENT0("cc", "CCLayerImpl::tryScroll: Ignored nonInvertibleTransfo rm"); 202 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform ");
203 return CCInputHandlerClient::ScrollIgnored; 203 return InputHandlerClient::ScrollIgnored;
204 } 204 }
205 205
206 if (!nonFastScrollableRegion().isEmpty()) { 206 if (!nonFastScrollableRegion().isEmpty()) {
207 bool clipped = false; 207 bool clipped = false;
208 FloatPoint hitTestPointInLocalSpace = CCMathUtil::projectPoint(screenSpa ceTransform().inverse(), FloatPoint(viewportPoint), clipped); 208 FloatPoint hitTestPointInLocalSpace = MathUtil::projectPoint(screenSpace Transform().inverse(), FloatPoint(viewportPoint), clipped);
209 if (!clipped && nonFastScrollableRegion().contains(flooredIntPoint(hitTe stPointInLocalSpace))) { 209 if (!clipped && nonFastScrollableRegion().contains(flooredIntPoint(hitTe stPointInLocalSpace))) {
210 TRACE_EVENT0("cc", "CCLayerImpl::tryScroll: Failed nonFastScrollable Region"); 210 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRe gion");
211 return CCInputHandlerClient::ScrollOnMainThread; 211 return InputHandlerClient::ScrollOnMainThread;
212 } 212 }
213 } 213 }
214 214
215 if (type == CCInputHandlerClient::Wheel && haveWheelEventHandlers()) { 215 if (type == InputHandlerClient::Wheel && haveWheelEventHandlers()) {
216 TRACE_EVENT0("cc", "CCLayerImpl::tryScroll: Failed wheelEventHandlers"); 216 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed wheelEventHandlers");
217 return CCInputHandlerClient::ScrollOnMainThread; 217 return InputHandlerClient::ScrollOnMainThread;
218 } 218 }
219 219
220 if (!scrollable()) { 220 if (!scrollable()) {
221 TRACE_EVENT0("cc", "CCLayerImpl::tryScroll: Ignored not scrollable"); 221 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable");
222 return CCInputHandlerClient::ScrollIgnored; 222 return InputHandlerClient::ScrollIgnored;
223 } 223 }
224 224
225 return CCInputHandlerClient::ScrollStarted; 225 return InputHandlerClient::ScrollStarted;
226 } 226 }
227 227
228 bool CCLayerImpl::drawCheckerboardForMissingTiles() const 228 bool LayerImpl::drawCheckerboardForMissingTiles() const
229 { 229 {
230 return m_drawCheckerboardForMissingTiles && !CCSettings::backgroundColorInst eadOfCheckerboard(); 230 return m_drawCheckerboardForMissingTiles && !Settings::backgroundColorInstea dOfCheckerboard();
231 } 231 }
232 232
233 IntRect CCLayerImpl::layerRectToContentRect(const WebKit::WebRect& layerRect) 233 IntRect LayerImpl::layerRectToContentRect(const WebKit::WebRect& layerRect)
234 { 234 {
235 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth(); 235 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth();
236 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height(); 236 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height();
237 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight); 237 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight);
238 contentRect.scale(widthScale, heightScale); 238 contentRect.scale(widthScale, heightScale);
239 return enclosingIntRect(contentRect); 239 return enclosingIntRect(contentRect);
240 } 240 }
241 241
242 std::string CCLayerImpl::indentString(int indent) 242 std::string LayerImpl::indentString(int indent)
243 { 243 {
244 std::string str; 244 std::string str;
245 for (int i = 0; i != indent; ++i) 245 for (int i = 0; i != indent; ++i)
246 str.append(" "); 246 str.append(" ");
247 return str; 247 return str;
248 } 248 }
249 249
250 void CCLayerImpl::dumpLayerProperties(std::string* str, int indent) const 250 void LayerImpl::dumpLayerProperties(std::string* str, int indent) const
251 { 251 {
252 std::string indentStr = indentString(indent); 252 std::string indentStr = indentString(indent);
253 str->append(indentStr); 253 str->append(indentStr);
254 base::StringAppendF(str, "layer ID: %d\n", m_layerId); 254 base::StringAppendF(str, "layer ID: %d\n", m_layerId);
255 255
256 str->append(indentStr); 256 str->append(indentStr);
257 base::StringAppendF(str, "bounds: %d, %d\n", bounds().width(), bounds().heig ht()); 257 base::StringAppendF(str, "bounds: %d, %d\n", bounds().width(), bounds().heig ht());
258 258
259 if (m_renderTarget) { 259 if (m_renderTarget) {
260 str->append(indentStr); 260 str->append(indentStr);
261 base::StringAppendF(str, "renderTarget: %d\n", m_renderTarget->m_layerId ); 261 base::StringAppendF(str, "renderTarget: %d\n", m_renderTarget->m_layerId );
262 } 262 }
263 263
264 str->append(indentStr); 264 str->append(indentStr);
265 base::StringAppendF(str, "drawTransform: %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f\n", 265 base::StringAppendF(str, "drawTransform: %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f\n",
266 m_drawTransform.m11(), m_drawTransform.m12(), m_drawTransform.m13(), m_d rawTransform.m14(), 266 m_drawTransform.m11(), m_drawTransform.m12(), m_drawTransform.m13(), m_d rawTransform.m14(),
267 m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_d rawTransform.m24(), 267 m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_d rawTransform.m24(),
268 m_drawTransform.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_d rawTransform.m34(), 268 m_drawTransform.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_d rawTransform.m34(),
269 m_drawTransform.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_d rawTransform.m44()); 269 m_drawTransform.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_d rawTransform.m44());
270 270
271 str->append(indentStr); 271 str->append(indentStr);
272 base::StringAppendF(str, "drawsContent: %s\n", m_drawsContent ? "yes" : "no" ); 272 base::StringAppendF(str, "drawsContent: %s\n", m_drawsContent ? "yes" : "no" );
273 } 273 }
274 274
275 void sortLayers(std::vector<CCLayerImpl*>::iterator first, std::vector<CCLayerIm pl*>::iterator end, CCLayerSorter* layerSorter) 275 void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<LayerImpl*> ::iterator end, LayerSorter* layerSorter)
276 { 276 {
277 TRACE_EVENT0("cc", "CCLayerImpl::sortLayers"); 277 TRACE_EVENT0("cc", "LayerImpl::sortLayers");
278 layerSorter->sort(first, end); 278 layerSorter->sort(first, end);
279 } 279 }
280 280
281 std::string CCLayerImpl::layerTreeAsText() const 281 std::string LayerImpl::layerTreeAsText() const
282 { 282 {
283 std::string str; 283 std::string str;
284 dumpLayer(&str, 0); 284 dumpLayer(&str, 0);
285 return str; 285 return str;
286 } 286 }
287 287
288 void CCLayerImpl::dumpLayer(std::string* str, int indent) const 288 void LayerImpl::dumpLayer(std::string* str, int indent) const
289 { 289 {
290 str->append(indentString(indent)); 290 str->append(indentString(indent));
291 base::StringAppendF(str, "%s(%s)\n", layerTypeAsString(), m_debugName.data() ); 291 base::StringAppendF(str, "%s(%s)\n", layerTypeAsString(), m_debugName.data() );
292 dumpLayerProperties(str, indent+2); 292 dumpLayerProperties(str, indent+2);
293 if (m_replicaLayer) { 293 if (m_replicaLayer) {
294 str->append(indentString(indent+2)); 294 str->append(indentString(indent+2));
295 str->append("Replica:\n"); 295 str->append("Replica:\n");
296 m_replicaLayer->dumpLayer(str, indent+3); 296 m_replicaLayer->dumpLayer(str, indent+3);
297 } 297 }
298 if (m_maskLayer) { 298 if (m_maskLayer) {
299 str->append(indentString(indent+2)); 299 str->append(indentString(indent+2));
300 str->append("Mask:\n"); 300 str->append("Mask:\n");
301 m_maskLayer->dumpLayer(str, indent+3); 301 m_maskLayer->dumpLayer(str, indent+3);
302 } 302 }
303 for (size_t i = 0; i < m_children.size(); ++i) 303 for (size_t i = 0; i < m_children.size(); ++i)
304 m_children[i]->dumpLayer(str, indent+1); 304 m_children[i]->dumpLayer(str, indent+1);
305 } 305 }
306 306
307 void CCLayerImpl::setStackingOrderChanged(bool stackingOrderChanged) 307 void LayerImpl::setStackingOrderChanged(bool stackingOrderChanged)
308 { 308 {
309 // We don't need to store this flag; we only need to track that the change o ccurred. 309 // We don't need to store this flag; we only need to track that the change o ccurred.
310 if (stackingOrderChanged) 310 if (stackingOrderChanged)
311 noteLayerPropertyChangedForSubtree(); 311 noteLayerPropertyChangedForSubtree();
312 } 312 }
313 313
314 bool CCLayerImpl::layerSurfacePropertyChanged() const 314 bool LayerImpl::layerSurfacePropertyChanged() const
315 { 315 {
316 if (m_layerSurfacePropertyChanged) 316 if (m_layerSurfacePropertyChanged)
317 return true; 317 return true;
318 318
319 // If this layer's surface property hasn't changed, we want to see if 319 // If this layer's surface property hasn't changed, we want to see if
320 // some layer above us has changed this property. This is done for the 320 // some layer above us has changed this property. This is done for the
321 // case when such parent layer does not draw content, and therefore will 321 // case when such parent layer does not draw content, and therefore will
322 // not be traversed by the damage tracker. We need to make sure that 322 // not be traversed by the damage tracker. We need to make sure that
323 // property change on such layer will be caught by its descendants. 323 // property change on such layer will be caught by its descendants.
324 CCLayerImpl* current = this->m_parent; 324 LayerImpl* current = this->m_parent;
325 while (current && !current->m_renderSurface) { 325 while (current && !current->m_renderSurface) {
326 if (current->m_layerSurfacePropertyChanged) 326 if (current->m_layerSurfacePropertyChanged)
327 return true; 327 return true;
328 current = current->m_parent; 328 current = current->m_parent;
329 } 329 }
330 330
331 return false; 331 return false;
332 } 332 }
333 333
334 void CCLayerImpl::noteLayerPropertyChangedForSubtree() 334 void LayerImpl::noteLayerPropertyChangedForSubtree()
335 { 335 {
336 m_layerPropertyChanged = true; 336 m_layerPropertyChanged = true;
337 noteLayerPropertyChangedForDescendants(); 337 noteLayerPropertyChangedForDescendants();
338 } 338 }
339 339
340 void CCLayerImpl::noteLayerPropertyChangedForDescendants() 340 void LayerImpl::noteLayerPropertyChangedForDescendants()
341 { 341 {
342 for (size_t i = 0; i < m_children.size(); ++i) 342 for (size_t i = 0; i < m_children.size(); ++i)
343 m_children[i]->noteLayerPropertyChangedForSubtree(); 343 m_children[i]->noteLayerPropertyChangedForSubtree();
344 } 344 }
345 345
346 const char* CCLayerImpl::layerTypeAsString() const 346 const char* LayerImpl::layerTypeAsString() const
347 { 347 {
348 return "LayerChromium"; 348 return "Layer";
349 } 349 }
350 350
351 void CCLayerImpl::resetAllChangeTrackingForSubtree() 351 void LayerImpl::resetAllChangeTrackingForSubtree()
352 { 352 {
353 m_layerPropertyChanged = false; 353 m_layerPropertyChanged = false;
354 m_layerSurfacePropertyChanged = false; 354 m_layerSurfacePropertyChanged = false;
355 355
356 m_updateRect = FloatRect(); 356 m_updateRect = FloatRect();
357 357
358 if (m_renderSurface) 358 if (m_renderSurface)
359 m_renderSurface->resetPropertyChangedFlag(); 359 m_renderSurface->resetPropertyChangedFlag();
360 360
361 if (m_maskLayer) 361 if (m_maskLayer)
362 m_maskLayer->resetAllChangeTrackingForSubtree(); 362 m_maskLayer->resetAllChangeTrackingForSubtree();
363 363
364 if (m_replicaLayer) 364 if (m_replicaLayer)
365 m_replicaLayer->resetAllChangeTrackingForSubtree(); // also resets the r eplica mask, if it exists. 365 m_replicaLayer->resetAllChangeTrackingForSubtree(); // also resets the r eplica mask, if it exists.
366 366
367 for (size_t i = 0; i < m_children.size(); ++i) 367 for (size_t i = 0; i < m_children.size(); ++i)
368 m_children[i]->resetAllChangeTrackingForSubtree(); 368 m_children[i]->resetAllChangeTrackingForSubtree();
369 } 369 }
370 370
371 bool CCLayerImpl::layerIsAlwaysDamaged() const 371 bool LayerImpl::layerIsAlwaysDamaged() const
372 { 372 {
373 return false; 373 return false;
374 } 374 }
375 375
376 int CCLayerImpl::id() const 376 int LayerImpl::id() const
377 { 377 {
378 return m_layerId; 378 return m_layerId;
379 } 379 }
380 380
381 float CCLayerImpl::opacity() const 381 float LayerImpl::opacity() const
382 { 382 {
383 return m_opacity; 383 return m_opacity;
384 } 384 }
385 385
386 void CCLayerImpl::setOpacityFromAnimation(float opacity) 386 void LayerImpl::setOpacityFromAnimation(float opacity)
387 { 387 {
388 setOpacity(opacity); 388 setOpacity(opacity);
389 } 389 }
390 390
391 const WebKit::WebTransformationMatrix& CCLayerImpl::transform() const 391 const WebKit::WebTransformationMatrix& LayerImpl::transform() const
392 { 392 {
393 return m_transform; 393 return m_transform;
394 } 394 }
395 395
396 void CCLayerImpl::setTransformFromAnimation(const WebTransformationMatrix& trans form) 396 void LayerImpl::setTransformFromAnimation(const WebTransformationMatrix& transfo rm)
397 { 397 {
398 setTransform(transform); 398 setTransform(transform);
399 } 399 }
400 400
401 void CCLayerImpl::setBounds(const IntSize& bounds) 401 void LayerImpl::setBounds(const IntSize& bounds)
402 { 402 {
403 if (m_bounds == bounds) 403 if (m_bounds == bounds)
404 return; 404 return;
405 405
406 m_bounds = bounds; 406 m_bounds = bounds;
407 407
408 if (masksToBounds()) 408 if (masksToBounds())
409 noteLayerPropertyChangedForSubtree(); 409 noteLayerPropertyChangedForSubtree();
410 else 410 else
411 m_layerPropertyChanged = true; 411 m_layerPropertyChanged = true;
412 } 412 }
413 413
414 void CCLayerImpl::setMaskLayer(scoped_ptr<CCLayerImpl> maskLayer) 414 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer)
415 { 415 {
416 m_maskLayer = maskLayer.Pass(); 416 m_maskLayer = maskLayer.Pass();
417 417
418 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; 418 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
419 if (newLayerId == m_maskLayerId) 419 if (newLayerId == m_maskLayerId)
420 return; 420 return;
421 421
422 m_maskLayerId = newLayerId; 422 m_maskLayerId = newLayerId;
423 noteLayerPropertyChangedForSubtree(); 423 noteLayerPropertyChangedForSubtree();
424 } 424 }
425 425
426 void CCLayerImpl::setReplicaLayer(scoped_ptr<CCLayerImpl> replicaLayer) 426 void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer)
427 { 427 {
428 m_replicaLayer = replicaLayer.Pass(); 428 m_replicaLayer = replicaLayer.Pass();
429 429
430 int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1; 430 int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1;
431 if (newLayerId == m_replicaLayerId) 431 if (newLayerId == m_replicaLayerId)
432 return; 432 return;
433 433
434 m_replicaLayerId = newLayerId; 434 m_replicaLayerId = newLayerId;
435 noteLayerPropertyChangedForSubtree(); 435 noteLayerPropertyChangedForSubtree();
436 } 436 }
437 437
438 void CCLayerImpl::setDrawsContent(bool drawsContent) 438 void LayerImpl::setDrawsContent(bool drawsContent)
439 { 439 {
440 if (m_drawsContent == drawsContent) 440 if (m_drawsContent == drawsContent)
441 return; 441 return;
442 442
443 m_drawsContent = drawsContent; 443 m_drawsContent = drawsContent;
444 m_layerPropertyChanged = true; 444 m_layerPropertyChanged = true;
445 } 445 }
446 446
447 void CCLayerImpl::setAnchorPoint(const FloatPoint& anchorPoint) 447 void LayerImpl::setAnchorPoint(const FloatPoint& anchorPoint)
448 { 448 {
449 if (m_anchorPoint == anchorPoint) 449 if (m_anchorPoint == anchorPoint)
450 return; 450 return;
451 451
452 m_anchorPoint = anchorPoint; 452 m_anchorPoint = anchorPoint;
453 noteLayerPropertyChangedForSubtree(); 453 noteLayerPropertyChangedForSubtree();
454 } 454 }
455 455
456 void CCLayerImpl::setAnchorPointZ(float anchorPointZ) 456 void LayerImpl::setAnchorPointZ(float anchorPointZ)
457 { 457 {
458 if (m_anchorPointZ == anchorPointZ) 458 if (m_anchorPointZ == anchorPointZ)
459 return; 459 return;
460 460
461 m_anchorPointZ = anchorPointZ; 461 m_anchorPointZ = anchorPointZ;
462 noteLayerPropertyChangedForSubtree(); 462 noteLayerPropertyChangedForSubtree();
463 } 463 }
464 464
465 void CCLayerImpl::setBackgroundColor(SkColor backgroundColor) 465 void LayerImpl::setBackgroundColor(SkColor backgroundColor)
466 { 466 {
467 if (m_backgroundColor == backgroundColor) 467 if (m_backgroundColor == backgroundColor)
468 return; 468 return;
469 469
470 m_backgroundColor = backgroundColor; 470 m_backgroundColor = backgroundColor;
471 m_layerPropertyChanged = true; 471 m_layerPropertyChanged = true;
472 } 472 }
473 473
474 void CCLayerImpl::setFilters(const WebKit::WebFilterOperations& filters) 474 void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters)
475 { 475 {
476 if (m_filters == filters) 476 if (m_filters == filters)
477 return; 477 return;
478 478
479 m_filters = filters; 479 m_filters = filters;
480 noteLayerPropertyChangedForSubtree(); 480 noteLayerPropertyChangedForSubtree();
481 } 481 }
482 482
483 void CCLayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgr oundFilters) 483 void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgrou ndFilters)
484 { 484 {
485 if (m_backgroundFilters == backgroundFilters) 485 if (m_backgroundFilters == backgroundFilters)
486 return; 486 return;
487 487
488 m_backgroundFilters = backgroundFilters; 488 m_backgroundFilters = backgroundFilters;
489 m_layerPropertyChanged = true; 489 m_layerPropertyChanged = true;
490 } 490 }
491 491
492 void CCLayerImpl::setMasksToBounds(bool masksToBounds) 492 void LayerImpl::setMasksToBounds(bool masksToBounds)
493 { 493 {
494 if (m_masksToBounds == masksToBounds) 494 if (m_masksToBounds == masksToBounds)
495 return; 495 return;
496 496
497 m_masksToBounds = masksToBounds; 497 m_masksToBounds = masksToBounds;
498 noteLayerPropertyChangedForSubtree(); 498 noteLayerPropertyChangedForSubtree();
499 } 499 }
500 500
501 void CCLayerImpl::setContentsOpaque(bool opaque) 501 void LayerImpl::setContentsOpaque(bool opaque)
502 { 502 {
503 if (m_contentsOpaque == opaque) 503 if (m_contentsOpaque == opaque)
504 return; 504 return;
505 505
506 m_contentsOpaque = opaque; 506 m_contentsOpaque = opaque;
507 noteLayerPropertyChangedForSubtree(); 507 noteLayerPropertyChangedForSubtree();
508 } 508 }
509 509
510 void CCLayerImpl::setOpacity(float opacity) 510 void LayerImpl::setOpacity(float opacity)
511 { 511 {
512 if (m_opacity == opacity) 512 if (m_opacity == opacity)
513 return; 513 return;
514 514
515 m_opacity = opacity; 515 m_opacity = opacity;
516 m_layerSurfacePropertyChanged = true; 516 m_layerSurfacePropertyChanged = true;
517 } 517 }
518 518
519 bool CCLayerImpl::opacityIsAnimating() const 519 bool LayerImpl::opacityIsAnimating() const
520 { 520 {
521 return m_layerAnimationController->isAnimatingProperty(CCActiveAnimation::Op acity); 521 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac ity);
522 } 522 }
523 523
524 void CCLayerImpl::setPosition(const FloatPoint& position) 524 void LayerImpl::setPosition(const FloatPoint& position)
525 { 525 {
526 if (m_position == position) 526 if (m_position == position)
527 return; 527 return;
528 528
529 m_position = position; 529 m_position = position;
530 noteLayerPropertyChangedForSubtree(); 530 noteLayerPropertyChangedForSubtree();
531 } 531 }
532 532
533 void CCLayerImpl::setPreserves3D(bool preserves3D) 533 void LayerImpl::setPreserves3D(bool preserves3D)
534 { 534 {
535 if (m_preserves3D == preserves3D) 535 if (m_preserves3D == preserves3D)
536 return; 536 return;
537 537
538 m_preserves3D = preserves3D; 538 m_preserves3D = preserves3D;
539 noteLayerPropertyChangedForSubtree(); 539 noteLayerPropertyChangedForSubtree();
540 } 540 }
541 541
542 void CCLayerImpl::setSublayerTransform(const WebTransformationMatrix& sublayerTr ansform) 542 void LayerImpl::setSublayerTransform(const WebTransformationMatrix& sublayerTran sform)
543 { 543 {
544 if (m_sublayerTransform == sublayerTransform) 544 if (m_sublayerTransform == sublayerTransform)
545 return; 545 return;
546 546
547 m_sublayerTransform = sublayerTransform; 547 m_sublayerTransform = sublayerTransform;
548 // sublayer transform does not affect the current layer; it affects only its children. 548 // sublayer transform does not affect the current layer; it affects only its children.
549 noteLayerPropertyChangedForDescendants(); 549 noteLayerPropertyChangedForDescendants();
550 } 550 }
551 551
552 void CCLayerImpl::setTransform(const WebTransformationMatrix& transform) 552 void LayerImpl::setTransform(const WebTransformationMatrix& transform)
553 { 553 {
554 if (m_transform == transform) 554 if (m_transform == transform)
555 return; 555 return;
556 556
557 m_transform = transform; 557 m_transform = transform;
558 m_layerSurfacePropertyChanged = true; 558 m_layerSurfacePropertyChanged = true;
559 } 559 }
560 560
561 bool CCLayerImpl::transformIsAnimating() const 561 bool LayerImpl::transformIsAnimating() const
562 { 562 {
563 return m_layerAnimationController->isAnimatingProperty(CCActiveAnimation::Tr ansform); 563 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform);
564 } 564 }
565 565
566 void CCLayerImpl::setDebugBorderColor(SkColor debugBorderColor) 566 void LayerImpl::setDebugBorderColor(SkColor debugBorderColor)
567 { 567 {
568 if (m_debugBorderColor == debugBorderColor) 568 if (m_debugBorderColor == debugBorderColor)
569 return; 569 return;
570 570
571 m_debugBorderColor = debugBorderColor; 571 m_debugBorderColor = debugBorderColor;
572 m_layerPropertyChanged = true; 572 m_layerPropertyChanged = true;
573 } 573 }
574 574
575 void CCLayerImpl::setDebugBorderWidth(float debugBorderWidth) 575 void LayerImpl::setDebugBorderWidth(float debugBorderWidth)
576 { 576 {
577 if (m_debugBorderWidth == debugBorderWidth) 577 if (m_debugBorderWidth == debugBorderWidth)
578 return; 578 return;
579 579
580 m_debugBorderWidth = debugBorderWidth; 580 m_debugBorderWidth = debugBorderWidth;
581 m_layerPropertyChanged = true; 581 m_layerPropertyChanged = true;
582 } 582 }
583 583
584 bool CCLayerImpl::hasDebugBorders() const 584 bool LayerImpl::hasDebugBorders() const
585 { 585 {
586 return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0; 586 return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0;
587 } 587 }
588 588
589 void CCLayerImpl::setContentBounds(const IntSize& contentBounds) 589 void LayerImpl::setContentBounds(const IntSize& contentBounds)
590 { 590 {
591 if (m_contentBounds == contentBounds) 591 if (m_contentBounds == contentBounds)
592 return; 592 return;
593 593
594 m_contentBounds = contentBounds; 594 m_contentBounds = contentBounds;
595 m_layerPropertyChanged = true; 595 m_layerPropertyChanged = true;
596 } 596 }
597 597
598 void CCLayerImpl::setScrollPosition(const IntPoint& scrollPosition) 598 void LayerImpl::setScrollPosition(const IntPoint& scrollPosition)
599 { 599 {
600 if (m_scrollPosition == scrollPosition) 600 if (m_scrollPosition == scrollPosition)
601 return; 601 return;
602 602
603 m_scrollPosition = scrollPosition; 603 m_scrollPosition = scrollPosition;
604 noteLayerPropertyChangedForSubtree(); 604 noteLayerPropertyChangedForSubtree();
605 } 605 }
606 606
607 void CCLayerImpl::setScrollDelta(const FloatSize& scrollDelta) 607 void LayerImpl::setScrollDelta(const FloatSize& scrollDelta)
608 { 608 {
609 if (m_scrollDelta == scrollDelta) 609 if (m_scrollDelta == scrollDelta)
610 return; 610 return;
611 611
612 m_scrollDelta = scrollDelta; 612 m_scrollDelta = scrollDelta;
613 noteLayerPropertyChangedForSubtree(); 613 noteLayerPropertyChangedForSubtree();
614 } 614 }
615 615
616 void CCLayerImpl::setImplTransform(const WebKit::WebTransformationMatrix& transf orm) 616 void LayerImpl::setImplTransform(const WebKit::WebTransformationMatrix& transfor m)
617 { 617 {
618 if (m_implTransform == transform) 618 if (m_implTransform == transform)
619 return; 619 return;
620 620
621 m_implTransform = transform; 621 m_implTransform = transform;
622 noteLayerPropertyChangedForSubtree(); 622 noteLayerPropertyChangedForSubtree();
623 } 623 }
624 624
625 void CCLayerImpl::setDoubleSided(bool doubleSided) 625 void LayerImpl::setDoubleSided(bool doubleSided)
626 { 626 {
627 if (m_doubleSided == doubleSided) 627 if (m_doubleSided == doubleSided)
628 return; 628 return;
629 629
630 m_doubleSided = doubleSided; 630 m_doubleSided = doubleSided;
631 noteLayerPropertyChangedForSubtree(); 631 noteLayerPropertyChangedForSubtree();
632 } 632 }
633 633
634 Region CCLayerImpl::visibleContentOpaqueRegion() const 634 Region LayerImpl::visibleContentOpaqueRegion() const
635 { 635 {
636 if (contentsOpaque()) 636 if (contentsOpaque())
637 return visibleContentRect(); 637 return visibleContentRect();
638 return Region(); 638 return Region();
639 } 639 }
640 640
641 void CCLayerImpl::didLoseContext() 641 void LayerImpl::didLoseContext()
642 { 642 {
643 } 643 }
644 644
645 void CCLayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition) 645 void LayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition)
646 { 646 {
647 m_maxScrollPosition = maxScrollPosition; 647 m_maxScrollPosition = maxScrollPosition;
648 648
649 if (!m_scrollbarAnimationController) 649 if (!m_scrollbarAnimationController)
650 return; 650 return;
651 m_scrollbarAnimationController->updateScrollOffset(this); 651 m_scrollbarAnimationController->updateScrollOffset(this);
652 } 652 }
653 653
654 CCScrollbarLayerImpl* CCLayerImpl::horizontalScrollbarLayer() const 654 ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer() const
655 { 655 {
656 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori zontalScrollbarLayer() : 0; 656 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori zontalScrollbarLayer() : 0;
657 } 657 }
658 658
659 void CCLayerImpl::setHorizontalScrollbarLayer(CCScrollbarLayerImpl* scrollbarLay er) 659 void LayerImpl::setHorizontalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
660 { 660 {
661 if (!m_scrollbarAnimationController) 661 if (!m_scrollbarAnimationController)
662 m_scrollbarAnimationController = CCScrollbarAnimationController::create( this); 662 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
663 m_scrollbarAnimationController->setHorizontalScrollbarLayer(scrollbarLayer); 663 m_scrollbarAnimationController->setHorizontalScrollbarLayer(scrollbarLayer);
664 m_scrollbarAnimationController->updateScrollOffset(this); 664 m_scrollbarAnimationController->updateScrollOffset(this);
665 } 665 }
666 666
667 CCScrollbarLayerImpl* CCLayerImpl::verticalScrollbarLayer() const 667 ScrollbarLayerImpl* LayerImpl::verticalScrollbarLayer() const
668 { 668 {
669 return m_scrollbarAnimationController ? m_scrollbarAnimationController->vert icalScrollbarLayer() : 0; 669 return m_scrollbarAnimationController ? m_scrollbarAnimationController->vert icalScrollbarLayer() : 0;
670 } 670 }
671 671
672 void CCLayerImpl::setVerticalScrollbarLayer(CCScrollbarLayerImpl* scrollbarLayer ) 672 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
673 { 673 {
674 if (!m_scrollbarAnimationController) 674 if (!m_scrollbarAnimationController)
675 m_scrollbarAnimationController = CCScrollbarAnimationController::create( this); 675 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
676 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 676 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
677 m_scrollbarAnimationController->updateScrollOffset(this); 677 m_scrollbarAnimationController->updateScrollOffset(this);
678 } 678 }
679 679
680 } 680 }
OLDNEW
« cc/active_animation.h ('K') | « 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