diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp index 0b7df902c0..4e08ecc4aa 100644 --- a/src/gpu/GrBackendTextureImageGenerator.cpp +++ b/src/gpu/GrBackendTextureImageGenerator.cpp @@ -219,8 +219,13 @@ GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture( ? SkBudgeted::kNo : SkBudgeted::kYes; - auto copy = GrSurfaceProxy::Copy(context, proxy.get(), fSurfaceOrigin, mipMapped, subset, - SkBackingFit::kExact, budgeted); + auto copy = GrSurfaceProxy::Copy(context, + std::move(proxy), + fSurfaceOrigin, + mipMapped, + subset, + SkBackingFit::kExact, + budgeted); return {std::move(copy), fSurfaceOrigin, readSwizzle}; } } diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp index b3745c89cf..b9167cb063 100644 --- a/src/gpu/GrBitmapTextureMaker.cpp +++ b/src/gpu/GrBitmapTextureMaker.cpp @@ -107,7 +107,7 @@ GrSurfaceProxyView GrBitmapTextureMaker::refOriginalTextureProxyView(GrMipmapped // We need a mipped proxy, but we found a proxy earlier that wasn't mipped. Thus we generate // a new mipped surface and copy the original proxy into the base layer. We will then let // the gpu generate the rest of the mips. - auto mippedProxy = GrCopyBaseMipMapToTextureProxy(this->context(), proxy.get(), + auto mippedProxy = GrCopyBaseMipMapToTextureProxy(this->context(), proxy, kTopLeft_GrSurfaceOrigin); if (!mippedProxy) { // We failed to make a mipped proxy with the base copied into it. This could have diff --git a/src/gpu/GrCopyRenderTask.cpp b/src/gpu/GrCopyRenderTask.cpp index a578451b1a..1481ce88b6 100644 --- a/src/gpu/GrCopyRenderTask.cpp +++ b/src/gpu/GrCopyRenderTask.cpp @@ -12,79 +12,54 @@ #include "src/gpu/GrResourceAllocator.h" sk_sp GrCopyRenderTask::Make(GrDrawingManager* drawingMgr, - GrSurfaceProxyView srcView, - const SkIRect& srcRect, - GrSurfaceProxyView dstView, - const SkIPoint& dstPoint, + sk_sp src, + SkIRect srcRect, + sk_sp 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 task(new GrCopyRenderTask( - drawingMgr, std::move(srcView), clippedSrcRect, std::move(dstView), clippedDstPoint)); + sk_sp 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 src, + SkIRect srcRect, + sk_sp 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); } diff --git a/src/gpu/GrCopyRenderTask.h b/src/gpu/GrCopyRenderTask.h index c3d10667e6..a319d4cd6f 100644 --- a/src/gpu/GrCopyRenderTask.h +++ b/src/gpu/GrCopyRenderTask.h @@ -12,29 +12,30 @@ class GrCopyRenderTask final : public GrRenderTask { 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. + */ static sk_sp Make(GrDrawingManager*, - GrSurfaceProxyView srcView, - const SkIRect& srcRect, - GrSurfaceProxyView dstView, - const SkIPoint& dstPoint, + sk_sp src, + SkIRect srcRect, + sk_sp dst, + SkIPoint dstPoint, const GrCaps*); private: GrCopyRenderTask(GrDrawingManager*, - GrSurfaceProxyView srcView, - const SkIRect& srcRect, - GrSurfaceProxyView dstView, - const SkIPoint& dstPoint); + sk_sp src, + SkIRect srcRect, + sk_sp dst, + SkIPoint dstPoint); - bool onIsUsed(GrSurfaceProxy* proxy) const override { - return proxy == fSrcView.proxy(); - } + 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->setXYWH(fDstPoint.x(), fDstPoint.y(), fSrcRect.width(), - fSrcRect.height()); + *targetUpdateBounds = SkIRect::MakePtSize(fDstPoint, fSrcRect.size()); return ExpectedOutcome::kTargetDirty; } bool onExecute(GrOpFlushState*) override; @@ -44,11 +45,11 @@ private: #endif #ifdef SK_DEBUG void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override { - fn(fSrcView.proxy(), GrMipmapped::kNo); + fn(fSrc.get(), GrMipmapped::kNo); } #endif - GrSurfaceProxyView fSrcView; + sk_sp fSrc; SkIRect fSrcRect; SkIPoint fDstPoint; }; diff --git a/src/gpu/GrDDLTask.cpp b/src/gpu/GrDDLTask.cpp index ab90e28d0f..f689ec230f 100644 --- a/src/gpu/GrDDLTask.cpp +++ b/src/gpu/GrDDLTask.cpp @@ -24,7 +24,7 @@ GrDDLTask::GrDDLTask(GrDrawingManager* drawingMgr, SkASSERT(task->isClosed()); for (int i = 0; i < task->numTargets(); ++i) { - drawingMgr->setLastRenderTask(task->target(i).proxy(), task.get()); + drawingMgr->setLastRenderTask(task->target(i), task.get()); } } diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index 7437d32776..5c1b9b505f 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -414,7 +414,7 @@ void GrDrawingManager::sortTasks() { GrOpsTask* curOpsTask = fDAG[i]->asOpsTask(); if (prevOpsTask && curOpsTask) { - SkASSERT(prevOpsTask->target(0).proxy() != curOpsTask->target(0).proxy()); + SkASSERT(prevOpsTask->target(0) != curOpsTask->target(0)); } prevOpsTask = curOpsTask; @@ -631,8 +631,11 @@ void GrDrawingManager::createDDLTask(sk_sp ddl, // Propagate the DDL proxy's state information to the replay target. if (ddl->priv().targetProxy()->isMSAADirty()) { - newDest->markMSAADirty(ddl->priv().targetProxy()->msaaDirtyRect(), - ddl->characterization().origin()); + auto nativeRect = GrNativeRect::MakeIRectRelativeTo( + ddl->characterization().origin(), + ddl->priv().targetProxy()->backingStoreDimensions().height(), + ddl->priv().targetProxy()->msaaDirtyRect()); + newDest->markMSAADirty(nativeRect); } GrTextureProxy* newTextureProxy = newDest->asTextureProxy(); if (newTextureProxy && GrMipmapped::kYes == newTextureProxy->mipmapped()) { @@ -704,7 +707,7 @@ sk_sp GrDrawingManager::newOpsTask(GrSurfaceProxyView surfaceView, sk_sp opsTask(new GrOpsTask(this, fContext->priv().arenas(), std::move(surfaceView), fContext->priv().auditTrail())); - SkASSERT(this->getLastRenderTask(opsTask->target(0).proxy()) == opsTask.get()); + SkASSERT(this->getLastRenderTask(opsTask->target(0)) == opsTask.get()); if (flushTimeOpsTask) { fOnFlushRenderTasks.push_back(opsTask); @@ -744,7 +747,7 @@ void GrDrawingManager::newWaitRenderTask(sk_sp proxy, std::move(semaphores), numSemaphores); - if (fActiveOpsTask && (fActiveOpsTask->target(0).proxy() == proxy.get())) { + if (fActiveOpsTask && (fActiveOpsTask->target(0) == proxy.get())) { SkASSERT(this->getLastRenderTask(proxy.get()) == fActiveOpsTask); this->insertTaskBeforeLast(waitTask); // In this case we keep the current renderTask open but just insert the new waitTask @@ -807,28 +810,29 @@ void GrDrawingManager::newTransferFromRenderTask(sk_sp srcProxy, SkDEBUGCODE(this->validate()); } -bool GrDrawingManager::newCopyRenderTask(GrSurfaceProxyView srcView, - const SkIRect& srcRect, - GrSurfaceProxyView dstView, - const SkIPoint& dstPoint) { +bool GrDrawingManager::newCopyRenderTask(sk_sp src, + SkIRect srcRect, + sk_sp dst, + SkIPoint dstPoint) { SkDEBUGCODE(this->validate()); SkASSERT(fContext); this->closeActiveOpsTask(); const GrCaps& caps = *fContext->priv().caps(); - GrSurfaceProxy* srcProxy = srcView.proxy(); - - GrRenderTask* task = - this->appendTask(GrCopyRenderTask::Make(this, std::move(srcView), srcRect, - std::move(dstView), dstPoint, &caps)); + GrRenderTask* task = this->appendTask(GrCopyRenderTask::Make(this, + src, + srcRect, + std::move(dst), + dstPoint, + &caps)); if (!task) { return false; } // 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, srcProxy, GrMipmapped::kNo, GrTextureResolveManager(this), caps); + task->addDependency(this, src.get(), GrMipmapped::kNo, GrTextureResolveManager(this), caps); task->makeClosed(caps); // We have closed the previous active oplist but since a new oplist isn't being added there diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h index 19c51547ae..4896f96f12 100644 --- a/src/gpu/GrDrawingManager.h +++ b/src/gpu/GrDrawingManager.h @@ -77,8 +77,10 @@ public: // values in the dst rect corresponding to the area clipped by the src rect are not overwritten. // This method is not guaranteed to succeed depending on the type of surface, formats, etc, and // the backend-specific limitations. - bool newCopyRenderTask(GrSurfaceProxyView srcView, const SkIRect& srcRect, - GrSurfaceProxyView dstView, const SkIPoint& dstPoint); + bool newCopyRenderTask(sk_sp src, + SkIRect srcRect, + sk_sp dst, + SkIPoint dstPoint); GrRecordingContext* getContext() { return fContext; } diff --git a/src/gpu/GrNativeRect.h b/src/gpu/GrNativeRect.h index 9b9013464b..c19df766f7 100644 --- a/src/gpu/GrNativeRect.h +++ b/src/gpu/GrNativeRect.h @@ -22,17 +22,14 @@ struct GrNativeRect { int fWidth; int fHeight; - static GrNativeRect MakeRelativeTo(GrSurfaceOrigin org, int rtHeight, const SkIRect& devRect) { + static GrNativeRect MakeRelativeTo(GrSurfaceOrigin origin, int rtHeight, SkIRect devRect) { GrNativeRect nativeRect; - nativeRect.setRelativeTo(org, rtHeight, devRect); + nativeRect.setRelativeTo(origin, rtHeight, devRect); return nativeRect; } - static GrNativeRect MakeRelativeTo(GrSurfaceOrigin origin, int surfaceHeight, int leftOffset, - int topOffset, int width, int height) { - GrNativeRect nativeRect; - nativeRect.setRelativeTo(origin, surfaceHeight, leftOffset, topOffset, width, height); - return nativeRect; + static SkIRect MakeIRectRelativeTo(GrSurfaceOrigin origin, int rtHeight, SkIRect devRect) { + return MakeRelativeTo(origin, rtHeight, devRect).asSkIRect(); } /** diff --git a/src/gpu/GrOpsTask.cpp b/src/gpu/GrOpsTask.cpp index 7a20c9ae03..db8a27b13d 100644 --- a/src/gpu/GrOpsTask.cpp +++ b/src/gpu/GrOpsTask.cpp @@ -356,14 +356,17 @@ inline void GrOpsTask::OpChain::validate() const { //////////////////////////////////////////////////////////////////////////////// -GrOpsTask::GrOpsTask(GrDrawingManager* drawingMgr, GrRecordingContext::Arenas arenas, +GrOpsTask::GrOpsTask(GrDrawingManager* drawingMgr, + GrRecordingContext::Arenas arenas, GrSurfaceProxyView view, GrAuditTrail* auditTrail) : GrRenderTask() , fArenas(arenas) , fAuditTrail(auditTrail) - SkDEBUGCODE(, fNumClips(0)) { - this->addTarget(drawingMgr, std::move(view)); + , fTargetSwizzle(view.swizzle()) + , fTargetOrigin(view.origin()) + SkDEBUGCODE(, fNumClips(0)) { + this->addTarget(drawingMgr, view.detachProxy()); } void GrOpsTask::deleteOps() { @@ -404,7 +407,7 @@ void GrOpsTask::addDrawOp(GrDrawingManager* drawingMgr, GrOp::Owner op, this->addSampledTexture(dstProxyView.proxy()); } addDependency(dstProxyView.proxy(), GrMipmapped::kNo); - if (this->target(0).proxy() == dstProxyView.proxy()) { + if (this->target(0) == dstProxyView.proxy()) { // Since we are sampling and drawing to the same surface we will need to use // texture barriers. SkASSERT(GrDstSampleTypeDirectlySamplesDst(dstProxyView.dstSampleType())); @@ -448,10 +451,11 @@ void GrOpsTask::onPrePrepare(GrRecordingContext* context) { return; } + GrSurfaceProxyView dstView(sk_ref_sp(this->target(0)), fTargetOrigin, fTargetSwizzle); for (const auto& chain : fOpChains) { if (chain.shouldExecute()) { chain.head()->prePrepare(context, - this->target(0), + dstView, chain.appliedClip(), chain.dstProxyView(), fRenderPassXferBarriers, @@ -461,7 +465,7 @@ void GrOpsTask::onPrePrepare(GrRecordingContext* context) { } void GrOpsTask::onPrepare(GrOpFlushState* flushState) { - SkASSERT(this->target(0).proxy()->peekRenderTarget()); + SkASSERT(this->target(0)->peekRenderTarget()); SkASSERT(this->isClosed()); #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK TRACE_EVENT0("skia.gpu", TRACE_FUNC); @@ -475,6 +479,7 @@ void GrOpsTask::onPrepare(GrOpFlushState* flushState) { } flushState->setSampledProxyArray(&fSampledProxies); + GrSurfaceProxyView dstView(sk_ref_sp(this->target(0)), fTargetOrigin, fTargetSwizzle); // Loop over the ops that haven't yet been prepared. for (const auto& chain : fOpChains) { if (chain.shouldExecute()) { @@ -482,7 +487,7 @@ void GrOpsTask::onPrepare(GrOpFlushState* flushState) { TRACE_EVENT0("skia.gpu", chain.head()->name()); #endif GrOpFlushState::OpArgs opArgs(chain.head(), - this->target(0), + dstView, chain.appliedClip(), chain.dstProxyView(), fRenderPassXferBarriers, @@ -548,7 +553,7 @@ bool GrOpsTask::onExecute(GrOpFlushState* flushState) { } SkASSERT(this->numTargets() == 1); - GrRenderTargetProxy* proxy = this->target(0).proxy()->asRenderTargetProxy(); + GrRenderTargetProxy* proxy = this->target(0)->asRenderTargetProxy(); SkASSERT(proxy); TRACE_EVENT0("skia.gpu", TRACE_FUNC); @@ -614,10 +619,17 @@ bool GrOpsTask::onExecute(GrOpFlushState* flushState) { ? GrStoreOp::kDiscard : GrStoreOp::kStore; - GrOpsRenderPass* renderPass = create_render_pass( - flushState->gpu(), proxy->peekRenderTarget(), stencil, this->target(0).origin(), - fClippedContentBounds, fColorLoadOp, fLoadClearColor, stencilLoadOp, stencilStoreOp, - fSampledProxies, fRenderPassXferBarriers); + GrOpsRenderPass* renderPass = create_render_pass(flushState->gpu(), + proxy->peekRenderTarget(), + stencil, + fTargetOrigin, + fClippedContentBounds, + fColorLoadOp, + fLoadClearColor, + stencilLoadOp, + stencilStoreOp, + fSampledProxies, + fRenderPassXferBarriers); if (!renderPass) { return false; @@ -625,6 +637,8 @@ bool GrOpsTask::onExecute(GrOpFlushState* flushState) { flushState->setOpsRenderPass(renderPass); renderPass->begin(); + GrSurfaceProxyView dstView(sk_ref_sp(this->target(0)), fTargetOrigin, fTargetSwizzle); + // Draw all the generated geometry. for (const auto& chain : fOpChains) { if (!chain.shouldExecute()) { @@ -635,7 +649,7 @@ bool GrOpsTask::onExecute(GrOpFlushState* flushState) { #endif GrOpFlushState::OpArgs opArgs(chain.head(), - this->target(0), + dstView, chain.appliedClip(), chain.dstProxyView(), fRenderPassXferBarriers, @@ -657,7 +671,7 @@ void GrOpsTask::setColorLoadOp(GrLoadOp op, std::array color) { fColorLoadOp = op; fLoadClearColor = color; if (GrLoadOp::kClear == fColorLoadOp) { - GrSurfaceProxy* proxy = this->target(0).proxy(); + GrSurfaceProxy* proxy = this->target(0); SkASSERT(proxy); fTotalBounds = proxy->backingStoreBoundsRect(); } @@ -672,7 +686,7 @@ bool GrOpsTask::resetForFullscreenClear(CanDiscardPreviousOps canDiscardPrevious // If the opsTask is using a render target which wraps a vulkan command buffer, we can't do // a clear load since we cannot change the render pass that we are using. Thus we fall back // to making a clear op in this case. - return !this->target(0).asRenderTargetProxy()->wrapsVkSecondaryCB(); + return !this->target(0)->asRenderTargetProxy()->wrapsVkSecondaryCB(); } // Could not empty the task, so an op must be added to handle the clear @@ -814,7 +828,7 @@ void GrOpsTask::gatherProxyIntervals(GrResourceAllocator* alloc) const { alloc->addInterval(fDeferredProxies[i], 0, 0, GrResourceAllocator::ActualUse::kNo); } - GrSurfaceProxy* targetProxy = this->target(0).proxy(); + GrSurfaceProxy* targetProxy = this->target(0); // Add the interval for all the writes to this GrOpsTasks's target if (fOpChains.count()) { @@ -832,8 +846,11 @@ void GrOpsTask::gatherProxyIntervals(GrResourceAllocator* alloc) const { } auto gather = [ alloc SkDEBUGCODE(, this) ] (GrSurfaceProxy* p, GrMipmapped) { - alloc->addInterval(p, alloc->curOp(), alloc->curOp(), GrResourceAllocator::ActualUse::kYes - SkDEBUGCODE(, this->target(0).proxy() == p)); + alloc->addInterval(p, + alloc->curOp(), + alloc->curOp(), + GrResourceAllocator::ActualUse::kYes + SkDEBUGCODE(, this->target(0) == p)); }; for (const OpChain& recordedOp : fOpChains) { recordedOp.visitProxies(gather); @@ -849,7 +866,7 @@ void GrOpsTask::recordOp( const DstProxyView* dstProxyView, const GrCaps& caps) { SkDEBUGCODE(op->validate();) SkASSERT(processorAnalysis.requiresDstTexture() == (dstProxyView && dstProxyView->proxy())); - GrSurfaceProxy* proxy = this->target(0).proxy(); + GrSurfaceProxy* proxy = this->target(0); SkASSERT(proxy); // A closed GrOpsTask should never receive new/more ops @@ -942,7 +959,7 @@ GrRenderTask::ExpectedOutcome GrOpsTask::onMakeClosed(const GrCaps& caps, SkIRect* targetUpdateBounds) { this->forwardCombine(caps); if (!this->isNoOp()) { - GrSurfaceProxy* proxy = this->target(0).proxy(); + GrSurfaceProxy* proxy = this->target(0); // Use the entire backing store bounds since the GPU doesn't clip automatically to the // logical dimensions. SkRect clippedContentBounds = proxy->backingStoreBoundsRect(); @@ -950,7 +967,10 @@ GrRenderTask::ExpectedOutcome GrOpsTask::onMakeClosed(const GrCaps& caps, // then we can simply assert here that the bounds intersect. if (clippedContentBounds.intersect(fTotalBounds)) { clippedContentBounds.roundOut(&fClippedContentBounds); - *targetUpdateBounds = fClippedContentBounds; + *targetUpdateBounds = GrNativeRect::MakeIRectRelativeTo( + fTargetOrigin, + this->target(0)->backingStoreDimensions().height(), + fClippedContentBounds); return ExpectedOutcome::kTargetDirty; } } diff --git a/src/gpu/GrOpsTask.h b/src/gpu/GrOpsTask.h index baad64005a..e62f4ec9a5 100644 --- a/src/gpu/GrOpsTask.h +++ b/src/gpu/GrOpsTask.h @@ -251,6 +251,9 @@ private: GrRecordingContext::Arenas fArenas; GrAuditTrail* fAuditTrail; + GrSwizzle fTargetSwizzle; + GrSurfaceOrigin fTargetOrigin; + GrLoadOp fColorLoadOp = GrLoadOp::kLoad; std::array fLoadClearColor = {0, 0, 0, 0}; StencilContent fInitialStencilContent = StencilContent::kDontCare; diff --git a/src/gpu/GrRenderTargetProxy.h b/src/gpu/GrRenderTargetProxy.h index 9f4f0ca480..ef92b07c7b 100644 --- a/src/gpu/GrRenderTargetProxy.h +++ b/src/gpu/GrRenderTargetProxy.h @@ -64,12 +64,10 @@ public: return fSurfaceFlags & GrInternalSurfaceFlags::kVkRTSupportsInputAttachment; } - void markMSAADirty(const SkIRect& dirtyRect, GrSurfaceOrigin origin) { + void markMSAADirty(SkIRect dirtyRect) { SkASSERT(SkIRect::MakeSize(this->backingStoreDimensions()).contains(dirtyRect)); SkASSERT(this->requiresManualMSAAResolve()); - auto nativeRect = GrNativeRect::MakeRelativeTo( - origin, this->backingStoreDimensions().height(), dirtyRect); - fMSAADirtyRect.join(nativeRect.asSkIRect()); + fMSAADirtyRect.join(dirtyRect); } void markMSAAResolved() { SkASSERT(this->requiresManualMSAAResolve()); diff --git a/src/gpu/GrRenderTask.cpp b/src/gpu/GrRenderTask.cpp index 0c24d50514..074f4a9c59 100644 --- a/src/gpu/GrRenderTask.cpp +++ b/src/gpu/GrRenderTask.cpp @@ -35,9 +35,9 @@ void GrRenderTask::disown(GrDrawingManager* drawingMgr) { SkDEBUGCODE(fDrawingMgr = nullptr); this->setFlag(kDisowned_Flag); - for (const GrSurfaceProxyView& target : fTargets) { - if (this == drawingMgr->getLastRenderTask(target.proxy())) { - drawingMgr->setLastRenderTask(target.proxy(), nullptr); + for (const sk_sp& target : fTargets) { + if (this == drawingMgr->getLastRenderTask(target.get())) { + drawingMgr->setLastRenderTask(target.get(), nullptr); } } } @@ -65,13 +65,12 @@ void GrRenderTask::makeClosed(const GrCaps& caps) { SkIRect targetUpdateBounds; if (ExpectedOutcome::kTargetDirty == this->onMakeClosed(caps, &targetUpdateBounds)) { - GrSurfaceProxy* proxy = this->target(0).proxy(); + GrSurfaceProxy* proxy = this->target(0); if (proxy->requiresManualMSAAResolve()) { - SkASSERT(this->target(0).asRenderTargetProxy()); - this->target(0).asRenderTargetProxy()->markMSAADirty(targetUpdateBounds, - this->target(0).origin()); + SkASSERT(this->target(0)->asRenderTargetProxy()); + this->target(0)->asRenderTargetProxy()->markMSAADirty(targetUpdateBounds); } - GrTextureProxy* textureProxy = this->target(0).asTextureProxy(); + GrTextureProxy* textureProxy = this->target(0)->asTextureProxy(); if (textureProxy && GrMipmapped::kYes == textureProxy->mipmapped()) { textureProxy->markMipmapsDirty(); } @@ -257,8 +256,8 @@ void GrRenderTask::closeThoseWhoDependOnMe(const GrCaps& caps) { } bool GrRenderTask::isInstantiated() const { - for (const GrSurfaceProxyView& target : fTargets) { - GrSurfaceProxy* proxy = target.proxy(); + for (const sk_sp& target : fTargets) { + GrSurfaceProxy* proxy = target.get(); if (!proxy->isInstantiated()) { return false; } @@ -272,13 +271,13 @@ bool GrRenderTask::isInstantiated() const { return true; } -void GrRenderTask::addTarget(GrDrawingManager* drawingMgr, GrSurfaceProxyView view) { - SkASSERT(view); +void GrRenderTask::addTarget(GrDrawingManager* drawingMgr, sk_sp proxy) { + SkASSERT(proxy); SkASSERT(!this->isClosed()); SkASSERT(!fDrawingMgr || drawingMgr == fDrawingMgr); SkDEBUGCODE(fDrawingMgr = drawingMgr); - drawingMgr->setLastRenderTask(view.proxy(), this); - fTargets.push_back(std::move(view)); + drawingMgr->setLastRenderTask(proxy.get(), this); + fTargets.emplace_back(std::move(proxy)); } #if GR_TEST_UTILS @@ -293,11 +292,10 @@ void GrRenderTask::dump(const SkString& label, if (!fTargets.empty()) { SkDebugf("%sTargets: \n", indent.c_str()); - for (const GrSurfaceProxyView& target : fTargets) { - if (target.proxy()) { - SkString proxyStr = target.proxy()->dump(); - SkDebugf("%s%s\n", indent.c_str(), proxyStr.c_str()); - } + for (const sk_sp& target : fTargets) { + SkASSERT(target); + SkString proxyStr = target->dump(); + SkDebugf("%s%s\n", indent.c_str(), proxyStr.c_str()); } } diff --git a/src/gpu/GrRenderTask.h b/src/gpu/GrRenderTask.h index 598deac119..218267f334 100644 --- a/src/gpu/GrRenderTask.h +++ b/src/gpu/GrRenderTask.h @@ -76,7 +76,7 @@ public: } uint32_t uniqueID() const { return fUniqueID; } virtual int numTargets() const { return fTargets.count(); } - const GrSurfaceProxyView& target(int i) const { return fTargets[i]; } + GrSurfaceProxy* target(int i) const { return fTargets[i].get(); } /* * Safely cast this GrRenderTask to a GrOpsTask (if possible). @@ -101,15 +101,15 @@ public: void visitTargetAndSrcProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const { this->visitProxies_debugOnly(fn); - for (const GrSurfaceProxyView& target : fTargets) { - fn(target.proxy(), GrMipmapped::kNo); + for (const sk_sp& target : fTargets) { + fn(target.get(), GrMipmapped::kNo); } } #endif bool isUsed(GrSurfaceProxy* proxy) const { - for (const GrSurfaceProxyView& target : fTargets) { - if (target.proxy() == proxy) { + for (const sk_sp& target : fTargets) { + if (target.get() == proxy) { return true; } } @@ -137,7 +137,12 @@ protected: // Add a target surface proxy to the list of targets for this task. // This also informs the drawing manager to update the lastRenderTask association. - void addTarget(GrDrawingManager*, GrSurfaceProxyView); + void addTarget(GrDrawingManager*, sk_sp); + + // Helper that adds the proxy owned by a view. + void addTarget(GrDrawingManager* dm, const GrSurfaceProxyView& view) { + this->addTarget(dm, view.refProxy()); + } enum class ExpectedOutcome : bool { kTargetUnchanged, @@ -151,7 +156,7 @@ protected: // targetUpdateBounds must not extend beyond the proxy bounds. virtual ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) = 0; - SkSTArray<1, GrSurfaceProxyView> fTargets; + SkSTArray<1, sk_sp> fTargets; // List of texture proxies whose contents are being prepared on a worker thread // TODO: this list exists so we can fire off the proper upload when an renderTask begins diff --git a/src/gpu/GrRenderTaskCluster.cpp b/src/gpu/GrRenderTaskCluster.cpp index 9cf0343805..676ec49843 100644 --- a/src/gpu/GrRenderTaskCluster.cpp +++ b/src/gpu/GrRenderTaskCluster.cpp @@ -13,9 +13,7 @@ // Uncomment to get lots of logging. #define CLUSTER_DEBUGF(...) //SkDebugf(__VA_ARGS__) -static GrSurfaceProxy* first_target(GrRenderTask* task) { - return task->target(0).proxy(); -} +static GrSurfaceProxy* first_target(GrRenderTask* task) { return task->target(0); } #ifdef SK_DEBUG [[maybe_unused]] static SkString describe_task(GrRenderTask* t) { @@ -74,7 +72,7 @@ static bool task_cluster_visit(GrRenderTask* task, SkTInternalLListnumTargets(); j++) { - lastTaskMap->remove(task->target(0).proxy()); + lastTaskMap->remove(task->target(0)); } return false; } diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp index 5a85e88677..9c1784a670 100644 --- a/src/gpu/GrSurfaceContext.cpp +++ b/src/gpu/GrSurfaceContext.cpp @@ -185,7 +185,7 @@ bool GrSurfaceContext::readPixels(GrDirectContext* dContext, GrPixmap dst, SkIPo // We allow unknown alpha types but only if both src and dst are unknown. Otherwise, it's too // weird to reason about what should be expected. - GrSurfaceProxy* srcProxy = this->asSurfaceProxy(); + sk_sp srcProxy = this->asSurfaceProxyRef(); if (srcProxy->framebufferOnly()) { return false; @@ -274,12 +274,22 @@ bool GrSurfaceContext::readPixels(GrDirectContext* dContext, GrPixmap dst, SkIPo static constexpr auto kBudgeted = SkBudgeted::kYes; static constexpr auto kMipMapped = GrMipMapped::kNo; if (restrictions.fMustCopyWholeSrc) { - copy = GrSurfaceProxy::Copy(fContext, srcProxy, this->origin(), kMipMapped, kFit, + copy = GrSurfaceProxy::Copy(fContext, + std::move(srcProxy), + this->origin(), + kMipMapped, + kFit, kBudgeted); } else { auto srcRect = SkIRect::MakePtSize(pt, dst.dimensions()); - copy = GrSurfaceProxy::Copy(fContext, srcProxy, this->origin(), kMipMapped, srcRect, - kFit, kBudgeted, restrictions.fRectsMustMatch); + copy = GrSurfaceProxy::Copy(fContext, + std::move(srcProxy), + this->origin(), + kMipMapped, + srcRect, + kFit, + kBudgeted, + restrictions.fRectsMustMatch); pt = {0, 0}; } if (!copy) { @@ -323,7 +333,7 @@ bool GrSurfaceContext::readPixels(GrDirectContext* dContext, GrPixmap dst, SkIPo pt.fY = flip ? srcSurface->height() - pt.fY - dst.height() : pt.fY; } - dContext->priv().flushSurface(srcProxy); + dContext->priv().flushSurface(srcProxy.get()); dContext->submit(); if (!dContext->priv().getGpu()->readPixels(srcSurface, pt.fX, pt.fY, dst.width(), dst.height(), this->colorInfo().colorType(), @@ -461,7 +471,7 @@ bool GrSurfaceContext::writePixels(GrDirectContext* dContext, GrPixmap src, SkIP } else { SkIRect srcRect = SkIRect::MakeSize(src.dimensions()); SkIPoint dstPoint = SkIPoint::Make(pt.fX, pt.fY); - if (!this->copy(tempProxy.get(), srcRect, dstPoint)) { + if (!this->copy(std::move(tempProxy), srcRect, dstPoint)) { return false; } } @@ -1029,7 +1039,7 @@ void GrSurfaceContext::asyncRescaleAndReadPixelsYUV420(GrDirectContext* dContext flushInfo); } -bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { +bool GrSurfaceContext::copy(sk_sp src, SkIRect srcRect, SkIPoint dstPoint) { ASSERT_SINGLE_OWNER RETURN_FALSE_IF_ABANDONED SkDEBUGCODE(this->validate();) @@ -1044,14 +1054,26 @@ bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const S return false; } - if (!caps->canCopySurface(this->asSurfaceProxy(), src, srcRect, dstPoint)) { + if (!caps->canCopySurface(this->asSurfaceProxy(), src.get(), srcRect, dstPoint)) { return false; } - // The swizzle doesn't matter for copies and it is not used. - return this->drawingManager()->newCopyRenderTask( - GrSurfaceProxyView(sk_ref_sp(src), this->origin(), GrSwizzle("rgba")), srcRect, - this->readSurfaceView(), dstPoint); + 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); } std::unique_ptr GrSurfaceContext::rescale(const GrImageInfo& info, diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h index 47d92c27be..8f20d100a2 100644 --- a/src/gpu/GrSurfaceContext.h +++ b/src/gpu/GrSurfaceContext.h @@ -180,12 +180,13 @@ public: GrAuditTrail* auditTrail(); #if GR_TEST_UTILS - bool testCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { - return this->copy(src, srcRect, dstPoint); + bool testCopy(sk_sp src, const SkIRect& srcRect, const SkIPoint& dstPoint) { + return this->copy(std::move(src), srcRect, dstPoint); } - bool testCopy(GrSurfaceProxy* src) { - return this->copy(src, SkIRect::MakeSize(src->dimensions()), {0, 0}); + bool testCopy(sk_sp src) { + auto rect = SkIRect::MakeSize(src->dimensions()); + return this->copy(std::move(src), rect, {0, 0}); } #endif @@ -241,7 +242,7 @@ private: * regions will not be shifted. The 'src' must have the same origin as the backing proxy * of fSurfaceContext. */ - bool copy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint); + bool copy(sk_sp src, SkIRect srcRect, SkIPoint dstPoint); class AsyncReadResult; diff --git a/src/gpu/GrSurfaceDrawContext.cpp b/src/gpu/GrSurfaceDrawContext.cpp index 9d098d2b68..189ed44390 100644 --- a/src/gpu/GrSurfaceDrawContext.cpp +++ b/src/gpu/GrSurfaceDrawContext.cpp @@ -1954,9 +1954,14 @@ bool GrSurfaceDrawContext::setupDstProxyView(const GrOp& op, dstOffset = {copyRect.fLeft, copyRect.fTop}; fit = SkBackingFit::kApprox; } - auto copy = - GrSurfaceProxy::Copy(fContext, this->asSurfaceProxy(), this->origin(), GrMipmapped::kNo, - copyRect, fit, SkBudgeted::kYes, restrictions.fRectsMustMatch); + auto copy = GrSurfaceProxy::Copy(fContext, + this->asSurfaceProxyRef(), + this->origin(), + GrMipmapped::kNo, + copyRect, + fit, + SkBudgeted::kYes, + restrictions.fRectsMustMatch); SkASSERT(copy); dstProxyView->setProxyView({std::move(copy), this->origin(), this->readSwizzle()}); diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index fea4e70159..c339610509 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -246,7 +246,7 @@ void GrSurfaceProxy::validate(GrContext_Base* context) const { #endif sk_sp GrSurfaceProxy::Copy(GrRecordingContext* context, - GrSurfaceProxy* src, + sk_sp src, GrSurfaceOrigin origin, GrMipmapped mipMapped, SkIRect srcRect, @@ -304,7 +304,7 @@ sk_sp GrSurfaceProxy::Copy(GrRecordingContext* context, GrSwizzle::RGBA(), origin, budgeted); - GrSurfaceProxyView view(sk_ref_sp(src), origin, GrSwizzle::RGBA()); + GrSurfaceProxyView view(std::move(src), origin, GrSwizzle::RGBA()); if (dstContext && dstContext->blitTexture(std::move(view), srcRect, dstPoint)) { return dstContext->asSurfaceProxyRef(); } @@ -314,14 +314,14 @@ sk_sp GrSurfaceProxy::Copy(GrRecordingContext* context, } sk_sp GrSurfaceProxy::Copy(GrRecordingContext* context, - GrSurfaceProxy* src, + sk_sp src, GrSurfaceOrigin origin, GrMipmapped mipMapped, SkBackingFit fit, SkBudgeted budgeted) { SkASSERT(!src->isFullyLazy()); - return Copy(context, src, origin, mipMapped, SkIRect::MakeSize(src->dimensions()), fit, - budgeted); + auto rect = SkIRect::MakeSize(src->dimensions()); + return Copy(context, std::move(src), origin, mipMapped, rect, fit, budgeted); } #if GR_TEST_UTILS diff --git a/src/gpu/GrSurfaceProxy.h b/src/gpu/GrSurfaceProxy.h index ae14446091..b6dcad00c7 100644 --- a/src/gpu/GrSurfaceProxy.h +++ b/src/gpu/GrSurfaceProxy.h @@ -299,7 +299,7 @@ public: // will be the same as the src. Therefore, the copy can be used in a view with the same swizzle // as the original for use with a given color type. static sk_sp Copy(GrRecordingContext*, - GrSurfaceProxy* src, + sk_sp src, GrSurfaceOrigin, GrMipmapped, SkIRect srcRect, @@ -309,7 +309,7 @@ public: // Same as above Copy but copies the entire 'src' static sk_sp Copy(GrRecordingContext*, - GrSurfaceProxy* src, + sk_sp src, GrSurfaceOrigin, GrMipmapped, SkBackingFit, diff --git a/src/gpu/GrSurfaceProxyView.h b/src/gpu/GrSurfaceProxyView.h index d616b008c1..58fe8b0284 100644 --- a/src/gpu/GrSurfaceProxyView.h +++ b/src/gpu/GrSurfaceProxyView.h @@ -94,9 +94,13 @@ public: SkIRect srcRect, SkBackingFit fit, SkBudgeted budgeted) { - auto origin = src.origin(); - auto* proxy = src.proxy(); - auto copy = GrSurfaceProxy::Copy(context, proxy, origin, mipMapped, srcRect, fit, budgeted); + auto copy = GrSurfaceProxy::Copy(context, + src.refProxy(), + src.origin(), + mipMapped, + srcRect, + fit, + budgeted); return {std::move(copy), src.origin(), src.swizzle()}; } diff --git a/src/gpu/GrTextureResolveRenderTask.cpp b/src/gpu/GrTextureResolveRenderTask.cpp index f1b1a35851..fd13d65d23 100644 --- a/src/gpu/GrTextureResolveRenderTask.cpp +++ b/src/gpu/GrTextureResolveRenderTask.cpp @@ -55,9 +55,8 @@ void GrTextureResolveRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc // manipulate the resolve proxies. auto fakeOp = alloc->curOp(); SkASSERT(fResolves.count() == this->numTargets()); - for (const GrSurfaceProxyView& target : fTargets) { - alloc->addInterval(target.proxy(), fakeOp, fakeOp, - GrResourceAllocator::ActualUse::kYes); + for (const sk_sp& target : fTargets) { + alloc->addInterval(target.get(), fakeOp, fakeOp, GrResourceAllocator::ActualUse::kYes); } alloc->incOps(); } @@ -68,7 +67,7 @@ bool GrTextureResolveRenderTask::onExecute(GrOpFlushState* flushState) { for (int i = 0; i < fResolves.count(); ++i) { const Resolve& resolve = fResolves[i]; if (GrSurfaceProxy::ResolveFlags::kMSAA & resolve.fFlags) { - GrSurfaceProxy* proxy = this->target(i).proxy(); + GrSurfaceProxy* proxy = this->target(i); // peekRenderTarget might be null if there was an instantiation error. if (GrRenderTarget* renderTarget = proxy->peekRenderTarget()) { flushState->gpu()->resolveRenderTarget(renderTarget, resolve.fMSAAResolveRect); @@ -80,7 +79,7 @@ bool GrTextureResolveRenderTask::onExecute(GrOpFlushState* flushState) { const Resolve& resolve = fResolves[i]; if (GrSurfaceProxy::ResolveFlags::kMipMaps & resolve.fFlags) { // peekTexture might be null if there was an instantiation error. - GrTexture* texture = this->target(i).proxy()->peekTexture(); + GrTexture* texture = this->target(i)->peekTexture(); if (texture && texture->mipmapsAreDirty()) { flushState->gpu()->regenerateMipMapLevels(texture); SkASSERT(!texture->mipmapsAreDirty()); diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 4e615b160c..d7a15e5b05 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -94,7 +94,7 @@ sk_sp GrMakeUniqueKeyInvalidationListener(GrUniqueKey* key, } sk_sp GrCopyBaseMipMapToTextureProxy(GrRecordingContext* ctx, - GrSurfaceProxy* baseProxy, + sk_sp baseProxy, GrSurfaceOrigin origin, SkBudgeted budgeted) { SkASSERT(baseProxy); @@ -102,7 +102,7 @@ sk_sp GrCopyBaseMipMapToTextureProxy(GrRecordingContext* ctx, if (!ctx->priv().caps()->isFormatCopyable(baseProxy->backendFormat())) { return {}; } - auto copy = GrSurfaceProxy::Copy(ctx, baseProxy, origin, GrMipmapped::kYes, + auto copy = GrSurfaceProxy::Copy(ctx, std::move(baseProxy), origin, GrMipmapped::kYes, SkBackingFit::kExact, budgeted); if (!copy) { return {}; @@ -116,7 +116,7 @@ GrSurfaceProxyView GrCopyBaseMipMapToView(GrRecordingContext* context, SkBudgeted budgeted) { auto origin = src.origin(); auto swizzle = src.swizzle(); - auto* proxy = src.proxy(); + auto proxy = src.refProxy(); return {GrCopyBaseMipMapToTextureProxy(context, proxy, origin, budgeted), origin, swizzle}; } diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h index 35d0b8f710..93a890217b 100644 --- a/src/gpu/SkGr.h +++ b/src/gpu/SkGr.h @@ -207,7 +207,7 @@ GrSurfaceProxyView GrRefCachedBitmapView(GrRecordingContext*, const SkBitmap&, G * Creates a new texture with mipmap levels and copies the baseProxy into the base layer. */ sk_sp GrCopyBaseMipMapToTextureProxy(GrRecordingContext*, - GrSurfaceProxy* baseProxy, + sk_sp baseProxy, GrSurfaceOrigin origin, SkBudgeted = SkBudgeted::kYes); /** diff --git a/src/gpu/mock/GrMockRenderTask.h b/src/gpu/mock/GrMockRenderTask.h index 697cc52704..a276e19726 100644 --- a/src/gpu/mock/GrMockRenderTask.h +++ b/src/gpu/mock/GrMockRenderTask.h @@ -17,7 +17,7 @@ public: this->setFlag(kDisowned_Flag); } - void addTarget(GrSurfaceProxyView view) { fTargets.push_back(std::move(view)); } + void addTarget(GrSurfaceProxyView view) { fTargets.push_back(view.detachProxy()); } void addDependency(GrRenderTask* dep) { fDependencies.push_back(dep); } // Overrides. diff --git a/src/gpu/vk/GrVkOpsRenderPass.cpp b/src/gpu/vk/GrVkOpsRenderPass.cpp index fcd3cb10fe..c38e0c27e9 100644 --- a/src/gpu/vk/GrVkOpsRenderPass.cpp +++ b/src/gpu/vk/GrVkOpsRenderPass.cpp @@ -183,9 +183,10 @@ bool GrVkOpsRenderPass::beginRenderPass(const VkClearValue& clearColor, bool useFullBounds = fCurrentRenderPass->hasResolveAttachment() && fGpu->vkCaps().mustLoadFullImageWithDiscardableMSAA(); - auto nativeBounds = GrNativeRect::MakeRelativeTo( - fOrigin, vkRT->height(), - useFullBounds ? SkIRect::MakeWH(vkRT->width(), vkRT->height()) : fBounds); + auto nativeBounds = GrNativeRect::MakeIRectRelativeTo( + fOrigin, + vkRT->height(), + useFullBounds ? SkIRect::MakeSize(vkRT->dimensions()) : fBounds); // The bounds we use for the render pass should be of the granularity supported // by the device. @@ -193,10 +194,13 @@ bool GrVkOpsRenderPass::beginRenderPass(const VkClearValue& clearColor, SkIRect adjustedBounds; if ((0 != granularity.width && 1 != granularity.width) || (0 != granularity.height && 1 != granularity.height)) { - adjust_bounds_to_granularity(&adjustedBounds, nativeBounds.asSkIRect(), granularity, - vkRT->width(), vkRT->height()); + adjust_bounds_to_granularity(&adjustedBounds, + nativeBounds, + granularity, + vkRT->width(), + vkRT->height()); } else { - adjustedBounds = nativeBounds.asSkIRect(); + adjustedBounds = nativeBounds; } if (!fGpu->beginRenderPass(fCurrentRenderPass, &clearColor, vkRT, adjustedBounds, diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp index 1e32535698..3a2f0d7d6f 100644 --- a/tests/CopySurfaceTest.cpp +++ b/tests/CopySurfaceTest.cpp @@ -111,7 +111,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { bool result = false; if (sOrigin == dOrigin) { - result = dstContext->testCopy(srcView.proxy(), + result = dstContext->testCopy(srcView.refProxy(), srcRect, dstPoint); } else if (dRenderable == GrRenderable::kYes) { diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp index 8ad24b6a11..3706415bb6 100644 --- a/tests/EGLImageTest.cpp +++ b/tests/EGLImageTest.cpp @@ -204,7 +204,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) { // TODO: why do we always need to draw to copy from an external texture? TestCopyFromSurface(reporter, context0, - surfaceContext->asSurfaceProxy(), + surfaceContext->asSurfaceProxyRef(), surfaceContext->origin(), colorInfo.colorType(), pixels.get(), diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 1366ce6ff4..26446e1a32 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -403,7 +403,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) { auto copySrc = maker.view(GrMipmapped::kNo); REPORTER_ASSERT(reporter, copySrc.proxy()); - auto copyResult = surfContext->testCopy(copySrc.proxy()); + auto copyResult = surfContext->testCopy(copySrc.refProxy()); REPORTER_ASSERT(reporter, copyResult == (ioType == kRW_GrIOType)); // Try the low level copy. dContext->flushAndSubmit(); @@ -811,8 +811,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleStateTest, reporter, contextInfo) { auto proxy = context->priv().proxyProvider()->testingOnly_createWrapped(std::move(idleTexture)); context->flushAndSubmit(); - SkAssertResult(sdc->testCopy(proxy.get())); - proxy.reset(); + SkAssertResult(sdc->testCopy(std::move(proxy))); REPORTER_ASSERT(reporter, !called); // After a flush we expect idleTexture to have reached the kFlushed state on all backends. diff --git a/tests/MtlCopySurfaceTest.mm b/tests/MtlCopySurfaceTest.mm index 7afd14217c..29a5b68088 100644 --- a/tests/MtlCopySurfaceTest.mm +++ b/tests/MtlCopySurfaceTest.mm @@ -45,7 +45,7 @@ DEF_GPUTEST_FOR_METAL_CONTEXT(MtlCopySurfaceTest, reporter, ctxInfo) { sk_sp srcProxy = proxyProvider->wrapBackendRenderTarget(backendRT, nullptr); auto dstProxy = GrSurfaceProxy::Copy(context, - srcProxy.get(), + srcProxy, kTopLeft_GrSurfaceOrigin, GrMipmapped::kNo, SkBackingFit::kExact, diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp index 6c3483801f..8133147196 100644 --- a/tests/RectangleTextureTest.cpp +++ b/tests/RectangleTextureTest.cpp @@ -109,7 +109,7 @@ static void test_copy_to_surface(skiatest::Reporter* reporter, pixmap); // If this assert ever fails we can add a fallback to do copy as draw, but until then we can // be more restrictive. - SkAssertResult(dstContext->testCopy(srcView.proxy())); + SkAssertResult(dstContext->testCopy(srcView.refProxy())); TestReadPixels(reporter, dContext, dstContext, pixels.get(), testName); } } @@ -179,8 +179,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) { refPixels); // Test copy to both a texture and RT - TestCopyFromSurface(reporter, dContext, rectProxy.get(), origin, grII.colorType(), - refPixels, "RectangleTexture-copy-from"); + TestCopyFromSurface(reporter, dContext, rectProxy, origin, grII.colorType(), refPixels, + "RectangleTexture-copy-from"); auto rectContext = GrSurfaceContext::Make(dContext, std::move(view), grII.colorInfo()); SkASSERT(rectContext); diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp index d31844c083..5fe1fcc0fe 100644 --- a/tests/TestUtils.cpp +++ b/tests/TestUtils.cpp @@ -82,12 +82,12 @@ void TestWritePixels(skiatest::Reporter* reporter, void TestCopyFromSurface(skiatest::Reporter* reporter, GrDirectContext* dContext, - GrSurfaceProxy* proxy, + sk_sp proxy, GrSurfaceOrigin origin, GrColorType colorType, uint32_t expectedPixelValues[], const char* testName) { - auto copy = GrSurfaceProxy::Copy(dContext, proxy, origin, GrMipmapped::kNo, + auto copy = GrSurfaceProxy::Copy(dContext, std::move(proxy), origin, GrMipmapped::kNo, SkBackingFit::kExact, SkBudgeted::kYes); SkASSERT(copy && copy->asTextureProxy()); auto swizzle = dContext->priv().caps()->getReadSwizzle(copy->backendFormat(), colorType); diff --git a/tests/TestUtils.h b/tests/TestUtils.h index b471aa4026..88d8323bc1 100644 --- a/tests/TestUtils.h +++ b/tests/TestUtils.h @@ -27,9 +27,13 @@ void TestWritePixels(skiatest::Reporter*, GrDirectContext*, GrSurfaceContext* sr // Ensure that the pixels can be copied from 'proxy' viewed as colorType, to an RGBA 8888 // destination (both texture-backed and rendertarget-backed). -void TestCopyFromSurface(skiatest::Reporter*, GrDirectContext*, GrSurfaceProxy* proxy, - GrSurfaceOrigin origin, GrColorType colorType, - uint32_t expectedPixelValues[], const char* testName); +void TestCopyFromSurface(skiatest::Reporter*, + GrDirectContext*, + sk_sp proxy, + GrSurfaceOrigin origin, + GrColorType colorType, + uint32_t expectedPixelValues[], + const char* testName); // Encodes the bitmap into a data:/image/png;base64,... url suitable to view in a browser after // printing to a log. If false is returned, dst holds an error message instead of a URI.