| Index: src/gpu/gl/GrGpuGL.cpp
|
| diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
|
| index eddccc39f67e626a0beb814cd4016a5ce6e8bf0b..6d15430ee28416dc9fa164a560e73c4fe796eddb 100644
|
| --- a/src/gpu/gl/GrGpuGL.cpp
|
| +++ b/src/gpu/gl/GrGpuGL.cpp
|
| @@ -10,6 +10,7 @@
|
| #include "GrGLNameAllocator.h"
|
| #include "GrGLStencilBuffer.h"
|
| #include "GrGLPath.h"
|
| +#include "GrGLPathRange.h"
|
| #include "GrGLShaderBuilder.h"
|
| #include "GrTemplates.h"
|
| #include "GrTypes.h"
|
| @@ -34,6 +35,21 @@
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| +static const GrGLenum gXformFormat2GLType[] = {
|
| + GR_GL_NONE,
|
| + GR_GL_TRANSLATE_X,
|
| + GR_GL_TRANSLATE_Y,
|
| + GR_GL_TRANSLATE_2D,
|
| + GR_GL_TRANSPOSE_AFFINE_2D
|
| +};
|
| +
|
| +GR_STATIC_ASSERT(0 == kNone_GrTransformFormat);
|
| +GR_STATIC_ASSERT(1 == kTranslateX_GrTransformFormat);
|
| +GR_STATIC_ASSERT(2 == kTranslateY_GrTransformFormat);
|
| +GR_STATIC_ASSERT(3 == kTranslate_GrTransformFormat);
|
| +GR_STATIC_ASSERT(4 == kAffine_GrTransformFormat);
|
| +GR_STATIC_ASSERT(kAffine_GrTransformFormat == kLast_GrTransformFormat);
|
| +
|
| static const GrGLenum gXfermodeCoeff2Blend[] = {
|
| GR_GL_ZERO,
|
| GR_GL_ONE,
|
| @@ -1362,6 +1378,11 @@ GrPath* GrGpuGL::onCreatePath(const SkPath& inPath, const SkStrokeRec& stroke) {
|
| return SkNEW_ARGS(GrGLPath, (this, inPath, stroke));
|
| }
|
|
|
| +GrPathRange* GrGpuGL::onCreatePathRange(size_t size, const SkStrokeRec& stroke) {
|
| + SkASSERT(this->caps()->pathRenderingSupport());
|
| + return SkNEW_ARGS(GrGLPathRange, (this, size, stroke));
|
| +}
|
| +
|
| void GrGpuGL::flushScissor() {
|
| if (fScissorState.fEnabled) {
|
| // Only access the RT if scissoring is being enabled. We can call this before performing
|
| @@ -1900,35 +1921,20 @@ void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) {
|
| }
|
| }
|
|
|
| -void GrGpuGL::onGpuDrawPaths(int pathCount, const GrPath** paths,
|
| - const SkMatrix* transforms,
|
| - SkPath::FillType fill,
|
| - SkStrokeRec::Style stroke) {
|
| +void GrGpuGL::onGpuDrawPaths(const GrPathRange* pathRange,
|
| + const uint32_t indices[], int count,
|
| + const float transforms[], GrTransformFormat transformsFormat,
|
| + SkPath::FillType fill) {
|
| SkASSERT(this->caps()->pathRenderingSupport());
|
| SkASSERT(NULL != this->drawState()->getRenderTarget());
|
| SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer());
|
| SkASSERT(!fCurrentProgram->hasVertexShader());
|
| - SkASSERT(stroke != SkStrokeRec::kHairline_Style);
|
| -
|
| - SkAutoMalloc pathData(pathCount * sizeof(GrGLuint));
|
| - SkAutoMalloc transformData(pathCount * sizeof(GrGLfloat) * 6);
|
| - GrGLfloat* transformValues =
|
| - reinterpret_cast<GrGLfloat*>(transformData.get());
|
| - GrGLuint* pathIDs = reinterpret_cast<GrGLuint*>(pathData.get());
|
| -
|
| - for (int i = 0; i < pathCount; ++i) {
|
| - SkASSERT(transforms[i].asAffine(NULL));
|
| - const SkMatrix& m = transforms[i];
|
| - transformValues[i * 6] = m.getScaleX();
|
| - transformValues[i * 6 + 1] = m.getSkewY();
|
| - transformValues[i * 6 + 2] = m.getSkewX();
|
| - transformValues[i * 6 + 3] = m.getScaleY();
|
| - transformValues[i * 6 + 4] = m.getTranslateX();
|
| - transformValues[i * 6 + 5] = m.getTranslateY();
|
| - pathIDs[i] = static_cast<const GrGLPath*>(paths[i])->pathID();
|
| - }
|
| +
|
| + GrGLuint baseID = static_cast<const GrGLPathRange*>(pathRange)->basePathID();
|
|
|
| flushPathStencilSettings(fill);
|
| + const SkStrokeRec& stroke = pathRange->getStroke();
|
| + SkASSERT(!stroke.isHairlineStyle());
|
|
|
| SkPath::FillType nonInvertedFill =
|
| SkPath::ConvertToNonInverseFillType(fill);
|
| @@ -1940,36 +1946,28 @@ void GrGpuGL::onGpuDrawPaths(int pathCount, const GrPath** paths,
|
| GrGLint writeMask =
|
| fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
|
|
|
| - bool doFill = stroke == SkStrokeRec::kFill_Style
|
| - || stroke == SkStrokeRec::kStrokeAndFill_Style;
|
| - bool doStroke = stroke == SkStrokeRec::kStroke_Style
|
| - || stroke == SkStrokeRec::kStrokeAndFill_Style;
|
| -
|
| - if (doFill) {
|
| - GL_CALL(StencilFillPathInstanced(pathCount, GR_GL_UNSIGNED_INT,
|
| - pathIDs, 0,
|
| - fillMode, writeMask,
|
| - GR_GL_AFFINE_2D, transformValues));
|
| + if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) {
|
| + GL_CALL(StencilFillPathInstanced(count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode,
|
| + writeMask, gXformFormat2GLType[transformsFormat],
|
| + transforms));
|
| }
|
| - if (doStroke) {
|
| - GL_CALL(StencilStrokePathInstanced(pathCount, GR_GL_UNSIGNED_INT,
|
| - pathIDs, 0,
|
| - 0xffff, writeMask,
|
| - GR_GL_AFFINE_2D, transformValues));
|
| + if (stroke.needToApply()) {
|
| + GL_CALL(StencilStrokePathInstanced(count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff,
|
| + writeMask, gXformFormat2GLType[transformsFormat],
|
| + transforms));
|
| }
|
|
|
| if (nonInvertedFill == fill) {
|
| - if (doStroke) {
|
| + if (stroke.needToApply()) {
|
| GL_CALL(CoverStrokePathInstanced(
|
| - pathCount, GR_GL_UNSIGNED_INT, pathIDs, 0,
|
| + count, GR_GL_UNSIGNED_INT, indices, baseID,
|
| GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES,
|
| - GR_GL_AFFINE_2D, transformValues));
|
| + gXformFormat2GLType[transformsFormat], transforms));
|
| } else {
|
| GL_CALL(CoverFillPathInstanced(
|
| - pathCount, GR_GL_UNSIGNED_INT, pathIDs, 0,
|
| + count, GR_GL_UNSIGNED_INT, indices, baseID,
|
| GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES,
|
| - GR_GL_AFFINE_2D, transformValues));
|
| -
|
| + gXformFormat2GLType[transformsFormat], transforms));
|
| }
|
| } else {
|
| GrDrawState* drawState = this->drawState();
|
|
|