Use new API everywhere for GrDefaultGeoProcFactory

BUG=skia:

Committed: https://skia.googlesource.com/skia/+/801823b3d825d96baadeb9077c5ed1a8ada05cf2

Review URL: https://codereview.chromium.org/1261083003
This commit is contained in:
joshualitt 2015-08-03 11:35:28 -07:00 committed by Commit bot
parent f23190078b
commit df0c557850
12 changed files with 177 additions and 158 deletions

View File

@ -147,6 +147,7 @@ protected:
} }
void onDraw(SkCanvas* canvas) override { void onDraw(SkCanvas* canvas) override {
using namespace GrDefaultGeoProcFactory;
GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget();
if (NULL == rt) { if (NULL == rt) {
this->drawGpuOnlyMessage(canvas); this->drawGpuOnlyMessage(canvas);
@ -157,10 +158,11 @@ protected:
return; return;
} }
static const GrColor color = 0xff000000; Color color(0xff000000);
Coverage coverage(Coverage::kSolid_Type);
LocalCoords localCoords(LocalCoords::kUnused_Type);
SkAutoTUnref<const GrGeometryProcessor> gp( SkAutoTUnref<const GrGeometryProcessor> gp(
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, color, GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I()));
false, false));
SkScalar y = 0; SkScalar y = 0;
for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_IterStart); for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_IterStart);
@ -191,7 +193,7 @@ protected:
pipelineBuilder.setRenderTarget(rt); pipelineBuilder.setRenderTarget(rt);
ConvexPolyTestBatch::Geometry geometry; ConvexPolyTestBatch::Geometry geometry;
geometry.fColor = color; geometry.fColor = color.fColor;
geometry.fBounds = p.getBounds(); geometry.fBounds = p.getBounds();
SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry)); SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));
@ -240,7 +242,7 @@ protected:
pipelineBuilder.setRenderTarget(rt); pipelineBuilder.setRenderTarget(rt);
ConvexPolyTestBatch::Geometry geometry; ConvexPolyTestBatch::Geometry geometry;
geometry.fColor = color; geometry.fColor = color.fColor;
geometry.fBounds = rect; geometry.fBounds = rect;
SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry)); SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));

View File

@ -718,16 +718,25 @@ static void extract_verts(const GrAAConvexTessellator& tess,
} }
static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
const SkMatrix& localMatrix, const SkMatrix& viewMatrix,
bool usesLocalCoords, bool usesLocalCoords,
bool coverageIgnored) { bool coverageIgnored) {
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; using namespace GrDefaultGeoProcFactory;
if (!tweakAlphaForCoverage) {
flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
}
return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored, Color color(Color::kAttribute_Type);
SkMatrix::I(), localMatrix); Coverage::Type coverageType;
// TODO remove coverage if coverage is ignored
/*if (coverageIgnored) {
coverageType = Coverage::kNone_Type;
} else*/ if (tweakAlphaForCoverage) {
coverageType = Coverage::kSolid_Type;
} else {
coverageType = Coverage::kAttribute_Type;
}
Coverage coverage(coverageType);
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
} }
class AAConvexPathBatch : public GrBatch { class AAConvexPathBatch : public GrBatch {
@ -771,17 +780,15 @@ public:
void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) { void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
SkMatrix invert;
if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
SkDebugf("Could not invert viewmatrix\n");
return;
}
// Setup GrGeometryProcessor // Setup GrGeometryProcessor
SkAutoTUnref<const GrGeometryProcessor> gp( SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
create_fill_gp(canTweakAlphaForCoverage, invert, this->viewMatrix(),
this->usesLocalCoords(), this->usesLocalCoords(),
this->coverageIgnored())); this->coverageIgnored()));
if (!gp) {
SkDebugf("Could not create GrGeometryProcessor\n");
return;
}
batchTarget->initDraw(gp, pipeline); batchTarget->initDraw(gp, pipeline);

View File

@ -807,18 +807,18 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
toSrc = &invert; toSrc = &invert;
} }
// Setup geometry processors for worst case SkAutoTUnref<const GrGeometryProcessor> lineGP;
uint32_t gpFlags = GrDefaultGeoProcFactory::kPosition_GPType | {
GrDefaultGeoProcFactory::kCoverage_GPType; using namespace GrDefaultGeoProcFactory;
SkAutoTUnref<const GrGeometryProcessor> lineGP( Color color(this->color());
GrDefaultGeoProcFactory::Create(gpFlags, Coverage coverage(Coverage::kAttribute_Type);
this->color(), LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
this->usesLocalCoords(), LocalCoords::kUnused_Type);
this->coverageIgnored(), localCoords.fMatrix = geometryProcessorLocalM;
*geometryProcessorViewM, lineGP.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
*geometryProcessorLocalM, *geometryProcessorViewM));
this->coverage())); }
SkAutoTUnref<const GrGeometryProcessor> quadGP( SkAutoTUnref<const GrGeometryProcessor> quadGP(
GrQuadEffect::Create(this->color(), GrQuadEffect::Create(this->color(),

View File

@ -93,16 +93,25 @@ static void extract_verts(const GrAAConvexTessellator& tess,
} }
static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
const SkMatrix& localMatrix, const SkMatrix& viewMatrix,
bool usesLocalCoords, bool usesLocalCoords,
bool coverageIgnored) { bool coverageIgnored) {
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; using namespace GrDefaultGeoProcFactory;
if (!tweakAlphaForCoverage) {
flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
}
return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored, Color color(Color::kAttribute_Type);
SkMatrix::I(), localMatrix); Coverage::Type coverageType;
// TODO remove coverage if coverage is ignored
/*if (coverageIgnored) {
coverageType = Coverage::kNone_Type;
} else*/ if (tweakAlphaForCoverage) {
coverageType = Coverage::kSolid_Type;
} else {
coverageType = Coverage::kAttribute_Type;
}
Coverage coverage(coverageType);
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
} }
class AAFlatteningConvexPathBatch : public GrBatch { class AAFlatteningConvexPathBatch : public GrBatch {
@ -178,17 +187,15 @@ public:
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
SkMatrix invert;
if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
SkDebugf("Could not invert viewmatrix\n");
return;
}
// Setup GrGeometryProcessor // Setup GrGeometryProcessor
SkAutoTUnref<const GrGeometryProcessor> gp( SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaForCoverage,
create_fill_gp(canTweakAlphaForCoverage, invert, this->viewMatrix(),
this->usesLocalCoords(), this->usesLocalCoords(),
this->coverageIgnored())); this->coverageIgnored()));
if (!gp) {
SkDebugf("Couldn't create a GrGeometryProcessor\n");
return;
}
batchTarget->initDraw(gp, pipeline); batchTarget->initDraw(gp, pipeline);

View File

@ -32,20 +32,25 @@ static void set_inset_fan(SkPoint* pts, size_t stride,
} }
static const GrGeometryProcessor* create_fill_rect_gp(bool tweakAlphaForCoverage, static const GrGeometryProcessor* create_fill_rect_gp(bool tweakAlphaForCoverage,
const SkMatrix& localMatrix, const SkMatrix& viewMatrix,
bool usesLocalCoords, bool usesLocalCoords,
bool coverageIgnored) { bool coverageIgnored) {
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; using namespace GrDefaultGeoProcFactory;
const GrGeometryProcessor* gp;
if (tweakAlphaForCoverage) { Color color(Color::kAttribute_Type);
gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored, Coverage::Type coverageType;
SkMatrix::I(), localMatrix); // TODO remove coverage if coverage is ignored
/*if (coverageIgnored) {
coverageType = Coverage::kNone_Type;
} else*/ if (tweakAlphaForCoverage) {
coverageType = Coverage::kSolid_Type;
} else { } else {
flags |= GrDefaultGeoProcFactory::kCoverage_GPType; coverageType = Coverage::kAttribute_Type;
gp = GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
SkMatrix::I(), localMatrix);
} }
return gp; Coverage coverage(coverageType);
LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix);
} }
GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey); GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
@ -92,16 +97,14 @@ public:
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
SkMatrix localMatrix;
if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) {
SkDebugf("Cannot invert\n");
return;
}
SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage, SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
localMatrix, this->viewMatrix(),
this->usesLocalCoords(), this->usesLocalCoords(),
this->coverageIgnored())); this->coverageIgnored()));
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
}
batchTarget->initDraw(gp, pipeline); batchTarget->initDraw(gp, pipeline);
@ -444,18 +447,14 @@ public:
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
// 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, SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
localMatrix, this->viewMatrix(),
this->usesLocalCoords(), this->usesLocalCoords(),
this->coverageIgnored())); this->coverageIgnored()));
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
}
batchTarget->initDraw(gp, pipeline); batchTarget->initDraw(gp, pipeline);

View File

@ -258,22 +258,6 @@ GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) {
GrRandomCoverage(d->fRandom)); 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 GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color,
const Coverage& coverage, const Coverage& coverage,
const LocalCoords& localCoords, const LocalCoords& localCoords,
@ -302,8 +286,9 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace(
const Coverage& coverage, const Coverage& coverage,
const LocalCoords& localCoords, const LocalCoords& localCoords,
const SkMatrix& viewMatrix) { const SkMatrix& viewMatrix) {
SkASSERT(LocalCoords::kUsePosition_Type == localCoords.fType);
SkMatrix invert = SkMatrix::I(); SkMatrix invert = SkMatrix::I();
if (LocalCoords::kUnused_Type != localCoords.fType) {
SkASSERT(LocalCoords::kUsePosition_Type == localCoords.fType);
if (!viewMatrix.isIdentity() && !viewMatrix.invert(&invert)) { if (!viewMatrix.isIdentity() && !viewMatrix.invert(&invert)) {
SkDebugf("Could not invert\n"); SkDebugf("Could not invert\n");
return NULL; return NULL;
@ -312,7 +297,8 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace(
if (localCoords.hasLocalMatrix()) { if (localCoords.hasLocalMatrix()) {
invert.preConcat(*localCoords.fMatrix); invert.preConcat(*localCoords.fMatrix);
} }
}
LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert);
return Create(color, coverage, inverted); return Create(color, coverage, inverted, SkMatrix::I());
} }

View File

@ -127,7 +127,7 @@ namespace GrDefaultGeoProcFactory {
const GrGeometryProcessor* Create(const Color&, const GrGeometryProcessor* Create(const Color&,
const Coverage&, const Coverage&,
const LocalCoords&, const LocalCoords&,
const SkMatrix& viewMatrix = SkMatrix::I()); const SkMatrix& viewMatrix);
/* /*
* Use this factory to create a GrGeometryProcessor that expects a device space vertex position * Use this factory to create a GrGeometryProcessor that expects a device space vertex position
@ -139,15 +139,6 @@ namespace GrDefaultGeoProcFactory {
const LocalCoords&, const LocalCoords&,
const SkMatrix& viewMatrix); 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); } inline size_t DefaultVertexStride() { return sizeof(PositionAttr); }
}; };

View File

@ -250,14 +250,19 @@ public:
} }
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
SkAutoTUnref<const GrGeometryProcessor> gp( SkAutoTUnref<const GrGeometryProcessor> gp;
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, {
this->color(), using namespace GrDefaultGeoProcFactory;
this->usesLocalCoords(), Color color(this->color());
this->coverageIgnored(), Coverage coverage(this->coverage());
this->viewMatrix(), if (this->coverageIgnored()) {
SkMatrix::I(), coverage.fType = Coverage::kNone_Type;
this->coverage())); }
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
this->viewMatrix()));
}
size_t vertexStride = gp->getVertexStride(); size_t vertexStride = gp->getVertexStride();
SkASSERT(vertexStride == sizeof(SkPoint)); SkASSERT(vertexStride == sizeof(SkPoint));

View File

@ -288,13 +288,17 @@ public:
} }
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
SkAutoTUnref<const GrGeometryProcessor> gp( SkAutoTUnref<const GrGeometryProcessor> gp;
GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, {
this->color(), using namespace GrDefaultGeoProcFactory;
this->usesLocalCoords(), Color color(this->color());
this->coverageIgnored(), Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type :
this->viewMatrix(), Coverage::kNone_Type);
SkMatrix::I())); LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
this->viewMatrix()));
}
batchTarget->initDraw(gp, pipeline); batchTarget->initDraw(gp, pipeline);
@ -560,23 +564,26 @@ static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords,
GrColor color, GrColor color,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
bool coverageIgnored) { bool coverageIgnored) {
using namespace GrDefaultGeoProcFactory;
*texOffset = -1; *texOffset = -1;
*colorOffset = -1; *colorOffset = -1;
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; 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);
if (hasLocalCoords && hasColors) { if (hasLocalCoords && hasColors) {
*colorOffset = sizeof(SkPoint); *colorOffset = sizeof(SkPoint);
*texOffset = sizeof(SkPoint) + sizeof(GrColor); *texOffset = sizeof(SkPoint) + sizeof(GrColor);
flags |= GrDefaultGeoProcFactory::kColor_GPType |
GrDefaultGeoProcFactory::kLocalCoord_GPType;
} else if (hasLocalCoords) { } else if (hasLocalCoords) {
*texOffset = sizeof(SkPoint); *texOffset = sizeof(SkPoint);
flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType;
} else if (hasColors) { } else if (hasColors) {
*colorOffset = sizeof(SkPoint); *colorOffset = sizeof(SkPoint);
flags |= GrDefaultGeoProcFactory::kColor_GPType;
} }
return GrDefaultGeoProcFactory::Create(flags, color, hasLocalCoords, coverageIgnored, return GrDefaultGeoProcFactory::Create(gpColor, coverage, localCoords, viewMatrix);
viewMatrix, SkMatrix::I());
} }
class DrawVerticesBatch : public GrBatch { class DrawVerticesBatch : public GrBatch {

View File

@ -183,7 +183,7 @@ private:
// generate vertex local coords // generate vertex local coords
if (this->hasLocalRect()) { if (this->hasLocalRect()) {
LocalCoords localCoords(LocalCoords::kHasExplicit_Type); LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
return GrDefaultGeoProcFactory::Create(color, coverage, localCoords); return GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatrix::I());
} else { } else {
LocalCoords localCoords(LocalCoords::kUsePosition_Type, LocalCoords localCoords(LocalCoords::kUsePosition_Type,
this->hasLocalMatrix() ? &this->localMatrix() : NULL); this->hasLocalMatrix() ? &this->localMatrix() : NULL);

View File

@ -1404,11 +1404,24 @@ public:
} }
LOG("got %d pts, %d contours\n", maxPts, contourCnt); LOG("got %d pts, %d contours\n", maxPts, contourCnt);
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; SkAutoTUnref<const GrGeometryProcessor> gp;
SkAutoTUnref<const GrGeometryProcessor> gp( {
GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.readsLocalCoords(), using namespace GrDefaultGeoProcFactory;
!fPipelineInfo.readsCoverage(), fViewMatrix,
SkMatrix::I())); 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));
}
batchTarget->initDraw(gp, pipeline); batchTarget->initDraw(gp, pipeline);
SkAutoTDeleteArray<Vertex*> contours(SkNEW_ARRAY(Vertex *, contourCnt)); SkAutoTDeleteArray<Vertex*> contours(SkNEW_ARRAY(Vertex *, contourCnt));

View File

@ -300,30 +300,28 @@ public:
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
int instanceCount = fGeoData.count(); int instanceCount = fGeoData.count();
SkMatrix invert;
if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
SkDebugf("Failed to invert\n");
return;
}
SkPaint::Cap cap = this->cap(); SkPaint::Cap cap = this->cap();
SkAutoTUnref<const GrGeometryProcessor> gp;
bool isRoundCap = SkPaint::kRound_Cap == cap; bool isRoundCap = SkPaint::kRound_Cap == cap;
DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap; DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
SkAutoTUnref<const GrGeometryProcessor> gp;
if (this->fullDash()) { if (this->fullDash()) {
gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, invert, gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(),
this->usesLocalCoords())); this->usesLocalCoords()));
} else { } else {
// Set up the vertex data for the line and start/end dashes // Set up the vertex data for the line and start/end dashes
gp.reset(GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType, using namespace GrDefaultGeoProcFactory;
this->color(), Color color(this->color());
this->usesLocalCoords(), Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type :
this->coverageIgnored(), Coverage::kSolid_Type);
SkMatrix::I(), LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
invert)); LocalCoords::kUnused_Type);
gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this->viewMatrix()));
}
if (!gp) {
SkDebugf("Could not create GrGeometryProcessor\n");
return;
} }
batchTarget->initDraw(gp, pipeline); batchTarget->initDraw(gp, pipeline);
@ -1209,15 +1207,19 @@ GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
static GrGeometryProcessor* create_dash_gp(GrColor color, static GrGeometryProcessor* create_dash_gp(GrColor color,
DashAAMode dashAAMode, DashAAMode dashAAMode,
DashCap cap, DashCap cap,
const SkMatrix& localMatrix, const SkMatrix& viewMatrix,
bool usesLocalCoords) { bool usesLocalCoords) {
SkMatrix invert;
if (usesLocalCoords && !viewMatrix.invert(&invert)) {
SkDebugf("Failed to invert\n");
return NULL;
}
switch (cap) { switch (cap) {
case kRound_DashCap: case kRound_DashCap:
return DashingCircleEffect::Create(color, dashAAMode, localMatrix, usesLocalCoords); return DashingCircleEffect::Create(color, dashAAMode, invert, usesLocalCoords);
case kNonRound_DashCap: case kNonRound_DashCap:
return DashingLineEffect::Create(color, dashAAMode, localMatrix, usesLocalCoords); return DashingLineEffect::Create(color, dashAAMode, invert, usesLocalCoords);
default:
SkFAIL("Unexpected dashed cap.");
} }
return NULL; return NULL;
} }