diff options
author | 2014-05-29 18:47:06 +0000 | |
---|---|---|
committer | 2014-05-29 18:47:06 +0000 | |
commit | 5744bbee6fa65f9d532587b6539fa0f104dda98b (patch) | |
tree | 2d98b8361705f56a3ab52dfbcd3b0fa1607a3587 /src/core/SkImageGenerator.cpp | |
parent | ad854bf9c0d2029cf0730e50ac7f7ddbe32d1c97 (diff) |
move SkImageGenerator.cpp from src/images to src/core
git-svn-id: http://skia.googlecode.com/svn/trunk@14973 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkImageGenerator.cpp')
-rw-r--r-- | src/core/SkImageGenerator.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp new file mode 100644 index 0000000000..daa55a3a4d --- /dev/null +++ b/src/core/SkImageGenerator.cpp @@ -0,0 +1,72 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkImageGenerator.h" + +#ifndef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI +bool SkImageGenerator::getInfo(SkImageInfo* info) { + SkImageInfo dummy; + if (NULL == info) { + info = &dummy; + } + return this->onGetInfo(info); +} + +bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, + SkPMColor ctable[], int* ctableCount) { + if (kUnknown_SkColorType == info.colorType()) { + return false; + } + if (NULL == pixels) { + return false; + } + if (rowBytes < info.minRowBytes()) { + return false; + } + + if (kIndex_8_SkColorType == info.colorType()) { + if (NULL == ctable || NULL == ctableCount) { + return false; + } + } else { + if (ctableCount) { + *ctableCount = 0; + } + ctableCount = NULL; + ctable = NULL; + } + + bool success = this->onGetPixels(info, pixels, rowBytes, ctable, ctableCount); + + if (success && ctableCount) { + SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); + } + return success; +} + +bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) { + SkASSERT(kIndex_8_SkColorType != info.colorType()); + if (kIndex_8_SkColorType == info.colorType()) { + return false; + } + return this->getPixels(info, pixels, rowBytes, NULL, NULL); +} +#endif + +///////////////////////////////////////////////////////////////////////////////////////////// + +SkData* SkImageGenerator::onRefEncodedData() { + return NULL; +} + +bool SkImageGenerator::onGetInfo(SkImageInfo*) { + return false; +} + +bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*, int*) { + return false; +} |