Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |