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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1638463002: Fix leak of SkImageGenerator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 2015 Google Inc. 2 * Copyright 2015 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 "DMSrcSink.h" 8 #include "DMSrcSink.h"
9 #include "SkAndroidCodec.h" 9 #include "SkAndroidCodec.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 272 }
273 273
274 // FIXME: Currently we cannot draw unpremultiplied sources. 274 // FIXME: Currently we cannot draw unpremultiplied sources.
275 if (decodeInfo->alphaType() == kUnpremul_SkAlphaType) { 275 if (decodeInfo->alphaType() == kUnpremul_SkAlphaType) {
276 *decodeInfo = decodeInfo->makeAlphaType(kPremul_SkAlphaType); 276 *decodeInfo = decodeInfo->makeAlphaType(kPremul_SkAlphaType);
277 } 277 }
278 return true; 278 return true;
279 } 279 }
280 280
281 Error test_gen(SkCanvas* canvas, SkData* data) { 281 Error test_gen(SkCanvas* canvas, SkData* data) {
282 SkImageGenerator* gen = SkCodecImageGenerator::NewFromEncodedCodec(data); 282 SkAutoTDelete<SkImageGenerator> gen = SkCodecImageGenerator::NewFromEncodedC odec(data);
283 if (!gen) { 283 if (!gen) {
284 return "Could not create image generator."; 284 return "Could not create image generator.";
285 } 285 }
286 286
287 // FIXME: The gpu backend does not draw kGray sources correctly. (skbug.com/ 4822) 287 // FIXME: The gpu backend does not draw kGray sources correctly. (skbug.com/ 4822)
288 // Currently, we will avoid creating a CodecSrc for this case (see DM.cpp). 288 // Currently, we will avoid creating a CodecSrc for this case (see DM.cpp).
289 SkASSERT(kGray_8_SkColorType != gen->getInfo().colorType()); 289 SkASSERT(kGray_8_SkColorType != gen->getInfo().colorType());
290 290
291 if (kOpaque_SkAlphaType != gen->getInfo().alphaType() && 291 if (kOpaque_SkAlphaType != gen->getInfo().alphaType() &&
292 kRGB_565_SkColorType == canvas->imageInfo().colorType()) { 292 kRGB_565_SkColorType == canvas->imageInfo().colorType()) {
293 return Error::Nonfatal("Skip testing non-opaque images to 565."); 293 return Error::Nonfatal("Skip testing non-opaque images to 565.");
294 } 294 }
295 295
296 SkAutoTDelete<SkImage> image(SkImage::NewFromGenerator(gen, nullptr)); 296 SkAutoTDelete<SkImage> image(SkImage::NewFromGenerator(gen.detach(), nullptr ));
djsollen 2016/01/25 18:34:07 why do you need to detach here? Does SkImage prom
297 if (!image) { 297 if (!image) {
298 return "Could not create image from codec image generator."; 298 return "Could not create image from codec image generator.";
299 } 299 }
300 300
301 canvas->drawImage(image, 0, 0); 301 canvas->drawImage(image, 0, 0);
302 return ""; 302 return "";
303 } 303 }
304 304
305 Error CodecSrc::draw(SkCanvas* canvas) const { 305 Error CodecSrc::draw(SkCanvas* canvas) const {
306 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); 306 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 skr.visit<void>(i, drawsAsSingletonPictures); 1345 skr.visit<void>(i, drawsAsSingletonPictures);
1346 } 1346 }
1347 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1347 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1348 1348
1349 canvas->drawPicture(macroPic); 1349 canvas->drawPicture(macroPic);
1350 return check_against_reference(bitmap, src, fSink); 1350 return check_against_reference(bitmap, src, fSink);
1351 }); 1351 });
1352 } 1352 }
1353 1353
1354 } // namespace DM 1354 } // namespace DM
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