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 "SamplePipeControllers.h" | 9 #include "SamplePipeControllers.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 | 74 |
75 bool CodecSrc::veto(SinkFlags flags) const { | 75 bool CodecSrc::veto(SinkFlags flags) const { |
76 // No need to test decoding to non-raster or indirect backend. | 76 // No need to test decoding to non-raster or indirect backend. |
77 // TODO: Once we implement GPU paths (e.g. JPEG YUV), we should use a deferr ed decode to | 77 // TODO: Once we implement GPU paths (e.g. JPEG YUV), we should use a deferr ed decode to |
78 // let the GPU handle it. | 78 // let the GPU handle it. |
79 return flags.type != SinkFlags::kRaster | 79 return flags.type != SinkFlags::kRaster |
80 || flags.approach != SinkFlags::kDirect; | 80 || flags.approach != SinkFlags::kDirect; |
81 } | 81 } |
82 | 82 |
83 Error CodecSrc::draw(SkCanvas* canvas) const { | 83 Error CodecSrc::draw(SkCanvas* canvas) const { |
84 SkDebugf("\nCodec %s\n", fPath.c_str()); | |
scroggo
2015/08/26 21:53:32
I'm guessing we do not want these print statements
| |
84 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); | 85 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); |
85 if (!encoded) { | 86 if (!encoded) { |
86 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); | 87 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); |
87 } | 88 } |
88 SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded)); | 89 SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded)); |
89 if (NULL == codec.get()) { | 90 if (NULL == codec.get()) { |
90 // scaledCodec not supported, try normal codec | 91 // scaledCodec not supported, try normal codec |
91 codec.reset(SkCodec::NewFromData(encoded)); | 92 codec.reset(SkCodec::NewFromData(encoded)); |
92 if (NULL == codec.get()) { | 93 if (NULL == codec.get()) { |
93 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str() ); | 94 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str() ); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 || flags.approach != SinkFlags::kDirect; | 489 || flags.approach != SinkFlags::kDirect; |
489 } | 490 } |
490 | 491 |
491 Error ImageSrc::draw(SkCanvas* canvas) const { | 492 Error ImageSrc::draw(SkCanvas* canvas) const { |
492 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); | 493 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); |
493 if (!encoded) { | 494 if (!encoded) { |
494 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); | 495 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); |
495 } | 496 } |
496 const SkColorType dstColorType = canvas->imageInfo().colorType(); | 497 const SkColorType dstColorType = canvas->imageInfo().colorType(); |
497 if (fDivisor == 0) { | 498 if (fDivisor == 0) { |
499 SkDebugf("\nImage %s\n", fPath.c_str()); | |
498 // Decode the full image. | 500 // Decode the full image. |
499 SkBitmap bitmap; | 501 SkBitmap bitmap; |
500 if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bit map, | 502 if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bit map, |
501 dstColorType, SkImageDecoder::kDecodeP ixels_Mode)) { | 503 dstColorType, SkImageDecoder::kDecodeP ixels_Mode)) { |
502 return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); | 504 return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); |
503 } | 505 } |
504 if (kRGB_565_SkColorType == dstColorType && !bitmap.isOpaque()) { | 506 if (kRGB_565_SkColorType == dstColorType && !bitmap.isOpaque()) { |
505 // Do not draw a bitmap with alpha to a destination without alpha. | 507 // Do not draw a bitmap with alpha to a destination without alpha. |
506 return Error::Nonfatal("Uninteresting to decode image with alpha int o 565."); | 508 return Error::Nonfatal("Uninteresting to decode image with alpha int o 565."); |
507 } | 509 } |
508 encoded.reset((SkData*)NULL); // Might as well drop this when we're don e with it. | 510 encoded.reset((SkData*)NULL); // Might as well drop this when we're don e with it. |
509 canvas->drawBitmap(bitmap, 0,0); | 511 canvas->drawBitmap(bitmap, 0,0); |
510 return ""; | 512 return ""; |
511 } | 513 } |
514 SkDebugf("\nSubset %s\n", fPath.c_str()); | |
512 // Decode subsets. This is a little involved. | 515 // Decode subsets. This is a little involved. |
513 SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(encoded)); | 516 SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(encoded)); |
514 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream.get())) ; | 517 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream.get())) ; |
515 if (!decoder) { | 518 if (!decoder) { |
516 return SkStringPrintf("Can't find a good decoder for %s.", fPath.c_str() ); | 519 return SkStringPrintf("Can't find a good decoder for %s.", fPath.c_str() ); |
517 } | 520 } |
518 stream->rewind(); | 521 stream->rewind(); |
519 int w,h; | 522 int w,h; |
520 if (!decoder->buildTileIndex(stream.detach(), &w, &h)) { | 523 if (!decoder->buildTileIndex(stream.detach(), &w, &h)) { |
521 return Error::Nonfatal("Subset decoding not supported."); | 524 return Error::Nonfatal("Subset decoding not supported."); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 skr.visit<void>(i, drawsAsSingletonPictures); | 1092 skr.visit<void>(i, drawsAsSingletonPictures); |
1090 } | 1093 } |
1091 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1094 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1092 | 1095 |
1093 canvas->drawPicture(macroPic); | 1096 canvas->drawPicture(macroPic); |
1094 return ""; | 1097 return ""; |
1095 }); | 1098 }); |
1096 } | 1099 } |
1097 | 1100 |
1098 } // namespace DM | 1101 } // namespace DM |
OLD | NEW |