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

Unified Diff: tests/SurfaceTest.cpp

Issue 351373005: add SkSurface::NewRasterDirectReleaseProc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 | « src/image/SkSurface_Raster.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 3f61f89abebd21df1ca23361165a6a3bb52d1b22..610e3370f6a47133544e77aa32a67f27271809d6 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -27,13 +27,14 @@ enum SurfaceType {
kGpuScratch_SurfaceType,
};
-static const int gSurfaceSize = 10;
-static SkPMColor gSurfaceStorage[gSurfaceSize * gSurfaceSize];
+static void release_storage(void* pixels, void* context) {
+ SkASSERT(pixels == context);
+ sk_free(pixels);
+}
static SkSurface* createSurface(SurfaceType surfaceType, GrContext* context,
SkImageInfo* requestedInfo = NULL) {
- static const SkImageInfo info = SkImageInfo::MakeN32Premul(gSurfaceSize,
- gSurfaceSize);
+ static const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
if (requestedInfo) {
*requestedInfo = info;
@@ -42,9 +43,12 @@ static SkSurface* createSurface(SurfaceType surfaceType, GrContext* context,
switch (surfaceType) {
case kRaster_SurfaceType:
return SkSurface::NewRaster(info);
- case kRasterDirect_SurfaceType:
- return SkSurface::NewRasterDirect(info, gSurfaceStorage,
- info.minRowBytes());
+ case kRasterDirect_SurfaceType: {
+ const size_t rowBytes = info.minRowBytes();
+ void* storage = sk_malloc_throw(info.getSafeSize(rowBytes));
+ return SkSurface::NewRasterDirectReleaseProc(info, storage, rowBytes,
+ release_storage, storage);
+ }
case kGpu_SurfaceType:
#if SK_SUPPORT_GPU
return context ? SkSurface::NewRenderTarget(context, info) : NULL;
« no previous file with comments | « src/image/SkSurface_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698