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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1990543002: Delete SkBitmapRegionCanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Preserve old name of tests Created 4 years, 7 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/DMSrcSink.h ('k') | gyp/codec_android.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 "SkAndroidCodec.h" 9 #include "SkAndroidCodec.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return gm->getName(); 64 return gm->getName();
65 } 65 }
66 66
67 void GMSrc::modifyGrContextOptions(GrContextOptions* options) const { 67 void GMSrc::modifyGrContextOptions(GrContextOptions* options) const {
68 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr)); 68 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr));
69 gm->modifyGrContextOptions(options); 69 gm->modifyGrContextOptions(options);
70 } 70 }
71 71
72 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 72 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
73 73
74 BRDSrc::BRDSrc(Path path, SkBitmapRegionDecoder::Strategy strategy, Mode mode, 74 BRDSrc::BRDSrc(Path path, Mode mode, CodecSrc::DstColorType dstColorType, uint32 _t sampleSize)
75 CodecSrc::DstColorType dstColorType, uint32_t sampleSize)
76 : fPath(path) 75 : fPath(path)
77 , fStrategy(strategy)
78 , fMode(mode) 76 , fMode(mode)
79 , fDstColorType(dstColorType) 77 , fDstColorType(dstColorType)
80 , fSampleSize(sampleSize) 78 , fSampleSize(sampleSize)
81 {} 79 {}
82 80
83 bool BRDSrc::veto(SinkFlags flags) const { 81 bool BRDSrc::veto(SinkFlags flags) const {
84 // No need to test to non-raster or indirect backends. 82 // No need to test to non-raster or indirect backends.
85 return flags.type != SinkFlags::kRaster 83 return flags.type != SinkFlags::kRaster
86 || flags.approach != SinkFlags::kDirect; 84 || flags.approach != SinkFlags::kDirect;
87 } 85 }
88 86
89 static SkBitmapRegionDecoder* create_brd(Path path, 87 static SkBitmapRegionDecoder* create_brd(Path path) {
90 SkBitmapRegionDecoder::Strategy strategy) {
91 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); 88 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
92 if (!encoded) { 89 if (!encoded) {
93 return NULL; 90 return NULL;
94 } 91 }
95 return SkBitmapRegionDecoder::Create(encoded, strategy); 92 return SkBitmapRegionDecoder::Create(encoded, SkBitmapRegionDecoder::kAndroi dCodec_Strategy);
96 } 93 }
97 94
98 Error BRDSrc::draw(SkCanvas* canvas) const { 95 Error BRDSrc::draw(SkCanvas* canvas) const {
99 SkColorType colorType = canvas->imageInfo().colorType(); 96 SkColorType colorType = canvas->imageInfo().colorType();
100 if (kRGB_565_SkColorType == colorType && 97 if (kRGB_565_SkColorType == colorType &&
101 CodecSrc::kGetFromCanvas_DstColorType != fDstColorType) { 98 CodecSrc::kGetFromCanvas_DstColorType != fDstColorType) {
102 return Error::Nonfatal("Testing non-565 to 565 is uninteresting."); 99 return Error::Nonfatal("Testing non-565 to 565 is uninteresting.");
103 } 100 }
104 switch (fDstColorType) { 101 switch (fDstColorType) {
105 case CodecSrc::kGetFromCanvas_DstColorType: 102 case CodecSrc::kGetFromCanvas_DstColorType:
106 break; 103 break;
107 case CodecSrc::kIndex8_Always_DstColorType: 104 case CodecSrc::kIndex8_Always_DstColorType:
108 colorType = kIndex_8_SkColorType; 105 colorType = kIndex_8_SkColorType;
109 break; 106 break;
110 case CodecSrc::kGrayscale_Always_DstColorType: 107 case CodecSrc::kGrayscale_Always_DstColorType:
111 colorType = kGray_8_SkColorType; 108 colorType = kGray_8_SkColorType;
112 break; 109 break;
113 default: 110 default:
114 SkASSERT(false); 111 SkASSERT(false);
115 break; 112 break;
116 } 113 }
117 114
118 SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath, fStrategy)); 115 SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath));
119 if (nullptr == brd.get()) { 116 if (nullptr == brd.get()) {
120 return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fP ath.c_str())); 117 return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fP ath.c_str()));
121 } 118 }
122 119
123 if (!brd->conversionSupported(colorType)) { 120 if (!brd->conversionSupported(colorType)) {
124 return Error::Nonfatal("Cannot convert to color type."); 121 return Error::Nonfatal("Cannot convert to color type.");
125 } 122 }
126 123
127 const uint32_t width = brd->width(); 124 const uint32_t width = brd->width();
128 const uint32_t height = brd->height(); 125 const uint32_t height = brd->height();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 207 }
211 return ""; 208 return "";
212 } 209 }
213 default: 210 default:
214 SkASSERT(false); 211 SkASSERT(false);
215 return "Error: Should not be reached."; 212 return "Error: Should not be reached.";
216 } 213 }
217 } 214 }
218 215
219 SkISize BRDSrc::size() const { 216 SkISize BRDSrc::size() const {
220 SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath, fStrategy)); 217 SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath));
221 if (brd) { 218 if (brd) {
222 return SkISize::Make(SkTMax(1, brd->width() / (int) fSampleSize), 219 return SkISize::Make(SkTMax(1, brd->width() / (int) fSampleSize),
223 SkTMax(1, brd->height() / (int) fSampleSize)); 220 SkTMax(1, brd->height() / (int) fSampleSize));
224 } 221 }
225 return SkISize::Make(0, 0); 222 return SkISize::Make(0, 0);
226 } 223 }
227 224
228 static SkString get_scaled_name(const Path& path, float scale) { 225 static SkString get_scaled_name(const Path& path, float scale) {
229 return SkStringPrintf("%s_%.3f", SkOSPath::Basename(path.c_str()).c_str(), s cale); 226 return SkStringPrintf("%s_%.3f", SkOSPath::Basename(path.c_str()).c_str(), s cale);
230 } 227 }
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 skr.visit(i, drawsAsSingletonPictures); 1459 skr.visit(i, drawsAsSingletonPictures);
1463 } 1460 }
1464 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); 1461 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1465 1462
1466 canvas->drawPicture(macroPic); 1463 canvas->drawPicture(macroPic);
1467 return check_against_reference(bitmap, src, fSink); 1464 return check_against_reference(bitmap, src, fSink);
1468 }); 1465 });
1469 } 1466 }
1470 1467
1471 } // namespace DM 1468 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | gyp/codec_android.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698