Reland "Remove support for copyAsDraw in gpu copySurface."
This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
Reason for revert: fixed
Original change's description:
> Revert "Remove support for copyAsDraw in gpu copySurface."
>
> This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
>
> Reason for revert: seems to break things?
>
> Original change's description:
> > Remove support for copyAsDraw in gpu copySurface.
> >
> > The major changes on a higher lever are:
> > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > takes in a proxy and returns a new one with the data copied to it. This
> > is the most common use case within Ganesh.
> >
> > 2) The backend copy calls no longer do draws, require origins to be the
> > same, and won't do any swizzling or adjustment of subrects. They are
> > all implemented to be dumb copy this data to this other spot.
> >
> > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> >
> > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > call the priv methods on GrSurfaceContext.
> >
> > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index d716d39..ac19e91 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
+#include "src/gpu/GrSurfaceContext.h"
+
#include "include/private/GrAuditTrail.h"
#include "include/private/GrOpList.h"
#include "include/private/GrRecordingContext.h"
@@ -15,7 +17,7 @@
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h"
-#include "src/gpu/GrSurfaceContext.h"
+#include "src/gpu/GrSurfaceContextPriv.h"
#include "src/gpu/GrSurfacePriv.h"
#include "src/gpu/GrTextureContext.h"
#include "src/gpu/SkGr.h"
@@ -377,7 +379,7 @@
}
auto tempProxy = direct->priv().proxyProvider()->createProxy(
- format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
+ format, desc, dstProxy->origin(), SkBackingFit::kApprox, SkBudgeted::kYes);
if (!tempProxy) {
return false;
}
@@ -399,7 +401,7 @@
}
if (this->asRenderTargetContext()) {
- std::unique_ptr<GrFragmentProcessor> fp;
+ std::unique_ptr<GrFragmentProcessor> fp;
if (canvas2DFastPath) {
fp = direct->priv().createUPMToPMEffect(
GrSimpleTextureEffect::Make(std::move(tempProxy), SkMatrix::I()));
@@ -421,10 +423,9 @@
} else {
SkIRect srcRect = SkIRect::MakeWH(width, height);
SkIPoint dstPoint = SkIPoint::Make(left, top);
- if (!caps->canCopySurface(this->asSurfaceProxy(), tempProxy.get(), srcRect, dstPoint)) {
+ if (!this->copy(tempProxy.get(), srcRect, dstPoint)) {
return false;
}
- SkAssertResult(this->copy(tempProxy.get(), srcRect, dstPoint));
}
return true;
}
@@ -531,13 +532,17 @@
ASSERT_SINGLE_OWNER
RETURN_FALSE_IF_ABANDONED
SkDEBUGCODE(this->validate();)
- GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContext::copy");
+ GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContextPriv::copy");
- if (!fContext->priv().caps()->canCopySurface(this->asSurfaceProxy(), src, srcRect,
- dstPoint)) {
+ SkASSERT(src->backendFormat().textureType() != GrTextureType::kExternal);
+ SkASSERT(src->origin() == this->asSurfaceProxy()->origin());
+
+ GrSurfaceProxy* dst = this->asSurfaceProxy();
+
+ if (!fContext->priv().caps()->canCopySurface(dst, src, srcRect, dstPoint)) {
return false;
}
- return this->getOpList()->copySurface(fContext, this->asSurfaceProxy(),
- src, srcRect, dstPoint);
+ return this->getOpList()->copySurface(fContext, dst, src, srcRect, dstPoint);
}
+