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

Unified Diff: tests/SurfaceTest.cpp

Issue 1672083002: Fix memory leaks in SurfaceClear_Gpu test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | 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 50d443d8a6f828f396a1992bc7e6559d3d0d19f2..d9138ebca73cc7a0676c32d6c5c9a84181a1060c 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -706,9 +706,10 @@ DEF_TEST(surface_rowbytes, reporter) {
#if SK_SUPPORT_GPU
-void test_surface_clear(skiatest::Reporter* reporter, SkSurface* surface,
+void test_surface_clear(skiatest::Reporter* reporter, SkSurface* surfacePtr,
std::function<GrSurface*(SkSurface*)> grSurfaceGetter,
uint32_t expectedValue) {
+ SkAutoTUnref<SkSurface> surface(surfacePtr);
if (!surface) {
ERRORF(reporter, "Could not create GPU SkSurface.");
return;
@@ -724,7 +725,7 @@ void test_surface_clear(skiatest::Reporter* reporter, SkSurface* surface,
return;
}
SkASSERT(surface->unique());
- surface->unref();
+ surface.reset();
grSurface->readPixels(0, 0, w, h, kRGBA_8888_GrPixelConfig, pixels.get());
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
@@ -747,19 +748,19 @@ void test_surface_clear(skiatest::Reporter* reporter, SkSurface* surface,
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, context) {
std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = {
- [] (SkSurface* s){ return s->getCanvas()->internal_private_accessTopLayerRenderTarget();},
+ [] (SkSurface* s){ return s->getCanvas()->internal_private_accessTopLayerRenderTarget(); },
[] (SkSurface* s){
SkBaseDevice* d =
s->getCanvas()->getDevice_just_for_deprecated_compatibility_testing();
return d->accessRenderTarget(); },
- [] (SkSurface* s){ SkImage* i = s->newImageSnapshot();
+ [] (SkSurface* s){ SkAutoTUnref<SkImage> i(s->newImageSnapshot());
return i->getTexture(); },
- [] (SkSurface* s){ SkImage* i = s->newImageSnapshot();
+ [] (SkSurface* s){ SkAutoTUnref<SkImage> i(s->newImageSnapshot());
return as_IB(i)->peekTexture(); },
};
for (auto grSurfaceGetter : grSurfaceGetters) {
for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surface}) {
- SkSurface* surface(surface_func(context, kPremul_SkAlphaType, nullptr));
+ SkSurface* surface = surface_func(context, kPremul_SkAlphaType, nullptr);
test_surface_clear(reporter, surface, grSurfaceGetter, 0x0);
}
// Wrapped RTs are *not* supposed to clear (to allow client to partially update a surface).
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698