Index: src/gpu/gl/GrGpuGL.cpp |
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp |
index 404e7abdbddf20caa5e9a2c5db507e2b24ad1794..70d3c31c0ceb697dd4eaaeabd1df05c8f30be8f8 100644 |
--- a/src/gpu/gl/GrGpuGL.cpp |
+++ b/src/gpu/gl/GrGpuGL.cpp |
@@ -7,10 +7,10 @@ |
#include "GrGpuGL.h" |
-#include "GrGLNameAllocator.h" |
#include "GrGLStencilBuffer.h" |
#include "GrGLPath.h" |
#include "GrGLPathRange.h" |
+#include "GrGLPathRendering.h" |
#include "GrGLShaderBuilder.h" |
#include "GrTemplates.h" |
#include "GrTypes.h" |
@@ -164,6 +164,10 @@ GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) |
fLastSuccessfulStencilFmtIdx = 0; |
fHWProgramID = 0; |
+ |
+ if (this->glCaps().pathRenderingSupport()) { |
+ fPathRendering.reset(GrGLPathRendering::Create(glInterface())); |
+ } |
} |
GrGpuGL::~GrGpuGL() { |
@@ -322,7 +326,7 @@ void GrGpuGL::onResetContext(uint32_t resetBits) { |
GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW)); |
for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords(); ++i) { |
- GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); |
+ fPathRendering->pathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL); |
fHWPathTexGenSettings[i].fMode = GR_GL_NONE; |
fHWPathTexGenSettings[i].fNumComponents = 0; |
} |
@@ -1874,7 +1878,7 @@ void GrGpuGL::onGpuStencilPath(const GrPath* path, SkPath::FillType fill) { |
GrGLenum fillMode = |
gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); |
GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); |
- GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
+ fPathRendering->stencilFillPath(id, fillMode, writeMask); |
} |
void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) { |
@@ -1897,18 +1901,18 @@ void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) { |
if (nonInvertedFill == fill) { |
if (stroke.needToApply()) { |
if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
- GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
+ fPathRendering->stencilFillPath(id, fillMode, writeMask); |
} |
- GL_CALL(StencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUNDING_BOX)); |
+ fPathRendering->stencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUNDING_BOX); |
} else { |
- GL_CALL(StencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUNDING_BOX)); |
+ fPathRendering->stencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUNDING_BOX); |
} |
} else { |
if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
- GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
+ fPathRendering->stencilFillPath(id, fillMode, writeMask); |
} |
if (stroke.needToApply()) { |
- GL_CALL(StencilStrokePath(id, 0xffff, writeMask)); |
+ fPathRendering->stencilStrokePath(id, 0xffff, writeMask); |
} |
GrDrawState* drawState = this->drawState(); |
@@ -1959,33 +1963,33 @@ void GrGpuGL::onGpuDrawPaths(const GrPathRange* pathRange, |
if (nonInvertedFill == fill) { |
if (stroke.needToApply()) { |
if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
- GL_CALL(StencilFillPathInstanced( |
- count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, |
- writeMask, gXformType2GLType[transformsType], |
- transforms)); |
+ fPathRendering->stencilFillPathInstanced( |
+ count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, |
+ writeMask, gXformType2GLType[transformsType], |
+ transforms); |
} |
- GL_CALL(StencilThenCoverStrokePathInstanced( |
- count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, writeMask, |
- GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
- gXformType2GLType[transformsType], transforms)); |
+ fPathRendering->stencilThenCoverStrokePathInstanced( |
+ count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, writeMask, |
+ GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
+ gXformType2GLType[transformsType], transforms); |
} else { |
- GL_CALL(StencilThenCoverFillPathInstanced( |
- count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, writeMask, |
- GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
- gXformType2GLType[transformsType], transforms)); |
+ fPathRendering->stencilThenCoverFillPathInstanced( |
+ count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, writeMask, |
+ GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
+ gXformType2GLType[transformsType], transforms); |
} |
} else { |
if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
- GL_CALL(StencilFillPathInstanced( |
- count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, |
- writeMask, gXformType2GLType[transformsType], |
- transforms)); |
+ fPathRendering->stencilFillPathInstanced( |
+ count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, |
+ writeMask, gXformType2GLType[transformsType], |
+ transforms); |
} |
if (stroke.needToApply()) { |
- GL_CALL(StencilStrokePathInstanced( |
- count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, |
- writeMask, gXformType2GLType[transformsType], |
- transforms)); |
+ fPathRendering->stencilStrokePathInstanced( |
+ count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, |
+ writeMask, gXformType2GLType[transformsType], |
+ transforms); |
} |
GrDrawState* drawState = this->drawState(); |
@@ -2203,9 +2207,9 @@ void GrGpuGL::flushPathStencilSettings(SkPath::FillType fill) { |
// that draws the path to the SB (glStencilFillPath) |
GrGLenum func = |
gr_to_gl_stencil_func(pathStencilSettings.func(GrStencilSettings::kFront_Face)); |
- GL_CALL(PathStencilFunc(func, |
- pathStencilSettings.funcRef(GrStencilSettings::kFront_Face), |
- pathStencilSettings.funcMask(GrStencilSettings::kFront_Face))); |
+ fPathRendering->pathStencilFunc( |
+ func, pathStencilSettings.funcRef(GrStencilSettings::kFront_Face), |
+ pathStencilSettings.funcMask(GrStencilSettings::kFront_Face)); |
fHWPathStencilSettings = pathStencilSettings; |
} |
@@ -2396,10 +2400,10 @@ void GrGpuGL::enablePathTexGen(int unitIdx, |
this->setTextureUnit(unitIdx); |
fHWPathTexGenSettings[unitIdx].fNumComponents = components; |
- GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, |
- GR_GL_OBJECT_LINEAR, |
- components, |
- coefficients)); |
+ fPathRendering->pathTexGen(GR_GL_TEXTURE0 + unitIdx, |
+ GR_GL_OBJECT_LINEAR, |
+ components, |
+ coefficients); |
memcpy(fHWPathTexGenSettings[unitIdx].fCoefficients, coefficients, |
3 * components * sizeof(GrGLfloat)); |
@@ -2448,7 +2452,7 @@ void GrGpuGL::flushPathTexGenSettings(int numUsedTexCoordSets) { |
SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); |
this->setTextureUnit(i); |
- GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); |
+ fPathRendering->pathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL); |
fHWPathTexGenSettings[i].fNumComponents = 0; |
} |
@@ -2504,38 +2508,6 @@ void GrGpuGL::flushMiscFixedFunctionState() { |
} |
} |
-GrGLuint GrGpuGL::createGLPathObject() { |
- if (NULL == fPathNameAllocator.get()) { |
- static const int range = 65536; |
- GrGLuint firstName; |
- GL_CALL_RET(firstName, GenPaths(range)); |
- fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, firstName + range))); |
- } |
- |
- GrGLuint name = fPathNameAllocator->allocateName(); |
- if (0 == name) { |
- // Our reserved path names are all in use. Fall back on GenPaths. |
- GL_CALL_RET(name, GenPaths(1)); |
- } |
- |
- return name; |
-} |
- |
-void GrGpuGL::deleteGLPathObject(GrGLuint name) { |
- if (NULL == fPathNameAllocator.get() || |
- name < fPathNameAllocator->firstName() || |
- name >= fPathNameAllocator->endName()) { |
- // If we aren't inside fPathNameAllocator's range then this name was |
- // generated by the GenPaths fallback (or else the name is unallocated). |
- GL_CALL(DeletePaths(name, 1)); |
- return; |
- } |
- |
- // Make the path empty to save memory, but don't free the name in the driver. |
- GL_CALL(PathCommands(name, 0, NULL, 0, GR_GL_FLOAT, NULL)); |
- fPathNameAllocator->free(name); |
-} |
- |
bool GrGpuGL::configToGLFormats(GrPixelConfig config, |
bool getSizedInternalFormat, |
GrGLenum* internalFormat, |