Revert of Use new API everywhere for GrDefaultGeoProcFactory (patchset #5 id:80001 of https://codereview.chromium.org/1261083003/)
Reason for revert: breaking things Original issue's description: > Use new API everywhere for GrDefaultGeoProcFactory > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/801823b3d825d96baadeb9077c5ed1a8ada05cf2 TBR=robertphillips@google.com,bsalomon@google.com,joshualitt@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1264283004
This commit is contained in:
parent
801823b3d8
commit
e494a58de3
@ -147,7 +147,6 @@ protected:
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget();
|
||||
if (NULL == rt) {
|
||||
this->drawGpuOnlyMessage(canvas);
|
||||
@ -158,11 +157,10 @@ protected:
|
||||
return;
|
||||
}
|
||||
|
||||
Color color(0xff000000);
|
||||
Coverage coverage(Coverage::kSolid_Type);
|
||||
LocalCoords localCoords(LocalCoords::kUnused_Type);
|
||||
static const GrColor color = 0xff000000;
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I()));
|
||||
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, color,
|
||||
false, false));
|
||||
|
||||
SkScalar y = 0;
|
||||
for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_IterStart);
|
||||
@ -193,7 +191,7 @@ protected:
|
||||
pipelineBuilder.setRenderTarget(rt);
|
||||
|
||||
ConvexPolyTestBatch::Geometry geometry;
|
||||
geometry.fColor = color.fColor;
|
||||
geometry.fColor = color;
|
||||
geometry.fBounds = p.getBounds();
|
||||
|
||||
SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));
|
||||
@ -242,7 +240,7 @@ protected:
|
||||
pipelineBuilder.setRenderTarget(rt);
|
||||
|
||||
ConvexPolyTestBatch::Geometry geometry;
|
||||
geometry.fColor = color.fColor;
|
||||
geometry.fColor = color;
|
||||
geometry.fBounds = rect;
|
||||
|
||||
SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));
|
||||
|
@ -718,24 +718,16 @@ static void extract_verts(const GrAAConvexTessellator& tess,
|
||||
}
|
||||
|
||||
static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored) {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
|
||||
Color color(Color::kAttribute_Type);
|
||||
Coverage::Type coverageType;
|
||||
if (coverageIgnored) {
|
||||
coverageType = Coverage::kNone_Type;
|
||||
} else if (tweakAlphaForCoverage) {
|
||||
coverageType = Coverage::kSolid_Type;
|
||||
} else {
|
||||
coverageType = Coverage::kAttribute_Type;
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
|
||||
if (!tweakAlphaForCoverage) {
|
||||
flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
|
||||
}
|
||||
Coverage coverage(coverageType);
|
||||
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
|
||||
LocalCoords::kUnused_Type);
|
||||
return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
|
||||
|
||||
return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
|
||||
SkMatrix::I(), localMatrix);
|
||||
}
|
||||
|
||||
class AAConvexPathBatch : public GrBatch {
|
||||
@ -779,16 +771,18 @@ public:
|
||||
void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) {
|
||||
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
|
||||
|
||||
// Setup GrGeometryProcessor
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
|
||||
this->viewMatrix(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
if (!gp) {
|
||||
SkDebugf("Could not create GrGeometryProcessor\n");
|
||||
SkMatrix invert;
|
||||
if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
|
||||
SkDebugf("Could not invert viewmatrix\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup GrGeometryProcessor
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
create_fill_gp(canTweakAlphaForCoverage, invert,
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
|
@ -807,18 +807,18 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
|
||||
toSrc = &invert;
|
||||
}
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> lineGP;
|
||||
{
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
// Setup geometry processors for worst case
|
||||
uint32_t gpFlags = GrDefaultGeoProcFactory::kPosition_GPType |
|
||||
GrDefaultGeoProcFactory::kCoverage_GPType;
|
||||
|
||||
Color color(this->color());
|
||||
Coverage coverage(Coverage::kAttribute_Type);
|
||||
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
|
||||
LocalCoords::kUnused_Type);
|
||||
localCoords.fMatrix = geometryProcessorLocalM;
|
||||
lineGP.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
|
||||
*geometryProcessorViewM));
|
||||
}
|
||||
SkAutoTUnref<const GrGeometryProcessor> lineGP(
|
||||
GrDefaultGeoProcFactory::Create(gpFlags,
|
||||
this->color(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored(),
|
||||
*geometryProcessorViewM,
|
||||
*geometryProcessorLocalM,
|
||||
this->coverage()));
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> quadGP(
|
||||
GrQuadEffect::Create(this->color(),
|
||||
|
@ -93,24 +93,16 @@ static void extract_verts(const GrAAConvexTessellator& tess,
|
||||
}
|
||||
|
||||
static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored) {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
|
||||
Color color(Color::kAttribute_Type);
|
||||
Coverage::Type coverageType;
|
||||
if (coverageIgnored) {
|
||||
coverageType = Coverage::kNone_Type;
|
||||
} else if (tweakAlphaForCoverage) {
|
||||
coverageType = Coverage::kSolid_Type;
|
||||
} else {
|
||||
coverageType = Coverage::kAttribute_Type;
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
|
||||
if (!tweakAlphaForCoverage) {
|
||||
flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
|
||||
}
|
||||
Coverage coverage(coverageType);
|
||||
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
|
||||
LocalCoords::kUnused_Type);
|
||||
return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
|
||||
|
||||
return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
|
||||
SkMatrix::I(), localMatrix);
|
||||
}
|
||||
|
||||
class AAFlatteningConvexPathBatch : public GrBatch {
|
||||
@ -186,16 +178,18 @@ public:
|
||||
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
|
||||
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
|
||||
|
||||
// Setup GrGeometryProcessor
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
|
||||
this->viewMatrix(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
if (!gp) {
|
||||
SkDebugf("Couldn't create a GrGeometryProcessor\n");
|
||||
SkMatrix invert;
|
||||
if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
|
||||
SkDebugf("Could not invert viewmatrix\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup GrGeometryProcessor
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
create_fill_gp(canTweakAlphaForCoverage, invert,
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
|
@ -32,24 +32,20 @@ static void set_inset_fan(SkPoint* pts, size_t stride,
|
||||
}
|
||||
|
||||
static const GrGeometryProcessor* create_fill_rect_gp(bool tweakAlphaForCoverage,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords,
|
||||
bool coverageIgnored) {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
|
||||
Color color(Color::kAttribute_Type);
|
||||
Coverage::Type coverageType;
|
||||
if (coverageIgnored) {
|
||||
coverageType = Coverage::kNone_Type;
|
||||
} else if (tweakAlphaForCoverage) {
|
||||
coverageType = Coverage::kSolid_Type;
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
|
||||
const GrGeometryProcessor* gp;
|
||||
if (tweakAlphaForCoverage) {
|
||||
gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
|
||||
SkMatrix::I(), localMatrix);
|
||||
} else {
|
||||
coverageType = Coverage::kAttribute_Type;
|
||||
flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
|
||||
gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
|
||||
SkMatrix::I(), localMatrix);
|
||||
}
|
||||
Coverage coverage(coverageType);
|
||||
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
|
||||
LocalCoords::kUnused_Type);
|
||||
return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
|
||||
return gp;
|
||||
}
|
||||
|
||||
GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
|
||||
@ -96,15 +92,17 @@ public:
|
||||
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
|
||||
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
|
||||
this->viewMatrix(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
if (!gp) {
|
||||
SkDebugf("Couldn't create GrGeometryProcessor\n");
|
||||
SkMatrix localMatrix;
|
||||
if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) {
|
||||
SkDebugf("Cannot invert\n");
|
||||
return;
|
||||
}
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
|
||||
localMatrix,
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
@ -446,15 +444,19 @@ public:
|
||||
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
|
||||
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
|
||||
this->viewMatrix(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
if (!gp) {
|
||||
SkDebugf("Couldn't create GrGeometryProcessor\n");
|
||||
// Local matrix is ignored if we don't have local coords. If we have localcoords we only
|
||||
// batch with identical view matrices
|
||||
SkMatrix localMatrix;
|
||||
if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) {
|
||||
SkDebugf("Cannot invert\n");
|
||||
return;
|
||||
}
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
|
||||
localMatrix,
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
|
@ -258,6 +258,22 @@ GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||
GrRandomCoverage(d->fRandom));
|
||||
}
|
||||
|
||||
const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags,
|
||||
GrColor color,
|
||||
bool localCoordsWillBeRead,
|
||||
bool coverageWillBeIgnored,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
uint8_t coverage) {
|
||||
return DefaultGeoProc::Create(gpTypeFlags,
|
||||
color,
|
||||
viewMatrix,
|
||||
localMatrix,
|
||||
localCoordsWillBeRead,
|
||||
coverageWillBeIgnored,
|
||||
coverage);
|
||||
}
|
||||
|
||||
const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color,
|
||||
const Coverage& coverage,
|
||||
const LocalCoords& localCoords,
|
||||
@ -286,19 +302,17 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace(
|
||||
const Coverage& coverage,
|
||||
const LocalCoords& localCoords,
|
||||
const SkMatrix& viewMatrix) {
|
||||
SkASSERT(LocalCoords::kUsePosition_Type == localCoords.fType);
|
||||
SkMatrix invert = SkMatrix::I();
|
||||
if (LocalCoords::kUnused_Type != localCoords.fType) {
|
||||
SkASSERT(LocalCoords::kUsePosition_Type == localCoords.fType);
|
||||
if (!viewMatrix.isIdentity() && !viewMatrix.invert(&invert)) {
|
||||
SkDebugf("Could not invert\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!viewMatrix.isIdentity() && !viewMatrix.invert(&invert)) {
|
||||
SkDebugf("Could not invert\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (localCoords.hasLocalMatrix()) {
|
||||
invert.preConcat(*localCoords.fMatrix);
|
||||
}
|
||||
if (localCoords.hasLocalMatrix()) {
|
||||
invert.preConcat(*localCoords.fMatrix);
|
||||
}
|
||||
|
||||
LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert);
|
||||
return Create(color, coverage, inverted, SkMatrix::I());
|
||||
return Create(color, coverage, inverted);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ namespace GrDefaultGeoProcFactory {
|
||||
const GrGeometryProcessor* Create(const Color&,
|
||||
const Coverage&,
|
||||
const LocalCoords&,
|
||||
const SkMatrix& viewMatrix);
|
||||
const SkMatrix& viewMatrix = SkMatrix::I());
|
||||
|
||||
/*
|
||||
* Use this factory to create a GrGeometryProcessor that expects a device space vertex position
|
||||
@ -139,6 +139,15 @@ namespace GrDefaultGeoProcFactory {
|
||||
const LocalCoords&,
|
||||
const SkMatrix& viewMatrix);
|
||||
|
||||
// TODO deprecate this
|
||||
const GrGeometryProcessor* Create(uint32_t gpTypeFlags,
|
||||
GrColor,
|
||||
bool localCoordsWillBeRead,
|
||||
bool coverageWillBeIgnored,
|
||||
const SkMatrix& viewMatrix = SkMatrix::I(),
|
||||
const SkMatrix& localMatrix = SkMatrix::I(),
|
||||
uint8_t coverage = 0xff);
|
||||
|
||||
inline size_t DefaultVertexStride() { return sizeof(PositionAttr); }
|
||||
};
|
||||
|
||||
|
@ -250,19 +250,14 @@ public:
|
||||
}
|
||||
|
||||
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp;
|
||||
{
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
Color color(this->color());
|
||||
Coverage coverage(this->coverage());
|
||||
if (this->coverageIgnored()) {
|
||||
coverage.fType = Coverage::kNone_Type;
|
||||
}
|
||||
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
|
||||
LocalCoords::kUnused_Type);
|
||||
gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
|
||||
this->viewMatrix()));
|
||||
}
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
|
||||
this->color(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored(),
|
||||
this->viewMatrix(),
|
||||
SkMatrix::I(),
|
||||
this->coverage()));
|
||||
|
||||
size_t vertexStride = gp->getVertexStride();
|
||||
SkASSERT(vertexStride == sizeof(SkPoint));
|
||||
|
@ -288,17 +288,13 @@ public:
|
||||
}
|
||||
|
||||
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp;
|
||||
{
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
Color color(this->color());
|
||||
Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type :
|
||||
Coverage::kNone_Type);
|
||||
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
|
||||
LocalCoords::kUnused_Type);
|
||||
gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
|
||||
this->viewMatrix()));
|
||||
}
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
|
||||
this->color(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored(),
|
||||
this->viewMatrix(),
|
||||
SkMatrix::I()));
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
@ -564,26 +560,23 @@ static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords,
|
||||
GrColor color,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool coverageIgnored) {
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
*texOffset = -1;
|
||||
*colorOffset = -1;
|
||||
Color gpColor(color);
|
||||
if (hasColors) {
|
||||
gpColor.fType = Color::kAttribute_Type;
|
||||
}
|
||||
|
||||
Coverage coverage(coverageIgnored ? Coverage::kNone_Type : Coverage::kSolid_Type);
|
||||
LocalCoords localCoords(hasLocalCoords ? LocalCoords::kHasExplicit_Type :
|
||||
LocalCoords::kUsePosition_Type);
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType;
|
||||
if (hasLocalCoords && hasColors) {
|
||||
*colorOffset = sizeof(SkPoint);
|
||||
*texOffset = sizeof(SkPoint) + sizeof(GrColor);
|
||||
flags |= GrDefaultGeoProcFactory::kColor_GPType |
|
||||
GrDefaultGeoProcFactory::kLocalCoord_GPType;
|
||||
} else if (hasLocalCoords) {
|
||||
*texOffset = sizeof(SkPoint);
|
||||
flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType;
|
||||
} else if (hasColors) {
|
||||
*colorOffset = sizeof(SkPoint);
|
||||
flags |= GrDefaultGeoProcFactory::kColor_GPType;
|
||||
}
|
||||
return GrDefaultGeoProcFactory::Create(gpColor, coverage, localCoords, viewMatrix);
|
||||
return GrDefaultGeoProcFactory::Create(flags, color, hasLocalCoords, coverageIgnored,
|
||||
viewMatrix, SkMatrix::I());
|
||||
}
|
||||
|
||||
class DrawVerticesBatch : public GrBatch {
|
||||
|
@ -183,7 +183,7 @@ private:
|
||||
// generate vertex local coords
|
||||
if (this->hasLocalRect()) {
|
||||
LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
|
||||
return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
|
||||
return GrDefaultGeoProcFactory::Create(color, coverage, localCoords);
|
||||
} else {
|
||||
LocalCoords localCoords(LocalCoords::kUsePosition_Type,
|
||||
this->hasLocalMatrix() ? &this->localMatrix() : NULL);
|
||||
|
@ -1404,24 +1404,11 @@ public:
|
||||
}
|
||||
|
||||
LOG("got %d pts, %d contours\n", maxPts, contourCnt);
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp;
|
||||
{
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
|
||||
Color color(fColor);
|
||||
LocalCoords localCoords(fPipelineInfo.readsLocalCoords() ?
|
||||
LocalCoords::kUsePosition_Type :
|
||||
LocalCoords::kUnused_Type);
|
||||
Coverage::Type coverageType;
|
||||
if (fPipelineInfo.readsCoverage()) {
|
||||
coverageType = Coverage::kSolid_Type;
|
||||
} else {
|
||||
coverageType = Coverage::kNone_Type;
|
||||
}
|
||||
Coverage coverage(coverageType);
|
||||
gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
|
||||
fViewMatrix));
|
||||
}
|
||||
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType;
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp(
|
||||
GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.readsLocalCoords(),
|
||||
!fPipelineInfo.readsCoverage(), fViewMatrix,
|
||||
SkMatrix::I()));
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
|
||||
SkAutoTDeleteArray<Vertex*> contours(SkNEW_ARRAY(Vertex *, contourCnt));
|
||||
|
@ -300,28 +300,30 @@ public:
|
||||
|
||||
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
|
||||
int instanceCount = fGeoData.count();
|
||||
|
||||
SkMatrix invert;
|
||||
if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
|
||||
SkDebugf("Failed to invert\n");
|
||||
return;
|
||||
}
|
||||
|
||||
SkPaint::Cap cap = this->cap();
|
||||
bool isRoundCap = SkPaint::kRound_Cap == cap;
|
||||
DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
|
||||
|
||||
SkAutoTUnref<const GrGeometryProcessor> gp;
|
||||
|
||||
bool isRoundCap = SkPaint::kRound_Cap == cap;
|
||||
DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
|
||||
if (this->fullDash()) {
|
||||
gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(),
|
||||
gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, invert,
|
||||
this->usesLocalCoords()));
|
||||
} else {
|
||||
// Set up the vertex data for the line and start/end dashes
|
||||
using namespace GrDefaultGeoProcFactory;
|
||||
Color color(this->color());
|
||||
Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type :
|
||||
Coverage::kSolid_Type);
|
||||
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
|
||||
LocalCoords::kUnused_Type);
|
||||
gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this->viewMatrix()));
|
||||
}
|
||||
|
||||
if (!gp) {
|
||||
SkDebugf("Could not create GrGeometryProcessor\n");
|
||||
return;
|
||||
gp.reset(GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
|
||||
this->color(),
|
||||
this->usesLocalCoords(),
|
||||
this->coverageIgnored(),
|
||||
SkMatrix::I(),
|
||||
invert));
|
||||
}
|
||||
|
||||
batchTarget->initDraw(gp, pipeline);
|
||||
@ -1207,19 +1209,15 @@ GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
|
||||
static GrGeometryProcessor* create_dash_gp(GrColor color,
|
||||
DashAAMode dashAAMode,
|
||||
DashCap cap,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMatrix& localMatrix,
|
||||
bool usesLocalCoords) {
|
||||
SkMatrix invert;
|
||||
if (usesLocalCoords && !viewMatrix.invert(&invert)) {
|
||||
SkDebugf("Failed to invert\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (cap) {
|
||||
case kRound_DashCap:
|
||||
return DashingCircleEffect::Create(color, dashAAMode, invert, usesLocalCoords);
|
||||
return DashingCircleEffect::Create(color, dashAAMode, localMatrix, usesLocalCoords);
|
||||
case kNonRound_DashCap:
|
||||
return DashingLineEffect::Create(color, dashAAMode, invert, usesLocalCoords);
|
||||
return DashingLineEffect::Create(color, dashAAMode, localMatrix, usesLocalCoords);
|
||||
default:
|
||||
SkFAIL("Unexpected dashed cap.");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user