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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 872183002: Don't leak image in Surface test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 SkImageInfo info = SkImageInfo::MakeN32Premul(8,8); 475 SkImageInfo info = SkImageInfo::MakeN32Premul(8,8);
476 for (int i = 0; i < 2; ++i) { 476 for (int i = 0; i < 2; ++i) {
477 SkSurface::Budgeted sbudgeted = i ? SkSurface::kYes_Budgeted : SkSurface ::kNo_Budgeted; 477 SkSurface::Budgeted sbudgeted = i ? SkSurface::kYes_Budgeted : SkSurface ::kNo_Budgeted;
478 for (int j = 0; j < 2; ++j) { 478 for (int j = 0; j < 2; ++j) {
479 SkSurface::Budgeted ibudgeted = j ? SkSurface::kYes_Budgeted : SkSur face::kNo_Budgeted; 479 SkSurface::Budgeted ibudgeted = j ? SkSurface::kYes_Budgeted : SkSur face::kNo_Budgeted;
480 SkAutoTUnref<SkSurface> 480 SkAutoTUnref<SkSurface>
481 surface(SkSurface::NewRenderTarget(context, sbudgeted, info, 0)) ; 481 surface(SkSurface::NewRenderTarget(context, sbudgeted, info, 0)) ;
482 SkASSERT(surface); 482 SkASSERT(surface);
483 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); 483 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface));
484 484
485 SkImage* image = surface->newImageSnapshot(ibudgeted); 485 SkAutoTUnref<SkImage> image(surface->newImageSnapshot(ibudgeted));
tfarina 2015/01/24 22:03:11 lgtm
486 486
487 // Initially the image shares a texture with the surface, and the su rface decides 487 // Initially the image shares a texture with the surface, and the su rface decides
488 // whether it is budgeted or not. 488 // whether it is budgeted or not.
489 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); 489 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface));
490 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(image)); 490 REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(image));
491 491
492 // Now trigger copy-on-write 492 // Now trigger copy-on-write
493 surface->getCanvas()->clear(SK_ColorBLUE); 493 surface->getCanvas()->clear(SK_ColorBLUE);
494 494
495 // They don't share a texture anymore. They should each have made th eir own budget 495 // They don't share a texture anymore. They should each have made th eir own budget
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode); 570 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
571 TestGetTexture(reporter, kGpu_SurfaceType, context); 571 TestGetTexture(reporter, kGpu_SurfaceType, context);
572 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); 572 TestGetTexture(reporter, kGpuScratch_SurfaceType, context);
573 test_empty_surface(reporter, context); 573 test_empty_surface(reporter, context);
574 test_surface_budget(reporter, context); 574 test_surface_budget(reporter, context);
575 } 575 }
576 } 576 }
577 } 577 }
578 #endif 578 #endif
579 } 579 }
OLDNEW
« 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