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

Side by Side Diff: tests/ImageDecodingTest.cpp

Issue 1336353003: fix leaked generator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 "Resources.h" 8 #include "Resources.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 /** 430 /**
431 * A test for the SkDecodingImageGenerator::Create 431 * A test for the SkDecodingImageGenerator::Create
432 */ 432 */
433 DEF_TEST(ImprovedBitmapFactory, reporter) { 433 DEF_TEST(ImprovedBitmapFactory, reporter) {
434 SkString pngFilename = GetResourcePath("randPixels.png"); 434 SkString pngFilename = GetResourcePath("randPixels.png");
435 SkAutoTDelete<SkStreamRewindable> stream(SkStream::NewFromFile(pngFilename.c _str())); 435 SkAutoTDelete<SkStreamRewindable> stream(SkStream::NewFromFile(pngFilename.c _str()));
436 if (sk_exists(pngFilename.c_str())) { 436 if (sk_exists(pngFilename.c_str())) {
437 // example of how Android will do this inside their BitmapFactory 437 // example of how Android will do this inside their BitmapFactory
438 SkDecodingImageGenerator::Options opts(1, true, kN32_SkColorType); 438 SkDecodingImageGenerator::Options opts(1, true, kN32_SkColorType);
439 SkBitmap bm; 439 SkBitmap bm;
440 SkImageGenerator* gen = SkDecodingImageGenerator::Create(stream, opts); 440 SkAutoTDelete<SkImageGenerator> gen(SkDecodingImageGenerator::Create(str eam.detach(),
441 opt s));
441 REPORTER_ASSERT(reporter, gen->tryGenerateBitmap(&bm)); 442 REPORTER_ASSERT(reporter, gen->tryGenerateBitmap(&bm));
442 } 443 }
443 } 444 }
444 445
445 //////////////////////////////////////////////////////////////////////////////// 446 ////////////////////////////////////////////////////////////////////////////////
446 447
447 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX) 448 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
448 static inline bool check_rounding(int value, int dividend, int divisor) { 449 static inline bool check_rounding(int value, int dividend, int divisor) {
449 // returns true if the value is greater than floor(dividend/divisor) 450 // returns true if the value is greater than floor(dividend/divisor)
450 // and less than SkNextPow2(ceil(dividend - divisor)) 451 // and less than SkNextPow2(ceil(dividend - divisor))
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 new SingleAllocator((void*)pixels.get(), sizeof(uint16_t) * pixelCou nt)); 723 new SingleAllocator((void*)pixels.get(), sizeof(uint16_t) * pixelCou nt));
723 decoder->setAllocator(allocator); 724 decoder->setAllocator(allocator);
724 decoder->setSampleSize(2); 725 decoder->setSampleSize(2);
725 SkBitmap bitmap; 726 SkBitmap bitmap;
726 bool success = decoder->decode(stream, &bitmap, kRGB_565_SkColorType, 727 bool success = decoder->decode(stream, &bitmap, kRGB_565_SkColorType,
727 SkImageDecoder::kDecodePixels_Mode) != SkImag eDecoder::kFailure; 728 SkImageDecoder::kDecodePixels_Mode) != SkImag eDecoder::kFailure;
728 REPORTER_ASSERT(r, success); 729 REPORTER_ASSERT(r, success);
729 REPORTER_ASSERT(r, !allocator->ready()); // Decoder used correct memory 730 REPORTER_ASSERT(r, !allocator->ready()); // Decoder used correct memory
730 REPORTER_ASSERT(r, sentinal == pixels[pixelCount]); 731 REPORTER_ASSERT(r, sentinal == pixels[pixelCount]);
731 } 732 }
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