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

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

Issue 709133003: Snap optdrawstate in inorder draw buffer and pass into gpu (Closed) Base URL: https://skia.googlesource.com/skia.git@remove_friends
Patch Set: Created 6 years, 1 month 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/GrTest.cpp ('k') | src/gpu/gl/GrGpuGL.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/GrGLNameAllocator.h" 9 #include "gl/GrGLNameAllocator.h"
10 #include "gl/GrGLUtil.h" 10 #include "gl/GrGLUtil.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 // This is a crude approximation. We may want to consider giving this class 148 // This is a crude approximation. We may want to consider giving this class
149 // a pseudo PathGenerator whose sole purpose is to track the approximate gpu 149 // a pseudo PathGenerator whose sole purpose is to track the approximate gpu
150 // memory size. 150 // memory size.
151 const size_t gpuMemorySize = fontDataLength / 4; 151 const size_t gpuMemorySize = fontDataLength / 4;
152 return SkNEW_ARGS(GrGLPathRange, (fGpu, basePathID, numPaths, gpuMemorySize, stroke)); 152 return SkNEW_ARGS(GrGLPathRange, (fGpu, basePathID, numPaths, gpuMemorySize, stroke));
153 } 153 }
154 154
155 void GrGLPathRendering::stencilPath(const GrPath* path, const GrStencilSettings& stencilSettings) { 155 void GrGLPathRendering::stencilPath(const GrPath* path, const GrStencilSettings& stencilSettings) {
156 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); 156 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID();
157 SkASSERT(fGpu->drawState()->getRenderTarget());
158 SkASSERT(fGpu->drawState()->getRenderTarget()->getStencilBuffer());
159 157
160 this->flushPathStencilSettings(stencilSettings); 158 this->flushPathStencilSettings(stencilSettings);
161 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 159 SkASSERT(!fHWPathStencilSettings.isTwoSided());
162 160
163 const SkStrokeRec& stroke = path->getStroke(); 161 const SkStrokeRec& stroke = path->getStroke();
164 162
165 GrGLenum fillMode = 163 GrGLenum fillMode =
166 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face)); 164 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face));
167 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face); 165 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
168 166
169 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.getS tyle()) { 167 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.getS tyle()) {
170 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 168 GL_CALL(StencilFillPath(id, fillMode, writeMask));
171 } 169 }
172 if (stroke.needToApply()) { 170 if (stroke.needToApply()) {
173 GL_CALL(StencilStrokePath(id, 0xffff, writeMask)); 171 GL_CALL(StencilStrokePath(id, 0xffff, writeMask));
174 } 172 }
175 } 173 }
176 174
177 void GrGLPathRendering::drawPath(const GrPath* path, const GrStencilSettings& st encilSettings) { 175 void GrGLPathRendering::drawPath(const GrPath* path, const GrStencilSettings& st encilSettings) {
178 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); 176 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID();
179 SkASSERT(fGpu->drawState()->getRenderTarget());
180 SkASSERT(fGpu->drawState()->getRenderTarget()->getStencilBuffer());
181 177
182 this->flushPathStencilSettings(stencilSettings); 178 this->flushPathStencilSettings(stencilSettings);
183 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 179 SkASSERT(!fHWPathStencilSettings.isTwoSided());
184 180
185 const SkStrokeRec& stroke = path->getStroke(); 181 const SkStrokeRec& stroke = path->getStroke();
186 182
187 GrGLenum fillMode = 183 GrGLenum fillMode =
188 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face)); 184 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face));
189 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face); 185 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
190 186
191 if (stroke.needToApply()) { 187 if (stroke.needToApply()) {
192 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) { 188 if (SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) {
193 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 189 GL_CALL(StencilFillPath(id, fillMode, writeMask));
194 } 190 }
195 this->stencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUNDING_B OX); 191 this->stencilThenCoverStrokePath(id, 0xffff, writeMask, GR_GL_BOUNDING_B OX);
196 } else { 192 } else {
197 this->stencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUNDING_B OX); 193 this->stencilThenCoverFillPath(id, fillMode, writeMask, GR_GL_BOUNDING_B OX);
198 } 194 }
199 } 195 }
200 196
201 void GrGLPathRendering::drawPaths(const GrPathRange* pathRange, const uint32_t i ndices[], int count, 197 void GrGLPathRendering::drawPaths(const GrPathRange* pathRange, const uint32_t i ndices[], int count,
202 const float transforms[], PathTransformType tr ansformsType, 198 const float transforms[], PathTransformType tr ansformsType,
203 const GrStencilSettings& stencilSettings) { 199 const GrStencilSettings& stencilSettings) {
204 SkASSERT(fGpu->caps()->pathRenderingSupport()); 200 SkASSERT(fGpu->caps()->pathRenderingSupport());
205 SkASSERT(fGpu->drawState()->getRenderTarget());
206 SkASSERT(fGpu->drawState()->getRenderTarget()->getStencilBuffer());
207 201
208 GrGLuint baseID = static_cast<const GrGLPathRange*>(pathRange)->basePathID() ; 202 GrGLuint baseID = static_cast<const GrGLPathRange*>(pathRange)->basePathID() ;
209 203
210 this->flushPathStencilSettings(stencilSettings); 204 this->flushPathStencilSettings(stencilSettings);
211 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 205 SkASSERT(!fHWPathStencilSettings.isTwoSided());
212 206
213 const SkStrokeRec& stroke = pathRange->getStroke(); 207 const SkStrokeRec& stroke = pathRange->getStroke();
214 208
215 GrGLenum fillMode = 209 GrGLenum fillMode =
216 gr_stencil_op_to_gl_path_rendering_fill_mode( 210 gr_stencil_op_to_gl_path_rendering_fill_mode(
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 reference, mask, coverMode, transformType, 458 reference, mask, coverMode, transformType,
465 transformValues)); 459 transformValues));
466 return; 460 return;
467 } 461 }
468 462
469 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase, 463 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase,
470 reference, mask, transformType, transform Values)); 464 reference, mask, transformType, transform Values));
471 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase, 465 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase,
472 coverMode, transformType, transformValues)) ; 466 coverMode, transformType, transformValues)) ;
473 } 467 }
OLDNEW
« no previous file with comments | « src/gpu/GrTest.cpp ('k') | src/gpu/gl/GrGpuGL.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698