No longer ref count GrGeometryProcessors
This CL is 100% plumbing. We ultimately want all GrPrimitiveProcessor-derived objects to not be refCounted. This will make several helper objects POD and, by putting them into an arena, will make managing their lifetime easier (e.g., for DDL prePreparing). Note: the CCPR GrGeometryProcessor-derived classes only ever appear on the stack so aren't forced into arenas. Bug: skia:9455 Change-Id: Ib9be503d2fbf8c2578642df93fc301156629829d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255304 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
parent
d95243b55f
commit
7cd0bfe769
@ -35,25 +35,11 @@ enum Mode {
|
||||
|
||||
class GP : public GrGeometryProcessor {
|
||||
public:
|
||||
GP(Mode mode, sk_sp<GrColorSpaceXform> colorSpaceXform)
|
||||
: INHERITED(kVertexColorSpaceBenchGP_ClassID)
|
||||
, fMode(mode)
|
||||
, fColorSpaceXform(std::move(colorSpaceXform)) {
|
||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||
switch (fMode) {
|
||||
case kBaseline_Mode:
|
||||
case kShader_Mode:
|
||||
fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
|
||||
break;
|
||||
case kFloat_Mode:
|
||||
fInColor = {"inColor", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
|
||||
break;
|
||||
case kHalf_Mode:
|
||||
fInColor = {"inColor", kHalf4_GrVertexAttribType, kHalf4_GrSLType};
|
||||
break;
|
||||
}
|
||||
this->setVertexAttributes(&fInPosition, 2);
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, Mode mode,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform) {
|
||||
return arena->make<GP>(mode, std::move(colorSpaceXform));
|
||||
}
|
||||
|
||||
const char* name() const override { return "VertexColorXformGP"; }
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
||||
@ -109,6 +95,28 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GP(Mode mode, sk_sp<GrColorSpaceXform> colorSpaceXform)
|
||||
: INHERITED(kVertexColorSpaceBenchGP_ClassID)
|
||||
, fMode(mode)
|
||||
, fColorSpaceXform(std::move(colorSpaceXform)) {
|
||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||
switch (fMode) {
|
||||
case kBaseline_Mode:
|
||||
case kShader_Mode:
|
||||
fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
|
||||
break;
|
||||
case kFloat_Mode:
|
||||
fInColor = {"inColor", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
|
||||
break;
|
||||
case kHalf_Mode:
|
||||
fInColor = {"inColor", kHalf4_GrVertexAttribType, kHalf4_GrSLType};
|
||||
break;
|
||||
}
|
||||
this->setVertexAttributes(&fInPosition, 2);
|
||||
}
|
||||
|
||||
Mode fMode;
|
||||
sk_sp<GrColorSpaceXform> fColorSpaceXform;
|
||||
|
||||
@ -160,7 +168,7 @@ private:
|
||||
friend class ::GrOpMemoryPool;
|
||||
|
||||
void onPrepareDraws(Target* target) override {
|
||||
sk_sp<GrGeometryProcessor> gp(new GP(fMode, fColorSpaceXform));
|
||||
GrGeometryProcessor* gp = GP::Make(target->allocator(), fMode, fColorSpaceXform);
|
||||
|
||||
size_t vertexStride = gp->vertexStride();
|
||||
const int kVertexCount = 1024;
|
||||
|
@ -71,12 +71,11 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
BezierTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect, const SkPMColor4f& color,
|
||||
int32_t classID)
|
||||
BezierTestOp(GrClipEdgeType et, const SkRect& rect, const SkPMColor4f& color, int32_t classID)
|
||||
: INHERITED(classID)
|
||||
, fRect(rect)
|
||||
, fColor(color)
|
||||
, fGeometryProcessor(std::move(gp))
|
||||
, fEdgeType(et)
|
||||
, fProcessorSet(SkBlendMode::kSrc) {
|
||||
this->setBounds(rect, HasAABloat::kYes, IsHairline::kNo);
|
||||
}
|
||||
@ -86,7 +85,7 @@ protected:
|
||||
this, chainBounds, std::move(fProcessorSet));
|
||||
}
|
||||
|
||||
sk_sp<const GrGeometryProcessor> gp() const { return fGeometryProcessor; }
|
||||
GrClipEdgeType edgeType() const { return fEdgeType; }
|
||||
|
||||
const SkRect& rect() const { return fRect; }
|
||||
const SkPMColor4f& color() const { return fColor; }
|
||||
@ -94,7 +93,7 @@ protected:
|
||||
private:
|
||||
SkRect fRect;
|
||||
SkPMColor4f fColor;
|
||||
sk_sp<const GrGeometryProcessor> fGeometryProcessor;
|
||||
GrClipEdgeType fEdgeType;
|
||||
GrProcessorSet fProcessorSet;
|
||||
|
||||
typedef GrMeshDrawOp INHERITED;
|
||||
@ -111,21 +110,21 @@ public:
|
||||
const char* name() const override { return "BezierConicTestOp"; }
|
||||
|
||||
static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
|
||||
sk_sp<const GrGeometryProcessor> gp,
|
||||
GrClipEdgeType et,
|
||||
const SkRect& rect,
|
||||
const SkPMColor4f& color,
|
||||
const SkMatrix& klm) {
|
||||
GrOpMemoryPool* pool = context->priv().opMemoryPool();
|
||||
|
||||
return pool->allocate<BezierConicTestOp>(std::move(gp), rect, color, klm);
|
||||
return pool->allocate<BezierConicTestOp>(et, rect, color, klm);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::GrOpMemoryPool; // for ctor
|
||||
|
||||
BezierConicTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect,
|
||||
BezierConicTestOp(GrClipEdgeType et, const SkRect& rect,
|
||||
const SkPMColor4f& color, const SkMatrix& klm)
|
||||
: INHERITED(std::move(gp), rect, color, ClassID()), fKLM(klm) {}
|
||||
: INHERITED(et, rect, color, ClassID()), fKLM(klm) {}
|
||||
|
||||
struct Vertex {
|
||||
SkPoint fPosition;
|
||||
@ -133,7 +132,14 @@ private:
|
||||
};
|
||||
|
||||
void onPrepareDraws(Target* target) override {
|
||||
SkASSERT(this->gp()->vertexStride() == sizeof(Vertex));
|
||||
GrGeometryProcessor* gp = GrConicEffect::Make(target->allocator(), this->color(),
|
||||
SkMatrix::I(), this->edgeType(),
|
||||
target->caps(), SkMatrix::I(), false);
|
||||
if (!gp) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkASSERT(gp->vertexStride() == sizeof(Vertex));
|
||||
QuadHelper helper(target, sizeof(Vertex), 1);
|
||||
Vertex* verts = reinterpret_cast<Vertex*>(helper.vertices());
|
||||
if (!verts) {
|
||||
@ -147,7 +153,7 @@ private:
|
||||
fKLM.mapHomogeneousPoints((SkPoint3* ) verts[v].fKLM, &pt3, 1);
|
||||
}
|
||||
|
||||
helper.recordDraw(target, this->gp());
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
SkMatrix fKLM;
|
||||
@ -177,7 +183,6 @@ protected:
|
||||
return SkISize::Make(800, 800);
|
||||
}
|
||||
|
||||
|
||||
void onDraw(GrContext* context, GrRenderTargetContext* renderTargetContext,
|
||||
SkCanvas* canvas) override {
|
||||
struct Vertex {
|
||||
@ -205,13 +210,7 @@ protected:
|
||||
};
|
||||
SkScalar weight = rand.nextRangeF(0.f, 2.f);
|
||||
for(int edgeType = 0; edgeType < kGrClipEdgeTypeCnt; ++edgeType) {
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrClipEdgeType et = (GrClipEdgeType)edgeType;
|
||||
gp = GrConicEffect::Make(color, SkMatrix::I(), et, *context->priv().caps(),
|
||||
SkMatrix::I(), false);
|
||||
if (!gp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SkScalar x = col * w;
|
||||
SkScalar y = row * h;
|
||||
@ -257,7 +256,7 @@ protected:
|
||||
boundsPaint.setStyle(SkPaint::kStroke_Style);
|
||||
canvas->drawRect(bounds, boundsPaint);
|
||||
|
||||
std::unique_ptr<GrDrawOp> op = BezierConicTestOp::Make(context, gp, bounds,
|
||||
std::unique_ptr<GrDrawOp> op = BezierConicTestOp::Make(context, et, bounds,
|
||||
color, klm);
|
||||
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
|
||||
}
|
||||
@ -322,21 +321,21 @@ public:
|
||||
const char* name() const override { return "BezierQuadTestOp"; }
|
||||
|
||||
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
|
||||
sk_sp<const GrGeometryProcessor> gp,
|
||||
GrClipEdgeType et,
|
||||
const SkRect& rect,
|
||||
const SkPMColor4f& color,
|
||||
const GrPathUtils::QuadUVMatrix& devToUV) {
|
||||
GrOpMemoryPool* pool = context->priv().opMemoryPool();
|
||||
|
||||
return pool->allocate<BezierQuadTestOp>(std::move(gp), rect, color, devToUV);
|
||||
return pool->allocate<BezierQuadTestOp>(et, rect, color, devToUV);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::GrOpMemoryPool; // for ctor
|
||||
|
||||
BezierQuadTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect,
|
||||
BezierQuadTestOp(GrClipEdgeType et, const SkRect& rect,
|
||||
const SkPMColor4f& color, const GrPathUtils::QuadUVMatrix& devToUV)
|
||||
: INHERITED(std::move(gp), rect, color, ClassID()), fDevToUV(devToUV) {}
|
||||
: INHERITED(et, rect, color, ClassID()), fDevToUV(devToUV) {}
|
||||
|
||||
struct Vertex {
|
||||
SkPoint fPosition;
|
||||
@ -344,7 +343,14 @@ private:
|
||||
};
|
||||
|
||||
void onPrepareDraws(Target* target) override {
|
||||
SkASSERT(this->gp()->vertexStride() == sizeof(Vertex));
|
||||
GrGeometryProcessor* gp = GrQuadEffect::Make(target->allocator(), this->color(),
|
||||
SkMatrix::I(), this->edgeType(),
|
||||
target->caps(), SkMatrix::I(), false);
|
||||
if (!gp) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkASSERT(gp->vertexStride() == sizeof(Vertex));
|
||||
QuadHelper helper(target, sizeof(Vertex), 1);
|
||||
Vertex* verts = reinterpret_cast<Vertex*>(helper.vertices());
|
||||
if (!verts) {
|
||||
@ -353,7 +359,7 @@ private:
|
||||
SkRect rect = this->rect();
|
||||
SkPointPriv::SetRectTriStrip(&verts[0].fPosition, rect, sizeof(Vertex));
|
||||
fDevToUV.apply(verts, 4, sizeof(Vertex), sizeof(SkPoint));
|
||||
helper.recordDraw(target, this->gp());
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
GrPathUtils::QuadUVMatrix fDevToUV;
|
||||
@ -408,13 +414,7 @@ protected:
|
||||
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
|
||||
};
|
||||
for(int edgeType = 0; edgeType < kGrClipEdgeTypeCnt; ++edgeType) {
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrClipEdgeType et = (GrClipEdgeType)edgeType;
|
||||
gp = GrQuadEffect::Make(color, SkMatrix::I(), et, *context->priv().caps(),
|
||||
SkMatrix::I(), false);
|
||||
if (!gp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SkScalar x = col * w;
|
||||
SkScalar y = row * h;
|
||||
@ -462,7 +462,7 @@ protected:
|
||||
|
||||
GrPathUtils::QuadUVMatrix DevToUV(pts);
|
||||
|
||||
std::unique_ptr<GrDrawOp> op = BezierQuadTestOp::Make(context, gp,
|
||||
std::unique_ptr<GrDrawOp> op = BezierQuadTestOp::Make(context, et,
|
||||
bounds, color, DevToUV);
|
||||
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
|
||||
}
|
||||
|
@ -109,12 +109,12 @@ private:
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
|
||||
Color color(fColor);
|
||||
sk_sp<GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Make(
|
||||
target->caps().shaderCaps(),
|
||||
color,
|
||||
Coverage::kSolid_Type,
|
||||
LocalCoords::kUnused_Type,
|
||||
SkMatrix::I()));
|
||||
GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Make(target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
color,
|
||||
Coverage::kSolid_Type,
|
||||
LocalCoords::kUnused_Type,
|
||||
SkMatrix::I());
|
||||
|
||||
SkASSERT(gp->vertexStride() == sizeof(SkPoint));
|
||||
QuadHelper helper(target, sizeof(SkPoint), 1);
|
||||
@ -124,7 +124,7 @@ private:
|
||||
}
|
||||
|
||||
SkPointPriv::SetRectTriStrip(verts, fRect, sizeof(SkPoint));
|
||||
helper.recordDraw(target, std::move(gp));
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "src/gpu/GrDefaultGeoProcFactory.h"
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/glsl/GrGLSLColorSpaceXformHelper.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
@ -34,17 +35,18 @@ enum GPFlag {
|
||||
|
||||
class DefaultGeoProc : public GrGeometryProcessor {
|
||||
public:
|
||||
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps* shaderCaps,
|
||||
uint32_t gpTypeFlags,
|
||||
const SkPMColor4f& color,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
bool localCoordsWillBeRead,
|
||||
uint8_t coverage) {
|
||||
return sk_sp<GrGeometryProcessor>(new DefaultGeoProc(
|
||||
shaderCaps, gpTypeFlags, color, std::move(colorSpaceXform), viewMatrix, localMatrix,
|
||||
coverage, localCoordsWillBeRead));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const GrShaderCaps* shaderCaps,
|
||||
uint32_t gpTypeFlags,
|
||||
const SkPMColor4f& color,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
bool localCoordsWillBeRead,
|
||||
uint8_t coverage) {
|
||||
return arena->make<DefaultGeoProc>(shaderCaps, gpTypeFlags, color,
|
||||
std::move(colorSpaceXform), viewMatrix, localMatrix,
|
||||
coverage, localCoordsWillBeRead);
|
||||
}
|
||||
|
||||
const char* name() const override { return "DefaultGeometryProcessor"; }
|
||||
@ -224,6 +226,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
DefaultGeoProc(const GrShaderCaps* shaderCaps,
|
||||
uint32_t gpTypeFlags,
|
||||
const SkPMColor4f& color,
|
||||
@ -275,7 +279,7 @@ private:
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
uint32_t flags = 0;
|
||||
if (d->fRandom->nextBool()) {
|
||||
flags |= kColorAttribute_GPFlag;
|
||||
@ -296,7 +300,7 @@ sk_sp<GrGeometryProcessor> DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
flags |= kLocalCoordAttribute_GPFlag;
|
||||
}
|
||||
|
||||
return DefaultGeoProc::Make(d->caps()->shaderCaps(),
|
||||
return DefaultGeoProc::Make(d->allocator(), d->caps()->shaderCaps(),
|
||||
flags,
|
||||
SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
GrTest::TestColorXform(d->fRandom),
|
||||
@ -307,11 +311,12 @@ sk_sp<GrGeometryProcessor> DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
}
|
||||
#endif
|
||||
|
||||
sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::Make(const GrShaderCaps* shaderCaps,
|
||||
const Color& color,
|
||||
const Coverage& coverage,
|
||||
const LocalCoords& localCoords,
|
||||
const SkMatrix& viewMatrix) {
|
||||
GrGeometryProcessor* GrDefaultGeoProcFactory::Make(SkArenaAlloc* arena,
|
||||
const GrShaderCaps* shaderCaps,
|
||||
const Color& color,
|
||||
const Coverage& coverage,
|
||||
const LocalCoords& localCoords,
|
||||
const SkMatrix& viewMatrix) {
|
||||
uint32_t flags = 0;
|
||||
if (Color::kPremulGrColorAttribute_Type == color.fType) {
|
||||
flags |= kColorAttribute_GPFlag;
|
||||
@ -330,7 +335,8 @@ sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::Make(const GrShaderCaps* sha
|
||||
uint8_t inCoverage = coverage.fCoverage;
|
||||
bool localCoordsWillBeRead = localCoords.fType != LocalCoords::kUnused_Type;
|
||||
|
||||
return DefaultGeoProc::Make(shaderCaps,
|
||||
return DefaultGeoProc::Make(arena,
|
||||
shaderCaps,
|
||||
flags,
|
||||
color.fColor,
|
||||
color.fColorSpaceXform,
|
||||
@ -340,12 +346,12 @@ sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::Make(const GrShaderCaps* sha
|
||||
inCoverage);
|
||||
}
|
||||
|
||||
sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::MakeForDeviceSpace(
|
||||
const GrShaderCaps* shaderCaps,
|
||||
const Color& color,
|
||||
const Coverage& coverage,
|
||||
const LocalCoords& localCoords,
|
||||
const SkMatrix& viewMatrix) {
|
||||
GrGeometryProcessor* GrDefaultGeoProcFactory::MakeForDeviceSpace(SkArenaAlloc* arena,
|
||||
const GrShaderCaps* shaderCaps,
|
||||
const Color& color,
|
||||
const Coverage& coverage,
|
||||
const LocalCoords& localCoords,
|
||||
const SkMatrix& viewMatrix) {
|
||||
SkMatrix invert = SkMatrix::I();
|
||||
if (LocalCoords::kUnused_Type != localCoords.fType) {
|
||||
SkASSERT(LocalCoords::kUsePosition_Type == localCoords.fType);
|
||||
@ -359,5 +365,5 @@ sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::MakeForDeviceSpace(
|
||||
}
|
||||
|
||||
LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert);
|
||||
return Make(shaderCaps, color, coverage, inverted, SkMatrix::I());
|
||||
return Make(arena, shaderCaps, color, coverage, inverted, SkMatrix::I());
|
||||
}
|
||||
|
@ -76,22 +76,24 @@ namespace GrDefaultGeoProcFactory {
|
||||
const SkMatrix* fMatrix;
|
||||
};
|
||||
|
||||
sk_sp<GrGeometryProcessor> Make(const GrShaderCaps*,
|
||||
const Color&,
|
||||
const Coverage&,
|
||||
const LocalCoords&,
|
||||
const SkMatrix& viewMatrix);
|
||||
GrGeometryProcessor* Make(SkArenaAlloc*,
|
||||
const GrShaderCaps*,
|
||||
const Color&,
|
||||
const Coverage&,
|
||||
const LocalCoords&,
|
||||
const SkMatrix& viewMatrix);
|
||||
|
||||
/*
|
||||
* Use this factory to create a GrGeometryProcessor that expects a device space vertex position
|
||||
* attribute. The view matrix must still be provided to compute correctly transformed
|
||||
* coordinates for GrFragmentProcessors. It may fail if the view matrix is not invertible.
|
||||
*/
|
||||
sk_sp<GrGeometryProcessor> MakeForDeviceSpace(const GrShaderCaps*,
|
||||
const Color&,
|
||||
const Coverage&,
|
||||
const LocalCoords&,
|
||||
const SkMatrix& viewMatrix);
|
||||
GrGeometryProcessor* MakeForDeviceSpace(SkArenaAlloc*,
|
||||
const GrShaderCaps*,
|
||||
const Color&,
|
||||
const Coverage&,
|
||||
const LocalCoords&,
|
||||
const SkMatrix& viewMatrix);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -12,10 +12,17 @@
|
||||
|
||||
/**
|
||||
* A GrGeometryProcessor is a flexible method for rendering a primitive. The GrGeometryProcessor
|
||||
* has complete control over vertex attributes and uniforms(aside from the render target) but it
|
||||
* has complete control over vertex attributes and uniforms (aside from the render target) but it
|
||||
* must obey the same contract as any GrPrimitiveProcessor, specifically it must emit a color and
|
||||
* coverage into the fragment shader. Where this color and coverage come from is completely the
|
||||
* responsibility of the GrGeometryProcessor.
|
||||
*
|
||||
* Note that all derived classes should hide their constructors and provide a Make factory
|
||||
* function that takes an arena (except for CCPR-specific classes). This is because
|
||||
* GrGeometryProcessor's are not ref-counted to must have some other mechanism for managing
|
||||
* their lifetime. In particular, geometry processors can be created in either the
|
||||
* record-time or flush-time arenas which defined their lifetimes (i.e., a DDLs life time in
|
||||
* the first case and a single flush in the second case).
|
||||
*/
|
||||
class GrGeometryProcessor : public GrPrimitiveProcessor {
|
||||
public:
|
||||
|
@ -58,7 +58,7 @@ void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp(
|
||||
this->proxy()->numStencilSamples(),
|
||||
this->proxy()->origin(),
|
||||
pipeline,
|
||||
fCurrDraw->fGeometryProcessor.get(),
|
||||
fCurrDraw->fGeometryProcessor,
|
||||
fCurrDraw->fFixedDynamicState,
|
||||
fCurrDraw->fDynamicStateArrays,
|
||||
fCurrDraw->fMeshCnt,
|
||||
@ -140,7 +140,7 @@ GrDeferredUploadToken GrOpFlushState::addASAPUpload(GrDeferredTextureUploadFn&&
|
||||
}
|
||||
|
||||
void GrOpFlushState::recordDraw(
|
||||
sk_sp<const GrGeometryProcessor> gp, const GrMesh meshes[], int meshCnt,
|
||||
const GrGeometryProcessor* gp, const GrMesh meshes[], int meshCnt,
|
||||
const GrPipeline::FixedDynamicState* fixedDynamicState,
|
||||
const GrPipeline::DynamicStateArrays* dynamicStateArrays,
|
||||
GrPrimitiveType primitiveType) {
|
||||
@ -160,7 +160,7 @@ void GrOpFlushState::recordDraw(
|
||||
dynamicStateArrays->fPrimitiveProcessorTextures[i]->ref();
|
||||
}
|
||||
}
|
||||
draw.fGeometryProcessor = std::move(gp);
|
||||
draw.fGeometryProcessor = gp;
|
||||
draw.fFixedDynamicState = fixedDynamicState;
|
||||
draw.fDynamicStateArrays = dynamicStateArrays;
|
||||
draw.fMeshes = meshes;
|
||||
|
@ -116,7 +116,7 @@ public:
|
||||
GrDeferredUploadToken addASAPUpload(GrDeferredTextureUploadFn&&) final;
|
||||
|
||||
/** Overrides of GrMeshDrawOp::Target. */
|
||||
void recordDraw(sk_sp<const GrGeometryProcessor>, const GrMesh[], int meshCnt,
|
||||
void recordDraw(const GrGeometryProcessor*, const GrMesh[], int meshCnt,
|
||||
const GrPipeline::FixedDynamicState*,
|
||||
const GrPipeline::DynamicStateArrays*, GrPrimitiveType) final;
|
||||
void* makeVertexSpace(size_t vertexSize, int vertexCount, sk_sp<const GrBuffer>*,
|
||||
@ -164,9 +164,12 @@ private:
|
||||
// the shared state once and then issue draws for each mesh.
|
||||
struct Draw {
|
||||
~Draw();
|
||||
sk_sp<const GrGeometryProcessor> fGeometryProcessor;
|
||||
const GrPipeline::FixedDynamicState* fFixedDynamicState;
|
||||
const GrPipeline::DynamicStateArrays* fDynamicStateArrays;
|
||||
// The geometry processor is always forced to be in an arena allocation or appears on
|
||||
// the stack (for CCPR). In either case this object does not need to manage its
|
||||
// lifetime.
|
||||
const GrGeometryProcessor* fGeometryProcessor = nullptr;
|
||||
const GrPipeline::FixedDynamicState* fFixedDynamicState = nullptr;
|
||||
const GrPipeline::DynamicStateArrays* fDynamicStateArrays = nullptr;
|
||||
const GrMesh* fMeshes = nullptr;
|
||||
const GrOp* fOp = nullptr;
|
||||
int fMeshCnt = 0;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
#include "include/private/SkTArray.h"
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/gpu/GrTestUtils.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
|
||||
@ -61,7 +62,10 @@ struct GrProcessorTestData {
|
||||
fProxies[1] = proxies[1];
|
||||
fProxyColorTypes[0] = proxyColorTypes[0];
|
||||
fProxyColorTypes[1] = proxyColorTypes[1];
|
||||
|
||||
fArena = std::unique_ptr<SkArenaAlloc>(new SkArenaAlloc(1000));
|
||||
}
|
||||
|
||||
SkRandom* fRandom;
|
||||
const GrRenderTargetContext* fRenderTargetContext;
|
||||
|
||||
@ -71,11 +75,14 @@ struct GrProcessorTestData {
|
||||
const GrCaps* caps();
|
||||
sk_sp<GrTextureProxy> textureProxy(int index) { return fProxies[index]; }
|
||||
GrColorType textureProxyColorType(int index) { return fProxyColorTypes[index]; }
|
||||
SkArenaAlloc* allocator() { return fArena.get(); }
|
||||
|
||||
private:
|
||||
GrContext* fContext;
|
||||
sk_sp<GrTextureProxy> fProxies[2];
|
||||
GrColorType fProxyColorTypes[2];
|
||||
|
||||
std::unique_ptr<SkArenaAlloc> fArena;
|
||||
};
|
||||
|
||||
class GrProcessor;
|
||||
@ -84,7 +91,6 @@ class GrTexture;
|
||||
template <class ProcessorSmartPtr>
|
||||
class GrProcessorTestFactory : private SkNoncopyable {
|
||||
public:
|
||||
using Processor = typename ProcessorSmartPtr::element_type;
|
||||
using MakeProc = ProcessorSmartPtr (*)(GrProcessorTestData*);
|
||||
|
||||
GrProcessorTestFactory(MakeProc makeProc) {
|
||||
@ -126,7 +132,7 @@ private:
|
||||
};
|
||||
|
||||
using GrFragmentProcessorTestFactory = GrProcessorTestFactory<std::unique_ptr<GrFragmentProcessor>>;
|
||||
using GrGeometryProcessorTestFactory = GrProcessorTestFactory<sk_sp<GrGeometryProcessor>>;
|
||||
using GrGeometryProcessorTestFactory = GrProcessorTestFactory<GrGeometryProcessor*>;
|
||||
|
||||
class GrXPFactoryTestFactory : private SkNoncopyable {
|
||||
public:
|
||||
@ -159,7 +165,7 @@ private:
|
||||
*/
|
||||
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
|
||||
static GrGeometryProcessorTestFactory gTestFactory SK_UNUSED; \
|
||||
static sk_sp<GrGeometryProcessor> TestCreate(GrProcessorTestData*);
|
||||
static GrGeometryProcessor* TestCreate(GrProcessorTestData*);
|
||||
|
||||
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
|
||||
static GrFragmentProcessorTestFactory gTestFactory SK_UNUSED; \
|
||||
@ -193,7 +199,7 @@ private:
|
||||
// The unit test relies on static initializers. Just declare the TestCreate function so that
|
||||
// its definitions will compile.
|
||||
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
|
||||
static sk_sp<GrGeometryProcessor> TestCreate(GrProcessorTestData*);
|
||||
static GrGeometryProcessor* TestCreate(GrProcessorTestData*);
|
||||
#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X)
|
||||
|
||||
// The unit test relies on static initializers. Just declare the TestGet function so that
|
||||
|
@ -70,7 +70,7 @@ inline void CubicStrokeInstance::set(const Sk4f& X, const Sk4f& Y, float dx, flo
|
||||
// for seamless integration with the connecting geometry.
|
||||
class LinearStrokeProcessor : public GrGeometryProcessor {
|
||||
public:
|
||||
LinearStrokeProcessor() : GrGeometryProcessor(kLinearStrokeProcessor_ClassID) {
|
||||
LinearStrokeProcessor() : INHERITED(kLinearStrokeProcessor_ClassID) {
|
||||
this->setInstanceAttributes(kInstanceAttribs, 2);
|
||||
#ifdef SK_DEBUG
|
||||
using Instance = LinearStrokeInstance;
|
||||
@ -96,6 +96,8 @@ private:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
||||
return new Impl();
|
||||
}
|
||||
|
||||
typedef GrGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
void LinearStrokeProcessor::Impl::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
|
@ -21,7 +21,7 @@ namespace {
|
||||
|
||||
class StencilResolveProcessor : public GrGeometryProcessor {
|
||||
public:
|
||||
StencilResolveProcessor() : GrGeometryProcessor(kStencilResolveProcessor_ClassID) {
|
||||
StencilResolveProcessor() : INHERITED(kStencilResolveProcessor_ClassID) {
|
||||
static constexpr Attribute kIBounds = {
|
||||
"ibounds", kShort4_GrVertexAttribType, kShort4_GrSLType};
|
||||
this->setInstanceAttributes(&kIBounds, 1);
|
||||
@ -29,10 +29,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const char* name() const override { return "GrCCPathProcessor"; }
|
||||
void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
const char* name() const final { return "StencilResolveProcessor"; }
|
||||
void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const final;
|
||||
class Impl;
|
||||
|
||||
typedef GrGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
// This processor draws pixel-aligned rectangles directly on top of every path in the atlas.
|
||||
|
@ -233,13 +233,13 @@ GrGLSLPrimitiveProcessor* GrConicEffect::createGLSLInstance(const GrShaderCaps&)
|
||||
GrConicEffect::GrConicEffect(const SkPMColor4f& color, const SkMatrix& viewMatrix, uint8_t coverage,
|
||||
GrClipEdgeType edgeType, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords)
|
||||
: INHERITED(kGrConicEffect_ClassID)
|
||||
, fColor(color)
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fLocalMatrix(viewMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fCoverageScale(coverage)
|
||||
, fEdgeType(edgeType) {
|
||||
: INHERITED(kGrConicEffect_ClassID)
|
||||
, fColor(color)
|
||||
, fViewMatrix(viewMatrix)
|
||||
, fLocalMatrix(viewMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fCoverageScale(coverage)
|
||||
, fEdgeType(edgeType) {
|
||||
this->setVertexAttributes(kAttributes, SK_ARRAY_COUNT(kAttributes));
|
||||
}
|
||||
|
||||
@ -248,13 +248,14 @@ GrConicEffect::GrConicEffect(const SkPMColor4f& color, const SkMatrix& viewMatri
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> GrConicEffect::TestCreate(GrProcessorTestData* d) {
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrGeometryProcessor* GrConicEffect::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* gp;
|
||||
do {
|
||||
GrClipEdgeType edgeType =
|
||||
static_cast<GrClipEdgeType>(
|
||||
d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
|
||||
gp = GrConicEffect::Make(SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
gp = GrConicEffect::Make(d->allocator(),
|
||||
SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
GrTest::TestMatrix(d->fRandom), edgeType, *d->caps(),
|
||||
GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
|
||||
} while (nullptr == gp);
|
||||
@ -448,12 +449,13 @@ GrQuadEffect::GrQuadEffect(const SkPMColor4f& color, const SkMatrix& viewMatrix,
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> GrQuadEffect::TestCreate(GrProcessorTestData* d) {
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrGeometryProcessor* GrQuadEffect::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* gp;
|
||||
do {
|
||||
GrClipEdgeType edgeType = static_cast<GrClipEdgeType>(
|
||||
d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
|
||||
gp = GrQuadEffect::Make(SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
gp = GrQuadEffect::Make(d->allocator(),
|
||||
SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
GrTest::TestMatrix(d->fRandom), edgeType, *d->caps(),
|
||||
GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
|
||||
} while (nullptr == gp);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define GrBezierEffect_DEFINED
|
||||
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrProcessor.h"
|
||||
@ -57,36 +58,29 @@ class GrGLConicEffect;
|
||||
|
||||
class GrConicEffect : public GrGeometryProcessor {
|
||||
public:
|
||||
static sk_sp<GrGeometryProcessor> Make(const SkPMColor4f& color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrClipEdgeType edgeType,
|
||||
const GrCaps& caps,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
uint8_t coverage = 0xff) {
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const SkPMColor4f& color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrClipEdgeType edgeType,
|
||||
const GrCaps& caps,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
uint8_t coverage = 0xff) {
|
||||
switch (edgeType) {
|
||||
case GrClipEdgeType::kFillAA:
|
||||
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
|
||||
return nullptr;
|
||||
}
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new GrConicEffect(color, viewMatrix, coverage, GrClipEdgeType::kFillAA,
|
||||
localMatrix, usesLocalCoords));
|
||||
case GrClipEdgeType::kFillAA: // fall through
|
||||
case GrClipEdgeType::kHairlineAA:
|
||||
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
|
||||
return nullptr;
|
||||
}
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new GrConicEffect(color, viewMatrix, coverage,
|
||||
GrClipEdgeType::kHairlineAA, localMatrix,
|
||||
usesLocalCoords));
|
||||
break;
|
||||
case GrClipEdgeType::kFillBW:
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new GrConicEffect(color, viewMatrix, coverage, GrClipEdgeType::kFillBW,
|
||||
localMatrix, usesLocalCoords));
|
||||
default:
|
||||
break;
|
||||
default: // kInverseFillBW or kInverseFillAA
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return arena->make<GrConicEffect>(color, viewMatrix, coverage, edgeType, localMatrix,
|
||||
usesLocalCoords);
|
||||
}
|
||||
|
||||
~GrConicEffect() override;
|
||||
@ -109,6 +103,8 @@ public:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrConicEffect(const SkPMColor4f&, const SkMatrix& viewMatrix, uint8_t coverage, GrClipEdgeType,
|
||||
const SkMatrix& localMatrix, bool usesLocalCoords);
|
||||
|
||||
@ -141,36 +137,29 @@ class GrGLQuadEffect;
|
||||
|
||||
class GrQuadEffect : public GrGeometryProcessor {
|
||||
public:
|
||||
static sk_sp<GrGeometryProcessor> Make(const SkPMColor4f& color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrClipEdgeType edgeType,
|
||||
const GrCaps& caps,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
uint8_t coverage = 0xff) {
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const SkPMColor4f& color,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrClipEdgeType edgeType,
|
||||
const GrCaps& caps,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
uint8_t coverage = 0xff) {
|
||||
switch (edgeType) {
|
||||
case GrClipEdgeType::kFillAA:
|
||||
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
|
||||
return nullptr;
|
||||
}
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new GrQuadEffect(color, viewMatrix, coverage, GrClipEdgeType::kFillAA,
|
||||
localMatrix, usesLocalCoords));
|
||||
case GrClipEdgeType::kFillAA: // fall through
|
||||
case GrClipEdgeType::kHairlineAA:
|
||||
if (!caps.shaderCaps()->shaderDerivativeSupport()) {
|
||||
return nullptr;
|
||||
}
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new GrQuadEffect(color, viewMatrix, coverage,
|
||||
GrClipEdgeType::kHairlineAA, localMatrix,
|
||||
usesLocalCoords));
|
||||
break;
|
||||
case GrClipEdgeType::kFillBW:
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new GrQuadEffect(color, viewMatrix, coverage, GrClipEdgeType::kFillBW,
|
||||
localMatrix, usesLocalCoords));
|
||||
default:
|
||||
break;
|
||||
default: // kInverseFillBW and kInverseFillAA
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return arena->make<GrQuadEffect>(color, viewMatrix, coverage, edgeType,
|
||||
localMatrix, usesLocalCoords);
|
||||
}
|
||||
|
||||
~GrQuadEffect() override;
|
||||
@ -193,6 +182,8 @@ public:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrQuadEffect(const SkPMColor4f&, const SkMatrix& viewMatrix, uint8_t coverage, GrClipEdgeType,
|
||||
const SkMatrix& localMatrix, bool usesLocalCoords);
|
||||
|
||||
|
@ -196,7 +196,7 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
sk_sp<GrGeometryProcessor> GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
||||
sk_sp<GrTextureProxy> proxies[kMaxTextures] = {
|
||||
@ -225,7 +225,7 @@ sk_sp<GrGeometryProcessor> GrBitmapTextGeoProc::TestCreate(GrProcessorTestData*
|
||||
break;
|
||||
}
|
||||
|
||||
return GrBitmapTextGeoProc::Make(*d->caps()->shaderCaps(),
|
||||
return GrBitmapTextGeoProc::Make(d->allocator(), *d->caps()->shaderCaps(),
|
||||
SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
d->fRandom->nextBool(),
|
||||
proxies, 1, samplerState, format,
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef GrBitmapTextGeoProc_DEFINED
|
||||
#define GrBitmapTextGeoProc_DEFINED
|
||||
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrProcessor.h"
|
||||
|
||||
@ -23,15 +24,15 @@ class GrBitmapTextGeoProc : public GrGeometryProcessor {
|
||||
public:
|
||||
static constexpr int kMaxTextures = 4;
|
||||
|
||||
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps,
|
||||
const SkPMColor4f& color, bool wideColor,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& p, GrMaskFormat format,
|
||||
const SkMatrix& localMatrix, bool usesW) {
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new GrBitmapTextGeoProc(caps, color, wideColor, proxies, numActiveProxies, p, format,
|
||||
localMatrix, usesW));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const GrShaderCaps& caps,
|
||||
const SkPMColor4f& color, bool wideColor,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& p, GrMaskFormat format,
|
||||
const SkMatrix& localMatrix, bool usesW) {
|
||||
return arena->make<GrBitmapTextGeoProc>(caps, color, wideColor, proxies, numActiveProxies,
|
||||
p, format, localMatrix, usesW);
|
||||
}
|
||||
|
||||
~GrBitmapTextGeoProc() override {}
|
||||
@ -55,6 +56,8 @@ public:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrBitmapTextGeoProc(const GrShaderCaps&, const SkPMColor4f&, bool wideColor,
|
||||
const sk_sp<GrTextureProxy>* proxies, int numProxies,
|
||||
const GrSamplerState& params, GrMaskFormat format,
|
||||
|
@ -284,7 +284,7 @@ GrDistanceFieldA8TextGeoProc::createGLSLInstance(const GrShaderCaps&) const {
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
||||
sk_sp<GrTextureProxy> proxies[kMaxTextures] = {
|
||||
@ -309,7 +309,7 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
float lum = d->fRandom->nextF();
|
||||
#endif
|
||||
return GrDistanceFieldA8TextGeoProc::Make(*d->caps()->shaderCaps(),
|
||||
return GrDistanceFieldA8TextGeoProc::Make(d->allocator(), *d->caps()->shaderCaps(),
|
||||
proxies, 1,
|
||||
samplerState,
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
@ -580,7 +580,7 @@ GrDistanceFieldPathGeoProc::createGLSLInstance(const GrShaderCaps&) const {
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
||||
sk_sp<GrTextureProxy> proxies[kMaxTextures] = {
|
||||
@ -602,7 +602,7 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes
|
||||
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
|
||||
}
|
||||
|
||||
return GrDistanceFieldPathGeoProc::Make(*d->caps()->shaderCaps(),
|
||||
return GrDistanceFieldPathGeoProc::Make(d->allocator(), *d->caps()->shaderCaps(),
|
||||
GrTest::TestMatrix(d->fRandom),
|
||||
d->fRandom->nextBool(),
|
||||
proxies, 1,
|
||||
@ -905,7 +905,7 @@ GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(cons
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
|
||||
GrProcessorUnitTest::kAlphaTextureIdx;
|
||||
sk_sp<GrTextureProxy> proxies[kMaxTextures] = {
|
||||
@ -928,7 +928,7 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor
|
||||
}
|
||||
flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
|
||||
SkMatrix localMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
return GrDistanceFieldLCDTextGeoProc::Make(*d->caps()->shaderCaps(), proxies, 1, samplerState,
|
||||
wa, flags, localMatrix);
|
||||
return GrDistanceFieldLCDTextGeoProc::Make(d->allocator(), *d->caps()->shaderCaps(), proxies,
|
||||
1, samplerState, wa, flags, localMatrix);
|
||||
}
|
||||
#endif
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef GrDistanceFieldGeoProc_DEFINED
|
||||
#define GrDistanceFieldGeoProc_DEFINED
|
||||
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrProcessor.h"
|
||||
|
||||
@ -57,22 +58,24 @@ public:
|
||||
|
||||
/** The local matrix should be identity if local coords are not required by the GrPipeline. */
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& params, float lum, uint32_t flags,
|
||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||
return sk_sp<GrGeometryProcessor>(new GrDistanceFieldA8TextGeoProc(
|
||||
caps, proxies, numActiveProxies, params, lum, flags, localMatrixIfUsesLocalCoords));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& params, float lum, uint32_t flags,
|
||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||
return arena->make<GrDistanceFieldA8TextGeoProc>(
|
||||
caps, proxies, numActiveProxies, params, lum, flags, localMatrixIfUsesLocalCoords);
|
||||
}
|
||||
#else
|
||||
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& params, uint32_t flags,
|
||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||
return sk_sp<GrGeometryProcessor>(new GrDistanceFieldA8TextGeoProc(
|
||||
caps, proxies, numActiveProxies, params, flags, localMatrixIfUsesLocalCoords));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& params, uint32_t flags,
|
||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||
return arena->make<GrDistanceFieldA8TextGeoProc>(
|
||||
caps, proxies, numActiveProxies, params, flags, localMatrixIfUsesLocalCoords);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -97,6 +100,8 @@ public:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrDistanceFieldA8TextGeoProc(const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
@ -135,15 +140,15 @@ public:
|
||||
static constexpr int kMaxTextures = 4;
|
||||
|
||||
/** The local matrix should be identity if local coords are not required by the GrPipeline. */
|
||||
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps,
|
||||
const SkMatrix& matrix,
|
||||
bool wideColor,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& params, uint32_t flags) {
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new GrDistanceFieldPathGeoProc(caps, matrix, wideColor, proxies, numActiveProxies,
|
||||
params, flags));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const GrShaderCaps& caps,
|
||||
const SkMatrix& matrix,
|
||||
bool wideColor,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& params, uint32_t flags) {
|
||||
return arena->make<GrDistanceFieldPathGeoProc>(caps, matrix, wideColor, proxies,
|
||||
numActiveProxies, params, flags);
|
||||
}
|
||||
|
||||
~GrDistanceFieldPathGeoProc() override {}
|
||||
@ -164,6 +169,8 @@ public:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrDistanceFieldPathGeoProc(const GrShaderCaps& caps,
|
||||
const SkMatrix& matrix,
|
||||
bool wideColor,
|
||||
@ -211,16 +218,17 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static sk_sp<GrGeometryProcessor> Make(const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& params,
|
||||
DistanceAdjust distanceAdjust,
|
||||
uint32_t flags,
|
||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new GrDistanceFieldLCDTextGeoProc(caps, proxies, numActiveProxies, params,
|
||||
distanceAdjust, flags, localMatrixIfUsesLocalCoords));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies,
|
||||
const GrSamplerState& params,
|
||||
DistanceAdjust distanceAdjust,
|
||||
uint32_t flags,
|
||||
const SkMatrix& localMatrixIfUsesLocalCoords) {
|
||||
return arena->make<GrDistanceFieldLCDTextGeoProc>(caps, proxies, numActiveProxies, params,
|
||||
distanceAdjust, flags,
|
||||
localMatrixIfUsesLocalCoords);
|
||||
}
|
||||
|
||||
~GrDistanceFieldLCDTextGeoProc() override {}
|
||||
@ -242,6 +250,8 @@ public:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrDistanceFieldLCDTextGeoProc(const GrShaderCaps& caps, const sk_sp<GrTextureProxy>* proxies,
|
||||
int numActiveProxies, const GrSamplerState& params,
|
||||
DistanceAdjust wa, uint32_t flags, const SkMatrix& localMatrix);
|
||||
|
@ -83,7 +83,8 @@ GrGLSLPrimitiveProcessor* GrRRectShadowGeoProc::createGLSLInstance(const GrShade
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrRRectShadowGeoProc);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> GrRRectShadowGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
return GrRRectShadowGeoProc::Make(d->textureProxy(GrProcessorUnitTest::kAlphaTextureIdx).get());
|
||||
GrGeometryProcessor* GrRRectShadowGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
return GrRRectShadowGeoProc::Make(d->allocator(),
|
||||
d->textureProxy(GrProcessorUnitTest::kAlphaTextureIdx).get());
|
||||
}
|
||||
#endif
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef GrShadowGeoProc_DEFINED
|
||||
#define GrShadowGeoProc_DEFINED
|
||||
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrProcessor.h"
|
||||
|
||||
@ -19,8 +20,8 @@ class GrGLRRectShadowGeoProc;
|
||||
*/
|
||||
class GrRRectShadowGeoProc : public GrGeometryProcessor {
|
||||
public:
|
||||
static sk_sp<GrGeometryProcessor> Make(const GrTextureProxy* lut) {
|
||||
return sk_sp<GrGeometryProcessor>(new GrRRectShadowGeoProc(lut));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, const GrTextureProxy* lut) {
|
||||
return arena->make<GrRRectShadowGeoProc>(lut);
|
||||
}
|
||||
|
||||
const char* name() const override { return "RRectShadow"; }
|
||||
@ -35,6 +36,8 @@ public:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrRRectShadowGeoProc(const GrTextureProxy* lut);
|
||||
|
||||
const TextureSampler& onTextureSampler(int i) const override { return fLUTTextureSampler; }
|
||||
|
@ -537,10 +537,11 @@ static void create_vertices(const SegmentArray& segments,
|
||||
|
||||
class QuadEdgeEffect : public GrGeometryProcessor {
|
||||
public:
|
||||
static sk_sp<GrGeometryProcessor> Make(const SkMatrix& localMatrix, bool usesLocalCoords,
|
||||
bool wideColor) {
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new QuadEdgeEffect(localMatrix, usesLocalCoords, wideColor));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool wideColor) {
|
||||
return arena->make<QuadEdgeEffect>(localMatrix, usesLocalCoords, wideColor);
|
||||
}
|
||||
|
||||
~QuadEdgeEffect() override {}
|
||||
@ -628,6 +629,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
QuadEdgeEffect(const SkMatrix& localMatrix, bool usesLocalCoords, bool wideColor)
|
||||
: INHERITED(kQuadEdgeEffect_ClassID)
|
||||
, fLocalMatrix(localMatrix)
|
||||
@ -653,11 +656,11 @@ private:
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
|
||||
// Doesn't work without derivative instructions.
|
||||
return d->caps()->shaderCaps()->shaderDerivativeSupport()
|
||||
? QuadEdgeEffect::Make(GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool(),
|
||||
d->fRandom->nextBool())
|
||||
? QuadEdgeEffect::Make(d->allocator(), GrTest::TestMatrix(d->fRandom),
|
||||
d->fRandom->nextBool(), d->fRandom->nextBool())
|
||||
: nullptr;
|
||||
}
|
||||
#endif
|
||||
@ -740,8 +743,9 @@ private:
|
||||
}
|
||||
|
||||
// Setup GrGeometryProcessor
|
||||
sk_sp<GrGeometryProcessor> quadProcessor(
|
||||
QuadEdgeEffect::Make(invert, fHelper.usesLocalCoords(), fWideColor));
|
||||
GrGeometryProcessor* quadProcessor = QuadEdgeEffect::Make(target->allocator(), invert,
|
||||
fHelper.usesLocalCoords(),
|
||||
fWideColor);
|
||||
const size_t kVertexStride = quadProcessor->vertexStride();
|
||||
|
||||
// TODO generate all segments for all paths and use one vertex buffer
|
||||
|
@ -962,7 +962,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
|
||||
|
||||
// do lines first
|
||||
if (lineCount) {
|
||||
sk_sp<GrGeometryProcessor> lineGP;
|
||||
GrGeometryProcessor* lineGP;
|
||||
{
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
|
||||
@ -970,7 +970,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
|
||||
LocalCoords localCoords(fHelper.usesLocalCoords() ? LocalCoords::kUsePosition_Type
|
||||
: LocalCoords::kUnused_Type);
|
||||
localCoords.fMatrix = geometryProcessorLocalM;
|
||||
lineGP = GrDefaultGeoProcFactory::Make(target->caps().shaderCaps(),
|
||||
lineGP = GrDefaultGeoProcFactory::Make(target->allocator(), target->caps().shaderCaps(),
|
||||
color, Coverage::kAttribute_Type, localCoords,
|
||||
*geometryProcessorViewM);
|
||||
}
|
||||
@ -993,25 +993,25 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
|
||||
add_line(&lines[2*i], toSrc, this->coverage(), &verts);
|
||||
}
|
||||
|
||||
helper.recordDraw(target, std::move(lineGP));
|
||||
helper.recordDraw(target, lineGP);
|
||||
}
|
||||
|
||||
if (quadCount || conicCount) {
|
||||
sk_sp<GrGeometryProcessor> quadGP(GrQuadEffect::Make(this->color(),
|
||||
*geometryProcessorViewM,
|
||||
GrClipEdgeType::kHairlineAA,
|
||||
target->caps(),
|
||||
*geometryProcessorLocalM,
|
||||
fHelper.usesLocalCoords(),
|
||||
this->coverage()));
|
||||
GrGeometryProcessor* quadGP = GrQuadEffect::Make(target->allocator(), this->color(),
|
||||
*geometryProcessorViewM,
|
||||
GrClipEdgeType::kHairlineAA,
|
||||
target->caps(),
|
||||
*geometryProcessorLocalM,
|
||||
fHelper.usesLocalCoords(),
|
||||
this->coverage());
|
||||
|
||||
sk_sp<GrGeometryProcessor> conicGP(GrConicEffect::Make(this->color(),
|
||||
*geometryProcessorViewM,
|
||||
GrClipEdgeType::kHairlineAA,
|
||||
target->caps(),
|
||||
*geometryProcessorLocalM,
|
||||
fHelper.usesLocalCoords(),
|
||||
this->coverage()));
|
||||
GrGeometryProcessor* conicGP = GrConicEffect::Make(target->allocator(), this->color(),
|
||||
*geometryProcessorViewM,
|
||||
GrClipEdgeType::kHairlineAA,
|
||||
target->caps(),
|
||||
*geometryProcessorLocalM,
|
||||
fHelper.usesLocalCoords(),
|
||||
this->coverage());
|
||||
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex;
|
||||
@ -1048,7 +1048,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
|
||||
mesh->setIndexedPatterned(quadsIndexBuffer, kIdxsPerQuad, kQuadNumVertices, quadCount,
|
||||
kQuadsNumInIdxBuffer);
|
||||
mesh->setVertexData(vertexBuffer, firstVertex);
|
||||
target->recordDraw(std::move(quadGP), mesh, 1, GrPrimitiveType::kTriangles);
|
||||
target->recordDraw(quadGP, mesh, 1, GrPrimitiveType::kTriangles);
|
||||
firstVertex += quadCount * kQuadNumVertices;
|
||||
}
|
||||
|
||||
@ -1057,7 +1057,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
|
||||
mesh->setIndexedPatterned(std::move(quadsIndexBuffer), kIdxsPerQuad, kQuadNumVertices,
|
||||
conicCount, kQuadsNumInIdxBuffer);
|
||||
mesh->setVertexData(std::move(vertexBuffer), firstVertex);
|
||||
target->recordDraw(std::move(conicGP), mesh, 1, GrPrimitiveType::kTriangles);
|
||||
target->recordDraw(conicGP, mesh, 1, GrPrimitiveType::kTriangles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,11 +96,12 @@ static void extract_verts(const GrAAConvexTessellator& tess,
|
||||
}
|
||||
}
|
||||
|
||||
static sk_sp<GrGeometryProcessor> create_lines_only_gp(const GrShaderCaps* shaderCaps,
|
||||
bool tweakAlphaForCoverage,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool wideColor) {
|
||||
static GrGeometryProcessor* create_lines_only_gp(SkArenaAlloc* arena,
|
||||
const GrShaderCaps* shaderCaps,
|
||||
bool tweakAlphaForCoverage,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool wideColor) {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
|
||||
Coverage::Type coverageType =
|
||||
@ -110,7 +111,8 @@ static sk_sp<GrGeometryProcessor> create_lines_only_gp(const GrShaderCaps* shade
|
||||
Color::Type colorType =
|
||||
wideColor ? Color::kPremulWideColorAttribute_Type : Color::kPremulGrColorAttribute_Type;
|
||||
|
||||
return MakeForDeviceSpace(shaderCaps, colorType, coverageType, localCoordsType, viewMatrix);
|
||||
return MakeForDeviceSpace(arena, shaderCaps, colorType, coverageType,
|
||||
localCoordsType, viewMatrix);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -198,7 +200,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void recordDraw(Target* target, sk_sp<const GrGeometryProcessor> gp, int vertexCount,
|
||||
void recordDraw(Target* target, const GrGeometryProcessor* gp, int vertexCount,
|
||||
size_t vertexStride, void* vertices, int indexCount, uint16_t* indices) const {
|
||||
if (vertexCount == 0 || indexCount == 0) {
|
||||
return;
|
||||
@ -225,16 +227,17 @@ private:
|
||||
mesh->setIndexed(std::move(indexBuffer), indexCount, firstIndex, 0, vertexCount - 1,
|
||||
GrPrimitiveRestart::kNo);
|
||||
mesh->setVertexData(std::move(vertexBuffer), firstVertex);
|
||||
target->recordDraw(std::move(gp), mesh, 1, GrPrimitiveType::kTriangles);
|
||||
target->recordDraw(gp, mesh, 1, GrPrimitiveType::kTriangles);
|
||||
}
|
||||
|
||||
void onPrepareDraws(Target* target) override {
|
||||
// Setup GrGeometryProcessor
|
||||
sk_sp<GrGeometryProcessor> gp(create_lines_only_gp(target->caps().shaderCaps(),
|
||||
fHelper.compatibleWithCoverageAsAlpha(),
|
||||
this->viewMatrix(),
|
||||
fHelper.usesLocalCoords(),
|
||||
fWideColor));
|
||||
GrGeometryProcessor* gp = create_lines_only_gp(target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
fHelper.compatibleWithCoverageAsAlpha(),
|
||||
this->viewMatrix(),
|
||||
fHelper.usesLocalCoords(),
|
||||
fWideColor);
|
||||
if (!gp) {
|
||||
SkDebugf("Couldn't create a GrGeometryProcessor\n");
|
||||
return;
|
||||
@ -294,8 +297,7 @@ private:
|
||||
indexCount += currentIndices;
|
||||
}
|
||||
if (vertexCount <= SK_MaxS32 && indexCount <= SK_MaxS32) {
|
||||
this->recordDraw(target, std::move(gp), vertexCount, vertexStride, vertices, indexCount,
|
||||
indices);
|
||||
this->recordDraw(target, gp, vertexCount, vertexStride, vertices, indexCount, indices);
|
||||
}
|
||||
sk_free(vertices);
|
||||
sk_free(indices);
|
||||
|
@ -315,12 +315,13 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
|
||||
|
||||
bool vmPerspective = fGeoData[0].fViewMatrix.hasPerspective();
|
||||
if (this->usesDistanceFields()) {
|
||||
flushInfo.fGeometryProcessor = this->setupDfProcessor(*target->caps().shaderCaps(),
|
||||
flushInfo.fGeometryProcessor = this->setupDfProcessor(target->allocator(),
|
||||
*target->caps().shaderCaps(),
|
||||
proxies, numActiveProxies);
|
||||
} else {
|
||||
GrSamplerState samplerState = fNeedsGlyphTransform ? GrSamplerState::ClampBilerp()
|
||||
: GrSamplerState::ClampNearest();
|
||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
|
||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(target->allocator(),
|
||||
*target->caps().shaderCaps(), this->color(), false, proxies, numActiveProxies,
|
||||
samplerState, maskFormat, localMatrix, vmPerspective);
|
||||
}
|
||||
@ -404,7 +405,7 @@ void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) co
|
||||
|
||||
auto atlasManager = target->atlasManager();
|
||||
|
||||
GrGeometryProcessor* gp = flushInfo->fGeometryProcessor.get();
|
||||
GrGeometryProcessor* gp = flushInfo->fGeometryProcessor;
|
||||
GrMaskFormat maskFormat = this->maskFormat();
|
||||
|
||||
unsigned int numActiveProxies;
|
||||
@ -524,9 +525,10 @@ GrOp::CombineResult GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& ca
|
||||
|
||||
// TODO trying to figure out why lcd is so whack
|
||||
// (see comments in GrTextContext::ComputeCanonicalColor)
|
||||
sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
unsigned int numActiveProxies) const {
|
||||
GrGeometryProcessor* GrAtlasTextOp::setupDfProcessor(SkArenaAlloc* arena,
|
||||
const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
unsigned int numActiveProxies) const {
|
||||
bool isLCD = this->isLCD();
|
||||
|
||||
SkMatrix localMatrix = SkMatrix::I();
|
||||
@ -550,7 +552,7 @@ sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const GrShaderCaps& c
|
||||
GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
|
||||
GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(
|
||||
redCorrection, greenCorrection, blueCorrection);
|
||||
return GrDistanceFieldLCDTextGeoProc::Make(caps, proxies, numActiveProxies,
|
||||
return GrDistanceFieldLCDTextGeoProc::Make(arena, caps, proxies, numActiveProxies,
|
||||
GrSamplerState::ClampBilerp(), widthAdjust,
|
||||
fDFGPFlags, localMatrix);
|
||||
} else {
|
||||
@ -562,11 +564,11 @@ sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const GrShaderCaps& c
|
||||
correction = fDistanceAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift,
|
||||
fUseGammaCorrectDistanceTable);
|
||||
}
|
||||
return GrDistanceFieldA8TextGeoProc::Make(caps, proxies, numActiveProxies,
|
||||
return GrDistanceFieldA8TextGeoProc::Make(arena, caps, proxies, numActiveProxies,
|
||||
GrSamplerState::ClampBilerp(),
|
||||
correction, fDFGPFlags, localMatrix);
|
||||
#else
|
||||
return GrDistanceFieldA8TextGeoProc::Make(caps, proxies, numActiveProxies,
|
||||
return GrDistanceFieldA8TextGeoProc::Make(arena, caps, proxies, numActiveProxies,
|
||||
GrSamplerState::ClampBilerp(),
|
||||
fDFGPFlags, localMatrix);
|
||||
#endif
|
||||
|
@ -106,7 +106,7 @@ private:
|
||||
struct FlushInfo {
|
||||
sk_sp<const GrBuffer> fVertexBuffer;
|
||||
sk_sp<const GrBuffer> fIndexBuffer;
|
||||
sk_sp<GrGeometryProcessor> fGeometryProcessor;
|
||||
GrGeometryProcessor* fGeometryProcessor;
|
||||
GrPipeline::FixedDynamicState* fFixedDynamicState;
|
||||
int fGlyphsToFlush;
|
||||
int fVertexOffset;
|
||||
@ -152,9 +152,10 @@ private:
|
||||
|
||||
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override;
|
||||
|
||||
sk_sp<GrGeometryProcessor> setupDfProcessor(const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
unsigned int numActiveProxies) const;
|
||||
GrGeometryProcessor* setupDfProcessor(SkArenaAlloc* arena,
|
||||
const GrShaderCaps& caps,
|
||||
const sk_sp<GrTextureProxy>* proxies,
|
||||
unsigned int numActiveProxies) const;
|
||||
|
||||
SkAutoSTMalloc<kMinGeometryAllocated, Geometry> fGeoData;
|
||||
int fGeoDataAllocSize;
|
||||
|
@ -188,11 +188,12 @@ static void setup_dashed_rect(const SkRect& rect, GrVertexWriter& vertices, cons
|
||||
* Bounding geometry is rendered and the effect computes coverage based on the fragment's
|
||||
* position relative to the dashed line.
|
||||
*/
|
||||
static sk_sp<GrGeometryProcessor> make_dash_gp(const SkPMColor4f&,
|
||||
AAMode aaMode,
|
||||
DashCap cap,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
static GrGeometryProcessor* make_dash_gp(SkArenaAlloc* arena,
|
||||
const SkPMColor4f&,
|
||||
AAMode aaMode,
|
||||
DashCap cap,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
class DashOp final : public GrMeshDrawOp {
|
||||
public:
|
||||
@ -330,17 +331,18 @@ private:
|
||||
bool isRoundCap = SkPaint::kRound_Cap == cap;
|
||||
DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
|
||||
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrGeometryProcessor* gp;
|
||||
if (this->fullDash()) {
|
||||
gp = make_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(),
|
||||
fUsesLocalCoords);
|
||||
gp = make_dash_gp(target->allocator(), this->color(), this->aaMode(), capType,
|
||||
this->viewMatrix(), fUsesLocalCoords);
|
||||
} else {
|
||||
// Set up the vertex data for the line and start/end dashes
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
Color color(this->color());
|
||||
LocalCoords::Type localCoordsType =
|
||||
fUsesLocalCoords ? LocalCoords::kUsePosition_Type : LocalCoords::kUnused_Type;
|
||||
gp = MakeForDeviceSpace(target->caps().shaderCaps(),
|
||||
gp = MakeForDeviceSpace(target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
color,
|
||||
Coverage::kSolid_Type,
|
||||
localCoordsType,
|
||||
@ -622,7 +624,7 @@ private:
|
||||
}
|
||||
rectIndex++;
|
||||
}
|
||||
helper.recordDraw(target, std::move(gp));
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
@ -764,10 +766,11 @@ class DashingCircleEffect : public GrGeometryProcessor {
|
||||
public:
|
||||
typedef SkPathEffect::DashInfo DashInfo;
|
||||
|
||||
static sk_sp<GrGeometryProcessor> Make(const SkPMColor4f&,
|
||||
AAMode aaMode,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const SkPMColor4f&,
|
||||
AAMode aaMode,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
const char* name() const override { return "DashingCircleEffect"; }
|
||||
|
||||
@ -784,21 +787,23 @@ public:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
friend class GLDashingCircleEffect;
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
DashingCircleEffect(const SkPMColor4f&, AAMode aaMode, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
SkPMColor4f fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
AAMode fAAMode;
|
||||
SkPMColor4f fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
AAMode fAAMode;
|
||||
|
||||
Attribute fInPosition;
|
||||
Attribute fInDashParams;
|
||||
Attribute fInCircleParams;
|
||||
Attribute fInPosition;
|
||||
Attribute fInDashParams;
|
||||
Attribute fInCircleParams;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
|
||||
|
||||
friend class GLDashingCircleEffect;
|
||||
typedef GrGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
@ -909,12 +914,12 @@ void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sk_sp<GrGeometryProcessor> DashingCircleEffect::Make(const SkPMColor4f& color,
|
||||
AAMode aaMode,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords));
|
||||
GrGeometryProcessor* DashingCircleEffect::Make(SkArenaAlloc* arena,
|
||||
const SkPMColor4f& color,
|
||||
AAMode aaMode,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return arena->make<DashingCircleEffect>(color, aaMode, localMatrix, usesLocalCoords);
|
||||
}
|
||||
|
||||
void DashingCircleEffect::getGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
@ -930,11 +935,11 @@ DashingCircleEffect::DashingCircleEffect(const SkPMColor4f& color,
|
||||
AAMode aaMode,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords)
|
||||
: INHERITED(kDashingCircleEffect_ClassID)
|
||||
, fColor(color)
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fAAMode(aaMode) {
|
||||
: INHERITED(kDashingCircleEffect_ClassID)
|
||||
, fColor(color)
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fUsesLocalCoords(usesLocalCoords)
|
||||
, fAAMode(aaMode) {
|
||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||
fInDashParams = {"inDashParams", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
|
||||
fInCircleParams = {"inCircleParams", kFloat2_GrVertexAttribType, kHalf2_GrSLType};
|
||||
@ -944,9 +949,10 @@ DashingCircleEffect::DashingCircleEffect(const SkPMColor4f& color,
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
|
||||
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashOp::kAAModeCnt));
|
||||
return DashingCircleEffect::Make(SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
return DashingCircleEffect::Make(d->allocator(),
|
||||
SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
aaMode, GrTest::TestMatrix(d->fRandom),
|
||||
d->fRandom->nextBool());
|
||||
}
|
||||
@ -969,10 +975,11 @@ class DashingLineEffect : public GrGeometryProcessor {
|
||||
public:
|
||||
typedef SkPathEffect::DashInfo DashInfo;
|
||||
|
||||
static sk_sp<GrGeometryProcessor> Make(const SkPMColor4f&,
|
||||
AAMode aaMode,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const SkPMColor4f&,
|
||||
AAMode aaMode,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
const char* name() const override { return "DashingEffect"; }
|
||||
|
||||
@ -980,7 +987,7 @@ public:
|
||||
|
||||
const SkPMColor4f& color() const { return fColor; }
|
||||
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
const SkMatrix& localMatrix() const { return fLocalMatrix; }
|
||||
|
||||
bool usesLocalCoords() const { return fUsesLocalCoords; }
|
||||
|
||||
@ -989,22 +996,23 @@ public:
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
friend class GLDashingLineEffect;
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
DashingLineEffect(const SkPMColor4f&, AAMode aaMode, const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords);
|
||||
|
||||
SkPMColor4f fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
AAMode fAAMode;
|
||||
SkPMColor4f fColor;
|
||||
SkMatrix fLocalMatrix;
|
||||
bool fUsesLocalCoords;
|
||||
AAMode fAAMode;
|
||||
|
||||
Attribute fInPosition;
|
||||
Attribute fInDashParams;
|
||||
Attribute fInRect;
|
||||
Attribute fInPosition;
|
||||
Attribute fInDashParams;
|
||||
Attribute fInRect;
|
||||
|
||||
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
|
||||
|
||||
friend class GLDashingLineEffect;
|
||||
|
||||
typedef GrGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
@ -1133,12 +1141,12 @@ void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sk_sp<GrGeometryProcessor> DashingLineEffect::Make(const SkPMColor4f& color,
|
||||
AAMode aaMode,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords));
|
||||
GrGeometryProcessor* DashingLineEffect::Make(SkArenaAlloc* arena,
|
||||
const SkPMColor4f& color,
|
||||
AAMode aaMode,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
return arena->make<DashingLineEffect>(color, aaMode, localMatrix, usesLocalCoords);
|
||||
}
|
||||
|
||||
void DashingLineEffect::getGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
@ -1168,9 +1176,10 @@ DashingLineEffect::DashingLineEffect(const SkPMColor4f& color,
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> DashingLineEffect::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
|
||||
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashOp::kAAModeCnt));
|
||||
return DashingLineEffect::Make(SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
return DashingLineEffect::Make(d->allocator(),
|
||||
SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
|
||||
aaMode, GrTest::TestMatrix(d->fRandom),
|
||||
d->fRandom->nextBool());
|
||||
}
|
||||
@ -1178,11 +1187,12 @@ sk_sp<GrGeometryProcessor> DashingLineEffect::TestCreate(GrProcessorTestData* d)
|
||||
#endif
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static sk_sp<GrGeometryProcessor> make_dash_gp(const SkPMColor4f& color,
|
||||
AAMode aaMode,
|
||||
DashCap cap,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool usesLocalCoords) {
|
||||
static GrGeometryProcessor* make_dash_gp(SkArenaAlloc* arena,
|
||||
const SkPMColor4f& color,
|
||||
AAMode aaMode,
|
||||
DashCap cap,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool usesLocalCoords) {
|
||||
SkMatrix invert;
|
||||
if (usesLocalCoords && !viewMatrix.invert(&invert)) {
|
||||
SkDebugf("Failed to invert\n");
|
||||
@ -1191,9 +1201,9 @@ static sk_sp<GrGeometryProcessor> make_dash_gp(const SkPMColor4f& color,
|
||||
|
||||
switch (cap) {
|
||||
case kRound_DashCap:
|
||||
return DashingCircleEffect::Make(color, aaMode, invert, usesLocalCoords);
|
||||
return DashingCircleEffect::Make(arena, color, aaMode, invert, usesLocalCoords);
|
||||
case kNonRound_DashCap:
|
||||
return DashingLineEffect::Make(color, aaMode, invert, usesLocalCoords);
|
||||
return DashingLineEffect::Make(arena, color, aaMode, invert, usesLocalCoords);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -67,11 +67,11 @@ namespace {
|
||||
class PathGeoBuilder {
|
||||
public:
|
||||
PathGeoBuilder(GrPrimitiveType primitiveType, GrMeshDrawOp::Target* target,
|
||||
sk_sp<const GrGeometryProcessor> geometryProcessor)
|
||||
const GrGeometryProcessor* geometryProcessor)
|
||||
: fPrimitiveType(primitiveType)
|
||||
, fTarget(target)
|
||||
, fVertexStride(sizeof(SkPoint))
|
||||
, fGeometryProcessor(std::move(geometryProcessor))
|
||||
, fGeometryProcessor(geometryProcessor)
|
||||
, fFirstIndex(0)
|
||||
, fIndicesInChunk(0)
|
||||
, fIndices(nullptr) {
|
||||
@ -313,7 +313,7 @@ private:
|
||||
GrPrimitiveType fPrimitiveType;
|
||||
GrMeshDrawOp::Target* fTarget;
|
||||
size_t fVertexStride;
|
||||
sk_sp<const GrGeometryProcessor> fGeometryProcessor;
|
||||
const GrGeometryProcessor* fGeometryProcessor;
|
||||
|
||||
sk_sp<const GrBuffer> fVertexBuffer;
|
||||
int fFirstVertex;
|
||||
@ -402,14 +402,15 @@ public:
|
||||
|
||||
private:
|
||||
void onPrepareDraws(Target* target) override {
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrGeometryProcessor* gp;
|
||||
{
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
Color color(this->color());
|
||||
Coverage coverage(this->coverage());
|
||||
LocalCoords localCoords(fHelper.usesLocalCoords() ? LocalCoords::kUsePosition_Type
|
||||
: LocalCoords::kUnused_Type);
|
||||
gp = GrDefaultGeoProcFactory::Make(target->caps().shaderCaps(),
|
||||
gp = GrDefaultGeoProcFactory::Make(target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
color,
|
||||
coverage,
|
||||
localCoords,
|
||||
@ -431,7 +432,7 @@ private:
|
||||
} else {
|
||||
primitiveType = GrPrimitiveType::kTriangles;
|
||||
}
|
||||
PathGeoBuilder pathGeoBuilder(primitiveType, target, std::move(gp));
|
||||
PathGeoBuilder pathGeoBuilder(primitiveType, target, gp);
|
||||
|
||||
// fill buffers
|
||||
for (int i = 0; i < instanceCount; i++) {
|
||||
|
@ -73,17 +73,18 @@ private:
|
||||
typedef GrMeshDrawOp INHERITED;
|
||||
};
|
||||
|
||||
static sk_sp<GrGeometryProcessor> make_gp(const GrShaderCaps* shaderCaps,
|
||||
bool hasColors,
|
||||
const SkPMColor4f& color,
|
||||
const SkMatrix& viewMatrix) {
|
||||
static GrGeometryProcessor* make_gp(SkArenaAlloc* arena,
|
||||
const GrShaderCaps* shaderCaps,
|
||||
bool hasColors,
|
||||
const SkPMColor4f& color,
|
||||
const SkMatrix& viewMatrix) {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
Color gpColor(color);
|
||||
if (hasColors) {
|
||||
gpColor.fType = Color::kPremulGrColorAttribute_Type;
|
||||
}
|
||||
|
||||
return GrDefaultGeoProcFactory::Make(shaderCaps, gpColor, Coverage::kSolid_Type,
|
||||
return GrDefaultGeoProcFactory::Make(arena, shaderCaps, gpColor, Coverage::kSolid_Type,
|
||||
LocalCoords::kHasExplicit_Type, viewMatrix);
|
||||
}
|
||||
|
||||
@ -184,10 +185,11 @@ SkString DrawAtlasOp::dumpInfo() const {
|
||||
|
||||
void DrawAtlasOp::onPrepareDraws(Target* target) {
|
||||
// Setup geometry processor
|
||||
sk_sp<GrGeometryProcessor> gp(make_gp(target->caps().shaderCaps(),
|
||||
this->hasColors(),
|
||||
this->color(),
|
||||
this->viewMatrix()));
|
||||
GrGeometryProcessor* gp = make_gp(target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
this->hasColors(),
|
||||
this->color(),
|
||||
this->viewMatrix());
|
||||
|
||||
int instanceCount = fGeoData.count();
|
||||
size_t vertexStride = gp->vertexStride();
|
||||
@ -208,7 +210,7 @@ void DrawAtlasOp::onPrepareDraws(Target* target) {
|
||||
memcpy(vertPtr, args.fVerts.begin(), allocSize);
|
||||
vertPtr += allocSize;
|
||||
}
|
||||
helper.recordDraw(target, std::move(gp));
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
void DrawAtlasOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
|
||||
|
@ -60,15 +60,16 @@ private:
|
||||
uint16_t* indices) const;
|
||||
|
||||
void drawVertices(Target*,
|
||||
sk_sp<const GrGeometryProcessor>,
|
||||
const GrGeometryProcessor*,
|
||||
sk_sp<const GrBuffer> vertexBuffer,
|
||||
int firstVertex,
|
||||
sk_sp<const GrBuffer> indexBuffer,
|
||||
int firstIndex);
|
||||
|
||||
sk_sp<GrGeometryProcessor> makeGP(const GrShaderCaps* shaderCaps,
|
||||
bool* hasColorAttribute,
|
||||
bool* hasLocalCoordAttribute) const;
|
||||
GrGeometryProcessor* makeGP(SkArenaAlloc* arena,
|
||||
const GrShaderCaps* shaderCaps,
|
||||
bool* hasColorAttribute,
|
||||
bool* hasLocalCoordAttribute) const;
|
||||
|
||||
GrPrimitiveType primitiveType() const { return fPrimitiveType; }
|
||||
bool combinablePrimitive() const {
|
||||
@ -229,9 +230,10 @@ GrProcessorSet::Analysis DrawVerticesOp::finalize(
|
||||
return result;
|
||||
}
|
||||
|
||||
sk_sp<GrGeometryProcessor> DrawVerticesOp::makeGP(const GrShaderCaps* shaderCaps,
|
||||
bool* hasColorAttribute,
|
||||
bool* hasLocalCoordAttribute) const {
|
||||
GrGeometryProcessor* DrawVerticesOp::makeGP(SkArenaAlloc* arena,
|
||||
const GrShaderCaps* shaderCaps,
|
||||
bool* hasColorAttribute,
|
||||
bool* hasLocalCoordAttribute) const {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
LocalCoords::Type localCoordsType;
|
||||
if (fHelper.usesLocalCoords()) {
|
||||
@ -264,11 +266,12 @@ sk_sp<GrGeometryProcessor> DrawVerticesOp::makeGP(const GrShaderCaps* shaderCaps
|
||||
|
||||
const SkMatrix& vm = this->hasMultipleViewMatrices() ? SkMatrix::I() : fMeshes[0].fViewMatrix;
|
||||
|
||||
return GrDefaultGeoProcFactory::Make(shaderCaps,
|
||||
color,
|
||||
Coverage::kSolid_Type,
|
||||
localCoordsType,
|
||||
vm);
|
||||
return GrDefaultGeoProcFactory::Make(arena,
|
||||
shaderCaps,
|
||||
color,
|
||||
Coverage::kSolid_Type,
|
||||
localCoordsType,
|
||||
vm);
|
||||
}
|
||||
|
||||
void DrawVerticesOp::onPrepareDraws(Target* target) {
|
||||
@ -283,9 +286,10 @@ void DrawVerticesOp::onPrepareDraws(Target* target) {
|
||||
void DrawVerticesOp::drawVolatile(Target* target) {
|
||||
bool hasColorAttribute;
|
||||
bool hasLocalCoordsAttribute;
|
||||
sk_sp<GrGeometryProcessor> gp = this->makeGP(target->caps().shaderCaps(),
|
||||
&hasColorAttribute,
|
||||
&hasLocalCoordsAttribute);
|
||||
GrGeometryProcessor* gp = this->makeGP(target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
&hasColorAttribute,
|
||||
&hasLocalCoordsAttribute);
|
||||
|
||||
// Allocate buffers.
|
||||
size_t vertexStride = gp->vertexStride();
|
||||
@ -316,8 +320,7 @@ void DrawVerticesOp::drawVolatile(Target* target) {
|
||||
indices);
|
||||
|
||||
// Draw the vertices.
|
||||
this->drawVertices(target, std::move(gp), std::move(vertexBuffer), firstVertex, indexBuffer,
|
||||
firstIndex);
|
||||
this->drawVertices(target, gp, std::move(vertexBuffer), firstVertex, indexBuffer, firstIndex);
|
||||
}
|
||||
|
||||
void DrawVerticesOp::drawNonVolatile(Target* target) {
|
||||
@ -325,9 +328,10 @@ void DrawVerticesOp::drawNonVolatile(Target* target) {
|
||||
|
||||
bool hasColorAttribute;
|
||||
bool hasLocalCoordsAttribute;
|
||||
sk_sp<GrGeometryProcessor> gp = this->makeGP(target->caps().shaderCaps(),
|
||||
&hasColorAttribute,
|
||||
&hasLocalCoordsAttribute);
|
||||
GrGeometryProcessor* gp = this->makeGP(target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
&hasColorAttribute,
|
||||
&hasLocalCoordsAttribute);
|
||||
|
||||
SkASSERT(fMeshes.count() == 1); // Non-volatile meshes should never combine.
|
||||
|
||||
@ -351,8 +355,7 @@ void DrawVerticesOp::drawNonVolatile(Target* target) {
|
||||
|
||||
// Draw using the cached buffers if possible.
|
||||
if (vertexBuffer && (!this->isIndexed() || indexBuffer)) {
|
||||
this->drawVertices(target, std::move(gp), std::move(vertexBuffer), 0,
|
||||
std::move(indexBuffer), 0);
|
||||
this->drawVertices(target, gp, std::move(vertexBuffer), 0, std::move(indexBuffer), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -396,8 +399,7 @@ void DrawVerticesOp::drawNonVolatile(Target* target) {
|
||||
rp->assignUniqueKeyToResource(indexKey, indexBuffer.get());
|
||||
|
||||
// Draw the vertices.
|
||||
this->drawVertices(target, std::move(gp), std::move(vertexBuffer), 0, std::move(indexBuffer),
|
||||
0);
|
||||
this->drawVertices(target, gp, std::move(vertexBuffer), 0, std::move(indexBuffer), 0);
|
||||
}
|
||||
|
||||
void DrawVerticesOp::fillBuffers(bool hasColorAttribute,
|
||||
@ -493,7 +495,7 @@ void DrawVerticesOp::fillBuffers(bool hasColorAttribute,
|
||||
}
|
||||
|
||||
void DrawVerticesOp::drawVertices(Target* target,
|
||||
sk_sp<const GrGeometryProcessor> gp,
|
||||
const GrGeometryProcessor* gp,
|
||||
sk_sp<const GrBuffer> vertexBuffer,
|
||||
int firstVertex,
|
||||
sk_sp<const GrBuffer> indexBuffer,
|
||||
@ -506,7 +508,7 @@ void DrawVerticesOp::drawVertices(Target* target,
|
||||
mesh->setNonIndexedNonInstanced(fVertexCount);
|
||||
}
|
||||
mesh->setVertexData(std::move(vertexBuffer), firstVertex);
|
||||
target->recordDraw(std::move(gp), mesh, 1, this->primitiveType());
|
||||
target->recordDraw(gp, mesh, 1, this->primitiveType());
|
||||
}
|
||||
|
||||
void DrawVerticesOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
|
||||
|
@ -175,8 +175,23 @@ GrDrawOp::CombineResult GrFillRRectOp::onCombineIfPossible(GrOp* op, const GrCap
|
||||
|
||||
class GrFillRRectOp::Processor : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, GrAAType aaType, Flags flags) {
|
||||
return arena->make<Processor>(aaType, flags);
|
||||
}
|
||||
|
||||
const char* name() const override { return "GrFillRRectOp::Processor"; }
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||
b->add32(((uint32_t)fFlags << 16) | (uint32_t)fAAType);
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
Processor(GrAAType aaType, Flags flags)
|
||||
: GrGeometryProcessor(kGrFillRRectOp_Processor_ClassID)
|
||||
: INHERITED(kGrFillRRectOp_Processor_ClassID)
|
||||
, fAAType(aaType)
|
||||
, fFlags(flags) {
|
||||
int numVertexAttribs = (GrAAType::kCoverage == fAAType) ? 3 : 2;
|
||||
@ -208,15 +223,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
const char* name() const override { return "GrFillRRectOp::Processor"; }
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||
b->add32(((uint32_t)fFlags << 16) | (uint32_t)fAAType);
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
private:
|
||||
static constexpr Attribute kVertexAttribs[] = {
|
||||
{"radii_selector", kFloat4_GrVertexAttribType, kFloat4_GrSLType},
|
||||
{"corner_and_radius_outsets", kFloat4_GrVertexAttribType, kFloat4_GrSLType},
|
||||
@ -231,6 +237,8 @@ private:
|
||||
|
||||
class CoverageImpl;
|
||||
class MSAAImpl;
|
||||
|
||||
typedef GrGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
constexpr GrPrimitiveProcessor::Attribute GrFillRRectOp::Processor::kVertexAttribs[];
|
||||
|
@ -200,7 +200,7 @@ private:
|
||||
// local coords.
|
||||
SkASSERT(!fHelper.isTrivial() || !fHelper.usesLocalCoords());
|
||||
|
||||
sk_sp<GrGeometryProcessor> gp = GrQuadPerEdgeAA::MakeProcessor(vertexSpec);
|
||||
GrGeometryProcessor* gp = GrQuadPerEdgeAA::MakeProcessor(target->allocator(), vertexSpec);
|
||||
size_t vertexSize = gp->vertexStride();
|
||||
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
@ -243,7 +243,7 @@ private:
|
||||
GrQuadPerEdgeAA::ConfigureMesh(mesh, vertexSpec, 0, fQuads.count(), totalNumVertices,
|
||||
std::move(vertexBuffer), std::move(indexBuffer),
|
||||
vertexOffsetInBuffer);
|
||||
target->recordDraw(std::move(gp), mesh, 1, vertexSpec.primitiveType());
|
||||
target->recordDraw(gp, mesh, 1, vertexSpec.primitiveType());
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
|
@ -28,13 +28,12 @@ namespace {
|
||||
|
||||
class LatticeGP : public GrGeometryProcessor {
|
||||
public:
|
||||
static sk_sp<GrGeometryProcessor> Make(GrGpu* gpu,
|
||||
const GrTextureProxy* proxy,
|
||||
sk_sp<GrColorSpaceXform> csxf,
|
||||
GrSamplerState::Filter filter,
|
||||
bool wideColor) {
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new LatticeGP(gpu, proxy, std::move(csxf), filter, wideColor));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
const GrTextureProxy* proxy,
|
||||
sk_sp<GrColorSpaceXform> csxf,
|
||||
GrSamplerState::Filter filter,
|
||||
bool wideColor) {
|
||||
return arena->make<LatticeGP>(proxy, std::move(csxf), filter, wideColor);
|
||||
}
|
||||
|
||||
const char* name() const override { return "LatticeGP"; }
|
||||
@ -92,9 +91,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
LatticeGP(GrGpu* gpu, const GrTextureProxy* proxy, sk_sp<GrColorSpaceXform> csxf,
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
LatticeGP(const GrTextureProxy* proxy, sk_sp<GrColorSpaceXform> csxf,
|
||||
GrSamplerState::Filter filter, bool wideColor)
|
||||
: INHERITED(kLatticeGP_ClassID), fColorSpaceXform(std::move(csxf)) {
|
||||
: INHERITED(kLatticeGP_ClassID)
|
||||
, fColorSpaceXform(std::move(csxf)) {
|
||||
|
||||
fSampler.reset(GrSamplerState(GrSamplerState::WrapMode::kClamp, filter),
|
||||
proxy->backendFormat(), proxy->textureSwizzle());
|
||||
@ -206,8 +208,8 @@ public:
|
||||
|
||||
private:
|
||||
void onPrepareDraws(Target* target) override {
|
||||
GrGpu* gpu = target->resourceProvider()->priv().gpu();
|
||||
auto gp = LatticeGP::Make(gpu, fProxy.get(), fColorSpaceXform, fFilter, fWideColor);
|
||||
auto gp = LatticeGP::Make(target->allocator(), fProxy.get(), fColorSpaceXform,
|
||||
fFilter, fWideColor);
|
||||
if (!gp) {
|
||||
SkDebugf("Couldn't create GrGeometryProcessor\n");
|
||||
return;
|
||||
@ -283,7 +285,7 @@ private:
|
||||
}
|
||||
auto fixedDynamicState = target->makeFixedDynamicState(1);
|
||||
fixedDynamicState->fPrimitiveProcessorTextures[0] = fProxy.get();
|
||||
helper.recordDraw(target, std::move(gp), fixedDynamicState);
|
||||
helper.recordDraw(target, gp, fixedDynamicState);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
|
@ -52,15 +52,14 @@ void GrMeshDrawOp::PatternHelper::init(Target* target, GrPrimitiveType primitive
|
||||
fMesh->setVertexData(std::move(vertexBuffer), firstVertex);
|
||||
}
|
||||
|
||||
void GrMeshDrawOp::PatternHelper::recordDraw(
|
||||
Target* target, sk_sp<const GrGeometryProcessor> gp) const {
|
||||
target->recordDraw(std::move(gp), fMesh, 1, fPrimitiveType);
|
||||
void GrMeshDrawOp::PatternHelper::recordDraw(Target* target, const GrGeometryProcessor* gp) const {
|
||||
target->recordDraw(gp, fMesh, 1, fPrimitiveType);
|
||||
}
|
||||
|
||||
void GrMeshDrawOp::PatternHelper::recordDraw(
|
||||
Target* target, sk_sp<const GrGeometryProcessor> gp,
|
||||
Target* target, const GrGeometryProcessor* gp,
|
||||
const GrPipeline::FixedDynamicState* fixedDynamicState) const {
|
||||
target->recordDraw(std::move(gp), fMesh, 1, fixedDynamicState, nullptr, fPrimitiveType);
|
||||
target->recordDraw(gp, fMesh, 1, fixedDynamicState, nullptr, fPrimitiveType);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -44,8 +44,8 @@ protected:
|
||||
int indicesPerRepetition, int repeatCount, int maxRepetitions);
|
||||
|
||||
/** Called to issue draws to the GrMeshDrawOp::Target.*/
|
||||
void recordDraw(Target*, sk_sp<const GrGeometryProcessor>) const;
|
||||
void recordDraw(Target*, sk_sp<const GrGeometryProcessor>,
|
||||
void recordDraw(Target*, const GrGeometryProcessor*) const;
|
||||
void recordDraw(Target*, const GrGeometryProcessor*,
|
||||
const GrPipeline::FixedDynamicState*) const;
|
||||
|
||||
void* vertices() const { return fVertices; }
|
||||
@ -109,7 +109,7 @@ public:
|
||||
|
||||
/** Adds a draw of a mesh. */
|
||||
virtual void recordDraw(
|
||||
sk_sp<const GrGeometryProcessor>, const GrMesh[], int meshCnt,
|
||||
const GrGeometryProcessor*, const GrMesh[], int meshCnt,
|
||||
const GrPipeline::FixedDynamicState*, const GrPipeline::DynamicStateArrays*,
|
||||
GrPrimitiveType) = 0;
|
||||
|
||||
@ -117,11 +117,11 @@ public:
|
||||
* Helper for drawing GrMesh(es) with zero primProc textures and no dynamic state besides the
|
||||
* scissor clip.
|
||||
*/
|
||||
void recordDraw(sk_sp<const GrGeometryProcessor> gp, const GrMesh meshes[], int meshCnt,
|
||||
void recordDraw(const GrGeometryProcessor* gp, const GrMesh meshes[], int meshCnt,
|
||||
GrPrimitiveType primitiveType) {
|
||||
static constexpr int kZeroPrimProcTextures = 0;
|
||||
auto fixedDynamicState = this->makeFixedDynamicState(kZeroPrimProcTextures);
|
||||
this->recordDraw(std::move(gp), meshes, meshCnt, fixedDynamicState, nullptr, primitiveType);
|
||||
this->recordDraw(gp, meshes, meshCnt, fixedDynamicState, nullptr, primitiveType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,6 +63,26 @@ static inline GrVertexWriter::TriStrip<float> origin_centered_tri_strip(float x,
|
||||
|
||||
class CircleGeometryProcessor : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool stroke, bool clipPlane,
|
||||
bool isectPlane, bool unionPlane, bool roundCaps,
|
||||
bool wideColor, const SkMatrix& localMatrix) {
|
||||
return arena->make<CircleGeometryProcessor>(stroke, clipPlane, isectPlane, unionPlane,
|
||||
roundCaps, wideColor, localMatrix);
|
||||
}
|
||||
|
||||
const char* name() const override { return "CircleGeometryProcessor"; }
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||
GLSLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
||||
return new GLSLProcessor();
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
CircleGeometryProcessor(bool stroke, bool clipPlane, bool isectPlane, bool unionPlane,
|
||||
bool roundCaps, bool wideColor, const SkMatrix& localMatrix)
|
||||
: INHERITED(kCircleGeometryProcessor_ClassID)
|
||||
@ -90,19 +110,6 @@ public:
|
||||
this->setVertexAttributes(&fInPosition, 7);
|
||||
}
|
||||
|
||||
~CircleGeometryProcessor() override {}
|
||||
|
||||
const char* name() const override { return "CircleEdge"; }
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||
GLSLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
||||
return new GLSLProcessor();
|
||||
}
|
||||
|
||||
private:
|
||||
class GLSLProcessor : public GrGLSLGeometryProcessor {
|
||||
public:
|
||||
GLSLProcessor() {}
|
||||
@ -243,7 +250,7 @@ private:
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleGeometryProcessor);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> CircleGeometryProcessor::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* CircleGeometryProcessor::TestCreate(GrProcessorTestData* d) {
|
||||
bool stroke = d->fRandom->nextBool();
|
||||
bool roundCaps = stroke ? d->fRandom->nextBool() : false;
|
||||
bool wideColor = d->fRandom->nextBool();
|
||||
@ -251,20 +258,16 @@ sk_sp<GrGeometryProcessor> CircleGeometryProcessor::TestCreate(GrProcessorTestDa
|
||||
bool isectPlane = d->fRandom->nextBool();
|
||||
bool unionPlane = d->fRandom->nextBool();
|
||||
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
|
||||
return sk_sp<GrGeometryProcessor>(new CircleGeometryProcessor(
|
||||
stroke, clipPlane, isectPlane, unionPlane, roundCaps, wideColor, matrix));
|
||||
return CircleGeometryProcessor::Make(d->allocator(), stroke, clipPlane, isectPlane,
|
||||
unionPlane, roundCaps, wideColor, matrix);
|
||||
}
|
||||
#endif
|
||||
|
||||
class ButtCapDashedCircleGeometryProcessor : public GrGeometryProcessor {
|
||||
public:
|
||||
ButtCapDashedCircleGeometryProcessor(bool wideColor, const SkMatrix& localMatrix)
|
||||
: INHERITED(kButtCapStrokedCircleGeometryProcessor_ClassID), fLocalMatrix(localMatrix) {
|
||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||
fInColor = MakeColorAttribute("inColor", wideColor);
|
||||
fInCircleEdge = {"inCircleEdge", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
|
||||
fInDashParams = {"inDashParams", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
|
||||
this->setVertexAttributes(&fInPosition, 4);
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool wideColor,
|
||||
const SkMatrix& localMatrix) {
|
||||
return arena->make<ButtCapDashedCircleGeometryProcessor>(wideColor, localMatrix);
|
||||
}
|
||||
|
||||
~ButtCapDashedCircleGeometryProcessor() override {}
|
||||
@ -280,6 +283,18 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
ButtCapDashedCircleGeometryProcessor(bool wideColor, const SkMatrix& localMatrix)
|
||||
: INHERITED(kButtCapStrokedCircleGeometryProcessor_ClassID)
|
||||
, fLocalMatrix(localMatrix) {
|
||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||
fInColor = MakeColorAttribute("inColor", wideColor);
|
||||
fInCircleEdge = {"inCircleEdge", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
|
||||
fInDashParams = {"inDashParams", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
|
||||
this->setVertexAttributes(&fInPosition, 4);
|
||||
}
|
||||
|
||||
class GLSLProcessor : public GrGLSLGeometryProcessor {
|
||||
public:
|
||||
GLSLProcessor() {}
|
||||
@ -488,10 +503,10 @@ private:
|
||||
};
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> ButtCapDashedCircleGeometryProcessor::TestCreate(GrProcessorTestData* d) {
|
||||
GrGeometryProcessor* ButtCapDashedCircleGeometryProcessor::TestCreate(GrProcessorTestData* d) {
|
||||
bool wideColor = d->fRandom->nextBool();
|
||||
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
|
||||
return sk_sp<GrGeometryProcessor>(new ButtCapDashedCircleGeometryProcessor(wideColor, matrix));
|
||||
return ButtCapDashedCircleGeometryProcessor::Make(d->allocator(), wideColor, matrix);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -507,12 +522,32 @@ sk_sp<GrGeometryProcessor> ButtCapDashedCircleGeometryProcessor::TestCreate(GrPr
|
||||
|
||||
class EllipseGeometryProcessor : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool stroke, bool wideColor,
|
||||
bool useScale, const SkMatrix& localMatrix) {
|
||||
return arena->make<EllipseGeometryProcessor>(stroke, wideColor, useScale, localMatrix);
|
||||
}
|
||||
|
||||
~EllipseGeometryProcessor() override {}
|
||||
|
||||
const char* name() const override { return "EllipseGeometryProcessor"; }
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||
GLSLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
||||
return new GLSLProcessor();
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
EllipseGeometryProcessor(bool stroke, bool wideColor, bool useScale,
|
||||
const SkMatrix& localMatrix)
|
||||
: INHERITED(kEllipseGeometryProcessor_ClassID)
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fStroke(stroke)
|
||||
, fUseScale(useScale) {
|
||||
: INHERITED(kEllipseGeometryProcessor_ClassID)
|
||||
, fLocalMatrix(localMatrix)
|
||||
, fStroke(stroke)
|
||||
, fUseScale(useScale) {
|
||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||
fInColor = MakeColorAttribute("inColor", wideColor);
|
||||
if (useScale) {
|
||||
@ -524,19 +559,6 @@ public:
|
||||
this->setVertexAttributes(&fInPosition, 4);
|
||||
}
|
||||
|
||||
~EllipseGeometryProcessor() override {}
|
||||
|
||||
const char* name() const override { return "EllipseEdge"; }
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||
GLSLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
||||
return new GLSLProcessor();
|
||||
}
|
||||
|
||||
private:
|
||||
class GLSLProcessor : public GrGLSLGeometryProcessor {
|
||||
public:
|
||||
GLSLProcessor() {}
|
||||
@ -676,10 +698,10 @@ private:
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseGeometryProcessor);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> EllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
|
||||
return sk_sp<GrGeometryProcessor>(
|
||||
new EllipseGeometryProcessor(d->fRandom->nextBool(), d->fRandom->nextBool(),
|
||||
d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom)));
|
||||
GrGeometryProcessor* EllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
|
||||
return EllipseGeometryProcessor::Make(d->allocator(), d->fRandom->nextBool(),
|
||||
d->fRandom->nextBool(), d->fRandom->nextBool(),
|
||||
GrTest::TestMatrix(d->fRandom));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -698,6 +720,26 @@ enum class DIEllipseStyle { kStroke = 0, kHairline, kFill };
|
||||
|
||||
class DIEllipseGeometryProcessor : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool wideColor, bool useScale,
|
||||
const SkMatrix& viewMatrix, DIEllipseStyle style) {
|
||||
return arena->make<DIEllipseGeometryProcessor>(wideColor, useScale, viewMatrix, style);
|
||||
}
|
||||
|
||||
~DIEllipseGeometryProcessor() override {}
|
||||
|
||||
const char* name() const override { return "DIEllipseGeometryProcessor"; }
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||
GLSLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
||||
return new GLSLProcessor();
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
DIEllipseGeometryProcessor(bool wideColor, bool useScale, const SkMatrix& viewMatrix,
|
||||
DIEllipseStyle style)
|
||||
: INHERITED(kDIEllipseGeometryProcessor_ClassID)
|
||||
@ -717,19 +759,6 @@ public:
|
||||
this->setVertexAttributes(&fInPosition, 4);
|
||||
}
|
||||
|
||||
~DIEllipseGeometryProcessor() override {}
|
||||
|
||||
const char* name() const override { return "DIEllipseEdge"; }
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||
GLSLProcessor::GenKey(*this, caps, b);
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
||||
return new GLSLProcessor();
|
||||
}
|
||||
|
||||
private:
|
||||
class GLSLProcessor : public GrGLSLGeometryProcessor {
|
||||
public:
|
||||
GLSLProcessor() : fViewMatrix(SkMatrix::InvalidMatrix()) {}
|
||||
@ -876,10 +905,10 @@ private:
|
||||
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseGeometryProcessor);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
sk_sp<GrGeometryProcessor> DIEllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
|
||||
return sk_sp<GrGeometryProcessor>(new DIEllipseGeometryProcessor(
|
||||
d->fRandom->nextBool(), d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom),
|
||||
(DIEllipseStyle)(d->fRandom->nextRangeU(0, 2))));
|
||||
GrGeometryProcessor* DIEllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) {
|
||||
return DIEllipseGeometryProcessor::Make(d->allocator(), d->fRandom->nextBool(),
|
||||
d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom),
|
||||
(DIEllipseStyle)(d->fRandom->nextRangeU(0, 2)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1240,9 +1269,11 @@ private:
|
||||
}
|
||||
|
||||
// Setup geometry processor
|
||||
sk_sp<GrGeometryProcessor> gp(new CircleGeometryProcessor(
|
||||
!fAllFill, fClipPlane, fClipPlaneIsect, fClipPlaneUnion, fRoundCaps, fWideColor,
|
||||
localMatrix));
|
||||
GrGeometryProcessor* gp = CircleGeometryProcessor::Make(target->allocator(),
|
||||
!fAllFill, fClipPlane,
|
||||
fClipPlaneIsect, fClipPlaneUnion,
|
||||
fRoundCaps, fWideColor,
|
||||
localMatrix);
|
||||
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex;
|
||||
@ -1364,7 +1395,7 @@ private:
|
||||
mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
|
||||
GrPrimitiveRestart::kNo);
|
||||
mesh->setVertexData(std::move(vertexBuffer), firstVertex);
|
||||
target->recordDraw(std::move(gp), mesh, 1, GrPrimitiveType::kTriangles);
|
||||
target->recordDraw(gp, mesh, 1, GrPrimitiveType::kTriangles);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
@ -1572,8 +1603,9 @@ private:
|
||||
}
|
||||
|
||||
// Setup geometry processor
|
||||
sk_sp<GrGeometryProcessor> gp(new ButtCapDashedCircleGeometryProcessor(fWideColor,
|
||||
localMatrix));
|
||||
GrGeometryProcessor* gp = ButtCapDashedCircleGeometryProcessor::Make(target->allocator(),
|
||||
fWideColor,
|
||||
localMatrix);
|
||||
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex;
|
||||
@ -1654,7 +1686,7 @@ private:
|
||||
mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
|
||||
GrPrimitiveRestart::kNo);
|
||||
mesh->setVertexData(std::move(vertexBuffer), firstVertex);
|
||||
target->recordDraw(std::move(gp), mesh, 1, GrPrimitiveType::kTriangles);
|
||||
target->recordDraw(gp, mesh, 1, GrPrimitiveType::kTriangles);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
@ -1871,8 +1903,9 @@ private:
|
||||
}
|
||||
|
||||
// Setup geometry processor
|
||||
sk_sp<GrGeometryProcessor> gp(new EllipseGeometryProcessor(fStroked, fWideColor, fUseScale,
|
||||
localMatrix));
|
||||
GrGeometryProcessor* gp = EllipseGeometryProcessor::Make(target->allocator(),
|
||||
fStroked, fWideColor, fUseScale,
|
||||
localMatrix);
|
||||
QuadHelper helper(target, gp->vertexStride(), fEllipses.count());
|
||||
GrVertexWriter verts{helper.vertices()};
|
||||
if (!verts.fPtr) {
|
||||
@ -1908,7 +1941,7 @@ private:
|
||||
GrVertexWriter::If(fUseScale, SkTMax(xRadius, yRadius)),
|
||||
invRadii);
|
||||
}
|
||||
helper.recordDraw(target, std::move(gp));
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
@ -2109,9 +2142,9 @@ public:
|
||||
private:
|
||||
void onPrepareDraws(Target* target) override {
|
||||
// Setup geometry processor
|
||||
sk_sp<GrGeometryProcessor> gp(
|
||||
new DIEllipseGeometryProcessor(fWideColor, fUseScale, this->viewMatrix(),
|
||||
this->style()));
|
||||
GrGeometryProcessor* gp = DIEllipseGeometryProcessor::Make(target->allocator(), fWideColor,
|
||||
fUseScale, this->viewMatrix(),
|
||||
this->style());
|
||||
|
||||
QuadHelper helper(target, gp->vertexStride(), fEllipses.count());
|
||||
GrVertexWriter verts{helper.vertices()};
|
||||
@ -2145,7 +2178,7 @@ private:
|
||||
origin_centered_tri_strip(innerRatioX + offsetDx,
|
||||
innerRatioY + offsetDy));
|
||||
}
|
||||
helper.recordDraw(target, std::move(gp));
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
@ -2485,9 +2518,9 @@ private:
|
||||
}
|
||||
|
||||
// Setup geometry processor
|
||||
sk_sp<GrGeometryProcessor> gp(
|
||||
new CircleGeometryProcessor(!fAllFill, false, false, false, false, fWideColor,
|
||||
localMatrix));
|
||||
GrGeometryProcessor* gp = CircleGeometryProcessor::Make(target->allocator(), !fAllFill,
|
||||
false, false, false, false,
|
||||
fWideColor, localMatrix);
|
||||
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex;
|
||||
@ -2576,7 +2609,7 @@ private:
|
||||
mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
|
||||
GrPrimitiveRestart::kNo);
|
||||
mesh->setVertexData(std::move(vertexBuffer), firstVertex);
|
||||
target->recordDraw(std::move(gp), mesh, 1, GrPrimitiveType::kTriangles);
|
||||
target->recordDraw(gp, mesh, 1, GrPrimitiveType::kTriangles);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
@ -2777,8 +2810,9 @@ private:
|
||||
}
|
||||
|
||||
// Setup geometry processor
|
||||
sk_sp<GrGeometryProcessor> gp(new EllipseGeometryProcessor(fStroked, fWideColor, fUseScale,
|
||||
localMatrix));
|
||||
GrGeometryProcessor* gp = EllipseGeometryProcessor::Make(target->allocator(), fStroked,
|
||||
fWideColor, fUseScale,
|
||||
localMatrix);
|
||||
|
||||
// drop out the middle quad if we're stroked
|
||||
int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPerFillRRect;
|
||||
@ -2857,7 +2891,7 @@ private:
|
||||
reciprocalRadii);
|
||||
}
|
||||
}
|
||||
helper.recordDraw(target, std::move(gp));
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
|
@ -500,19 +500,20 @@ class QuadPerEdgeAAGeometryProcessor : public GrGeometryProcessor {
|
||||
public:
|
||||
using Saturate = GrTextureOp::Saturate;
|
||||
|
||||
static sk_sp<GrGeometryProcessor> Make(const VertexSpec& spec) {
|
||||
return sk_sp<QuadPerEdgeAAGeometryProcessor>(new QuadPerEdgeAAGeometryProcessor(spec));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, const VertexSpec& spec) {
|
||||
return arena->make<QuadPerEdgeAAGeometryProcessor>(spec);
|
||||
}
|
||||
|
||||
static sk_sp<GrGeometryProcessor> Make(const VertexSpec& vertexSpec, const GrShaderCaps& caps,
|
||||
const GrBackendFormat& backendFormat,
|
||||
const GrSamplerState& samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform,
|
||||
Saturate saturate) {
|
||||
return sk_sp<QuadPerEdgeAAGeometryProcessor>(new QuadPerEdgeAAGeometryProcessor(
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, const VertexSpec& vertexSpec,
|
||||
const GrShaderCaps& caps,
|
||||
const GrBackendFormat& backendFormat,
|
||||
const GrSamplerState& samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform,
|
||||
Saturate saturate) {
|
||||
return arena->make<QuadPerEdgeAAGeometryProcessor>(
|
||||
vertexSpec, caps, backendFormat, samplerState, swizzle,
|
||||
std::move(textureColorSpaceXform), saturate));
|
||||
std::move(textureColorSpaceXform), saturate);
|
||||
}
|
||||
|
||||
const char* name() const override { return "QuadPerEdgeAAGeometryProcessor"; }
|
||||
@ -702,6 +703,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
QuadPerEdgeAAGeometryProcessor(const VertexSpec& spec)
|
||||
: INHERITED(kQuadPerEdgeAAGeometryProcessor_ClassID)
|
||||
, fTextureColorSpaceXform(nullptr) {
|
||||
@ -796,18 +799,20 @@ private:
|
||||
typedef GrGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
sk_sp<GrGeometryProcessor> MakeProcessor(const VertexSpec& spec) {
|
||||
return QuadPerEdgeAAGeometryProcessor::Make(spec);
|
||||
GrGeometryProcessor* MakeProcessor(SkArenaAlloc* arena, const VertexSpec& spec) {
|
||||
return QuadPerEdgeAAGeometryProcessor::Make(arena, spec);
|
||||
}
|
||||
|
||||
sk_sp<GrGeometryProcessor> MakeTexturedProcessor(const VertexSpec& spec, const GrShaderCaps& caps,
|
||||
const GrBackendFormat& backendFormat,
|
||||
const GrSamplerState& samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform,
|
||||
Saturate saturate) {
|
||||
return QuadPerEdgeAAGeometryProcessor::Make(spec, caps, backendFormat, samplerState, swizzle,
|
||||
std::move(textureColorSpaceXform), saturate);
|
||||
GrGeometryProcessor* MakeTexturedProcessor(SkArenaAlloc* arena, const VertexSpec& spec,
|
||||
const GrShaderCaps& caps,
|
||||
const GrBackendFormat& backendFormat,
|
||||
const GrSamplerState& samplerState,
|
||||
const GrSwizzle& swizzle,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform,
|
||||
Saturate saturate) {
|
||||
return QuadPerEdgeAAGeometryProcessor::Make(arena, spec, caps, backendFormat, samplerState,
|
||||
swizzle, std::move(textureColorSpaceXform),
|
||||
saturate);
|
||||
}
|
||||
|
||||
} // namespace GrQuadPerEdgeAA
|
||||
|
@ -158,12 +158,12 @@ namespace GrQuadPerEdgeAA {
|
||||
WriteQuadProc fWriteProc;
|
||||
};
|
||||
|
||||
sk_sp<GrGeometryProcessor> MakeProcessor(const VertexSpec& spec);
|
||||
GrGeometryProcessor* MakeProcessor(SkArenaAlloc*, const VertexSpec&);
|
||||
|
||||
sk_sp<GrGeometryProcessor> MakeTexturedProcessor(
|
||||
const VertexSpec& spec, const GrShaderCaps& caps, const GrBackendFormat&,
|
||||
const GrSamplerState& samplerState, const GrSwizzle& swizzle,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform, Saturate saturate);
|
||||
GrGeometryProcessor* MakeTexturedProcessor(
|
||||
SkArenaAlloc*, const VertexSpec&, const GrShaderCaps&, const GrBackendFormat&,
|
||||
const GrSamplerState&, const GrSwizzle&,
|
||||
sk_sp<GrColorSpaceXform> textureColorSpaceXform, Saturate);
|
||||
|
||||
// This method will return the correct index buffer for the specified indexBufferOption.
|
||||
// It will, correctly, return nullptr if the indexBufferOption is kTriStrips.
|
||||
|
@ -18,13 +18,14 @@
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
||||
|
||||
static sk_sp<GrGeometryProcessor> make_gp(const GrShaderCaps* shaderCaps,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool wideColor) {
|
||||
static GrGeometryProcessor* make_gp(SkArenaAlloc* arena,
|
||||
const GrShaderCaps* shaderCaps,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool wideColor) {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
Color::Type colorType =
|
||||
wideColor ? Color::kPremulWideColorAttribute_Type : Color::kPremulGrColorAttribute_Type;
|
||||
return GrDefaultGeoProcFactory::Make(shaderCaps, colorType, Coverage::kSolid_Type,
|
||||
Color::Type colorType = wideColor ? Color::kPremulWideColorAttribute_Type
|
||||
: Color::kPremulGrColorAttribute_Type;
|
||||
return GrDefaultGeoProcFactory::Make(arena, shaderCaps, colorType, Coverage::kSolid_Type,
|
||||
LocalCoords::kUsePosition_Type, viewMatrix);
|
||||
}
|
||||
|
||||
@ -94,8 +95,8 @@ public:
|
||||
|
||||
private:
|
||||
void onPrepareDraws(Target* target) override {
|
||||
sk_sp<GrGeometryProcessor> gp = make_gp(target->caps().shaderCaps(), fViewMatrix,
|
||||
fWideColor);
|
||||
GrGeometryProcessor* gp = make_gp(target->allocator(), target->caps().shaderCaps(),
|
||||
fViewMatrix, fWideColor);
|
||||
if (!gp) {
|
||||
SkDebugf("Couldn't create GrGeometryProcessor\n");
|
||||
return;
|
||||
@ -128,7 +129,7 @@ private:
|
||||
iter.next();
|
||||
}
|
||||
}
|
||||
helper.recordDraw(target, std::move(gp));
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
|
@ -539,7 +539,8 @@ private:
|
||||
|
||||
void onPrepareDraws(Target* target) override {
|
||||
// Setup geometry processor
|
||||
sk_sp<GrGeometryProcessor> gp = GrRRectShadowGeoProc::Make(fFalloffProxy.get());
|
||||
GrGeometryProcessor* gp = GrRRectShadowGeoProc::Make(target->allocator(),
|
||||
fFalloffProxy.get());
|
||||
|
||||
int instanceCount = fGeoData.count();
|
||||
SkASSERT(sizeof(CircleVertex) == gp->vertexStride());
|
||||
@ -597,8 +598,7 @@ private:
|
||||
mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
|
||||
GrPrimitiveRestart::kNo);
|
||||
mesh->setVertexData(std::move(vertexBuffer), firstVertex);
|
||||
target->recordDraw(std::move(gp), mesh, 1, fixedDynamicState, nullptr,
|
||||
GrPrimitiveType::kTriangles);
|
||||
target->recordDraw(gp, mesh, 1, fixedDynamicState, nullptr, GrPrimitiveType::kTriangles);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
|
@ -309,7 +309,7 @@ private:
|
||||
struct FlushInfo {
|
||||
sk_sp<const GrBuffer> fVertexBuffer;
|
||||
sk_sp<const GrBuffer> fIndexBuffer;
|
||||
sk_sp<GrGeometryProcessor> fGeometryProcessor;
|
||||
GrGeometryProcessor* fGeometryProcessor;
|
||||
GrPipeline::FixedDynamicState* fFixedDynamicState;
|
||||
int fVertexOffset;
|
||||
int fInstancesToFlush;
|
||||
@ -353,7 +353,7 @@ private:
|
||||
} else {
|
||||
matrix = &SkMatrix::I();
|
||||
}
|
||||
flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(
|
||||
flushInfo.fGeometryProcessor = GrDistanceFieldPathGeoProc::Make(target->allocator(),
|
||||
*target->caps().shaderCaps(), *matrix, fWideColor, fAtlas->getProxies(),
|
||||
fAtlas->numActivePages(), GrSamplerState::ClampBilerp(), flags);
|
||||
} else {
|
||||
@ -364,7 +364,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
|
||||
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(target->allocator(),
|
||||
*target->caps().shaderCaps(), this->color(), fWideColor, fAtlas->getProxies(),
|
||||
fAtlas->numActivePages(), GrSamplerState::ClampNearest(), kA8_GrMaskFormat,
|
||||
invert, false);
|
||||
@ -774,7 +774,7 @@ private:
|
||||
}
|
||||
|
||||
void flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const {
|
||||
GrGeometryProcessor* gp = flushInfo->fGeometryProcessor.get();
|
||||
GrGeometryProcessor* gp = flushInfo->fGeometryProcessor;
|
||||
int numAtlasTextures = SkToInt(fAtlas->numActivePages());
|
||||
auto proxies = fAtlas->getProxies();
|
||||
if (gp->numTextureSamplers() != numAtlasTextures) {
|
||||
|
@ -176,15 +176,15 @@ public:
|
||||
|
||||
private:
|
||||
void onPrepareDraws(Target* target) override {
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrGeometryProcessor* gp;
|
||||
{
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
Color color(fColor);
|
||||
LocalCoords::Type localCoordsType = fHelper.usesLocalCoords()
|
||||
? LocalCoords::kUsePosition_Type
|
||||
: LocalCoords::kUnused_Type;
|
||||
gp = GrDefaultGeoProcFactory::Make(target->caps().shaderCaps(), color,
|
||||
Coverage::kSolid_Type, localCoordsType,
|
||||
gp = GrDefaultGeoProcFactory::Make(target->allocator(), target->caps().shaderCaps(),
|
||||
color, Coverage::kSolid_Type, localCoordsType,
|
||||
fViewMatrix);
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ private:
|
||||
GrMesh* mesh = target->allocMesh(primType);
|
||||
mesh->setNonIndexedNonInstanced(vertexCount);
|
||||
mesh->setVertexData(std::move(vertexBuffer), firstVertex);
|
||||
target->recordDraw(std::move(gp), mesh, 1, primType);
|
||||
target->recordDraw(gp, mesh, 1, primType);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
@ -304,11 +304,12 @@ static void compute_aa_rects(SkRect* devOutside, SkRect* devOutsideAssist, SkRec
|
||||
}
|
||||
}
|
||||
|
||||
static sk_sp<GrGeometryProcessor> create_aa_stroke_rect_gp(const GrShaderCaps* shaderCaps,
|
||||
bool tweakAlphaForCoverage,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool wideColor) {
|
||||
static GrGeometryProcessor* create_aa_stroke_rect_gp(SkArenaAlloc* arena,
|
||||
const GrShaderCaps* shaderCaps,
|
||||
bool tweakAlphaForCoverage,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool wideColor) {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
|
||||
Coverage::Type coverageType =
|
||||
@ -318,7 +319,8 @@ static sk_sp<GrGeometryProcessor> create_aa_stroke_rect_gp(const GrShaderCaps* s
|
||||
Color::Type colorType =
|
||||
wideColor ? Color::kPremulWideColorAttribute_Type: Color::kPremulGrColorAttribute_Type;
|
||||
|
||||
return MakeForDeviceSpace(shaderCaps, colorType, coverageType, localCoordsType, viewMatrix);
|
||||
return MakeForDeviceSpace(arena, shaderCaps, colorType, coverageType,
|
||||
localCoordsType, viewMatrix);
|
||||
}
|
||||
|
||||
class AAStrokeRectOp final : public GrMeshDrawOp {
|
||||
@ -469,11 +471,12 @@ private:
|
||||
};
|
||||
|
||||
void AAStrokeRectOp::onPrepareDraws(Target* target) {
|
||||
sk_sp<GrGeometryProcessor> gp(create_aa_stroke_rect_gp(target->caps().shaderCaps(),
|
||||
fHelper.compatibleWithCoverageAsAlpha(),
|
||||
this->viewMatrix(),
|
||||
fHelper.usesLocalCoords(),
|
||||
fWideColor));
|
||||
GrGeometryProcessor* gp = create_aa_stroke_rect_gp(target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
fHelper.compatibleWithCoverageAsAlpha(),
|
||||
this->viewMatrix(),
|
||||
fHelper.usesLocalCoords(),
|
||||
fWideColor);
|
||||
if (!gp) {
|
||||
SkDebugf("Couldn't create GrGeometryProcessor\n");
|
||||
return;
|
||||
@ -513,7 +516,7 @@ void AAStrokeRectOp::onPrepareDraws(Target* target) {
|
||||
info.fDegenerate,
|
||||
fHelper.compatibleWithCoverageAsAlpha());
|
||||
}
|
||||
helper.recordDraw(target, std::move(gp));
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
void AAStrokeRectOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
|
||||
|
@ -255,7 +255,7 @@ private:
|
||||
return path;
|
||||
}
|
||||
|
||||
void draw(Target* target, sk_sp<const GrGeometryProcessor> gp, size_t vertexStride) {
|
||||
void draw(Target* target, const GrGeometryProcessor* gp, size_t vertexStride) {
|
||||
SkASSERT(!fAntiAlias);
|
||||
GrResourceProvider* rp = target->resourceProvider();
|
||||
bool inverseFill = fShape.inverseFilled();
|
||||
@ -279,8 +279,7 @@ private:
|
||||
SkScalar tol = GrPathUtils::kDefaultTolerance;
|
||||
tol = GrPathUtils::scaleToleranceToSrc(tol, fViewMatrix, fShape.bounds());
|
||||
if (cache_match(cachedVertexBuffer.get(), tol, &actualCount)) {
|
||||
this->drawVertices(target, std::move(gp), std::move(cachedVertexBuffer), 0,
|
||||
actualCount);
|
||||
this->drawVertices(target, gp, std::move(cachedVertexBuffer), 0, actualCount);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -307,10 +306,10 @@ private:
|
||||
key.setCustomData(SkData::MakeWithCopy(&info, sizeof(info)));
|
||||
rp->assignUniqueKeyToResource(key, vb.get());
|
||||
|
||||
this->drawVertices(target, std::move(gp), std::move(vb), 0, count);
|
||||
this->drawVertices(target, gp, std::move(vb), 0, count);
|
||||
}
|
||||
|
||||
void drawAA(Target* target, sk_sp<const GrGeometryProcessor> gp, size_t vertexStride) {
|
||||
void drawAA(Target* target, const GrGeometryProcessor* gp, size_t vertexStride) {
|
||||
SkASSERT(fAntiAlias);
|
||||
SkPath path = getPath();
|
||||
if (path.isEmpty()) {
|
||||
@ -326,12 +325,12 @@ private:
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
this->drawVertices(target, std::move(gp), allocator.detachVertexBuffer(),
|
||||
this->drawVertices(target, gp, allocator.detachVertexBuffer(),
|
||||
allocator.firstVertex(), count);
|
||||
}
|
||||
|
||||
void onPrepareDraws(Target* target) override {
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrGeometryProcessor* gp;
|
||||
{
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
|
||||
@ -350,27 +349,28 @@ private:
|
||||
coverageType = Coverage::kSolid_Type;
|
||||
}
|
||||
if (fAntiAlias) {
|
||||
gp = GrDefaultGeoProcFactory::MakeForDeviceSpace(target->caps().shaderCaps(),
|
||||
gp = GrDefaultGeoProcFactory::MakeForDeviceSpace(target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
color, coverageType,
|
||||
localCoordsType, fViewMatrix);
|
||||
} else {
|
||||
gp = GrDefaultGeoProcFactory::Make(target->caps().shaderCaps(),
|
||||
gp = GrDefaultGeoProcFactory::Make(target->allocator(), target->caps().shaderCaps(),
|
||||
color, coverageType, localCoordsType,
|
||||
fViewMatrix);
|
||||
}
|
||||
}
|
||||
if (!gp.get()) {
|
||||
if (!gp) {
|
||||
return;
|
||||
}
|
||||
size_t vertexStride = gp->vertexStride();
|
||||
if (fAntiAlias) {
|
||||
this->drawAA(target, std::move(gp), vertexStride);
|
||||
this->drawAA(target, gp, vertexStride);
|
||||
} else {
|
||||
this->draw(target, std::move(gp), vertexStride);
|
||||
this->draw(target, gp, vertexStride);
|
||||
}
|
||||
}
|
||||
|
||||
void drawVertices(Target* target, sk_sp<const GrGeometryProcessor> gp, sk_sp<const GrBuffer> vb,
|
||||
void drawVertices(Target* target, const GrGeometryProcessor* gp, sk_sp<const GrBuffer> vb,
|
||||
int firstVertex, int count) {
|
||||
GrPrimitiveType primitiveType = TESSELLATOR_WIREFRAME ? GrPrimitiveType::kLines
|
||||
: GrPrimitiveType::kTriangles;
|
||||
@ -378,7 +378,7 @@ private:
|
||||
GrMesh* mesh = target->allocMesh(primitiveType);
|
||||
mesh->setNonIndexedNonInstanced(count);
|
||||
mesh->setVertexData(std::move(vb), firstVertex);
|
||||
target->recordDraw(std::move(gp), mesh, 1, primitiveType);
|
||||
target->recordDraw(gp, mesh, 1, primitiveType);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
|
@ -761,7 +761,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<GrGeometryProcessor> gp;
|
||||
GrGeometryProcessor* gp;
|
||||
|
||||
{
|
||||
const GrBackendFormat& backendFormat =
|
||||
@ -773,14 +773,14 @@ private:
|
||||
|
||||
auto saturate = static_cast<GrTextureOp::Saturate>(fSaturate);
|
||||
|
||||
gp = GrQuadPerEdgeAA::MakeTexturedProcessor(
|
||||
gp = GrQuadPerEdgeAA::MakeTexturedProcessor(target->allocator(),
|
||||
desc.fVertexSpec, *target->caps().shaderCaps(), backendFormat,
|
||||
samplerState, swizzle, std::move(fTextureColorSpaceXform), saturate);
|
||||
|
||||
SkASSERT(vertexSize == gp->vertexStride());
|
||||
}
|
||||
|
||||
target->recordDraw(std::move(gp), meshes, desc.fNumProxies,
|
||||
target->recordDraw(gp, meshes, desc.fNumProxies,
|
||||
desc.fFixedDynamicState, desc.fDynamicStateArrays,
|
||||
desc.fVertexSpec.primitiveType());
|
||||
}
|
||||
|
@ -321,6 +321,27 @@ private:
|
||||
|
||||
class GrMeshTestProcessor : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool instanced, bool hasVertexBuffer) {
|
||||
return arena->make<GrMeshTestProcessor>(instanced, hasVertexBuffer);
|
||||
}
|
||||
|
||||
const char* name() const override { return "GrMeshTestProcessor"; }
|
||||
|
||||
const Attribute& inColor() const {
|
||||
return fVertexColor.isInitialized() ? fVertexColor : fInstanceColor;
|
||||
}
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const final {
|
||||
b->add32(fInstanceLocation.isInitialized());
|
||||
b->add32(fVertexPosition.isInitialized());
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const final;
|
||||
|
||||
private:
|
||||
friend class GLSLMeshTestProcessor;
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrMeshTestProcessor(bool instanced, bool hasVertexBuffer)
|
||||
: INHERITED(kGrMeshTestProcessor_ClassID) {
|
||||
if (instanced) {
|
||||
@ -338,27 +359,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
const char* name() const override { return "GrMeshTest Processor"; }
|
||||
|
||||
const Attribute& inColor() const {
|
||||
return fVertexColor.isInitialized() ? fVertexColor : fInstanceColor;
|
||||
}
|
||||
|
||||
void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const final {
|
||||
b->add32(fInstanceLocation.isInitialized());
|
||||
b->add32(fVertexPosition.isInitialized());
|
||||
}
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const final;
|
||||
|
||||
private:
|
||||
Attribute fVertexPosition;
|
||||
Attribute fVertexColor;
|
||||
|
||||
Attribute fInstanceLocation;
|
||||
Attribute fInstanceColor;
|
||||
|
||||
friend class GLSLMeshTestProcessor;
|
||||
typedef GrGeometryProcessor INHERITED;
|
||||
};
|
||||
|
||||
@ -412,13 +418,15 @@ sk_sp<const GrBuffer> DrawMeshHelper::getIndexBuffer() {
|
||||
|
||||
void DrawMeshHelper::drawMesh(const GrMesh& mesh, GrPrimitiveType primitiveType) {
|
||||
GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kSrc, GrSwizzle::RGBA());
|
||||
GrMeshTestProcessor mtp(mesh.isInstanced(), mesh.hasVertexData());
|
||||
|
||||
GrGeometryProcessor* mtp = GrMeshTestProcessor::Make(fState->allocator(),
|
||||
mesh.isInstanced(), mesh.hasVertexData());
|
||||
|
||||
GrProgramInfo programInfo(fState->proxy()->numSamples(),
|
||||
fState->proxy()->numStencilSamples(),
|
||||
fState->drawOpArgs().origin(),
|
||||
&pipeline,
|
||||
&mtp,
|
||||
mtp,
|
||||
nullptr, nullptr, 0, primitiveType);
|
||||
|
||||
fState->opsRenderPass()->draw(programInfo, &mesh, 1,
|
||||
|
@ -60,9 +60,8 @@ struct Vertex {
|
||||
|
||||
class GrPipelineDynamicStateTestProcessor : public GrGeometryProcessor {
|
||||
public:
|
||||
GrPipelineDynamicStateTestProcessor()
|
||||
: INHERITED(kGrPipelineDynamicStateTestProcessor_ClassID) {
|
||||
this->setVertexAttributes(kAttributes, SK_ARRAY_COUNT(kAttributes));
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena) {
|
||||
return arena->make<GrPipelineDynamicStateTestProcessor>();
|
||||
}
|
||||
|
||||
const char* name() const override { return "GrPipelineDynamicStateTest Processor"; }
|
||||
@ -75,6 +74,13 @@ public:
|
||||
const Attribute& inColor() const { return kAttributes[1]; }
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GrPipelineDynamicStateTestProcessor()
|
||||
: INHERITED(kGrPipelineDynamicStateTestProcessor_ClassID) {
|
||||
this->setVertexAttributes(kAttributes, SK_ARRAY_COUNT(kAttributes));
|
||||
}
|
||||
|
||||
static constexpr Attribute kAttributes[] = {
|
||||
{"vertex", kFloat2_GrVertexAttribType, kHalf2_GrSLType},
|
||||
{"color", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType},
|
||||
@ -153,13 +159,13 @@ private:
|
||||
GrPipeline::DynamicStateArrays dynamicState;
|
||||
dynamicState.fScissorRects = kDynamicScissors;
|
||||
|
||||
GrPipelineDynamicStateTestProcessor primProc;
|
||||
auto geomProc = GrPipelineDynamicStateTestProcessor::Make(flushState->allocator());
|
||||
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
&pipeline,
|
||||
&primProc,
|
||||
geomProc,
|
||||
nullptr,
|
||||
&dynamicState, 0, GrPrimitiveType::kTriangleStrip);
|
||||
|
||||
|
@ -99,8 +99,9 @@ private:
|
||||
static const int kColorOffset = sizeof(SkPoint);
|
||||
static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
|
||||
|
||||
sk_sp<GrGeometryProcessor> gp =
|
||||
GrDefaultGeoProcFactory::Make(target->caps().shaderCaps(),
|
||||
GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Make(
|
||||
target->allocator(),
|
||||
target->caps().shaderCaps(),
|
||||
Color::kPremulGrColorAttribute_Type,
|
||||
Coverage::kSolid_Type,
|
||||
fHasLocalRect ? LocalCoords::kHasExplicit_Type
|
||||
@ -161,7 +162,7 @@ private:
|
||||
mesh->setIndexed(indexBuffer, 6, firstIndex, 0, 3, GrPrimitiveRestart::kNo);
|
||||
mesh->setVertexData(vertexBuffer, firstVertex);
|
||||
|
||||
target->recordDraw(std::move(gp), mesh, 1, GrPrimitiveType::kTriangles);
|
||||
target->recordDraw(gp, mesh, 1, GrPrimitiveType::kTriangles);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
|
@ -57,24 +57,10 @@ private:
|
||||
void onPrepareDraws(Target* target) override {
|
||||
class GP : public GrGeometryProcessor {
|
||||
public:
|
||||
GP(int numAttribs) : INHERITED(kGP_ClassID), fNumAttribs(numAttribs) {
|
||||
SkASSERT(numAttribs > 1);
|
||||
fAttribNames.reset(new SkString[numAttribs]);
|
||||
fAttributes.reset(new Attribute[numAttribs]);
|
||||
for (auto i = 0; i < numAttribs; ++i) {
|
||||
fAttribNames[i].printf("attr%d", i);
|
||||
// This gives us more of a mix of attribute types, and allows the
|
||||
// component count to fit within the limits for iOS Metal.
|
||||
if (i & 0x1) {
|
||||
fAttributes[i] = {fAttribNames[i].c_str(), kFloat_GrVertexAttribType,
|
||||
kFloat_GrSLType};
|
||||
} else {
|
||||
fAttributes[i] = {fAttribNames[i].c_str(), kFloat2_GrVertexAttribType,
|
||||
kFloat2_GrSLType};
|
||||
}
|
||||
}
|
||||
this->setVertexAttributes(fAttributes.get(), numAttribs);
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena, int numAttribs) {
|
||||
return arena->make<GP>(numAttribs);
|
||||
}
|
||||
|
||||
const char* name() const override { return "Dummy GP"; }
|
||||
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override {
|
||||
@ -101,18 +87,40 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::SkArenaAlloc; // for access to ctor
|
||||
|
||||
GP(int numAttribs) : INHERITED(kGP_ClassID), fNumAttribs(numAttribs) {
|
||||
SkASSERT(numAttribs > 1);
|
||||
fAttribNames.reset(new SkString[numAttribs]);
|
||||
fAttributes.reset(new Attribute[numAttribs]);
|
||||
for (auto i = 0; i < numAttribs; ++i) {
|
||||
fAttribNames[i].printf("attr%d", i);
|
||||
// This gives us more of a mix of attribute types, and allows the
|
||||
// component count to fit within the limits for iOS Metal.
|
||||
if (i & 0x1) {
|
||||
fAttributes[i] = {fAttribNames[i].c_str(), kFloat_GrVertexAttribType,
|
||||
kFloat_GrSLType};
|
||||
} else {
|
||||
fAttributes[i] = {fAttribNames[i].c_str(), kFloat2_GrVertexAttribType,
|
||||
kFloat2_GrSLType};
|
||||
}
|
||||
}
|
||||
this->setVertexAttributes(fAttributes.get(), numAttribs);
|
||||
}
|
||||
|
||||
int fNumAttribs;
|
||||
std::unique_ptr<SkString[]> fAttribNames;
|
||||
std::unique_ptr<Attribute[]> fAttributes;
|
||||
|
||||
typedef GrGeometryProcessor INHERITED;
|
||||
};
|
||||
sk_sp<GrGeometryProcessor> gp(new GP(fNumAttribs));
|
||||
|
||||
GrGeometryProcessor* gp = GP::Make(target->allocator(), fNumAttribs);
|
||||
size_t vertexStride = gp->vertexStride();
|
||||
QuadHelper helper(target, vertexStride, 1);
|
||||
SkPoint* vertices = reinterpret_cast<SkPoint*>(helper.vertices());
|
||||
SkPointPriv::SetRectTriStrip(vertices, 0.f, 0.f, 1.f, 1.f, vertexStride);
|
||||
helper.recordDraw(target, std::move(gp));
|
||||
helper.recordDraw(target, gp);
|
||||
}
|
||||
|
||||
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
|
||||
|
Loading…
Reference in New Issue
Block a user