Avoid unnecessary GrShape->SkPath conversion in GrStencilAndCoverPathRenderer

Also remove redundant param to the path batch constructor.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2348543002

Review-Url: https://codereview.chromium.org/2348543002
This commit is contained in:
bsalomon 2016-10-03 09:48:22 -07:00 committed by Commit bot
parent 01015fbea1
commit a224bb7027
2 changed files with 9 additions and 13 deletions

View File

@ -64,9 +64,8 @@ class GrDrawPathBatch final : public GrDrawPathBatchBase {
public:
DEFINE_BATCH_CLASS_ID
static GrDrawBatch* Create(const SkMatrix& viewMatrix, GrColor color,
GrPathRendering::FillType fill, const GrPath* path) {
return new GrDrawPathBatch(viewMatrix, color, fill, path);
static GrDrawBatch* Create(const SkMatrix& viewMatrix, GrColor color, const GrPath* path) {
return new GrDrawPathBatch(viewMatrix, color, path);
}
const char* name() const override { return "DrawPath"; }
@ -74,9 +73,8 @@ public:
SkString dumpInfo() const override;
private:
GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, GrPathRendering::FillType fill,
const GrPath* path)
: INHERITED(ClassID(), viewMatrix, color, fill)
GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, const GrPath* path)
: INHERITED(ClassID(), viewMatrix, color, path->getFillType())
, fPath(path) {
this->setTransformedBounds(path->getBounds(), viewMatrix, HasAABloat::kNo, IsZeroArea::kNo);
}

View File

@ -94,12 +94,10 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
const SkMatrix& viewMatrix = *args.fViewMatrix;
SkPath path;
args.fShape->asPath(&path);
SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fShape));
SkAutoTUnref<GrPath> path(get_gr_path(fResourceProvider, *args.fShape));
if (path.isInverseFillType()) {
if (args.fShape->inverseFilled()) {
SkMatrix invert = SkMatrix::I();
SkRect bounds =
SkRect::MakeLTRB(0, 0,
@ -126,7 +124,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
// fake inverse with a stencil and cover
args.fDrawContext->drawContextPriv().stencilPath(*args.fClip, args.fPaint->isAntiAlias(),
viewMatrix, p);
viewMatrix, path);
{
static constexpr GrUserStencilSettings kInvertedCoverPass(
@ -160,8 +158,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
0xffff>()
);
SkAutoTUnref<GrDrawBatch> batch(
GrDrawPathBatch::Create(viewMatrix, args.fPaint->getColor(), p->getFillType(), p));
SkAutoTUnref<GrDrawBatch> batch(GrDrawPathBatch::Create(viewMatrix, args.fPaint->getColor(),
path));
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fPaint->isAntiAlias());
pipelineBuilder.setUserStencil(&kCoverPass);