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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1294613002: Revert of SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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') | 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 "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"
31 30
32 DEFINE_bool(multiPage, false, "For document-type backends, render the source" 31 DEFINE_bool(multiPage, false, "For document-type backends, render the source"
33 " into multiple pages"); 32 " into multiple pages");
34 33
35 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { 34 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) {
36 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); 35 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size));
37 return encoded && SkInstallDiscardablePixelRef(encoded, dst); 36 return encoded && SkInstallDiscardablePixelRef(encoded, dst);
38 } 37 }
39 38
40 namespace DM { 39 namespace DM {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // let the GPU handle it. 77 // let the GPU handle it.
79 return flags.type != SinkFlags::kRaster 78 return flags.type != SinkFlags::kRaster
80 || flags.approach != SinkFlags::kDirect; 79 || flags.approach != SinkFlags::kDirect;
81 } 80 }
82 81
83 Error CodecSrc::draw(SkCanvas* canvas) const { 82 Error CodecSrc::draw(SkCanvas* canvas) const {
84 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); 83 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
85 if (!encoded) { 84 if (!encoded) {
86 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 85 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
87 } 86 }
88 SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded)); 87 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
89 if (NULL == codec.get()) { 88 if (NULL == codec.get()) {
90 // scaledCodec not supported, try normal codec 89 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str());
91 codec.reset(SkCodec::NewFromData(encoded));
92 if (NULL == codec.get()) {
93 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str() );
94 }
95 } 90 }
96 91
97 // Choose the color type to decode to 92 // Choose the color type to decode to
98 SkImageInfo decodeInfo = codec->getInfo(); 93 SkImageInfo decodeInfo = codec->getInfo();
99 SkColorType canvasColorType = canvas->imageInfo().colorType(); 94 SkColorType canvasColorType = canvas->imageInfo().colorType();
100 switch (fDstColorType) { 95 switch (fDstColorType) {
101 case kIndex8_Always_DstColorType: 96 case kIndex8_Always_DstColorType:
102 decodeInfo = codec->getInfo().makeColorType(kIndex_8_SkColorType); 97 decodeInfo = codec->getInfo().makeColorType(kIndex_8_SkColorType);
103 if (kRGB_565_SkColorType == canvasColorType) { 98 if (kRGB_565_SkColorType == canvasColorType) {
104 return Error::Nonfatal("Testing non-565 to 565 is uninteresting. "); 99 return Error::Nonfatal("Testing non-565 to 565 is uninteresting. ");
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 left += decodeInfo.width(); 439 left += decodeInfo.width();
445 } 440 }
446 return ""; 441 return "";
447 } 442 }
448 } 443 }
449 return ""; 444 return "";
450 } 445 }
451 446
452 SkISize CodecSrc::size() const { 447 SkISize CodecSrc::size() const {
453 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); 448 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
454 SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded)); 449 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
455 if (NULL == codec) { 450 if (NULL != codec) {
456 // scaledCodec not supported, try regular codec 451 SkISize size = codec->getScaledDimensions(fScale);
457 codec.reset(SkCodec::NewFromData(encoded)); 452 return size;
458 if (NULL == codec) { 453 } else {
459 return SkISize::Make(0, 0); 454 return SkISize::Make(0, 0);
460 }
461 } 455 }
462 SkISize size = codec->getScaledDimensions(fScale);
463 return size;
464 } 456 }
465 457
466 Name CodecSrc::name() const { 458 Name CodecSrc::name() const {
467 if (1.0f == fScale) { 459 if (1.0f == fScale) {
468 return SkOSPath::Basename(fPath.c_str()); 460 return SkOSPath::Basename(fPath.c_str());
469 } else { 461 } else {
470 return SkStringPrintf("%s_%.3f", SkOSPath::Basename(fPath.c_str()).c_str (), fScale); 462 return SkStringPrintf("%s_%.3f", SkOSPath::Basename(fPath.c_str()).c_str (), fScale);
471 } 463 }
472 } 464 }
473 465
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 skr.visit<void>(i, drawsAsSingletonPictures); 1075 skr.visit<void>(i, drawsAsSingletonPictures);
1084 } 1076 }
1085 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1077 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1086 1078
1087 canvas->drawPicture(macroPic); 1079 canvas->drawPicture(macroPic);
1088 return ""; 1080 return "";
1089 }); 1081 });
1090 } 1082 }
1091 1083
1092 } // namespace DM 1084 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | gyp/codec.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698