Use GrSurfaceProxyView in RenderTasks.
Bug: skia:9556
Change-Id: Ibe0ae6981e87909848e5af73fc716aac7c8a591f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249232
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrCopyRenderTask.cpp b/src/gpu/GrCopyRenderTask.cpp
index 9e44187..39fa454 100644
--- a/src/gpu/GrCopyRenderTask.cpp
+++ b/src/gpu/GrCopyRenderTask.cpp
@@ -11,15 +11,17 @@
#include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrResourceAllocator.h"
-sk_sp<GrRenderTask> GrCopyRenderTask::Make(sk_sp<GrSurfaceProxy> srcProxy,
+sk_sp<GrRenderTask> GrCopyRenderTask::Make(GrSurfaceProxyView srcView,
const SkIRect& srcRect,
- sk_sp<GrSurfaceProxy> dstProxy,
+ GrSurfaceProxyView dstView,
const SkIPoint& dstPoint,
const GrCaps* caps) {
- SkASSERT(dstProxy);
- SkASSERT(srcProxy);
+ 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)) {
@@ -30,8 +32,8 @@
return nullptr;
}
- SkASSERT(dstProxy->origin() == srcProxy->origin());
- if (srcProxy->origin() == kBottomLeft_GrSurfaceOrigin) {
+ 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;
@@ -39,44 +41,46 @@
}
sk_sp<GrCopyRenderTask> task(new GrCopyRenderTask(
- std::move(srcProxy), clippedSrcRect, std::move(dstProxy), clippedDstPoint));
+ std::move(srcView), clippedSrcRect, std::move(dstView), clippedDstPoint));
return task;
}
-GrCopyRenderTask::GrCopyRenderTask(sk_sp<GrSurfaceProxy> srcProxy,
+GrCopyRenderTask::GrCopyRenderTask(GrSurfaceProxyView srcView,
const SkIRect& srcRect,
- sk_sp<GrSurfaceProxy> dstProxy,
+ GrSurfaceProxyView dstView,
const SkIPoint& dstPoint)
- : GrRenderTask(std::move(dstProxy))
- , fSrcProxy(std::move(srcProxy))
+ : GrRenderTask(std::move(dstView))
+ , fSrcView(std::move(srcView))
, fSrcRect(srcRect)
, fDstPoint(dstPoint) {
- fTarget->setLastRenderTask(this);
+ fTargetView.proxy()->setLastRenderTask(this);
}
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 fSrcProxy and copy to fTarget.
- alloc->addInterval(fSrcProxy.get(), alloc->curOp(), alloc->curOp(),
+ // we read fSrcView and copy to fTargetView.
+ alloc->addInterval(fSrcView.proxy(), alloc->curOp(), alloc->curOp(),
GrResourceAllocator::ActualUse::kYes);
- alloc->addInterval(fTarget.get(), alloc->curOp(), alloc->curOp(),
+ alloc->addInterval(fTargetView.proxy(), alloc->curOp(), alloc->curOp(),
GrResourceAllocator::ActualUse::kYes);
alloc->incOps();
}
bool GrCopyRenderTask::onExecute(GrOpFlushState* flushState) {
- if (!fSrcProxy->isInstantiated() || !fTarget->isInstantiated()) {
+ GrSurfaceProxy* dstProxy = fTargetView.proxy();
+ GrSurfaceProxy* srcProxy = fSrcView.proxy();
+ if (!srcProxy->isInstantiated() || !dstProxy->isInstantiated()) {
return false;
}
- GrSurface* srcSurface = fSrcProxy->peekSurface();
- GrSurface* dstSurface = fTarget->peekSurface();
- if (fSrcProxy->origin() == kBottomLeft_GrSurfaceOrigin) {
- if (fSrcProxy->height() != srcSurface->height()) {
- fSrcRect.offset(0, srcSurface->height() - fSrcProxy->height());
+ GrSurface* srcSurface = srcProxy->peekSurface();
+ GrSurface* dstSurface = dstProxy->peekSurface();
+ if (fSrcView.origin() == kBottomLeft_GrSurfaceOrigin) {
+ if (srcProxy->height() != srcSurface->height()) {
+ fSrcRect.offset(0, srcSurface->height() - srcProxy->height());
}
- if (fTarget->height() != dstSurface->height()) {
- fDstPoint.fY = fDstPoint.fY + (dstSurface->height() - fTarget->height());
+ if (dstProxy->height() != dstSurface->height()) {
+ fDstPoint.fY = fDstPoint.fY + (dstSurface->height() - dstProxy->height());
}
}
return flushState->gpu()->copySurface(dstSurface, srcSurface, fSrcRect, fDstPoint);