| 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 "include/core/SkImageGenerator.h" |
| 9 |
|
| 10 |
#include "include/core/SkColorType.h" |
| 11 |
#include "include/private/base/SkAssert.h" |
| 12 |
#include "src/core/SkNextID.h" |
| 13 |
|
| 14 |
SkImageGenerator::SkImageGenerator(const SkImageInfo& info, uint32_t uniqueID) |
| 15 |
: fInfo(info) |
| 16 |
, fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : uniqueID) |
| 17 |
{} |
| 18 |
|
| 19 |
bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) { |
| 20 |
if (kUnknown_SkColorType == info.colorType()) { |
| 21 |
return false; |
| 22 |
} |
| 23 |
if (nullptr == pixels) { |
| 24 |
return false; |
| 25 |
} |
| 26 |
if (rowBytes < info.minRowBytes()) { |
| 27 |
return false; |
| 28 |
} |
| 29 |
|
| 30 |
Options defaultOpts; |
| 31 |
return this->onGetPixels(info, pixels, rowBytes, defaultOpts); |
| 32 |
} |
| 33 |
|
| 34 |
bool SkImageGenerator::queryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes& supportedDataTypes, |
| 35 |
SkYUVAPixmapInfo* yuvaPixmapInfo) const { |
| 36 |
SkASSERT(yuvaPixmapInfo); |
| 37 |
|
| 38 |
return this->onQueryYUVAInfo(supportedDataTypes, yuvaPixmapInfo) && |
| 39 |
yuvaPixmapInfo->isSupported(supportedDataTypes); |
| 40 |
} |
| 41 |
|
| 42 |
bool SkImageGenerator::getYUVAPlanes(const SkYUVAPixmaps& yuvaPixmaps) { |
| 43 |
return this->onGetYUVAPlanes(yuvaPixmaps); |
| 44 |
} |