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

Side by Side Diff: Source/core/rendering/CompositedLayerMapping.cpp

Issue 139273007: Web Animations: Remove legacy animations engine. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 21 matching lines...) Expand all
32 #include "RuntimeEnabledFeatures.h" 32 #include "RuntimeEnabledFeatures.h"
33 #include "core/animation/ActiveAnimations.h" 33 #include "core/animation/ActiveAnimations.h"
34 #include "core/fetch/ImageResource.h" 34 #include "core/fetch/ImageResource.h"
35 #include "core/html/HTMLIFrameElement.h" 35 #include "core/html/HTMLIFrameElement.h"
36 #include "core/html/HTMLMediaElement.h" 36 #include "core/html/HTMLMediaElement.h"
37 #include "core/html/canvas/CanvasRenderingContext.h" 37 #include "core/html/canvas/CanvasRenderingContext.h"
38 #include "core/inspector/InspectorInstrumentation.h" 38 #include "core/inspector/InspectorInstrumentation.h"
39 #include "core/page/Chrome.h" 39 #include "core/page/Chrome.h"
40 #include "core/frame/FrameView.h" 40 #include "core/frame/FrameView.h"
41 #include "core/frame/Settings.h" 41 #include "core/frame/Settings.h"
42 #include "core/frame/animation/AnimationController.h"
43 #include "core/page/scrolling/ScrollingCoordinator.h" 42 #include "core/page/scrolling/ScrollingCoordinator.h"
44 #include "core/plugins/PluginView.h" 43 #include "core/plugins/PluginView.h"
45 #include "core/rendering/FilterEffectRenderer.h" 44 #include "core/rendering/FilterEffectRenderer.h"
46 #include "core/rendering/RenderApplet.h" 45 #include "core/rendering/RenderApplet.h"
47 #include "core/rendering/RenderEmbeddedObject.h" 46 #include "core/rendering/RenderEmbeddedObject.h"
48 #include "core/rendering/RenderIFrame.h" 47 #include "core/rendering/RenderIFrame.h"
49 #include "core/rendering/RenderImage.h" 48 #include "core/rendering/RenderImage.h"
50 #include "core/rendering/RenderLayerCompositor.h" 49 #include "core/rendering/RenderLayerCompositor.h"
51 #include "core/rendering/RenderLayerStackingNodeIterator.h" 50 #include "core/rendering/RenderLayerStackingNodeIterator.h"
52 #include "core/rendering/RenderVideo.h" 51 #include "core/rendering/RenderVideo.h"
53 #include "core/rendering/RenderView.h" 52 #include "core/rendering/RenderView.h"
54 #include "core/rendering/animation/WebAnimationProvider.h"
55 #include "core/rendering/style/KeyframeList.h" 53 #include "core/rendering/style/KeyframeList.h"
56 #include "platform/LengthFunctions.h" 54 #include "platform/LengthFunctions.h"
57 #include "platform/fonts/FontCache.h" 55 #include "platform/fonts/FontCache.h"
58 #include "platform/graphics/GraphicsContext.h" 56 #include "platform/graphics/GraphicsContext.h"
59 #include "platform/graphics/GraphicsContext3D.h" 57 #include "platform/graphics/GraphicsContext3D.h"
60 #include "wtf/CurrentTime.h" 58 #include "wtf/CurrentTime.h"
61 #include "wtf/text/StringBuilder.h" 59 #include "wtf/text/StringBuilder.h"
62 60
63 using namespace std; 61 using namespace std;
64 62
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 { 148 {
151 Page* page = layer->renderer()->frame()->page(); 149 Page* page = layer->renderer()->frame()->page();
152 if (!page) 150 if (!page)
153 return 0; 151 return 0;
154 152
155 return page->scrollingCoordinator(); 153 return page->scrollingCoordinator();
156 } 154 }
157 155
158 CompositedLayerMapping::CompositedLayerMapping(RenderLayer* layer) 156 CompositedLayerMapping::CompositedLayerMapping(RenderLayer* layer)
159 : m_owningLayer(layer) 157 : m_owningLayer(layer)
160 , m_animationProvider(adoptPtr(new WebAnimationProvider))
161 , m_artificiallyInflatedBounds(false) 158 , m_artificiallyInflatedBounds(false)
162 , m_isMainFrameRenderViewLayer(false) 159 , m_isMainFrameRenderViewLayer(false)
163 , m_requiresOwnBackingStoreForIntrinsicReasons(true) 160 , m_requiresOwnBackingStoreForIntrinsicReasons(true)
164 , m_requiresOwnBackingStoreForAncestorReasons(true) 161 , m_requiresOwnBackingStoreForAncestorReasons(true)
165 , m_canCompositeFilters(false) 162 , m_canCompositeFilters(false)
166 , m_backgroundLayerPaintsFixedRootBackground(false) 163 , m_backgroundLayerPaintsFixedRootBackground(false)
167 { 164 {
168 if (layer->isRootLayer() && renderer()->frame()->isMainFrame()) 165 if (layer->isRootLayer() && renderer()->frame()->isMainFrame())
169 m_isMainFrameRenderViewLayer = true; 166 m_isMainFrameRenderViewLayer = true;
170 167
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 } 612 }
616 613
617 void CompositedLayerMapping::updateGraphicsLayerGeometry() 614 void CompositedLayerMapping::updateGraphicsLayerGeometry()
618 { 615 {
619 // If we haven't built z-order lists yet, wait until later. 616 // If we haven't built z-order lists yet, wait until later.
620 if (m_owningLayer->stackingNode()->isStackingContainer() && m_owningLayer->s tackingNode()->zOrderListsDirty()) 617 if (m_owningLayer->stackingNode()->isStackingContainer() && m_owningLayer->s tackingNode()->zOrderListsDirty())
621 return; 618 return;
622 619
623 // Set transform property, if it is not animating. We have to do this here b ecause the transform 620 // Set transform property, if it is not animating. We have to do this here b ecause the transform
624 // is affected by the layer dimensions. 621 // is affected by the layer dimensions.
625 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled() 622 if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled() || !hasActiveAnimatio nsOnCompositor(*renderer(), CSSPropertyWebkitTransform))
626 ? !hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyWebkitTransfo rm)
627 : !renderer()->animation().isRunningAcceleratedAnimationOnRenderer(rende rer(), CSSPropertyWebkitTransform))
628 updateTransform(renderer()->style()); 623 updateTransform(renderer()->style());
629 624
630 // Set opacity, if it is not animating. 625 // Set opacity, if it is not animating.
631 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled() 626 if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled() || !hasActiveAnimatio nsOnCompositor(*renderer(), CSSPropertyOpacity))
632 ? !hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyOpacity)
633 : !renderer()->animation().isRunningAcceleratedAnimationOnRenderer(rende rer(), CSSPropertyOpacity))
634 updateOpacity(renderer()->style()); 627 updateOpacity(renderer()->style());
635 628
636 bool isSimpleContainer = isSimpleContainerCompositingLayer(); 629 bool isSimpleContainer = isSimpleContainerCompositingLayer();
637 630
638 m_owningLayer->updateDescendantDependentFlags(); 631 m_owningLayer->updateDescendantDependentFlags();
639 632
640 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a nd its non-compositing 633 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a nd its non-compositing
641 // descendants. So, the visibility flag for m_graphicsLayer should be true i f there are any 634 // descendants. So, the visibility flag for m_graphicsLayer should be true i f there are any
642 // non-compositing visible layers. 635 // non-compositing visible layers.
643 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo mpositingDescendantLayers(); 636 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo mpositingDescendantLayers();
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 return rects.release(); 1918 return rects.release();
1926 } 1919 }
1927 1920
1928 #ifndef NDEBUG 1921 #ifndef NDEBUG
1929 void CompositedLayerMapping::verifyNotPainting() 1922 void CompositedLayerMapping::verifyNotPainting()
1930 { 1923 {
1931 ASSERT(!renderer()->frame()->page() || !renderer()->frame()->page()->isPaint ing()); 1924 ASSERT(!renderer()->frame()->page() || !renderer()->frame()->page()->isPaint ing());
1932 } 1925 }
1933 #endif 1926 #endif
1934 1927
1935 bool CompositedLayerMapping::startAnimation(double timeOffset, const CSSAnimatio nData* anim, const KeyframeList& keyframes)
1936 {
1937 bool hasTransform = renderer()->isBox() && keyframes.containsProperty(CSSPro pertyWebkitTransform);
1938 IntSize boxSize;
1939 if (hasTransform)
1940 boxSize = toRenderBox(renderer())->pixelSnappedBorderBoxRect().size();
1941 WebAnimations animations(m_animationProvider->startAnimation(timeOffset, ani m, keyframes, hasTransform, boxSize));
1942 if (animations.isEmpty())
1943 return false;
1944
1945 bool hasOpacity = keyframes.containsProperty(CSSPropertyOpacity);
1946 bool hasFilter = keyframes.containsProperty(CSSPropertyWebkitFilter);
1947 int animationId = m_animationProvider->getWebAnimationId(keyframes.animation Name());
1948
1949 // Animating only some properties of the animation is not supported. So if t he
1950 // GraphicsLayer rejects any property of the animation, we have to remove th e
1951 // animation and return false to indicate un-accelerated animation is requir ed.
1952 if (hasTransform) {
1953 if (!animations.m_transformAnimation || !m_graphicsLayer->addAnimation(a nimations.m_transformAnimation.release()))
1954 return false;
1955 }
1956 if (hasOpacity) {
1957 if (!animations.m_opacityAnimation || !m_graphicsLayer->addAnimation(ani mations.m_opacityAnimation.release())) {
1958 if (hasTransform)
1959 m_graphicsLayer->removeAnimation(animationId);
1960 return false;
1961 }
1962 }
1963 if (hasFilter) {
1964 if (!animations.m_filterAnimation || !m_graphicsLayer->addAnimation(anim ations.m_filterAnimation.release())) {
1965 if (hasTransform || hasOpacity)
1966 m_graphicsLayer->removeAnimation(animationId);
1967 return false;
1968 }
1969 }
1970 return true;
1971 }
1972
1973 void CompositedLayerMapping::animationPaused(double timeOffset, const String& an imationName)
1974 {
1975 int animationId = m_animationProvider->getWebAnimationId(animationName);
1976 ASSERT(animationId);
1977 m_graphicsLayer->pauseAnimation(animationId, timeOffset);
1978 }
1979
1980 void CompositedLayerMapping::animationFinished(const String& animationName)
1981 {
1982 int animationId = m_animationProvider->getWebAnimationId(animationName);
1983 ASSERT(animationId);
1984 m_graphicsLayer->removeAnimation(animationId);
1985 }
1986
1987 bool CompositedLayerMapping::startTransition(double timeOffset, CSSPropertyID pr operty, const RenderStyle* fromStyle, const RenderStyle* toStyle)
1988 {
1989 ASSERT(property != CSSPropertyInvalid);
1990 IntSize boxSize;
1991 if (property == CSSPropertyWebkitTransform && m_owningLayer->hasTransform()) {
1992 ASSERT(renderer()->isBox());
1993 boxSize = toRenderBox(renderer())->pixelSnappedBorderBoxRect().size();
1994 }
1995 float fromOpacity = 0;
1996 float toOpacity = 0;
1997 if (property == CSSPropertyOpacity) {
1998 fromOpacity = compositingOpacity(fromStyle->opacity());
1999 toOpacity = compositingOpacity(toStyle->opacity());
2000 }
2001
2002 // Although KeyframeAnimation can have multiple properties of the animation, ImplicitAnimation (= Transition) has only one animation property.
2003 WebAnimations animations(m_animationProvider->startTransition(timeOffset, pr operty, fromStyle,
2004 toStyle, m_owningLayer->hasTransform(), m_owningLayer->hasFilter(), boxS ize, fromOpacity, toOpacity));
2005 if (animations.m_transformAnimation && m_graphicsLayer->addAnimation(animati ons.m_transformAnimation.release())) {
2006 // To ensure that the correct transform is visible when the animation en ds, also set the final transform.
2007 updateTransform(toStyle);
2008 return true;
2009 }
2010 if (animations.m_opacityAnimation && m_graphicsLayer->addAnimation(animation s.m_opacityAnimation.release())) {
2011 // To ensure that the correct opacity is visible when the animation ends , also set the final opacity.
2012 updateOpacity(toStyle);
2013 return true;
2014 }
2015 if (animations.m_filterAnimation && m_graphicsLayer->addAnimation(animations .m_filterAnimation.release())) {
2016 // To ensure that the correct filter is visible when the animation ends, also set the final filter.
2017 updateFilters(toStyle);
2018 return true;
2019 }
2020
2021 return false;
2022 }
2023
2024 void CompositedLayerMapping::transitionPaused(double timeOffset, CSSPropertyID p roperty)
2025 {
2026 int animationId = m_animationProvider->getWebAnimationId(property);
2027 ASSERT(animationId);
2028 m_graphicsLayer->pauseAnimation(animationId, timeOffset);
2029 }
2030
2031 void CompositedLayerMapping::transitionFinished(CSSPropertyID property)
2032 {
2033 int animationId = m_animationProvider->getWebAnimationId(property);
2034 ASSERT(animationId);
2035 m_graphicsLayer->removeAnimation(animationId);
2036 }
2037
2038 void CompositedLayerMapping::notifyAnimationStarted(const GraphicsLayer*, double wallClockTime, double monotonicTime) 1928 void CompositedLayerMapping::notifyAnimationStarted(const GraphicsLayer*, double wallClockTime, double monotonicTime)
2039 { 1929 {
2040 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) 1930 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled())
2041 renderer()->node()->document().cssPendingAnimations().notifyCompositorAn imationStarted(monotonicTime); 1931 renderer()->node()->document().cssPendingAnimations().notifyCompositorAn imationStarted(monotonicTime);
2042 else
2043 renderer()->animation().notifyAnimationStarted(renderer(), wallClockTime );
2044 } 1932 }
2045 1933
2046 LayoutRect CompositedLayerMapping::compositedBounds() const 1934 LayoutRect CompositedLayerMapping::compositedBounds() const
2047 { 1935 {
2048 return m_compositedBounds; 1936 return m_compositedBounds;
2049 } 1937 }
2050 1938
2051 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds) 1939 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds)
2052 { 1940 {
2053 m_compositedBounds = bounds; 1941 m_compositedBounds = bounds;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2024 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2137 name = "Scrolling Contents Layer"; 2025 name = "Scrolling Contents Layer";
2138 } else { 2026 } else {
2139 ASSERT_NOT_REACHED(); 2027 ASSERT_NOT_REACHED();
2140 } 2028 }
2141 2029
2142 return name; 2030 return name;
2143 } 2031 }
2144 2032
2145 } // namespace WebCore 2033 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698