OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "gl/GrGLPathRendering.h" | 8 #include "gl/GrGLPathRendering.h" |
9 #include "gl/GrGLNameAllocator.h" | 9 #include "gl/GrGLNameAllocator.h" |
10 #include "gl/GrGLUtil.h" | 10 #include "gl/GrGLUtil.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return GR_GL_COUNT_UP; | 42 return GR_GL_COUNT_UP; |
43 case kInvert_StencilOp: | 43 case kInvert_StencilOp: |
44 return GR_GL_INVERT; | 44 return GR_GL_INVERT; |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 GrGLPathRendering::GrGLPathRendering(GrGpuGL* gpu) | 48 GrGLPathRendering::GrGLPathRendering(GrGpuGL* gpu) |
49 : fGpu(gpu) { | 49 : fGpu(gpu) { |
50 const GrGLInterface* glInterface = gpu->glInterface(); | 50 const GrGLInterface* glInterface = gpu->glInterface(); |
51 fCaps.stencilThenCoverSupport = | 51 fCaps.stencilThenCoverSupport = |
52 NULL != glInterface->fFunctions.fStencilThenCoverFillPath && | 52 glInterface->fFunctions.fStencilThenCoverFillPath && |
53 NULL != glInterface->fFunctions.fStencilThenCoverStrokePath && | 53 glInterface->fFunctions.fStencilThenCoverStrokePath && |
54 NULL != glInterface->fFunctions.fStencilThenCoverFillPathInstanced && | 54 glInterface->fFunctions.fStencilThenCoverFillPathInstanced && |
55 NULL != glInterface->fFunctions.fStencilThenCoverStrokePathInstanced; | 55 glInterface->fFunctions.fStencilThenCoverStrokePathInstanced; |
56 fCaps.fragmentInputGenSupport = | 56 fCaps.fragmentInputGenSupport = |
57 kGLES_GrGLStandard == glInterface->fStandard && | 57 kGLES_GrGLStandard == glInterface->fStandard && |
58 NULL != glInterface->fFunctions.fProgramPathFragmentInputGen; | 58 glInterface->fFunctions.fProgramPathFragmentInputGen; |
59 | 59 |
60 if (!fCaps.fragmentInputGenSupport) { | 60 if (!fCaps.fragmentInputGenSupport) { |
61 fHWPathTexGenSettings.reset(fGpu->glCaps().maxFixedFunctionTextureCoords
()); | 61 fHWPathTexGenSettings.reset(fGpu->glCaps().maxFixedFunctionTextureCoords
()); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 GrGLPathRendering::~GrGLPathRendering() { | 65 GrGLPathRendering::~GrGLPathRendering() { |
66 } | 66 } |
67 | 67 |
68 void GrGLPathRendering::abandonGpuResources() { | 68 void GrGLPathRendering::abandonGpuResources() { |
(...skipping 21 matching lines...) Expand all Loading... |
90 GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const SkStrokeRec& s
troke) { | 90 GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const SkStrokeRec& s
troke) { |
91 return SkNEW_ARGS(GrGLPath, (fGpu, inPath, stroke)); | 91 return SkNEW_ARGS(GrGLPath, (fGpu, inPath, stroke)); |
92 } | 92 } |
93 | 93 |
94 GrPathRange* GrGLPathRendering::createPathRange(size_t size, const SkStrokeRec&
stroke) { | 94 GrPathRange* GrGLPathRendering::createPathRange(size_t size, const SkStrokeRec&
stroke) { |
95 return SkNEW_ARGS(GrGLPathRange, (fGpu, size, stroke)); | 95 return SkNEW_ARGS(GrGLPathRange, (fGpu, size, stroke)); |
96 } | 96 } |
97 | 97 |
98 void GrGLPathRendering::stencilPath(const GrPath* path, SkPath::FillType fill) { | 98 void GrGLPathRendering::stencilPath(const GrPath* path, SkPath::FillType fill) { |
99 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); | 99 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); |
100 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()); | 100 SkASSERT(fGpu->drawState()->getRenderTarget()); |
101 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()->getStencilBuffer()); | 101 SkASSERT(fGpu->drawState()->getRenderTarget()->getStencilBuffer()); |
102 | 102 |
103 this->flushPathStencilSettings(fill); | 103 this->flushPathStencilSettings(fill); |
104 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 104 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
105 | 105 |
106 GrGLenum fillMode = | 106 GrGLenum fillMode = |
107 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); | 107 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); |
108 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); | 108 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); |
109 GL_CALL(StencilFillPath(id, fillMode, writeMask)); | 109 GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
110 } | 110 } |
111 | 111 |
112 void GrGLPathRendering::drawPath(const GrPath* path, SkPath::FillType fill) { | 112 void GrGLPathRendering::drawPath(const GrPath* path, SkPath::FillType fill) { |
113 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); | 113 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); |
114 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()); | 114 SkASSERT(fGpu->drawState()->getRenderTarget()); |
115 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()->getStencilBuffer()); | 115 SkASSERT(fGpu->drawState()->getRenderTarget()->getStencilBuffer()); |
116 | 116 |
117 this->flushPathStencilSettings(fill); | 117 this->flushPathStencilSettings(fill); |
118 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 118 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
119 | 119 |
120 const SkStrokeRec& stroke = path->getStroke(); | 120 const SkStrokeRec& stroke = path->getStroke(); |
121 | 121 |
122 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill)
; | 122 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill)
; |
123 | 123 |
124 GrGLenum fillMode = | 124 GrGLenum fillMode = |
125 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); | 125 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass
Op(GrStencilSettings::kFront_Face)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 | 161 |
162 fGpu->drawSimpleRect(bounds); | 162 fGpu->drawSimpleRect(bounds); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 void GrGLPathRendering::drawPaths(const GrPathRange* pathRange, const uint32_t i
ndices[], int count, | 166 void GrGLPathRendering::drawPaths(const GrPathRange* pathRange, const uint32_t i
ndices[], int count, |
167 const float transforms[], PathTransformType tr
ansformsType, | 167 const float transforms[], PathTransformType tr
ansformsType, |
168 SkPath::FillType fill) { | 168 SkPath::FillType fill) { |
169 SkASSERT(fGpu->caps()->pathRenderingSupport()); | 169 SkASSERT(fGpu->caps()->pathRenderingSupport()); |
170 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()); | 170 SkASSERT(fGpu->drawState()->getRenderTarget()); |
171 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()->getStencilBuffer()); | 171 SkASSERT(fGpu->drawState()->getRenderTarget()->getStencilBuffer()); |
172 | 172 |
173 GrGLuint baseID = static_cast<const GrGLPathRange*>(pathRange)->basePathID()
; | 173 GrGLuint baseID = static_cast<const GrGLPathRange*>(pathRange)->basePathID()
; |
174 | 174 |
175 this->flushPathStencilSettings(fill); | 175 this->flushPathStencilSettings(fill); |
176 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 176 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
177 | 177 |
178 const SkStrokeRec& stroke = pathRange->getStroke(); | 178 const SkStrokeRec& stroke = pathRange->getStroke(); |
179 | 179 |
180 SkPath::FillType nonInvertedFill = | 180 SkPath::FillType nonInvertedFill = |
181 SkPath::ConvertToNonInverseFillType(fill); | 181 SkPath::ConvertToNonInverseFillType(fill); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 reference, mask, coverMode,
transformType, | 468 reference, mask, coverMode,
transformType, |
469 transformValues)); | 469 transformValues)); |
470 return; | 470 return; |
471 } | 471 } |
472 | 472 |
473 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase, | 473 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase, |
474 reference, mask, transformType, transform
Values)); | 474 reference, mask, transformType, transform
Values)); |
475 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase, | 475 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase, |
476 coverMode, transformType, transformValues))
; | 476 coverMode, transformType, transformValues))
; |
477 } | 477 } |
OLD | NEW |