Add origin back to GrCopyRenderTask
Will be needed for repositionable DDLs.
Change-Id: I6dacf51bd36cfbe1c54a9350987f17a6d18cf3c4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357776
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrCopyRenderTask.cpp b/src/gpu/GrCopyRenderTask.cpp
index 1481ce8..f2887e3 100644
--- a/src/gpu/GrCopyRenderTask.cpp
+++ b/src/gpu/GrCopyRenderTask.cpp
@@ -16,20 +16,25 @@
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
SkIPoint dstPoint,
- const GrCaps* caps) {
+ GrSurfaceOrigin origin) {
SkASSERT(src);
SkASSERT(dst);
- // Make sure our caller's values are inside the backing surfaces' bounds.
- SkASSERT(SkIRect::MakeSize(src->backingStoreDimensions()).contains(srcRect));
- SkASSERT(SkIRect::MakeSize(dst->backingStoreDimensions()).contains(
- SkIRect::MakePtSize(dstPoint, srcRect.size())));
+ if (!GrClipSrcRectAndDstPoint(dst->dimensions(),
+ src->dimensions(),
+ srcRect,
+ dstPoint,
+ &srcRect,
+ &dstPoint)) {
+ return nullptr;
+ }
sk_sp<GrCopyRenderTask> task(new GrCopyRenderTask(drawingMgr,
std::move(src),
srcRect,
std::move(dst),
- dstPoint));
+ dstPoint,
+ origin));
return std::move(task);
}
@@ -37,8 +42,9 @@
sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
- SkIPoint dstPoint)
- : GrRenderTask(), fSrc(std::move(src)), fSrcRect(srcRect), fDstPoint(dstPoint) {
+ SkIPoint dstPoint,
+ GrSurfaceOrigin origin)
+ : fSrc(std::move(src)), fSrcRect(srcRect), fDstPoint(dstPoint), fOrigin(origin) {
this->addTarget(drawingMgr, std::move(dst));
}
@@ -53,6 +59,15 @@
alloc->incOps();
}
+GrRenderTask::ExpectedOutcome GrCopyRenderTask::onMakeClosed(const GrCaps&,
+ SkIRect* targetUpdateBounds) {
+ *targetUpdateBounds = GrNativeRect::MakeIRectRelativeTo(
+ fOrigin,
+ this->target(0)->height(),
+ SkIRect::MakePtSize(fDstPoint, fSrcRect.size()));
+ return ExpectedOutcome::kTargetDirty;
+}
+
bool GrCopyRenderTask::onExecute(GrOpFlushState* flushState) {
GrSurfaceProxy* dstProxy = this->target(0);
if (!fSrc->isInstantiated() || !dstProxy->isInstantiated()) {
@@ -60,6 +75,11 @@
}
GrSurface* srcSurface = fSrc->peekSurface();
GrSurface* dstSurface = dstProxy->peekSurface();
- return flushState->gpu()->copySurface(dstSurface, srcSurface, fSrcRect, fDstPoint);
+ SkIRect srcRect = GrNativeRect::MakeIRectRelativeTo(fOrigin, srcSurface->height(), fSrcRect);
+ SkIPoint dstPoint = fDstPoint;
+ if (fOrigin == kBottomLeft_GrSurfaceOrigin) {
+ dstPoint.fY = dstSurface->height() - dstPoint.fY - srcRect.height();
+ }
+ return flushState->gpu()->copySurface(dstSurface, srcSurface, srcRect, dstPoint);
}
diff --git a/src/gpu/GrCopyRenderTask.h b/src/gpu/GrCopyRenderTask.h
index a319d4c..515077e 100644
--- a/src/gpu/GrCopyRenderTask.h
+++ b/src/gpu/GrCopyRenderTask.h
@@ -14,30 +14,28 @@
public:
/**
* Copies pixels from srcRect in src to SkIRect::MakePtSize(dstPoint, srcRect.dimensions) in
- * dst. The coordinates are absolute pixel coordinates in the proxies' backing stores.
+ * dst. The src/dst share a common origin.
*/
static sk_sp<GrRenderTask> Make(GrDrawingManager*,
sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
SkIPoint dstPoint,
- const GrCaps*);
+ GrSurfaceOrigin);
private:
GrCopyRenderTask(GrDrawingManager*,
sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
- SkIPoint dstPoint);
+ SkIPoint dstPoint,
+ GrSurfaceOrigin);
bool onIsUsed(GrSurfaceProxy* proxy) const override { return proxy == fSrc.get(); }
// If instantiation failed, at flush time we simply will skip doing the copy.
void handleInternalAllocationFailure() override {}
void gatherProxyIntervals(GrResourceAllocator*) const override;
- ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override {
- *targetUpdateBounds = SkIRect::MakePtSize(fDstPoint, fSrcRect.size());
- return ExpectedOutcome::kTargetDirty;
- }
+ ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override;
bool onExecute(GrOpFlushState*) override;
#if GR_TEST_UTILS
@@ -52,6 +50,7 @@
sk_sp<GrSurfaceProxy> fSrc;
SkIRect fSrcRect;
SkIPoint fDstPoint;
+ GrSurfaceOrigin fOrigin;
};
#endif
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 1f2ab64..b185589 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -840,23 +840,24 @@
bool GrDrawingManager::newCopyRenderTask(sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
- SkIPoint dstPoint) {
+ SkIPoint dstPoint,
+ GrSurfaceOrigin origin) {
SkDEBUGCODE(this->validate());
SkASSERT(fContext);
this->closeActiveOpsTask();
- const GrCaps& caps = *fContext->priv().caps();
GrRenderTask* task = this->appendTask(GrCopyRenderTask::Make(this,
src,
srcRect,
std::move(dst),
dstPoint,
- &caps));
+ origin));
if (!task) {
return false;
}
+ const GrCaps& caps = *fContext->priv().caps();
// We always say GrMipmapped::kNo here since we are always just copying from the base layer to
// another base layer. We don't need to make sure the whole mip map chain is valid.
task->addDependency(this, src.get(), GrMipmapped::kNo, GrTextureResolveManager(this), caps);
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 4896f96..bf9d718 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -80,7 +80,8 @@
bool newCopyRenderTask(sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
- SkIPoint dstPoint);
+ SkIPoint dstPoint,
+ GrSurfaceOrigin);
GrRecordingContext* getContext() { return fContext; }
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 13c15c3..95088dc 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -1036,22 +1036,11 @@
return false;
}
- if (!GrClipSrcRectAndDstPoint(this->dimensions(), src->dimensions(), srcRect, dstPoint,
- &srcRect, &dstPoint)) {
- return false;
- }
-
- if (this->origin() == kBottomLeft_GrSurfaceOrigin) {
- int rectHeight = srcRect.height();
- srcRect.fTop = src->backingStoreDimensions().height() - srcRect.fBottom;
- srcRect.fBottom = srcRect.fTop + rectHeight;
- dstPoint.fY = this->asSurfaceProxy()->backingStoreDimensions().height() -
- (dstPoint.fY + rectHeight);
- }
return this->drawingManager()->newCopyRenderTask(std::move(src),
srcRect,
this->asSurfaceProxyRef(),
- dstPoint);
+ dstPoint,
+ this->origin());
}
std::unique_ptr<GrSurfaceFillContext> GrSurfaceContext::rescale(const GrImageInfo& info,