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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h ('k') | 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/Canvas2DLayerBridgeTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
index aeb1bfd13c85b47a06248d09832ca1b62aff095d..40a2e40a1478e55a90bd77cace6342b8c112680c 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
@@ -1311,4 +1311,65 @@ TEST_F(Canvas2DLayerBridgeTest, DISABLED_DeleteIOSurfaceAfterTeardown)
EXPECT_EQ(1u, gl.destroyImageCount());
}
+class FlushMockGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
+ public:
+ MOCK_METHOD0(Flush, void());
+};
+
+TEST_F(Canvas2DLayerBridgeTest, NoUnnecessaryFlushes) {
+ FlushMockGLES2Interface gl;
+ std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
+ WTF::wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
+
+ EXPECT_CALL(gl, Flush()).Times(0);
+ Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
+ std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
+ Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr,
+ kN32_SkColorType)));
+ EXPECT_FALSE(bridge->hasRecordedDrawCommands());
+ ::testing::Mock::VerifyAndClearExpectations(&gl);
+
+ EXPECT_CALL(gl, Flush()).Times(0);
+ bridge->didDraw(FloatRect(0, 0, 1, 1));
+ EXPECT_TRUE(bridge->hasRecordedDrawCommands());
+ ::testing::Mock::VerifyAndClearExpectations(&gl);
+
+ EXPECT_CALL(gl, Flush()).Times(1);
+ bridge->flushGpu();
+ EXPECT_FALSE(bridge->hasRecordedDrawCommands());
+ ::testing::Mock::VerifyAndClearExpectations(&gl);
+
+ EXPECT_CALL(gl, Flush()).Times(0);
+ bridge->didDraw(FloatRect(0, 0, 1, 1));
+ EXPECT_TRUE(bridge->hasRecordedDrawCommands());
+ ::testing::Mock::VerifyAndClearExpectations(&gl);
+
+ EXPECT_CALL(gl, Flush()).Times(1);
+ bridge->flushGpu();
+ EXPECT_FALSE(bridge->hasRecordedDrawCommands());
+ ::testing::Mock::VerifyAndClearExpectations(&gl);
+
+ // No flush because already flushed since last draw
+ EXPECT_CALL(gl, Flush()).Times(0);
+ bridge->flushGpu();
+ EXPECT_FALSE(bridge->hasRecordedDrawCommands());
+ ::testing::Mock::VerifyAndClearExpectations(&gl);
+
+ EXPECT_CALL(gl, Flush()).Times(0);
+ bridge->didDraw(FloatRect(0, 0, 1, 1));
+ EXPECT_TRUE(bridge->hasRecordedDrawCommands());
+ ::testing::Mock::VerifyAndClearExpectations(&gl);
+
+ // Flushes recording, but not the gpu
+ EXPECT_CALL(gl, Flush()).Times(0);
+ bridge->flush();
+ EXPECT_FALSE(bridge->hasRecordedDrawCommands());
+ ::testing::Mock::VerifyAndClearExpectations(&gl);
+
+ EXPECT_CALL(gl, Flush()).Times(1);
+ bridge->flushGpu();
+ EXPECT_FALSE(bridge->hasRecordedDrawCommands());
+ ::testing::Mock::VerifyAndClearExpectations(&gl);
+}
+
} // namespace blink
« 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