Unreviewed, rolling out r121178.
[WebKit-https.git] / Source / WebCore / platform / graphics / chromium / LayerChromium.cpp
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #include "config.h"
32
33 #if USE(ACCELERATED_COMPOSITING)
34 #include "LayerChromium.h"
35
36 #include "NativeImageSkia.h"
37 #include "PlatformContextSkia.h"
38 #include "RenderLayerBacking.h"
39 #include "TextStream.h"
40 #include "cc/CCActiveAnimation.h"
41 #include "cc/CCAnimationEvents.h"
42 #include "cc/CCLayerAnimationController.h"
43 #include "cc/CCLayerAnimationDelegate.h"
44 #include "cc/CCLayerImpl.h"
45 #include "cc/CCLayerTreeHost.h"
46 #include "cc/CCSettings.h"
47 #include "skia/ext/platform_canvas.h"
48
49 using namespace std;
50 using WebKit::WebTransformationMatrix;
51
52 namespace WebCore {
53
54 static int s_nextLayerId = 1;
55
56 PassRefPtr<LayerChromium> LayerChromium::create()
57 {
58     return adoptRef(new LayerChromium());
59 }
60
61 LayerChromium::LayerChromium()
62     : m_needsDisplay(false)
63     , m_stackingOrderChanged(false)
64     , m_layerId(s_nextLayerId++)
65     , m_parent(0)
66     , m_layerTreeHost(0)
67     , m_layerAnimationController(CCLayerAnimationController::create(this))
68     , m_scrollable(false)
69     , m_shouldScrollOnMainThread(false)
70     , m_haveWheelEventHandlers(false)
71     , m_nonFastScrollableRegionChanged(false)
72     , m_anchorPoint(0.5, 0.5)
73     , m_backgroundColor(0, 0, 0, 0)
74     , m_debugBorderWidth(0)
75     , m_opacity(1.0)
76     , m_anchorPointZ(0)
77     , m_isContainerForFixedPositionLayers(false)
78     , m_fixedToContainerLayer(false)
79     , m_isDrawable(false)
80     , m_masksToBounds(false)
81     , m_opaque(false)
82     , m_doubleSided(true)
83     , m_usesLayerClipping(false)
84     , m_isNonCompositedContent(false)
85     , m_preserves3D(false)
86     , m_useParentBackfaceVisibility(false)
87     , m_alwaysReserveTextures(false)
88     , m_drawCheckerboardForMissingTiles(false)
89     , m_forceRenderSurface(false)
90     , m_replicaLayer(0)
91     , m_drawOpacity(0)
92     , m_drawOpacityIsAnimating(false)
93     , m_targetRenderSurface(0)
94     , m_drawTransformIsAnimating(false)
95     , m_screenSpaceTransformIsAnimating(false)
96     , m_contentsScale(1.0)
97     , m_layerAnimationDelegate(0)
98     , m_layerScrollDelegate(0)
99 {
100     if (m_layerId < 0) {
101         s_nextLayerId = 1;
102         m_layerId = s_nextLayerId++;
103     }
104 }
105
106 LayerChromium::~LayerChromium()
107 {
108     // Our parent should be holding a reference to us so there should be no
109     // way for us to be destroyed while we still have a parent.
110     ASSERT(!parent());
111
112     // Remove the parent reference from all children.
113     removeAllChildren();
114 }
115
116 void LayerChromium::setIsNonCompositedContent(bool isNonCompositedContent)
117 {
118     m_isNonCompositedContent = isNonCompositedContent;
119 }
120
121 void LayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
122 {
123     if (m_layerTreeHost == host)
124         return;
125
126     m_layerTreeHost = host;
127
128     for (size_t i = 0; i < m_children.size(); ++i)
129         m_children[i]->setLayerTreeHost(host);
130
131     if (m_maskLayer)
132         m_maskLayer->setLayerTreeHost(host);
133     if (m_replicaLayer)
134         m_replicaLayer->setLayerTreeHost(host);
135
136     // If this layer already has active animations, the host needs to be notified.
137     if (host && m_layerAnimationController->hasActiveAnimation())
138         host->didAddAnimation();
139 }
140
141 void LayerChromium::setNeedsCommit()
142 {
143     if (m_layerTreeHost)
144         m_layerTreeHost->setNeedsCommit();
145 }
146
147 void LayerChromium::setParent(LayerChromium* layer)
148 {
149     ASSERT(!layer || !layer->hasAncestor(this));
150     m_parent = layer;
151     setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0);
152 }
153
154 bool LayerChromium::hasAncestor(LayerChromium* ancestor) const
155 {
156     for (LayerChromium* layer = parent(); layer; layer = layer->parent()) {
157         if (layer == ancestor)
158             return true;
159     }
160     return false;
161 }
162
163 void LayerChromium::addChild(PassRefPtr<LayerChromium> child)
164 {
165     insertChild(child, numChildren());
166 }
167
168 void LayerChromium::insertChild(PassRefPtr<LayerChromium> child, size_t index)
169 {
170     index = min(index, m_children.size());
171     child->removeFromParent();
172     child->setParent(this);
173     child->m_stackingOrderChanged = true;
174     m_children.insert(index, child);
175     setNeedsCommit();
176 }
177
178 void LayerChromium::removeFromParent()
179 {
180     if (m_parent)
181         m_parent->removeChild(this);
182 }
183
184 void LayerChromium::removeChild(LayerChromium* child)
185 {
186     int foundIndex = indexOfChild(child);
187     if (foundIndex == -1)
188         return;
189
190     child->setParent(0);
191     m_children.remove(foundIndex);
192     setNeedsCommit();
193 }
194
195 void LayerChromium::replaceChild(LayerChromium* reference, PassRefPtr<LayerChromium> newLayer)
196 {
197     ASSERT_ARG(reference, reference);
198     ASSERT_ARG(reference, reference->parent() == this);
199
200     if (reference == newLayer)
201         return;
202
203     int referenceIndex = indexOfChild(reference);
204     if (referenceIndex == -1) {
205         ASSERT_NOT_REACHED();
206         return;
207     }
208
209     reference->removeFromParent();
210
211     if (newLayer) {
212         newLayer->removeFromParent();
213         insertChild(newLayer, referenceIndex);
214     }
215 }
216
217 int LayerChromium::indexOfChild(const LayerChromium* reference)
218 {
219     for (size_t i = 0; i < m_children.size(); i++) {
220         if (m_children[i] == reference)
221             return i;
222     }
223     return -1;
224 }
225
226 void LayerChromium::setBounds(const IntSize& size)
227 {
228     if (bounds() == size)
229         return;
230
231     bool firstResize = !bounds().width() && !bounds().height() && size.width() && size.height();
232
233     m_bounds = size;
234
235     if (firstResize)
236         setNeedsDisplay();
237     else
238         setNeedsCommit();
239 }
240
241 const LayerChromium* LayerChromium::rootLayer() const
242 {
243     const LayerChromium* layer = this;
244     for (LayerChromium* parent = layer->parent(); parent; layer = parent, parent = parent->parent()) { }
245     return layer;
246 }
247
248 void LayerChromium::removeAllChildren()
249 {
250     while (m_children.size()) {
251         LayerChromium* layer = m_children[0].get();
252         ASSERT(layer->parent());
253         layer->removeFromParent();
254     }
255 }
256
257 void LayerChromium::setChildren(const Vector<RefPtr<LayerChromium> >& children)
258 {
259     if (children == m_children)
260         return;
261
262     removeAllChildren();
263     size_t listSize = children.size();
264     for (size_t i = 0; i < listSize; i++)
265         addChild(children[i]);
266 }
267
268 void LayerChromium::setAnchorPoint(const FloatPoint& anchorPoint)
269 {
270     if (m_anchorPoint == anchorPoint)
271         return;
272     m_anchorPoint = anchorPoint;
273     setNeedsCommit();
274 }
275
276 void LayerChromium::setAnchorPointZ(float anchorPointZ)
277 {
278     if (m_anchorPointZ == anchorPointZ)
279         return;
280     m_anchorPointZ = anchorPointZ;
281     setNeedsCommit();
282 }
283
284 void LayerChromium::setBackgroundColor(const Color& backgroundColor)
285 {
286     if (m_backgroundColor == backgroundColor)
287         return;
288     m_backgroundColor = backgroundColor;
289     setNeedsCommit();
290 }
291
292 void LayerChromium::setMasksToBounds(bool masksToBounds)
293 {
294     if (m_masksToBounds == masksToBounds)
295         return;
296     m_masksToBounds = masksToBounds;
297     setNeedsCommit();
298 }
299
300 void LayerChromium::setMaskLayer(LayerChromium* maskLayer)
301 {
302     if (m_maskLayer == maskLayer)
303         return;
304     if (m_maskLayer)
305         m_maskLayer->setLayerTreeHost(0);
306     m_maskLayer = maskLayer;
307     if (m_maskLayer) {
308         m_maskLayer->setLayerTreeHost(m_layerTreeHost);
309         m_maskLayer->setIsMask(true);
310     }
311     setNeedsCommit();
312 }
313
314 void LayerChromium::setReplicaLayer(LayerChromium* layer)
315 {
316     if (m_replicaLayer == layer)
317         return;
318     if (m_replicaLayer)
319         m_replicaLayer->setLayerTreeHost(0);
320     m_replicaLayer = layer;
321     if (m_replicaLayer)
322         m_replicaLayer->setLayerTreeHost(m_layerTreeHost);
323     setNeedsCommit();
324 }
325
326 void LayerChromium::setFilters(const WebKit::WebFilterOperations& filters)
327 {
328     if (m_filters == filters)
329         return;
330     m_filters = filters;
331     setNeedsCommit();
332     if (!filters.isEmpty())
333         CCLayerTreeHost::setNeedsFilterContext(true);
334 }
335
336 void LayerChromium::setBackgroundFilters(const WebKit::WebFilterOperations& backgroundFilters)
337 {
338     if (m_backgroundFilters == backgroundFilters)
339         return;
340     m_backgroundFilters = backgroundFilters;
341     setNeedsCommit();
342     if (!backgroundFilters.isEmpty())
343         CCLayerTreeHost::setNeedsFilterContext(true);
344 }
345
346 void LayerChromium::setOpacity(float opacity)
347 {
348     if (m_opacity == opacity)
349         return;
350     m_opacity = opacity;
351     setNeedsCommit();
352 }
353
354 bool LayerChromium::opacityIsAnimating() const
355 {
356     return m_layerAnimationController->isAnimatingProperty(CCActiveAnimation::Opacity);
357 }
358
359 void LayerChromium::setOpaque(bool opaque)
360 {
361     if (m_opaque == opaque)
362         return;
363     m_opaque = opaque;
364     setNeedsDisplay();
365 }
366
367 void LayerChromium::setPosition(const FloatPoint& position)
368 {
369     if (m_position == position)
370         return;
371     m_position = position;
372     setNeedsCommit();
373 }
374
375 void LayerChromium::setSublayerTransform(const WebTransformationMatrix& sublayerTransform)
376 {
377     if (m_sublayerTransform == sublayerTransform)
378         return;
379     m_sublayerTransform = sublayerTransform;
380     setNeedsCommit();
381 }
382
383 void LayerChromium::setTransform(const WebTransformationMatrix& transform)
384 {
385     if (m_transform == transform)
386         return;
387     m_transform = transform;
388     setNeedsCommit();
389 }
390
391 bool LayerChromium::transformIsAnimating() const
392 {
393     return m_layerAnimationController->isAnimatingProperty(CCActiveAnimation::Transform);
394 }
395
396 void LayerChromium::setScrollPosition(const IntPoint& scrollPosition)
397 {
398     if (m_scrollPosition == scrollPosition)
399         return;
400     m_scrollPosition = scrollPosition;
401     setNeedsCommit();
402 }
403
404 void LayerChromium::setMaxScrollPosition(const IntSize& maxScrollPosition)
405 {
406     if (m_maxScrollPosition == maxScrollPosition)
407         return;
408     m_maxScrollPosition = maxScrollPosition;
409     setNeedsCommit();
410 }
411
412 void LayerChromium::setScrollable(bool scrollable)
413 {
414     if (m_scrollable == scrollable)
415         return;
416     m_scrollable = scrollable;
417     setNeedsCommit();
418 }
419
420 void LayerChromium::setShouldScrollOnMainThread(bool shouldScrollOnMainThread)
421 {
422     if (m_shouldScrollOnMainThread == shouldScrollOnMainThread)
423         return;
424     m_shouldScrollOnMainThread = shouldScrollOnMainThread;
425     setNeedsCommit();
426 }
427
428 void LayerChromium::setHaveWheelEventHandlers(bool haveWheelEventHandlers)
429 {
430     if (m_haveWheelEventHandlers == haveWheelEventHandlers)
431         return;
432     m_haveWheelEventHandlers = haveWheelEventHandlers;
433     setNeedsCommit();
434 }
435
436 void LayerChromium::setNonFastScrollableRegion(const Region& region)
437 {
438     if (m_nonFastScrollableRegion == region)
439         return;
440     m_nonFastScrollableRegion = region;
441     m_nonFastScrollableRegionChanged = true;
442     setNeedsCommit();
443 }
444
445 void LayerChromium::scrollBy(const IntSize& scrollDelta)
446 {
447     setScrollPosition(scrollPosition() + scrollDelta);
448     if (m_layerScrollDelegate)
449         m_layerScrollDelegate->didScroll(scrollDelta);
450 }
451
452 void LayerChromium::setDrawCheckerboardForMissingTiles(bool checkerboard)
453 {
454     if (m_drawCheckerboardForMissingTiles == checkerboard)
455         return;
456     m_drawCheckerboardForMissingTiles = checkerboard;
457     setNeedsCommit();
458 }
459
460 void LayerChromium::setForceRenderSurface(bool force)
461 {
462     if (m_forceRenderSurface == force)
463         return;
464     m_forceRenderSurface = force;
465     setNeedsCommit();
466 }
467
468 void LayerChromium::setDoubleSided(bool doubleSided)
469 {
470     if (m_doubleSided == doubleSided)
471         return;
472     m_doubleSided = doubleSided;
473     setNeedsCommit();
474 }
475
476 void LayerChromium::setIsDrawable(bool isDrawable)
477 {
478     if (m_isDrawable == isDrawable)
479         return;
480
481     m_isDrawable = isDrawable;
482     setNeedsCommit();
483 }
484
485 LayerChromium* LayerChromium::parent() const
486 {
487     return m_parent;
488 }
489
490 void LayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
491 {
492     m_updateRect.unite(dirtyRect);
493
494     // Simply mark the contents as dirty. For non-root layers, the call to
495     // setNeedsCommit will schedule a fresh compositing pass.
496     // For the root layer, setNeedsCommit has no effect.
497     if (!dirtyRect.isEmpty())
498         m_needsDisplay = true;
499
500     setNeedsCommit();
501 }
502
503 bool LayerChromium::descendantIsFixedToContainerLayer() const
504 {
505     for (size_t i = 0; i < m_children.size(); ++i) {
506         if (m_children[i]->fixedToContainerLayer() || m_children[i]->descendantIsFixedToContainerLayer())
507             return true;
508     }
509     return false;
510 }
511
512 void LayerChromium::setIsContainerForFixedPositionLayers(bool isContainerForFixedPositionLayers)
513 {
514     if (m_isContainerForFixedPositionLayers == isContainerForFixedPositionLayers)
515         return;
516     m_isContainerForFixedPositionLayers = isContainerForFixedPositionLayers;
517
518     if (m_layerTreeHost && m_layerTreeHost->commitRequested())
519         return;
520
521     // Only request a commit if we have a fixed positioned descendant.
522     if (descendantIsFixedToContainerLayer())
523         setNeedsCommit();
524 }
525
526 void LayerChromium::setFixedToContainerLayer(bool fixedToContainerLayer)
527 {
528     if (m_fixedToContainerLayer == fixedToContainerLayer)
529         return;
530     m_fixedToContainerLayer = fixedToContainerLayer;
531     setNeedsCommit();
532 }
533
534 void LayerChromium::pushPropertiesTo(CCLayerImpl* layer)
535 {
536     layer->setAnchorPoint(m_anchorPoint);
537     layer->setAnchorPointZ(m_anchorPointZ);
538     layer->setBackgroundColor(m_backgroundColor);
539     layer->setBounds(m_bounds);
540     layer->setContentBounds(contentBounds());
541     layer->setContentsScale(contentsScale());
542     layer->setDebugBorderColor(m_debugBorderColor);
543     layer->setDebugBorderWidth(m_debugBorderWidth);
544     layer->setDebugName(m_debugName.isolatedCopy()); // We have to use isolatedCopy() here to safely pass ownership to another thread.
545     layer->setDoubleSided(m_doubleSided);
546     layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles);
547     layer->setForceRenderSurface(m_forceRenderSurface);
548     layer->setDrawsContent(drawsContent());
549     layer->setFilters(filters());
550     layer->setBackgroundFilters(backgroundFilters());
551     layer->setIsNonCompositedContent(m_isNonCompositedContent);
552     layer->setMasksToBounds(m_masksToBounds);
553     layer->setScrollable(m_scrollable);
554     layer->setShouldScrollOnMainThread(m_shouldScrollOnMainThread);
555     layer->setHaveWheelEventHandlers(m_haveWheelEventHandlers);
556     // Copying a Region is more expensive than most layer properties, since it involves copying two Vectors that may be
557     // arbitrarily large depending on page content, so we only push the property if it's changed.
558     if (m_nonFastScrollableRegionChanged) {
559         layer->setNonFastScrollableRegion(m_nonFastScrollableRegion);
560         m_nonFastScrollableRegionChanged = false;
561     }
562     layer->setOpaque(m_opaque);
563     if (!opacityIsAnimating())
564         layer->setOpacity(m_opacity);
565     layer->setPosition(m_position);
566     layer->setIsContainerForFixedPositionLayers(m_isContainerForFixedPositionLayers);
567     layer->setFixedToContainerLayer(m_fixedToContainerLayer);
568     layer->setPreserves3D(preserves3D());
569     layer->setUseParentBackfaceVisibility(m_useParentBackfaceVisibility);
570     layer->setScrollPosition(m_scrollPosition);
571     layer->setMaxScrollPosition(m_maxScrollPosition);
572     layer->setSublayerTransform(m_sublayerTransform);
573     if (!transformIsAnimating())
574         layer->setTransform(m_transform);
575
576     // If the main thread commits multiple times before the impl thread actually draws, then damage tracking
577     // will become incorrect if we simply clobber the updateRect here. The CCLayerImpl's updateRect needs to
578     // accumulate (i.e. union) any update changes that have occurred on the main thread.
579     m_updateRect.uniteIfNonZero(layer->updateRect());
580     layer->setUpdateRect(m_updateRect);
581
582     layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta());
583     layer->setSentScrollDelta(IntSize());
584
585     layer->setStackingOrderChanged(m_stackingOrderChanged);
586
587     if (maskLayer())
588         maskLayer()->pushPropertiesTo(layer->maskLayer());
589     if (replicaLayer())
590         replicaLayer()->pushPropertiesTo(layer->replicaLayer());
591
592     m_layerAnimationController->pushAnimationUpdatesTo(layer->layerAnimationController());
593
594     // Reset any state that should be cleared for the next update.
595     m_stackingOrderChanged = false;
596     m_updateRect = FloatRect();
597 }
598
599 PassOwnPtr<CCLayerImpl> LayerChromium::createCCLayerImpl()
600 {
601     return CCLayerImpl::create(m_layerId);
602 }
603
604 void LayerChromium::setDebugBorderColor(const Color& color)
605 {
606     m_debugBorderColor = color;
607     setNeedsCommit();
608 }
609
610 void LayerChromium::setDebugBorderWidth(float width)
611 {
612     m_debugBorderWidth = width;
613     setNeedsCommit();
614 }
615
616 void LayerChromium::setDebugName(const String& debugName)
617 {
618     m_debugName = debugName;
619     setNeedsCommit();
620 }
621
622
623 void LayerChromium::setContentsScale(float contentsScale)
624 {
625     if (!needsContentsScale() || m_contentsScale == contentsScale)
626         return;
627     m_contentsScale = contentsScale;
628     setNeedsDisplay();
629 }
630
631 void LayerChromium::createRenderSurface()
632 {
633     ASSERT(!m_renderSurface);
634     m_renderSurface = adoptPtr(new RenderSurfaceChromium(this));
635     setTargetRenderSurface(m_renderSurface.get());
636 }
637
638 bool LayerChromium::descendantDrawsContent()
639 {
640     for (size_t i = 0; i < m_children.size(); ++i) {
641         if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsContent())
642             return true;
643     }
644     return false;
645 }
646
647 void LayerChromium::setOpacityFromAnimation(float opacity)
648 {
649     // This is called due to an ongoing accelerated animation. Since this animation is
650     // also being run on the impl thread, there is no need to request a commit to push
651     // this value over, so set the value directly rather than calling setOpacity.
652     m_opacity = opacity;
653 }
654
655 void LayerChromium::setTransformFromAnimation(const WebTransformationMatrix& transform)
656 {
657     // This is called due to an ongoing accelerated animation. Since this animation is
658     // also being run on the impl thread, there is no need to request a commit to push
659     // this value over, so set this value directly rather than calling setTransform.
660     m_transform = transform;
661 }
662
663 bool LayerChromium::addAnimation(PassOwnPtr<CCActiveAnimation> animation)
664 {
665     if (!CCSettings::acceleratedAnimationEnabled())
666         return false;
667
668     m_layerAnimationController->addAnimation(animation);
669     if (m_layerTreeHost) {
670         m_layerTreeHost->didAddAnimation();
671         setNeedsCommit();
672     }
673     return true;
674 }
675
676 void LayerChromium::pauseAnimation(int animationId, double timeOffset)
677 {
678     m_layerAnimationController->pauseAnimation(animationId, timeOffset);
679     setNeedsCommit();
680 }
681
682 void LayerChromium::removeAnimation(int animationId)
683 {
684     m_layerAnimationController->removeAnimation(animationId);
685     setNeedsCommit();
686 }
687
688 void LayerChromium::suspendAnimations(double monotonicTime)
689 {
690     m_layerAnimationController->suspendAnimations(monotonicTime);
691     setNeedsCommit();
692 }
693
694 void LayerChromium::resumeAnimations(double monotonicTime)
695 {
696     m_layerAnimationController->resumeAnimations(monotonicTime);
697     setNeedsCommit();
698 }
699
700 void LayerChromium::setLayerAnimationController(PassOwnPtr<CCLayerAnimationController> layerAnimationController)
701 {
702     m_layerAnimationController = layerAnimationController;
703     if (m_layerAnimationController) {
704         m_layerAnimationController->setClient(this);
705         m_layerAnimationController->setForceSync();
706     }
707     setNeedsCommit();
708 }
709
710 PassOwnPtr<CCLayerAnimationController> LayerChromium::releaseLayerAnimationController()
711 {
712     OwnPtr<CCLayerAnimationController> toReturn = m_layerAnimationController.release();
713     m_layerAnimationController = CCLayerAnimationController::create(this);
714     return toReturn.release();
715 }
716
717 bool LayerChromium::hasActiveAnimation() const
718 {
719     return m_layerAnimationController->hasActiveAnimation();
720 }
721
722 void LayerChromium::notifyAnimationStarted(const CCAnimationEvent& event, double wallClockTime)
723 {
724     m_layerAnimationController->notifyAnimationStarted(event);
725     if (m_layerAnimationDelegate)
726         m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime);
727 }
728
729 void LayerChromium::notifyAnimationFinished(double wallClockTime)
730 {
731     if (m_layerAnimationDelegate)
732         m_layerAnimationDelegate->notifyAnimationFinished(wallClockTime);
733 }
734
735 Region LayerChromium::visibleContentOpaqueRegion() const
736 {
737     if (opaque())
738         return visibleLayerRect();
739     return Region();
740 }
741
742 void sortLayers(Vector<RefPtr<LayerChromium> >::iterator, Vector<RefPtr<LayerChromium> >::iterator, void*)
743 {
744     // Currently we don't use z-order to decide what to paint, so there's no need to actually sort LayerChromiums.
745 }
746
747 }
748 #endif // USE(ACCELERATED_COMPOSITING)