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/core/SkImageGenerator.cpp

Issue 919693002: Make SkImageGenerator::getPixels() return an enum. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Stage the change for chromium Created 5 years, 10 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 bool SkImageGenerator::getInfo(SkImageInfo* info) { 10 bool SkImageGenerator::getInfo(SkImageInfo* info) {
11 SkImageInfo dummy; 11 SkImageInfo dummy;
12 if (NULL == info) { 12 if (NULL == info) {
13 info = &dummy; 13 info = &dummy;
14 } 14 }
15 return this->onGetInfo(info); 15 return this->onGetInfo(info);
16 } 16 }
17 17
18 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r owBytes, 18 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo id* pixels,
19 SkPMColor ctable[], int* ctableCount) { 19 size_t rowBytes, SkPMColor ctable[],
20 int* ctableCount) {
20 if (kUnknown_SkColorType == info.colorType()) { 21 if (kUnknown_SkColorType == info.colorType()) {
21 return false; 22 return kInvalidConversion;
22 } 23 }
23 if (NULL == pixels) { 24 if (NULL == pixels) {
24 return false; 25 return kInvalidParameters;
25 } 26 }
26 if (rowBytes < info.minRowBytes()) { 27 if (rowBytes < info.minRowBytes()) {
27 return false; 28 return kInvalidParameters;
28 } 29 }
29 30
30 if (kIndex_8_SkColorType == info.colorType()) { 31 if (kIndex_8_SkColorType == info.colorType()) {
31 if (NULL == ctable || NULL == ctableCount) { 32 if (NULL == ctable || NULL == ctableCount) {
32 return false; 33 return kInvalidParameters;
33 } 34 }
34 } else { 35 } else {
35 if (ctableCount) { 36 if (ctableCount) {
36 *ctableCount = 0; 37 *ctableCount = 0;
37 } 38 }
38 ctableCount = NULL; 39 ctableCount = NULL;
39 ctable = NULL; 40 ctable = NULL;
40 } 41 }
41 42
42 bool success = this->onGetPixels(info, pixels, rowBytes, ctable, ctableCount ); 43 const Result result = this->onGetPixelsEnum(info, pixels, rowBytes, ctable, ctableCount);
43 44
44 if (success && ctableCount) { 45 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) {
45 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); 46 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
46 } 47 }
47 return success; 48 return result;
48 } 49 }
49 50
50 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r owBytes) { 51 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo id* pixels,
52 size_t rowBytes) {
51 SkASSERT(kIndex_8_SkColorType != info.colorType()); 53 SkASSERT(kIndex_8_SkColorType != info.colorType());
52 if (kIndex_8_SkColorType == info.colorType()) { 54 if (kIndex_8_SkColorType == info.colorType()) {
53 return false; 55 return kInvalidConversion;
54 } 56 }
55 return this->getPixels(info, pixels, rowBytes, NULL, NULL); 57 return this->getPixels(info, pixels, rowBytes, NULL, NULL);
56 } 58 }
57 59
58 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r owBytes[3], 60 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r owBytes[3],
59 SkYUVColorSpace* colorSpace) { 61 SkYUVColorSpace* colorSpace) {
60 #ifdef SK_DEBUG 62 #ifdef SK_DEBUG
61 // In all cases, we need the sizes array 63 // In all cases, we need the sizes array
62 SkASSERT(sizes); 64 SkASSERT(sizes);
63 65
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 //////////////////////////////////////////////////////////////////////////////// ///////////// 112 //////////////////////////////////////////////////////////////////////////////// /////////////
111 113
112 SkData* SkImageGenerator::onRefEncodedData() { 114 SkData* SkImageGenerator::onRefEncodedData() {
113 return NULL; 115 return NULL;
114 } 116 }
115 117
116 bool SkImageGenerator::onGetInfo(SkImageInfo*) { 118 bool SkImageGenerator::onGetInfo(SkImageInfo*) {
117 return false; 119 return false;
118 } 120 }
119 121
120 bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor* , int*) { 122 #ifdef SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN
121 return false; 123 bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t,
124 SkPMColor*, int*) {
125 return kUnimplemented;
122 } 126 }
127 #endif
128 SkImageGenerator::Result SkImageGenerator::onGetPixelsEnum(const SkImageInfo& in fo, void* pixels,
129 size_t rowBytes, SkPM Color* colors,
130 int* colorCount) {
131 #ifdef SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN
132 if (this->onGetPixels(info, pixels, rowBytes, colors, colorCount)) {
133 return kSuccess;
134 }
135 #endif
136 return kUnimplemented;
137 }
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