Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 437473002: Wrap NV_path_rendering API with GrGLPathRendering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix builds more Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 319 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
316 } 320 }
317 321
318 if (resetBits & kPathRendering_GrGLBackendState) { 322 if (resetBits & kPathRendering_GrGLBackendState) {
319 if (this->caps()->pathRenderingSupport()) { 323 if (this->caps()->pathRenderingSupport()) {
320 fHWProjectionMatrixState.invalidate(); 324 fHWProjectionMatrixState.invalidate();
321 // we don't use the model view matrix. 325 // we don't use the model view matrix.
322 GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW)); 326 GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW));
323 327
324 for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords(); ++i) { 328 for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords(); ++i) {
325 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); 329 fPathRendering->pathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NU LL);
326 fHWPathTexGenSettings[i].fMode = GR_GL_NONE; 330 fHWPathTexGenSettings[i].fMode = GR_GL_NONE;
327 fHWPathTexGenSettings[i].fNumComponents = 0; 331 fHWPathTexGenSettings[i].fNumComponents = 0;
328 } 332 }
329 fHWActivePathTexGenSets = 0; 333 fHWActivePathTexGenSets = 0;
330 } 334 }
331 fHWPathStencilSettings.invalidate(); 335 fHWPathStencilSettings.invalidate();
332 } 336 }
333 337
334 // we assume these values 338 // we assume these values
335 if (resetBits & kPixelStore_GrGLBackendState) { 339 if (resetBits & kPixelStore_GrGLBackendState) {
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); 1871 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer());
1868 1872
1869 flushPathStencilSettings(fill); 1873 flushPathStencilSettings(fill);
1870 1874
1871 // Decide how to manipulate the stencil buffer based on the fill rule. 1875 // Decide how to manipulate the stencil buffer based on the fill rule.
1872 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 1876 SkASSERT(!fHWPathStencilSettings.isTwoSided());
1873 1877
1874 GrGLenum fillMode = 1878 GrGLenum fillMode =
1875 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face)); 1879 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face));
1876 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face); 1880 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
1877 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 1881 fPathRendering->stencilFillPath(id, fillMode, writeMask);
1878 } 1882 }
1879 1883
1880 void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) { 1884 void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) {
1881 SkASSERT(this->caps()->pathRenderingSupport()); 1885 SkASSERT(this->caps()->pathRenderingSupport());
1882 1886
1883 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); 1887 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID();
1884 SkASSERT(NULL != this->drawState()->getRenderTarget()); 1888 SkASSERT(NULL != this->drawState()->getRenderTarget());
1885 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); 1889 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer());
1886 SkASSERT(!fCurrentProgram->hasVertexShader()); 1890 SkASSERT(!fCurrentProgram->hasVertexShader());
1887 1891
1888 flushPathStencilSettings(fill); 1892 flushPathStencilSettings(fill);
1889 const SkStrokeRec& stroke = path->getStroke(); 1893 const SkStrokeRec& stroke = path->getStroke();
1890 1894
1891 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill) ; 1895 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill) ;
1892 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 1896 SkASSERT(!fHWPathStencilSettings.isTwoSided());
1893 GrGLenum fillMode = 1897 GrGLenum fillMode =
1894 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face)); 1898 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face));
1895 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face); 1899 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
1896 1900
1897 if (nonInvertedFill == fill) { 1901 if (nonInvertedFill == fill) {
1898 if (stroke.needToApply()) { 1902 if (stroke.needToApply()) {
1899 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { 1903 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) {
1900 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 1904 fPathRendering->stencilFillPath(id, fillMode, writeMask);
1901 } 1905 }
1902 GL_CALL(StencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUN DING_BOX)); 1906 fPathRendering->stencilThenCoverStrokePath(id, 0xffff, writeMask, GR _GL_BOUNDING_BOX);
1903 } else { 1907 } else {
1904 GL_CALL(StencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUN DING_BOX)); 1908 fPathRendering->stencilThenCoverFillPath(id, fillMode, writeMask, GR _GL_BOUNDING_BOX);
1905 } 1909 }
1906 } else { 1910 } else {
1907 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke. getStyle()) { 1911 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke. getStyle()) {
1908 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 1912 fPathRendering->stencilFillPath(id, fillMode, writeMask);
1909 } 1913 }
1910 if (stroke.needToApply()) { 1914 if (stroke.needToApply()) {
1911 GL_CALL(StencilStrokePath(id, 0xffff, writeMask)); 1915 fPathRendering->stencilStrokePath(id, 0xffff, writeMask);
1912 } 1916 }
1913 1917
1914 GrDrawState* drawState = this->drawState(); 1918 GrDrawState* drawState = this->drawState();
1915 GrDrawState::AutoViewMatrixRestore avmr; 1919 GrDrawState::AutoViewMatrixRestore avmr;
1916 SkRect bounds = SkRect::MakeLTRB(0, 0, 1920 SkRect bounds = SkRect::MakeLTRB(0, 0,
1917 SkIntToScalar(drawState->getRenderTarge t()->width()), 1921 SkIntToScalar(drawState->getRenderTarge t()->width()),
1918 SkIntToScalar(drawState->getRenderTarge t()->height())); 1922 SkIntToScalar(drawState->getRenderTarge t()->height()));
1919 SkMatrix vmi; 1923 SkMatrix vmi;
1920 // mapRect through persp matrix may not be correct 1924 // mapRect through persp matrix may not be correct
1921 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn verse(&vmi)) { 1925 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn verse(&vmi)) {
(...skipping 30 matching lines...) Expand all
1952 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 1956 SkASSERT(!fHWPathStencilSettings.isTwoSided());
1953 GrGLenum fillMode = 1957 GrGLenum fillMode =
1954 gr_stencil_op_to_gl_path_rendering_fill_mode( 1958 gr_stencil_op_to_gl_path_rendering_fill_mode(
1955 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); 1959 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
1956 GrGLint writeMask = 1960 GrGLint writeMask =
1957 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); 1961 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
1958 1962
1959 if (nonInvertedFill == fill) { 1963 if (nonInvertedFill == fill) {
1960 if (stroke.needToApply()) { 1964 if (stroke.needToApply()) {
1961 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { 1965 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) {
1962 GL_CALL(StencilFillPathInstanced( 1966 fPathRendering->stencilFillPathInstanced(
1963 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode , 1967 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode,
1964 writeMask, gXformType2GLType[transformsType], 1968 writeMask, gXformType2GLType[transformsType] ,
1965 transforms)); 1969 transforms);
1966 } 1970 }
1967 GL_CALL(StencilThenCoverStrokePathInstanced( 1971 fPathRendering->stencilThenCoverStrokePathInstanced(
1968 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, writ eMask, 1972 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xff ff, writeMask,
1969 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, 1973 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES,
1970 gXformType2GLType[transformsType], transforms)); 1974 gXformType2GLType[transformsType], transforms);
1971 } else { 1975 } else {
1972 GL_CALL(StencilThenCoverFillPathInstanced( 1976 fPathRendering->stencilThenCoverFillPathInstanced(
1973 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, wr iteMask, 1977 count, GR_GL_UNSIGNED_INT, indices, baseID, fill Mode, writeMask,
1974 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, 1978 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES,
1975 gXformType2GLType[transformsType], transforms)); 1979 gXformType2GLType[transformsType], transforms);
1976 } 1980 }
1977 } else { 1981 } else {
1978 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke. getStyle()) { 1982 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke. getStyle()) {
1979 GL_CALL(StencilFillPathInstanced( 1983 fPathRendering->stencilFillPathInstanced(
1980 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, 1984 count, GR_GL_UNSIGNED_INT, indices, baseID, fill Mode,
1981 writeMask, gXformType2GLType[transformsType], 1985 writeMask, gXformType2GLType[transformsType],
1982 transforms)); 1986 transforms);
1983 } 1987 }
1984 if (stroke.needToApply()) { 1988 if (stroke.needToApply()) {
1985 GL_CALL(StencilStrokePathInstanced( 1989 fPathRendering->stencilStrokePathInstanced(
1986 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, 1990 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xff ff,
1987 writeMask, gXformType2GLType[transformsType], 1991 writeMask, gXformType2GLType[transformsType],
1988 transforms)); 1992 transforms);
1989 } 1993 }
1990 1994
1991 GrDrawState* drawState = this->drawState(); 1995 GrDrawState* drawState = this->drawState();
1992 GrDrawState::AutoViewMatrixRestore avmr; 1996 GrDrawState::AutoViewMatrixRestore avmr;
1993 SkRect bounds = SkRect::MakeLTRB(0, 0, 1997 SkRect bounds = SkRect::MakeLTRB(0, 0,
1994 SkIntToScalar(drawState->getRenderTarge t()->width()), 1998 SkIntToScalar(drawState->getRenderTarge t()->width()),
1995 SkIntToScalar(drawState->getRenderTarge t()->height())); 1999 SkIntToScalar(drawState->getRenderTarge t()->height()));
1996 SkMatrix vmi; 2000 SkMatrix vmi;
1997 // mapRect through persp matrix may not be correct 2001 // mapRect through persp matrix may not be correct
1998 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn verse(&vmi)) { 2002 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn verse(&vmi)) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 } 2200 }
2197 2201
2198 void GrGpuGL::flushPathStencilSettings(SkPath::FillType fill) { 2202 void GrGpuGL::flushPathStencilSettings(SkPath::FillType fill) {
2199 GrStencilSettings pathStencilSettings; 2203 GrStencilSettings pathStencilSettings;
2200 this->getPathStencilSettingsForFillType(fill, &pathStencilSettings); 2204 this->getPathStencilSettingsForFillType(fill, &pathStencilSettings);
2201 if (fHWPathStencilSettings != pathStencilSettings) { 2205 if (fHWPathStencilSettings != pathStencilSettings) {
2202 // Just the func, ref, and mask is set here. The op and write mask are p arams to the call 2206 // Just the func, ref, and mask is set here. The op and write mask are p arams to the call
2203 // that draws the path to the SB (glStencilFillPath) 2207 // that draws the path to the SB (glStencilFillPath)
2204 GrGLenum func = 2208 GrGLenum func =
2205 gr_to_gl_stencil_func(pathStencilSettings.func(GrStencilSettings::kF ront_Face)); 2209 gr_to_gl_stencil_func(pathStencilSettings.func(GrStencilSettings::kF ront_Face));
2206 GL_CALL(PathStencilFunc(func, 2210 fPathRendering->pathStencilFunc(
2207 pathStencilSettings.funcRef(GrStencilSettings::k Front_Face), 2211 func, pathStencilSettings.funcRef(GrStencilSettings: :kFront_Face),
2208 pathStencilSettings.funcMask(GrStencilSettings:: kFront_Face))); 2212 pathStencilSettings.funcMask(GrStencilSettings::kFro nt_Face));
2209 2213
2210 fHWPathStencilSettings = pathStencilSettings; 2214 fHWPathStencilSettings = pathStencilSettings;
2211 } 2215 }
2212 } 2216 }
2213 2217
2214 void GrGpuGL::flushBlend(bool isLines, 2218 void GrGpuGL::flushBlend(bool isLines,
2215 GrBlendCoeff srcCoeff, 2219 GrBlendCoeff srcCoeff,
2216 GrBlendCoeff dstCoeff) { 2220 GrBlendCoeff dstCoeff) {
2217 // Any optimization to disable blending should have already been applied and 2221 // Any optimization to disable blending should have already been applied and
2218 // tweaked the coeffs to (1, 0). 2222 // tweaked the coeffs to (1, 0).
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode && 2393 if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode &&
2390 components == fHWPathTexGenSettings[unitIdx].fNumComponents && 2394 components == fHWPathTexGenSettings[unitIdx].fNumComponents &&
2391 !memcmp(coefficients, fHWPathTexGenSettings[unitIdx].fCoefficients, 2395 !memcmp(coefficients, fHWPathTexGenSettings[unitIdx].fCoefficients,
2392 3 * components * sizeof(GrGLfloat))) { 2396 3 * components * sizeof(GrGLfloat))) {
2393 return; 2397 return;
2394 } 2398 }
2395 2399
2396 this->setTextureUnit(unitIdx); 2400 this->setTextureUnit(unitIdx);
2397 2401
2398 fHWPathTexGenSettings[unitIdx].fNumComponents = components; 2402 fHWPathTexGenSettings[unitIdx].fNumComponents = components;
2399 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, 2403 fPathRendering->pathTexGen(GR_GL_TEXTURE0 + unitIdx,
2400 GR_GL_OBJECT_LINEAR, 2404 GR_GL_OBJECT_LINEAR,
2401 components, 2405 components,
2402 coefficients)); 2406 coefficients);
2403 2407
2404 memcpy(fHWPathTexGenSettings[unitIdx].fCoefficients, coefficients, 2408 memcpy(fHWPathTexGenSettings[unitIdx].fCoefficients, coefficients,
2405 3 * components * sizeof(GrGLfloat)); 2409 3 * components * sizeof(GrGLfloat));
2406 } 2410 }
2407 2411
2408 void GrGpuGL::enablePathTexGen(int unitIdx, PathTexGenComponents components, 2412 void GrGpuGL::enablePathTexGen(int unitIdx, PathTexGenComponents components,
2409 const SkMatrix& matrix) { 2413 const SkMatrix& matrix) {
2410 GrGLfloat coefficients[3 * 3]; 2414 GrGLfloat coefficients[3 * 3];
2411 SkASSERT(this->glCaps().pathRenderingSupport()); 2415 SkASSERT(this->glCaps().pathRenderingSupport());
2412 SkASSERT(components >= kS_PathTexGenComponents && 2416 SkASSERT(components >= kS_PathTexGenComponents &&
(...skipping 28 matching lines...) Expand all
2441 SkDEBUGCODE( 2445 SkDEBUGCODE(
2442 for (int i = 0; i < numUsedTexCoordSets; i++) { 2446 for (int i = 0; i < numUsedTexCoordSets; i++) {
2443 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); 2447 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents);
2444 } 2448 }
2445 ); 2449 );
2446 2450
2447 for (int i = numUsedTexCoordSets; i < fHWActivePathTexGenSets; i++) { 2451 for (int i = numUsedTexCoordSets; i < fHWActivePathTexGenSets; i++) {
2448 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents); 2452 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents);
2449 2453
2450 this->setTextureUnit(i); 2454 this->setTextureUnit(i);
2451 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); 2455 fPathRendering->pathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL);
2452 fHWPathTexGenSettings[i].fNumComponents = 0; 2456 fHWPathTexGenSettings[i].fNumComponents = 0;
2453 } 2457 }
2454 2458
2455 fHWActivePathTexGenSets = numUsedTexCoordSets; 2459 fHWActivePathTexGenSets = numUsedTexCoordSets;
2456 } 2460 }
2457 2461
2458 void GrGpuGL::flushMiscFixedFunctionState() { 2462 void GrGpuGL::flushMiscFixedFunctionState() {
2459 2463
2460 const GrDrawState& drawState = this->getDrawState(); 2464 const GrDrawState& drawState = this->getDrawState();
2461 2465
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2497 case GrDrawState::kBoth_DrawFace: 2501 case GrDrawState::kBoth_DrawFace:
2498 GL_CALL(Disable(GR_GL_CULL_FACE)); 2502 GL_CALL(Disable(GR_GL_CULL_FACE));
2499 break; 2503 break;
2500 default: 2504 default:
2501 SkFAIL("Unknown draw face."); 2505 SkFAIL("Unknown draw face.");
2502 } 2506 }
2503 fHWDrawFace = drawState.getDrawFace(); 2507 fHWDrawFace = drawState.getDrawFace();
2504 } 2508 }
2505 } 2509 }
2506 2510
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
2539 bool GrGpuGL::configToGLFormats(GrPixelConfig config, 2511 bool GrGpuGL::configToGLFormats(GrPixelConfig config,
2540 bool getSizedInternalFormat, 2512 bool getSizedInternalFormat,
2541 GrGLenum* internalFormat, 2513 GrGLenum* internalFormat,
2542 GrGLenum* externalFormat, 2514 GrGLenum* externalFormat,
2543 GrGLenum* externalType) { 2515 GrGLenum* externalType) {
2544 GrGLenum dontCare; 2516 GrGLenum dontCare;
2545 if (NULL == internalFormat) { 2517 if (NULL == internalFormat) {
2546 internalFormat = &dontCare; 2518 internalFormat = &dontCare;
2547 } 2519 }
2548 if (NULL == externalFormat) { 2520 if (NULL == externalFormat) {
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2988 this->setVertexArrayID(gpu, 0); 2960 this->setVertexArrayID(gpu, 0);
2989 } 2961 }
2990 int attrCount = gpu->glCaps().maxVertexAttributes(); 2962 int attrCount = gpu->glCaps().maxVertexAttributes();
2991 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2963 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2992 fDefaultVertexArrayAttribState.resize(attrCount); 2964 fDefaultVertexArrayAttribState.resize(attrCount);
2993 } 2965 }
2994 attribState = &fDefaultVertexArrayAttribState; 2966 attribState = &fDefaultVertexArrayAttribState;
2995 } 2967 }
2996 return attribState; 2968 return attribState;
2997 } 2969 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698