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

Side by Side Diff: src/codec/SkCodec_wbmp.cpp

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase on merged SkCodec and SkScanlineDecoder Created 5 years, 2 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
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 "SkCodec.h" 8 #include "SkCodec.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 SkEncodedFormat SkWbmpCodec::onGetEncodedFormat() const { 103 SkEncodedFormat SkWbmpCodec::onGetEncodedFormat() const {
104 return kWBMP_SkEncodedFormat; 104 return kWBMP_SkEncodedFormat;
105 } 105 }
106 106
107 SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info, 107 SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info,
108 void* dst, 108 void* dst,
109 size_t rowBytes, 109 size_t rowBytes,
110 const Options& options, 110 const Options& options,
111 SkPMColor ctable[], 111 SkPMColor ctable[],
112 int* ctableCount) { 112 int* ctableCount,
113 int* rowsDecoded) {
113 if (options.fSubset) { 114 if (options.fSubset) {
114 // Subsets are not supported. 115 // Subsets are not supported.
115 return kUnimplemented; 116 return kUnimplemented;
116 } 117 }
117 if (info.dimensions() != this->getInfo().dimensions()) { 118 if (info.dimensions() != this->getInfo().dimensions()) {
118 return kInvalidScale; 119 return kInvalidScale;
119 } 120 }
120 121
121 if (!valid_alpha(info.alphaType(), this->getInfo().alphaType())) { 122 if (!valid_alpha(info.alphaType(), this->getInfo().alphaType())) {
122 return kInvalidConversion; 123 return kInvalidConversion;
123 } 124 }
124 125
125 // Prepare a color table if necessary 126 // Prepare a color table if necessary
126 setup_color_table(info.colorType(), ctable, ctableCount); 127 setup_color_table(info.colorType(), ctable, ctableCount);
127 128
128 129
129 // Initialize the swizzler 130 // Initialize the swizzler
130 SkAutoTDelete<SkSwizzler> swizzler(this->initializeSwizzler(info, ctable, op tions)); 131 SkAutoTDelete<SkSwizzler> swizzler(this->initializeSwizzler(info, ctable, op tions));
131 if (nullptr == swizzler.get()) { 132 if (nullptr == swizzler.get()) {
132 return kInvalidConversion; 133 return kInvalidConversion;
133 } 134 }
134 135
135 // Perform the decode 136 // Perform the decode
136 SkISize size = info.dimensions(); 137 SkISize size = info.dimensions();
137 SkAutoTMalloc<uint8_t> src(fSrcRowBytes); 138 SkAutoTMalloc<uint8_t> src(fSrcRowBytes);
138 void* dstRow = dst; 139 void* dstRow = dst;
139 for (int y = 0; y < size.height(); ++y) { 140 for (int y = 0; y < size.height(); ++y) {
140 Result rowResult = this->readRow(src.get()); 141 Result rowResult = this->readRow(src.get());
scroggo 2015/10/01 14:48:31 I think this should also return a bool?
msarett 2015/10/01 18:14:14 Yes it should.
141 if (kSuccess != rowResult) { 142 if (kSuccess != rowResult) {
143 *rowsDecoded = y;
142 return rowResult; 144 return rowResult;
143 } 145 }
144 swizzler->swizzle(dstRow, src.get()); 146 swizzler->swizzle(dstRow, src.get());
145 dstRow = SkTAddOffset<void>(dstRow, rowBytes); 147 dstRow = SkTAddOffset<void>(dstRow, rowBytes);
146 } 148 }
147 return kSuccess; 149 return kSuccess;
148 } 150 }
149 151
150 bool SkWbmpCodec::IsWbmp(SkStream* stream) { 152 bool SkWbmpCodec::IsWbmp(SkStream* stream) {
151 return read_header(stream, nullptr); 153 return read_header(stream, nullptr);
152 } 154 }
153 155
154 SkCodec* SkWbmpCodec::NewFromStream(SkStream* stream) { 156 SkCodec* SkWbmpCodec::NewFromStream(SkStream* stream) {
155 SkAutoTDelete<SkStream> streamDeleter(stream); 157 SkAutoTDelete<SkStream> streamDeleter(stream);
156 SkISize size; 158 SkISize size;
157 if (!read_header(stream, &size)) { 159 if (!read_header(stream, &size)) {
158 return nullptr; 160 return nullptr;
159 } 161 }
160 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), 162 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(),
161 kGray_8_SkColorType, kOpaque_SkAlphaType); 163 kGray_8_SkColorType, kOpaque_SkAlphaType);
162 return new SkWbmpCodec(info, streamDeleter.detach()); 164 return new SkWbmpCodec(info, streamDeleter.detach());
163 } 165 }
164 166
165 SkCodec::Result SkWbmpCodec::onGetScanlines(void* dst, int count, size_t dstRowB ytes) { 167 uint32_t SkWbmpCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) {
166 void* dstRow = dst; 168 void* dstRow = dst;
167 for (int y = 0; y < count; ++y) { 169 for (int y = 0; y < count; ++y) {
168 Result rowResult = this->readRow(fSrcBuffer.get()); 170 SkCodec::Result rowResult = this->readRow(fSrcBuffer.get());
169 if (kSuccess != rowResult) { 171 if (SkCodec::kSuccess != rowResult) {
170 return rowResult; 172 return y;
171 } 173 }
172 fSwizzler->swizzle(dstRow, fSrcBuffer.get()); 174 fSwizzler->swizzle(dstRow, fSrcBuffer.get());
173 dstRow = SkTAddOffset<void>(dstRow, dstRowBytes); 175 dstRow = SkTAddOffset<void>(dstRow, dstRowBytes);
174 } 176 }
175 return kSuccess; 177 return count;
176 } 178 }
177 179
178 SkCodec::Result SkWbmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, 180 SkCodec::Result SkWbmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
179 const Options& options, SkPMColor inputColorTable[], int* inputColorCoun t) { 181 const Options& options, SkPMColor inputColorTable[], int* inputColorCoun t) {
180 if (options.fSubset) { 182 if (options.fSubset) {
181 // Subsets are not supported. 183 // Subsets are not supported.
182 return kUnimplemented; 184 return kUnimplemented;
183 } 185 }
184 if (dstInfo.dimensions() != this->getInfo().dimensions()) { 186 if (dstInfo.dimensions() != this->getInfo().dimensions()) {
185 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstI nfo)) { 187 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstI nfo)) {
(...skipping 17 matching lines...) Expand all
203 fSwizzler.reset(this->initializeSwizzler(dstInfo, 205 fSwizzler.reset(this->initializeSwizzler(dstInfo,
204 get_color_ptr(fColorTable.get()), options)); 206 get_color_ptr(fColorTable.get()), options));
205 if (nullptr == fSwizzler.get()) { 207 if (nullptr == fSwizzler.get()) {
206 return kInvalidConversion; 208 return kInvalidConversion;
207 } 209 }
208 210
209 fSrcBuffer.reset(fSrcRowBytes); 211 fSrcBuffer.reset(fSrcRowBytes);
210 212
211 return kSuccess; 213 return kSuccess;
212 } 214 }
213
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698