Reland "Reland "Release YUVA planes in SkImage_GpuYUVA after flattenning to RGBA.""
This reverts commit 8fbca482e5d9bd46ef6d97c0c3283cb108988ce4.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Revert "Reland "Release YUVA planes in SkImage_GpuYUVA after flattenning to RGBA.""
>
> This reverts commit 622b6f5367e2d26dab276df8bd9df0451236808b.
>
> Reason for revert: ANGLE may not be fixed
>
> Original change's description:
> > Reland "Release YUVA planes in SkImage_GpuYUVA after flattenning to RGBA."
> >
> > This reverts commit bc0c460349142140295593a3a32d507f7b45c622.
> >
> > Reason for revert: fixed isTextureBacked(), checked cc_unittests passes
> >
> > Original change's description:
> > > Revert "Release YUVA planes in SkImage_GpuYUVA after flattenning to RGBA."
> > >
> > > This reverts commit a15f355be83136e7827ccfbc9bb9e9ea77f48518.
> > >
> > > Reason for revert: ANGLE failing new test
> > >
> > > Original change's description:
> > > > Release YUVA planes in SkImage_GpuYUVA after flattenning to RGBA.
> > > >
> > > > Also removed unused virtual function from SkImage_GpuBase and override
> > > > on SkImage_GpuYUVA.
> > > >
> > > > Change-Id: Ib47b46b529b16976181cb9453976133d66e0f952
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212734
> > > > Commit-Queue: Brian Salomon <bsalomon@google.com>
> > > > Reviewed-by: Robert Phillips <robertphillips@google.com>
> > >
> > > TBR=jvanverth@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Ib2566ff8aa99d3698d6044167e70a1d75542f2e9
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212986
> > > Reviewed-by: Robert Phillips <robertphillips@google.com>
> > > Commit-Queue: Robert Phillips <robertphillips@google.com>
> >
> > TBR=jvanverth@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I3c9454da33a764504e768d02b59a5cd99766aff1
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212988
> > Commit-Queue: Brian Salomon <bsalomon@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=jvanverth@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I06632adc69844522c87cd72e8a6b0c2795974fe4
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212989
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
TBR=jvanverth@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I15cad8a907dbf6faa892cf7ca15c0fa5da58f87f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/213123
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp
index 80b39d0..0fb1cbe 100644
--- a/src/gpu/GrImageTextureMaker.cpp
+++ b/src/gpu/GrImageTextureMaker.cpp
@@ -91,8 +91,9 @@
bool coordsLimitedToConstraintRect,
const GrSamplerState::Filter* filterOrNullForBicubic) {
- // Check simple cases to see if we need to fall back to flattening the image
- if (!filterOrNullForBicubic || this->domainNeedsDecal()) {
+ // Check simple cases to see if we need to fall back to flattening the image (or whether it's
+ // already been flattened.)
+ if (!filterOrNullForBicubic || this->domainNeedsDecal() || fImage->fRGBProxy) {
return this->INHERITED::createFragmentProcessor(textureMatrix, constraintRect,
filterConstraint,
coordsLimitedToConstraintRect,
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index b06d7fc..a3b86c5 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -64,8 +64,6 @@
return nullptr;
}
virtual bool isYUVA() const { return false; }
- virtual bool asYUVATextureProxiesRef(sk_sp<GrTextureProxy>[4], SkYUVAIndex[4],
- SkYUVColorSpace*) const { return false; }
virtual GrTexture* onGetTexture() const { return nullptr; }
#endif
virtual GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index 915d0de..146e9f5 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -71,8 +71,12 @@
SkASSERT(SkYUVAIndex::AreValidIndices(image->fYUVAIndices, &textureCount));
SkASSERT(textureCount == fNumProxies);
- for (int i = 0; i < fNumProxies; ++i) {
- fProxies[i] = image->fProxies[i]; // we ref in this case, not move
+ if (image->fRGBProxy) {
+ fRGBProxy = image->fRGBProxy; // we ref in this case, not move
+ } else {
+ for (int i = 0; i < fNumProxies; ++i) {
+ fProxies[i] = image->fProxies[i]; // we ref in this case, not move
+ }
}
memcpy(fYUVAIndices, image->fYUVAIndices, 4 * sizeof(SkYUVAIndex));
}
@@ -80,6 +84,8 @@
SkImage_GpuYUVA::~SkImage_GpuYUVA() {}
bool SkImage_GpuYUVA::setupMipmapsForPlanes(GrRecordingContext* context) const {
+ // We shouldn't get here if the planes were already flattened to RGBA.
+ SkASSERT(fProxies[0] && !fRGBProxy);
if (!context || !fContext->priv().matches(context)) {
return false;
}
@@ -108,12 +114,15 @@
return GrSemaphoresSubmitted::kNo;
}
- GrSurfaceProxy* proxies[5] = {fProxies[0].get(), fProxies[1].get(),
- fProxies[2].get(), fProxies[3].get(), nullptr};
+ GrSurfaceProxy* proxies[4] = {fProxies[0].get(), fProxies[1].get(),
+ fProxies[2].get(), fProxies[3].get()};
int numProxies = fNumProxies;
if (fRGBProxy) {
- proxies[fNumProxies] = fRGBProxy.get();
- ++numProxies;
+ // Either we've already flushed the flattening draw or the flattening is unflushed. In the
+ // latter case it should still be ok to just pass fRGBProxy because it in turn depends on
+ // the planar proxies and will cause all of their work to flush as well.
+ proxies[0] = fRGBProxy.get();
+ numProxies = 1;
}
return context->priv().flushSurfaces(proxies, numProxies, info);
}
@@ -155,6 +164,9 @@
}
fRGBProxy = renderTargetContext->asTextureProxyRef();
+ for (auto& p : fProxies) {
+ p.reset();
+ }
return fRGBProxy;
}
diff --git a/src/image/SkImage_GpuYUVA.h b/src/image/SkImage_GpuYUVA.h
index daa9ee1..693a250 100644
--- a/src/image/SkImage_GpuYUVA.h
+++ b/src/image/SkImage_GpuYUVA.h
@@ -36,29 +36,25 @@
GrTextureProxy* peekProxy() const override;
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override;
- virtual bool onIsTextureBacked() const override { return SkToBool(fProxies[0].get()); }
+ virtual bool onIsTextureBacked() const override { return fProxies[0] || fRGBProxy; }
sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType, sk_sp<SkColorSpace>) const final;
virtual bool isYUVA() const override { return true; }
- virtual bool asYUVATextureProxiesRef(sk_sp<GrTextureProxy> proxies[4],
- SkYUVAIndex yuvaIndices[4],
- SkYUVColorSpace* yuvColorSpace) const override {
- for (int i = 0; i < 4; ++i) {
- proxies[i] = fProxies[i];
- yuvaIndices[i] = fYUVAIndices[i];
- }
- *yuvColorSpace = fYUVColorSpace;
- return true;
- }
bool setupMipmapsForPlanes(GrRecordingContext*) const;
// Returns a ref-ed texture proxy with miplevels
sk_sp<GrTextureProxy> asMippedTextureProxyRef(GrRecordingContext*) const;
- bool testingOnly_IsFlattened() const { return SkToBool(fRGBProxy); }
+#if GR_TEST_UTILS
+ bool testingOnly_IsFlattened() const {
+ // We should only have the flattened proxy or the planar proxies at one point in time.
+ SkASSERT(SkToBool(fRGBProxy) != SkToBool(fProxies[0]));
+ return SkToBool(fRGBProxy);
+ }
+#endif
/**
* This is the implementation of SkDeferredDisplayListRecorder::makeYUVAPromiseTexture.