Remove deprecated DDL promise texture image factories.

Bug: skia:10632
Change-Id: I218281256ea5ab4a5a5a7ea7bf209350082f8dc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335038
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Brian Salomon 2020-11-16 10:31:49 -05:00 committed by Skia Commit-Bot
parent c634fc4a66
commit 98e17bf01a
5 changed files with 42 additions and 216 deletions

View File

@ -7,6 +7,9 @@ This file includes a list of high level updates for each milestone release.
Milestone 89
------------
* Deprecated SkImage factories have been removed from
SkDeferredDisplayListRecorder.
* The following YUV image factories have been removed:
SkImage::MakeFromYUVTexturesCopyWithExternalBackend
SkImage::MakeFromNV12TexturesCopyWithExternalBackend

View File

@ -101,27 +101,13 @@ public:
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureContext textureContext);
/** Legacy compatibility version that takes an additional proc that is never called. */
sk_sp<SkImage> makePromiseTexture(const GrBackendFormat& backendFormat,
int width,
int height,
GrMipmapped mipMapped,
GrSurfaceOrigin origin,
SkColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureReleaseProc ignoredProc,
PromiseImageTextureContext textureContext);
/**
This entry point operates like 'makePromiseTexture' but it is used to construct a SkImage
from YUV[A] data. The source data may be planar (i.e. spread across multiple textures). In
the extreme Y, U, V, and A are all in different planes and thus the image is specified by
four textures. 'yuvaBackendTextureInfo' describes the planar arrangement, texture formats,
conversion to RGB, and origin of the textures. Separate 'textureFulfillProc' and
'textureReleaseProc' calls are made for each texture but each texture has its own
'textureReleaseProc' calls are made for each texture. Each texture has its own
PromiseImageTextureContext. If 'yuvaBackendTextureinfo' is not valid then no release proc
calls are made. Otherwise, the calls will be made even on failure. 'textureContexts' has one
entry for each of the up to four textures, as indicated by 'yuvaBackendTextureinfo'.
@ -136,45 +122,6 @@ public:
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureContext textureContexts[]);
/** Deprecated. Use GrYUVABackendTextureInfo version instead.
This entry point operates like 'makePromiseTexture' but it is used to construct a SkImage
from YUV[A] data. The source data may be planar (i.e. spread across multiple textures). In
the extreme Y, U, V, and A are all in different planes and thus the image is specified by
four textures. 'yuvaIndices' specifies the mapping from texture color channels to Y, U, V,
and possibly A components. It therefore indicates how many unique textures compose the full
image. Separate textureFulfillProc and textureReleaseProc calls are made for each texture
but each texture has its own PromiseImageTextureContext. If the 'yuvaindices' are invalid no
release proc calls are made. Otherwise the calls will be made even on failure. 'yuvFormats',
'yuvaSizes', and 'textureContexts' have one entry for each of the up to four textures, as
indicated by 'yuvaIndices'.
*/
sk_sp<SkImage> makeYUVAPromiseTexture(SkYUVColorSpace yuvColorSpace,
const GrBackendFormat yuvaFormats[],
const SkISize yuvaSizes[],
const SkYUVAIndex yuvaIndices[4],
int imageWidth,
int imageHeight,
GrSurfaceOrigin imageOrigin,
sk_sp<SkColorSpace> imageColorSpace,
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureContext textureContexts[]);
/** Legacy compatibility version that takes an additional proc that is never called. */
sk_sp<SkImage> makeYUVAPromiseTexture(SkYUVColorSpace yuvColorSpace,
const GrBackendFormat yuvaFormats[],
const SkISize yuvaSizes[],
const SkYUVAIndex yuvaIndices[4],
int imageWidth,
int imageHeight,
GrSurfaceOrigin imageOrigin,
sk_sp<SkColorSpace> imageColorSpace,
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureReleaseProc ignoredProc,
PromiseImageTextureContext textureContexts[]);
private:
bool init();

View File

@ -39,13 +39,7 @@ sk_sp<SkImage> SkDeferredDisplayListRecorder::makePromiseTexture(
}
sk_sp<SkImage> SkDeferredDisplayListRecorder::makeYUVAPromiseTexture(
SkYUVColorSpace yuvColorSpace,
const GrBackendFormat yuvaFormats[],
const SkISize yuvaSizes[],
const SkYUVAIndex yuvaIndices[4],
int imageWidth,
int imageHeight,
GrSurfaceOrigin imageOrigin,
const GrYUVABackendTextureInfo& yuvaBackendTextureInfo,
sk_sp<SkColorSpace> imageColorSpace,
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,
@ -271,61 +265,8 @@ sk_sp<SkImage> SkDeferredDisplayListRecorder::makeYUVAPromiseTexture(
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureContext textureContexts[]) {
if (!yuvaBackendTextureInfo.isValid()) {
return nullptr;
}
SkISize planeDimensions[SkYUVAInfo::kMaxPlanes];
int n = yuvaBackendTextureInfo.yuvaInfo().planeDimensions(planeDimensions);
GrBackendFormat backendFormats[SkYUVAInfo::kMaxPlanes];
for (int i = 0; i < n; ++i) {
backendFormats[i] = yuvaBackendTextureInfo.planeFormat(i);
}
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount];
SkAssertResult(yuvaBackendTextureInfo.toYUVAIndices(yuvaIndices));
if (yuvaBackendTextureInfo.yuvaInfo().origin() != SkEncodedOrigin::kDefault_SkEncodedOrigin) {
// The legacy interface we're converting to does not support this. This will get removed
// when the old APIs are gone and we only have to support YUVA configs described by
// SkYUVAInfo.
if (textureReleaseProc) {
for (int i = 0; i < n; ++i) {
textureReleaseProc(textureContexts[i]);
}
}
return nullptr;
}
return this->makeYUVAPromiseTexture(yuvaBackendTextureInfo.yuvColorSpace(),
backendFormats,
planeDimensions,
yuvaIndices,
yuvaBackendTextureInfo.yuvaInfo().width(),
yuvaBackendTextureInfo.yuvaInfo().height(),
yuvaBackendTextureInfo.textureOrigin(),
std::move(imageColorSpace),
textureFulfillProc,
textureReleaseProc,
textureContexts);
}
sk_sp<SkImage> SkDeferredDisplayListRecorder::makeYUVAPromiseTexture(
SkYUVColorSpace yuvColorSpace,
const GrBackendFormat yuvaFormats[],
const SkISize yuvaSizes[],
const SkYUVAIndex yuvaIndices[4],
int imageWidth,
int imageHeight,
GrSurfaceOrigin imageOrigin,
sk_sp<SkColorSpace> imageColorSpace,
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureContext textureContexts[]) {
return SkImage_GpuYUVA::MakePromiseYUVATexture(fContext.get(),
yuvColorSpace,
yuvaFormats,
yuvaSizes,
yuvaIndices,
imageWidth,
imageHeight,
imageOrigin,
yuvaBackendTextureInfo,
std::move(imageColorSpace),
textureFulfillProc,
textureReleaseProc,
@ -333,55 +274,3 @@ sk_sp<SkImage> SkDeferredDisplayListRecorder::makeYUVAPromiseTexture(
}
#endif
sk_sp<SkImage> SkDeferredDisplayListRecorder::makePromiseTexture(
const GrBackendFormat& backendFormat,
int width,
int height,
GrMipmapped mipmapped,
GrSurfaceOrigin origin,
SkColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureReleaseProc ignoredProc,
PromiseImageTextureContext textureContext) {
return this->makePromiseTexture(backendFormat,
width,
height,
mipmapped,
origin,
colorType,
alphaType,
std::move(colorSpace),
textureFulfillProc,
textureReleaseProc,
textureContext);
}
sk_sp<SkImage> SkDeferredDisplayListRecorder::makeYUVAPromiseTexture(
SkYUVColorSpace yuvColorSpace,
const GrBackendFormat yuvaFormats[],
const SkISize yuvaSizes[],
const SkYUVAIndex yuvaIndices[4],
int imageWidth,
int imageHeight,
GrSurfaceOrigin imageOrigin,
sk_sp<SkColorSpace> imageColorSpace,
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureReleaseProc ignoredProc,
PromiseImageTextureContext textureContexts[]) {
return this->makeYUVAPromiseTexture(yuvColorSpace,
yuvaFormats,
yuvaSizes,
yuvaIndices,
imageWidth,
imageHeight,
imageOrigin,
std::move(imageColorSpace),
textureFulfillProc,
textureReleaseProc,
textureContexts);
}

View File

@ -372,76 +372,69 @@ sk_sp<SkImage> SkImage::MakeFromYUVAPixmaps(GrRecordingContext* context,
sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(
GrRecordingContext* context,
SkYUVColorSpace yuvColorSpace,
const GrBackendFormat yuvaFormats[],
const SkISize yuvaSizes[],
const SkYUVAIndex yuvaIndices[4],
int imageWidth,
int imageHeight,
GrSurfaceOrigin textureOrigin,
const GrYUVABackendTextureInfo& yuvaBackendTextureInfo,
sk_sp<SkColorSpace> imageColorSpace,
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,
PromiseImageTextureContext textureContexts[]) {
int numTextures;
bool valid = SkYUVAIndex::AreValidIndices(yuvaIndices, &numTextures);
if (!yuvaBackendTextureInfo.isValid()) {
return nullptr;
}
SkISize planeDimensions[SkYUVAInfo::kMaxPlanes];
int n = yuvaBackendTextureInfo.yuvaInfo().planeDimensions(planeDimensions);
// Our contract is that we will always call the release proc even on failure.
// We use the helper to convey the context, so we need to ensure make doesn't fail.
textureReleaseProc = textureReleaseProc ? textureReleaseProc : [](void*) {};
sk_sp<GrRefCntedCallback> releaseHelpers[4];
for (int i = 0; i < numTextures; ++i) {
for (int i = 0; i < n; ++i) {
releaseHelpers[i] = GrRefCntedCallback::Make(textureReleaseProc, textureContexts[i]);
}
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount];
SkAssertResult(yuvaBackendTextureInfo.toYUVAIndices(yuvaIndices));
if (yuvaBackendTextureInfo.yuvaInfo().origin() != SkEncodedOrigin::kDefault_SkEncodedOrigin) {
// SkImage_GpuYUVA does not support this yet. This will get removed
// when the old APIs are gone and we only have to support YUVA configs described by
// SkYUVAInfo.
return nullptr;
}
int numIndices;
SkAssertResult(SkYUVAIndex::AreValidIndices(yuvaIndices, &numIndices));
SkASSERT(numIndices == n);
if (!context) {
return nullptr;
}
if (!valid) {
return nullptr;
}
if (imageWidth <= 0 || imageHeight <= 0) {
return nullptr;
}
SkAlphaType at = (-1 != yuvaIndices[SkYUVAIndex::kA_Index].fIndex) ? kPremul_SkAlphaType
: kOpaque_SkAlphaType;
SkImageInfo info =
SkImageInfo::Make(imageWidth, imageHeight, kAssumedColorType, at, imageColorSpace);
SkAlphaType at = yuvaBackendTextureInfo.yuvaInfo().hasAlpha() ? kPremul_SkAlphaType
: kOpaque_SkAlphaType;
SkImageInfo info = SkImageInfo::Make(yuvaBackendTextureInfo.yuvaInfo().dimensions(),
kAssumedColorType, at, imageColorSpace);
if (!SkImageInfoIsValid(info)) {
return nullptr;
}
// verify sizes with expected texture count
for (int i = 0; i < numTextures; ++i) {
if (yuvaSizes[i].isEmpty()) {
return nullptr;
}
}
for (int i = numTextures; i < SkYUVASizeInfo::kMaxCount; ++i) {
if (!yuvaSizes[i].isEmpty()) {
return nullptr;
}
}
// Get lazy proxies
// Make a lazy proxy for each plane and wrap in a view.
GrSurfaceProxyView views[4];
for (int texIdx = 0; texIdx < numTextures; ++texIdx) {
for (int texIdx = 0; texIdx < n; ++texIdx) {
auto proxy = MakePromiseImageLazyProxy(context,
yuvaSizes[texIdx],
yuvaFormats[texIdx],
planeDimensions[texIdx],
yuvaBackendTextureInfo.planeFormat(texIdx),
GrMipmapped::kNo,
textureFulfillProc,
std::move(releaseHelpers[texIdx]));
if (!proxy) {
return nullptr;
}
views[texIdx] = GrSurfaceProxyView(std::move(proxy), textureOrigin, GrSwizzle("rgba"));
views[texIdx] = GrSurfaceProxyView(std::move(proxy), yuvaBackendTextureInfo.textureOrigin(),
GrSwizzle("rgba"));
}
return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(context), SkISize{imageWidth, imageHeight},
kNeedNewImageUniqueID, yuvColorSpace, views, numTextures,
yuvaIndices, std::move(imageColorSpace));
return sk_make_sp<SkImage_GpuYUVA>(
sk_ref_sp(context), yuvaBackendTextureInfo.yuvaInfo().dimensions(),
kNeedNewImageUniqueID, yuvaBackendTextureInfo.yuvColorSpace(), views, n, yuvaIndices,
std::move(imageColorSpace));
}

View File

@ -71,13 +71,7 @@ public:
* This is the implementation of SkDeferredDisplayListRecorder::makeYUVAPromiseTexture.
*/
static sk_sp<SkImage> MakePromiseYUVATexture(GrRecordingContext*,
SkYUVColorSpace yuvColorSpace,
const GrBackendFormat yuvaFormats[],
const SkISize yuvaSizes[],
const SkYUVAIndex yuvaIndices[4],
int width,
int height,
GrSurfaceOrigin textureOrigin,
const GrYUVABackendTextureInfo&,
sk_sp<SkColorSpace> imageColorSpace,
PromiseImageTextureFulfillProc textureFulfillProc,
PromiseImageTextureReleaseProc textureReleaseProc,