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

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

Issue 1288483002: Consolidate SkCodec functions for handling rewind (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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
« src/codec/SkBmpCodec.h ('K') | « src/codec/SkJpegCodec.cpp ('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 "SkWebpCodec.h" 8 #include "SkWebpCodec.h"
9 #include "SkTemplates.h" 9 #include "SkTemplates.h"
10 10
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // As stated below, libwebp snaps to even left and top. Make sure top and le ft are even, so we 146 // As stated below, libwebp snaps to even left and top. Make sure top and le ft are even, so we
147 // decode this exact subset. 147 // decode this exact subset.
148 // Leave right and bottom unmodified, so we suggest a slightly larger subset than requested. 148 // Leave right and bottom unmodified, so we suggest a slightly larger subset than requested.
149 desiredSubset->fLeft = (desiredSubset->fLeft >> 1) << 1; 149 desiredSubset->fLeft = (desiredSubset->fLeft >> 1) << 1;
150 desiredSubset->fTop = (desiredSubset->fTop >> 1) << 1; 150 desiredSubset->fTop = (desiredSubset->fTop >> 1) << 1;
151 return true; 151 return true;
152 } 152 }
153 153
154 SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, 154 SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
155 const Options& options, SkPMColor*, int *) { 155 const Options& options, SkPMColor*, int *) {
156 switch (this->rewindIfNeeded()) { 156 if (!this->rewindIfNeeded()) {
157 case kCouldNotRewind_RewindState: 157 return kCouldNotRewind;
158 return kCouldNotRewind;
159 case kRewound_RewindState:
160 // Rewound to the beginning. Since creation only does a peek, the st ream is at the
161 // correct position.
162 break;
163 case kNoRewindNecessary_RewindState:
164 // Already at the right spot for decoding.
165 break;
166 } 158 }
167 159
168 if (!conversion_possible(dstInfo, this->getInfo())) { 160 if (!conversion_possible(dstInfo, this->getInfo())) {
169 return kInvalidConversion; 161 return kInvalidConversion;
170 } 162 }
171 163
172 WebPDecoderConfig config; 164 WebPDecoderConfig config;
173 if (0 == WebPInitDecoderConfig(&config)) { 165 if (0 == WebPInitDecoderConfig(&config)) {
174 // ABI mismatch. 166 // ABI mismatch.
175 // FIXME: New enum for this? 167 // FIXME: New enum for this?
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // Break out of the switch statement. Continue the loop. 245 // Break out of the switch statement. Continue the loop.
254 break; 246 break;
255 default: 247 default:
256 return kInvalidInput; 248 return kInvalidInput;
257 } 249 }
258 } 250 }
259 } 251 }
260 252
261 SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream) 253 SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream)
262 : INHERITED(info, stream) {} 254 : INHERITED(info, stream) {}
OLDNEW
« src/codec/SkBmpCodec.h ('K') | « src/codec/SkJpegCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698