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

Unified Diff: tests/SurfaceTest.cpp

Issue 1219793002: augment surface tests to check legacy genID (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | 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 817906070ad62183e8264efe55e08e348dfbe61b..42f4fcc3a4acbc9d7e9f2d10076a7f75775a1d4f 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -223,26 +223,41 @@ struct ReleaseDataContext {
}
};
+// May we (soon) eliminate the need to keep testing this, by hiding the bloody device!
+#include "SkDevice.h"
+static uint32_t get_legacy_gen_id(SkSurface* surf) {
+ SkBaseDevice* device = surf->getCanvas()->getDevice_just_for_deprecated_compatibility_testing();
+ return device->accessBitmap(false).getGenerationID();
+}
+
static void test_texture_handle(skiatest::Reporter* reporter, SkSurface* surf) {
SkAutoTUnref<SkImage> image0(surf->newImageSnapshot());
+ const uint32_t genID0 = get_legacy_gen_id(surf);
GrBackendObject obj = surf->getTextureHandle(SkSurface::kFlushRead_TextureHandleAccess);
REPORTER_ASSERT(reporter, obj != 0);
SkAutoTUnref<SkImage> image1(surf->newImageSnapshot());
+ const uint32_t genID1 = get_legacy_gen_id(surf);
// just read access should not affect the snapshot
REPORTER_ASSERT(reporter, image0->uniqueID() == image1->uniqueID());
+ REPORTER_ASSERT(reporter, genID0 == genID1);
obj = surf->getTextureHandle(SkSurface::kFlushWrite_TextureHandleAccess);
REPORTER_ASSERT(reporter, obj != 0);
SkAutoTUnref<SkImage> image2(surf->newImageSnapshot());
+ const uint32_t genID2 = get_legacy_gen_id(surf);
// expect a new image, since we claimed we would write
REPORTER_ASSERT(reporter, image0->uniqueID() != image2->uniqueID());
+ REPORTER_ASSERT(reporter, genID0 != genID2);
obj = surf->getTextureHandle(SkSurface::kDiscardWrite_TextureHandleAccess);
REPORTER_ASSERT(reporter, obj != 0);
SkAutoTUnref<SkImage> image3(surf->newImageSnapshot());
+ const uint32_t genID3 = get_legacy_gen_id(surf);
// expect a new(er) image, since we claimed we would write
REPORTER_ASSERT(reporter, image0->uniqueID() != image3->uniqueID());
REPORTER_ASSERT(reporter, image2->uniqueID() != image3->uniqueID());
+ REPORTER_ASSERT(reporter, genID0 != genID3);
+ REPORTER_ASSERT(reporter, genID2 != genID3);
}
static SkImage* create_image(skiatest::Reporter* reporter,
« 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