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>
This commit is contained in:
Brian Salomon 2021-01-21 10:43:35 -05:00 committed by Skia Commit-Bot
parent 25788c3179
commit 982127b7d5
32 changed files with 253 additions and 209 deletions

View File

@ -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};
}
}

View File

@ -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

View File

@ -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);
}

View File

@ -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<GrRenderTask> Make(GrDrawingManager*,
GrSurfaceProxyView srcView,
const SkIRect& srcRect,
GrSurfaceProxyView dstView,
const SkIPoint& dstPoint,
sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
SkIPoint dstPoint,
const GrCaps*);
private:
GrCopyRenderTask(GrDrawingManager*,
GrSurfaceProxyView srcView,
const SkIRect& srcRect,
GrSurfaceProxyView dstView,
const SkIPoint& dstPoint);
sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> 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<GrSurfaceProxy> fSrc;
SkIRect fSrcRect;
SkIPoint fDstPoint;
};

View File

@ -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());
}
}

View File

@ -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<const SkDeferredDisplayList> 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<GrOpsTask> GrDrawingManager::newOpsTask(GrSurfaceProxyView surfaceView,
sk_sp<GrOpsTask> 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<GrSurfaceProxy> 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<GrSurfaceProxy> srcProxy,
SkDEBUGCODE(this->validate());
}
bool GrDrawingManager::newCopyRenderTask(GrSurfaceProxyView srcView,
const SkIRect& srcRect,
GrSurfaceProxyView dstView,
const SkIPoint& dstPoint) {
bool GrDrawingManager::newCopyRenderTask(sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> 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

View File

@ -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<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
SkIPoint dstPoint);
GrRecordingContext* getContext() { return fContext; }

View File

@ -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();
}
/**

View File

@ -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<float, 4> 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;
}
}

View File

@ -251,6 +251,9 @@ private:
GrRecordingContext::Arenas fArenas;
GrAuditTrail* fAuditTrail;
GrSwizzle fTargetSwizzle;
GrSurfaceOrigin fTargetOrigin;
GrLoadOp fColorLoadOp = GrLoadOp::kLoad;
std::array<float, 4> fLoadClearColor = {0, 0, 0, 0};
StencilContent fInitialStencilContent = StencilContent::kDontCare;

View File

@ -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());

View File

@ -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<GrSurfaceProxy>& 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<GrSurfaceProxy>& 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<GrSurfaceProxy> 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<GrSurfaceProxy>& target : fTargets) {
SkASSERT(target);
SkString proxyStr = target->dump();
SkDebugf("%s%s\n", indent.c_str(), proxyStr.c_str());
}
}

View File

@ -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<GrSurfaceProxy>& 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<GrSurfaceProxy>& 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<GrSurfaceProxy>);
// 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<GrSurfaceProxy>> 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

View File

@ -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, SkTInternalLList<GrRenderTask
// Tasks with 0 or multiple targets are treated as full barriers
// for all their targets.
for (int j = 0; j < task->numTargets(); j++) {
lastTaskMap->remove(task->target(0).proxy());
lastTaskMap->remove(task->target(0));
}
return false;
}

View File

@ -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<GrSurfaceProxy> 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<GrSurfaceProxy> 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<GrSurfaceDrawContext> GrSurfaceContext::rescale(const GrImageInfo& info,

View File

@ -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<GrSurfaceProxy> 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<GrSurfaceProxy> 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<GrSurfaceProxy> src, SkIRect srcRect, SkIPoint dstPoint);
class AsyncReadResult;

View File

@ -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()});

View File

@ -246,7 +246,7 @@ void GrSurfaceProxy::validate(GrContext_Base* context) const {
#endif
sk_sp<GrSurfaceProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
GrSurfaceProxy* src,
sk_sp<GrSurfaceProxy> src,
GrSurfaceOrigin origin,
GrMipmapped mipMapped,
SkIRect srcRect,
@ -304,7 +304,7 @@ sk_sp<GrSurfaceProxy> 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> GrSurfaceProxy::Copy(GrRecordingContext* context,
}
sk_sp<GrSurfaceProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
GrSurfaceProxy* src,
sk_sp<GrSurfaceProxy> 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

View File

@ -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<GrSurfaceProxy> Copy(GrRecordingContext*,
GrSurfaceProxy* src,
sk_sp<GrSurfaceProxy> src,
GrSurfaceOrigin,
GrMipmapped,
SkIRect srcRect,
@ -309,7 +309,7 @@ public:
// Same as above Copy but copies the entire 'src'
static sk_sp<GrSurfaceProxy> Copy(GrRecordingContext*,
GrSurfaceProxy* src,
sk_sp<GrSurfaceProxy> src,
GrSurfaceOrigin,
GrMipmapped,
SkBackingFit,

View File

@ -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()};
}

View File

@ -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<GrSurfaceProxy>& 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());

View File

@ -94,7 +94,7 @@ sk_sp<SkIDChangeListener> GrMakeUniqueKeyInvalidationListener(GrUniqueKey* key,
}
sk_sp<GrSurfaceProxy> GrCopyBaseMipMapToTextureProxy(GrRecordingContext* ctx,
GrSurfaceProxy* baseProxy,
sk_sp<GrSurfaceProxy> baseProxy,
GrSurfaceOrigin origin,
SkBudgeted budgeted) {
SkASSERT(baseProxy);
@ -102,7 +102,7 @@ sk_sp<GrSurfaceProxy> 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};
}

View File

@ -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<GrSurfaceProxy> GrCopyBaseMipMapToTextureProxy(GrRecordingContext*,
GrSurfaceProxy* baseProxy,
sk_sp<GrSurfaceProxy> baseProxy,
GrSurfaceOrigin origin,
SkBudgeted = SkBudgeted::kYes);
/**

View File

@ -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.

View File

@ -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,

View File

@ -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) {

View File

@ -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(),

View File

@ -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.

View File

@ -45,7 +45,7 @@ DEF_GPUTEST_FOR_METAL_CONTEXT(MtlCopySurfaceTest, reporter, ctxInfo) {
sk_sp<GrSurfaceProxy> srcProxy = proxyProvider->wrapBackendRenderTarget(backendRT, nullptr);
auto dstProxy = GrSurfaceProxy::Copy(context,
srcProxy.get(),
srcProxy,
kTopLeft_GrSurfaceOrigin,
GrMipmapped::kNo,
SkBackingFit::kExact,

View File

@ -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);

View File

@ -82,12 +82,12 @@ void TestWritePixels(skiatest::Reporter* reporter,
void TestCopyFromSurface(skiatest::Reporter* reporter,
GrDirectContext* dContext,
GrSurfaceProxy* proxy,
sk_sp<GrSurfaceProxy> 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);

View File

@ -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<GrSurfaceProxy> 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.