| Index: src/gpu/gl/GrGLPathRange.cpp
|
| diff --git a/src/gpu/gl/GrGLPathRange.cpp b/src/gpu/gl/GrGLPathRange.cpp
|
| index d7ccf1bcc74664673bb079bd2a1c34202bdf8452..3840840c370b6b0bb8afd9fc47a09abed1f09ae9 100644
|
| --- a/src/gpu/gl/GrGLPathRange.cpp
|
| +++ b/src/gpu/gl/GrGLPathRange.cpp
|
| @@ -11,10 +11,12 @@
|
| #include "GrGLPathRendering.h"
|
| #include "GrGLGpu.h"
|
|
|
| -GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const SkStrokeRec& stroke)
|
| - : INHERITED(gpu, pathGenerator, stroke),
|
| +GrGLPathRange::GrGLPathRange(GrGLGpu* gpu, PathGenerator* pathGenerator, const GrStrokeInfo& stroke)
|
| + : INHERITED(gpu, pathGenerator),
|
| + fStroke(stroke),
|
| fBasePathID(gpu->glPathRendering()->genPaths(this->getNumPaths())),
|
| fGpuMemorySize(0) {
|
| + this->init();
|
| this->registerWithCache();
|
| }
|
|
|
| @@ -22,14 +24,28 @@ GrGLPathRange::GrGLPathRange(GrGLGpu* gpu,
|
| GrGLuint basePathID,
|
| int numPaths,
|
| size_t gpuMemorySize,
|
| - const SkStrokeRec& stroke)
|
| - : INHERITED(gpu, numPaths, stroke),
|
| + const GrStrokeInfo& stroke)
|
| + : INHERITED(gpu, numPaths),
|
| + fStroke(stroke),
|
| fBasePathID(basePathID),
|
| fGpuMemorySize(gpuMemorySize) {
|
| + this->init();
|
| this->registerWithCache();
|
| }
|
|
|
| -void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const {
|
| +void GrGLPathRange::init() {
|
| + if (fStroke.isDashed()) {
|
| + fShouldStroke = false;
|
| + fShouldFill = true;
|
| + } else {
|
| + const SkStrokeRec& strokeRec = fStroke.getStrokeRec();
|
| + fShouldStroke = strokeRec.needToApply();
|
| + fShouldFill = fStroke.isFillStyle() ||
|
| + strokeRec.getStyle() == SkStrokeRec::kStrokeAndFill_Style;
|
| + }
|
| +}
|
| +
|
| +void GrGLPathRange::onInitPath(int index, const SkPath& origSkPath) const {
|
| GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu());
|
| if (NULL == gpu) {
|
| return;
|
| @@ -41,7 +57,32 @@ void GrGLPathRange::onInitPath(int index, const SkPath& skPath) const {
|
| GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index)));
|
| SkASSERT(GR_GL_FALSE == isPath);
|
|
|
| - GrGLPath::InitPathObject(gpu, fBasePathID + index, skPath, this->getStroke());
|
| + const SkPath* skPath = &origSkPath;
|
| + SkTLazy<SkPath> tmpPath;
|
| + const GrStrokeInfo* stroke = &fStroke;
|
| + GrStrokeInfo tmpStroke(fStroke, false);
|
| +
|
| + // 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->applyDash(tmpPath.init(), &tmpStroke, *skPath)) {
|
| + return;
|
| + }
|
| + skPath = tmpPath.get();
|
| + stroke = &tmpStroke;
|
| + if (tmpStroke.getStrokeRec().needToApply()) {
|
| + SkStrokeRec* strokeRec = tmpStroke.getStrokeRecPtr();
|
| + if (!strokeRec->applyToPath(tmpPath.get(), *tmpPath.get())) {
|
| + return;
|
| + }
|
| + strokeRec->setFillStyle();
|
| + }
|
| + }
|
| +
|
| + GrGLPath::InitPathObject(gpu, fBasePathID + index, *skPath, *stroke);
|
|
|
| // TODO: Use a better approximation for the individual path sizes.
|
| fGpuMemorySize += 100;
|
|
|