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

Unified Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp

Issue 1432783003: Graphics Layer Test: Support compositorAnimationTimelines mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp
index 0e74191ae32e12f7d622bb1ad2aa28b17acad659..756bf7d0678040c6aaa513ecdb99027f911efa9b 100644
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp
@@ -25,11 +25,15 @@
#include "config.h"
#include "platform/graphics/GraphicsLayer.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/scroll/ScrollableArea.h"
#include "platform/transforms/Matrix3DTransformOperation.h"
#include "platform/transforms/RotateTransformOperation.h"
#include "platform/transforms/TranslateTransformOperation.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebCompositorAnimationPlayer.h"
+#include "public/platform/WebCompositorAnimationPlayerClient.h"
+#include "public/platform/WebCompositorAnimationTimeline.h"
#include "public/platform/WebCompositorSupport.h"
#include "public/platform/WebFloatAnimationCurve.h"
#include "public/platform/WebGraphicsContext3D.h"
@@ -83,6 +87,8 @@ public:
m_layerTreeView.clear();
}
+ WebLayerTreeView* layerTreeView() { return m_layerTreeView.get(); }
+
protected:
WebLayer* m_platformLayer;
OwnPtr<GraphicsLayerForTesting> m_graphicsLayer;
@@ -94,6 +100,21 @@ private:
MockGraphicsLayerClient m_client;
};
+class AnimationPlayerForTesting : public WebCompositorAnimationPlayerClient {
+public:
+ AnimationPlayerForTesting()
+ {
+ m_compositorPlayer = adoptPtr(Platform::current()->compositorSupport()->createAnimationPlayer());
+ }
+
+ WebCompositorAnimationPlayer* compositorPlayer() const override
+ {
+ return m_compositorPlayer.get();
+ }
+
+ OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer;
+};
+
TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations)
{
ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
@@ -102,25 +123,63 @@ TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations)
curve->add(WebFloatKeyframe(0.0, 0.0));
OwnPtr<WebCompositorAnimation> floatAnimation(adoptPtr(Platform::current()->compositorSupport()->createAnimation(*curve, WebCompositorAnimation::TargetPropertyOpacity)));
int animationId = floatAnimation->id();
- ASSERT_TRUE(m_platformLayer->addAnimation(floatAnimation.leakPtr()));
- ASSERT_TRUE(m_platformLayer->hasActiveAnimation());
+ if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
+ OwnPtr<WebCompositorAnimationTimeline> compositorTimeline = adoptPtr(Platform::current()->compositorSupport()->createAnimationTimeline());
+ AnimationPlayerForTesting player;
- m_graphicsLayer->setShouldFlattenTransform(false);
+ layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline.get());
+ compositorTimeline->playerAttached(player);
- m_platformLayer = m_graphicsLayer->platformLayer();
- ASSERT_TRUE(m_platformLayer);
+ player.compositorPlayer()->attachLayer(m_platformLayer);
+ ASSERT_TRUE(player.compositorPlayer()->isLayerAttached());
- ASSERT_TRUE(m_platformLayer->hasActiveAnimation());
- m_platformLayer->removeAnimation(animationId);
- ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
+ player.compositorPlayer()->addAnimation(floatAnimation.leakPtr());
- m_graphicsLayer->setShouldFlattenTransform(true);
+ ASSERT_TRUE(m_platformLayer->hasActiveAnimation());
- m_platformLayer = m_graphicsLayer->platformLayer();
- ASSERT_TRUE(m_platformLayer);
+ m_graphicsLayer->setShouldFlattenTransform(false);
- ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
+ m_platformLayer = m_graphicsLayer->platformLayer();
+ ASSERT_TRUE(m_platformLayer);
+
+ ASSERT_TRUE(m_platformLayer->hasActiveAnimation());
+ player.compositorPlayer()->removeAnimation(animationId);
+ ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
+
+ m_graphicsLayer->setShouldFlattenTransform(true);
+
+ m_platformLayer = m_graphicsLayer->platformLayer();
+ ASSERT_TRUE(m_platformLayer);
+
+ ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
+
+ player.compositorPlayer()->detachLayer();
+ ASSERT_FALSE(player.compositorPlayer()->isLayerAttached());
+
+ compositorTimeline->playerDestroyed(player);
+ layerTreeView()->detachCompositorAnimationTimeline(compositorTimeline.get());
+ } else {
+ ASSERT_TRUE(m_platformLayer->addAnimation(floatAnimation.leakPtr()));
+
+ ASSERT_TRUE(m_platformLayer->hasActiveAnimation());
+
+ m_graphicsLayer->setShouldFlattenTransform(false);
+
+ m_platformLayer = m_graphicsLayer->platformLayer();
+ ASSERT_TRUE(m_platformLayer);
+
+ ASSERT_TRUE(m_platformLayer->hasActiveAnimation());
+ m_platformLayer->removeAnimation(animationId);
+ ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
+
+ m_graphicsLayer->setShouldFlattenTransform(true);
+
+ m_platformLayer = m_graphicsLayer->platformLayer();
+ ASSERT_TRUE(m_platformLayer);
+
+ ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
+ }
}
class FakeScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<FakeScrollableArea>, public ScrollableArea {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698