Make render task targets be just a proxy.
Change-Id: I09548cc22b13bc0b9b5f77cf1f20c1505a529c51
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356760
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrCopyRenderTask.cpp b/src/gpu/GrCopyRenderTask.cpp
index a578451..1481ce8 100644
--- a/src/gpu/GrCopyRenderTask.cpp
+++ b/src/gpu/GrCopyRenderTask.cpp
@@ -12,79 +12,54 @@
#include "src/gpu/GrResourceAllocator.h"
sk_sp<GrRenderTask> GrCopyRenderTask::Make(GrDrawingManager* drawingMgr,
- GrSurfaceProxyView srcView,
- const SkIRect& srcRect,
- GrSurfaceProxyView dstView,
- const SkIPoint& dstPoint,
+ sk_sp<GrSurfaceProxy> src,
+ SkIRect srcRect,
+ sk_sp<GrSurfaceProxy> dst,
+ SkIPoint dstPoint,
const GrCaps* caps) {
- SkASSERT(dstView.proxy());
- SkASSERT(srcView.proxy());
- SkIRect clippedSrcRect;
- SkIPoint clippedDstPoint;
- GrSurfaceProxy* srcProxy = srcView.proxy();
- GrSurfaceProxy* dstProxy = dstView.proxy();
- // If the rect is outside the srcProxy or dstProxy then we've already succeeded.
- if (!GrClipSrcRectAndDstPoint(dstProxy->dimensions(), srcProxy->dimensions(), srcRect, dstPoint,
- &clippedSrcRect, &clippedDstPoint)) {
- return nullptr;
- }
+ SkASSERT(src);
+ SkASSERT(dst);
- if (caps->isFormatCompressed(dstProxy->backendFormat())) {
- return nullptr;
- }
+ // 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())));
- SkASSERT(dstView.origin() == srcView.origin());
- if (srcView.origin() == kBottomLeft_GrSurfaceOrigin) {
- int rectHeight = clippedSrcRect.height();
- clippedSrcRect.fTop = srcProxy->height() - clippedSrcRect.fBottom;
- clippedSrcRect.fBottom = clippedSrcRect.fTop + rectHeight;
- clippedDstPoint.fY = dstProxy->height() - clippedDstPoint.fY - rectHeight;
- }
-
- sk_sp<GrCopyRenderTask> task(new GrCopyRenderTask(
- drawingMgr, std::move(srcView), clippedSrcRect, std::move(dstView), clippedDstPoint));
+ sk_sp<GrCopyRenderTask> task(new GrCopyRenderTask(drawingMgr,
+ std::move(src),
+ srcRect,
+ std::move(dst),
+ dstPoint));
return std::move(task);
}
GrCopyRenderTask::GrCopyRenderTask(GrDrawingManager* drawingMgr,
- GrSurfaceProxyView srcView,
- const SkIRect& srcRect,
- GrSurfaceProxyView dstView,
- const SkIPoint& dstPoint)
- : GrRenderTask()
- , fSrcView(std::move(srcView))
- , fSrcRect(srcRect)
- , fDstPoint(dstPoint) {
- this->addTarget(drawingMgr, dstView);
+ sk_sp<GrSurfaceProxy> src,
+ SkIRect srcRect,
+ sk_sp<GrSurfaceProxy> dst,
+ SkIPoint dstPoint)
+ : GrRenderTask(), fSrc(std::move(src)), fSrcRect(srcRect), fDstPoint(dstPoint) {
+ this->addTarget(drawingMgr, std::move(dst));
}
void GrCopyRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
// This renderTask doesn't have "normal" ops. In this case we still need to add an interval (so
// fEndOfOpsTaskOpIndices will remain in sync), so we create a fake op# to capture the fact that
// we read fSrcView and copy to target view.
- alloc->addInterval(fSrcView.proxy(), alloc->curOp(), alloc->curOp(),
+ alloc->addInterval(fSrc.get(), alloc->curOp(), alloc->curOp(),
GrResourceAllocator::ActualUse::kYes);
- alloc->addInterval(this->target(0).proxy(), alloc->curOp(), alloc->curOp(),
+ alloc->addInterval(this->target(0), alloc->curOp(), alloc->curOp(),
GrResourceAllocator::ActualUse::kYes);
alloc->incOps();
}
bool GrCopyRenderTask::onExecute(GrOpFlushState* flushState) {
- GrSurfaceProxy* dstProxy = this->target(0).proxy();
- GrSurfaceProxy* srcProxy = fSrcView.proxy();
- if (!srcProxy->isInstantiated() || !dstProxy->isInstantiated()) {
+ GrSurfaceProxy* dstProxy = this->target(0);
+ if (!fSrc->isInstantiated() || !dstProxy->isInstantiated()) {
return false;
}
- GrSurface* srcSurface = srcProxy->peekSurface();
+ GrSurface* srcSurface = fSrc->peekSurface();
GrSurface* dstSurface = dstProxy->peekSurface();
- if (fSrcView.origin() == kBottomLeft_GrSurfaceOrigin) {
- if (srcProxy->height() != srcSurface->height()) {
- fSrcRect.offset(0, srcSurface->height() - srcProxy->height());
- }
- if (dstProxy->height() != dstSurface->height()) {
- fDstPoint.fY = fDstPoint.fY + (dstSurface->height() - dstProxy->height());
- }
- }
return flushState->gpu()->copySurface(dstSurface, srcSurface, fSrcRect, fDstPoint);
}