Revert "Merged all Chromoting Host code into remoting_core.dll (Windows)."
[chromium-blink-merge.git] / cc / layer.cc
blob8581a40b951fc346ba5c16d40a7eab68ea0d023c
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
3 // found in the LICENSE file.
5 #include "cc/layer.h"
7 #include "cc/animation.h"
8 #include "cc/animation_events.h"
9 #include "cc/layer_animation_controller.h"
10 #include "cc/layer_impl.h"
11 #include "cc/layer_tree_host.h"
12 #include "cc/layer_tree_impl.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimationDelegate.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerScrollClient.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
16 #include "third_party/skia/include/core/SkImageFilter.h"
17 #include "ui/gfx/rect_conversions.h"
19 namespace cc {
21 static int s_nextLayerId = 1;
23 scoped_refptr<Layer> Layer::create()
25 return make_scoped_refptr(new Layer());
28 Layer::Layer()
29 : m_needsDisplay(false)
30 , m_stackingOrderChanged(false)
31 , m_layerId(s_nextLayerId++)
32 , m_ignoreSetNeedsCommit(false)
33 , m_parent(0)
34 , m_layerTreeHost(0)
35 , m_scrollable(false)
36 , m_shouldScrollOnMainThread(false)
37 , m_haveWheelEventHandlers(false)
38 , m_anchorPoint(0.5, 0.5)
39 , m_backgroundColor(0)
40 , m_opacity(1.0)
41 , m_anchorPointZ(0)
42 , m_isContainerForFixedPositionLayers(false)
43 , m_fixedToContainerLayer(false)
44 , m_isDrawable(false)
45 , m_masksToBounds(false)
46 , m_contentsOpaque(false)
47 , m_doubleSided(true)
48 , m_preserves3D(false)
49 , m_useParentBackfaceVisibility(false)
50 , m_drawCheckerboardForMissingTiles(false)
51 , m_forceRenderSurface(false)
52 , m_replicaLayer(0)
53 , m_rasterScale(1.0)
54 , m_automaticallyComputeRasterScale(false)
55 , m_boundsContainPageScale(false)
56 , m_layerAnimationDelegate(0)
57 , m_layerScrollClient(0)
59 if (m_layerId < 0) {
60 s_nextLayerId = 1;
61 m_layerId = s_nextLayerId++;
64 m_layerAnimationController = LayerAnimationController::create(m_layerId);
65 m_layerAnimationController->addObserver(this);
66 addLayerAnimationEventObserver(m_layerAnimationController.get());
69 Layer::~Layer()
71 // Our parent should be holding a reference to us so there should be no
72 // way for us to be destroyed while we still have a parent.
73 DCHECK(!parent());
75 m_layerAnimationController->removeObserver(this);
77 // Remove the parent reference from all children.
78 removeAllChildren();
81 void Layer::setLayerTreeHost(LayerTreeHost* host)
83 if (m_layerTreeHost == host)
84 return;
86 m_layerTreeHost = host;
88 for (size_t i = 0; i < m_children.size(); ++i)
89 m_children[i]->setLayerTreeHost(host);
91 if (m_maskLayer)
92 m_maskLayer->setLayerTreeHost(host);
93 if (m_replicaLayer)
94 m_replicaLayer->setLayerTreeHost(host);
96 m_layerAnimationController->setAnimationRegistrar(host ? host->animationRegistrar() : 0);
98 if (host && m_layerAnimationController->hasAnyAnimation())
99 host->setNeedsCommit();
102 void Layer::setNeedsCommit()
104 if (m_ignoreSetNeedsCommit)
105 return;
106 if (m_layerTreeHost)
107 m_layerTreeHost->setNeedsCommit();
110 void Layer::setNeedsFullTreeSync()
112 if (m_layerTreeHost)
113 m_layerTreeHost->setNeedsFullTreeSync();
116 gfx::Rect Layer::layerRectToContentRect(const gfx::RectF& layerRect) const
118 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), contentsScaleY());
119 // Intersect with content rect to avoid the extra pixel because for some
120 // values x and y, ceil((x / y) * y) may be x + 1.
121 contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds()));
122 return gfx::ToEnclosingRect(contentRect);
125 bool Layer::blocksPendingCommit() const
127 return false;
130 bool Layer::canClipSelf() const
132 return false;
135 bool Layer::blocksPendingCommitRecursive() const
137 if (blocksPendingCommit())
138 return true;
139 if (maskLayer() && maskLayer()->blocksPendingCommitRecursive())
140 return true;
141 if (replicaLayer() && replicaLayer()->blocksPendingCommitRecursive())
142 return true;
143 for (size_t i = 0; i < m_children.size(); ++i)
145 if (m_children[i]->blocksPendingCommitRecursive())
146 return true;
148 return false;
151 void Layer::setParent(Layer* layer)
153 DCHECK(!layer || !layer->hasAncestor(this));
154 m_parent = layer;
155 setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0);
157 forceAutomaticRasterScaleToBeRecomputed();
160 bool Layer::hasAncestor(Layer* ancestor) const
162 for (const Layer* layer = parent(); layer; layer = layer->parent()) {
163 if (layer == ancestor)
164 return true;
166 return false;
169 void Layer::addChild(scoped_refptr<Layer> child)
171 insertChild(child, numChildren());
174 void Layer::insertChild(scoped_refptr<Layer> child, size_t index)
176 child->removeFromParent();
177 child->setParent(this);
178 child->m_stackingOrderChanged = true;
180 index = std::min(index, m_children.size());
181 LayerList::iterator iter = m_children.begin();
182 m_children.insert(iter + index, child);
183 setNeedsFullTreeSync();
186 void Layer::removeFromParent()
188 if (m_parent)
189 m_parent->removeChild(this);
192 void Layer::removeChild(Layer* child)
194 for (LayerList::iterator iter = m_children.begin(); iter != m_children.end(); ++iter)
196 if (*iter != child)
197 continue;
199 child->setParent(0);
200 m_children.erase(iter);
201 setNeedsFullTreeSync();
202 return;
206 void Layer::replaceChild(Layer* reference, scoped_refptr<Layer> newLayer)
208 DCHECK(reference);
209 DCHECK_EQ(reference->parent(), this);
211 if (reference == newLayer)
212 return;
214 int referenceIndex = indexOfChild(reference);
215 if (referenceIndex == -1) {
216 NOTREACHED();
217 return;
220 reference->removeFromParent();
222 if (newLayer) {
223 newLayer->removeFromParent();
224 insertChild(newLayer, referenceIndex);
228 int Layer::indexOfChild(const Layer* reference)
230 for (size_t i = 0; i < m_children.size(); i++) {
231 if (m_children[i] == reference)
232 return i;
234 return -1;
237 void Layer::setBounds(const gfx::Size& size)
239 if (bounds() == size)
240 return;
242 bool firstResize = bounds().IsEmpty() && !size.IsEmpty();
244 m_bounds = size;
246 didUpdateBounds();
248 if (firstResize)
249 setNeedsDisplay();
250 else
251 setNeedsCommit();
254 void Layer::didUpdateBounds()
256 m_drawProperties.content_bounds = bounds();
259 Layer* Layer::rootLayer()
261 Layer* layer = this;
262 while (layer->parent())
263 layer = layer->parent();
264 return layer;
267 void Layer::removeAllChildren()
269 while (m_children.size()) {
270 Layer* layer = m_children[0].get();
271 DCHECK(layer->parent());
272 layer->removeFromParent();
276 void Layer::setChildren(const LayerList& children)
278 if (children == m_children)
279 return;
281 removeAllChildren();
282 size_t listSize = children.size();
283 for (size_t i = 0; i < listSize; i++)
284 addChild(children[i]);
287 Layer* Layer::childAt(size_t index)
289 DCHECK_LT(index, m_children.size());
290 return m_children[index].get();
293 void Layer::setAnchorPoint(const gfx::PointF& anchorPoint)
295 if (m_anchorPoint == anchorPoint)
296 return;
297 m_anchorPoint = anchorPoint;
298 setNeedsCommit();
301 void Layer::setAnchorPointZ(float anchorPointZ)
303 if (m_anchorPointZ == anchorPointZ)
304 return;
305 m_anchorPointZ = anchorPointZ;
306 setNeedsCommit();
309 void Layer::setBackgroundColor(SkColor backgroundColor)
311 if (m_backgroundColor == backgroundColor)
312 return;
313 m_backgroundColor = backgroundColor;
314 setNeedsCommit();
317 void Layer::calculateContentsScale(
318 float idealContentsScale,
319 float* contentsScaleX,
320 float* contentsScaleY,
321 gfx::Size* contentBounds)
323 *contentsScaleX = 1;
324 *contentsScaleY = 1;
325 *contentBounds = bounds();
328 void Layer::setMasksToBounds(bool masksToBounds)
330 if (m_masksToBounds == masksToBounds)
331 return;
332 m_masksToBounds = masksToBounds;
333 setNeedsCommit();
336 void Layer::setMaskLayer(Layer* maskLayer)
338 if (m_maskLayer == maskLayer)
339 return;
340 if (m_maskLayer)
341 m_maskLayer->setLayerTreeHost(0);
342 m_maskLayer = maskLayer;
343 if (m_maskLayer) {
344 m_maskLayer->setLayerTreeHost(m_layerTreeHost);
345 m_maskLayer->setIsMask(true);
347 setNeedsFullTreeSync();
350 void Layer::setReplicaLayer(Layer* layer)
352 if (m_replicaLayer == layer)
353 return;
354 if (m_replicaLayer)
355 m_replicaLayer->setLayerTreeHost(0);
356 m_replicaLayer = layer;
357 if (m_replicaLayer)
358 m_replicaLayer->setLayerTreeHost(m_layerTreeHost);
359 setNeedsFullTreeSync();
362 void Layer::setFilters(const WebKit::WebFilterOperations& filters)
364 if (m_filters == filters)
365 return;
366 DCHECK(!m_filter);
367 m_filters = filters;
368 setNeedsCommit();
369 if (!filters.isEmpty())
370 LayerTreeHost::setNeedsFilterContext(true);
373 void Layer::setFilter(const skia::RefPtr<SkImageFilter>& filter)
375 if (m_filter.get() == filter.get())
376 return;
377 DCHECK(m_filters.isEmpty());
378 m_filter = filter;
379 setNeedsCommit();
380 if (filter)
381 LayerTreeHost::setNeedsFilterContext(true);
384 void Layer::setBackgroundFilters(const WebKit::WebFilterOperations& backgroundFilters)
386 if (m_backgroundFilters == backgroundFilters)
387 return;
388 m_backgroundFilters = backgroundFilters;
389 setNeedsCommit();
390 if (!backgroundFilters.isEmpty())
391 LayerTreeHost::setNeedsFilterContext(true);
394 bool Layer::needsDisplay() const
396 return m_needsDisplay;
399 void Layer::setOpacity(float opacity)
401 if (m_opacity == opacity)
402 return;
403 m_opacity = opacity;
404 setNeedsCommit();
407 float Layer::opacity() const
409 return m_opacity;
412 bool Layer::opacityIsAnimating() const
414 return m_layerAnimationController->isAnimatingProperty(Animation::Opacity);
417 void Layer::setContentsOpaque(bool opaque)
419 if (m_contentsOpaque == opaque)
420 return;
421 m_contentsOpaque = opaque;
422 setNeedsDisplay();
425 void Layer::setPosition(const gfx::PointF& position)
427 if (m_position == position)
428 return;
429 m_position = position;
430 setNeedsCommit();
433 void Layer::setSublayerTransform(const gfx::Transform& sublayerTransform)
435 if (m_sublayerTransform == sublayerTransform)
436 return;
437 m_sublayerTransform = sublayerTransform;
438 setNeedsCommit();
441 void Layer::setTransform(const gfx::Transform& transform)
443 if (m_transform == transform)
444 return;
445 m_transform = transform;
446 setNeedsCommit();
449 const gfx::Transform& Layer::transform() const
451 return m_transform;
454 bool Layer::transformIsAnimating() const
456 return m_layerAnimationController->isAnimatingProperty(Animation::Transform);
459 void Layer::setScrollOffset(gfx::Vector2d scrollOffset)
461 if (m_scrollOffset == scrollOffset)
462 return;
463 m_scrollOffset = scrollOffset;
464 if (m_layerScrollClient)
465 m_layerScrollClient->didScroll();
466 setNeedsCommit();
469 void Layer::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
471 if (m_maxScrollOffset == maxScrollOffset)
472 return;
473 m_maxScrollOffset = maxScrollOffset;
474 setNeedsCommit();
477 void Layer::setScrollable(bool scrollable)
479 if (m_scrollable == scrollable)
480 return;
481 m_scrollable = scrollable;
482 setNeedsCommit();
485 void Layer::setShouldScrollOnMainThread(bool shouldScrollOnMainThread)
487 if (m_shouldScrollOnMainThread == shouldScrollOnMainThread)
488 return;
489 m_shouldScrollOnMainThread = shouldScrollOnMainThread;
490 setNeedsCommit();
493 void Layer::setHaveWheelEventHandlers(bool haveWheelEventHandlers)
495 if (m_haveWheelEventHandlers == haveWheelEventHandlers)
496 return;
497 m_haveWheelEventHandlers = haveWheelEventHandlers;
498 setNeedsCommit();
501 void Layer::setNonFastScrollableRegion(const Region& region)
503 if (m_nonFastScrollableRegion == region)
504 return;
505 m_nonFastScrollableRegion = region;
506 setNeedsCommit();
509 void Layer::setTouchEventHandlerRegion(const Region& region)
511 if (m_touchEventHandlerRegion == region)
512 return;
513 m_touchEventHandlerRegion = region;
516 void Layer::setDrawCheckerboardForMissingTiles(bool checkerboard)
518 if (m_drawCheckerboardForMissingTiles == checkerboard)
519 return;
520 m_drawCheckerboardForMissingTiles = checkerboard;
521 setNeedsCommit();
524 void Layer::setForceRenderSurface(bool force)
526 if (m_forceRenderSurface == force)
527 return;
528 m_forceRenderSurface = force;
529 setNeedsCommit();
532 void Layer::setImplTransform(const gfx::Transform& transform)
534 if (m_implTransform == transform)
535 return;
536 m_implTransform = transform;
537 setNeedsCommit();
540 void Layer::setDoubleSided(bool doubleSided)
542 if (m_doubleSided == doubleSided)
543 return;
544 m_doubleSided = doubleSided;
545 setNeedsCommit();
548 void Layer::setIsDrawable(bool isDrawable)
550 if (m_isDrawable == isDrawable)
551 return;
553 m_isDrawable = isDrawable;
554 setNeedsCommit();
557 void Layer::setNeedsDisplayRect(const gfx::RectF& dirtyRect)
559 m_updateRect.Union(dirtyRect);
561 // Simply mark the contents as dirty. For non-root layers, the call to
562 // setNeedsCommit will schedule a fresh compositing pass.
563 // For the root layer, setNeedsCommit has no effect.
564 if (!dirtyRect.IsEmpty())
565 m_needsDisplay = true;
567 if (drawsContent())
568 setNeedsCommit();
571 bool Layer::descendantIsFixedToContainerLayer() const
573 for (size_t i = 0; i < m_children.size(); ++i) {
574 if (m_children[i]->fixedToContainerLayer() || m_children[i]->descendantIsFixedToContainerLayer())
575 return true;
577 return false;
580 void Layer::setIsContainerForFixedPositionLayers(bool isContainerForFixedPositionLayers)
582 if (m_isContainerForFixedPositionLayers == isContainerForFixedPositionLayers)
583 return;
584 m_isContainerForFixedPositionLayers = isContainerForFixedPositionLayers;
586 if (m_layerTreeHost && m_layerTreeHost->commitRequested())
587 return;
589 // Only request a commit if we have a fixed positioned descendant.
590 if (descendantIsFixedToContainerLayer())
591 setNeedsCommit();
594 void Layer::setFixedToContainerLayer(bool fixedToContainerLayer)
596 if (m_fixedToContainerLayer == fixedToContainerLayer)
597 return;
598 m_fixedToContainerLayer = fixedToContainerLayer;
599 setNeedsCommit();
602 void Layer::pushPropertiesTo(LayerImpl* layer)
604 layer->setAnchorPoint(m_anchorPoint);
605 layer->setAnchorPointZ(m_anchorPointZ);
606 layer->setBackgroundColor(m_backgroundColor);
607 layer->setBounds(m_bounds);
608 layer->setContentBounds(contentBounds());
609 layer->setContentsScale(contentsScaleX(), contentsScaleY());
610 layer->setDebugName(m_debugName);
611 layer->setDoubleSided(m_doubleSided);
612 layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles);
613 layer->setForceRenderSurface(m_forceRenderSurface);
614 layer->setDrawsContent(drawsContent());
615 layer->setFilters(filters());
616 layer->setFilter(filter());
617 layer->setBackgroundFilters(backgroundFilters());
618 layer->setMasksToBounds(m_masksToBounds);
619 layer->setShouldScrollOnMainThread(m_shouldScrollOnMainThread);
620 layer->setHaveWheelEventHandlers(m_haveWheelEventHandlers);
621 layer->setNonFastScrollableRegion(m_nonFastScrollableRegion);
622 layer->setTouchEventHandlerRegion(m_touchEventHandlerRegion);
623 layer->setContentsOpaque(m_contentsOpaque);
624 if (!opacityIsAnimating())
625 layer->setOpacity(m_opacity);
626 layer->setPosition(m_position);
627 layer->setIsContainerForFixedPositionLayers(m_isContainerForFixedPositionLayers);
628 layer->setFixedToContainerLayer(m_fixedToContainerLayer);
629 layer->setPreserves3D(preserves3D());
630 layer->setUseParentBackfaceVisibility(m_useParentBackfaceVisibility);
631 layer->setSublayerTransform(m_sublayerTransform);
632 if (!transformIsAnimating())
633 layer->setTransform(m_transform);
635 layer->setScrollable(m_scrollable);
636 layer->setScrollOffset(m_scrollOffset);
637 layer->setMaxScrollOffset(m_maxScrollOffset);
639 // If the main thread commits multiple times before the impl thread actually draws, then damage tracking
640 // will become incorrect if we simply clobber the updateRect here. The LayerImpl's updateRect needs to
641 // accumulate (i.e. union) any update changes that have occurred on the main thread.
642 m_updateRect.Union(layer->updateRect());
643 layer->setUpdateRect(m_updateRect);
645 if (layer->layerTreeImpl()->settings().implSidePainting) {
646 DCHECK(layer->layerTreeImpl()->IsPendingTree());
647 LayerImpl* active_twin = layer->layerTreeImpl()->FindActiveTreeLayerById(id());
648 // Update the scroll delta from the active layer, which may have
649 // adjusted its scroll delta prior to this pending layer being created.
650 // This code is identical to that in LayerImpl::setScrollDelta.
651 if (active_twin) {
652 DCHECK(layer->sentScrollDelta().IsZero());
653 layer->setScrollDelta(active_twin->scrollDelta() - active_twin->sentScrollDelta());
655 } else {
656 layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta());
657 layer->setSentScrollDelta(gfx::Vector2d());
660 layer->setStackingOrderChanged(m_stackingOrderChanged);
662 m_layerAnimationController->pushAnimationUpdatesTo(layer->layerAnimationController());
664 // Reset any state that should be cleared for the next update.
665 m_stackingOrderChanged = false;
666 m_updateRect = gfx::RectF();
669 scoped_ptr<LayerImpl> Layer::createLayerImpl(LayerTreeImpl* treeImpl)
671 return LayerImpl::create(treeImpl, m_layerId);
674 bool Layer::drawsContent() const
676 return m_isDrawable;
679 bool Layer::needMoreUpdates()
681 return false;
684 void Layer::setDebugName(const std::string& debugName)
686 m_debugName = debugName;
687 setNeedsCommit();
690 void Layer::setRasterScale(float scale)
692 if (m_rasterScale == scale)
693 return;
694 m_rasterScale = scale;
696 // When automatically computed, this acts like a draw property.
697 if (m_automaticallyComputeRasterScale)
698 return;
699 setNeedsDisplay();
702 void Layer::setAutomaticallyComputeRasterScale(bool automatic)
704 if (m_automaticallyComputeRasterScale == automatic)
705 return;
706 m_automaticallyComputeRasterScale = automatic;
708 if (m_automaticallyComputeRasterScale)
709 forceAutomaticRasterScaleToBeRecomputed();
710 else
711 setRasterScale(1);
714 void Layer::forceAutomaticRasterScaleToBeRecomputed()
716 if (!m_automaticallyComputeRasterScale)
717 return;
718 m_rasterScale = 0;
719 setNeedsDisplay();
722 void Layer::setBoundsContainPageScale(bool boundsContainPageScale)
724 for (size_t i = 0; i < m_children.size(); ++i)
725 m_children[i]->setBoundsContainPageScale(boundsContainPageScale);
727 if (boundsContainPageScale == m_boundsContainPageScale)
728 return;
730 m_boundsContainPageScale = boundsContainPageScale;
731 setNeedsDisplay();
734 void Layer::createRenderSurface()
736 DCHECK(!m_drawProperties.render_surface);
737 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurface(this));
738 m_drawProperties.render_target = this;
741 int Layer::id() const
743 return m_layerId;
746 void Layer::OnOpacityAnimated(float opacity)
748 // This is called due to an ongoing accelerated animation. Since this animation is
749 // also being run on the impl thread, there is no need to request a commit to push
750 // this value over, so set the value directly rather than calling setOpacity.
751 m_opacity = opacity;
754 void Layer::OnTransformAnimated(const gfx::Transform& transform)
756 // This is called due to an ongoing accelerated animation. Since this animation is
757 // also being run on the impl thread, there is no need to request a commit to push
758 // this value over, so set this value directly rather than calling setTransform.
759 m_transform = transform;
762 bool Layer::IsActive() const
764 return true;
767 bool Layer::addAnimation(scoped_ptr <Animation> animation)
769 // WebCore currently assumes that accelerated animations will start soon
770 // after the animation is added. However we cannot guarantee that if we do
771 // not have a layerTreeHost that will setNeedsCommit().
772 // Unfortunately, the fix below to guarantee correctness causes performance
773 // regressions on Android, since Android has shipped for a long time
774 // with all animations accelerated. For this reason, we will live with
775 // this bug only on Android until the bug is fixed.
776 // http://crbug.com/129683
777 #if !defined(OS_ANDROID)
778 if (!m_layerTreeHost)
779 return false;
781 if (!m_layerTreeHost->settings().acceleratedAnimationEnabled)
782 return false;
783 #endif
785 m_layerAnimationController->addAnimation(animation.Pass());
786 setNeedsCommit();
787 return true;
790 void Layer::pauseAnimation(int animationId, double timeOffset)
792 m_layerAnimationController->pauseAnimation(animationId, timeOffset);
793 setNeedsCommit();
796 void Layer::removeAnimation(int animationId)
798 m_layerAnimationController->removeAnimation(animationId);
799 setNeedsCommit();
802 void Layer::suspendAnimations(double monotonicTime)
804 m_layerAnimationController->suspendAnimations(monotonicTime);
805 setNeedsCommit();
808 void Layer::resumeAnimations(double monotonicTime)
810 m_layerAnimationController->resumeAnimations(monotonicTime);
811 setNeedsCommit();
814 void Layer::setLayerAnimationController(scoped_refptr<LayerAnimationController> layerAnimationController)
816 removeLayerAnimationEventObserver(m_layerAnimationController.get());
817 m_layerAnimationController->removeObserver(this);
818 m_layerAnimationController = layerAnimationController;
819 m_layerAnimationController->setForceSync();
820 m_layerAnimationController->addObserver(this);
821 addLayerAnimationEventObserver(m_layerAnimationController.get());
822 setNeedsCommit();
825 scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController()
827 m_layerAnimationController->removeObserver(this);
828 scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationController;
829 m_layerAnimationController = LayerAnimationController::create(id());
830 m_layerAnimationController->addObserver(this);
831 return toReturn;
834 bool Layer::hasActiveAnimation() const
836 return m_layerAnimationController->hasActiveAnimation();
839 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClockTime)
841 FOR_EACH_OBSERVER(LayerAnimationEventObserver, m_layerAnimationObservers,
842 OnAnimationStarted(event));
843 if (m_layerAnimationDelegate)
844 m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime);
847 void Layer::notifyAnimationFinished(double wallClockTime)
849 if (m_layerAnimationDelegate)
850 m_layerAnimationDelegate->notifyAnimationFinished(wallClockTime);
853 void Layer::addLayerAnimationEventObserver(LayerAnimationEventObserver* animationObserver)
855 if (!m_layerAnimationObservers.HasObserver(animationObserver))
856 m_layerAnimationObservers.AddObserver(animationObserver);
859 void Layer::removeLayerAnimationEventObserver(LayerAnimationEventObserver* animationObserver)
861 m_layerAnimationObservers.RemoveObserver(animationObserver);
864 Region Layer::visibleContentOpaqueRegion() const
866 if (contentsOpaque())
867 return visibleContentRect();
868 return Region();
871 ScrollbarLayer* Layer::toScrollbarLayer()
873 return 0;
876 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped_refptr<Layer> >::iterator, void*)
878 // Currently we don't use z-order to decide what to paint, so there's no need to actually sort Layers.
881 } // namespace cc