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

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: 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
« dm/DMSrcSink.h ('K') | « 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (!bitmap.tryAllocPixels(decodeInfo, nullptr, colorTable.get())) {
320 return SkStringPrintf("Image(%s) is too large (%d x %d)", fPath.c_str(), 320 return SkStringPrintf("Image(%s) is too large (%d x %d)", fPath.c_str(),
321 decodeInfo.width(), decodeInfo.height()); 321 decodeInfo.width(), decodeInfo.height());
322 } 322 }
323 323
324 SkCodec::Options options;
324 switch (fMode) { 325 switch (fMode) {
326 case kCodecZeroInit_Mode:
327 options.fZeroInitialized = SkCodec::kYes_ZeroInitialized;
328 bitmap.eraseColor(0);
scroggo 2016/01/12 22:27:46 This won't work for index8 bitmaps. Instead, we ca
mtklein 2016/01/12 22:51:22 e.g. SkMallocPixelRef::NewZeroed() / SkMallocPixel
msarett 2016/01/13 14:58:16 Done.
329 // Intentional fall through.
325 case kCodec_Mode: { 330 case kCodec_Mode: {
326 switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowB ytes(), nullptr, 331 switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowB ytes(), &options,
327 colorPtr, colorCountPtr)) { 332 colorPtr, colorCountPtr)) {
328 case SkCodec::kSuccess: 333 case SkCodec::kSuccess:
329 // We consider incomplete to be valid, since we should still decode what is 334 // We consider incomplete to be valid, since we should still decode what is
330 // available. 335 // available.
331 case SkCodec::kIncompleteInput: 336 case SkCodec::kIncompleteInput:
332 break; 337 break;
333 case SkCodec::kInvalidConversion: 338 case SkCodec::kInvalidConversion:
334 return Error::Nonfatal("Incompatible colortype conversion"); 339 return Error::Nonfatal("Incompatible colortype conversion");
335 default: 340 default:
336 // Everything else is considered a failure. 341 // Everything else is considered a failure.
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 skr.visit<void>(i, drawsAsSingletonPictures); 1306 skr.visit<void>(i, drawsAsSingletonPictures);
1302 } 1307 }
1303 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1308 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1304 1309
1305 canvas->drawPicture(macroPic); 1310 canvas->drawPicture(macroPic);
1306 return check_against_reference(bitmap, src, fSink); 1311 return check_against_reference(bitmap, src, fSink);
1307 }); 1312 });
1308 } 1313 }
1309 1314
1310 } // namespace DM 1315 } // namespace DM
OLDNEW
« dm/DMSrcSink.h ('K') | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698