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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1415243007: Rename SkBitmapRegionDecoder and Create function (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/DMSrcSink.h ('k') | gyp/tools.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 "SkAndroidCodec.h" 10 #include "SkAndroidCodec.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return gm->getName(); 60 return gm->getName();
61 } 61 }
62 62
63 void GMSrc::modifyGrContextOptions(GrContextOptions* options) const { 63 void GMSrc::modifyGrContextOptions(GrContextOptions* options) const {
64 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr)); 64 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr));
65 gm->modifyGrContextOptions(options); 65 gm->modifyGrContextOptions(options);
66 } 66 }
67 67
68 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 68 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
69 69
70 BRDSrc::BRDSrc(Path path, SkBitmapRegionDecoderInterface::Strategy strategy, Mod e mode, 70 BRDSrc::BRDSrc(Path path, SkBitmapRegionDecoder::Strategy strategy, Mode mode,
71 CodecSrc::DstColorType dstColorType, uint32_t sampleSize) 71 CodecSrc::DstColorType dstColorType, uint32_t sampleSize)
72 : fPath(path) 72 : fPath(path)
73 , fStrategy(strategy) 73 , fStrategy(strategy)
74 , fMode(mode) 74 , fMode(mode)
75 , fDstColorType(dstColorType) 75 , fDstColorType(dstColorType)
76 , fSampleSize(sampleSize) 76 , fSampleSize(sampleSize)
77 {} 77 {}
78 78
79 bool BRDSrc::veto(SinkFlags flags) const { 79 bool BRDSrc::veto(SinkFlags flags) const {
80 // No need to test to non-raster or indirect backends. 80 // No need to test to non-raster or indirect backends.
81 return flags.type != SinkFlags::kRaster 81 return flags.type != SinkFlags::kRaster
82 || flags.approach != SinkFlags::kDirect; 82 || flags.approach != SinkFlags::kDirect;
83 } 83 }
84 84
85 static SkBitmapRegionDecoderInterface* create_brd(Path path, 85 static SkBitmapRegionDecoder* create_brd(Path path,
86 SkBitmapRegionDecoderInterface::Strategy strategy) { 86 SkBitmapRegionDecoder::Strategy strategy) {
87 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); 87 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
88 if (!encoded) { 88 if (!encoded) {
89 return NULL; 89 return NULL;
90 } 90 }
91 return SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(encoded, st rategy); 91 return SkBitmapRegionDecoder::Create(encoded, strategy);
92 } 92 }
93 93
94 Error BRDSrc::draw(SkCanvas* canvas) const { 94 Error BRDSrc::draw(SkCanvas* canvas) const {
95 SkColorType colorType = canvas->imageInfo().colorType(); 95 SkColorType colorType = canvas->imageInfo().colorType();
96 if (kRGB_565_SkColorType == colorType && 96 if (kRGB_565_SkColorType == colorType &&
97 CodecSrc::kGetFromCanvas_DstColorType != fDstColorType) { 97 CodecSrc::kGetFromCanvas_DstColorType != fDstColorType) {
98 return Error::Nonfatal("Testing non-565 to 565 is uninteresting."); 98 return Error::Nonfatal("Testing non-565 to 565 is uninteresting.");
99 } 99 }
100 switch (fDstColorType) { 100 switch (fDstColorType) {
101 case CodecSrc::kGetFromCanvas_DstColorType: 101 case CodecSrc::kGetFromCanvas_DstColorType:
102 break; 102 break;
103 case CodecSrc::kIndex8_Always_DstColorType: 103 case CodecSrc::kIndex8_Always_DstColorType:
104 colorType = kIndex_8_SkColorType; 104 colorType = kIndex_8_SkColorType;
105 break; 105 break;
106 case CodecSrc::kGrayscale_Always_DstColorType: 106 case CodecSrc::kGrayscale_Always_DstColorType:
107 colorType = kGray_8_SkColorType; 107 colorType = kGray_8_SkColorType;
108 break; 108 break;
109 } 109 }
110 110
111 SkAutoTDelete<SkBitmapRegionDecoderInterface> brd(create_brd(fPath, fStrateg y)); 111 SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath, fStrategy));
112 if (nullptr == brd.get()) { 112 if (nullptr == brd.get()) {
113 return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fP ath.c_str())); 113 return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fP ath.c_str()));
114 } 114 }
115 115
116 if (!brd->conversionSupported(colorType)) { 116 if (!brd->conversionSupported(colorType)) {
117 return Error::Nonfatal("Cannot convert to color type.\n"); 117 return Error::Nonfatal("Cannot convert to color type.\n");
118 } 118 }
119 119
120 const uint32_t width = brd->width(); 120 const uint32_t width = brd->width();
121 const uint32_t height = brd->height(); 121 const uint32_t height = brd->height();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 203 }
204 return ""; 204 return "";
205 } 205 }
206 default: 206 default:
207 SkASSERT(false); 207 SkASSERT(false);
208 return "Error: Should not be reached.\n"; 208 return "Error: Should not be reached.\n";
209 } 209 }
210 } 210 }
211 211
212 SkISize BRDSrc::size() const { 212 SkISize BRDSrc::size() const {
213 SkAutoTDelete<SkBitmapRegionDecoderInterface> brd(create_brd(fPath, fStrateg y)); 213 SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath, fStrategy));
214 if (brd) { 214 if (brd) {
215 return SkISize::Make(SkTMax(1, brd->width() / (int) fSampleSize), 215 return SkISize::Make(SkTMax(1, brd->width() / (int) fSampleSize),
216 SkTMax(1, brd->height() / (int) fSampleSize)); 216 SkTMax(1, brd->height() / (int) fSampleSize));
217 } 217 }
218 return SkISize::Make(0, 0); 218 return SkISize::Make(0, 0);
219 } 219 }
220 220
221 static SkString get_scaled_name(const Path& path, float scale) { 221 static SkString get_scaled_name(const Path& path, float scale) {
222 return SkStringPrintf("%s_%.3f", SkOSPath::Basename(path.c_str()).c_str(), s cale); 222 return SkStringPrintf("%s_%.3f", SkOSPath::Basename(path.c_str()).c_str(), s cale);
223 } 223 }
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 skr.visit<void>(i, drawsAsSingletonPictures); 1374 skr.visit<void>(i, drawsAsSingletonPictures);
1375 } 1375 }
1376 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1376 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1377 1377
1378 canvas->drawPicture(macroPic); 1378 canvas->drawPicture(macroPic);
1379 return ""; 1379 return "";
1380 }); 1380 });
1381 } 1381 }
1382 1382
1383 } // namespace DM 1383 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | gyp/tools.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698