SkImage_GpuYUVA doesn't take origin
When flattening we always flatten to kTopLeft. Rename some origin params to SkImage factories to make it clearer that they refer to input texture origins. Only preserve the origin in the variants that immediately flatten to RGBA as part of contract (make SkImage_Gpu not SkImage_GpuYUVA). Bug: skia:10632 Change-Id: I0ed9d693758086c4050f983b579d0d77daefc3d7 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322486 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
c3bdd1c597
commit
8e5cf44114
@ -395,7 +395,7 @@ public:
|
||||
|
||||
@param context GPU context
|
||||
@param backendTexture texture residing on GPU
|
||||
@param imageOrigin origin of the resulting image
|
||||
@param textureOrigin origin of backendTexture
|
||||
@param colorType color type of the resulting image
|
||||
@param alphaType alpha type of the resulting image
|
||||
@param colorSpace range of colors; may be nullptr
|
||||
@ -403,7 +403,7 @@ public:
|
||||
*/
|
||||
static sk_sp<SkImage> MakeFromAdoptedTexture(GrRecordingContext* context,
|
||||
const GrBackendTexture& backendTexture,
|
||||
GrSurfaceOrigin imageOrigin,
|
||||
GrSurfaceOrigin textureOrigin,
|
||||
SkColorType colorType,
|
||||
SkAlphaType alphaType = kPremul_SkAlphaType,
|
||||
sk_sp<SkColorSpace> colorSpace = nullptr);
|
||||
@ -421,7 +421,7 @@ public:
|
||||
@param yuvaIndices array indicating which texture in yuvaTextures, and channel
|
||||
in that texture, maps to each component of YUVA.
|
||||
@param imageSize size of the resulting image
|
||||
@param imageOrigin origin of the resulting image.
|
||||
@param textureOrigin origin of the input textures.
|
||||
@param imageColorSpace range of colors of the resulting image; may be nullptr
|
||||
@param textureReleaseProc called when the backend textures can be released
|
||||
@param releaseContext state passed to textureReleaseProc
|
||||
@ -432,7 +432,7 @@ public:
|
||||
const GrBackendTexture yuvaTextures[],
|
||||
const SkYUVAIndex yuvaIndices[4],
|
||||
SkISize imageSize,
|
||||
GrSurfaceOrigin imageOrigin,
|
||||
GrSurfaceOrigin textureOrigin,
|
||||
sk_sp<SkColorSpace> imageColorSpace = nullptr,
|
||||
TextureReleaseProc textureReleaseProc = nullptr,
|
||||
ReleaseContext releaseContext = nullptr);
|
||||
@ -472,7 +472,7 @@ public:
|
||||
GrContext* context,
|
||||
SkYUVColorSpace yuvColorSpace,
|
||||
const GrBackendTexture yuvTextures[3],
|
||||
GrSurfaceOrigin imageOrigin,
|
||||
GrSurfaceOrigin textureOrigin,
|
||||
const GrBackendTexture& backendTexture,
|
||||
sk_sp<SkColorSpace> imageColorSpace = nullptr);
|
||||
|
||||
@ -486,6 +486,7 @@ public:
|
||||
@param context GPU context
|
||||
@param yuvColorSpace How the YUV values are converted to RGB
|
||||
@param nv12Textures array of YUV textures on GPU
|
||||
@param textureOrigin origin of textures in nv12Textures and of backendTexture
|
||||
@param backendTexture the resource that stores the final pixels
|
||||
@param imageColorSpace range of colors; may be nullptr
|
||||
@param textureReleaseProc function called when backendTexture can be released
|
||||
@ -496,7 +497,7 @@ public:
|
||||
GrContext* context,
|
||||
SkYUVColorSpace yuvColorSpace,
|
||||
const GrBackendTexture nv12Textures[2],
|
||||
GrSurfaceOrigin imageOrigin,
|
||||
GrSurfaceOrigin textureOrigin,
|
||||
const GrBackendTexture& backendTexture,
|
||||
sk_sp<SkColorSpace> imageColorSpace = nullptr,
|
||||
TextureReleaseProc textureReleaseProc = nullptr,
|
||||
|
@ -39,7 +39,6 @@ SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp<GrImageContext> context,
|
||||
GrSurfaceProxyView views[],
|
||||
int numViews,
|
||||
const SkYUVAIndex yuvaIndices[4],
|
||||
GrSurfaceOrigin origin,
|
||||
sk_sp<SkColorSpace> imageColorSpace)
|
||||
: INHERITED(std::move(context),
|
||||
size,
|
||||
@ -51,8 +50,7 @@ SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp<GrImageContext> context,
|
||||
GetAlphaTypeFromYUVAIndices(yuvaIndices),
|
||||
std::move(imageColorSpace))
|
||||
, fNumViews(numViews)
|
||||
, fYUVColorSpace(colorSpace)
|
||||
, fOrigin(origin) {
|
||||
, fYUVColorSpace(colorSpace) {
|
||||
// The caller should have done this work, just verifying
|
||||
SkDEBUGCODE(int textureCount;)
|
||||
SkASSERT(SkYUVAIndex::AreValidIndices(yuvaIndices, &textureCount));
|
||||
@ -75,7 +73,6 @@ SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp<GrImageContext> context, const SkImage_Gp
|
||||
GetAlphaTypeFromYUVAIndices(image->fYUVAIndices), std::move(targetCS))
|
||||
, fNumViews(image->fNumViews)
|
||||
, fYUVColorSpace(image->fYUVColorSpace)
|
||||
, fOrigin(image->fOrigin)
|
||||
// Since null fFromColorSpace means no GrColorSpaceXform, we turn a null
|
||||
// image->refColorSpace() into an explicit SRGB.
|
||||
, fFromColorSpace(image->colorSpace() ? image->refColorSpace() : SkColorSpace::MakeSRGB()) {
|
||||
@ -161,7 +158,7 @@ void SkImage_GpuYUVA::flattenToRGB(GrRecordingContext* context) const {
|
||||
// Needs to create a render target in order to draw to it for the yuv->rgb conversion.
|
||||
auto renderTargetContext = GrRenderTargetContext::Make(
|
||||
context, GrColorType::kRGBA_8888, this->refColorSpace(), SkBackingFit::kExact,
|
||||
this->dimensions(), 1, GrMipmapped::kNo, GrProtected::kNo, fOrigin);
|
||||
this->dimensions(), 1, GrMipmapped::kNo, GrProtected::kNo);
|
||||
if (!renderTargetContext) {
|
||||
return;
|
||||
}
|
||||
@ -179,7 +176,6 @@ void SkImage_GpuYUVA::flattenToRGB(GrRecordingContext* context) const {
|
||||
}
|
||||
|
||||
fRGBView = renderTargetContext->readSurfaceView();
|
||||
SkASSERT(fRGBView.origin() == fOrigin);
|
||||
SkASSERT(fRGBView.swizzle() == GrSwizzle());
|
||||
for (auto& v : fViews) {
|
||||
v.reset();
|
||||
@ -232,7 +228,7 @@ sk_sp<SkImage> SkImage_GpuYUVA::onMakeColorTypeAndColorSpace(
|
||||
|
||||
sk_sp<SkImage> SkImage_GpuYUVA::onReinterpretColorSpace(sk_sp<SkColorSpace> newCS) const {
|
||||
return sk_make_sp<SkImage_GpuYUVA>(fContext, this->dimensions(), kNeedNewImageUniqueID,
|
||||
fYUVColorSpace, fViews, fNumViews, fYUVAIndices, fOrigin,
|
||||
fYUVColorSpace, fViews, fNumViews, fYUVAIndices,
|
||||
std::move(newCS));
|
||||
}
|
||||
|
||||
@ -243,7 +239,7 @@ sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrContext* ctx,
|
||||
const GrBackendTexture yuvaTextures[],
|
||||
const SkYUVAIndex yuvaIndices[4],
|
||||
SkISize imageSize,
|
||||
GrSurfaceOrigin imageOrigin,
|
||||
GrSurfaceOrigin textureOrigin,
|
||||
sk_sp<SkColorSpace> imageColorSpace,
|
||||
TextureReleaseProc textureReleaseProc,
|
||||
ReleaseContext releaseContext) {
|
||||
@ -259,14 +255,13 @@ sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrContext* ctx,
|
||||
|
||||
GrSurfaceProxyView tempViews[4];
|
||||
if (!SkImage_GpuBase::MakeTempTextureProxies(ctx, yuvaTextures, numTextures, yuvaIndices,
|
||||
imageOrigin, tempViews,
|
||||
textureOrigin, tempViews,
|
||||
std::move(releaseHelper))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(ctx), imageSize, kNeedNewImageUniqueID, colorSpace,
|
||||
tempViews, numTextures, yuvaIndices, imageOrigin,
|
||||
imageColorSpace);
|
||||
tempViews, numTextures, yuvaIndices, imageColorSpace);
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::MakeFromYUVAPixmaps(GrRecordingContext* context,
|
||||
@ -334,7 +329,6 @@ sk_sp<SkImage> SkImage::MakeFromYUVAPixmaps(GrRecordingContext* context,
|
||||
tempViews,
|
||||
numPlanes,
|
||||
yuvaIndices,
|
||||
kTopLeft_GrSurfaceOrigin,
|
||||
std::move(imageColorSpace));
|
||||
}
|
||||
|
||||
@ -347,7 +341,7 @@ sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(
|
||||
const SkYUVAIndex yuvaIndices[4],
|
||||
int imageWidth,
|
||||
int imageHeight,
|
||||
GrSurfaceOrigin imageOrigin,
|
||||
GrSurfaceOrigin textureOrigin,
|
||||
sk_sp<SkColorSpace> imageColorSpace,
|
||||
PromiseImageTextureFulfillProc textureFulfillProc,
|
||||
PromiseImageTextureReleaseProc textureReleaseProc,
|
||||
@ -413,10 +407,10 @@ sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
views[texIdx] = GrSurfaceProxyView(std::move(proxy), imageOrigin, GrSwizzle("rgba"));
|
||||
views[texIdx] = GrSurfaceProxyView(std::move(proxy), textureOrigin, GrSwizzle("rgba"));
|
||||
}
|
||||
|
||||
return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(context), SkISize{imageWidth, imageHeight},
|
||||
kNeedNewImageUniqueID, yuvColorSpace, views, numTextures,
|
||||
yuvaIndices, imageOrigin, std::move(imageColorSpace));
|
||||
yuvaIndices, std::move(imageColorSpace));
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ public:
|
||||
GrSurfaceProxyView views[],
|
||||
int numViews,
|
||||
const SkYUVAIndex[4],
|
||||
GrSurfaceOrigin,
|
||||
sk_sp<SkColorSpace>);
|
||||
|
||||
GrSemaphoresSubmitted onFlush(GrDirectContext*, const GrFlushInfo&) override;
|
||||
@ -77,7 +76,7 @@ public:
|
||||
const SkYUVAIndex yuvaIndices[4],
|
||||
int width,
|
||||
int height,
|
||||
GrSurfaceOrigin imageOrigin,
|
||||
GrSurfaceOrigin textureOrigin,
|
||||
sk_sp<SkColorSpace> imageColorSpace,
|
||||
PromiseImageTextureFulfillProc textureFulfillProc,
|
||||
PromiseImageTextureReleaseProc textureReleaseProc,
|
||||
@ -96,7 +95,7 @@ private:
|
||||
int fNumViews;
|
||||
SkYUVAIndex fYUVAIndices[4];
|
||||
const SkYUVColorSpace fYUVColorSpace;
|
||||
GrSurfaceOrigin fOrigin;
|
||||
|
||||
// If this is non-null then the planar data should be converted from fFromColorSpace to
|
||||
// this->colorSpace(). Otherwise we assume the planar data (post YUV->RGB conversion) is already
|
||||
// in this->colorSpace().
|
||||
|
Loading…
Reference in New Issue
Block a user