Remove GrPendingIOResource
AFAICT these three remaining uses of GrPendingIOResource were just real-ref placeholders (i.e., they just added 1 pending read and then held on to the GrPendingIOResource until object destruction). Change-Id: Iba6bb199477d846d079999f09794422e240c675a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235458 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
30eea6c87c
commit
e1efd38cf0
@ -127,7 +127,6 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/GrPathRendererChain.h",
|
||||
"$_src/gpu/GrPathRenderer.cpp",
|
||||
"$_src/gpu/GrPathRenderer.h",
|
||||
"$_src/gpu/GrPendingIOResource.h",
|
||||
"$_src/gpu/GrOnFlushResourceProvider.cpp",
|
||||
"$_src/gpu/GrOnFlushResourceProvider.h",
|
||||
"$_src/gpu/GrPipeline.cpp",
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "src/gpu/GrBuffer.h"
|
||||
#include "src/gpu/GrGpuBuffer.h"
|
||||
#include "src/gpu/GrPendingIOResource.h"
|
||||
|
||||
class GrPrimitiveProcessor;
|
||||
|
||||
|
@ -54,9 +54,8 @@ void GrGLPathRendering::onStencilPath(const StencilPathArgs&, const GrPath*) {}
|
||||
std::unique_ptr<GrOp> GrStencilPathOp::Make(GrRecordingContext*,
|
||||
const SkMatrix&,
|
||||
bool,
|
||||
GrPathRendering::FillType,
|
||||
bool,
|
||||
const GrScissorState&,
|
||||
const GrPath*) { return nullptr; }
|
||||
sk_sp<const GrPath>) { return nullptr; }
|
||||
|
||||
void GrPath::ComputeKey(const GrShape&, GrUniqueKey*, bool*) {}
|
||||
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrPendingIOResource_DEFINED
|
||||
#define GrPendingIOResource_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/gpu/GrGpuResource.h"
|
||||
#include "include/private/SkNoncopyable.h"
|
||||
#include "src/gpu/GrSurfaceProxy.h"
|
||||
|
||||
/**
|
||||
* Helper for owning a pending read, write, read-write on a GrGpuResource. It never owns a regular
|
||||
* ref.
|
||||
*/
|
||||
template <typename T, GrIOType IO_TYPE>
|
||||
class GrPendingIOResource : SkNoncopyable {
|
||||
public:
|
||||
GrPendingIOResource() = default;
|
||||
GrPendingIOResource(T* resource) { this->reset(resource); }
|
||||
GrPendingIOResource(sk_sp<T> resource) { *this = std::move(resource); }
|
||||
GrPendingIOResource(const GrPendingIOResource& that) : GrPendingIOResource(that.get()) {}
|
||||
~GrPendingIOResource() { this->release(); }
|
||||
|
||||
GrPendingIOResource& operator=(sk_sp<T> resource) {
|
||||
this->reset(resource.get());
|
||||
return *this;
|
||||
}
|
||||
|
||||
void reset(T* resource = nullptr) {
|
||||
if (resource) {
|
||||
switch (IO_TYPE) {
|
||||
case kRead_GrIOType:
|
||||
resource->addPendingRead();
|
||||
break;
|
||||
case kWrite_GrIOType:
|
||||
resource->addPendingWrite();
|
||||
break;
|
||||
case kRW_GrIOType:
|
||||
resource->addPendingRead();
|
||||
resource->addPendingWrite();
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->release();
|
||||
fResource = resource;
|
||||
}
|
||||
|
||||
explicit operator bool() const { return SkToBool(fResource); }
|
||||
|
||||
bool operator==(const GrPendingIOResource& other) const { return fResource == other.fResource; }
|
||||
|
||||
T* get() const { return fResource; }
|
||||
T* operator*() const { return *fResource; }
|
||||
T* operator->() const { return fResource; }
|
||||
|
||||
private:
|
||||
void release() {
|
||||
if (fResource) {
|
||||
switch (IO_TYPE) {
|
||||
case kRead_GrIOType:
|
||||
fResource->completedRead();
|
||||
break;
|
||||
case kWrite_GrIOType:
|
||||
fResource->completedWrite();
|
||||
break;
|
||||
case kRW_GrIOType:
|
||||
fResource->completedRead();
|
||||
fResource->completedWrite();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
T* fResource = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
@ -13,7 +13,6 @@
|
||||
#include "src/gpu/GrColor.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/GrNonAtomicRef.h"
|
||||
#include "src/gpu/GrPendingIOResource.h"
|
||||
#include "src/gpu/GrProcessorSet.h"
|
||||
#include "src/gpu/GrProgramDesc.h"
|
||||
#include "src/gpu/GrScissorState.h"
|
||||
|
@ -875,7 +875,7 @@ void GrRenderTargetContext::internalStencilClear(const GrFixedClip& clip, bool i
|
||||
void GrRenderTargetContextPriv::stencilPath(const GrHardClip& clip,
|
||||
GrAA doStencilMSAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrPath* path) {
|
||||
sk_sp<const GrPath> path) {
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
RETURN_IF_ABANDONED_PRIV
|
||||
SkDEBUGCODE(fRenderTargetContext->validate();)
|
||||
@ -900,10 +900,9 @@ void GrRenderTargetContextPriv::stencilPath(const GrHardClip& clip,
|
||||
std::unique_ptr<GrOp> op = GrStencilPathOp::Make(fRenderTargetContext->fContext,
|
||||
viewMatrix,
|
||||
GrAA::kYes == doStencilMSAA,
|
||||
path->getFillType(),
|
||||
appliedClip.hasStencilClip(),
|
||||
appliedClip.scissorState(),
|
||||
path);
|
||||
std::move(path));
|
||||
if (!op) {
|
||||
return;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
}
|
||||
|
||||
void stencilPath(
|
||||
const GrHardClip&, GrAA doStencilMSAA, const SkMatrix& viewMatrix, const GrPath*);
|
||||
const GrHardClip&, GrAA doStencilMSAA, const SkMatrix& viewMatrix, sk_sp<const GrPath>);
|
||||
|
||||
/**
|
||||
* Draws a path, either AA or not, and touches the stencil buffer with the user stencil settings
|
||||
|
@ -862,6 +862,9 @@ void GrResourceCache::validate() const {
|
||||
void update(GrGpuResource* resource) {
|
||||
fBytes += resource->gpuMemorySize();
|
||||
|
||||
// No resource should ever have pendingIO any more
|
||||
SkASSERT(!resource->internalHasPendingIO());
|
||||
|
||||
if (!resource->resourcePriv().isPurgeable()) {
|
||||
++fLocked;
|
||||
}
|
||||
|
@ -79,10 +79,10 @@ std::unique_ptr<GrDrawOp> GrDrawPathOp::Make(GrRecordingContext* context,
|
||||
const SkMatrix& viewMatrix,
|
||||
GrPaint&& paint,
|
||||
GrAA aa,
|
||||
GrPath* path) {
|
||||
sk_sp<const GrPath> path) {
|
||||
GrOpMemoryPool* pool = context->priv().opMemoryPool();
|
||||
|
||||
return pool->allocate<GrDrawPathOp>(viewMatrix, std::move(paint), aa, path);
|
||||
return pool->allocate<GrDrawPathOp>(viewMatrix, std::move(paint), aa, std::move(path));
|
||||
}
|
||||
|
||||
void GrDrawPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
DEFINE_OP_CLASS_ID
|
||||
|
||||
static std::unique_ptr<GrDrawOp> Make(
|
||||
GrRecordingContext*, const SkMatrix& viewMatrix, GrPaint&&, GrAA, GrPath*);
|
||||
GrRecordingContext*, const SkMatrix& viewMatrix, GrPaint&&, GrAA, sk_sp<const GrPath>);
|
||||
|
||||
const char* name() const override { return "DrawPath"; }
|
||||
|
||||
@ -82,16 +82,16 @@ public:
|
||||
private:
|
||||
friend class GrOpMemoryPool; // for ctor
|
||||
|
||||
GrDrawPathOp(const SkMatrix& viewMatrix, GrPaint&& paint, GrAA aa, const GrPath* path)
|
||||
GrDrawPathOp(const SkMatrix& viewMatrix, GrPaint&& paint, GrAA aa, sk_sp<const GrPath> path)
|
||||
: GrDrawPathOpBase(
|
||||
ClassID(), viewMatrix, std::move(paint), path->getFillType(), aa)
|
||||
, fPath(path) {
|
||||
this->setTransformedBounds(path->getBounds(), viewMatrix, HasAABloat::kNo, IsZeroArea::kNo);
|
||||
, fPath(std::move(path)) {
|
||||
this->setTransformedBounds(fPath->getBounds(), viewMatrix, HasAABloat::kNo, IsZeroArea::kNo);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
|
||||
|
||||
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
|
||||
sk_sp<const GrPath> fPath;
|
||||
|
||||
typedef GrDrawPathOpBase INHERITED;
|
||||
};
|
||||
|
@ -79,7 +79,7 @@ void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
|
||||
"GrStencilAndCoverPathRenderer::onStencilPath");
|
||||
sk_sp<GrPath> p(get_gr_path(fResourceProvider, *args.fShape));
|
||||
args.fRenderTargetContext->priv().stencilPath(
|
||||
*args.fClip, args.fDoStencilMSAA, *args.fViewMatrix, p.get());
|
||||
*args.fClip, args.fDoStencilMSAA, *args.fViewMatrix, std::move(p));
|
||||
}
|
||||
|
||||
bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
@ -120,7 +120,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
// Just ignore the analytic FPs (if any) during the stencil pass. They will still clip the
|
||||
// final draw and it is meaningless to multiply by coverage when drawing to stencil.
|
||||
args.fRenderTargetContext->priv().stencilPath(
|
||||
stencilClip, GrAA(doStencilMSAA), viewMatrix, path.get());
|
||||
stencilClip, GrAA(doStencilMSAA), viewMatrix, std::move(path));
|
||||
|
||||
{
|
||||
static constexpr GrUserStencilSettings kInvertedCoverPass(
|
||||
@ -162,7 +162,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
}
|
||||
} else {
|
||||
std::unique_ptr<GrDrawOp> op = GrDrawPathOp::Make(
|
||||
args.fContext, viewMatrix, std::move(args.fPaint), GrAA(doStencilMSAA), path.get());
|
||||
args.fContext, viewMatrix, std::move(args.fPaint), GrAA(doStencilMSAA),
|
||||
std::move(path));
|
||||
args.fRenderTargetContext->addDrawOp(*args.fClip, std::move(op));
|
||||
}
|
||||
|
||||
|
@ -17,14 +17,13 @@
|
||||
std::unique_ptr<GrOp> GrStencilPathOp::Make(GrRecordingContext* context,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool useHWAA,
|
||||
GrPathRendering::FillType fillType,
|
||||
bool hasStencilClip,
|
||||
const GrScissorState& scissor,
|
||||
const GrPath* path) {
|
||||
sk_sp<const GrPath> path) {
|
||||
GrOpMemoryPool* pool = context->priv().opMemoryPool();
|
||||
|
||||
return pool->allocate<GrStencilPathOp>(viewMatrix, useHWAA, fillType,
|
||||
hasStencilClip, scissor, path);
|
||||
return pool->allocate<GrStencilPathOp>(viewMatrix, useHWAA,
|
||||
hasStencilClip, scissor, std::move(path));
|
||||
}
|
||||
|
||||
void GrStencilPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
|
||||
@ -32,7 +31,7 @@ void GrStencilPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds
|
||||
SkASSERT(rt);
|
||||
|
||||
int numStencilBits = rt->renderTargetPriv().numStencilBits();
|
||||
GrStencilSettings stencil(GrPathRendering::GetStencilPassSettings(fFillType),
|
||||
GrStencilSettings stencil(GrPathRendering::GetStencilPassSettings(fPath->getFillType()),
|
||||
fHasStencilClip, numStencilBits);
|
||||
|
||||
GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fProxy,
|
||||
|
@ -23,10 +23,9 @@ public:
|
||||
static std::unique_ptr<GrOp> Make(GrRecordingContext* context,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool useHWAA,
|
||||
GrPathRendering::FillType fillType,
|
||||
bool hasStencilClip,
|
||||
const GrScissorState& scissor,
|
||||
const GrPath* path);
|
||||
sk_sp<const GrPath> path);
|
||||
|
||||
const char* name() const override { return "StencilPathOp"; }
|
||||
|
||||
@ -44,30 +43,27 @@ private:
|
||||
|
||||
GrStencilPathOp(const SkMatrix& viewMatrix,
|
||||
bool useHWAA,
|
||||
GrPathRendering::FillType fillType,
|
||||
bool hasStencilClip,
|
||||
const GrScissorState& scissor,
|
||||
const GrPath* path)
|
||||
sk_sp<const GrPath> path)
|
||||
: INHERITED(ClassID())
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fUseHWAA(useHWAA)
|
||||
, fFillType(fillType)
|
||||
, fHasStencilClip(hasStencilClip)
|
||||
, fScissor(scissor)
|
||||
, fPath(path) {
|
||||
this->setBounds(path->getBounds(), HasAABloat::kNo, IsZeroArea::kNo);
|
||||
, fPath(std::move(path)) {
|
||||
this->setBounds(fPath->getBounds(), HasAABloat::kNo, IsZeroArea::kNo);
|
||||
}
|
||||
|
||||
void onPrepare(GrOpFlushState*) override {}
|
||||
|
||||
void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
|
||||
|
||||
SkMatrix fViewMatrix;
|
||||
bool fUseHWAA;
|
||||
GrPathRendering::FillType fFillType;
|
||||
bool fHasStencilClip;
|
||||
GrScissorState fScissor;
|
||||
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
|
||||
SkMatrix fViewMatrix;
|
||||
bool fUseHWAA;
|
||||
bool fHasStencilClip;
|
||||
GrScissorState fScissor;
|
||||
sk_sp<const GrPath> fPath;
|
||||
|
||||
typedef GrOp INHERITED;
|
||||
};
|
||||
|
@ -46,8 +46,9 @@ private:
|
||||
|
||||
class Copy : public GrVkPrimaryCommandBufferTask {
|
||||
public:
|
||||
Copy(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint, bool shouldDiscardDst)
|
||||
: fSrc(src)
|
||||
Copy(sk_sp<GrSurface> src, const SkIRect& srcRect, const SkIPoint& dstPoint,
|
||||
bool shouldDiscardDst)
|
||||
: fSrc(std::move(src))
|
||||
, fSrcRect(srcRect)
|
||||
, fDstPoint(dstPoint)
|
||||
, fShouldDiscardDst(shouldDiscardDst) {}
|
||||
@ -57,11 +58,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
using Src = GrPendingIOResource<GrSurface, kRead_GrIOType>;
|
||||
Src fSrc;
|
||||
SkIRect fSrcRect;
|
||||
SkIPoint fDstPoint;
|
||||
bool fShouldDiscardDst;
|
||||
sk_sp<GrSurface> fSrc;
|
||||
SkIRect fSrcRect;
|
||||
SkIPoint fDstPoint;
|
||||
bool fShouldDiscardDst;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
@ -71,7 +71,7 @@ private:
|
||||
void GrVkGpuTextureCommandBuffer::copy(GrSurface* src, const SkIRect& srcRect,
|
||||
const SkIPoint& dstPoint) {
|
||||
SkASSERT(!src->isProtected() || (fTexture->isProtected() && fGpu->protectedContext()));
|
||||
fTasks.emplace<Copy>(src, srcRect, dstPoint, false);
|
||||
fTasks.emplace<Copy>(sk_ref_sp(src), srcRect, dstPoint, false);
|
||||
}
|
||||
|
||||
void GrVkGpuTextureCommandBuffer::insertEventMarker(const char* msg) {
|
||||
@ -549,7 +549,8 @@ void GrVkGpuRTCommandBuffer::copy(GrSurface* src, const SkIRect& srcRect,
|
||||
}
|
||||
|
||||
fPreCommandBufferTasks.emplace<Copy>(
|
||||
src, srcRect, dstPoint, LoadStoreState::kStartsWithDiscard == cbInfo.fLoadStoreState);
|
||||
sk_ref_sp(src), srcRect, dstPoint,
|
||||
LoadStoreState::kStartsWithDiscard == cbInfo.fLoadStoreState);
|
||||
++fCommandBufferInfos[fCurrentCmdInfo].fNumPreCmds;
|
||||
|
||||
if (LoadStoreState::kLoadAndStore != cbInfo.fLoadStoreState) {
|
||||
@ -792,7 +793,9 @@ void GrVkGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
|
||||
|
||||
void GrVkGpuRTCommandBuffer::appendSampledTexture(GrTexture* tex) {
|
||||
SkASSERT(!tex->isProtected() || (fRenderTarget->isProtected() && fGpu->protectedContext()));
|
||||
fCommandBufferInfos[fCurrentCmdInfo].fSampledTextures.push_back(static_cast<GrVkTexture*>(tex));
|
||||
GrVkTexture* vkTex = static_cast<GrVkTexture*>(tex);
|
||||
|
||||
fCommandBufferInfos[fCurrentCmdInfo].fSampledTextures.push_back(sk_ref_sp(vkTex));
|
||||
}
|
||||
|
||||
void GrVkGpuRTCommandBuffer::sendInstancedMeshToGpu(GrPrimitiveType,
|
||||
|
@ -188,7 +188,6 @@ private:
|
||||
};
|
||||
|
||||
struct CommandBufferInfo {
|
||||
using SampledTexture = GrPendingIOResource<GrVkTexture, kRead_GrIOType>;
|
||||
const GrVkRenderPass* fRenderPass;
|
||||
std::unique_ptr<GrVkSecondaryCommandBuffer> fCommandBuffer;
|
||||
int fNumPreCmds = 0;
|
||||
@ -199,7 +198,7 @@ private:
|
||||
// Array of images that will be sampled and thus need to be transferred to sampled layout
|
||||
// before submitting the secondary command buffers. This must happen after we do any predraw
|
||||
// uploads or copies.
|
||||
SkTArray<SampledTexture> fSampledTextures;
|
||||
SkTArray<sk_sp<GrVkTexture>> fSampledTextures;
|
||||
|
||||
GrVkSecondaryCommandBuffer* currentCmdBuf() {
|
||||
return fCommandBuffer.get();
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "include/gpu/GrTexture.h"
|
||||
#include "src/gpu/GrContextPriv.h"
|
||||
#include "src/gpu/GrPendingIOResource.h"
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRenderTargetProxy.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
|
Loading…
Reference in New Issue
Block a user