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

Side by Side Diff: src/core/SkImageGenerator.cpp

Issue 1226023003: Remove SkImageGenerator pieces only for SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@severIG
Patch Set: Change the public interface without staging it. Created 5 years, 5 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/SkImageGenerator.h ('k') | src/images/SkDecodingImageGenerator.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 2014 Google Inc. 2 * Copyright 2014 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 "SkImageGenerator.h" 8 #include "SkImageGenerator.h"
9 9
10 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo id* pixels, 10 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r owBytes,
11 size_t rowBytes, const Opti ons* options, 11 SkPMColor ctable[], int* ctableCount) {
12 SkPMColor ctable[], int* ct ableCount) {
13 if (kUnknown_SkColorType == info.colorType()) { 12 if (kUnknown_SkColorType == info.colorType()) {
14 return kInvalidConversion; 13 return false;
15 } 14 }
16 if (NULL == pixels) { 15 if (NULL == pixels) {
17 return kInvalidParameters; 16 return false;
18 } 17 }
19 if (rowBytes < info.minRowBytes()) { 18 if (rowBytes < info.minRowBytes()) {
20 return kInvalidParameters; 19 return false;
21 } 20 }
22 21
23 if (kIndex_8_SkColorType == info.colorType()) { 22 if (kIndex_8_SkColorType == info.colorType()) {
24 if (NULL == ctable || NULL == ctableCount) { 23 if (NULL == ctable || NULL == ctableCount) {
25 return kInvalidParameters; 24 return false;
26 } 25 }
27 } else { 26 } else {
28 if (ctableCount) { 27 if (ctableCount) {
29 *ctableCount = 0; 28 *ctableCount = 0;
30 } 29 }
31 ctableCount = NULL; 30 ctableCount = NULL;
32 ctable = NULL; 31 ctable = NULL;
33 } 32 }
34 33
34 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
35 // Default options. 35 // Default options.
36 Options optsStorage; 36 Options options;
37 if (NULL == options) { 37 const Result result = this->onGetPixels(info, pixels, rowBytes, options, cta ble, ctableCount);
38 options = &optsStorage; 38
39 if (kIncompleteInput != result && kSuccess != result) {
40 return false;
39 } 41 }
40 const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ct able, ctableCount); 42 if (ctableCount) {
41
42 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) {
43 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); 43 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
44 } 44 }
45 return result; 45 return true;
46 #else
47 const bool success = this->onGetPixels(info, pixels, rowBytes, ctable, ctabl eCount);
48 if (success && ctableCount) {
49 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
50 }
51 return success;
52 #endif
46 } 53 }
47 54
48 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo id* pixels, 55 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r owBytes) {
49 size_t rowBytes) {
50 SkASSERT(kIndex_8_SkColorType != info.colorType()); 56 SkASSERT(kIndex_8_SkColorType != info.colorType());
51 if (kIndex_8_SkColorType == info.colorType()) { 57 if (kIndex_8_SkColorType == info.colorType()) {
52 return kInvalidConversion; 58 return false;
53 } 59 }
54 return this->getPixels(info, pixels, rowBytes, NULL, NULL, NULL); 60 return this->getPixels(info, pixels, rowBytes, NULL, NULL);
55 } 61 }
56 62
57 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r owBytes[3], 63 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r owBytes[3],
58 SkYUVColorSpace* colorSpace) { 64 SkYUVColorSpace* colorSpace) {
59 #ifdef SK_DEBUG 65 #ifdef SK_DEBUG
60 // In all cases, we need the sizes array 66 // In all cases, we need the sizes array
61 SkASSERT(sizes); 67 SkASSERT(sizes);
62 68
63 bool isValidWithPlanes = (planes) && (rowBytes) && 69 bool isValidWithPlanes = (planes) && (rowBytes) &&
64 ((planes[0]) && (planes[1]) && (planes[2]) && 70 ((planes[0]) && (planes[1]) && (planes[2]) &&
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 111 }
106 return this->onGetYUV8Planes(sizes, planes, rowBytes); 112 return this->onGetYUV8Planes(sizes, planes, rowBytes);
107 } 113 }
108 114
109 //////////////////////////////////////////////////////////////////////////////// ///////////// 115 //////////////////////////////////////////////////////////////////////////////// /////////////
110 116
111 SkData* SkImageGenerator::onRefEncodedData() { 117 SkData* SkImageGenerator::onRefEncodedData() {
112 return NULL; 118 return NULL;
113 } 119 }
114 120
121 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
115 SkImageGenerator::Result SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, 122 SkImageGenerator::Result SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst,
116 size_t rb, const Options& options, 123 size_t rb, const Options& options,
117 SkPMColor* colors, int* c olorCount) { 124 SkPMColor* colors, int* c olorCount) {
118 return kUnimplemented; 125 return kUnimplemented;
119 } 126 }
127 #else
128 bool SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, size_t rb ,
129 SkPMColor* colors, int* colorCount) {
130 return false;
131 }
132 #endif
OLDNEW
« no previous file with comments | « include/core/SkImageGenerator.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698