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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1577853004: Add CodecZeroInit test to DMSrcSink (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 4 years, 11 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') | no next file » | 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 int* colorCountPtr = nullptr; 309 int* colorCountPtr = nullptr;
310 int maxColors = 256; 310 int maxColors = 256;
311 if (kIndex_8_SkColorType == decodeInfo.colorType()) { 311 if (kIndex_8_SkColorType == decodeInfo.colorType()) {
312 SkPMColor colors[256]; 312 SkPMColor colors[256];
313 colorTable.reset(new SkColorTable(colors, maxColors)); 313 colorTable.reset(new SkColorTable(colors, maxColors));
314 colorPtr = const_cast<SkPMColor*>(colorTable->readColors()); 314 colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
315 colorCountPtr = &maxColors; 315 colorCountPtr = &maxColors;
316 } 316 }
317 317
318 SkBitmap bitmap; 318 SkBitmap bitmap;
319 if (!bitmap.tryAllocPixels(decodeInfo, nullptr, colorTable.get())) { 319 SkPixelRefFactory* factory = nullptr;
320 SkMallocPixelRef::ZeroedPRFactory zeroFactory;
321 SkCodec::Options options;
322 if (kCodecZeroInit_Mode == fMode) {
323 factory = &zeroFactory;
324 options.fZeroInitialized = SkCodec::kYes_ZeroInitialized;
325 }
326 if (!bitmap.tryAllocPixels(decodeInfo, factory, colorTable.get())) {
320 return SkStringPrintf("Image(%s) is too large (%d x %d)", fPath.c_str(), 327 return SkStringPrintf("Image(%s) is too large (%d x %d)", fPath.c_str(),
321 decodeInfo.width(), decodeInfo.height()); 328 decodeInfo.width(), decodeInfo.height());
322 } 329 }
323 330
324 switch (fMode) { 331 switch (fMode) {
332 case kCodecZeroInit_Mode:
325 case kCodec_Mode: { 333 case kCodec_Mode: {
326 switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowB ytes(), nullptr, 334 switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowB ytes(), &options,
327 colorPtr, colorCountPtr)) { 335 colorPtr, colorCountPtr)) {
328 case SkCodec::kSuccess: 336 case SkCodec::kSuccess:
329 // We consider incomplete to be valid, since we should still decode what is 337 // We consider incomplete to be valid, since we should still decode what is
330 // available. 338 // available.
331 case SkCodec::kIncompleteInput: 339 case SkCodec::kIncompleteInput:
332 break; 340 break;
333 case SkCodec::kInvalidConversion: 341 case SkCodec::kInvalidConversion:
334 return Error::Nonfatal("Incompatible colortype conversion"); 342 return Error::Nonfatal("Incompatible colortype conversion");
335 default: 343 default:
336 // Everything else is considered a failure. 344 // Everything else is considered a failure.
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 skr.visit<void>(i, drawsAsSingletonPictures); 1309 skr.visit<void>(i, drawsAsSingletonPictures);
1302 } 1310 }
1303 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1311 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1304 1312
1305 canvas->drawPicture(macroPic); 1313 canvas->drawPicture(macroPic);
1306 return check_against_reference(bitmap, src, fSink); 1314 return check_against_reference(bitmap, src, fSink);
1307 }); 1315 });
1308 } 1316 }
1309 1317
1310 } // namespace DM 1318 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698