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 11bool SkImageGenerator::getInfo(SkImageInfo* info) { 12 SkImageInfo dummy; 13 if (NULL == info) { 14 info = &dummy; 15 } 16 return this->onGetInfo(info); 17} 18 19bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, 20 SkPMColor ctable[], int* ctableCount) { 21 if (kUnknown_SkColorType == info.colorType()) { 22 return false; 23 } 24 if (NULL == pixels) { 25 return false; 26 } 27 if (rowBytes < info.minRowBytes()) { 28 return false; 29 } 30 31 if (kIndex_8_SkColorType == info.colorType()) { 32 if (NULL == ctable || NULL == ctableCount) { 33 return false; 34 } 35 } else { 36 if (ctableCount) { 37 *ctableCount = 0; 38 } 39 ctableCount = NULL; 40 ctable = NULL; 41 } 42 43 bool success = this->onGetPixels(info, pixels, rowBytes, ctable, ctableCount); 44 45 if (success && ctableCount) { 46 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); 47 } 48 return success; 49} 50 51bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) { 52 SkASSERT(kIndex_8_SkColorType != info.colorType()); 53 if (kIndex_8_SkColorType == info.colorType()) { 54 return false; 55 } 56 return this->getPixels(info, pixels, rowBytes, NULL, NULL); 57} 58#endif 59 60///////////////////////////////////////////////////////////////////////////////////////////// 61 62SkData* SkImageGenerator::onRefEncodedData() { 63 return NULL; 64} 65 66bool SkImageGenerator::onGetInfo(SkImageInfo*) { 67 return false; 68} 69 70bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*, int*) { 71 return false; 72} 73