| Index: src/gpu/gl/GrGLPathRange.cpp
|
| diff --git a/src/gpu/gl/GrGLPathRange.cpp b/src/gpu/gl/GrGLPathRange.cpp
|
| index d7ccf1bcc74664673bb079bd2a1c34202bdf8452..b577d896192d41cf1c07c0374f10d51f897412f3 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,27 @@ 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 {
|
| + fShouldStroke = fStroke.needToApply();
|
| + fShouldFill = fStroke.isFillStyle() ||
|
| + fStroke.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 +56,31 @@ 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(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;
|
|
|