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

Unified Diff: tests/SurfaceTest.cpp

Issue 14646007: Adding public API method on SkImage for extracting the GPU texture handle. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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/SkImage_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
===================================================================
--- tests/SurfaceTest.cpp (revision 8915)
+++ tests/SurfaceTest.cpp (working copy)
@@ -146,6 +146,23 @@
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 @@
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 @@
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
}
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698