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

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

Issue 1895383002: Revert of Add SkEncodedInfo to report properties of encoded image data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | « src/codec/SkWbmpCodec.h ('k') | src/codec/SkWebpCodec.h » ('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 "SkCodec.h" 8 #include "SkCodec.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 SkSwizzler* SkWbmpCodec::initializeSwizzler(const SkImageInfo& info, const SkPMC olor* ctable, 98 SkSwizzler* SkWbmpCodec::initializeSwizzler(const SkImageInfo& info, const SkPMC olor* ctable,
99 const Options& opts) { 99 const Options& opts) {
100 return SkSwizzler::CreateSwizzler(SkSwizzler::kBit, ctable, info, opts); 100 return SkSwizzler::CreateSwizzler(SkSwizzler::kBit, ctable, info, opts);
101 } 101 }
102 102
103 bool SkWbmpCodec::readRow(uint8_t* row) { 103 bool SkWbmpCodec::readRow(uint8_t* row) {
104 return this->stream()->read(row, fSrcRowBytes) == fSrcRowBytes; 104 return this->stream()->read(row, fSrcRowBytes) == fSrcRowBytes;
105 } 105 }
106 106
107 SkWbmpCodec::SkWbmpCodec(int width, int height, const SkEncodedInfo& info, SkStr eam* stream) 107 SkWbmpCodec::SkWbmpCodec(const SkImageInfo& info, SkStream* stream)
108 : INHERITED(width, height, info, stream) 108 : INHERITED(info, stream)
109 , fSrcRowBytes(get_src_row_bytes(this->getInfo().width())) 109 , fSrcRowBytes(get_src_row_bytes(this->getInfo().width()))
110 , fSwizzler(nullptr) 110 , fSwizzler(nullptr)
111 , fColorTable(nullptr) 111 , fColorTable(nullptr)
112 {} 112 {}
113 113
114 SkEncodedFormat SkWbmpCodec::onGetEncodedFormat() const { 114 SkEncodedFormat SkWbmpCodec::onGetEncodedFormat() const {
115 return kWBMP_SkEncodedFormat; 115 return kWBMP_SkEncodedFormat;
116 } 116 }
117 117
118 SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info, 118 SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 SkMemoryStream stream(data); 159 SkMemoryStream stream(data);
160 return read_header(&stream, nullptr); 160 return read_header(&stream, nullptr);
161 } 161 }
162 162
163 SkCodec* SkWbmpCodec::NewFromStream(SkStream* stream) { 163 SkCodec* SkWbmpCodec::NewFromStream(SkStream* stream) {
164 SkAutoTDelete<SkStream> streamDeleter(stream); 164 SkAutoTDelete<SkStream> streamDeleter(stream);
165 SkISize size; 165 SkISize size;
166 if (!read_header(stream, &size)) { 166 if (!read_header(stream, &size)) {
167 return nullptr; 167 return nullptr;
168 } 168 }
169 SkEncodedInfo info = SkEncodedInfo::Make(SkEncodedInfo::kGray_Color, 169 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(),
170 SkEncodedInfo::kOpaque_Alpha, 1); 170 kGray_8_SkColorType, kOpaque_SkAlphaType);
171 return new SkWbmpCodec(size.width(), size.height(), info, streamDeleter.rele ase()); 171 return new SkWbmpCodec(info, streamDeleter.release());
172 } 172 }
173 173
174 int SkWbmpCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) { 174 int SkWbmpCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) {
175 void* dstRow = dst; 175 void* dstRow = dst;
176 for (int y = 0; y < count; ++y) { 176 for (int y = 0; y < count; ++y) {
177 if (!this->readRow(fSrcBuffer.get())) { 177 if (!this->readRow(fSrcBuffer.get())) {
178 return y; 178 return y;
179 } 179 }
180 fSwizzler->swizzle(dstRow, fSrcBuffer.get()); 180 fSwizzler->swizzle(dstRow, fSrcBuffer.get());
181 dstRow = SkTAddOffset<void>(dstRow, dstRowBytes); 181 dstRow = SkTAddOffset<void>(dstRow, dstRowBytes);
(...skipping 27 matching lines...) Expand all
209 } 209 }
210 210
211 // Initialize the swizzler 211 // Initialize the swizzler
212 fSwizzler.reset(this->initializeSwizzler(dstInfo, get_color_ptr(fColorTable. get()), options)); 212 fSwizzler.reset(this->initializeSwizzler(dstInfo, get_color_ptr(fColorTable. get()), options));
213 SkASSERT(fSwizzler); 213 SkASSERT(fSwizzler);
214 214
215 fSrcBuffer.reset(fSrcRowBytes); 215 fSrcBuffer.reset(fSrcRowBytes);
216 216
217 return kSuccess; 217 return kSuccess;
218 } 218 }
OLDNEW
« no previous file with comments | « src/codec/SkWbmpCodec.h ('k') | src/codec/SkWebpCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698