Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: src/gpu/gl/GrGLPathRendering.cpp

Issue 1969693003: Revert of Separate user and raw stencil settings (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLPathRendering.h ('k') | src/gpu/gl/GrGLUtil.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 kIncClamp_StencilOp:
74 return GR_GL_COUNT_UP; 74 return GR_GL_COUNT_UP;
75 case GrStencilOp::kInvert: 75 case kInvert_StencilOp:
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
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 = 136 GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode(
137 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.fron t().fPassOp); 137 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
138 GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; 138 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
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 = 160 GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode(
161 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.fron t().fPassOp); 161 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
162 GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; 162 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
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
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(fHWPathStencilSettings.fron t().fPassOp); 194 gr_stencil_op_to_gl_path_rendering_fill_mode(
195 GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; 195 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
196 GrGLint writeMask =
197 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
196 198
197 if (glPathRange->shouldStroke()) { 199 if (glPathRange->shouldStroke()) {
198 if (glPathRange->shouldFill()) { 200 if (glPathRange->shouldFill()) {
199 GL_CALL(StencilFillPathInstanced( 201 GL_CALL(StencilFillPathInstanced(
200 count, gIndexType2GLType[indexType], indices, glPath Range->basePathID(), 202 count, gIndexType2GLType[indexType], indices, glPath Range->basePathID(),
201 fillMode, writeMask, gXformType2GLType[transformType ], 203 fillMode, writeMask, gXformType2GLType[transformType ],
202 transformValues)); 204 transformValues));
203 } 205 }
204 GL_CALL(StencilThenCoverStrokePathInstanced( 206 GL_CALL(StencilThenCoverStrokePathInstanced(
205 count, gIndexType2GLType[indexType], indices, glPath Range->basePathID(), 207 count, gIndexType2GLType[indexType], indices, glPath Range->basePathID(),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 315
314 void GrGLPathRendering::deletePaths(GrGLuint path, GrGLsizei range) { 316 void GrGLPathRendering::deletePaths(GrGLuint path, GrGLsizei range) {
315 GL_CALL(DeletePaths(path, range)); 317 GL_CALL(DeletePaths(path, range));
316 } 318 }
317 319
318 void GrGLPathRendering::flushPathStencilSettings(const GrStencilSettings& stenci lSettings) { 320 void GrGLPathRendering::flushPathStencilSettings(const GrStencilSettings& stenci lSettings) {
319 if (fHWPathStencilSettings != stencilSettings) { 321 if (fHWPathStencilSettings != stencilSettings) {
320 SkASSERT(stencilSettings.isValid()); 322 SkASSERT(stencilSettings.isValid());
321 // Just the func, ref, and mask is set here. The op and write mask are p arams to the call 323 // Just the func, ref, and mask is set here. The op and write mask are p arams to the call
322 // that draws the path to the SB (glStencilFillPath) 324 // that draws the path to the SB (glStencilFillPath)
323 uint16_t ref = stencilSettings.front().fRef; 325 const GrStencilSettings::Face kFront_Face = GrStencilSettings::kFront_Fa ce;
324 GrStencilTest test = stencilSettings.front().fTest; 326 GrStencilFunc func = stencilSettings.func(kFront_Face);
325 uint16_t testMask = stencilSettings.front().fTestMask; 327 uint16_t funcRef = stencilSettings.funcRef(kFront_Face);
328 uint16_t funcMask = stencilSettings.funcMask(kFront_Face);
326 329
327 if (!fHWPathStencilSettings.isValid() || 330 if (!fHWPathStencilSettings.isValid() ||
328 ref != fHWPathStencilSettings.front().fRef || 331 func != fHWPathStencilSettings.func(kFront_Face) ||
329 test != fHWPathStencilSettings.front().fTest || 332 funcRef != fHWPathStencilSettings.funcRef(kFront_Face) ||
330 testMask != fHWPathStencilSettings.front().fTestMask) { 333 funcMask != fHWPathStencilSettings.funcMask(kFront_Face)) {
331 GL_CALL(PathStencilFunc(GrToGLStencilFunc(test), ref, testMask)); 334 GL_CALL(PathStencilFunc(GrToGLStencilFunc(func), funcRef, funcMask)) ;
332 } 335 }
333 fHWPathStencilSettings = stencilSettings; 336 fHWPathStencilSettings = stencilSettings;
334 } 337 }
335 } 338 }
336 339
337 inline GrGLGpu* GrGLPathRendering::gpu() { 340 inline GrGLGpu* GrGLPathRendering::gpu() {
338 return static_cast<GrGLGpu*>(fGpu); 341 return static_cast<GrGLGpu*>(fGpu);
339 } 342 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLPathRendering.h ('k') | src/gpu/gl/GrGLUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698