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

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: 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
« src/gpu/gl/GrGLInterface.cpp ('K') | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | 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" 10 #include "GrGLNameAllocator.h"
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 1892 SkASSERT(!fHWPathStencilSettings.isTwoSided());
1893 GrGLenum fillMode = 1893 GrGLenum fillMode =
1894 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));
1895 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face); 1895 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
1896 1896
1897 if (nonInvertedFill == fill) { 1897 if (nonInvertedFill == fill) {
1898 if (stroke.needToApply()) { 1898 if (stroke.needToApply()) {
1899 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { 1899 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) {
1900 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 1900 GL_CALL(StencilFillPath(id, fillMode, writeMask));
1901 } 1901 }
1902 GL_CALL(StencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUN DING_BOX)); 1902 this->stencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUNDI NG_BOX);
1903 } else { 1903 } else {
1904 GL_CALL(StencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUN DING_BOX)); 1904 this->stencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUNDI NG_BOX);
1905 } 1905 }
1906 } else { 1906 } else {
1907 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke. getStyle()) { 1907 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke. getStyle()) {
1908 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 1908 GL_CALL(StencilFillPath(id, fillMode, writeMask));
1909 } 1909 }
1910 if (stroke.needToApply()) { 1910 if (stroke.needToApply()) {
1911 GL_CALL(StencilStrokePath(id, 0xffff, writeMask)); 1911 GL_CALL(StencilStrokePath(id, 0xffff, writeMask));
1912 } 1912 }
1913 1913
1914 GrDrawState* drawState = this->drawState(); 1914 GrDrawState* drawState = this->drawState();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); 1957 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
1958 1958
1959 if (nonInvertedFill == fill) { 1959 if (nonInvertedFill == fill) {
1960 if (stroke.needToApply()) { 1960 if (stroke.needToApply()) {
1961 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { 1961 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) {
1962 GL_CALL(StencilFillPathInstanced( 1962 GL_CALL(StencilFillPathInstanced(
1963 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode , 1963 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode ,
1964 writeMask, gXformType2GLType[transformsType], 1964 writeMask, gXformType2GLType[transformsType],
1965 transforms)); 1965 transforms));
1966 } 1966 }
1967 GL_CALL(StencilThenCoverStrokePathInstanced( 1967 this->stencilThenCoverStrokePathInstanced(
1968 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, writ eMask, 1968 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, writ eMask,
1969 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, 1969 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES,
1970 gXformType2GLType[transformsType], transforms)); 1970 gXformType2GLType[transformsType], transforms);
1971 } else { 1971 } else {
1972 GL_CALL(StencilThenCoverFillPathInstanced( 1972 this->stencilThenCoverFillPathInstanced(
1973 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, wr iteMask, 1973 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, wr iteMask,
1974 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, 1974 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES,
1975 gXformType2GLType[transformsType], transforms)); 1975 gXformType2GLType[transformsType], transforms);
1976 } 1976 }
1977 } else { 1977 } else {
1978 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke. getStyle()) { 1978 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke. getStyle()) {
1979 GL_CALL(StencilFillPathInstanced( 1979 GL_CALL(StencilFillPathInstanced(
1980 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, 1980 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode,
1981 writeMask, gXformType2GLType[transformsType], 1981 writeMask, gXformType2GLType[transformsType],
1982 transforms)); 1982 transforms));
1983 } 1983 }
1984 if (stroke.needToApply()) { 1984 if (stroke.needToApply()) {
1985 GL_CALL(StencilStrokePathInstanced( 1985 GL_CALL(StencilStrokePathInstanced(
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 } 2674 }
2675 2675
2676 void GrGpuGL::setTextureUnit(int unit) { 2676 void GrGpuGL::setTextureUnit(int unit) {
2677 SkASSERT(unit >= 0 && unit < fHWBoundTextureUniqueIDs.count()); 2677 SkASSERT(unit >= 0 && unit < fHWBoundTextureUniqueIDs.count());
2678 if (unit != fHWActiveTextureUnitIdx) { 2678 if (unit != fHWActiveTextureUnitIdx) {
2679 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); 2679 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit));
2680 fHWActiveTextureUnitIdx = unit; 2680 fHWActiveTextureUnitIdx = unit;
2681 } 2681 }
2682 } 2682 }
2683 2683
2684 void GrGpuGL::stencilThenCoverFillPath(GrGLuint path, GrGLenum fillMode,
2685 GrGLuint mask, GrGLenum coverMode) {
2686 SkASSERT(this->caps()->pathRenderingSupport());
2687 if (!this->caps()->pathRenderingV13Support()) {
2688 GL_CALL(StencilFillPath(path, fillMode, mask));
2689 GL_CALL(CoverFillPath(path, coverMode));
2690 return;
2691 }
2692 GL_CALL(StencilThenCoverFillPath(path, fillMode, mask, coverMode));
2693 }
2694
2695 void GrGpuGL::stencilThenCoverStrokePath(GrGLuint path, GrGLint reference,
2696 GrGLuint mask, GrGLenum coverMode) {
2697 SkASSERT(this->caps()->pathRenderingSupport());
2698 if (!this->caps()->pathRenderingV13Support()) {
2699 GL_CALL(StencilStrokePath(path, reference, mask));
2700 GL_CALL(CoverStrokePath(path, coverMode));
2701 return;
2702 }
2703 GL_CALL(StencilThenCoverStrokePath(path, reference, mask, coverMode));
2704 }
2705
2706 void GrGpuGL::stencilThenCoverFillPathInstanced(GrGLsizei numPaths, GrGLenum pat hNameType,
2707 const GrGLvoid *paths, GrGLuint pathBase,
2708 GrGLenum fillMode, GrGLuint mask ,
2709 GrGLenum coverMode, GrGLenum tra nsformType,
2710 const GrGLfloat *transformValues ) {
2711 SkASSERT(this->caps()->pathRenderingSupport());
2712 if (!this->caps()->pathRenderingV13Support()) {
2713 GL_CALL(StencilFillPathInstanced(numPaths, pathNameType, paths, pathBase ,
2714 fillMode, mask, transformType, transfor mValues));
2715 GL_CALL(CoverFillPathInstanced(numPaths, pathNameType, paths, pathBase,
2716 coverMode, transformType, transformValues ));
2717 return;
2718 }
2719 GL_CALL(StencilThenCoverFillPathInstanced(numPaths, pathNameType, paths, pat hBase, fillMode,
2720 mask, coverMode, transformType, tr ansformValues));
2721 }
2722
2723 void GrGpuGL::stencilThenCoverStrokePathInstanced(GrGLsizei numPaths, GrGLenum p athNameType,
2724 const GrGLvoid *paths, GrGLuin t pathBase,
2725 GrGLint reference, GrGLuint ma sk,
2726 GrGLenum coverMode, GrGLenum t ransformType,
2727 const GrGLfloat *transformValu es) {
2728 SkASSERT(this->caps()->pathRenderingSupport());
2729 if (!this->caps()->pathRenderingV13Support()) {
2730 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBa se,
2731 reference, mask, transformType, trans formValues));
2732 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase ,
2733 coverMode, transformType, transformValu es));
2734 return;
2735 }
2736 GL_CALL(StencilThenCoverStrokePathInstanced(numPaths, pathNameType, paths, p athBase, reference,
2737 mask, coverMode, transformType, transformValues));
2738 }
2739
2684 void GrGpuGL::setScratchTextureUnit() { 2740 void GrGpuGL::setScratchTextureUnit() {
2685 // Bind the last texture unit since it is the least likely to be used by GrG LProgram. 2741 // Bind the last texture unit since it is the least likely to be used by GrG LProgram.
2686 int lastUnitIdx = fHWBoundTextureUniqueIDs.count() - 1; 2742 int lastUnitIdx = fHWBoundTextureUniqueIDs.count() - 1;
2687 if (lastUnitIdx != fHWActiveTextureUnitIdx) { 2743 if (lastUnitIdx != fHWActiveTextureUnitIdx) {
2688 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx)); 2744 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx));
2689 fHWActiveTextureUnitIdx = lastUnitIdx; 2745 fHWActiveTextureUnitIdx = lastUnitIdx;
2690 } 2746 }
2691 // clear out the this field so that if a program does use this unit it will rebind the correct 2747 // clear out the this field so that if a program does use this unit it will rebind the correct
2692 // texture. 2748 // texture.
2693 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID; 2749 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2988 this->setVertexArrayID(gpu, 0); 3044 this->setVertexArrayID(gpu, 0);
2989 } 3045 }
2990 int attrCount = gpu->glCaps().maxVertexAttributes(); 3046 int attrCount = gpu->glCaps().maxVertexAttributes();
2991 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3047 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2992 fDefaultVertexArrayAttribState.resize(attrCount); 3048 fDefaultVertexArrayAttribState.resize(attrCount);
2993 } 3049 }
2994 attribState = &fDefaultVertexArrayAttribState; 3050 attribState = &fDefaultVertexArrayAttribState;
2995 } 3051 }
2996 return attribState; 3052 return attribState;
2997 } 3053 }
OLDNEW
« src/gpu/gl/GrGLInterface.cpp ('K') | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698