diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkImageCacherator.cpp | 9 | ||||
-rw-r--r-- | src/core/SkImageGenerator.cpp | 66 | ||||
-rw-r--r-- | src/core/SkPixelRef.cpp | 5 | ||||
-rw-r--r-- | src/core/SkYUVPlanesCache.h | 11 |
4 files changed, 26 insertions, 65 deletions
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index ea4d4c2bab..e9b7f6a82a 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -213,12 +213,11 @@ public: Generator_GrYUVProvider(SkImageGenerator* gen) : fGen(gen) {} uint32_t onGetID() override { return fGen->uniqueID(); } - bool onGetYUVSizes(SkISize sizes[3]) override { - return fGen->getYUV8Planes(sizes, nullptr, nullptr, nullptr); + bool onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const override { + return fGen->queryYUV8(sizeInfo, colorSpace); } - bool onGetYUVPlanes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], - SkYUVColorSpace* space) override { - return fGen->getYUV8Planes(sizes, planes, rowBytes, space); + bool onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) override { + return fGen->getYUV8Planes(sizeInfo, planes); } }; diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp index 7d71b6701c..c8c94c2270 100644 --- a/src/core/SkImageGenerator.cpp +++ b/src/core/SkImageGenerator.cpp @@ -52,56 +52,28 @@ bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r return this->getPixels(info, pixels, rowBytes, nullptr, nullptr); } -bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], - SkYUVColorSpace* colorSpace) { -#ifdef SK_DEBUG - // In all cases, we need the sizes array - SkASSERT(sizes); - - bool isValidWithPlanes = (planes) && (rowBytes) && - ((planes[0]) && (planes[1]) && (planes[2]) && - (0 != rowBytes[0]) && (0 != rowBytes[1]) && (0 != rowBytes[2])); - bool isValidWithoutPlanes = - ((nullptr == planes) || - ((nullptr == planes[0]) && (nullptr == planes[1]) && (nullptr == planes[2]))) && - ((nullptr == rowBytes) || - ((0 == rowBytes[0]) && (0 == rowBytes[1]) && (0 == rowBytes[2]))); - - // Either we have all planes and rowBytes information or we have none of it - // Having only partial information is not supported - SkASSERT(isValidWithPlanes || isValidWithoutPlanes); - - // If we do have planes information, make sure all sizes are non 0 - // and all rowBytes are valid - SkASSERT(!isValidWithPlanes || - ((sizes[0].fWidth >= 0) && - (sizes[0].fHeight >= 0) && - (sizes[1].fWidth >= 0) && - (sizes[1].fHeight >= 0) && - (sizes[2].fWidth >= 0) && - (sizes[2].fHeight >= 0) && - (rowBytes[0] >= (size_t)sizes[0].fWidth) && - (rowBytes[1] >= (size_t)sizes[1].fWidth) && - (rowBytes[2] >= (size_t)sizes[2].fWidth))); -#endif +bool SkImageGenerator::queryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const { + SkASSERT(sizeInfo); - return this->onGetYUV8Planes(sizes, planes, rowBytes, colorSpace); + return this->onQueryYUV8(sizeInfo, colorSpace); } -bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]) { - return false; -} - -bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], - SkYUVColorSpace* colorSpace) { - // In order to maintain compatibility with clients that implemented the original - // onGetYUV8Planes interface, we assume that the color space is JPEG. - // TODO(rileya): remove this and the old onGetYUV8Planes once clients switch over to - // the new interface. - if (colorSpace) { - *colorSpace = kJPEG_SkYUVColorSpace; - } - return this->onGetYUV8Planes(sizes, planes, rowBytes); +bool SkImageGenerator::getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) { + SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth >= 0); + SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight >= 0); + SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kU].fWidth >= 0); + SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kU].fHeight >= 0); + SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kV].fWidth >= 0); + SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kV].fHeight >= 0); + SkASSERT(sizeInfo.fWidthBytes[SkYUVSizeInfo::kY] >= + (size_t) sizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth); + SkASSERT(sizeInfo.fWidthBytes[SkYUVSizeInfo::kU] >= + (size_t) sizeInfo.fSizes[SkYUVSizeInfo::kU].fWidth); + SkASSERT(sizeInfo.fWidthBytes[SkYUVSizeInfo::kV] >= + (size_t) sizeInfo.fSizes[SkYUVSizeInfo::kV].fWidth); + SkASSERT(planes && planes[0] && planes[1] && planes[2]); + + return this->onGetYUV8Planes(sizeInfo, planes); } GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subset) { diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp index 0825760ccd..cdc318b2a8 100644 --- a/src/core/SkPixelRef.cpp +++ b/src/core/SkPixelRef.cpp @@ -323,11 +323,6 @@ SkData* SkPixelRef::onRefEncodedData() { return nullptr; } -bool SkPixelRef::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], - SkYUVColorSpace* colorSpace) { - return false; -} - size_t SkPixelRef::getAllocatedSizeInBytes() const { return 0; } diff --git a/src/core/SkYUVPlanesCache.h b/src/core/SkYUVPlanesCache.h index a024192d07..1c866a2d2b 100644 --- a/src/core/SkYUVPlanesCache.h +++ b/src/core/SkYUVPlanesCache.h @@ -10,6 +10,7 @@ #include "SkCachedData.h" #include "SkImageInfo.h" +#include "SkYUVSizeInfo.h" class SkResourceCache; @@ -19,17 +20,11 @@ public: * The Info struct contains data about the 3 Y, U and V planes of memory stored * contiguously, in that order, as a single block of memory within SkYUVPlanesCache. * - * fSize: Width and height of each of the 3 planes (in pixels). - * fSizeInMemory: Amount of memory allocated for each plane (may be different from - "height * rowBytes", depending on the jpeg decoder's block size). - * The sum of these is the total size stored within SkYUVPlanesCache. - * fRowBytes: rowBytes for each of the 3 planes (in bytes). + * fSizeInfo: fWidth, fHeight, and fWidthBytes of each of the Y, U, and V planes. * fColorSpace: color space that will be used for the YUV -> RGB conversion. */ struct Info { - SkISize fSize[3]; - size_t fSizeInMemory[3]; - size_t fRowBytes[3]; + SkYUVSizeInfo fSizeInfo; SkYUVColorSpace fColorSpace; }; /** |