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 "GrGLNameAllocator.h" |
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 | 1887 |
1888 flushPathStencilSettings(fill); | 1888 flushPathStencilSettings(fill); |
1889 const SkStrokeRec& stroke = path->getStroke(); | 1889 const SkStrokeRec& stroke = path->getStroke(); |
1890 | 1890 |
1891 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill)
; | 1891 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill)
; |
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 (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.getS
tyle()) { | |
1898 GL_CALL(StencilFillPath(id, fillMode, writeMask)); | |
1899 } | |
1900 if (stroke.needToApply()) { | |
1901 GL_CALL(StencilStrokePath(id, 0xffff, writeMask)); | |
1902 } | |
1903 | |
1904 if (nonInvertedFill == fill) { | 1897 if (nonInvertedFill == fill) { |
1905 if (stroke.needToApply()) { | 1898 if (stroke.needToApply()) { |
1906 GL_CALL(CoverStrokePath(id, GR_GL_BOUNDING_BOX)); | 1899 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
| 1900 GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
| 1901 } |
| 1902 GL_CALL(StencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUN
DING_BOX)); |
1907 } else { | 1903 } else { |
1908 GL_CALL(CoverFillPath(id, GR_GL_BOUNDING_BOX)); | 1904 GL_CALL(StencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUN
DING_BOX)); |
1909 } | 1905 } |
1910 } else { | 1906 } else { |
| 1907 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { |
| 1908 GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
| 1909 } |
| 1910 if (stroke.needToApply()) { |
| 1911 GL_CALL(StencilStrokePath(id, 0xffff, writeMask)); |
| 1912 } |
| 1913 |
1911 GrDrawState* drawState = this->drawState(); | 1914 GrDrawState* drawState = this->drawState(); |
1912 GrDrawState::AutoViewMatrixRestore avmr; | 1915 GrDrawState::AutoViewMatrixRestore avmr; |
1913 SkRect bounds = SkRect::MakeLTRB(0, 0, | 1916 SkRect bounds = SkRect::MakeLTRB(0, 0, |
1914 SkIntToScalar(drawState->getRenderTarge
t()->width()), | 1917 SkIntToScalar(drawState->getRenderTarge
t()->width()), |
1915 SkIntToScalar(drawState->getRenderTarge
t()->height())); | 1918 SkIntToScalar(drawState->getRenderTarge
t()->height())); |
1916 SkMatrix vmi; | 1919 SkMatrix vmi; |
1917 // mapRect through persp matrix may not be correct | 1920 // mapRect through persp matrix may not be correct |
1918 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { | 1921 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { |
1919 vmi.mapRect(&bounds); | 1922 vmi.mapRect(&bounds); |
1920 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion | 1923 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion |
(...skipping 25 matching lines...) Expand all Loading... |
1946 SkPath::FillType nonInvertedFill = | 1949 SkPath::FillType nonInvertedFill = |
1947 SkPath::ConvertToNonInverseFillType(fill); | 1950 SkPath::ConvertToNonInverseFillType(fill); |
1948 | 1951 |
1949 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 1952 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
1950 GrGLenum fillMode = | 1953 GrGLenum fillMode = |
1951 gr_stencil_op_to_gl_path_rendering_fill_mode( | 1954 gr_stencil_op_to_gl_path_rendering_fill_mode( |
1952 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); | 1955 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); |
1953 GrGLint writeMask = | 1956 GrGLint writeMask = |
1954 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); | 1957 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); |
1955 | 1958 |
1956 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.getS
tyle()) { | |
1957 GL_CALL(StencilFillPathInstanced(count, GR_GL_UNSIGNED_INT, indices, bas
eID, fillMode, | |
1958 writeMask, gXformType2GLType[transforms
Type], | |
1959 transforms)); | |
1960 } | |
1961 if (stroke.needToApply()) { | |
1962 GL_CALL(StencilStrokePathInstanced(count, GR_GL_UNSIGNED_INT, indices, b
aseID, 0xffff, | |
1963 writeMask, gXformType2GLType[transfor
msType], | |
1964 transforms)); | |
1965 } | |
1966 | |
1967 if (nonInvertedFill == fill) { | 1959 if (nonInvertedFill == fill) { |
1968 if (stroke.needToApply()) { | 1960 if (stroke.needToApply()) { |
1969 GL_CALL(CoverStrokePathInstanced( | 1961 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
1970 count, GR_GL_UNSIGNED_INT, indices, baseID, | 1962 GL_CALL(StencilFillPathInstanced( |
| 1963 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode
, |
| 1964 writeMask, gXformType2GLType[transformsType], |
| 1965 transforms)); |
| 1966 } |
| 1967 GL_CALL(StencilThenCoverStrokePathInstanced( |
| 1968 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, writ
eMask, |
1971 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, | 1969 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
1972 gXformType2GLType[transformsType], transforms)); | 1970 gXformType2GLType[transformsType], transforms)); |
1973 } else { | 1971 } else { |
1974 GL_CALL(CoverFillPathInstanced( | 1972 GL_CALL(StencilThenCoverFillPathInstanced( |
1975 count, GR_GL_UNSIGNED_INT, indices, baseID, | 1973 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, wr
iteMask, |
1976 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, | 1974 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
1977 gXformType2GLType[transformsType], transforms)); | 1975 gXformType2GLType[transformsType], transforms)); |
1978 } | 1976 } |
1979 } else { | 1977 } else { |
| 1978 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.
getStyle()) { |
| 1979 GL_CALL(StencilFillPathInstanced( |
| 1980 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode, |
| 1981 writeMask, gXformType2GLType[transformsType], |
| 1982 transforms)); |
| 1983 } |
| 1984 if (stroke.needToApply()) { |
| 1985 GL_CALL(StencilStrokePathInstanced( |
| 1986 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff, |
| 1987 writeMask, gXformType2GLType[transformsType], |
| 1988 transforms)); |
| 1989 } |
| 1990 |
1980 GrDrawState* drawState = this->drawState(); | 1991 GrDrawState* drawState = this->drawState(); |
1981 GrDrawState::AutoViewMatrixRestore avmr; | 1992 GrDrawState::AutoViewMatrixRestore avmr; |
1982 SkRect bounds = SkRect::MakeLTRB(0, 0, | 1993 SkRect bounds = SkRect::MakeLTRB(0, 0, |
1983 SkIntToScalar(drawState->getRenderTarge
t()->width()), | 1994 SkIntToScalar(drawState->getRenderTarge
t()->width()), |
1984 SkIntToScalar(drawState->getRenderTarge
t()->height())); | 1995 SkIntToScalar(drawState->getRenderTarge
t()->height())); |
1985 SkMatrix vmi; | 1996 SkMatrix vmi; |
1986 // mapRect through persp matrix may not be correct | 1997 // mapRect through persp matrix may not be correct |
1987 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { | 1998 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { |
1988 vmi.mapRect(&bounds); | 1999 vmi.mapRect(&bounds); |
1989 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion | 2000 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 this->setVertexArrayID(gpu, 0); | 3029 this->setVertexArrayID(gpu, 0); |
3019 } | 3030 } |
3020 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3031 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3021 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3032 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3022 fDefaultVertexArrayAttribState.resize(attrCount); | 3033 fDefaultVertexArrayAttribState.resize(attrCount); |
3023 } | 3034 } |
3024 attribState = &fDefaultVertexArrayAttribState; | 3035 attribState = &fDefaultVertexArrayAttribState; |
3025 } | 3036 } |
3026 return attribState; | 3037 return attribState; |
3027 } | 3038 } |
OLD | NEW |