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

Side by Side Diff: cc/layer.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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/layer.h" 7 #include "cc/layer.h"
8 8
9 #include "CCActiveAnimation.h" 9 #include "CCActiveAnimation.h"
10 #include "CCAnimationEvents.h" 10 #include "CCAnimationEvents.h"
11 #include "CCLayerAnimationController.h" 11 #include "CCLayerAnimationController.h"
12 #include "CCLayerImpl.h" 12 #include "CCLayerImpl.h"
13 #include "CCLayerTreeHost.h" 13 #include "CCLayerTreeHost.h"
14 #include "CCSettings.h" 14 #include "CCSettings.h"
15 #include <public/WebAnimationDelegate.h> 15 #include <public/WebAnimationDelegate.h>
16 #include <public/WebLayerScrollClient.h> 16 #include <public/WebLayerScrollClient.h>
17 #include <public/WebSize.h> 17 #include <public/WebSize.h>
18 18
19 using namespace std; 19 using namespace std;
20 using WebKit::WebTransformationMatrix; 20 using WebKit::WebTransformationMatrix;
21 21
22 namespace cc { 22 namespace cc {
23 23
24 static int s_nextLayerId = 1; 24 static int s_nextLayerId = 1;
25 25
26 scoped_refptr<LayerChromium> LayerChromium::create() 26 scoped_refptr<Layer> Layer::create()
27 { 27 {
28 return make_scoped_refptr(new LayerChromium()); 28 return make_scoped_refptr(new Layer());
29 } 29 }
30 30
31 LayerChromium::LayerChromium() 31 Layer::Layer()
32 : m_needsDisplay(false) 32 : m_needsDisplay(false)
33 , m_stackingOrderChanged(false) 33 , m_stackingOrderChanged(false)
34 , m_layerId(s_nextLayerId++) 34 , m_layerId(s_nextLayerId++)
35 , m_parent(0) 35 , m_parent(0)
36 , m_layerTreeHost(0) 36 , m_layerTreeHost(0)
37 , m_layerAnimationController(CCLayerAnimationController::create(this)) 37 , m_layerAnimationController(LayerAnimationController::create(this))
38 , m_scrollable(false) 38 , m_scrollable(false)
39 , m_shouldScrollOnMainThread(false) 39 , m_shouldScrollOnMainThread(false)
40 , m_haveWheelEventHandlers(false) 40 , m_haveWheelEventHandlers(false)
41 , m_nonFastScrollableRegionChanged(false) 41 , m_nonFastScrollableRegionChanged(false)
42 , m_anchorPoint(0.5, 0.5) 42 , m_anchorPoint(0.5, 0.5)
43 , m_backgroundColor(0) 43 , m_backgroundColor(0)
44 , m_debugBorderColor(0) 44 , m_debugBorderColor(0)
45 , m_debugBorderWidth(0) 45 , m_debugBorderWidth(0)
46 , m_opacity(1.0) 46 , m_opacity(1.0)
47 , m_anchorPointZ(0) 47 , m_anchorPointZ(0)
(...skipping 18 matching lines...) Expand all
66 , m_boundsContainPageScale(false) 66 , m_boundsContainPageScale(false)
67 , m_layerAnimationDelegate(0) 67 , m_layerAnimationDelegate(0)
68 , m_layerScrollClient(0) 68 , m_layerScrollClient(0)
69 { 69 {
70 if (m_layerId < 0) { 70 if (m_layerId < 0) {
71 s_nextLayerId = 1; 71 s_nextLayerId = 1;
72 m_layerId = s_nextLayerId++; 72 m_layerId = s_nextLayerId++;
73 } 73 }
74 } 74 }
75 75
76 LayerChromium::~LayerChromium() 76 Layer::~Layer()
77 { 77 {
78 // Our parent should be holding a reference to us so there should be no 78 // Our parent should be holding a reference to us so there should be no
79 // way for us to be destroyed while we still have a parent. 79 // way for us to be destroyed while we still have a parent.
80 ASSERT(!parent()); 80 ASSERT(!parent());
81 81
82 // Remove the parent reference from all children. 82 // Remove the parent reference from all children.
83 removeAllChildren(); 83 removeAllChildren();
84 } 84 }
85 85
86 void LayerChromium::setUseLCDText(bool useLCDText) 86 void Layer::setUseLCDText(bool useLCDText)
87 { 87 {
88 m_useLCDText = useLCDText; 88 m_useLCDText = useLCDText;
89 } 89 }
90 90
91 void LayerChromium::setLayerTreeHost(CCLayerTreeHost* host) 91 void Layer::setLayerTreeHost(LayerTreeHost* host)
92 { 92 {
93 if (m_layerTreeHost == host) 93 if (m_layerTreeHost == host)
94 return; 94 return;
95 95
96 m_layerTreeHost = host; 96 m_layerTreeHost = host;
97 97
98 for (size_t i = 0; i < m_children.size(); ++i) 98 for (size_t i = 0; i < m_children.size(); ++i)
99 m_children[i]->setLayerTreeHost(host); 99 m_children[i]->setLayerTreeHost(host);
100 100
101 if (m_maskLayer) 101 if (m_maskLayer)
102 m_maskLayer->setLayerTreeHost(host); 102 m_maskLayer->setLayerTreeHost(host);
103 if (m_replicaLayer) 103 if (m_replicaLayer)
104 m_replicaLayer->setLayerTreeHost(host); 104 m_replicaLayer->setLayerTreeHost(host);
105 105
106 // If this layer already has active animations, the host needs to be notifie d. 106 // If this layer already has active animations, the host needs to be notifie d.
107 if (host && m_layerAnimationController->hasActiveAnimation()) 107 if (host && m_layerAnimationController->hasActiveAnimation())
108 host->didAddAnimation(); 108 host->didAddAnimation();
109 } 109 }
110 110
111 void LayerChromium::setNeedsCommit() 111 void Layer::setNeedsCommit()
112 { 112 {
113 if (m_layerTreeHost) 113 if (m_layerTreeHost)
114 m_layerTreeHost->setNeedsCommit(); 114 m_layerTreeHost->setNeedsCommit();
115 } 115 }
116 116
117 IntRect LayerChromium::layerRectToContentRect(const WebKit::WebRect& layerRect) 117 IntRect Layer::layerRectToContentRect(const WebKit::WebRect& layerRect)
118 { 118 {
119 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth(); 119 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth();
120 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height(); 120 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height();
121 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight); 121 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight);
122 contentRect.scale(widthScale, heightScale); 122 contentRect.scale(widthScale, heightScale);
123 return enclosingIntRect(contentRect); 123 return enclosingIntRect(contentRect);
124 } 124 }
125 125
126 void LayerChromium::setParent(LayerChromium* layer) 126 void Layer::setParent(Layer* layer)
127 { 127 {
128 ASSERT(!layer || !layer->hasAncestor(this)); 128 ASSERT(!layer || !layer->hasAncestor(this));
129 m_parent = layer; 129 m_parent = layer;
130 setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0); 130 setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0);
131 } 131 }
132 132
133 bool LayerChromium::hasAncestor(LayerChromium* ancestor) const 133 bool Layer::hasAncestor(Layer* ancestor) const
134 { 134 {
135 for (LayerChromium* layer = parent(); layer; layer = layer->parent()) { 135 for (Layer* layer = parent(); layer; layer = layer->parent()) {
136 if (layer == ancestor) 136 if (layer == ancestor)
137 return true; 137 return true;
138 } 138 }
139 return false; 139 return false;
140 } 140 }
141 141
142 void LayerChromium::addChild(scoped_refptr<LayerChromium> child) 142 void Layer::addChild(scoped_refptr<Layer> child)
143 { 143 {
144 insertChild(child, numChildren()); 144 insertChild(child, numChildren());
145 } 145 }
146 146
147 void LayerChromium::insertChild(scoped_refptr<LayerChromium> child, size_t index ) 147 void Layer::insertChild(scoped_refptr<Layer> child, size_t index)
148 { 148 {
149 index = min(index, m_children.size()); 149 index = min(index, m_children.size());
150 child->removeFromParent(); 150 child->removeFromParent();
151 child->setParent(this); 151 child->setParent(this);
152 child->m_stackingOrderChanged = true; 152 child->m_stackingOrderChanged = true;
153 153
154 LayerList::iterator iter = m_children.begin(); 154 LayerList::iterator iter = m_children.begin();
155 m_children.insert(iter + index, child); 155 m_children.insert(iter + index, child);
156 setNeedsCommit(); 156 setNeedsCommit();
157 } 157 }
158 158
159 void LayerChromium::removeFromParent() 159 void Layer::removeFromParent()
160 { 160 {
161 if (m_parent) 161 if (m_parent)
162 m_parent->removeChild(this); 162 m_parent->removeChild(this);
163 } 163 }
164 164
165 void LayerChromium::removeChild(LayerChromium* child) 165 void Layer::removeChild(Layer* child)
166 { 166 {
167 for (LayerList::iterator iter = m_children.begin(); iter != m_children.end() ; ++iter) 167 for (LayerList::iterator iter = m_children.begin(); iter != m_children.end() ; ++iter)
168 { 168 {
169 if (*iter != child) 169 if (*iter != child)
170 continue; 170 continue;
171 171
172 child->setParent(0); 172 child->setParent(0);
173 m_children.erase(iter); 173 m_children.erase(iter);
174 setNeedsCommit(); 174 setNeedsCommit();
175 return; 175 return;
176 } 176 }
177 } 177 }
178 178
179 void LayerChromium::replaceChild(LayerChromium* reference, scoped_refptr<LayerCh romium> newLayer) 179 void Layer::replaceChild(Layer* reference, scoped_refptr<Layer> newLayer)
180 { 180 {
181 ASSERT_ARG(reference, reference); 181 ASSERT_ARG(reference, reference);
182 ASSERT_ARG(reference, reference->parent() == this); 182 ASSERT_ARG(reference, reference->parent() == this);
183 183
184 if (reference == newLayer) 184 if (reference == newLayer)
185 return; 185 return;
186 186
187 int referenceIndex = indexOfChild(reference); 187 int referenceIndex = indexOfChild(reference);
188 if (referenceIndex == -1) { 188 if (referenceIndex == -1) {
189 ASSERT_NOT_REACHED(); 189 ASSERT_NOT_REACHED();
190 return; 190 return;
191 } 191 }
192 192
193 reference->removeFromParent(); 193 reference->removeFromParent();
194 194
195 if (newLayer) { 195 if (newLayer) {
196 newLayer->removeFromParent(); 196 newLayer->removeFromParent();
197 insertChild(newLayer, referenceIndex); 197 insertChild(newLayer, referenceIndex);
198 } 198 }
199 } 199 }
200 200
201 int LayerChromium::indexOfChild(const LayerChromium* reference) 201 int Layer::indexOfChild(const Layer* reference)
202 { 202 {
203 for (size_t i = 0; i < m_children.size(); i++) { 203 for (size_t i = 0; i < m_children.size(); i++) {
204 if (m_children[i] == reference) 204 if (m_children[i] == reference)
205 return i; 205 return i;
206 } 206 }
207 return -1; 207 return -1;
208 } 208 }
209 209
210 void LayerChromium::setBounds(const IntSize& size) 210 void Layer::setBounds(const IntSize& size)
211 { 211 {
212 if (bounds() == size) 212 if (bounds() == size)
213 return; 213 return;
214 214
215 bool firstResize = bounds().isEmpty() && !size.isEmpty(); 215 bool firstResize = bounds().isEmpty() && !size.isEmpty();
216 216
217 m_bounds = size; 217 m_bounds = size;
218 218
219 if (firstResize) 219 if (firstResize)
220 setNeedsDisplay(); 220 setNeedsDisplay();
221 else 221 else
222 setNeedsCommit(); 222 setNeedsCommit();
223 } 223 }
224 224
225 LayerChromium* LayerChromium::rootLayer() 225 Layer* Layer::rootLayer()
226 { 226 {
227 LayerChromium* layer = this; 227 Layer* layer = this;
228 while (layer->parent()) 228 while (layer->parent())
229 layer = layer->parent(); 229 layer = layer->parent();
230 return layer; 230 return layer;
231 } 231 }
232 232
233 void LayerChromium::removeAllChildren() 233 void Layer::removeAllChildren()
234 { 234 {
235 while (m_children.size()) { 235 while (m_children.size()) {
236 LayerChromium* layer = m_children[0].get(); 236 Layer* layer = m_children[0].get();
237 ASSERT(layer->parent()); 237 ASSERT(layer->parent());
238 layer->removeFromParent(); 238 layer->removeFromParent();
239 } 239 }
240 } 240 }
241 241
242 void LayerChromium::setChildren(const LayerList& children) 242 void Layer::setChildren(const LayerList& children)
243 { 243 {
244 if (children == m_children) 244 if (children == m_children)
245 return; 245 return;
246 246
247 removeAllChildren(); 247 removeAllChildren();
248 size_t listSize = children.size(); 248 size_t listSize = children.size();
249 for (size_t i = 0; i < listSize; i++) 249 for (size_t i = 0; i < listSize; i++)
250 addChild(children[i]); 250 addChild(children[i]);
251 } 251 }
252 252
253 void LayerChromium::setAnchorPoint(const FloatPoint& anchorPoint) 253 void Layer::setAnchorPoint(const FloatPoint& anchorPoint)
254 { 254 {
255 if (m_anchorPoint == anchorPoint) 255 if (m_anchorPoint == anchorPoint)
256 return; 256 return;
257 m_anchorPoint = anchorPoint; 257 m_anchorPoint = anchorPoint;
258 setNeedsCommit(); 258 setNeedsCommit();
259 } 259 }
260 260
261 void LayerChromium::setAnchorPointZ(float anchorPointZ) 261 void Layer::setAnchorPointZ(float anchorPointZ)
262 { 262 {
263 if (m_anchorPointZ == anchorPointZ) 263 if (m_anchorPointZ == anchorPointZ)
264 return; 264 return;
265 m_anchorPointZ = anchorPointZ; 265 m_anchorPointZ = anchorPointZ;
266 setNeedsCommit(); 266 setNeedsCommit();
267 } 267 }
268 268
269 void LayerChromium::setBackgroundColor(SkColor backgroundColor) 269 void Layer::setBackgroundColor(SkColor backgroundColor)
270 { 270 {
271 if (m_backgroundColor == backgroundColor) 271 if (m_backgroundColor == backgroundColor)
272 return; 272 return;
273 m_backgroundColor = backgroundColor; 273 m_backgroundColor = backgroundColor;
274 setNeedsCommit(); 274 setNeedsCommit();
275 } 275 }
276 276
277 IntSize LayerChromium::contentBounds() const 277 IntSize Layer::contentBounds() const
278 { 278 {
279 return bounds(); 279 return bounds();
280 } 280 }
281 281
282 void LayerChromium::setMasksToBounds(bool masksToBounds) 282 void Layer::setMasksToBounds(bool masksToBounds)
283 { 283 {
284 if (m_masksToBounds == masksToBounds) 284 if (m_masksToBounds == masksToBounds)
285 return; 285 return;
286 m_masksToBounds = masksToBounds; 286 m_masksToBounds = masksToBounds;
287 setNeedsCommit(); 287 setNeedsCommit();
288 } 288 }
289 289
290 void LayerChromium::setMaskLayer(LayerChromium* maskLayer) 290 void Layer::setMaskLayer(Layer* maskLayer)
291 { 291 {
292 if (m_maskLayer == maskLayer) 292 if (m_maskLayer == maskLayer)
293 return; 293 return;
294 if (m_maskLayer) 294 if (m_maskLayer)
295 m_maskLayer->setLayerTreeHost(0); 295 m_maskLayer->setLayerTreeHost(0);
296 m_maskLayer = maskLayer; 296 m_maskLayer = maskLayer;
297 if (m_maskLayer) { 297 if (m_maskLayer) {
298 m_maskLayer->setLayerTreeHost(m_layerTreeHost); 298 m_maskLayer->setLayerTreeHost(m_layerTreeHost);
299 m_maskLayer->setIsMask(true); 299 m_maskLayer->setIsMask(true);
300 } 300 }
301 setNeedsCommit(); 301 setNeedsCommit();
302 } 302 }
303 303
304 void LayerChromium::setReplicaLayer(LayerChromium* layer) 304 void Layer::setReplicaLayer(Layer* layer)
305 { 305 {
306 if (m_replicaLayer == layer) 306 if (m_replicaLayer == layer)
307 return; 307 return;
308 if (m_replicaLayer) 308 if (m_replicaLayer)
309 m_replicaLayer->setLayerTreeHost(0); 309 m_replicaLayer->setLayerTreeHost(0);
310 m_replicaLayer = layer; 310 m_replicaLayer = layer;
311 if (m_replicaLayer) 311 if (m_replicaLayer)
312 m_replicaLayer->setLayerTreeHost(m_layerTreeHost); 312 m_replicaLayer->setLayerTreeHost(m_layerTreeHost);
313 setNeedsCommit(); 313 setNeedsCommit();
314 } 314 }
315 315
316 void LayerChromium::setFilters(const WebKit::WebFilterOperations& filters) 316 void Layer::setFilters(const WebKit::WebFilterOperations& filters)
317 { 317 {
318 if (m_filters == filters) 318 if (m_filters == filters)
319 return; 319 return;
320 m_filters = filters; 320 m_filters = filters;
321 setNeedsCommit(); 321 setNeedsCommit();
322 if (!filters.isEmpty()) 322 if (!filters.isEmpty())
323 CCLayerTreeHost::setNeedsFilterContext(true); 323 LayerTreeHost::setNeedsFilterContext(true);
324 } 324 }
325 325
326 void LayerChromium::setBackgroundFilters(const WebKit::WebFilterOperations& back groundFilters) 326 void Layer::setBackgroundFilters(const WebKit::WebFilterOperations& backgroundFi lters)
327 { 327 {
328 if (m_backgroundFilters == backgroundFilters) 328 if (m_backgroundFilters == backgroundFilters)
329 return; 329 return;
330 m_backgroundFilters = backgroundFilters; 330 m_backgroundFilters = backgroundFilters;
331 setNeedsCommit(); 331 setNeedsCommit();
332 if (!backgroundFilters.isEmpty()) 332 if (!backgroundFilters.isEmpty())
333 CCLayerTreeHost::setNeedsFilterContext(true); 333 LayerTreeHost::setNeedsFilterContext(true);
334 } 334 }
335 335
336 bool LayerChromium::needsDisplay() const 336 bool Layer::needsDisplay() const
337 { 337 {
338 return m_needsDisplay; 338 return m_needsDisplay;
339 } 339 }
340 340
341 void LayerChromium::setOpacity(float opacity) 341 void Layer::setOpacity(float opacity)
342 { 342 {
343 if (m_opacity == opacity) 343 if (m_opacity == opacity)
344 return; 344 return;
345 m_opacity = opacity; 345 m_opacity = opacity;
346 setNeedsCommit(); 346 setNeedsCommit();
347 } 347 }
348 348
349 bool LayerChromium::opacityIsAnimating() const 349 bool Layer::opacityIsAnimating() const
350 { 350 {
351 return m_layerAnimationController->isAnimatingProperty(CCActiveAnimation::Op acity); 351 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac ity);
352 } 352 }
353 353
354 void LayerChromium::setContentsOpaque(bool opaque) 354 void Layer::setContentsOpaque(bool opaque)
355 { 355 {
356 if (m_contentsOpaque == opaque) 356 if (m_contentsOpaque == opaque)
357 return; 357 return;
358 m_contentsOpaque = opaque; 358 m_contentsOpaque = opaque;
359 setNeedsDisplay(); 359 setNeedsDisplay();
360 } 360 }
361 361
362 void LayerChromium::setPosition(const FloatPoint& position) 362 void Layer::setPosition(const FloatPoint& position)
363 { 363 {
364 if (m_position == position) 364 if (m_position == position)
365 return; 365 return;
366 m_position = position; 366 m_position = position;
367 setNeedsCommit(); 367 setNeedsCommit();
368 } 368 }
369 369
370 void LayerChromium::setSublayerTransform(const WebTransformationMatrix& sublayer Transform) 370 void Layer::setSublayerTransform(const WebTransformationMatrix& sublayerTransfor m)
371 { 371 {
372 if (m_sublayerTransform == sublayerTransform) 372 if (m_sublayerTransform == sublayerTransform)
373 return; 373 return;
374 m_sublayerTransform = sublayerTransform; 374 m_sublayerTransform = sublayerTransform;
375 setNeedsCommit(); 375 setNeedsCommit();
376 } 376 }
377 377
378 void LayerChromium::setTransform(const WebTransformationMatrix& transform) 378 void Layer::setTransform(const WebTransformationMatrix& transform)
379 { 379 {
380 if (m_transform == transform) 380 if (m_transform == transform)
381 return; 381 return;
382 m_transform = transform; 382 m_transform = transform;
383 setNeedsCommit(); 383 setNeedsCommit();
384 } 384 }
385 385
386 bool LayerChromium::transformIsAnimating() const 386 bool Layer::transformIsAnimating() const
387 { 387 {
388 return m_layerAnimationController->isAnimatingProperty(CCActiveAnimation::Tr ansform); 388 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform);
389 } 389 }
390 390
391 void LayerChromium::setScrollPosition(const IntPoint& scrollPosition) 391 void Layer::setScrollPosition(const IntPoint& scrollPosition)
392 { 392 {
393 if (m_scrollPosition == scrollPosition) 393 if (m_scrollPosition == scrollPosition)
394 return; 394 return;
395 m_scrollPosition = scrollPosition; 395 m_scrollPosition = scrollPosition;
396 if (m_layerScrollClient) 396 if (m_layerScrollClient)
397 m_layerScrollClient->didScroll(); 397 m_layerScrollClient->didScroll();
398 setNeedsCommit(); 398 setNeedsCommit();
399 } 399 }
400 400
401 void LayerChromium::setMaxScrollPosition(const IntSize& maxScrollPosition) 401 void Layer::setMaxScrollPosition(const IntSize& maxScrollPosition)
402 { 402 {
403 if (m_maxScrollPosition == maxScrollPosition) 403 if (m_maxScrollPosition == maxScrollPosition)
404 return; 404 return;
405 m_maxScrollPosition = maxScrollPosition; 405 m_maxScrollPosition = maxScrollPosition;
406 setNeedsCommit(); 406 setNeedsCommit();
407 } 407 }
408 408
409 void LayerChromium::setScrollable(bool scrollable) 409 void Layer::setScrollable(bool scrollable)
410 { 410 {
411 if (m_scrollable == scrollable) 411 if (m_scrollable == scrollable)
412 return; 412 return;
413 m_scrollable = scrollable; 413 m_scrollable = scrollable;
414 setNeedsCommit(); 414 setNeedsCommit();
415 } 415 }
416 416
417 void LayerChromium::setShouldScrollOnMainThread(bool shouldScrollOnMainThread) 417 void Layer::setShouldScrollOnMainThread(bool shouldScrollOnMainThread)
418 { 418 {
419 if (m_shouldScrollOnMainThread == shouldScrollOnMainThread) 419 if (m_shouldScrollOnMainThread == shouldScrollOnMainThread)
420 return; 420 return;
421 m_shouldScrollOnMainThread = shouldScrollOnMainThread; 421 m_shouldScrollOnMainThread = shouldScrollOnMainThread;
422 setNeedsCommit(); 422 setNeedsCommit();
423 } 423 }
424 424
425 void LayerChromium::setHaveWheelEventHandlers(bool haveWheelEventHandlers) 425 void Layer::setHaveWheelEventHandlers(bool haveWheelEventHandlers)
426 { 426 {
427 if (m_haveWheelEventHandlers == haveWheelEventHandlers) 427 if (m_haveWheelEventHandlers == haveWheelEventHandlers)
428 return; 428 return;
429 m_haveWheelEventHandlers = haveWheelEventHandlers; 429 m_haveWheelEventHandlers = haveWheelEventHandlers;
430 setNeedsCommit(); 430 setNeedsCommit();
431 } 431 }
432 432
433 void LayerChromium::setNonFastScrollableRegion(const Region& region) 433 void Layer::setNonFastScrollableRegion(const Region& region)
434 { 434 {
435 if (m_nonFastScrollableRegion == region) 435 if (m_nonFastScrollableRegion == region)
436 return; 436 return;
437 m_nonFastScrollableRegion = region; 437 m_nonFastScrollableRegion = region;
438 m_nonFastScrollableRegionChanged = true; 438 m_nonFastScrollableRegionChanged = true;
439 setNeedsCommit(); 439 setNeedsCommit();
440 } 440 }
441 441
442 void LayerChromium::setDrawCheckerboardForMissingTiles(bool checkerboard) 442 void Layer::setDrawCheckerboardForMissingTiles(bool checkerboard)
443 { 443 {
444 if (m_drawCheckerboardForMissingTiles == checkerboard) 444 if (m_drawCheckerboardForMissingTiles == checkerboard)
445 return; 445 return;
446 m_drawCheckerboardForMissingTiles = checkerboard; 446 m_drawCheckerboardForMissingTiles = checkerboard;
447 setNeedsCommit(); 447 setNeedsCommit();
448 } 448 }
449 449
450 void LayerChromium::setForceRenderSurface(bool force) 450 void Layer::setForceRenderSurface(bool force)
451 { 451 {
452 if (m_forceRenderSurface == force) 452 if (m_forceRenderSurface == force)
453 return; 453 return;
454 m_forceRenderSurface = force; 454 m_forceRenderSurface = force;
455 setNeedsCommit(); 455 setNeedsCommit();
456 } 456 }
457 457
458 void LayerChromium::setImplTransform(const WebTransformationMatrix& transform) 458 void Layer::setImplTransform(const WebTransformationMatrix& transform)
459 { 459 {
460 if (m_implTransform == transform) 460 if (m_implTransform == transform)
461 return; 461 return;
462 m_implTransform = transform; 462 m_implTransform = transform;
463 setNeedsCommit(); 463 setNeedsCommit();
464 } 464 }
465 465
466 void LayerChromium::setDoubleSided(bool doubleSided) 466 void Layer::setDoubleSided(bool doubleSided)
467 { 467 {
468 if (m_doubleSided == doubleSided) 468 if (m_doubleSided == doubleSided)
469 return; 469 return;
470 m_doubleSided = doubleSided; 470 m_doubleSided = doubleSided;
471 setNeedsCommit(); 471 setNeedsCommit();
472 } 472 }
473 473
474 void LayerChromium::setIsDrawable(bool isDrawable) 474 void Layer::setIsDrawable(bool isDrawable)
475 { 475 {
476 if (m_isDrawable == isDrawable) 476 if (m_isDrawable == isDrawable)
477 return; 477 return;
478 478
479 m_isDrawable = isDrawable; 479 m_isDrawable = isDrawable;
480 setNeedsCommit(); 480 setNeedsCommit();
481 } 481 }
482 482
483 LayerChromium* LayerChromium::parent() const 483 Layer* Layer::parent() const
484 { 484 {
485 return m_parent; 485 return m_parent;
486 } 486 }
487 487
488 void LayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect) 488 void Layer::setNeedsDisplayRect(const FloatRect& dirtyRect)
489 { 489 {
490 m_updateRect.unite(dirtyRect); 490 m_updateRect.unite(dirtyRect);
491 491
492 // Simply mark the contents as dirty. For non-root layers, the call to 492 // Simply mark the contents as dirty. For non-root layers, the call to
493 // setNeedsCommit will schedule a fresh compositing pass. 493 // setNeedsCommit will schedule a fresh compositing pass.
494 // For the root layer, setNeedsCommit has no effect. 494 // For the root layer, setNeedsCommit has no effect.
495 if (!dirtyRect.isEmpty()) 495 if (!dirtyRect.isEmpty())
496 m_needsDisplay = true; 496 m_needsDisplay = true;
497 497
498 setNeedsCommit(); 498 setNeedsCommit();
499 } 499 }
500 500
501 bool LayerChromium::descendantIsFixedToContainerLayer() const 501 bool Layer::descendantIsFixedToContainerLayer() const
502 { 502 {
503 for (size_t i = 0; i < m_children.size(); ++i) { 503 for (size_t i = 0; i < m_children.size(); ++i) {
504 if (m_children[i]->fixedToContainerLayer() || m_children[i]->descendantI sFixedToContainerLayer()) 504 if (m_children[i]->fixedToContainerLayer() || m_children[i]->descendantI sFixedToContainerLayer())
505 return true; 505 return true;
506 } 506 }
507 return false; 507 return false;
508 } 508 }
509 509
510 void LayerChromium::setIsContainerForFixedPositionLayers(bool isContainerForFixe dPositionLayers) 510 void Layer::setIsContainerForFixedPositionLayers(bool isContainerForFixedPositio nLayers)
511 { 511 {
512 if (m_isContainerForFixedPositionLayers == isContainerForFixedPositionLayers ) 512 if (m_isContainerForFixedPositionLayers == isContainerForFixedPositionLayers )
513 return; 513 return;
514 m_isContainerForFixedPositionLayers = isContainerForFixedPositionLayers; 514 m_isContainerForFixedPositionLayers = isContainerForFixedPositionLayers;
515 515
516 if (m_layerTreeHost && m_layerTreeHost->commitRequested()) 516 if (m_layerTreeHost && m_layerTreeHost->commitRequested())
517 return; 517 return;
518 518
519 // Only request a commit if we have a fixed positioned descendant. 519 // Only request a commit if we have a fixed positioned descendant.
520 if (descendantIsFixedToContainerLayer()) 520 if (descendantIsFixedToContainerLayer())
521 setNeedsCommit(); 521 setNeedsCommit();
522 } 522 }
523 523
524 void LayerChromium::setFixedToContainerLayer(bool fixedToContainerLayer) 524 void Layer::setFixedToContainerLayer(bool fixedToContainerLayer)
525 { 525 {
526 if (m_fixedToContainerLayer == fixedToContainerLayer) 526 if (m_fixedToContainerLayer == fixedToContainerLayer)
527 return; 527 return;
528 m_fixedToContainerLayer = fixedToContainerLayer; 528 m_fixedToContainerLayer = fixedToContainerLayer;
529 setNeedsCommit(); 529 setNeedsCommit();
530 } 530 }
531 531
532 void LayerChromium::pushPropertiesTo(CCLayerImpl* layer) 532 void Layer::pushPropertiesTo(LayerImpl* layer)
533 { 533 {
534 layer->setAnchorPoint(m_anchorPoint); 534 layer->setAnchorPoint(m_anchorPoint);
535 layer->setAnchorPointZ(m_anchorPointZ); 535 layer->setAnchorPointZ(m_anchorPointZ);
536 layer->setBackgroundColor(m_backgroundColor); 536 layer->setBackgroundColor(m_backgroundColor);
537 layer->setBounds(m_bounds); 537 layer->setBounds(m_bounds);
538 layer->setContentBounds(contentBounds()); 538 layer->setContentBounds(contentBounds());
539 layer->setDebugBorderColor(m_debugBorderColor); 539 layer->setDebugBorderColor(m_debugBorderColor);
540 layer->setDebugBorderWidth(m_debugBorderWidth); 540 layer->setDebugBorderWidth(m_debugBorderWidth);
541 layer->setDebugName(m_debugName); 541 layer->setDebugName(m_debugName);
542 layer->setDoubleSided(m_doubleSided); 542 layer->setDoubleSided(m_doubleSided);
(...skipping 21 matching lines...) Expand all
564 layer->setFixedToContainerLayer(m_fixedToContainerLayer); 564 layer->setFixedToContainerLayer(m_fixedToContainerLayer);
565 layer->setPreserves3D(preserves3D()); 565 layer->setPreserves3D(preserves3D());
566 layer->setUseParentBackfaceVisibility(m_useParentBackfaceVisibility); 566 layer->setUseParentBackfaceVisibility(m_useParentBackfaceVisibility);
567 layer->setScrollPosition(m_scrollPosition); 567 layer->setScrollPosition(m_scrollPosition);
568 layer->setMaxScrollPosition(m_maxScrollPosition); 568 layer->setMaxScrollPosition(m_maxScrollPosition);
569 layer->setSublayerTransform(m_sublayerTransform); 569 layer->setSublayerTransform(m_sublayerTransform);
570 if (!transformIsAnimating()) 570 if (!transformIsAnimating())
571 layer->setTransform(m_transform); 571 layer->setTransform(m_transform);
572 572
573 // If the main thread commits multiple times before the impl thread actually draws, then damage tracking 573 // If the main thread commits multiple times before the impl thread actually draws, then damage tracking
574 // will become incorrect if we simply clobber the updateRect here. The CCLay erImpl's updateRect needs to 574 // will become incorrect if we simply clobber the updateRect here. The Layer Impl's updateRect needs to
575 // accumulate (i.e. union) any update changes that have occurred on the main thread. 575 // accumulate (i.e. union) any update changes that have occurred on the main thread.
576 m_updateRect.uniteIfNonZero(layer->updateRect()); 576 m_updateRect.uniteIfNonZero(layer->updateRect());
577 layer->setUpdateRect(m_updateRect); 577 layer->setUpdateRect(m_updateRect);
578 578
579 layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta()); 579 layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta());
580 layer->setSentScrollDelta(IntSize()); 580 layer->setSentScrollDelta(IntSize());
581 581
582 layer->setStackingOrderChanged(m_stackingOrderChanged); 582 layer->setStackingOrderChanged(m_stackingOrderChanged);
583 583
584 if (maskLayer()) 584 if (maskLayer())
585 maskLayer()->pushPropertiesTo(layer->maskLayer()); 585 maskLayer()->pushPropertiesTo(layer->maskLayer());
586 if (replicaLayer()) 586 if (replicaLayer())
587 replicaLayer()->pushPropertiesTo(layer->replicaLayer()); 587 replicaLayer()->pushPropertiesTo(layer->replicaLayer());
588 588
589 m_layerAnimationController->pushAnimationUpdatesTo(layer->layerAnimationCont roller()); 589 m_layerAnimationController->pushAnimationUpdatesTo(layer->layerAnimationCont roller());
590 590
591 // Reset any state that should be cleared for the next update. 591 // Reset any state that should be cleared for the next update.
592 m_stackingOrderChanged = false; 592 m_stackingOrderChanged = false;
593 m_updateRect = FloatRect(); 593 m_updateRect = FloatRect();
594 } 594 }
595 595
596 scoped_ptr<CCLayerImpl> LayerChromium::createCCLayerImpl() 596 scoped_ptr<LayerImpl> Layer::createLayerImpl()
597 { 597 {
598 return CCLayerImpl::create(m_layerId); 598 return LayerImpl::create(m_layerId);
599 } 599 }
600 600
601 bool LayerChromium::drawsContent() const 601 bool Layer::drawsContent() const
602 { 602 {
603 return m_isDrawable; 603 return m_isDrawable;
604 } 604 }
605 605
606 bool LayerChromium::needMoreUpdates() 606 bool Layer::needMoreUpdates()
607 { 607 {
608 return false; 608 return false;
609 } 609 }
610 610
611 bool LayerChromium::needsContentsScale() const 611 bool Layer::needsContentsScale() const
612 { 612 {
613 return false; 613 return false;
614 } 614 }
615 615
616 void LayerChromium::setDebugBorderColor(SkColor color) 616 void Layer::setDebugBorderColor(SkColor color)
617 { 617 {
618 m_debugBorderColor = color; 618 m_debugBorderColor = color;
619 setNeedsCommit(); 619 setNeedsCommit();
620 } 620 }
621 621
622 void LayerChromium::setDebugBorderWidth(float width) 622 void Layer::setDebugBorderWidth(float width)
623 { 623 {
624 m_debugBorderWidth = width; 624 m_debugBorderWidth = width;
625 setNeedsCommit(); 625 setNeedsCommit();
626 } 626 }
627 627
628 void LayerChromium::setDebugName(const std::string& debugName) 628 void Layer::setDebugName(const std::string& debugName)
629 { 629 {
630 m_debugName = debugName; 630 m_debugName = debugName;
631 setNeedsCommit(); 631 setNeedsCommit();
632 } 632 }
633 633
634 void LayerChromium::setContentsScale(float contentsScale) 634 void Layer::setContentsScale(float contentsScale)
635 { 635 {
636 if (!needsContentsScale() || m_contentsScale == contentsScale) 636 if (!needsContentsScale() || m_contentsScale == contentsScale)
637 return; 637 return;
638 m_contentsScale = contentsScale; 638 m_contentsScale = contentsScale;
639 639
640 setNeedsDisplay(); 640 setNeedsDisplay();
641 } 641 }
642 642
643 void LayerChromium::setBoundsContainPageScale(bool boundsContainPageScale) 643 void Layer::setBoundsContainPageScale(bool boundsContainPageScale)
644 { 644 {
645 for (size_t i = 0; i < m_children.size(); ++i) 645 for (size_t i = 0; i < m_children.size(); ++i)
646 m_children[i]->setBoundsContainPageScale(boundsContainPageScale); 646 m_children[i]->setBoundsContainPageScale(boundsContainPageScale);
647 647
648 if (boundsContainPageScale == m_boundsContainPageScale) 648 if (boundsContainPageScale == m_boundsContainPageScale)
649 return; 649 return;
650 650
651 m_boundsContainPageScale = boundsContainPageScale; 651 m_boundsContainPageScale = boundsContainPageScale;
652 setNeedsDisplay(); 652 setNeedsDisplay();
653 } 653 }
654 654
655 void LayerChromium::createRenderSurface() 655 void Layer::createRenderSurface()
656 { 656 {
657 ASSERT(!m_renderSurface); 657 ASSERT(!m_renderSurface);
658 m_renderSurface = make_scoped_ptr(new RenderSurfaceChromium(this)); 658 m_renderSurface = make_scoped_ptr(new RenderSurface(this));
659 setRenderTarget(this); 659 setRenderTarget(this);
660 } 660 }
661 661
662 bool LayerChromium::descendantDrawsContent() 662 bool Layer::descendantDrawsContent()
663 { 663 {
664 for (size_t i = 0; i < m_children.size(); ++i) { 664 for (size_t i = 0; i < m_children.size(); ++i) {
665 if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsConte nt()) 665 if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsConte nt())
666 return true; 666 return true;
667 } 667 }
668 return false; 668 return false;
669 } 669 }
670 670
671 int LayerChromium::id() const 671 int Layer::id() const
672 { 672 {
673 return m_layerId; 673 return m_layerId;
674 } 674 }
675 675
676 float LayerChromium::opacity() const 676 float Layer::opacity() const
677 { 677 {
678 return m_opacity; 678 return m_opacity;
679 } 679 }
680 680
681 void LayerChromium::setOpacityFromAnimation(float opacity) 681 void Layer::setOpacityFromAnimation(float opacity)
682 { 682 {
683 // This is called due to an ongoing accelerated animation. Since this animat ion is 683 // This is called due to an ongoing accelerated animation. Since this animat ion is
684 // also being run on the impl thread, there is no need to request a commit t o push 684 // also being run on the impl thread, there is no need to request a commit t o push
685 // this value over, so set the value directly rather than calling setOpacity . 685 // this value over, so set the value directly rather than calling setOpacity .
686 m_opacity = opacity; 686 m_opacity = opacity;
687 } 687 }
688 688
689 const WebKit::WebTransformationMatrix& LayerChromium::transform() const 689 const WebKit::WebTransformationMatrix& Layer::transform() const
690 { 690 {
691 return m_transform; 691 return m_transform;
692 } 692 }
693 693
694 void LayerChromium::setTransformFromAnimation(const WebTransformationMatrix& tra nsform) 694 void Layer::setTransformFromAnimation(const WebTransformationMatrix& transform)
695 { 695 {
696 // This is called due to an ongoing accelerated animation. Since this animat ion is 696 // This is called due to an ongoing accelerated animation. Since this animat ion is
697 // also being run on the impl thread, there is no need to request a commit t o push 697 // also being run on the impl thread, there is no need to request a commit t o push
698 // this value over, so set this value directly rather than calling setTransf orm. 698 // this value over, so set this value directly rather than calling setTransf orm.
699 m_transform = transform; 699 m_transform = transform;
700 } 700 }
701 701
702 bool LayerChromium::addAnimation(scoped_ptr <CCActiveAnimation> animation) 702 bool Layer::addAnimation(scoped_ptr <ActiveAnimation> animation)
703 { 703 {
704 // WebCore currently assumes that accelerated animations will start soon 704 // WebCore currently assumes that accelerated animations will start soon
705 // after the animation is added. However we cannot guarantee that if we do 705 // after the animation is added. However we cannot guarantee that if we do
706 // not have a layerTreeHost that will setNeedsCommit(). 706 // not have a layerTreeHost that will setNeedsCommit().
707 if (!m_layerTreeHost) 707 if (!m_layerTreeHost)
708 return false; 708 return false;
709 709
710 if (!CCSettings::acceleratedAnimationEnabled()) 710 if (!Settings::acceleratedAnimationEnabled())
711 return false; 711 return false;
712 712
713 m_layerAnimationController->addAnimation(animation.Pass()); 713 m_layerAnimationController->addAnimation(animation.Pass());
714 if (m_layerTreeHost) { 714 if (m_layerTreeHost) {
715 m_layerTreeHost->didAddAnimation(); 715 m_layerTreeHost->didAddAnimation();
716 setNeedsCommit(); 716 setNeedsCommit();
717 } 717 }
718 return true; 718 return true;
719 } 719 }
720 720
721 void LayerChromium::pauseAnimation(int animationId, double timeOffset) 721 void Layer::pauseAnimation(int animationId, double timeOffset)
722 { 722 {
723 m_layerAnimationController->pauseAnimation(animationId, timeOffset); 723 m_layerAnimationController->pauseAnimation(animationId, timeOffset);
724 setNeedsCommit(); 724 setNeedsCommit();
725 } 725 }
726 726
727 void LayerChromium::removeAnimation(int animationId) 727 void Layer::removeAnimation(int animationId)
728 { 728 {
729 m_layerAnimationController->removeAnimation(animationId); 729 m_layerAnimationController->removeAnimation(animationId);
730 setNeedsCommit(); 730 setNeedsCommit();
731 } 731 }
732 732
733 void LayerChromium::suspendAnimations(double monotonicTime) 733 void Layer::suspendAnimations(double monotonicTime)
734 { 734 {
735 m_layerAnimationController->suspendAnimations(monotonicTime); 735 m_layerAnimationController->suspendAnimations(monotonicTime);
736 setNeedsCommit(); 736 setNeedsCommit();
737 } 737 }
738 738
739 void LayerChromium::resumeAnimations(double monotonicTime) 739 void Layer::resumeAnimations(double monotonicTime)
740 { 740 {
741 m_layerAnimationController->resumeAnimations(monotonicTime); 741 m_layerAnimationController->resumeAnimations(monotonicTime);
742 setNeedsCommit(); 742 setNeedsCommit();
743 } 743 }
744 744
745 void LayerChromium::setLayerAnimationController(scoped_ptr<CCLayerAnimationContr oller> layerAnimationController) 745 void Layer::setLayerAnimationController(scoped_ptr<LayerAnimationController> lay erAnimationController)
746 { 746 {
747 m_layerAnimationController = layerAnimationController.Pass(); 747 m_layerAnimationController = layerAnimationController.Pass();
748 if (m_layerAnimationController) { 748 if (m_layerAnimationController) {
749 m_layerAnimationController->setClient(this); 749 m_layerAnimationController->setClient(this);
750 m_layerAnimationController->setForceSync(); 750 m_layerAnimationController->setForceSync();
751 } 751 }
752 setNeedsCommit(); 752 setNeedsCommit();
753 } 753 }
754 754
755 scoped_ptr<CCLayerAnimationController> LayerChromium::releaseLayerAnimationContr oller() 755 scoped_ptr<LayerAnimationController> Layer::releaseLayerAnimationController()
756 { 756 {
757 scoped_ptr<CCLayerAnimationController> toReturn = m_layerAnimationController .Pass(); 757 scoped_ptr<LayerAnimationController> toReturn = m_layerAnimationController.P ass();
758 m_layerAnimationController = CCLayerAnimationController::create(this); 758 m_layerAnimationController = LayerAnimationController::create(this);
759 return toReturn.Pass(); 759 return toReturn.Pass();
760 } 760 }
761 761
762 bool LayerChromium::hasActiveAnimation() const 762 bool Layer::hasActiveAnimation() const
763 { 763 {
764 return m_layerAnimationController->hasActiveAnimation(); 764 return m_layerAnimationController->hasActiveAnimation();
765 } 765 }
766 766
767 void LayerChromium::notifyAnimationStarted(const CCAnimationEvent& event, double wallClockTime) 767 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClock Time)
768 { 768 {
769 m_layerAnimationController->notifyAnimationStarted(event); 769 m_layerAnimationController->notifyAnimationStarted(event);
770 if (m_layerAnimationDelegate) 770 if (m_layerAnimationDelegate)
771 m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime); 771 m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime);
772 } 772 }
773 773
774 void LayerChromium::notifyAnimationFinished(double wallClockTime) 774 void Layer::notifyAnimationFinished(double wallClockTime)
775 { 775 {
776 if (m_layerAnimationDelegate) 776 if (m_layerAnimationDelegate)
777 m_layerAnimationDelegate->notifyAnimationFinished(wallClockTime); 777 m_layerAnimationDelegate->notifyAnimationFinished(wallClockTime);
778 } 778 }
779 779
780 Region LayerChromium::visibleContentOpaqueRegion() const 780 Region Layer::visibleContentOpaqueRegion() const
781 { 781 {
782 if (contentsOpaque()) 782 if (contentsOpaque())
783 return visibleContentRect(); 783 return visibleContentRect();
784 return Region(); 784 return Region();
785 } 785 }
786 786
787 ScrollbarLayerChromium* LayerChromium::toScrollbarLayerChromium() 787 ScrollbarLayer* Layer::toScrollbarLayer()
788 { 788 {
789 return 0; 789 return 0;
790 } 790 }
791 791
792 void sortLayers(std::vector<scoped_refptr<LayerChromium> >::iterator, std::vecto r<scoped_refptr<LayerChromium> >::iterator, void*) 792 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*)
793 { 793 {
794 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort LayerChromiums. 794 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers.
795 } 795 }
796 796
797 } 797 }
OLDNEW
« cc/active_animation.h ('K') | « cc/layer.h ('k') | cc/layer_animation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698