| 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 GrStencilOp::kIncClamp: | 73 case GrStencilOp::kIncWrap: |
| 74 return GR_GL_COUNT_UP; | 74 return GR_GL_COUNT_UP; |
| 75 case GrStencilOp::kInvert: | 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(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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& stencilPassSettings, |
| 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(stencilPassSettings); |
| 158 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 158 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 159 | 159 |
| 160 GrGLenum fillMode = | 160 GrGLenum fillMode = |
| 161 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.fron
t().fPassOp); | 161 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.fron
t().fPassOp); |
| 162 GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; | 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)); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline, | 176 void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline, |
| 177 const GrPrimitiveProcessor& primProc, | 177 const GrPrimitiveProcessor& primProc, |
| 178 const GrStencilSettings& stencil, const GrPa
thRange* pathRange, | 178 const GrStencilSettings& stencilPassSettings
, |
| 179 const void* indices, PathIndexType indexType
, | 179 const GrPathRange* pathRange, const void* in
dices, |
| 180 const float transformValues[], PathTransform
Type transformType, | 180 PathIndexType indexType, const float transfo
rmValues[], |
| 181 int count) { | 181 PathTransformType transformType, int count)
{ |
| 182 SkDEBUGCODE(verify_floats(transformValues, gXformType2ComponentCount[transfo
rmType] * count)); | 182 SkDEBUGCODE(verify_floats(transformValues, gXformType2ComponentCount[transfo
rmType] * count)); |
| 183 | 183 |
| 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(stencilPassSettings); |
| 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(fHWPathStencilSettings.fron
t().fPassOp); | 194 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.fron
t().fPassOp); |
| 195 GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; | 195 GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; |
| 196 | 196 |
| 197 if (glPathRange->shouldStroke()) { | 197 if (glPathRange->shouldStroke()) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 testMask != fHWPathStencilSettings.front().fTestMask) { | 330 testMask != fHWPathStencilSettings.front().fTestMask) { |
| 331 GL_CALL(PathStencilFunc(GrToGLStencilFunc(test), ref, testMask)); | 331 GL_CALL(PathStencilFunc(GrToGLStencilFunc(test), ref, testMask)); |
| 332 } | 332 } |
| 333 fHWPathStencilSettings = stencilSettings; | 333 fHWPathStencilSettings = stencilSettings; |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 | 336 |
| 337 inline GrGLGpu* GrGLPathRendering::gpu() { | 337 inline GrGLGpu* GrGLPathRendering::gpu() { |
| 338 return static_cast<GrGLGpu*>(fGpu); | 338 return static_cast<GrGLGpu*>(fGpu); |
| 339 } | 339 } |
| OLD | NEW |