aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-01 22:38:16 +0000
committerGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-01 22:38:16 +0000
commitda90474b5fcc019fb0971d12360bd05213ad4dc8 (patch)
treee14995c17b2c7a84b94a9b49a804359ef82d2e89 /tests
parent3dab1ff4a3b832678cfde99a2f14730bef83caab (diff)
Adding public API method on SkImage for extracting the GPU texture handle.
TEST=Surface unit test Review URL: https://codereview.chromium.org/14646007 git-svn-id: http://skia.googlecode.com/svn/trunk@8945 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/SurfaceTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 1197d4b427..d83f2e1f63 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -146,6 +146,23 @@ static void TestSurfaceWritableAfterSnapshotRelease(skiatest::Reporter* reporter
surface->newImageSnapshot()->unref(); // Create and destroy SkImage
canvas->clear(2);
}
+
+static void TestGetTexture(skiatest::Reporter* reporter,
+ SurfaceType surfaceType,
+ GrContext* context) {
+ SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context));
+ SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
+ GrTexture* texture = image->getTexture();
+ if (surfaceType == kGpu_SurfaceType) {
+ REPORTER_ASSERT(reporter, NULL != texture);
+ REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle());
+ } else {
+ REPORTER_ASSERT(reporter, NULL == texture);
+ }
+ surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode);
+ REPORTER_ASSERT(reporter, image->getTexture() == texture);
+}
+
static void TestSurfaceNoCanvas(skiatest::Reporter* reporter,
SurfaceType surfaceType,
GrContext* context,
@@ -185,6 +202,8 @@ static void TestSurface(skiatest::Reporter* reporter, GrContextFactory* factory)
TestSurfaceWritableAfterSnapshotRelease(reporter, kPicture_SurfaceType, NULL);
TestSurfaceNoCanvas(reporter, kRaster_SurfaceType, NULL, SkSurface::kDiscard_ContentChangeMode);
TestSurfaceNoCanvas(reporter, kRaster_SurfaceType, NULL, SkSurface::kRetain_ContentChangeMode);
+ TestGetTexture(reporter, kRaster_SurfaceType, NULL);
+ TestGetTexture(reporter, kPicture_SurfaceType, NULL);
#if SK_SUPPORT_GPU
if (NULL != factory) {
GrContext* context = factory->get(GrContextFactory::kNative_GLContextType);
@@ -192,6 +211,7 @@ static void TestSurface(skiatest::Reporter* reporter, GrContextFactory* factory)
TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, context);
TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode);
TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
+ TestGetTexture(reporter, kGpu_SurfaceType, context);
}
#endif
}