Index: src/gpu/gl/GrGpuGL.cpp |
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp |
index ff53b9c14cdeb5e8e141899249399ed58bff55f7..b5b1686d79b516e7ad06d94168c448b3645e12b8 100644 |
--- a/src/gpu/gl/GrGpuGL.cpp |
+++ b/src/gpu/gl/GrGpuGL.cpp |
@@ -7,6 +7,7 @@ |
#include "GrGpuGL.h" |
+#include "GrGLNameAllocator.h" |
#include "GrGLStencilBuffer.h" |
#include "GrGLPath.h" |
#include "GrGLShaderBuilder.h" |
@@ -2379,6 +2380,39 @@ void GrGpuGL::notifyTextureDelete(GrGLTexture* texture) { |
} |
} |
+ |
+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, |