GrGeometryProcessor derives from GrNonAtomicRef not GrProgramElement.

It probably doesn't need to be ref counted at all and should be stored
in GrOpFlushState's arena but that's a larger change for another day.

Change-Id: I5f593fb426b8e7794f2ca81194f5a8d9e0f0a072
Reviewed-on: https://skia-review.googlesource.com/145332
Auto-Submit: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Brian Salomon 2018-08-03 11:54:34 -04:00 committed by Skia Commit-Bot
parent 4c3b63e289
commit 607be37e3d
38 changed files with 82 additions and 274 deletions

View File

@ -204,7 +204,7 @@ private:
mesh.setVertexData(vertexBuffer, firstVertex);
auto pipe = target->makePipeline(0, GrProcessorSet::MakeEmptySet(),
target->detachAppliedClip());
target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(gp, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
Mode fMode;

View File

@ -40,7 +40,8 @@ public:
}
protected:
BezierTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color, int32_t classID)
BezierTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
int32_t classID)
: INHERITED(classID)
, fRect(rect)
, fColor(color)
@ -53,7 +54,7 @@ protected:
return target->makePipeline(0, std::move(fProcessorSet), target->detachAppliedClip());
}
const GrGeometryProcessor* gp() const { return fGeometryProcessor.get(); }
sk_sp<const GrGeometryProcessor> gp() const { return fGeometryProcessor; }
const SkRect& rect() const { return fRect; }
GrColor color() const { return fColor; }
@ -63,7 +64,7 @@ private:
SkRect fRect;
GrColor fColor;
sk_sp<GrGeometryProcessor> fGeometryProcessor;
sk_sp<const GrGeometryProcessor> fGeometryProcessor;
GrProcessorSet fProcessorSet;
typedef GrMeshDrawOp INHERITED;
@ -76,7 +77,7 @@ public:
const char* name() const override { return "BezierCubicTestOp"; }
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
sk_sp<GrGeometryProcessor> gp,
sk_sp<const GrGeometryProcessor> gp,
const SkRect& rect,
GrColor color) {
GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
@ -87,7 +88,7 @@ public:
private:
friend class ::GrOpMemoryPool; // for ctor
BezierCubicTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color)
BezierCubicTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect, GrColor color)
: INHERITED(std::move(gp), rect, color, ClassID()) {}
void onPrepareDraws(Target* target) override {
@ -261,7 +262,7 @@ public:
const char* name() const override { return "BezierConicTestOp"; }
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
sk_sp<GrGeometryProcessor> gp,
sk_sp<const GrGeometryProcessor> gp,
const SkRect& rect,
GrColor color,
const SkMatrix& klm) {
@ -273,7 +274,7 @@ public:
private:
friend class ::GrOpMemoryPool; // for ctor
BezierConicTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
BezierConicTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
const SkMatrix& klm)
: INHERITED(std::move(gp), rect, color, ClassID()), fKLM(klm) {}
@ -483,7 +484,7 @@ public:
const char* name() const override { return "BezierQuadTestOp"; }
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
sk_sp<GrGeometryProcessor> gp,
sk_sp<const GrGeometryProcessor> gp,
const SkRect& rect,
GrColor color,
const GrPathUtils::QuadUVMatrix& devToUV) {
@ -495,7 +496,7 @@ public:
private:
friend class ::GrOpMemoryPool; // for ctor
BezierQuadTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
BezierQuadTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
const GrPathUtils::QuadUVMatrix& devToUV)
: INHERITED(std::move(gp), rect, color, ClassID()), fDevToUV(devToUV) {}

View File

@ -96,7 +96,7 @@ private:
SkPointPriv::SetRectTriStrip(verts, fRect, sizeof(SkPoint));
auto pipe = target->makePipeline(0, std::move(fProcessors), target->detachAppliedClip());
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* op, const GrCaps& caps) override { return false; }

View File

@ -125,7 +125,6 @@ skia_gpu_sources = [
"$_src/gpu/GrPathUtils.cpp",
"$_src/gpu/GrPathUtils.h",
"$_src/gpu/GrPendingIOResource.h",
"$_src/gpu/GrPendingProgramElement.h",
"$_src/gpu/GrOnFlushResourceProvider.cpp",
"$_src/gpu/GrOnFlushResourceProvider.h",
"$_src/gpu/GrPipeline.cpp",
@ -136,7 +135,6 @@ skia_gpu_sources = [
"$_src/gpu/GrProcessorSet.h",
"$_src/gpu/GrProgramDesc.cpp",
"$_src/gpu/GrProgramDesc.h",
"$_src/gpu/GrProgramElement.h",
"$_src/gpu/GrProcessor.cpp",
"$_src/gpu/GrProcessor.h",
"$_src/gpu/GrProcessorAnalysis.cpp",

View File

@ -80,8 +80,10 @@ public:
fProxy = nullptr;
}
/** Called by owning GrProgramElement when the program element is first scheduled for
execution. It can only be called once. */
/**
* Called when transferring into an op list and therefore scheduled for an IO operation. It can
* only be called once.
*/
void markPendingIO() const {
// This should only be called when the owning GrProgramElement gets its first
// pendingExecution ref.

View File

@ -44,7 +44,7 @@ bool GrGpuRTCommandBuffer::draw(const GrPrimitiveProcessor& primProc, const GrPi
auto resourceProvider = this->gpu()->getContext()->contextPriv().resourceProvider();
if (pipeline.isBad() || !primProc.instantiate(resourceProvider)) {
if (pipeline.isBad()) {
return false;
}
for (int i = 0; i < primProc.numTextureSamplers(); ++i) {

View File

@ -104,7 +104,7 @@ GrDeferredUploadToken GrOpFlushState::addASAPUpload(GrDeferredTextureUploadFn&&
return fTokenTracker->nextTokenToFlush();
}
void GrOpFlushState::draw(const GrGeometryProcessor* gp, const GrPipeline* pipeline,
void GrOpFlushState::draw(sk_sp<const GrGeometryProcessor> gp, const GrPipeline* pipeline,
const GrPipeline::FixedDynamicState* fixedDynamicState,
const GrMesh& mesh) {
SkASSERT(fOpArgs);
@ -132,7 +132,7 @@ void GrOpFlushState::draw(const GrGeometryProcessor* gp, const GrPipeline* pipel
for (int i = 0; i < gp->numTextureSamplers(); ++i) {
fixedDynamicState->fPrimitiveProcessorTextures[i]->addPendingRead();
}
draw.fGeometryProcessor.reset(gp);
draw.fGeometryProcessor = std::move(gp);
draw.fPipeline = pipeline;
draw.fFixedDynamicState = fixedDynamicState;
draw.fDynamicStateArrays = nullptr;

View File

@ -74,8 +74,8 @@ public:
/** Overrides of GrMeshDrawOp::Target. */
void draw(const GrGeometryProcessor*, const GrPipeline*, const GrPipeline::FixedDynamicState*,
const GrMesh&) final;
void draw(sk_sp<const GrGeometryProcessor>, const GrPipeline*,
const GrPipeline::FixedDynamicState*, const GrMesh&) final;
void* makeVertexSpace(size_t vertexSize, int vertexCount, const GrBuffer**,
int* startVertex) final;
uint16_t* makeIndexSpace(int indexCount, const GrBuffer**, int* startIndex) final;
@ -124,7 +124,7 @@ private:
}
}
int fMeshCnt = 0;
GrPendingProgramElement<const GrGeometryProcessor> fGeometryProcessor;
sk_sp<const GrGeometryProcessor> fGeometryProcessor;
const GrPipeline* fPipeline;
const GrPipeline::FixedDynamicState* fFixedDynamicState;
const GrPipeline::DynamicStateArrays* fDynamicStateArrays;

View File

@ -1,56 +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 GrPendingProgramElement_DEFINED
#define GrPendingProgramElement_DEFINED
#include "SkRefCnt.h"
#include "GrTypes.h"
/**
* Helper for owning a pending execution on a GrProgramElement. Using this rather than ref allows
* resources that are owned by the program element to be correctly tracked as having pending reads
* and writes rather than refs.
*/
template <typename T> class GrPendingProgramElement : SkNoncopyable {
public:
GrPendingProgramElement() : fObj(nullptr) { }
// Adds a pending execution on obj.
explicit GrPendingProgramElement(T* obj) : fObj(obj) {
if (obj) {
obj->addPendingExecution();
}
}
void reset(T* obj) {
if (obj) {
obj->addPendingExecution();
}
if (fObj) {
fObj->completedExecution();
}
fObj = obj;
}
T* get() const { return fObj; }
operator T*() { return fObj; }
T *operator->() const { return fObj; }
~GrPendingProgramElement() {
if (fObj) {
fObj->completedExecution();
}
}
private:
T* fObj;
typedef SkNoncopyable INHERITED;
};
#endif

View File

@ -12,7 +12,6 @@
#include "GrFragmentProcessor.h"
#include "GrNonAtomicRef.h"
#include "GrPendingIOResource.h"
#include "GrPendingProgramElement.h"
#include "GrProcessorSet.h"
#include "GrProgramDesc.h"
#include "GrRect.h"

View File

@ -9,6 +9,7 @@
#define GrPrimitiveProcessor_DEFINED
#include "GrColor.h"
#include "GrNonAtomicRef.h"
#include "GrProcessor.h"
#include "GrProxyRef.h"
#include "GrShaderVar.h"
@ -41,9 +42,10 @@ class GrGLSLPrimitiveProcessor;
* GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh color / coverage
* pipelines, and they must provide some notion of equality
*
* TODO: Overrides of GrProgramElement virtuals don't do anything anymore. Remove this base class.
* TODO: This class does not really need to be ref counted. Instances should be allocated using
* GrOpFlushState's arena and destroyed when the arena is torn down.
*/
class GrPrimitiveProcessor : public GrProcessor, public GrProgramElement {
class GrPrimitiveProcessor : public GrProcessor, public GrNonAtomicRef<GrPrimitiveProcessor> {
public:
class TextureSampler;
@ -138,8 +140,6 @@ public:
virtual float getSampleShading() const { return 0.0; }
bool instantiate(GrResourceProvider*) const { return true; }
protected:
void setVertexAttributeCnt(int cnt) {
SkASSERT(cnt >= 0);
@ -166,11 +166,6 @@ protected:
inline static const TextureSampler& IthTextureSampler(int i);
private:
void addPendingIOs() const final {}
void removeRefs() const final {}
void pendingIOComplete() const final {}
void notifyRefCntIsZero() const final {}
virtual const Attribute& onVertexAttribute(int) const = 0;
virtual const Attribute& onInstanceAttribute(int) const = 0;
virtual const TextureSampler& onTextureSampler(int) const { return IthTextureSampler(0); }

View File

@ -12,7 +12,6 @@
#include "GrBuffer.h"
#include "GrColor.h"
#include "GrProcessorUnitTest.h"
#include "GrProgramElement.h"
#include "GrSamplerState.h"
#include "GrShaderVar.h"
#include "GrSurfaceProxyPriv.h"

View File

@ -1,126 +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 GrProgramElement_DEFINED
#define GrProgramElement_DEFINED
#include "../private/SkTArray.h"
#include "SkRefCnt.h"
/**
* Note: We are converting GrProcessor from ref counting to a single owner model using move
* semantics. This class will be removed.
*
* This is used to track "refs" for two separate types GrProcessor ownership. A regular ref is owned
* by any client that may continue to issue draws that use the GrProgramElement. A recorded op or
* GrPipeline uses "pending executions" instead of refs. A pending execution is cleared after the
* draw is executed (or aborted).
*
* While a GrProgramElement is ref'ed any resources it owns are also ref'ed. However, once it gets
* into the state where it has pending executions AND no refs then it converts its ownership of
* its GrGpuResources from refs to pending IOs. The pending IOs allow the cache to track when it is
* safe to recycle a resource even though we still have buffered GrOps that read or write to the
* the resource.
*
* To make this work the subclass GrProcessor implements addPendingIOs, removeRefs, and
* pendingIOComplete. addPendingIOs adds pending reads/writes to GrGpuResources owned by the
* processor as appropriate when the processor is recorded in a GrOpList. removeRefs is called when
* the ref count reaches 0 and the GrProcessor is only owned by "pending executions".
* pendingIOComplete occurs if the resource is still owned by a ref but all recorded draws have been
* completed. Whenever pending executions and refs reach zero the processor is deleted.
*
* The GrProcessor may also implement notifyRefCntIsZero in order to change its ownership of child
* processors from ref to pending execution when the processor is first owned exclusively in pending
* execution mode.
*/
class GrProgramElement : public SkNoncopyable {
public:
virtual ~GrProgramElement() {
// fRefCnt can be one when an effect is created statically using GR_CREATE_STATIC_EFFECT
SkASSERT((0 == fRefCnt || 1 == fRefCnt) && 0 == fPendingExecutions);
// Set to invalid values.
SkDEBUGCODE(fRefCnt = fPendingExecutions = -10;)
}
void ref() const {
this->validate();
// Once the ref cnt reaches zero it should never be ref'ed again.
SkASSERT(fRefCnt > 0);
++fRefCnt;
this->validate();
}
void unref() const {
this->validate();
--fRefCnt;
if (0 == fRefCnt) {
this->notifyRefCntIsZero();
if (0 == fPendingExecutions) {
delete this;
return;
} else {
this->removeRefs();
}
}
this->validate();
}
void validate() const {
#ifdef SK_DEBUG
SkASSERT(fRefCnt >= 0);
SkASSERT(fPendingExecutions >= 0);
SkASSERT(fRefCnt + fPendingExecutions > 0);
#endif
}
protected:
GrProgramElement() : fRefCnt(1), fPendingExecutions(0) {}
void addPendingExecution() const {
this->validate();
if (0 == fPendingExecutions) {
this->addPendingIOs();
}
++fPendingExecutions;
this->validate();
}
void completedExecution() const {
this->validate();
--fPendingExecutions;
if (0 == fPendingExecutions) {
if (0 == fRefCnt) {
delete this;
return;
} else {
this->pendingIOComplete();
}
}
this->validate();
}
private:
virtual void addPendingIOs() const = 0;
virtual void removeRefs() const = 0;
virtual void pendingIOComplete() const = 0;
/** This will be called when the ref cnt is zero. The object may or may not have pending
executions. */
virtual void notifyRefCntIsZero() const = 0;
mutable int32_t fRefCnt;
// Count of deferred executions not yet issued to the 3D API.
mutable int32_t fPendingExecutions;
// Only these classes can access addPendingExecution() and completedExecution().
template <typename T> friend class GrPendingProgramElement;
friend class GrProcessorSet;
typedef SkNoncopyable INHERITED;
};
#endif

View File

@ -33,11 +33,7 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrPrimitiveProcessor& primP
const GrPipeline& pipeline,
GrProgramDesc* desc,
GrGLGpu* gpu) {
#ifdef SK_DEBUG
GrResourceProvider* resourceProvider = gpu->getContext()->contextPriv().resourceProvider();
SkASSERT(!pipeline.isBad() && primProc.instantiate(resourceProvider));
#endif
SkASSERT(!pipeline.isBad());
ATRACE_ANDROID_FRAMEWORK("Shader Compile");
GrAutoLocaleSetter als("C");

View File

@ -847,7 +847,7 @@ private:
mesh.setIndexed(indexBuffer, tess.numIndices(), firstIndex, 0, tess.numPts() - 1,
GrPrimitiveRestart::kNo);
mesh.setVertexData(vertexBuffer, firstVertex);
target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(gp, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
}
@ -935,7 +935,7 @@ private:
mesh.setIndexed(indexBuffer, draw.fIndexCnt, firstIndex, 0, draw.fVertexCnt - 1,
GrPrimitiveRestart::kNo);
mesh.setVertexData(vertexBuffer, firstVertex);
target->draw(quadProcessor.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(quadProcessor, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
firstIndex += draw.fIndexCnt;
firstVertex += draw.fVertexCnt;
}

View File

@ -292,7 +292,7 @@ private:
info = this->next(info);
}
auto pipe = fHelper.makePipeline(target);
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -979,7 +979,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
mesh.setIndexedPatterned(linesIndexBuffer.get(), kIdxsPerLineSeg, kLineSegNumVertices,
lineCount, kLineSegsNumInIdxBuffer);
mesh.setVertexData(vertexBuffer, firstVertex);
target->draw(lineGP.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(lineGP), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
if (quadCount || conicCount) {
@ -1034,7 +1034,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
mesh.setIndexedPatterned(quadsIndexBuffer.get(), kIdxsPerQuad, kQuadNumVertices,
quadCount, kQuadsNumInIdxBuffer);
mesh.setVertexData(vertexBuffer, firstVertex);
target->draw(quadGP.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(quadGP), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
firstVertex += quadCount * kQuadNumVertices;
}
@ -1043,7 +1043,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
mesh.setIndexedPatterned(quadsIndexBuffer.get(), kIdxsPerQuad, kQuadNumVertices,
conicCount, kQuadsNumInIdxBuffer);
mesh.setVertexData(vertexBuffer, firstVertex);
target->draw(conicGP.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(conicGP), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
}
}

View File

@ -210,7 +210,7 @@ public:
}
private:
void draw(Target* target, const GrGeometryProcessor* gp, const GrPipeline* pipeline,
void draw(Target* target, sk_sp<const GrGeometryProcessor> gp, const GrPipeline* pipeline,
const GrPipeline::FixedDynamicState* fixedDynamicState, int vertexCount,
size_t vertexStride, void* vertices, int indexCount, uint16_t* indices) const {
if (vertexCount == 0 || indexCount == 0) {
@ -238,7 +238,7 @@ private:
mesh.setIndexed(indexBuffer, indexCount, firstIndex, 0, vertexCount - 1,
GrPrimitiveRestart::kNo);
mesh.setVertexData(vertexBuffer, firstVertex);
target->draw(gp, pipeline, fixedDynamicState, mesh);
target->draw(std::move(gp), pipeline, fixedDynamicState, mesh);
}
void onPrepareDraws(Target* target) override {
@ -279,7 +279,7 @@ private:
if (vertexCount + currentVertices > static_cast<int>(UINT16_MAX)) {
// if we added the current instance, we would overflow the indices we can store in a
// uint16_t. Draw what we've got so far and reset.
this->draw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, vertexCount,
this->draw(target, gp, pipe.fPipeline, pipe.fFixedDynamicState, vertexCount,
vertexStride, vertices, indexCount, indices);
vertexCount = 0;
indexCount = 0;
@ -311,7 +311,7 @@ private:
indexCount += currentIndices;
}
if (vertexCount <= SK_MaxS32 && indexCount <= SK_MaxS32) {
this->draw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, vertexCount,
this->draw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, vertexCount,
vertexStride, vertices, indexCount, indices);
}
sk_free(vertices);

View File

@ -308,7 +308,7 @@ void AAStrokeRectOp::onPrepareDraws(Target* target) {
fHelper.compatibleWithAlphaAsCoverage());
}
auto pipe = fHelper.makePipeline(target);
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
sk_sp<const GrBuffer> AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* resourceProvider,

View File

@ -431,8 +431,8 @@ void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) co
mesh.setIndexedPatterned(flushInfo->fIndexBuffer.get(), kIndicesPerGlyph, kVerticesPerGlyph,
flushInfo->fGlyphsToFlush, maxGlyphsPerDraw);
mesh.setVertexData(flushInfo->fVertexBuffer.get(), flushInfo->fVertexOffset);
target->draw(flushInfo->fGeometryProcessor.get(), flushInfo->fPipeline,
flushInfo->fFixedDynamicState, mesh);
target->draw(flushInfo->fGeometryProcessor, flushInfo->fPipeline, flushInfo->fFixedDynamicState,
mesh);
flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
flushInfo->fGlyphsToFlush = 0;
}

View File

@ -696,7 +696,7 @@ private:
}
auto pipe = target->makePipeline(pipelineFlags, std::move(fProcessorSet),
target->detachAppliedClip());
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -65,12 +65,12 @@ namespace {
class PathGeoBuilder {
public:
PathGeoBuilder(GrPrimitiveType primitiveType, GrMeshDrawOp::Target* target,
GrGeometryProcessor* geometryProcessor, const GrPipeline* pipeline,
sk_sp<const GrGeometryProcessor> geometryProcessor, const GrPipeline* pipeline,
const GrPipeline::FixedDynamicState* fixedDynamicState)
: fMesh(primitiveType)
, fTarget(target)
, fVertexStride(sizeof(SkPoint))
, fGeometryProcessor(geometryProcessor)
, fGeometryProcessor(std::move(geometryProcessor))
, fPipeline(pipeline)
, fFixedDynamicState(fixedDynamicState)
, fIndexBuffer(nullptr)
@ -314,7 +314,7 @@ private:
GrMesh fMesh;
GrMeshDrawOp::Target* fTarget;
size_t fVertexStride;
GrGeometryProcessor* fGeometryProcessor;
sk_sp<const GrGeometryProcessor> fGeometryProcessor;
const GrPipeline* fPipeline;
const GrPipeline::FixedDynamicState* fFixedDynamicState;
@ -428,7 +428,7 @@ private:
primitiveType = GrPrimitiveType::kTriangles;
}
auto pipe = fHelper.makePipeline(target);
PathGeoBuilder pathGeoBuilder(primitiveType, target, gp.get(), pipe.fPipeline,
PathGeoBuilder pathGeoBuilder(primitiveType, target, std::move(gp), pipe.fPipeline,
pipe.fFixedDynamicState);
// fill buffers

View File

@ -147,7 +147,7 @@ void GrDrawAtlasOp::onPrepareDraws(Target* target) {
vertPtr += allocSize;
}
auto pipe = fHelper.makePipeline(target);
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool GrDrawAtlasOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {

View File

@ -261,7 +261,7 @@ void GrDrawVerticesOp::drawVolatile(Target* target) {
indices);
// Draw the vertices.
this->drawVertices(target, gp.get(), vertexBuffer, firstVertex, indexBuffer, firstIndex);
this->drawVertices(target, std::move(gp), vertexBuffer, firstVertex, indexBuffer, firstIndex);
}
void GrDrawVerticesOp::drawNonVolatile(Target* target) {
@ -298,7 +298,7 @@ void GrDrawVerticesOp::drawNonVolatile(Target* target) {
// Draw using the cached buffers if possible.
if (vertexBuffer && (!this->isIndexed() || indexBuffer)) {
this->drawVertices(target, gp.get(), vertexBuffer.get(), 0, indexBuffer.get(), 0);
this->drawVertices(target, std::move(gp), vertexBuffer.get(), 0, indexBuffer.get(), 0);
return;
}
@ -353,7 +353,7 @@ void GrDrawVerticesOp::drawNonVolatile(Target* target) {
rp->assignUniqueKeyToResource(indexKey, indexBuffer.get());
// Draw the vertices.
this->drawVertices(target, gp.get(), vertexBuffer.get(), 0, indexBuffer.get(), 0);
this->drawVertices(target, std::move(gp), vertexBuffer.get(), 0, indexBuffer.get(), 0);
}
void GrDrawVerticesOp::fillBuffers(bool hasColorAttribute,
@ -465,7 +465,7 @@ void GrDrawVerticesOp::fillBuffers(bool hasColorAttribute,
}
void GrDrawVerticesOp::drawVertices(Target* target,
GrGeometryProcessor* gp,
sk_sp<const GrGeometryProcessor> gp,
const GrBuffer* vertexBuffer,
int firstVertex,
const GrBuffer* indexBuffer,
@ -480,7 +480,7 @@ void GrDrawVerticesOp::drawVertices(Target* target,
}
mesh.setVertexData(vertexBuffer, firstVertex);
auto pipe = fHelper.makePipeline(target);
target->draw(gp, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
bool GrDrawVerticesOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {

View File

@ -80,7 +80,7 @@ private:
uint16_t* indices) const;
void drawVertices(Target*,
GrGeometryProcessor*,
sk_sp<const GrGeometryProcessor>,
const GrBuffer* vertexBuffer,
int firstVertex,
const GrBuffer* indexBuffer,

View File

@ -283,7 +283,7 @@ private:
}
auto pipe = fHelper.makePipeline(target, 1);
pipe.fFixedDynamicState->fPrimitiveProcessorTextures[0] = fProxy.get();
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -41,9 +41,9 @@ void* GrMeshDrawOp::PatternHelper::init(Target* target, size_t vertexStride,
}
void GrMeshDrawOp::PatternHelper::recordDraw(
Target* target, const GrGeometryProcessor* gp, const GrPipeline* pipeline,
Target* target, sk_sp<const GrGeometryProcessor> gp, const GrPipeline* pipeline,
const GrPipeline::FixedDynamicState* fixedDynamicState) {
target->draw(gp, pipeline, fixedDynamicState, fMesh);
target->draw(std::move(gp), pipeline, fixedDynamicState, fMesh);
}
void* GrMeshDrawOp::QuadHelper::init(Target* target, size_t vertexStride, int quadsToDraw) {

View File

@ -12,7 +12,6 @@
#include "GrDrawOp.h"
#include "GrGeometryProcessor.h"
#include "GrMesh.h"
#include "GrPendingProgramElement.h"
class GrAtlasManager;
class GrCaps;
@ -41,7 +40,7 @@ protected:
int indicesPerRepetition, int repeatCount);
/** Call after init() to issue draws to the GrMeshDrawOp::Target.*/
void recordDraw(Target*, const GrGeometryProcessor*, const GrPipeline*,
void recordDraw(Target*, sk_sp<const GrGeometryProcessor>, const GrPipeline*,
const GrPipeline::FixedDynamicState*);
private:
@ -78,7 +77,7 @@ public:
virtual ~Target() {}
/** Adds a draw of a mesh. */
virtual void draw(const GrGeometryProcessor*, const GrPipeline*,
virtual void draw(sk_sp<const GrGeometryProcessor>, const GrPipeline*,
const GrPipeline::FixedDynamicState*, const GrMesh&) = 0;
/**

View File

@ -207,7 +207,7 @@ private:
fRects[i].fRect, &fRects[i].fLocalQuad);
}
auto pipe = fHelper.makePipeline(target);
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -345,7 +345,7 @@ private:
}
}
auto pipe = fHelper.makePipeline(target);
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -192,7 +192,7 @@ private:
mesh.setNonIndexedNonInstanced(vertexCount);
mesh.setVertexData(vertexBuffer, firstVertex);
auto pipe = fHelper.makePipeline(target);
target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
bool onCombineIfPossible(GrOp* t, const GrCaps&) override {

View File

@ -1475,7 +1475,7 @@ private:
GrPrimitiveRestart::kNo);
mesh.setVertexData(vertexBuffer, firstVertex);
auto pipe = fHelper.makePipeline(target);
target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -1791,7 +1791,7 @@ private:
GrPrimitiveRestart::kNo);
mesh.setVertexData(vertexBuffer, firstVertex);
auto pipe = fHelper.makePipeline(target);
target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -2040,7 +2040,7 @@ private:
verts += kVerticesPerQuad;
}
auto pipe = fHelper.makePipeline(target);
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -2274,7 +2274,7 @@ private:
verts += kVerticesPerQuad;
}
auto pipe = fHelper.makePipeline(target);
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -2730,7 +2730,7 @@ private:
GrPrimitiveRestart::kNo);
mesh.setVertexData(vertexBuffer, firstVertex);
auto pipe = fHelper.makePipeline(target);
target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -2997,7 +2997,7 @@ private:
}
}
auto pipe = fHelper.makePipeline(target);
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -144,7 +144,7 @@ private:
verts += numRectsInRegion * kVertsPerInstance * kVertexStride;
}
auto pipe = fHelper.makePipeline(target);
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -631,7 +631,7 @@ private:
mesh.setIndexed(indexBuffer, fIndexCount, firstIndex, 0, fVertCount - 1,
GrPrimitiveRestart::kNo);
mesh.setVertexData(vertexBuffer, firstVertex);
target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -840,7 +840,7 @@ private:
kVerticesPerQuad, flushInfo->fInstancesToFlush,
maxInstancesPerDraw);
mesh.setVertexData(flushInfo->fVertexBuffer.get(), flushInfo->fVertexOffset);
target->draw(flushInfo->fGeometryProcessor.get(), flushInfo->fPipeline,
target->draw(flushInfo->fGeometryProcessor, flushInfo->fPipeline,
flushInfo->fFixedDynamicState, mesh);
flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFlush;
flushInfo->fInstancesToFlush = 0;

View File

@ -237,7 +237,7 @@ private:
return path;
}
void draw(Target* target, const GrGeometryProcessor* gp, size_t vertexStride) {
void draw(Target* target, sk_sp<const GrGeometryProcessor> gp, size_t vertexStride) {
SkASSERT(!fAntiAlias);
GrResourceProvider* rp = target->resourceProvider();
bool inverseFill = fShape.inverseFilled();
@ -261,7 +261,7 @@ private:
SkScalar tol = GrPathUtils::kDefaultTolerance;
tol = GrPathUtils::scaleToleranceToSrc(tol, fViewMatrix, fShape.bounds());
if (cache_match(cachedVertexBuffer.get(), tol, &actualCount)) {
this->drawVertices(target, gp, cachedVertexBuffer.get(), 0, actualCount);
this->drawVertices(target, std::move(gp), cachedVertexBuffer.get(), 0, actualCount);
return;
}
@ -280,7 +280,7 @@ private:
if (count == 0) {
return;
}
this->drawVertices(target, gp, allocator.vertexBuffer(), 0, count);
this->drawVertices(target, std::move(gp), allocator.vertexBuffer(), 0, count);
TessInfo info;
info.fTolerance = isLinear ? 0 : tol;
info.fCount = count;
@ -289,7 +289,7 @@ private:
fShape.addGenIDChangeListener(sk_make_sp<PathInvalidator>(key, target->contextUniqueID()));
}
void drawAA(Target* target, const GrGeometryProcessor* gp, size_t vertexStride) {
void drawAA(Target* target, sk_sp<const GrGeometryProcessor> gp, size_t vertexStride) {
SkASSERT(fAntiAlias);
SkPath path = getPath();
if (path.isEmpty()) {
@ -306,7 +306,8 @@ private:
if (count == 0) {
return;
}
this->drawVertices(target, gp, allocator.vertexBuffer(), allocator.firstVertex(), count);
this->drawVertices(target, std::move(gp), allocator.vertexBuffer(), allocator.firstVertex(),
count);
}
void onPrepareDraws(Target* target) override {
@ -349,19 +350,19 @@ private:
}
SkASSERT(vertexStride == gp->debugOnly_vertexStride());
if (fAntiAlias) {
this->drawAA(target, gp.get(), vertexStride);
this->drawAA(target, std::move(gp), vertexStride);
} else {
this->draw(target, gp.get(), vertexStride);
this->draw(target, std::move(gp), vertexStride);
}
}
void drawVertices(Target* target, const GrGeometryProcessor* gp, const GrBuffer* vb,
void drawVertices(Target* target, sk_sp<const GrGeometryProcessor> gp, const GrBuffer* vb,
int firstVertex, int count) {
GrMesh mesh(TESSELLATOR_WIREFRAME ? GrPrimitiveType::kLines : GrPrimitiveType::kTriangles);
mesh.setNonIndexedNonInstanced(count);
mesh.setVertexData(vb, firstVertex);
auto pipe = fHelper.makePipeline(target);
target->draw(gp, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }

View File

@ -871,7 +871,7 @@ __attribute__((no_sanitize("float-cast-overflow")))
mesh.setNonIndexedNonInstanced(4);
}
mesh.setVertexData(vbuffer, vstart);
target->draw(gp.get(), pipeline, fixedDynamicState, mesh);
target->draw(std::move(gp), pipeline, fixedDynamicState, mesh);
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -164,7 +164,7 @@ private:
mesh.setVertexData(vertexBuffer, firstVertex);
auto pipe = fHelper.makePipeline(target);
target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
}
Helper fHelper;

View File

@ -112,7 +112,7 @@ private:
SkPointPriv::SetRectTriStrip(vertices, 0.f, 0.f, 1.f, 1.f, vertexStride);
auto pipe = target->makePipeline(0, GrProcessorSet::MakeEmptySet(),
target->detachAppliedClip());
helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
}
int fNumAttribs;