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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move Jpeg Swizzler to ScanlineDecoder Created 5 years, 4 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 | « dm/DM.cpp ('k') | gyp/codec.gyp » ('j') | gyp/codec.gyp » ('J')
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 "SamplePipeControllers.h" 9 #include "SamplePipeControllers.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
11 #include "SkCommonFlags.h" 11 #include "SkCommonFlags.h"
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkDeferredCanvas.h" 13 #include "SkDeferredCanvas.h"
14 #include "SkDocument.h" 14 #include "SkDocument.h"
15 #include "SkError.h" 15 #include "SkError.h"
16 #include "SkFunction.h" 16 #include "SkFunction.h"
17 #include "SkImageGenerator.h" 17 #include "SkImageGenerator.h"
18 #include "SkMultiPictureDraw.h" 18 #include "SkMultiPictureDraw.h"
19 #include "SkNullCanvas.h" 19 #include "SkNullCanvas.h"
20 #include "SkOSFile.h" 20 #include "SkOSFile.h"
21 #include "SkPictureData.h" 21 #include "SkPictureData.h"
22 #include "SkPictureRecorder.h" 22 #include "SkPictureRecorder.h"
23 #include "SkRandom.h" 23 #include "SkRandom.h"
24 #include "SkRecordDraw.h" 24 #include "SkRecordDraw.h"
25 #include "SkRecorder.h" 25 #include "SkRecorder.h"
26 #include "SkSVGCanvas.h" 26 #include "SkSVGCanvas.h"
27 #include "SkScanlineDecoder.h" 27 #include "SkScanlineDecoder.h"
28 #include "SkStream.h" 28 #include "SkStream.h"
29 #include "SkXMLWriter.h" 29 #include "SkXMLWriter.h"
30 #include "SkScaledCodec.h"
30 31
31 DEFINE_bool(multiPage, false, "For document-type backends, render the source" 32 DEFINE_bool(multiPage, false, "For document-type backends, render the source"
32 " into multiple pages"); 33 " into multiple pages");
33 34
34 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { 35 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) {
35 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); 36 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size));
36 return encoded && SkInstallDiscardablePixelRef(encoded, dst); 37 return encoded && SkInstallDiscardablePixelRef(encoded, dst);
37 } 38 }
38 39
39 namespace DM { 40 namespace DM {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // let the GPU handle it. 78 // let the GPU handle it.
78 return flags.type != SinkFlags::kRaster 79 return flags.type != SinkFlags::kRaster
79 || flags.approach != SinkFlags::kDirect; 80 || flags.approach != SinkFlags::kDirect;
80 } 81 }
81 82
82 Error CodecSrc::draw(SkCanvas* canvas) const { 83 Error CodecSrc::draw(SkCanvas* canvas) const {
83 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); 84 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
84 if (!encoded) { 85 if (!encoded) {
85 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 86 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
86 } 87 }
87 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); 88 SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded));
88 if (NULL == codec.get()) { 89 if (NULL == codec.get()) {
89 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str()); 90 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str());
90 } 91 }
91 92
92 // Choose the color type to decode to 93 // Choose the color type to decode to
93 SkImageInfo decodeInfo = codec->getInfo(); 94 SkImageInfo decodeInfo = codec->getInfo();
94 SkColorType canvasColorType = canvas->imageInfo().colorType(); 95 SkColorType canvasColorType = canvas->imageInfo().colorType();
95 switch (fDstColorType) { 96 switch (fDstColorType) {
96 case kIndex8_Always_DstColorType: 97 case kIndex8_Always_DstColorType:
97 decodeInfo = codec->getInfo().makeColorType(kIndex_8_SkColorType); 98 decodeInfo = codec->getInfo().makeColorType(kIndex_8_SkColorType);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 left += decodeInfo.width(); 440 left += decodeInfo.width();
440 } 441 }
441 return ""; 442 return "";
442 } 443 }
443 } 444 }
444 return ""; 445 return "";
445 } 446 }
446 447
447 SkISize CodecSrc::size() const { 448 SkISize CodecSrc::size() const {
448 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); 449 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
449 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); 450 SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded));
450 if (NULL != codec) { 451 if (NULL != codec) {
451 SkISize size = codec->getScaledDimensions(fScale); 452 SkISize size = codec->getScaledDimensions(fScale);
452 return size; 453 return size;
453 } else { 454 } else {
454 return SkISize::Make(0, 0); 455 return SkISize::Make(0, 0);
455 } 456 }
456 } 457 }
457 458
458 Name CodecSrc::name() const { 459 Name CodecSrc::name() const {
459 if (1.0f == fScale) { 460 if (1.0f == fScale) {
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 skr.visit<void>(i, drawsAsSingletonPictures); 1076 skr.visit<void>(i, drawsAsSingletonPictures);
1076 } 1077 }
1077 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1078 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1078 1079
1079 canvas->drawPicture(macroPic); 1080 canvas->drawPicture(macroPic);
1080 return ""; 1081 return "";
1081 }); 1082 });
1082 } 1083 }
1083 1084
1084 } // namespace DM 1085 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | gyp/codec.gyp » ('j') | gyp/codec.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698