Don't implement getBackendTexture for YUVA images.

Removes a use case of SkImage_Base::view().

This forces a RGBA flattening image which seems like an undesirable
side effect. If clients need the textures backing these image types
we should provide a query for GrYUVABackendTextures instead that
could return the whole set.

Bug: skia:11208
Bug: skia:9570

Change-Id: I085e5212b69fef7a53fb1606aecfb6f7f0e7c740
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360418
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Brian Salomon 2021-01-27 15:37:11 -05:00 committed by Skia Commit-Bot
parent f988bb53d0
commit d8ce784b83
4 changed files with 34 additions and 36 deletions

View File

@ -82,6 +82,37 @@ GrSemaphoresSubmitted SkImage_Gpu::onFlush(GrDirectContext* dContext, const GrFl
info);
}
GrBackendTexture SkImage_Gpu::onGetBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const {
auto direct = fContext->asDirectContext();
if (!direct) {
// This image was created with a DDL context and cannot be instantiated.
return GrBackendTexture(); // invalid
}
GrSurfaceProxy* proxy = fView.proxy();
if (!proxy->isInstantiated()) {
auto resourceProvider = direct->priv().resourceProvider();
if (!proxy->instantiate(resourceProvider)) {
return GrBackendTexture(); // invalid
}
}
GrTexture* texture = proxy->peekTexture();
if (texture) {
if (flushPendingGrContextIO) {
direct->priv().flushSurface(proxy);
}
if (origin) {
*origin = fView.origin();
}
return texture->getBackendTexture();
}
return GrBackendTexture(); // invalid
}
sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(SkColorType targetCT,
sk_sp<SkColorSpace> targetCS,
GrDirectContext* direct) const {

View File

@ -55,6 +55,9 @@ public:
return &fView;
}
GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const final;
bool onIsTextureBacked() const override {
SkASSERT(fView.proxy());
return true;

View File

@ -198,39 +198,6 @@ GrSurfaceProxyView SkImage_GpuBase::refView(GrRecordingContext* context,
return adjuster.view(mipMapped);
}
GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const {
auto direct = fContext->asDirectContext();
if (!direct) {
// This image was created with a DDL context and cannot be instantiated.
return GrBackendTexture(); // invalid
}
const GrSurfaceProxyView* view = this->view(direct);
SkASSERT(view && *view);
GrSurfaceProxy* proxy = view->proxy();
if (!proxy->isInstantiated()) {
auto resourceProvider = direct->priv().resourceProvider();
if (!proxy->instantiate(resourceProvider)) {
return GrBackendTexture(); // invalid
}
}
GrTexture* texture = proxy->peekTexture();
if (texture) {
if (flushPendingGrContextIO) {
direct->priv().flushSurface(proxy);
}
if (origin) {
*origin = view->origin();
}
return texture->getBackendTexture();
}
return GrBackendTexture(); // invalid
}
bool SkImage_GpuBase::onIsValid(GrRecordingContext* context) const {
// The base class has already checked that 'context' isn't abandoned (if it's not nullptr)
if (fContext->priv().abandoned()) {

View File

@ -43,9 +43,6 @@ public:
return *this->view(context);
}
GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const final;
bool onIsValid(GrRecordingContext*) const final;
#if GR_TEST_UTILS