aboutsummaryrefslogtreecommitdiff
path: root/src/image
diff options
context:
space:
mode:
authorJim Van Verth <jvanverth@google.com>2018-10-23 17:27:55 -0400
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2018-10-23 21:58:21 +0000
commitc96740729a6a524ec4c768af84b876dcac1dbd7f (patch)
tree4addc4971e47deb2703f4cb237e5c3f2bbe6a97e /src/image
parent49353683320d630f3ea6ba15dcbc3e97ccfcf693 (diff)
downloadskqp-c96740729a6a524ec4c768af84b876dcac1dbd7f.tar.gz
Some more clean-up of YUVA code
* Restore pre-colortype interface * Remove other colortype references Bug: skia:7903 Change-Id: I0db6d61e78d719ff941ac195bcbed4416f7d3138 Reviewed-on: https://skia-review.googlesource.com/c/164610 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/SkImage_Gpu.cpp26
-rw-r--r--src/image/SkImage_GpuYUVA.cpp97
-rw-r--r--src/image/SkImage_GpuYUVA.h13
3 files changed, 8 insertions, 128 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 4ef8b1ce29..844a463a33 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -127,8 +127,6 @@ sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(
// of validate_backend_texture.
GrBackendTexture yuvaTexturesCopy[4];
- bool nv12 = (yuvaIndices[1].fIndex == yuvaIndices[2].fIndex);
-
for (int i = 0; i < 4; ++i) {
// Validate that the yuvaIndices refer to valid backend textures.
const SkYUVAIndex& yuvaIndex = yuvaIndices[i];
@@ -142,32 +140,8 @@ sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(
return nullptr;
}
- SkColorType ct = kUnknown_SkColorType;
- if (SkYUVAIndex::kA_Index == i) {
- // The A plane is always kAlpha8 (for now)
- ct = kAlpha_8_SkColorType;
- } else {
- // The UV planes can either be interleaved or planar. If interleaved the Y plane
- // should have A8 color type but may be RGBA. We fall back in the latter case below.
- ct = nv12 && SkYUVAIndex::kY_Index != i ? kRGBA_8888_SkColorType : kAlpha_8_SkColorType;
- }
-
if (!yuvaTexturesCopy[yuvaIndex.fIndex].isValid()) {
yuvaTexturesCopy[yuvaIndex.fIndex] = yuvaTextures[yuvaIndex.fIndex];
-
- // TODO: Instead of using assumption about whether it is NV12 format to guess colorType,
- // actually use channel information here.
- // Alternate TODO: Don't bother validating.
- if (!ValidateBackendTexture(ctx, yuvaTexturesCopy[yuvaIndex.fIndex],
- &yuvaTexturesCopy[yuvaIndex.fIndex].fConfig,
- ct, kPremul_SkAlphaType, nullptr)) {
- // Try RGBA in case the assumed colortype is wrong
- if (!ValidateBackendTexture(ctx, yuvaTexturesCopy[yuvaIndex.fIndex],
- &yuvaTexturesCopy[yuvaIndex.fIndex].fConfig,
- kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr)) {
- return nullptr;
- }
- }
}
// TODO: Check that for each plane, the channel actually exist in the image source we are
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index 019131c4b3..1033358905 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -96,94 +96,11 @@ sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef() const {
return fRGBProxy;
}
-//////////////////////////////////////////////////////////////////////////////////////////////////
-
-//*** bundle this into a helper function used by this and SkImage_Gpu?
-sk_sp<SkImage> SkImage_GpuYUVA::MakeFromYUVATextures(GrContext* ctx,
- SkYUVColorSpace colorSpace,
- const GrBackendTexture yuvaTextures[],
- const SkYUVAIndex yuvaIndices[4],
- int width,
- int height,
- GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> imageColorSpace) {
- GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
-
- // Right now this still only deals with YUV and NV12 formats. Assuming that YUV has different
- // textures for U and V planes, while NV12 uses same texture for U and V planes.
- bool nv12 = (yuvaIndices[SkYUVAIndex::kU_Index].fIndex ==
- yuvaIndices[SkYUVAIndex::kV_Index].fIndex);
-
- // We need to make a copy of the input backend textures because we need to preserve the result
- // of validate_backend_texture.
- GrBackendTexture yuvaTexturesCopy[4];
- for (int i = 0; i < 4; ++i) {
- // Validate that the yuvaIndices refer to valid backend textures.
- const SkYUVAIndex& yuvaIndex = yuvaIndices[i];
- if (SkYUVAIndex::kA_Index == i && yuvaIndex.fIndex == -1) {
- // Meaning the A plane isn't passed in.
- continue;
- }
- if (yuvaIndex.fIndex == -1 || yuvaIndex.fIndex > 3) {
- // Y plane, U plane, and V plane must refer to image sources being passed in. There are
- // at most 4 image sources being passed in, could not have a index more than 3.
- return nullptr;
- }
- SkColorType ct = kUnknown_SkColorType;
- if (SkYUVAIndex::kY_Index == i || SkYUVAIndex::kA_Index == i) {
- // The Y and A planes are always kAlpha8 (for now)
- ct = kAlpha_8_SkColorType;
- } else {
- // The UV planes can either be interleaved or planar
- ct = nv12 ? kRGBA_8888_SkColorType : kAlpha_8_SkColorType;
- }
-
- if (!yuvaTexturesCopy[yuvaIndex.fIndex].isValid()) {
- yuvaTexturesCopy[yuvaIndex.fIndex] = yuvaTextures[yuvaIndex.fIndex];
- // TODO: Instead of using assumption about whether it is NV12 format to guess colorType,
- // actually use channel information here.
- if (!ValidateBackendTexture(ctx, yuvaTexturesCopy[yuvaIndex.fIndex],
- &yuvaTexturesCopy[yuvaIndex.fIndex].fConfig,
- ct, kUnpremul_SkAlphaType, nullptr)) {
- return nullptr;
- }
- }
-
- // TODO: Check that for each plane, the channel actually exist in the image source we are
- // reading from.
- }
-
- sk_sp<GrTextureProxy> tempTextureProxies[4]; // build from yuvaTextures
- for (int i = 0; i < 4; ++i) {
- // Fill in tempTextureProxies to avoid duplicate texture proxies.
- int textureIndex = yuvaIndices[i].fIndex;
-
- // Safely ignore since this means we are missing the A plane.
- if (textureIndex == -1) {
- SkASSERT(SkYUVAIndex::kA_Index == i);
- continue;
- }
-
- if (!tempTextureProxies[textureIndex]) {
- SkASSERT(yuvaTexturesCopy[textureIndex].isValid());
- tempTextureProxies[textureIndex] =
- proxyProvider->wrapBackendTexture(yuvaTexturesCopy[textureIndex], origin);
- if (!tempTextureProxies[textureIndex]) {
- return nullptr;
- }
- }
- }
-
- return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(ctx), width, height, kNeedNewImageUniqueID,
- colorSpace, tempTextureProxies, yuvaIndices, origin,
- imageColorSpace, SkBudgeted::kYes);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(GrContext* context,
SkYUVColorSpace yuvColorSpace,
const GrBackendFormat yuvaFormats[],
- const SkYUVSizeInfo& yuvaSizeInfo,
+ const SkISize yuvaSizes[],
const SkYUVAIndex yuvaIndices[4],
int imageWidth,
int imageHeight,
@@ -233,16 +150,14 @@ sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(GrContext* context,
return nullptr;
}
- // verify sizeInfo with expected texture count
+ // verify sizes with expected texture count
for (int i = 0; i < numTextures; ++i) {
- if (yuvaSizeInfo.fSizes[i].isEmpty() ||
- !yuvaSizeInfo.fWidthBytes[i]) {
+ if (yuvaSizes[i].isEmpty()) {
return nullptr;
}
}
for (int i = numTextures; i < SkYUVSizeInfo::kMaxCount; ++i) {
- if (!yuvaSizeInfo.fSizes[i].isEmpty() ||
- yuvaSizeInfo.fWidthBytes[i]) {
+ if (!yuvaSizes[i].isEmpty()) {
return nullptr;
}
}
@@ -277,8 +192,8 @@ sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(GrContext* context,
};
GrSurfaceDesc desc;
desc.fFlags = kNone_GrSurfaceFlags;
- desc.fWidth = yuvaSizeInfo.fSizes[texIdx].width();
- desc.fHeight = yuvaSizeInfo.fSizes[texIdx].height();
+ desc.fWidth = yuvaSizes[texIdx].width();
+ desc.fHeight = yuvaSizes[texIdx].height();
desc.fConfig = params.fConfig;
desc.fSampleCnt = 1;
proxies[texIdx] = proxyProvider->createLazyProxy(
diff --git a/src/image/SkImage_GpuYUVA.h b/src/image/SkImage_GpuYUVA.h
index 337fb3dfda..ebeaf8cbaa 100644
--- a/src/image/SkImage_GpuYUVA.h
+++ b/src/image/SkImage_GpuYUVA.h
@@ -63,7 +63,7 @@ public:
@param context Gpu context
@param yuvColorSpace color range of expected YUV pixels
@param yuvaFormats formats of promised gpu textures for each YUVA plane
- @param yuvaSizeInfo width, height, and colortype of promised gpu textures
+ @param yuvaSizes width and height of promised gpu textures
@param yuvaIndices mapping from yuv plane index to texture representing that plane
@param width width of promised gpu texture
@param height height of promised gpu texture
@@ -78,7 +78,7 @@ public:
static sk_sp<SkImage> MakePromiseYUVATexture(GrContext* context,
SkYUVColorSpace yuvColorSpace,
const GrBackendFormat yuvaFormats[],
- const SkYUVSizeInfo& yuvaSizeInfo,
+ const SkISize yuvaSizes[],
const SkYUVAIndex yuvaIndices[4],
int width,
int height,
@@ -89,15 +89,6 @@ public:
PromiseDoneProc promiseDoneProc,
TextureContext textureContexts[]);
- static sk_sp<SkImage> MakeFromYUVATextures(GrContext* context,
- SkYUVColorSpace yuvColorSpace,
- const GrBackendTexture yuvaTextures[],
- const SkYUVAIndex yuvaIndices[4],
- int width,
- int height,
- GrSurfaceOrigin imageOrigin,
- sk_sp<SkColorSpace> imageColorSpace);
-
private:
// This array will usually only be sparsely populated.
// The actual non-null fields are dictated by the 'fYUVAIndices' indices