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

Unified Diff: tests/SurfaceTest.cpp

Issue 1276713002: SkSurface copy-on-write can yield stale GPU render targets. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: comment type Created 5 years, 4 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 | « src/image/SkSurface_Gpu.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SurfaceTest.cpp
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 3d6e59ed356572f8bf0ec632c90df3a7f05913ee..18fbfe94719cd5798edc3d17828d05e9a9b367d2 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -621,6 +621,19 @@ static void test_snap_alphatype(skiatest::Reporter* reporter, GrContextFactory*
}
}
+static void test_backend_cow(skiatest::Reporter* reporter, SkSurface* surface,
+ SkSurface::BackendHandleAccess mode,
+ GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) {
+ GrBackendObject obj1 = func(surface, mode);
+ SkAutoTUnref<SkImage> snap1(surface->newImageSnapshot());
+
+ GrBackendObject obj2 = func(surface, mode);
+ SkAutoTUnref<SkImage> snap2(surface->newImageSnapshot());
+
+ // If the access mode triggers CoW, then the backend objects should reflect it.
+ REPORTER_ASSERT(reporter, (obj1 == obj2) == (snap1 == snap2));
+}
+
static void TestSurfaceCopyOnWrite(skiatest::Reporter* reporter, SurfaceType surfaceType,
GrContext* context) {
// Verify that the right canvas commands trigger a copy on write
@@ -699,6 +712,28 @@ static void TestSurfaceCopyOnWrite(skiatest::Reporter* reporter, SurfaceType sur
testPaint))
EXPECT_COPY_ON_WRITE(drawTextOnPath(testText.c_str(), testText.size(), testPath, NULL, \
testPaint))
+
+ const SkSurface::BackendHandleAccess accessModes[] = {
+ SkSurface::kFlushRead_BackendHandleAccess,
+ SkSurface::kFlushWrite_BackendHandleAccess,
+ SkSurface::kDiscardWrite_BackendHandleAccess,
+ };
+
+ for (auto access : accessModes) {
+ test_backend_cow(reporter, surface, access,
+ [](SkSurface* s, SkSurface::BackendHandleAccess a) -> GrBackendObject {
+ return s->getTextureHandle(a);
+ });
+
+ test_backend_cow(reporter, surface, access,
+ [](SkSurface* s, SkSurface::BackendHandleAccess a) -> GrBackendObject {
+ GrBackendObject result;
+ if (!s->getRenderTargetHandle(&result, a)) {
+ return 0;
+ }
+ return result;
+ });
+ }
}
static void TestSurfaceWritableAfterSnapshotRelease(skiatest::Reporter* reporter,
« no previous file with comments | « src/image/SkSurface_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698