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:
parent
f988bb53d0
commit
d8ce784b83
@ -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 {
|
||||
|
@ -55,6 +55,9 @@ public:
|
||||
return &fView;
|
||||
}
|
||||
|
||||
GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,
|
||||
GrSurfaceOrigin* origin) const final;
|
||||
|
||||
bool onIsTextureBacked() const override {
|
||||
SkASSERT(fView.proxy());
|
||||
return true;
|
||||
|
@ -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()) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user