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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp

Issue 2636973002: Adding test to verify that Canvas2DLayerBridge flushes only when required (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 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 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback); 1304 bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback);
1305 } 1305 }
1306 1306
1307 bool lostResource = false; 1307 bool lostResource = false;
1308 releaseCallback->Run(gpu::SyncToken(), lostResource); 1308 releaseCallback->Run(gpu::SyncToken(), lostResource);
1309 1309
1310 EXPECT_EQ(1u, gl.createImageCount()); 1310 EXPECT_EQ(1u, gl.createImageCount());
1311 EXPECT_EQ(1u, gl.destroyImageCount()); 1311 EXPECT_EQ(1u, gl.destroyImageCount());
1312 } 1312 }
1313 1313
1314 class FlushMockGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
1315 public:
1316 MOCK_METHOD0(Flush, void());
1317 };
1318
1319 TEST_F(Canvas2DLayerBridgeTest, NoUnnecessaryFlushes) {
1320 FlushMockGLES2Interface gl;
1321 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
1322 WTF::wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
1323
1324 EXPECT_CALL(gl, Flush()).Times(0);
1325 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
1326 std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
1327 Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr,
1328 kN32_SkColorType)));
1329 EXPECT_FALSE(bridge->hasRecordedDrawCommands());
1330 ::testing::Mock::VerifyAndClearExpectations(&gl);
1331
1332 EXPECT_CALL(gl, Flush()).Times(0);
1333 bridge->didDraw(FloatRect(0, 0, 1, 1));
1334 EXPECT_TRUE(bridge->hasRecordedDrawCommands());
1335 ::testing::Mock::VerifyAndClearExpectations(&gl);
1336
1337 EXPECT_CALL(gl, Flush()).Times(1);
1338 bridge->flushGpu();
1339 EXPECT_FALSE(bridge->hasRecordedDrawCommands());
1340 ::testing::Mock::VerifyAndClearExpectations(&gl);
1341
1342 EXPECT_CALL(gl, Flush()).Times(0);
1343 bridge->didDraw(FloatRect(0, 0, 1, 1));
1344 EXPECT_TRUE(bridge->hasRecordedDrawCommands());
1345 ::testing::Mock::VerifyAndClearExpectations(&gl);
1346
1347 EXPECT_CALL(gl, Flush()).Times(1);
1348 bridge->flushGpu();
1349 EXPECT_FALSE(bridge->hasRecordedDrawCommands());
1350 ::testing::Mock::VerifyAndClearExpectations(&gl);
1351
1352 // No flush because already flushed since last draw
1353 EXPECT_CALL(gl, Flush()).Times(0);
1354 bridge->flushGpu();
1355 EXPECT_FALSE(bridge->hasRecordedDrawCommands());
1356 ::testing::Mock::VerifyAndClearExpectations(&gl);
1357
1358 EXPECT_CALL(gl, Flush()).Times(0);
1359 bridge->didDraw(FloatRect(0, 0, 1, 1));
1360 EXPECT_TRUE(bridge->hasRecordedDrawCommands());
1361 ::testing::Mock::VerifyAndClearExpectations(&gl);
1362
1363 // Flushes recording, but not the gpu
1364 EXPECT_CALL(gl, Flush()).Times(0);
1365 bridge->flush();
1366 EXPECT_FALSE(bridge->hasRecordedDrawCommands());
1367 ::testing::Mock::VerifyAndClearExpectations(&gl);
1368
1369 EXPECT_CALL(gl, Flush()).Times(1);
1370 bridge->flushGpu();
1371 EXPECT_FALSE(bridge->hasRecordedDrawCommands());
1372 ::testing::Mock::VerifyAndClearExpectations(&gl);
1373 }
1374
1314 } // namespace blink 1375 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698