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

Unified Diff: tests/DeferredCanvasTest.cpp

Issue 1145893007: Fixing leaky handling of SkImage in SkDeferredCanvas. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: reed feedback Created 5 years, 7 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/pipe/SkGPipeWrite.cpp ('K') | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DeferredCanvasTest.cpp
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 56b1bea93fc4d9eac54bcf664b385b8a83e9066c..60d7d0a038034e710cc16d496e2bda9b6900b0cb 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -689,6 +689,22 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
}
}
+static void TestDeferredCanvasImageFreeAfterFlush(skiatest::Reporter* reporter) {
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRasterN32Premul(100, 100));
+ SkAutoTUnref<SkImage> sourceImage(sourceSurface->newImageSnapshot());
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
+
+ canvas->drawImage(sourceImage, 0, 0, NULL);
+
+ size_t newBytesAllocated = canvas->storageAllocatedForRecording();
+ REPORTER_ASSERT(reporter, newBytesAllocated > 0);
+
+ canvas->flush();
+
+ newBytesAllocated = canvas->storageAllocatedForRecording();
+ REPORTER_ASSERT(reporter, newBytesAllocated == 0);
+}
typedef const void* PixelPtr;
// Returns an opaque pointer which, either points to a GrTexture or RAM pixel
@@ -930,6 +946,7 @@ DEF_TEST(DeferredCanvas_CPU, reporter) {
TestDeferredCanvasSkip(reporter);
TestDeferredCanvasBitmapShaderNoLeak(reporter);
TestDeferredCanvasBitmapSizeThreshold(reporter);
+ TestDeferredCanvasImageFreeAfterFlush(reporter);
TestDeferredCanvasCreateCompatibleDevice(reporter);
TestDeferredCanvasWritePixelsToSurface(reporter);
TestDeferredCanvasGetCanvasSize(reporter);
« src/pipe/SkGPipeWrite.cpp ('K') | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698