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

Unified Diff: tests/SurfaceTest.cpp

Issue 1220733007: add ability to get FBO ID to Surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks 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
« src/image/SkSurface_Gpu.cpp ('K') | « 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 42f4fcc3a4acbc9d7e9f2d10076a7f75775a1d4f..6871cbcf6d4af5e8423a174f19a312479e57c4a9 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -230,10 +230,11 @@ static uint32_t get_legacy_gen_id(SkSurface* surf) {
return device->accessBitmap(false).getGenerationID();
}
-static void test_texture_handle(skiatest::Reporter* reporter, SkSurface* surf) {
+template <class F>
+static void test_backend_handle(skiatest::Reporter* reporter, SkSurface* surf, F f) {
SkAutoTUnref<SkImage> image0(surf->newImageSnapshot());
const uint32_t genID0 = get_legacy_gen_id(surf);
- GrBackendObject obj = surf->getTextureHandle(SkSurface::kFlushRead_TextureHandleAccess);
+ GrBackendObject obj = f(surf, SkSurface::kFlushRead_BackendHandleAccess);
REPORTER_ASSERT(reporter, obj != 0);
SkAutoTUnref<SkImage> image1(surf->newImageSnapshot());
const uint32_t genID1 = get_legacy_gen_id(surf);
@@ -241,7 +242,7 @@ static void test_texture_handle(skiatest::Reporter* reporter, SkSurface* surf) {
REPORTER_ASSERT(reporter, image0->uniqueID() == image1->uniqueID());
REPORTER_ASSERT(reporter, genID0 == genID1);
- obj = surf->getTextureHandle(SkSurface::kFlushWrite_TextureHandleAccess);
+ obj = f(surf, SkSurface::kFlushWrite_BackendHandleAccess);
REPORTER_ASSERT(reporter, obj != 0);
SkAutoTUnref<SkImage> image2(surf->newImageSnapshot());
const uint32_t genID2 = get_legacy_gen_id(surf);
@@ -249,7 +250,7 @@ static void test_texture_handle(skiatest::Reporter* reporter, SkSurface* surf) {
REPORTER_ASSERT(reporter, image0->uniqueID() != image2->uniqueID());
REPORTER_ASSERT(reporter, genID0 != genID2);
- obj = surf->getTextureHandle(SkSurface::kDiscardWrite_TextureHandleAccess);
+ obj = f(surf, SkSurface::kDiscardWrite_BackendHandleAccess);
REPORTER_ASSERT(reporter, obj != 0);
SkAutoTUnref<SkImage> image3(surf->newImageSnapshot());
const uint32_t genID3 = get_legacy_gen_id(surf);
@@ -286,8 +287,16 @@ static SkImage* create_image(skiatest::Reporter* reporter,
SkAutoTUnref<SkSurface> surf(
SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0));
surf->getCanvas()->clear(color);
- // test our backing texture while were here...
- test_texture_handle(reporter, surf);
+ // test our backing texture / rendertarget while were here...
+ test_backend_handle(reporter, surf,
+ [](SkSurface* surf, SkSurface::BackendHandleAccess access) -> GrBackendObject {
+ return surf->getTextureHandle(access); });
+ test_backend_handle(reporter, surf,
+ [](SkSurface* surf, SkSurface::BackendHandleAccess access) -> GrBackendObject {
+ GrBackendObject obj;
+ bool result = surf->getRenderTargetHandle(&obj, access);
+ SkASSERT(result);
+ return obj; });
// redraw so our returned image looks as expected.
surf->getCanvas()->clear(color);
return surf->newImageSnapshot();
« src/image/SkSurface_Gpu.cpp ('K') | « src/image/SkSurface_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698