cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "gl/GrGLPathRendering.h" |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 9 | #include "gl/GrGLUtil.h" |
jvanverth | 39edf76 | 2014-12-22 11:44:19 -0800 | [diff] [blame] | 10 | #include "gl/GrGLGpu.h" |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 11 | |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 12 | #include "GrGLPath.h" |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 13 | #include "GrGLPathRendering.h" |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 14 | #include "GrRenderTargetProxy.h" |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 15 | |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 16 | #include "SkStream.h" |
| 17 | #include "SkTypeface.h" |
| 18 | |
kkinnunen | cabe20c | 2015-06-01 01:37:26 -0700 | [diff] [blame] | 19 | #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) |
| 20 | #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->gpu()->glInterface(), RET, X) |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 21 | |
kkinnunen | 702501d | 2016-01-13 23:36:45 -0800 | [diff] [blame] | 22 | // Number of paths to allocate per glGenPaths call. The call can be overly slow on command buffer GL |
| 23 | // implementation. The call has a result value, and thus waiting for the call completion is needed. |
| 24 | static const GrGLsizei kPathIDPreallocationAmount = 65536; |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 25 | |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 26 | GR_STATIC_ASSERT(0 == GrPathRendering::kNone_PathTransformType); |
| 27 | GR_STATIC_ASSERT(1 == GrPathRendering::kTranslateX_PathTransformType); |
| 28 | GR_STATIC_ASSERT(2 == GrPathRendering::kTranslateY_PathTransformType); |
| 29 | GR_STATIC_ASSERT(3 == GrPathRendering::kTranslate_PathTransformType); |
| 30 | GR_STATIC_ASSERT(4 == GrPathRendering::kAffine_PathTransformType); |
| 31 | GR_STATIC_ASSERT(GrPathRendering::kAffine_PathTransformType == GrPathRendering::kLast_PathTransformType); |
| 32 | |
kkinnunen | 68c63b3 | 2016-03-04 00:12:33 -0800 | [diff] [blame] | 33 | #ifdef SK_DEBUG |
kkinnunen | 68c63b3 | 2016-03-04 00:12:33 -0800 | [diff] [blame] | 34 | |
| 35 | static void verify_floats(const float* floats, int count) { |
| 36 | for (int i = 0; i < count; ++i) { |
| 37 | SkASSERT(!SkScalarIsNaN(SkFloatToScalar(floats[i]))); |
| 38 | } |
| 39 | } |
| 40 | #endif |
| 41 | |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 42 | static GrGLenum gr_stencil_op_to_gl_path_rendering_fill_mode(GrStencilOp op) { |
| 43 | switch (op) { |
| 44 | default: |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 45 | SK_ABORT("Unexpected path fill."); |
Brian Salomon | 2335644 | 2018-11-30 15:33:19 -0500 | [diff] [blame] | 46 | /* fallthrough */ |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 47 | case GrStencilOp::kIncWrap: |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 48 | return GR_GL_COUNT_UP; |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 49 | case GrStencilOp::kInvert: |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 50 | return GR_GL_INVERT; |
| 51 | } |
| 52 | } |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 53 | |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 54 | GrGLPathRendering::GrGLPathRendering(GrGLGpu* gpu) |
kkinnunen | 702501d | 2016-01-13 23:36:45 -0800 | [diff] [blame] | 55 | : GrPathRendering(gpu) |
| 56 | , fPreallocatedPathCount(0) { |
kkinnunen | 6bb6d40 | 2015-07-14 10:59:23 -0700 | [diff] [blame] | 57 | const GrGLInterface* glInterface = gpu->glInterface(); |
Mike Klein | 7634330 | 2017-06-22 13:15:13 -0700 | [diff] [blame] | 58 | fCaps.bindFragmentInputSupport = (bool)glInterface->fFunctions.fBindFragmentInputLocation; |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | GrGLPathRendering::~GrGLPathRendering() { |
kkinnunen | 702501d | 2016-01-13 23:36:45 -0800 | [diff] [blame] | 62 | if (fPreallocatedPathCount > 0) { |
| 63 | this->deletePaths(fFirstPreallocatedPathID, fPreallocatedPathCount); |
| 64 | } |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 65 | } |
| 66 | |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 67 | void GrGLPathRendering::disconnect(GrGpu::DisconnectType type) { |
| 68 | if (GrGpu::DisconnectType::kCleanup == type) { |
| 69 | this->deletePaths(fFirstPreallocatedPathID, fPreallocatedPathCount); |
Brian Salomon | 2335644 | 2018-11-30 15:33:19 -0500 | [diff] [blame] | 70 | } |
kkinnunen | 702501d | 2016-01-13 23:36:45 -0800 | [diff] [blame] | 71 | fPreallocatedPathCount = 0; |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 72 | } |
| 73 | |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 74 | void GrGLPathRendering::resetContext() { |
| 75 | fHWProjectionMatrixState.invalidate(); |
| 76 | // we don't use the model view matrix. |
jvanverth | 5053063 | 2015-04-27 10:36:27 -0700 | [diff] [blame] | 77 | GL_CALL(MatrixLoadIdentity(GR_GL_PATH_MODELVIEW)); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 78 | |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 79 | fHWPathStencilSettings.invalidate(); |
| 80 | } |
| 81 | |
Robert Phillips | 67d52cf | 2017-06-05 13:38:13 -0400 | [diff] [blame] | 82 | sk_sp<GrPath> GrGLPathRendering::createPath(const SkPath& inPath, const GrStyle& style) { |
| 83 | return sk_make_sp<GrGLPath>(this->gpu(), inPath, style); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 84 | } |
| 85 | |
kkinnunen | cabe20c | 2015-06-01 01:37:26 -0700 | [diff] [blame] | 86 | void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath* path) { |
| 87 | GrGLGpu* gpu = this->gpu(); |
| 88 | SkASSERT(gpu->caps()->shaderCaps()->pathRenderingSupport()); |
| 89 | gpu->flushColorWrite(false); |
kkinnunen | cabe20c | 2015-06-01 01:37:26 -0700 | [diff] [blame] | 90 | |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 91 | GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(args.fProxy->peekRenderTarget()); |
kkinnunen | cabe20c | 2015-06-01 01:37:26 -0700 | [diff] [blame] | 92 | SkISize size = SkISize::Make(rt->width(), rt->height()); |
Chris Dalton | c8ece3d | 2018-07-30 15:03:45 -0600 | [diff] [blame] | 93 | this->setProjectionMatrix(*args.fViewMatrix, size, args.fProxy->origin()); |
| 94 | gpu->flushScissor(*args.fScissor, rt->getViewport(), args.fProxy->origin()); |
cdalton | af8bc7d | 2016-02-05 09:35:20 -0800 | [diff] [blame] | 95 | gpu->flushHWAAState(rt, args.fUseHWAA, true); |
Chris Dalton | c8ece3d | 2018-07-30 15:03:45 -0600 | [diff] [blame] | 96 | gpu->flushRenderTarget(rt); |
kkinnunen | cabe20c | 2015-06-01 01:37:26 -0700 | [diff] [blame] | 97 | |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 98 | const GrGLPath* glPath = static_cast<const GrGLPath*>(path); |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 99 | |
kkinnunen | cabe20c | 2015-06-01 01:37:26 -0700 | [diff] [blame] | 100 | this->flushPathStencilSettings(*args.fStencil); |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 101 | SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 102 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 103 | GrGLenum fillMode = |
| 104 | gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.front().fPassOp); |
| 105 | GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; |
joshualitt | 92e496f | 2014-10-31 13:56:50 -0700 | [diff] [blame] | 106 | |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 107 | if (glPath->shouldFill()) { |
| 108 | GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); |
joshualitt | 92e496f | 2014-10-31 13:56:50 -0700 | [diff] [blame] | 109 | } |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 110 | if (glPath->shouldStroke()) { |
| 111 | GL_CALL(StencilStrokePath(glPath->pathID(), 0xffff, writeMask)); |
joshualitt | 92e496f | 2014-10-31 13:56:50 -0700 | [diff] [blame] | 112 | } |
| 113 | } |
| 114 | |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 115 | void GrGLPathRendering::onDrawPath(GrRenderTarget* renderTarget, GrSurfaceOrigin origin, |
| 116 | const GrPrimitiveProcessor& primProc, |
Brian Salomon | ff168d9 | 2018-06-23 15:17:27 -0400 | [diff] [blame] | 117 | const GrPipeline& pipeline, |
Brian Salomon | 4934890 | 2018-06-26 09:12:38 -0400 | [diff] [blame] | 118 | const GrPipeline::FixedDynamicState& fixedDynamicState, |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 119 | const GrStencilSettings& stencilPassSettings, |
stephana | 1dc1721 | 2016-04-25 07:01:22 -0700 | [diff] [blame] | 120 | const GrPath* path) { |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 121 | if (!this->gpu()->flushGLState(renderTarget, origin, primProc, pipeline, |
| 122 | &fixedDynamicState, nullptr, 1, false)) { |
stephana | 1dc1721 | 2016-04-25 07:01:22 -0700 | [diff] [blame] | 123 | return; |
| 124 | } |
| 125 | const GrGLPath* glPath = static_cast<const GrGLPath*>(path); |
| 126 | |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 127 | this->flushPathStencilSettings(stencilPassSettings); |
stephana | 1dc1721 | 2016-04-25 07:01:22 -0700 | [diff] [blame] | 128 | SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 129 | |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 130 | GrGLenum fillMode = |
| 131 | gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.front().fPassOp); |
| 132 | GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; |
stephana | 1dc1721 | 2016-04-25 07:01:22 -0700 | [diff] [blame] | 133 | |
| 134 | if (glPath->shouldStroke()) { |
| 135 | if (glPath->shouldFill()) { |
| 136 | GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); |
| 137 | } |
| 138 | GL_CALL(StencilThenCoverStrokePath(glPath->pathID(), 0xffff, writeMask, |
| 139 | GR_GL_BOUNDING_BOX)); |
| 140 | } else { |
| 141 | GL_CALL(StencilThenCoverFillPath(glPath->pathID(), fillMode, writeMask, |
| 142 | GR_GL_BOUNDING_BOX)); |
| 143 | } |
| 144 | } |
| 145 | |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 146 | void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, GrGLint location, |
| 147 | GrGLenum genMode, GrGLint components, |
| 148 | const SkMatrix& matrix) { |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 149 | float coefficients[3 * 3]; |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 150 | SkASSERT(components >= 1 && components <= 3); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 151 | |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 152 | coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); |
| 153 | coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]); |
| 154 | coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 155 | |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 156 | if (components >= 2) { |
| 157 | coefficients[3] = SkScalarToFloat(matrix[SkMatrix::kMSkewY]); |
| 158 | coefficients[4] = SkScalarToFloat(matrix[SkMatrix::kMScaleY]); |
| 159 | coefficients[5] = SkScalarToFloat(matrix[SkMatrix::kMTransY]); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 160 | } |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 161 | |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 162 | if (components >= 3) { |
| 163 | coefficients[6] = SkScalarToFloat(matrix[SkMatrix::kMPersp0]); |
| 164 | coefficients[7] = SkScalarToFloat(matrix[SkMatrix::kMPersp1]); |
| 165 | coefficients[8] = SkScalarToFloat(matrix[SkMatrix::kMPersp2]); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 166 | } |
kkinnunen | 68c63b3 | 2016-03-04 00:12:33 -0800 | [diff] [blame] | 167 | SkDEBUGCODE(verify_floats(coefficients, components * 3)); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 168 | |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 169 | GL_CALL(ProgramPathFragmentInputGen(program, location, genMode, components, coefficients)); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | void GrGLPathRendering::setProjectionMatrix(const SkMatrix& matrix, |
joshualitt | ee2af95 | 2014-12-30 09:04:15 -0800 | [diff] [blame] | 173 | const SkISize& renderTargetSize, |
| 174 | GrSurfaceOrigin renderTargetOrigin) { |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 175 | |
kkinnunen | cabe20c | 2015-06-01 01:37:26 -0700 | [diff] [blame] | 176 | SkASSERT(this->gpu()->glCaps().shaderCaps()->pathRenderingSupport()); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 177 | |
| 178 | if (renderTargetOrigin == fHWProjectionMatrixState.fRenderTargetOrigin && |
| 179 | renderTargetSize == fHWProjectionMatrixState.fRenderTargetSize && |
| 180 | matrix.cheapEqualTo(fHWProjectionMatrixState.fViewMatrix)) { |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | fHWProjectionMatrixState.fViewMatrix = matrix; |
| 185 | fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize; |
| 186 | fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin; |
| 187 | |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 188 | float glMatrix[4 * 4]; |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 189 | fHWProjectionMatrixState.getRTAdjustedGLMatrix<4>(glMatrix); |
kkinnunen | 68c63b3 | 2016-03-04 00:12:33 -0800 | [diff] [blame] | 190 | SkDEBUGCODE(verify_floats(glMatrix, SK_ARRAY_COUNT(glMatrix))); |
jvanverth | 5053063 | 2015-04-27 10:36:27 -0700 | [diff] [blame] | 191 | GL_CALL(MatrixLoadf(GR_GL_PATH_PROJECTION, glMatrix)); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 192 | } |
| 193 | |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 194 | GrGLuint GrGLPathRendering::genPaths(GrGLsizei range) { |
kkinnunen | 702501d | 2016-01-13 23:36:45 -0800 | [diff] [blame] | 195 | SkASSERT(range > 0); |
| 196 | GrGLuint firstID; |
| 197 | if (fPreallocatedPathCount >= range) { |
| 198 | firstID = fFirstPreallocatedPathID; |
| 199 | fPreallocatedPathCount -= range; |
| 200 | fFirstPreallocatedPathID += range; |
| 201 | return firstID; |
| 202 | } |
| 203 | // Allocate range + the amount to fill up preallocation amount. If succeed, either join with |
| 204 | // the existing preallocation range or delete the existing and use the new (potentially partial) |
| 205 | // preallocation range. |
| 206 | GrGLsizei allocAmount = range + (kPathIDPreallocationAmount - fPreallocatedPathCount); |
| 207 | if (allocAmount >= range) { |
| 208 | GL_CALL_RET(firstID, GenPaths(allocAmount)); |
| 209 | |
| 210 | if (firstID != 0) { |
| 211 | if (fPreallocatedPathCount > 0 && |
| 212 | firstID == fFirstPreallocatedPathID + fPreallocatedPathCount) { |
| 213 | firstID = fFirstPreallocatedPathID; |
| 214 | fPreallocatedPathCount += allocAmount - range; |
| 215 | fFirstPreallocatedPathID += range; |
| 216 | return firstID; |
| 217 | } |
| 218 | |
| 219 | if (allocAmount > range) { |
| 220 | if (fPreallocatedPathCount > 0) { |
| 221 | this->deletePaths(fFirstPreallocatedPathID, fPreallocatedPathCount); |
| 222 | } |
| 223 | fFirstPreallocatedPathID = firstID + range; |
| 224 | fPreallocatedPathCount = allocAmount - range; |
| 225 | } |
| 226 | // Special case: if allocAmount == range, we have full preallocated range. |
| 227 | return firstID; |
| 228 | } |
| 229 | } |
| 230 | // Failed to allocate with preallocation. Remove existing preallocation and try to allocate just |
| 231 | // the range. |
| 232 | if (fPreallocatedPathCount > 0) { |
| 233 | this->deletePaths(fFirstPreallocatedPathID, fPreallocatedPathCount); |
| 234 | fPreallocatedPathCount = 0; |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 235 | } |
| 236 | |
kkinnunen | 702501d | 2016-01-13 23:36:45 -0800 | [diff] [blame] | 237 | GL_CALL_RET(firstID, GenPaths(range)); |
| 238 | if (firstID == 0) { |
| 239 | SkDebugf("Warning: Failed to allocate path\n"); |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 240 | } |
kkinnunen | 702501d | 2016-01-13 23:36:45 -0800 | [diff] [blame] | 241 | return firstID; |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 242 | } |
| 243 | |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 244 | void GrGLPathRendering::deletePaths(GrGLuint path, GrGLsizei range) { |
kkinnunen | 702501d | 2016-01-13 23:36:45 -0800 | [diff] [blame] | 245 | GL_CALL(DeletePaths(path, range)); |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 246 | } |
| 247 | |
joshualitt | 92e496f | 2014-10-31 13:56:50 -0700 | [diff] [blame] | 248 | void GrGLPathRendering::flushPathStencilSettings(const GrStencilSettings& stencilSettings) { |
| 249 | if (fHWPathStencilSettings != stencilSettings) { |
kkinnunen | 1517f93 | 2016-01-25 06:07:26 -0800 | [diff] [blame] | 250 | SkASSERT(stencilSettings.isValid()); |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 251 | // Just the func, ref, and mask is set here. The op and write mask are params to the call |
| 252 | // that draws the path to the SB (glStencilFillPath) |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 253 | uint16_t ref = stencilSettings.front().fRef; |
| 254 | GrStencilTest test = stencilSettings.front().fTest; |
| 255 | uint16_t testMask = stencilSettings.front().fTestMask; |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 256 | |
kkinnunen | 1517f93 | 2016-01-25 06:07:26 -0800 | [diff] [blame] | 257 | if (!fHWPathStencilSettings.isValid() || |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 258 | ref != fHWPathStencilSettings.front().fRef || |
| 259 | test != fHWPathStencilSettings.front().fTest || |
| 260 | testMask != fHWPathStencilSettings.front().fTestMask) { |
| 261 | GL_CALL(PathStencilFunc(GrToGLStencilFunc(test), ref, testMask)); |
kkinnunen | 1517f93 | 2016-01-25 06:07:26 -0800 | [diff] [blame] | 262 | } |
joshualitt | 92e496f | 2014-10-31 13:56:50 -0700 | [diff] [blame] | 263 | fHWPathStencilSettings = stencilSettings; |
kkinnunen | 5b65357 | 2014-08-20 04:13:27 -0700 | [diff] [blame] | 264 | } |
cdalton | c7103a1 | 2014-08-11 14:05:05 -0700 | [diff] [blame] | 265 | } |
| 266 | |
kkinnunen | cabe20c | 2015-06-01 01:37:26 -0700 | [diff] [blame] | 267 | inline GrGLGpu* GrGLPathRendering::gpu() { |
| 268 | return static_cast<GrGLGpu*>(fGpu); |
| 269 | } |