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

Side by Side Diff: third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp

Issue 2596623002: Create compositor animations for effect animations in SPv2. (Closed)
Patch Set: Sync to head and add node removal test. Created 3 years, 12 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 EXPECT_EQ(2U, element->elementAnimations()->animations().size()); 1247 EXPECT_EQ(2U, element->elementAnimations()->animations().size());
1248 simulateFrame(1.); 1248 simulateFrame(1.);
1249 1249
1250 element->setLayoutObject(nullptr); 1250 element->setLayoutObject(nullptr);
1251 LayoutObjectProxy::dispose(layoutObject); 1251 LayoutObjectProxy::dispose(layoutObject);
1252 1252
1253 ThreadState::current()->collectAllGarbage(); 1253 ThreadState::current()->collectAllGarbage();
1254 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty()); 1254 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty());
1255 } 1255 }
1256 1256
1257 namespace {
1258
1259 void updateDummyTransformNode(ObjectPaintProperties& properties,
1260 CompositingReasons reasons) {
1261 properties.updateTransform(TransformPaintPropertyNode::root(),
1262 TransformationMatrix(), FloatPoint3D(), false, 0,
1263 reasons);
1264 }
1265
1266 void updateDummyEffectNode(ObjectPaintProperties& properties,
1267 CompositingReasons reasons) {
1268 properties.updateEffect(
1269 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
1270 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 1.0,
1271 SkBlendMode::kSrcOver, reasons);
1272 }
1273
1274 } // namespace
1275
1257 TEST_F(AnimationCompositorAnimationsTest, 1276 TEST_F(AnimationCompositorAnimationsTest,
1258 canStartAnimationOnCompositorTransformSPv2) { 1277 canStartAnimationOnCompositorTransformSPv2) {
1259 Persistent<Element> element = m_document->createElement("shared"); 1278 Persistent<Element> element = m_document->createElement("shared");
1260 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); 1279 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get());
1261 element->setLayoutObject(layoutObject); 1280 element->setLayoutObject(layoutObject);
1262 1281
1263 ScopedSlimmingPaintV2ForTest enableSPv2(true); 1282 ScopedSlimmingPaintV2ForTest enableSPv2(true);
1264 auto& properties = 1283 auto& properties =
1265 layoutObject->getMutableForPainting().ensurePaintProperties(); 1284 layoutObject->getMutableForPainting().ensurePaintProperties();
1266 1285
1267 // Add a transform with a compositing reason, which should allow starting 1286 // Add a transform with a compositing reason, which should allow starting
1268 // animation. 1287 // animation.
1269 properties.updateTransform(TransformPaintPropertyNode::root(), 1288 updateDummyTransformNode(properties, CompositingReasonActiveAnimation);
1270 TransformationMatrix(), FloatPoint3D(), false, 0,
1271 CompositingReasonActiveAnimation);
1272 EXPECT_TRUE(CompositorAnimations::canStartAnimationOnCompositor(*element)); 1289 EXPECT_TRUE(CompositorAnimations::canStartAnimationOnCompositor(*element));
1273 1290
1274 // Setting to CompositingReasonNone should produce false. 1291 // Setting to CompositingReasonNone should produce false.
1275 properties.updateTransform(TransformPaintPropertyNode::root(), 1292 updateDummyTransformNode(properties, CompositingReasonNone);
1276 TransformationMatrix(), FloatPoint3D(), false, 0,
1277 CompositingReasonNone);
1278 EXPECT_FALSE(CompositorAnimations::canStartAnimationOnCompositor(*element)); 1293 EXPECT_FALSE(CompositorAnimations::canStartAnimationOnCompositor(*element));
1279 1294
1280 // Clearing the transform node entirely should also produce false. 1295 // Clearing the transform node entirely should also produce false.
1281 properties.clearTransform(); 1296 properties.clearTransform();
1282 EXPECT_FALSE(CompositorAnimations::canStartAnimationOnCompositor(*element)); 1297 EXPECT_FALSE(CompositorAnimations::canStartAnimationOnCompositor(*element));
1283 1298
1284 element->setLayoutObject(nullptr); 1299 element->setLayoutObject(nullptr);
1285 LayoutObjectProxy::dispose(layoutObject); 1300 LayoutObjectProxy::dispose(layoutObject);
1286 } 1301 }
1287 1302
1303 TEST_F(AnimationCompositorAnimationsTest,
1304 canStartAnimationOnCompositorEffectSPv2) {
1305 Persistent<Element> element = m_document->createElement("shared");
1306 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get());
1307 element->setLayoutObject(layoutObject);
1308
1309 ScopedSlimmingPaintV2ForTest enableSPv2(true);
1310 auto& properties =
1311 layoutObject->getMutableForPainting().ensurePaintProperties();
1312
1313 // Add an effect with a compositing reason, which should allow starting
1314 // animation.
1315 updateDummyEffectNode(properties, CompositingReasonActiveAnimation);
1316 EXPECT_TRUE(CompositorAnimations::canStartAnimationOnCompositor(*element));
1317
1318 // Setting to CompositingReasonNone should produce false.
1319 updateDummyEffectNode(properties, CompositingReasonNone);
1320 EXPECT_FALSE(CompositorAnimations::canStartAnimationOnCompositor(*element));
1321
1322 // Clearing the effect node entirely should also produce false.
1323 properties.clearEffect();
1324 EXPECT_FALSE(CompositorAnimations::canStartAnimationOnCompositor(*element));
1325
1326 element->setLayoutObject(nullptr);
1327 LayoutObjectProxy::dispose(layoutObject);
1328 }
1329
1288 } // namespace blink 1330 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698