aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkImageGenerator.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-03-07 09:16:52 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-07 09:16:52 -0800
commit1590f3b32890f6455b30494308633177b54db347 (patch)
tree5fabc87ced4a0c49bc304d87306068647e8123c2 /src/core/SkImageGenerator.cpp
parent54887a6a2e12b0f2c93e039b00678732b6518826 (diff)
Revert of Update Skia's YUV API (patchset #5 id:160001 of https://codereview.chromium.org/1716523002/ )
Reason for revert: Blimp failures with manual roll in Chrome. Original issue's description: > Update Skia's YUV API > > We should match the recently designed API in SkCodec. > https://codereview.chromium.org/1549473003/ > > This requires changes in Chromium as well. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1716523002 > > Committed: https://skia.googlesource.com/skia/+/095d31c8a0eeb5d491febf064bc3c8a44e22b94f TBR=scroggo@google.com,reed@google.com,bsalomon@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1775493002
Diffstat (limited to 'src/core/SkImageGenerator.cpp')
-rw-r--r--src/core/SkImageGenerator.cpp66
1 files changed, 47 insertions, 19 deletions
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp
index c8c94c2270..7d71b6701c 100644
--- a/src/core/SkImageGenerator.cpp
+++ b/src/core/SkImageGenerator.cpp
@@ -52,28 +52,56 @@ bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r
return this->getPixels(info, pixels, rowBytes, nullptr, nullptr);
}
-bool SkImageGenerator::queryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
- SkASSERT(sizeInfo);
+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
- return this->onQueryYUV8(sizeInfo, colorSpace);
+ return this->onGetYUV8Planes(sizes, planes, rowBytes, colorSpace);
}
-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);
+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);
}
GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subset) {