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/GrGLUtil.h" | 9 #include "gl/GrGLUtil.h" |
10 #include "gl/GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 SkASSERT(!SkScalarIsNaN(SkFloatToScalar(floats[i]))); | 63 SkASSERT(!SkScalarIsNaN(SkFloatToScalar(floats[i]))); |
64 } | 64 } |
65 } | 65 } |
66 #endif | 66 #endif |
67 | 67 |
68 static GrGLenum gr_stencil_op_to_gl_path_rendering_fill_mode(GrStencilOp op) { | 68 static GrGLenum gr_stencil_op_to_gl_path_rendering_fill_mode(GrStencilOp op) { |
69 switch (op) { | 69 switch (op) { |
70 default: | 70 default: |
71 SkFAIL("Unexpected path fill."); | 71 SkFAIL("Unexpected path fill."); |
72 /* fallthrough */; | 72 /* fallthrough */; |
73 case kIncClamp_StencilOp: | 73 case GrStencilOp::kIncClamp: |
74 return GR_GL_COUNT_UP; | 74 return GR_GL_COUNT_UP; |
75 case kInvert_StencilOp: | 75 case GrStencilOp::kInvert: |
76 return GR_GL_INVERT; | 76 return GR_GL_INVERT; |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 GrGLPathRendering::GrGLPathRendering(GrGLGpu* gpu) | 80 GrGLPathRendering::GrGLPathRendering(GrGLGpu* gpu) |
81 : GrPathRendering(gpu) | 81 : GrPathRendering(gpu) |
82 , fPreallocatedPathCount(0) { | 82 , fPreallocatedPathCount(0) { |
83 const GrGLInterface* glInterface = gpu->glInterface(); | 83 const GrGLInterface* glInterface = gpu->glInterface(); |
84 fCaps.bindFragmentInputSupport = | 84 fCaps.bindFragmentInputSupport = |
85 nullptr != glInterface->fFunctions.fBindFragmentInputLocation; | 85 nullptr != glInterface->fFunctions.fBindFragmentInputLocation; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 this->setProjectionMatrix(*args.fViewMatrix, size, rt->origin()); | 126 this->setProjectionMatrix(*args.fViewMatrix, size, rt->origin()); |
127 gpu->flushScissor(*args.fScissor, rt->getViewport(), rt->origin()); | 127 gpu->flushScissor(*args.fScissor, rt->getViewport(), rt->origin()); |
128 gpu->flushHWAAState(rt, args.fUseHWAA, true); | 128 gpu->flushHWAAState(rt, args.fUseHWAA, true); |
129 gpu->flushRenderTarget(rt, nullptr); | 129 gpu->flushRenderTarget(rt, nullptr); |
130 | 130 |
131 const GrGLPath* glPath = static_cast<const GrGLPath*>(path); | 131 const GrGLPath* glPath = static_cast<const GrGLPath*>(path); |
132 | 132 |
133 this->flushPathStencilSettings(*args.fStencil); | 133 this->flushPathStencilSettings(*args.fStencil); |
134 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 134 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
135 | 135 |
136 GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode( | 136 GrGLenum fillMode = |
137 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); | 137 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.fron
t().fPassOp); |
138 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); | 138 GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; |
139 | 139 |
140 if (glPath->shouldFill()) { | 140 if (glPath->shouldFill()) { |
141 GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); | 141 GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); |
142 } | 142 } |
143 if (glPath->shouldStroke()) { | 143 if (glPath->shouldStroke()) { |
144 GL_CALL(StencilStrokePath(glPath->pathID(), 0xffff, writeMask)); | 144 GL_CALL(StencilStrokePath(glPath->pathID(), 0xffff, writeMask)); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 void GrGLPathRendering::onDrawPath(const GrPipeline& pipeline, | 148 void GrGLPathRendering::onDrawPath(const GrPipeline& pipeline, |
149 const GrPrimitiveProcessor& primProc, | 149 const GrPrimitiveProcessor& primProc, |
150 const GrStencilSettings& stencil, | 150 const GrStencilSettings& stencil, |
151 const GrPath* path) { | 151 const GrPath* path) { |
152 if (!this->gpu()->flushGLState(pipeline, primProc)) { | 152 if (!this->gpu()->flushGLState(pipeline, primProc)) { |
153 return; | 153 return; |
154 } | 154 } |
155 const GrGLPath* glPath = static_cast<const GrGLPath*>(path); | 155 const GrGLPath* glPath = static_cast<const GrGLPath*>(path); |
156 | 156 |
157 this->flushPathStencilSettings(stencil); | 157 this->flushPathStencilSettings(stencil); |
158 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 158 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
159 | 159 |
160 GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode( | 160 GrGLenum fillMode = |
161 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); | 161 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.fron
t().fPassOp); |
162 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); | 162 GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; |
163 | 163 |
164 if (glPath->shouldStroke()) { | 164 if (glPath->shouldStroke()) { |
165 if (glPath->shouldFill()) { | 165 if (glPath->shouldFill()) { |
166 GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); | 166 GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); |
167 } | 167 } |
168 GL_CALL(StencilThenCoverStrokePath(glPath->pathID(), 0xffff, writeMask, | 168 GL_CALL(StencilThenCoverStrokePath(glPath->pathID(), 0xffff, writeMask, |
169 GR_GL_BOUNDING_BOX)); | 169 GR_GL_BOUNDING_BOX)); |
170 } else { | 170 } else { |
171 GL_CALL(StencilThenCoverFillPath(glPath->pathID(), fillMode, writeMask, | 171 GL_CALL(StencilThenCoverFillPath(glPath->pathID(), fillMode, writeMask, |
172 GR_GL_BOUNDING_BOX)); | 172 GR_GL_BOUNDING_BOX)); |
(...skipping 11 matching lines...) Expand all Loading... |
184 if (!this->gpu()->flushGLState(pipeline, primProc)) { | 184 if (!this->gpu()->flushGLState(pipeline, primProc)) { |
185 return; | 185 return; |
186 } | 186 } |
187 this->flushPathStencilSettings(stencil); | 187 this->flushPathStencilSettings(stencil); |
188 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 188 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
189 | 189 |
190 | 190 |
191 const GrGLPathRange* glPathRange = static_cast<const GrGLPathRange*>(pathRan
ge); | 191 const GrGLPathRange* glPathRange = static_cast<const GrGLPathRange*>(pathRan
ge); |
192 | 192 |
193 GrGLenum fillMode = | 193 GrGLenum fillMode = |
194 gr_stencil_op_to_gl_path_rendering_fill_mode( | 194 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.fron
t().fPassOp); |
195 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); | 195 GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; |
196 GrGLint writeMask = | |
197 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); | |
198 | 196 |
199 if (glPathRange->shouldStroke()) { | 197 if (glPathRange->shouldStroke()) { |
200 if (glPathRange->shouldFill()) { | 198 if (glPathRange->shouldFill()) { |
201 GL_CALL(StencilFillPathInstanced( | 199 GL_CALL(StencilFillPathInstanced( |
202 count, gIndexType2GLType[indexType], indices, glPath
Range->basePathID(), | 200 count, gIndexType2GLType[indexType], indices, glPath
Range->basePathID(), |
203 fillMode, writeMask, gXformType2GLType[transformType
], | 201 fillMode, writeMask, gXformType2GLType[transformType
], |
204 transformValues)); | 202 transformValues)); |
205 } | 203 } |
206 GL_CALL(StencilThenCoverStrokePathInstanced( | 204 GL_CALL(StencilThenCoverStrokePathInstanced( |
207 count, gIndexType2GLType[indexType], indices, glPath
Range->basePathID(), | 205 count, gIndexType2GLType[indexType], indices, glPath
Range->basePathID(), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 313 |
316 void GrGLPathRendering::deletePaths(GrGLuint path, GrGLsizei range) { | 314 void GrGLPathRendering::deletePaths(GrGLuint path, GrGLsizei range) { |
317 GL_CALL(DeletePaths(path, range)); | 315 GL_CALL(DeletePaths(path, range)); |
318 } | 316 } |
319 | 317 |
320 void GrGLPathRendering::flushPathStencilSettings(const GrStencilSettings& stenci
lSettings) { | 318 void GrGLPathRendering::flushPathStencilSettings(const GrStencilSettings& stenci
lSettings) { |
321 if (fHWPathStencilSettings != stencilSettings) { | 319 if (fHWPathStencilSettings != stencilSettings) { |
322 SkASSERT(stencilSettings.isValid()); | 320 SkASSERT(stencilSettings.isValid()); |
323 // Just the func, ref, and mask is set here. The op and write mask are p
arams to the call | 321 // Just the func, ref, and mask is set here. The op and write mask are p
arams to the call |
324 // that draws the path to the SB (glStencilFillPath) | 322 // that draws the path to the SB (glStencilFillPath) |
325 const GrStencilSettings::Face kFront_Face = GrStencilSettings::kFront_Fa
ce; | 323 uint16_t ref = stencilSettings.front().fRef; |
326 GrStencilFunc func = stencilSettings.func(kFront_Face); | 324 GrStencilTest test = stencilSettings.front().fTest; |
327 uint16_t funcRef = stencilSettings.funcRef(kFront_Face); | 325 uint16_t testMask = stencilSettings.front().fTestMask; |
328 uint16_t funcMask = stencilSettings.funcMask(kFront_Face); | |
329 | 326 |
330 if (!fHWPathStencilSettings.isValid() || | 327 if (!fHWPathStencilSettings.isValid() || |
331 func != fHWPathStencilSettings.func(kFront_Face) || | 328 ref != fHWPathStencilSettings.front().fRef || |
332 funcRef != fHWPathStencilSettings.funcRef(kFront_Face) || | 329 test != fHWPathStencilSettings.front().fTest || |
333 funcMask != fHWPathStencilSettings.funcMask(kFront_Face)) { | 330 testMask != fHWPathStencilSettings.front().fTestMask) { |
334 GL_CALL(PathStencilFunc(GrToGLStencilFunc(func), funcRef, funcMask))
; | 331 GL_CALL(PathStencilFunc(GrToGLStencilFunc(test), ref, testMask)); |
335 } | 332 } |
336 fHWPathStencilSettings = stencilSettings; | 333 fHWPathStencilSettings = stencilSettings; |
337 } | 334 } |
338 } | 335 } |
339 | 336 |
340 inline GrGLGpu* GrGLPathRendering::gpu() { | 337 inline GrGLGpu* GrGLPathRendering::gpu() { |
341 return static_cast<GrGLGpu*>(fGpu); | 338 return static_cast<GrGLGpu*>(fGpu); |
342 } | 339 } |
OLD | NEW |