GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& origSkPath, const GrStrokeInfo& origStroke) : INHERITED(gpu, origSkPath, origStroke), fPathID(gpu->glPathRendering()->genPaths(1)) { // Convert a dashing to either a stroke or a fill. const SkPath* skPath = &origSkPath; SkTLazy<SkPath> tmpPath; const GrStrokeInfo* stroke = &origStroke; GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle); if (stroke->isDashed()) { if (stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) { skPath = tmpPath.get(); stroke = &tmpStroke; } } InitPathObject(gpu, fPathID, *skPath, *stroke); fShouldStroke = stroke->needToApply(); fShouldFill = stroke->isFillStyle() || stroke->getStyle() == SkStrokeRec::kStrokeAndFill_Style; if (fShouldStroke) { // FIXME: try to account for stroking, without rasterizing the stroke. fBounds.outset(stroke->getWidth(), stroke->getWidth()); } this->registerWithCache(); }
GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& origSkPath, const GrStrokeInfo& origStroke) : INHERITED(gpu, origSkPath, origStroke), fPathID(gpu->glPathRendering()->genPaths(1)) { if (origSkPath.isEmpty()) { InitPathObjectEmptyPath(gpu, fPathID); fShouldStroke = false; fShouldFill = false; } else { const SkPath* skPath = &origSkPath; SkTLazy<SkPath> tmpPath; const GrStrokeInfo* stroke = &origStroke; GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle); if (stroke->isDashed()) { // Skia stroking and NVPR stroking differ with respect to dashing // pattern. // Convert a dashing to either a stroke or a fill. if (stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) { skPath = tmpPath.get(); stroke = &tmpStroke; } } bool didInit = false; if (stroke->needToApply() && stroke->getCap() != SkPaint::kButt_Cap) { // Skia stroking and NVPR stroking differ with respect to stroking // end caps of empty subpaths. // Convert stroke to fill if path contains empty subpaths. didInit = InitPathObjectPathDataCheckingDegenerates(gpu, fPathID, *skPath); if (!didInit) { if (!tmpPath.isValid()) { tmpPath.init(); } SkAssertResult(stroke->applyToPath(tmpPath.get(), *skPath)); skPath = tmpPath.get(); tmpStroke.setFillStyle(); stroke = &tmpStroke; } } if (!didInit) { InitPathObjectPathData(gpu, fPathID, *skPath); } fShouldStroke = stroke->needToApply(); fShouldFill = stroke->isFillStyle() || stroke->getStyle() == SkStrokeRec::kStrokeAndFill_Style; if (fShouldStroke) { InitPathObjectStroke(gpu, fPathID, *stroke); // FIXME: try to account for stroking, without rasterizing the stroke. fBounds.outset(stroke->getWidth(), stroke->getWidth()); } } this->registerWithCache(); }
void GrGLPathRange::onInitPath(int index, const SkPath& origSkPath) const { GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu()); if (NULL == gpu) { return; } // Make sure the path at this index hasn't been initted already. SkDEBUGCODE( GrGLboolean isPath; GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index))); SkASSERT(GR_GL_FALSE == isPath); const SkPath* skPath = &origSkPath; SkTLazy<SkPath> tmpPath; const GrStrokeInfo* stroke = &fStroke; GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle); // Dashing must be applied to the path. However, if dashing is present, // we must convert all the paths to fills. The GrStrokeInfo::applyDash leaves // simple paths as strokes but converts other paths to fills. // Thus we must stroke the strokes here, so that all paths in the // path range are using the same style. if (fStroke.isDashed()) { if (!stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) { return; } skPath = tmpPath.get(); stroke = &tmpStroke; if (tmpStroke.needToApply()) { if (!tmpStroke.applyToPath(tmpPath.get(), *tmpPath.get())) { return; } tmpStroke.setFillStyle(); } } GrGLPath::InitPathObject(gpu, fBasePathID + index, *skPath, *stroke); // TODO: Use a better approximation for the individual path sizes. fGpuMemorySize += 100; }