OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "SkImageGenerator.h" |
| 9 |
| 10 #ifndef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI |
| 11 bool SkImageGenerator::getInfo(SkImageInfo* info) { |
| 12 SkImageInfo dummy; |
| 13 if (NULL == info) { |
| 14 info = &dummy; |
| 15 } |
| 16 return this->onGetInfo(info); |
| 17 } |
| 18 |
| 19 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r
owBytes, |
| 20 SkPMColor ctable[], int* ctableCount) { |
| 21 // Dummy (out-of-range) value to catch subclasses that forgot to respect cta
ble params. |
| 22 int localCTableCount = -1; |
| 23 int* localCTableCountPtr = NULL; |
| 24 |
| 25 if (kIndex_8_SkColorType == info.colorType()) { |
| 26 if (NULL == ctable || NULL == ctableCount) { |
| 27 return false; |
| 28 } |
| 29 } else { |
| 30 if (ctableCount) { |
| 31 *ctableCount = 0; |
| 32 } |
| 33 ctableCount = NULL; |
| 34 ctable = NULL; |
| 35 } |
| 36 |
| 37 if (kUnknown_SkColorType == info.colorType()) { |
| 38 return false; |
| 39 } |
| 40 if (NULL == pixels) { |
| 41 return false; |
| 42 } |
| 43 if (rowBytes < info.minRowBytes()) { |
| 44 return false; |
| 45 } |
| 46 |
| 47 bool success = this->onGetPixels(info, pixels, rowBytes, ctable, localCTable
CountPtr); |
| 48 |
| 49 if (success && localCTableCountPtr) { |
| 50 SkASSERT(localCTableCount >= 0 && localCTableCount <= 256); |
| 51 if (ctableCount) { |
| 52 *ctableCount = localCTableCount; |
| 53 } |
| 54 } |
| 55 return success; |
| 56 } |
| 57 |
| 58 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r
owBytes) { |
| 59 SkASSERT(kIndex_8_SkColorType != info.colorType()); |
| 60 if (kIndex_8_SkColorType == info.colorType()) { |
| 61 return false; |
| 62 } |
| 63 return this->getPixels(info, pixels, rowBytes, NULL, NULL); |
| 64 } |
| 65 #endif |
| 66 |
| 67 ////////////////////////////////////////////////////////////////////////////////
///////////// |
| 68 |
| 69 SkData* SkImageGenerator::onRefEncodedData() { |
| 70 return NULL; |
| 71 } |
| 72 |
| 73 bool SkImageGenerator::onGetInfo(SkImageInfo*) { |
| 74 return false; |
| 75 } |
| 76 |
| 77 bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*
, int*) { |
| 78 return false; |
| 79 } |
OLD | NEW |