| 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" |
| 10 #include "GrGLStencilBuffer.h" | 11 #include "GrGLStencilBuffer.h" |
| 11 #include "GrGLPath.h" | 12 #include "GrGLPath.h" |
| 12 #include "GrGLPathRange.h" | 13 #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 } | |
| 171 } | 167 } |
| 172 | 168 |
| 173 GrGpuGL::~GrGpuGL() { | 169 GrGpuGL::~GrGpuGL() { |
| 174 if (0 != fHWProgramID) { | 170 if (0 != fHWProgramID) { |
| 175 // detach the current program so there is no confusion on OpenGL's part | 171 // detach the current program so there is no confusion on OpenGL's part |
| 176 // that we want it to be deleted | 172 // that we want it to be deleted |
| 177 SkASSERT(fHWProgramID == fCurrentProgram->programID()); | 173 SkASSERT(fHWProgramID == fCurrentProgram->programID()); |
| 178 GL_CALL(UseProgram(0)); | 174 GL_CALL(UseProgram(0)); |
| 179 } | 175 } |
| 180 | 176 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 315 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
| 320 } | 316 } |
| 321 | 317 |
| 322 if (resetBits & kPathRendering_GrGLBackendState) { | 318 if (resetBits & kPathRendering_GrGLBackendState) { |
| 323 if (this->caps()->pathRenderingSupport()) { | 319 if (this->caps()->pathRenderingSupport()) { |
| 324 fHWProjectionMatrixState.invalidate(); | 320 fHWProjectionMatrixState.invalidate(); |
| 325 // we don't use the model view matrix. | 321 // we don't use the model view matrix. |
| 326 GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW)); | 322 GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW)); |
| 327 | 323 |
| 328 for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords();
++i) { | 324 for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords();
++i) { |
| 329 fPathRendering->pathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NU
LL); | 325 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); |
| 330 fHWPathTexGenSettings[i].fMode = GR_GL_NONE; | 326 fHWPathTexGenSettings[i].fMode = GR_GL_NONE; |
| 331 fHWPathTexGenSettings[i].fNumComponents = 0; | 327 fHWPathTexGenSettings[i].fNumComponents = 0; |
| 332 } | 328 } |
| 333 fHWActivePathTexGenSets = 0; | 329 fHWActivePathTexGenSets = 0; |
| 334 } | 330 } |
| 335 fHWPathStencilSettings.invalidate(); | 331 fHWPathStencilSettings.invalidate(); |
| 336 } | 332 } |
| 337 | 333 |
| 338 // we assume these values | 334 // we assume these values |
| 339 if (resetBits & kPixelStore_GrGLBackendState) { | 335 if (resetBits & kPixelStore_GrGLBackendState) { |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); | 1867 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); |
| 1872 | 1868 |
| 1873 flushPathStencilSettings(fill); | 1869 flushPathStencilSettings(fill); |
| 1874 | 1870 |
| 1875 // Decide how to manipulate the stencil buffer based on the fill rule. | 1871 // Decide how to manipulate the stencil buffer based on the fill rule. |
| 1876 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 1872 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 1877 | 1873 |
| 1878 GrGLenum fillMode = | 1874 GrGLenum fillMode = |
| 1879 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); | 1875 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); |
| 1880 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); | 1876 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); |
| 1881 fPathRendering->stencilFillPath(id, fillMode, writeMask); | 1877 GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
| 1882 } | 1878 } |
| 1883 | 1879 |
| 1884 void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) { | 1880 void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) { |
| 1885 SkASSERT(this->caps()->pathRenderingSupport()); | 1881 SkASSERT(this->caps()->pathRenderingSupport()); |
| 1886 | 1882 |
| 1887 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); | 1883 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); |
| 1888 SkASSERT(NULL != this->drawState()->getRenderTarget()); | 1884 SkASSERT(NULL != this->drawState()->getRenderTarget()); |
| 1889 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); | 1885 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); |
| 1890 SkASSERT(!fCurrentProgram->hasVertexShader()); | 1886 SkASSERT(!fCurrentProgram->hasVertexShader()); |
| 1891 | 1887 |
| 1892 flushPathStencilSettings(fill); | 1888 flushPathStencilSettings(fill); |
| 1893 const SkStrokeRec& stroke = path->getStroke(); | 1889 const SkStrokeRec& stroke = path->getStroke(); |
| 1894 | 1890 |
| 1895 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill)
; | 1891 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill)
; |
| 1896 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 1892 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 1897 GrGLenum fillMode = | 1893 GrGLenum fillMode = |
| 1898 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); | 1894 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); |
| 1899 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); | 1895 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); |
| 1900 | 1896 |
| 1901 if (nonInvertedFill == fill) { | 1897 if (nonInvertedFill == fill) { |
| 1902 if (stroke.needToApply()) { | 1898 if (stroke.needToApply()) { |
| 1903 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { | 1899 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
| 1904 fPathRendering->stencilFillPath(id, fillMode, writeMask); | 1900 GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
| 1905 } | 1901 } |
| 1906 fPathRendering->stencilThenCoverStrokePath(id, 0xffff, writeMask, GR
_GL_BOUNDING_BOX); | 1902 GL_CALL(StencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUN
DING_BOX)); |
| 1907 } else { | 1903 } else { |
| 1908 fPathRendering->stencilThenCoverFillPath(id, fillMode, writeMask, GR
_GL_BOUNDING_BOX); | 1904 GL_CALL(StencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUN
DING_BOX)); |
| 1909 } | 1905 } |
| 1910 } else { | 1906 } else { |
| 1911 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { | 1907 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { |
| 1912 fPathRendering->stencilFillPath(id, fillMode, writeMask); | 1908 GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
| 1913 } | 1909 } |
| 1914 if (stroke.needToApply()) { | 1910 if (stroke.needToApply()) { |
| 1915 fPathRendering->stencilStrokePath(id, 0xffff, writeMask); | 1911 GL_CALL(StencilStrokePath(id, 0xffff, writeMask)); |
| 1916 } | 1912 } |
| 1917 | 1913 |
| 1918 GrDrawState* drawState = this->drawState(); | 1914 GrDrawState* drawState = this->drawState(); |
| 1919 GrDrawState::AutoViewMatrixRestore avmr; | 1915 GrDrawState::AutoViewMatrixRestore avmr; |
| 1920 SkRect bounds = SkRect::MakeLTRB(0, 0, | 1916 SkRect bounds = SkRect::MakeLTRB(0, 0, |
| 1921 SkIntToScalar(drawState->getRenderTarge
t()->width()), | 1917 SkIntToScalar(drawState->getRenderTarge
t()->width()), |
| 1922 SkIntToScalar(drawState->getRenderTarge
t()->height())); | 1918 SkIntToScalar(drawState->getRenderTarge
t()->height())); |
| 1923 SkMatrix vmi; | 1919 SkMatrix vmi; |
| 1924 // mapRect through persp matrix may not be correct | 1920 // mapRect through persp matrix may not be correct |
| 1925 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { | 1921 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1956 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 1952 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 1957 GrGLenum fillMode = | 1953 GrGLenum fillMode = |
| 1958 gr_stencil_op_to_gl_path_rendering_fill_mode( | 1954 gr_stencil_op_to_gl_path_rendering_fill_mode( |
| 1959 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); | 1955 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); |
| 1960 GrGLint writeMask = | 1956 GrGLint writeMask = |
| 1961 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); | 1957 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); |
| 1962 | 1958 |
| 1963 if (nonInvertedFill == fill) { | 1959 if (nonInvertedFill == fill) { |
| 1964 if (stroke.needToApply()) { | 1960 if (stroke.needToApply()) { |
| 1965 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { | 1961 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
| 1966 fPathRendering->stencilFillPathInstanced( | 1962 GL_CALL(StencilFillPathInstanced( |
| 1967 count, GR_GL_UNSIGNED_INT, indices, baseID,
fillMode, | 1963 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode
, |
| 1968 writeMask, gXformType2GLType[transformsType]
, | 1964 writeMask, gXformType2GLType[transformsType], |
| 1969 transforms); | 1965 transforms)); |
| 1970 } | 1966 } |
| 1971 fPathRendering->stencilThenCoverStrokePathInstanced( | 1967 GL_CALL(StencilThenCoverStrokePathInstanced( |
| 1972 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xff
ff, writeMask, | 1968 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, writ
eMask, |
| 1973 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, | 1969 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
| 1974 gXformType2GLType[transformsType], transforms); | 1970 gXformType2GLType[transformsType], transforms)); |
| 1975 } else { | 1971 } else { |
| 1976 fPathRendering->stencilThenCoverFillPathInstanced( | 1972 GL_CALL(StencilThenCoverFillPathInstanced( |
| 1977 count, GR_GL_UNSIGNED_INT, indices, baseID, fill
Mode, writeMask, | 1973 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, wr
iteMask, |
| 1978 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, | 1974 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
| 1979 gXformType2GLType[transformsType], transforms); | 1975 gXformType2GLType[transformsType], transforms)); |
| 1980 } | 1976 } |
| 1981 } else { | 1977 } else { |
| 1982 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { | 1978 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { |
| 1983 fPathRendering->stencilFillPathInstanced( | 1979 GL_CALL(StencilFillPathInstanced( |
| 1984 count, GR_GL_UNSIGNED_INT, indices, baseID, fill
Mode, | 1980 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, |
| 1985 writeMask, gXformType2GLType[transformsType], | 1981 writeMask, gXformType2GLType[transformsType], |
| 1986 transforms); | 1982 transforms)); |
| 1987 } | 1983 } |
| 1988 if (stroke.needToApply()) { | 1984 if (stroke.needToApply()) { |
| 1989 fPathRendering->stencilStrokePathInstanced( | 1985 GL_CALL(StencilStrokePathInstanced( |
| 1990 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xff
ff, | 1986 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, |
| 1991 writeMask, gXformType2GLType[transformsType], | 1987 writeMask, gXformType2GLType[transformsType], |
| 1992 transforms); | 1988 transforms)); |
| 1993 } | 1989 } |
| 1994 | 1990 |
| 1995 GrDrawState* drawState = this->drawState(); | 1991 GrDrawState* drawState = this->drawState(); |
| 1996 GrDrawState::AutoViewMatrixRestore avmr; | 1992 GrDrawState::AutoViewMatrixRestore avmr; |
| 1997 SkRect bounds = SkRect::MakeLTRB(0, 0, | 1993 SkRect bounds = SkRect::MakeLTRB(0, 0, |
| 1998 SkIntToScalar(drawState->getRenderTarge
t()->width()), | 1994 SkIntToScalar(drawState->getRenderTarge
t()->width()), |
| 1999 SkIntToScalar(drawState->getRenderTarge
t()->height())); | 1995 SkIntToScalar(drawState->getRenderTarge
t()->height())); |
| 2000 SkMatrix vmi; | 1996 SkMatrix vmi; |
| 2001 // mapRect through persp matrix may not be correct | 1997 // mapRect through persp matrix may not be correct |
| 2002 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { | 1998 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 } | 2196 } |
| 2201 | 2197 |
| 2202 void GrGpuGL::flushPathStencilSettings(SkPath::FillType fill) { | 2198 void GrGpuGL::flushPathStencilSettings(SkPath::FillType fill) { |
| 2203 GrStencilSettings pathStencilSettings; | 2199 GrStencilSettings pathStencilSettings; |
| 2204 this->getPathStencilSettingsForFillType(fill, &pathStencilSettings); | 2200 this->getPathStencilSettingsForFillType(fill, &pathStencilSettings); |
| 2205 if (fHWPathStencilSettings != pathStencilSettings) { | 2201 if (fHWPathStencilSettings != pathStencilSettings) { |
| 2206 // Just the func, ref, and mask is set here. The op and write mask are p
arams to the call | 2202 // Just the func, ref, and mask is set here. The op and write mask are p
arams to the call |
| 2207 // that draws the path to the SB (glStencilFillPath) | 2203 // that draws the path to the SB (glStencilFillPath) |
| 2208 GrGLenum func = | 2204 GrGLenum func = |
| 2209 gr_to_gl_stencil_func(pathStencilSettings.func(GrStencilSettings::kF
ront_Face)); | 2205 gr_to_gl_stencil_func(pathStencilSettings.func(GrStencilSettings::kF
ront_Face)); |
| 2210 fPathRendering->pathStencilFunc( | 2206 GL_CALL(PathStencilFunc(func, |
| 2211 func, pathStencilSettings.funcRef(GrStencilSettings:
:kFront_Face), | 2207 pathStencilSettings.funcRef(GrStencilSettings::k
Front_Face), |
| 2212 pathStencilSettings.funcMask(GrStencilSettings::kFro
nt_Face)); | 2208 pathStencilSettings.funcMask(GrStencilSettings::
kFront_Face))); |
| 2213 | 2209 |
| 2214 fHWPathStencilSettings = pathStencilSettings; | 2210 fHWPathStencilSettings = pathStencilSettings; |
| 2215 } | 2211 } |
| 2216 } | 2212 } |
| 2217 | 2213 |
| 2218 void GrGpuGL::flushBlend(bool isLines, | 2214 void GrGpuGL::flushBlend(bool isLines, |
| 2219 GrBlendCoeff srcCoeff, | 2215 GrBlendCoeff srcCoeff, |
| 2220 GrBlendCoeff dstCoeff) { | 2216 GrBlendCoeff dstCoeff) { |
| 2221 // Any optimization to disable blending should have already been applied and | 2217 // Any optimization to disable blending should have already been applied and |
| 2222 // tweaked the coeffs to (1, 0). | 2218 // tweaked the coeffs to (1, 0). |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2393 if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode && | 2389 if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode && |
| 2394 components == fHWPathTexGenSettings[unitIdx].fNumComponents && | 2390 components == fHWPathTexGenSettings[unitIdx].fNumComponents && |
| 2395 !memcmp(coefficients, fHWPathTexGenSettings[unitIdx].fCoefficients, | 2391 !memcmp(coefficients, fHWPathTexGenSettings[unitIdx].fCoefficients, |
| 2396 3 * components * sizeof(GrGLfloat))) { | 2392 3 * components * sizeof(GrGLfloat))) { |
| 2397 return; | 2393 return; |
| 2398 } | 2394 } |
| 2399 | 2395 |
| 2400 this->setTextureUnit(unitIdx); | 2396 this->setTextureUnit(unitIdx); |
| 2401 | 2397 |
| 2402 fHWPathTexGenSettings[unitIdx].fNumComponents = components; | 2398 fHWPathTexGenSettings[unitIdx].fNumComponents = components; |
| 2403 fPathRendering->pathTexGen(GR_GL_TEXTURE0 + unitIdx, | 2399 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, |
| 2404 GR_GL_OBJECT_LINEAR, | 2400 GR_GL_OBJECT_LINEAR, |
| 2405 components, | 2401 components, |
| 2406 coefficients); | 2402 coefficients)); |
| 2407 | 2403 |
| 2408 memcpy(fHWPathTexGenSettings[unitIdx].fCoefficients, coefficients, | 2404 memcpy(fHWPathTexGenSettings[unitIdx].fCoefficients, coefficients, |
| 2409 3 * components * sizeof(GrGLfloat)); | 2405 3 * components * sizeof(GrGLfloat)); |
| 2410 } | 2406 } |
| 2411 | 2407 |
| 2412 void GrGpuGL::enablePathTexGen(int unitIdx, PathTexGenComponents components, | 2408 void GrGpuGL::enablePathTexGen(int unitIdx, PathTexGenComponents components, |
| 2413 const SkMatrix& matrix) { | 2409 const SkMatrix& matrix) { |
| 2414 GrGLfloat coefficients[3 * 3]; | 2410 GrGLfloat coefficients[3 * 3]; |
| 2415 SkASSERT(this->glCaps().pathRenderingSupport()); | 2411 SkASSERT(this->glCaps().pathRenderingSupport()); |
| 2416 SkASSERT(components >= kS_PathTexGenComponents && | 2412 SkASSERT(components >= kS_PathTexGenComponents && |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2445 SkDEBUGCODE( | 2441 SkDEBUGCODE( |
| 2446 for (int i = 0; i < numUsedTexCoordSets; i++) { | 2442 for (int i = 0; i < numUsedTexCoordSets; i++) { |
| 2447 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); | 2443 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); |
| 2448 } | 2444 } |
| 2449 ); | 2445 ); |
| 2450 | 2446 |
| 2451 for (int i = numUsedTexCoordSets; i < fHWActivePathTexGenSets; i++) { | 2447 for (int i = numUsedTexCoordSets; i < fHWActivePathTexGenSets; i++) { |
| 2452 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); | 2448 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); |
| 2453 | 2449 |
| 2454 this->setTextureUnit(i); | 2450 this->setTextureUnit(i); |
| 2455 fPathRendering->pathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL); | 2451 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); |
| 2456 fHWPathTexGenSettings[i].fNumComponents = 0; | 2452 fHWPathTexGenSettings[i].fNumComponents = 0; |
| 2457 } | 2453 } |
| 2458 | 2454 |
| 2459 fHWActivePathTexGenSets = numUsedTexCoordSets; | 2455 fHWActivePathTexGenSets = numUsedTexCoordSets; |
| 2460 } | 2456 } |
| 2461 | 2457 |
| 2462 void GrGpuGL::flushMiscFixedFunctionState() { | 2458 void GrGpuGL::flushMiscFixedFunctionState() { |
| 2463 | 2459 |
| 2464 const GrDrawState& drawState = this->getDrawState(); | 2460 const GrDrawState& drawState = this->getDrawState(); |
| 2465 | 2461 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 case GrDrawState::kBoth_DrawFace: | 2497 case GrDrawState::kBoth_DrawFace: |
| 2502 GL_CALL(Disable(GR_GL_CULL_FACE)); | 2498 GL_CALL(Disable(GR_GL_CULL_FACE)); |
| 2503 break; | 2499 break; |
| 2504 default: | 2500 default: |
| 2505 SkFAIL("Unknown draw face."); | 2501 SkFAIL("Unknown draw face."); |
| 2506 } | 2502 } |
| 2507 fHWDrawFace = drawState.getDrawFace(); | 2503 fHWDrawFace = drawState.getDrawFace(); |
| 2508 } | 2504 } |
| 2509 } | 2505 } |
| 2510 | 2506 |
| 2507 GrGLuint GrGpuGL::createGLPathObject() { |
| 2508 if (NULL == fPathNameAllocator.get()) { |
| 2509 static const int range = 65536; |
| 2510 GrGLuint firstName; |
| 2511 GL_CALL_RET(firstName, GenPaths(range)); |
| 2512 fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, first
Name + range))); |
| 2513 } |
| 2514 |
| 2515 GrGLuint name = fPathNameAllocator->allocateName(); |
| 2516 if (0 == name) { |
| 2517 // Our reserved path names are all in use. Fall back on GenPaths. |
| 2518 GL_CALL_RET(name, GenPaths(1)); |
| 2519 } |
| 2520 |
| 2521 return name; |
| 2522 } |
| 2523 |
| 2524 void GrGpuGL::deleteGLPathObject(GrGLuint name) { |
| 2525 if (NULL == fPathNameAllocator.get() || |
| 2526 name < fPathNameAllocator->firstName() || |
| 2527 name >= fPathNameAllocator->endName()) { |
| 2528 // If we aren't inside fPathNameAllocator's range then this name was |
| 2529 // generated by the GenPaths fallback (or else the name is unallocated). |
| 2530 GL_CALL(DeletePaths(name, 1)); |
| 2531 return; |
| 2532 } |
| 2533 |
| 2534 // Make the path empty to save memory, but don't free the name in the driver
. |
| 2535 GL_CALL(PathCommands(name, 0, NULL, 0, GR_GL_FLOAT, NULL)); |
| 2536 fPathNameAllocator->free(name); |
| 2537 } |
| 2538 |
| 2511 bool GrGpuGL::configToGLFormats(GrPixelConfig config, | 2539 bool GrGpuGL::configToGLFormats(GrPixelConfig config, |
| 2512 bool getSizedInternalFormat, | 2540 bool getSizedInternalFormat, |
| 2513 GrGLenum* internalFormat, | 2541 GrGLenum* internalFormat, |
| 2514 GrGLenum* externalFormat, | 2542 GrGLenum* externalFormat, |
| 2515 GrGLenum* externalType) { | 2543 GrGLenum* externalType) { |
| 2516 GrGLenum dontCare; | 2544 GrGLenum dontCare; |
| 2517 if (NULL == internalFormat) { | 2545 if (NULL == internalFormat) { |
| 2518 internalFormat = &dontCare; | 2546 internalFormat = &dontCare; |
| 2519 } | 2547 } |
| 2520 if (NULL == externalFormat) { | 2548 if (NULL == externalFormat) { |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 this->setVertexArrayID(gpu, 0); | 2988 this->setVertexArrayID(gpu, 0); |
| 2961 } | 2989 } |
| 2962 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2990 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2963 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2991 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2964 fDefaultVertexArrayAttribState.resize(attrCount); | 2992 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2965 } | 2993 } |
| 2966 attribState = &fDefaultVertexArrayAttribState; | 2994 attribState = &fDefaultVertexArrayAttribState; |
| 2967 } | 2995 } |
| 2968 return attribState; | 2996 return attribState; |
| 2969 } | 2997 } |
| OLD | NEW |