aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-02-05 13:47:06 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-05 13:47:06 -0800
commit2fba80912027999b560a97a832948c37ab36acfe (patch)
treed34540d83732491d99773a1d7667b8ff3bf7f45f /tests
parent7fec91ce6660190f8d7c5eb6f3061e4550cc672b (diff)
Fix memory leaks in SurfaceClear_Gpu test
Diffstat (limited to 'tests')
-rw-r--r--tests/SurfaceTest.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 50d443d8a6..d9138ebca7 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).