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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1055743003: Swizzler changes Index8 and 565 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Avoid setting a field to a local variable Created 5 years, 8 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 | « no previous file | src/codec/SkCodec_libbmp.h » ('j') | src/codec/SkCodec_libbmp.cpp » ('J')
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 "SkCommonFlags.h" 10 #include "SkCommonFlags.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); 65 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
66 if (!encoded) { 66 if (!encoded) {
67 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 67 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
68 } 68 }
69 69
70 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); 70 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
71 if (!codec) { 71 if (!codec) {
72 return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); 72 return SkStringPrintf("Couldn't decode %s.", fPath.c_str());
73 } 73 }
74 74
75 // Process the decode info to prepare for the decode
75 SkImageInfo decodeInfo = codec->getInfo().makeColorType(canvasInfo.colorType ()); 76 SkImageInfo decodeInfo = codec->getInfo().makeColorType(canvasInfo.colorType ());
77
78 // Construct a color table for the decode if necessary
79 SkAutoTUnref<SkColorTable> colorTable(NULL);
80 SkPMColor* colorPtr = NULL;
81 int* colorCountPtr = NULL;
82 int maxColors = 256;
83 if (kIndex_8_SkColorType == decodeInfo.colorType()) {
84 SkPMColor colors[maxColors];
85 colorTable.reset(SkNEW_ARGS(SkColorTable, (colors, maxColors)));
86 colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
87 colorCountPtr = &maxColors;
88 }
89
90 // FIXME: Currently we cannot draw unpremultiplied sources.
76 if (decodeInfo.alphaType() == kUnpremul_SkAlphaType) { 91 if (decodeInfo.alphaType() == kUnpremul_SkAlphaType) {
77 // FIXME: Currently we cannot draw unpremultiplied sources.
78 decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType); 92 decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType);
79 } 93 }
80 94
81 SkBitmap bitmap; 95 SkBitmap bitmap;
82 if (!bitmap.tryAllocPixels(decodeInfo)) { 96 if (!bitmap.tryAllocPixels(decodeInfo, NULL, colorTable.get())) {
83 return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPath.c_str( ), 97 return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPath.c_str( ),
84 decodeInfo.width(), decodeInfo.height()); 98 decodeInfo.width(), decodeInfo.height());
85 } 99 }
86 100
87 switch (fMode) { 101 switch (fMode) {
88 case kNormal_Mode: 102 case kNormal_Mode:
89 switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowB ytes())) { 103 switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowB ytes(), NULL,
104 colorPtr, colorCountPtr)) {
90 case SkImageGenerator::kSuccess: 105 case SkImageGenerator::kSuccess:
91 // We consider incomplete to be valid, since we should still decode what is 106 // We consider incomplete to be valid, since we should still decode what is
92 // available. 107 // available.
93 case SkImageGenerator::kIncompleteInput: 108 case SkImageGenerator::kIncompleteInput:
94 break; 109 break;
95 case SkImageGenerator::kInvalidConversion: 110 case SkImageGenerator::kInvalidConversion:
96 return Error::Nonfatal("Incompatible colortype conversion"); 111 return Error::Nonfatal("Incompatible colortype conversion");
97 default: 112 default:
98 // Everything else is considered a failure. 113 // Everything else is considered a failure.
99 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( )); 114 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( ));
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 surfaces.unrefAll(); 644 surfaces.unrefAll();
630 return ""; 645 return "";
631 } 646 }
632 SkISize size() const override { return fSize; } 647 SkISize size() const override { return fSize; }
633 Name name() const override { sk_throw(); return ""; } // No one should be calling this. 648 Name name() const override { sk_throw(); return ""; } // No one should be calling this.
634 } proxy(fW, fH, pic, src.size()); 649 } proxy(fW, fH, pic, src.size());
635 return fSink->draw(proxy, bitmap, stream, log); 650 return fSink->draw(proxy, bitmap, stream, log);
636 } 651 }
637 652
638 } // namespace DM 653 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkCodec_libbmp.h » ('j') | src/codec/SkCodec_libbmp.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698