| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
| 10 #include "GrGLNameAllocator.h" | |
| 11 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
| 12 #include "GrGLPath.h" | 11 #include "GrGLPath.h" |
| 13 #include "GrGLPathRange.h" | 12 #include "GrGLPathRange.h" |
| 13 #include "GrGLPathRendering.h" |
| 14 #include "GrGLShaderBuilder.h" | 14 #include "GrGLShaderBuilder.h" |
| 15 #include "GrTemplates.h" | 15 #include "GrTemplates.h" |
| 16 #include "GrTypes.h" | 16 #include "GrTypes.h" |
| 17 #include "SkStrokeRec.h" | 17 #include "SkStrokeRec.h" |
| 18 #include "SkTemplates.h" | 18 #include "SkTemplates.h" |
| 19 | 19 |
| 20 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) | 20 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) |
| 21 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) | 21 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) |
| 22 | 22 |
| 23 #define SKIP_CACHE_CHECK true | 23 #define SKIP_CACHE_CHECK true |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 GrPrintf("\n"); | 157 GrPrintf("\n"); |
| 158 GrPrintf(this->glCaps().dump().c_str()); | 158 GrPrintf(this->glCaps().dump().c_str()); |
| 159 } | 159 } |
| 160 | 160 |
| 161 fProgramCache = SkNEW_ARGS(ProgramCache, (this)); | 161 fProgramCache = SkNEW_ARGS(ProgramCache, (this)); |
| 162 | 162 |
| 163 SkASSERT(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr
ibCnt); | 163 SkASSERT(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttr
ibCnt); |
| 164 | 164 |
| 165 fLastSuccessfulStencilFmtIdx = 0; | 165 fLastSuccessfulStencilFmtIdx = 0; |
| 166 fHWProgramID = 0; | 166 fHWProgramID = 0; |
| 167 |
| 168 if (this->glCaps().pathRenderingSupport()) { |
| 169 fPathRendering.reset(GrGLPathRendering::Create(glInterface())); |
| 170 } |
| 167 } | 171 } |
| 168 | 172 |
| 169 GrGpuGL::~GrGpuGL() { | 173 GrGpuGL::~GrGpuGL() { |
| 170 if (0 != fHWProgramID) { | 174 if (0 != fHWProgramID) { |
| 171 // detach the current program so there is no confusion on OpenGL's part | 175 // detach the current program so there is no confusion on OpenGL's part |
| 172 // that we want it to be deleted | 176 // that we want it to be deleted |
| 173 SkASSERT(fHWProgramID == fCurrentProgram->programID()); | 177 SkASSERT(fHWProgramID == fCurrentProgram->programID()); |
| 174 GL_CALL(UseProgram(0)); | 178 GL_CALL(UseProgram(0)); |
| 175 } | 179 } |
| 176 | 180 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 326 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
| 323 } | 327 } |
| 324 | 328 |
| 325 if (resetBits & kPathRendering_GrGLBackendState) { | 329 if (resetBits & kPathRendering_GrGLBackendState) { |
| 326 if (this->caps()->pathRenderingSupport()) { | 330 if (this->caps()->pathRenderingSupport()) { |
| 327 fHWProjectionMatrixState.invalidate(); | 331 fHWProjectionMatrixState.invalidate(); |
| 328 // we don't use the model view matrix. | 332 // we don't use the model view matrix. |
| 329 GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW)); | 333 GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW)); |
| 330 | 334 |
| 331 for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords();
++i) { | 335 for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords();
++i) { |
| 332 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); | 336 fPathRendering->pathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NU
LL); |
| 333 fHWPathTexGenSettings[i].fMode = GR_GL_NONE; | 337 fHWPathTexGenSettings[i].fMode = GR_GL_NONE; |
| 334 fHWPathTexGenSettings[i].fNumComponents = 0; | 338 fHWPathTexGenSettings[i].fNumComponents = 0; |
| 335 } | 339 } |
| 336 fHWActivePathTexGenSets = 0; | 340 fHWActivePathTexGenSets = 0; |
| 337 } | 341 } |
| 338 fHWPathStencilSettings.invalidate(); | 342 fHWPathStencilSettings.invalidate(); |
| 339 } | 343 } |
| 340 | 344 |
| 341 // we assume these values | 345 // we assume these values |
| 342 if (resetBits & kPixelStore_GrGLBackendState) { | 346 if (resetBits & kPixelStore_GrGLBackendState) { |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); | 1878 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); |
| 1875 | 1879 |
| 1876 flushPathStencilSettings(fill); | 1880 flushPathStencilSettings(fill); |
| 1877 | 1881 |
| 1878 // Decide how to manipulate the stencil buffer based on the fill rule. | 1882 // Decide how to manipulate the stencil buffer based on the fill rule. |
| 1879 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 1883 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 1880 | 1884 |
| 1881 GrGLenum fillMode = | 1885 GrGLenum fillMode = |
| 1882 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); | 1886 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); |
| 1883 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); | 1887 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); |
| 1884 GL_CALL(StencilFillPath(id, fillMode, writeMask)); | 1888 fPathRendering->stencilFillPath(id, fillMode, writeMask); |
| 1885 } | 1889 } |
| 1886 | 1890 |
| 1887 void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) { | 1891 void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) { |
| 1888 SkASSERT(this->caps()->pathRenderingSupport()); | 1892 SkASSERT(this->caps()->pathRenderingSupport()); |
| 1889 | 1893 |
| 1890 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); | 1894 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); |
| 1891 SkASSERT(NULL != this->drawState()->getRenderTarget()); | 1895 SkASSERT(NULL != this->drawState()->getRenderTarget()); |
| 1892 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); | 1896 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); |
| 1893 SkASSERT(!fCurrentProgram->hasVertexShader()); | 1897 SkASSERT(!fCurrentProgram->hasVertexShader()); |
| 1894 | 1898 |
| 1895 flushPathStencilSettings(fill); | 1899 flushPathStencilSettings(fill); |
| 1896 const SkStrokeRec& stroke = path->getStroke(); | 1900 const SkStrokeRec& stroke = path->getStroke(); |
| 1897 | 1901 |
| 1898 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill)
; | 1902 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill)
; |
| 1899 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 1903 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 1900 GrGLenum fillMode = | 1904 GrGLenum fillMode = |
| 1901 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); | 1905 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); |
| 1902 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); | 1906 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); |
| 1903 | 1907 |
| 1904 if (nonInvertedFill == fill) { | 1908 if (nonInvertedFill == fill) { |
| 1905 if (stroke.needToApply()) { | 1909 if (stroke.needToApply()) { |
| 1906 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { | 1910 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
| 1907 GL_CALL(StencilFillPath(id, fillMode, writeMask)); | 1911 fPathRendering->stencilFillPath(id, fillMode, writeMask); |
| 1908 } | 1912 } |
| 1909 GL_CALL(StencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUN
DING_BOX)); | 1913 fPathRendering->stencilThenCoverStrokePath(id, 0xffff, writeMask, GR
_GL_BOUNDING_BOX); |
| 1910 } else { | 1914 } else { |
| 1911 GL_CALL(StencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUN
DING_BOX)); | 1915 fPathRendering->stencilThenCoverFillPath(id, fillMode, writeMask, GR
_GL_BOUNDING_BOX); |
| 1912 } | 1916 } |
| 1913 } else { | 1917 } else { |
| 1914 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { | 1918 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { |
| 1915 GL_CALL(StencilFillPath(id, fillMode, writeMask)); | 1919 fPathRendering->stencilFillPath(id, fillMode, writeMask); |
| 1916 } | 1920 } |
| 1917 if (stroke.needToApply()) { | 1921 if (stroke.needToApply()) { |
| 1918 GL_CALL(StencilStrokePath(id, 0xffff, writeMask)); | 1922 fPathRendering->stencilStrokePath(id, 0xffff, writeMask); |
| 1919 } | 1923 } |
| 1920 | 1924 |
| 1921 GrDrawState* drawState = this->drawState(); | 1925 GrDrawState* drawState = this->drawState(); |
| 1922 GrDrawState::AutoViewMatrixRestore avmr; | 1926 GrDrawState::AutoViewMatrixRestore avmr; |
| 1923 SkRect bounds = SkRect::MakeLTRB(0, 0, | 1927 SkRect bounds = SkRect::MakeLTRB(0, 0, |
| 1924 SkIntToScalar(drawState->getRenderTarge
t()->width()), | 1928 SkIntToScalar(drawState->getRenderTarge
t()->width()), |
| 1925 SkIntToScalar(drawState->getRenderTarge
t()->height())); | 1929 SkIntToScalar(drawState->getRenderTarge
t()->height())); |
| 1926 SkMatrix vmi; | 1930 SkMatrix vmi; |
| 1927 // mapRect through persp matrix may not be correct | 1931 // mapRect through persp matrix may not be correct |
| 1928 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { | 1932 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1959 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 1963 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 1960 GrGLenum fillMode = | 1964 GrGLenum fillMode = |
| 1961 gr_stencil_op_to_gl_path_rendering_fill_mode( | 1965 gr_stencil_op_to_gl_path_rendering_fill_mode( |
| 1962 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); | 1966 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); |
| 1963 GrGLint writeMask = | 1967 GrGLint writeMask = |
| 1964 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); | 1968 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); |
| 1965 | 1969 |
| 1966 if (nonInvertedFill == fill) { | 1970 if (nonInvertedFill == fill) { |
| 1967 if (stroke.needToApply()) { | 1971 if (stroke.needToApply()) { |
| 1968 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { | 1972 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
| 1969 GL_CALL(StencilFillPathInstanced( | 1973 fPathRendering->stencilFillPathInstanced( |
| 1970 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode
, | 1974 count, GR_GL_UNSIGNED_INT, indices, baseID,
fillMode, |
| 1971 writeMask, gXformType2GLType[transformsType], | 1975 writeMask, gXformType2GLType[transformsType]
, |
| 1972 transforms)); | 1976 transforms); |
| 1973 } | 1977 } |
| 1974 GL_CALL(StencilThenCoverStrokePathInstanced( | 1978 fPathRendering->stencilThenCoverStrokePathInstanced( |
| 1975 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, writ
eMask, | 1979 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xff
ff, writeMask, |
| 1976 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, | 1980 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
| 1977 gXformType2GLType[transformsType], transforms)); | 1981 gXformType2GLType[transformsType], transforms); |
| 1978 } else { | 1982 } else { |
| 1979 GL_CALL(StencilThenCoverFillPathInstanced( | 1983 fPathRendering->stencilThenCoverFillPathInstanced( |
| 1980 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, wr
iteMask, | 1984 count, GR_GL_UNSIGNED_INT, indices, baseID, fill
Mode, writeMask, |
| 1981 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, | 1985 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
| 1982 gXformType2GLType[transformsType], transforms)); | 1986 gXformType2GLType[transformsType], transforms); |
| 1983 } | 1987 } |
| 1984 } else { | 1988 } else { |
| 1985 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { | 1989 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { |
| 1986 GL_CALL(StencilFillPathInstanced( | 1990 fPathRendering->stencilFillPathInstanced( |
| 1987 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, | 1991 count, GR_GL_UNSIGNED_INT, indices, baseID, fill
Mode, |
| 1988 writeMask, gXformType2GLType[transformsType], | 1992 writeMask, gXformType2GLType[transformsType], |
| 1989 transforms)); | 1993 transforms); |
| 1990 } | 1994 } |
| 1991 if (stroke.needToApply()) { | 1995 if (stroke.needToApply()) { |
| 1992 GL_CALL(StencilStrokePathInstanced( | 1996 fPathRendering->stencilStrokePathInstanced( |
| 1993 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, | 1997 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xff
ff, |
| 1994 writeMask, gXformType2GLType[transformsType], | 1998 writeMask, gXformType2GLType[transformsType], |
| 1995 transforms)); | 1999 transforms); |
| 1996 } | 2000 } |
| 1997 | 2001 |
| 1998 GrDrawState* drawState = this->drawState(); | 2002 GrDrawState* drawState = this->drawState(); |
| 1999 GrDrawState::AutoViewMatrixRestore avmr; | 2003 GrDrawState::AutoViewMatrixRestore avmr; |
| 2000 SkRect bounds = SkRect::MakeLTRB(0, 0, | 2004 SkRect bounds = SkRect::MakeLTRB(0, 0, |
| 2001 SkIntToScalar(drawState->getRenderTarge
t()->width()), | 2005 SkIntToScalar(drawState->getRenderTarge
t()->width()), |
| 2002 SkIntToScalar(drawState->getRenderTarge
t()->height())); | 2006 SkIntToScalar(drawState->getRenderTarge
t()->height())); |
| 2003 SkMatrix vmi; | 2007 SkMatrix vmi; |
| 2004 // mapRect through persp matrix may not be correct | 2008 // mapRect through persp matrix may not be correct |
| 2005 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { | 2009 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2203 } | 2207 } |
| 2204 | 2208 |
| 2205 void GrGpuGL::flushPathStencilSettings(SkPath::FillType fill) { | 2209 void GrGpuGL::flushPathStencilSettings(SkPath::FillType fill) { |
| 2206 GrStencilSettings pathStencilSettings; | 2210 GrStencilSettings pathStencilSettings; |
| 2207 this->getPathStencilSettingsForFillType(fill, &pathStencilSettings); | 2211 this->getPathStencilSettingsForFillType(fill, &pathStencilSettings); |
| 2208 if (fHWPathStencilSettings != pathStencilSettings) { | 2212 if (fHWPathStencilSettings != pathStencilSettings) { |
| 2209 // Just the func, ref, and mask is set here. The op and write mask are p
arams to the call | 2213 // Just the func, ref, and mask is set here. The op and write mask are p
arams to the call |
| 2210 // that draws the path to the SB (glStencilFillPath) | 2214 // that draws the path to the SB (glStencilFillPath) |
| 2211 GrGLenum func = | 2215 GrGLenum func = |
| 2212 gr_to_gl_stencil_func(pathStencilSettings.func(GrStencilSettings::kF
ront_Face)); | 2216 gr_to_gl_stencil_func(pathStencilSettings.func(GrStencilSettings::kF
ront_Face)); |
| 2213 GL_CALL(PathStencilFunc(func, | 2217 fPathRendering->pathStencilFunc( |
| 2214 pathStencilSettings.funcRef(GrStencilSettings::k
Front_Face), | 2218 func, pathStencilSettings.funcRef(GrStencilSettings:
:kFront_Face), |
| 2215 pathStencilSettings.funcMask(GrStencilSettings::
kFront_Face))); | 2219 pathStencilSettings.funcMask(GrStencilSettings::kFro
nt_Face)); |
| 2216 | 2220 |
| 2217 fHWPathStencilSettings = pathStencilSettings; | 2221 fHWPathStencilSettings = pathStencilSettings; |
| 2218 } | 2222 } |
| 2219 } | 2223 } |
| 2220 | 2224 |
| 2221 void GrGpuGL::flushBlend(bool isLines, | 2225 void GrGpuGL::flushBlend(bool isLines, |
| 2222 GrBlendCoeff srcCoeff, | 2226 GrBlendCoeff srcCoeff, |
| 2223 GrBlendCoeff dstCoeff) { | 2227 GrBlendCoeff dstCoeff) { |
| 2224 // Any optimization to disable blending should have already been applied and | 2228 // Any optimization to disable blending should have already been applied and |
| 2225 // tweaked the coeffs to (1, 0). | 2229 // tweaked the coeffs to (1, 0). |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2396 if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode && | 2400 if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode && |
| 2397 components == fHWPathTexGenSettings[unitIdx].fNumComponents && | 2401 components == fHWPathTexGenSettings[unitIdx].fNumComponents && |
| 2398 !memcmp(coefficients, fHWPathTexGenSettings[unitIdx].fCoefficients, | 2402 !memcmp(coefficients, fHWPathTexGenSettings[unitIdx].fCoefficients, |
| 2399 3 * components * sizeof(GrGLfloat))) { | 2403 3 * components * sizeof(GrGLfloat))) { |
| 2400 return; | 2404 return; |
| 2401 } | 2405 } |
| 2402 | 2406 |
| 2403 this->setTextureUnit(unitIdx); | 2407 this->setTextureUnit(unitIdx); |
| 2404 | 2408 |
| 2405 fHWPathTexGenSettings[unitIdx].fNumComponents = components; | 2409 fHWPathTexGenSettings[unitIdx].fNumComponents = components; |
| 2406 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, | 2410 fPathRendering->pathTexGen(GR_GL_TEXTURE0 + unitIdx, |
| 2407 GR_GL_OBJECT_LINEAR, | 2411 GR_GL_OBJECT_LINEAR, |
| 2408 components, | 2412 components, |
| 2409 coefficients)); | 2413 coefficients); |
| 2410 | 2414 |
| 2411 memcpy(fHWPathTexGenSettings[unitIdx].fCoefficients, coefficients, | 2415 memcpy(fHWPathTexGenSettings[unitIdx].fCoefficients, coefficients, |
| 2412 3 * components * sizeof(GrGLfloat)); | 2416 3 * components * sizeof(GrGLfloat)); |
| 2413 } | 2417 } |
| 2414 | 2418 |
| 2415 void GrGpuGL::enablePathTexGen(int unitIdx, PathTexGenComponents components, | 2419 void GrGpuGL::enablePathTexGen(int unitIdx, PathTexGenComponents components, |
| 2416 const SkMatrix& matrix) { | 2420 const SkMatrix& matrix) { |
| 2417 GrGLfloat coefficients[3 * 3]; | 2421 GrGLfloat coefficients[3 * 3]; |
| 2418 SkASSERT(this->glCaps().pathRenderingSupport()); | 2422 SkASSERT(this->glCaps().pathRenderingSupport()); |
| 2419 SkASSERT(components >= kS_PathTexGenComponents && | 2423 SkASSERT(components >= kS_PathTexGenComponents && |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2448 SkDEBUGCODE( | 2452 SkDEBUGCODE( |
| 2449 for (int i = 0; i < numUsedTexCoordSets; i++) { | 2453 for (int i = 0; i < numUsedTexCoordSets; i++) { |
| 2450 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); | 2454 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); |
| 2451 } | 2455 } |
| 2452 ); | 2456 ); |
| 2453 | 2457 |
| 2454 for (int i = numUsedTexCoordSets; i < fHWActivePathTexGenSets; i++) { | 2458 for (int i = numUsedTexCoordSets; i < fHWActivePathTexGenSets; i++) { |
| 2455 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); | 2459 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); |
| 2456 | 2460 |
| 2457 this->setTextureUnit(i); | 2461 this->setTextureUnit(i); |
| 2458 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); | 2462 fPathRendering->pathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL); |
| 2459 fHWPathTexGenSettings[i].fNumComponents = 0; | 2463 fHWPathTexGenSettings[i].fNumComponents = 0; |
| 2460 } | 2464 } |
| 2461 | 2465 |
| 2462 fHWActivePathTexGenSets = numUsedTexCoordSets; | 2466 fHWActivePathTexGenSets = numUsedTexCoordSets; |
| 2463 } | 2467 } |
| 2464 | 2468 |
| 2465 void GrGpuGL::flushMiscFixedFunctionState() { | 2469 void GrGpuGL::flushMiscFixedFunctionState() { |
| 2466 | 2470 |
| 2467 const GrDrawState& drawState = this->getDrawState(); | 2471 const GrDrawState& drawState = this->getDrawState(); |
| 2468 | 2472 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2504 case GrDrawState::kBoth_DrawFace: | 2508 case GrDrawState::kBoth_DrawFace: |
| 2505 GL_CALL(Disable(GR_GL_CULL_FACE)); | 2509 GL_CALL(Disable(GR_GL_CULL_FACE)); |
| 2506 break; | 2510 break; |
| 2507 default: | 2511 default: |
| 2508 SkFAIL("Unknown draw face."); | 2512 SkFAIL("Unknown draw face."); |
| 2509 } | 2513 } |
| 2510 fHWDrawFace = drawState.getDrawFace(); | 2514 fHWDrawFace = drawState.getDrawFace(); |
| 2511 } | 2515 } |
| 2512 } | 2516 } |
| 2513 | 2517 |
| 2514 GrGLuint GrGpuGL::createGLPathObject() { | |
| 2515 if (NULL == fPathNameAllocator.get()) { | |
| 2516 static const int range = 65536; | |
| 2517 GrGLuint firstName; | |
| 2518 GL_CALL_RET(firstName, GenPaths(range)); | |
| 2519 fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, first
Name + range))); | |
| 2520 } | |
| 2521 | |
| 2522 GrGLuint name = fPathNameAllocator->allocateName(); | |
| 2523 if (0 == name) { | |
| 2524 // Our reserved path names are all in use. Fall back on GenPaths. | |
| 2525 GL_CALL_RET(name, GenPaths(1)); | |
| 2526 } | |
| 2527 | |
| 2528 return name; | |
| 2529 } | |
| 2530 | |
| 2531 void GrGpuGL::deleteGLPathObject(GrGLuint name) { | |
| 2532 if (NULL == fPathNameAllocator.get() || | |
| 2533 name < fPathNameAllocator->firstName() || | |
| 2534 name >= fPathNameAllocator->endName()) { | |
| 2535 // If we aren't inside fPathNameAllocator's range then this name was | |
| 2536 // generated by the GenPaths fallback (or else the name is unallocated). | |
| 2537 GL_CALL(DeletePaths(name, 1)); | |
| 2538 return; | |
| 2539 } | |
| 2540 | |
| 2541 // Make the path empty to save memory, but don't free the name in the driver
. | |
| 2542 GL_CALL(PathCommands(name, 0, NULL, 0, GR_GL_FLOAT, NULL)); | |
| 2543 fPathNameAllocator->free(name); | |
| 2544 } | |
| 2545 | |
| 2546 bool GrGpuGL::configToGLFormats(GrPixelConfig config, | 2518 bool GrGpuGL::configToGLFormats(GrPixelConfig config, |
| 2547 bool getSizedInternalFormat, | 2519 bool getSizedInternalFormat, |
| 2548 GrGLenum* internalFormat, | 2520 GrGLenum* internalFormat, |
| 2549 GrGLenum* externalFormat, | 2521 GrGLenum* externalFormat, |
| 2550 GrGLenum* externalType) { | 2522 GrGLenum* externalType) { |
| 2551 GrGLenum dontCare; | 2523 GrGLenum dontCare; |
| 2552 if (NULL == internalFormat) { | 2524 if (NULL == internalFormat) { |
| 2553 internalFormat = &dontCare; | 2525 internalFormat = &dontCare; |
| 2554 } | 2526 } |
| 2555 if (NULL == externalFormat) { | 2527 if (NULL == externalFormat) { |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2995 this->setVertexArrayID(gpu, 0); | 2967 this->setVertexArrayID(gpu, 0); |
| 2996 } | 2968 } |
| 2997 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2969 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2998 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2970 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2999 fDefaultVertexArrayAttribState.resize(attrCount); | 2971 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3000 } | 2972 } |
| 3001 attribState = &fDefaultVertexArrayAttribState; | 2973 attribState = &fDefaultVertexArrayAttribState; |
| 3002 } | 2974 } |
| 3003 return attribState; | 2975 return attribState; |
| 3004 } | 2976 } |
| OLD | NEW |