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