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

Side by Side Diff: src/images/SkDecodingImageGenerator.cpp

Issue 656163002: Revert of JPEG YUV Decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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
« no previous file with comments | « include/core/SkImageDecoder.h ('k') | src/images/SkImageDecoder.cpp » ('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 2013 Google Inc. 2 * Copyright 2013 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 "SkData.h" 8 #include "SkData.h"
9 #include "SkDecodingImageGenerator.h" 9 #include "SkDecodingImageGenerator.h"
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 27 matching lines...) Expand all
38 38
39 protected: 39 protected:
40 virtual SkData* onRefEncodedData() SK_OVERRIDE; 40 virtual SkData* onRefEncodedData() SK_OVERRIDE;
41 virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { 41 virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
42 *info = fInfo; 42 *info = fInfo;
43 return true; 43 return true;
44 } 44 }
45 virtual bool onGetPixels(const SkImageInfo& info, 45 virtual bool onGetPixels(const SkImageInfo& info,
46 void* pixels, size_t rowBytes, 46 void* pixels, size_t rowBytes,
47 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE; 47 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE;
48 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3],
49 SkYUVColorSpace* colorSpace) SK_OVERRIDE;
50 48
51 private: 49 private:
52 typedef SkImageGenerator INHERITED; 50 typedef SkImageGenerator INHERITED;
53 }; 51 };
54 52
55 /** 53 /**
56 * Special allocator used by getPixels(). Uses preallocated memory 54 * Special allocator used by getPixels(). Uses preallocated memory
57 * provided if possible, else fall-back on the default allocator 55 * provided if possible, else fall-back on the default allocator
58 */ 56 */
59 class TargetAllocator : public SkBitmap::Allocator { 57 class TargetAllocator : public SkBitmap::Allocator {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return false; 197 return false;
200 } 198 }
201 const int count = ctable->count(); 199 const int count = ctable->count();
202 memcpy(ctableEntries, ctable->lockColors(), count * sizeof(SkPMColor)); 200 memcpy(ctableEntries, ctable->lockColors(), count * sizeof(SkPMColor));
203 ctable->unlockColors(); 201 ctable->unlockColors();
204 *ctableCount = count; 202 *ctableCount = count;
205 } 203 }
206 return true; 204 return true;
207 } 205 }
208 206
209 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
210 size_t rowBytes[3], SkYUVColorSpace * colorSpace) {
211 if (!fStream->rewind()) {
212 return false;
213 }
214
215 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
216 if (NULL == decoder.get()) {
217 return false;
218 }
219
220 return decoder->decodeYUV8Planes(fStream, sizes, planes, rowBytes, colorSpac e);
221 }
222
223 // A contructor-type function that returns NULL on failure. This 207 // A contructor-type function that returns NULL on failure. This
224 // prevents the returned SkImageGenerator from ever being in a bad 208 // prevents the returned SkImageGenerator from ever being in a bad
225 // state. Called by both Create() functions 209 // state. Called by both Create() functions
226 SkImageGenerator* CreateDecodingImageGenerator( 210 SkImageGenerator* CreateDecodingImageGenerator(
227 SkData* data, 211 SkData* data,
228 SkStreamRewindable* stream, 212 SkStreamRewindable* stream,
229 const SkDecodingImageGenerator::Options& opts) { 213 const SkDecodingImageGenerator::Options& opts) {
230 SkASSERT(stream); 214 SkASSERT(stream);
231 SkAutoTUnref<SkStreamRewindable> autoStream(stream); // always unref this. 215 SkAutoTUnref<SkStreamRewindable> autoStream(stream); // always unref this.
232 SkAssertResult(autoStream->rewind()); 216 SkAssertResult(autoStream->rewind());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 SkStreamRewindable* stream, 273 SkStreamRewindable* stream,
290 const SkDecodingImageGenerator::Options& opts) { 274 const SkDecodingImageGenerator::Options& opts) {
291 SkASSERT(stream != NULL); 275 SkASSERT(stream != NULL);
292 SkASSERT(stream->unique()); 276 SkASSERT(stream->unique());
293 if ((stream == NULL) || !stream->unique()) { 277 if ((stream == NULL) || !stream->unique()) {
294 SkSafeUnref(stream); 278 SkSafeUnref(stream);
295 return NULL; 279 return NULL;
296 } 280 }
297 return CreateDecodingImageGenerator(NULL, stream, opts); 281 return CreateDecodingImageGenerator(NULL, stream, opts);
298 } 282 }
OLDNEW
« no previous file with comments | « include/core/SkImageDecoder.h ('k') | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698