| 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" |
| 11 #include "gl/GrGpuGL.h" | 11 #include "gl/GrGpuGL.h" |
| 12 | 12 |
| 13 #include "GrGLPath.h" | 13 #include "GrGLPath.h" |
| 14 #include "GrGLPathRange.h" | 14 #include "GrGLPathRange.h" |
| 15 #include "GrGLPathRendering.h" | 15 #include "GrGLPathRendering.h" |
| 16 | 16 |
| 17 #include "SkStream.h" | 17 #include "SkStream.h" |
| 18 #include "SkTypeface.h" | 18 #include "SkTypeface.h" |
| 19 | 19 |
| 20 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) | 20 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) |
| 21 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(fGpu->glInterface(), RET, X) | 21 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(fGpu->glInterface(), RET, X) |
| 22 | 22 |
| 23 | 23 |
| 24 static const GrGLenum gIndexType2GLType[] = { |
| 25 GR_GL_UNSIGNED_BYTE, |
| 26 GR_GL_UNSIGNED_SHORT, |
| 27 GR_GL_UNSIGNED_INT |
| 28 }; |
| 29 |
| 30 GR_STATIC_ASSERT(0 == GrPathRange::kU8_PathIndexType); |
| 31 GR_STATIC_ASSERT(1 == GrPathRange::kU16_PathIndexType); |
| 32 GR_STATIC_ASSERT(2 == GrPathRange::kU32_PathIndexType); |
| 33 GR_STATIC_ASSERT(GrPathRange::kU32_PathIndexType == GrPathRange::kLast_PathIndex
Type); |
| 34 |
| 24 static const GrGLenum gXformType2GLType[] = { | 35 static const GrGLenum gXformType2GLType[] = { |
| 25 GR_GL_NONE, | 36 GR_GL_NONE, |
| 26 GR_GL_TRANSLATE_X, | 37 GR_GL_TRANSLATE_X, |
| 27 GR_GL_TRANSLATE_Y, | 38 GR_GL_TRANSLATE_Y, |
| 28 GR_GL_TRANSLATE_2D, | 39 GR_GL_TRANSLATE_2D, |
| 29 GR_GL_TRANSPOSE_AFFINE_2D | 40 GR_GL_TRANSPOSE_AFFINE_2D |
| 30 }; | 41 }; |
| 31 | 42 |
| 32 GR_STATIC_ASSERT(0 == GrPathRendering::kNone_PathTransformType); | 43 GR_STATIC_ASSERT(0 == GrPathRendering::kNone_PathTransformType); |
| 33 GR_STATIC_ASSERT(1 == GrPathRendering::kTranslateX_PathTransformType); | 44 GR_STATIC_ASSERT(1 == GrPathRendering::kTranslateX_PathTransformType); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 if (stroke.needToApply()) { | 198 if (stroke.needToApply()) { |
| 188 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { | 199 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
| 189 GL_CALL(StencilFillPath(id, fillMode, writeMask)); | 200 GL_CALL(StencilFillPath(id, fillMode, writeMask)); |
| 190 } | 201 } |
| 191 this->stencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUNDING_B
OX); | 202 this->stencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUNDING_B
OX); |
| 192 } else { | 203 } else { |
| 193 this->stencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUNDING_B
OX); | 204 this->stencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUNDING_B
OX); |
| 194 } | 205 } |
| 195 } | 206 } |
| 196 | 207 |
| 197 void GrGLPathRendering::drawPaths(const GrPathRange* pathRange, const uint32_t i
ndices[], int count, | 208 void GrGLPathRendering::drawPaths(const GrPathRange* pathRange, |
| 198 const float transforms[], PathTransformType tr
ansformsType, | 209 const void* indices, PathIndexType indexType, |
| 199 const GrStencilSettings& stencilSettings) { | 210 const float transformValues[], PathTransformTy
pe transformType, |
| 211 int count, const GrStencilSettings& stencilSet
tings) { |
| 200 SkASSERT(fGpu->caps()->pathRenderingSupport()); | 212 SkASSERT(fGpu->caps()->pathRenderingSupport()); |
| 201 | 213 |
| 202 GrGLuint baseID = static_cast<const GrGLPathRange*>(pathRange)->basePathID()
; | 214 GrGLuint baseID = static_cast<const GrGLPathRange*>(pathRange)->basePathID()
; |
| 203 | 215 |
| 204 this->flushPathStencilSettings(stencilSettings); | 216 this->flushPathStencilSettings(stencilSettings); |
| 205 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 217 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 206 | 218 |
| 207 const SkStrokeRec& stroke = pathRange->getStroke(); | 219 const SkStrokeRec& stroke = pathRange->getStroke(); |
| 208 | 220 |
| 209 GrGLenum fillMode = | 221 GrGLenum fillMode = |
| 210 gr_stencil_op_to_gl_path_rendering_fill_mode( | 222 gr_stencil_op_to_gl_path_rendering_fill_mode( |
| 211 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); | 223 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); |
| 212 GrGLint writeMask = | 224 GrGLint writeMask = |
| 213 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); | 225 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); |
| 214 | 226 |
| 215 if (stroke.needToApply()) { | 227 if (stroke.needToApply()) { |
| 216 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { | 228 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { |
| 217 GL_CALL(StencilFillPathInstanced( | 229 GL_CALL(StencilFillPathInstanced( |
| 218 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode
, | 230 count, gIndexType2GLType[indexType], indices, baseID
, fillMode, |
| 219 writeMask, gXformType2GLType[transformsType], | 231 writeMask, gXformType2GLType[transformType], transfo
rmValues)); |
| 220 transforms)); | |
| 221 } | 232 } |
| 222 this->stencilThenCoverStrokePathInstanced( | 233 this->stencilThenCoverStrokePathInstanced( |
| 223 count, GR_GL_UNSIGNED_INT, indices, baseID, 0xffff,
writeMask, | 234 count, gIndexType2GLType[indexType], indices, baseID
, |
| 224 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, | 235 0xffff, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_BO
XES, |
| 225 gXformType2GLType[transformsType], transforms); | 236 gXformType2GLType[transformType], transformValues); |
| 226 } else { | 237 } else { |
| 227 this->stencilThenCoverFillPathInstanced( | 238 this->stencilThenCoverFillPathInstanced( |
| 228 count, GR_GL_UNSIGNED_INT, indices, baseID, fillMode
, writeMask, | 239 count, gIndexType2GLType[indexType], indices, baseID
, |
| 229 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, | 240 fillMode, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_
BOXES, |
| 230 gXformType2GLType[transformsType], transforms); | 241 gXformType2GLType[transformType], transformValues); |
| 231 } | 242 } |
| 232 } | 243 } |
| 233 | 244 |
| 234 void GrGLPathRendering::enablePathTexGen(int unitIdx, PathTexGenComponents compo
nents, | 245 void GrGLPathRendering::enablePathTexGen(int unitIdx, PathTexGenComponents compo
nents, |
| 235 const GrGLfloat* coefficients) { | 246 const GrGLfloat* coefficients) { |
| 236 SkASSERT(components >= kS_PathTexGenComponents && | 247 SkASSERT(components >= kS_PathTexGenComponents && |
| 237 components <= kSTR_PathTexGenComponents); | 248 components <= kSTR_PathTexGenComponents); |
| 238 SkASSERT(fGpu->glCaps().maxFixedFunctionTextureCoords() >= unitIdx); | 249 SkASSERT(fGpu->glCaps().maxFixedFunctionTextureCoords() >= unitIdx); |
| 239 | 250 |
| 240 if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode && | 251 if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode && |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 reference, mask, coverMode,
transformType, | 469 reference, mask, coverMode,
transformType, |
| 459 transformValues)); | 470 transformValues)); |
| 460 return; | 471 return; |
| 461 } | 472 } |
| 462 | 473 |
| 463 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase, | 474 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase, |
| 464 reference, mask, transformType, transform
Values)); | 475 reference, mask, transformType, transform
Values)); |
| 465 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase, | 476 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase, |
| 466 coverMode, transformType, transformValues))
; | 477 coverMode, transformType, transformValues))
; |
| 467 } | 478 } |
| OLD | NEW |