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

Side by Side Diff: src/gpu/batches/GrMSAAPathRenderer.cpp

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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/batches/GrDrawVerticesBatch.cpp ('k') | src/gpu/batches/GrNinePatch.cpp » ('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 2016 Google Inc. 2 * Copyright 2016 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 "GrMSAAPathRenderer.h" 8 #include "GrMSAAPathRenderer.h"
9 9
10 #include "GrAuditTrail.h" 10 #include "GrAuditTrail.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 }; 77 };
78 78
79 static inline void append_contour_edge_indices(uint16_t fanCenterIdx, 79 static inline void append_contour_edge_indices(uint16_t fanCenterIdx,
80 uint16_t edgeV0Idx, 80 uint16_t edgeV0Idx,
81 MSAALineVertices& lines) { 81 MSAALineVertices& lines) {
82 *(lines.nextIndex++) = fanCenterIdx; 82 *(lines.nextIndex++) = fanCenterIdx;
83 *(lines.nextIndex++) = edgeV0Idx; 83 *(lines.nextIndex++) = edgeV0Idx;
84 *(lines.nextIndex++) = edgeV0Idx + 1; 84 *(lines.nextIndex++) = edgeV0Idx + 1;
85 } 85 }
86 86
87 static inline void add_quad(MSAALineVertices& lines, MSAAQuadVertices& quads, co nst SkPoint pts[], 87 static inline void add_quad(MSAALineVertices& lines, MSAAQuadVertices& quads, co nst SkPoint pts[],
88 SkColor color, bool indexed, uint16_t subpathLineIdx Start) { 88 SkColor color, bool indexed, uint16_t subpathLineIdx Start) {
89 SkASSERT(lines.nextVertex < lines.verticesEnd); 89 SkASSERT(lines.nextVertex < lines.verticesEnd);
90 *lines.nextVertex = { pts[2], color }; 90 *lines.nextVertex = { pts[2], color };
91 if (indexed) { 91 if (indexed) {
92 int prevIdx = (uint16_t) (lines.nextVertex - lines.vertices - 1); 92 int prevIdx = (uint16_t) (lines.nextVertex - lines.vertices - 1);
93 if (prevIdx > subpathLineIdxStart) { 93 if (prevIdx > subpathLineIdxStart) {
94 append_contour_edge_indices(subpathLineIdxStart, prevIdx, lines); 94 append_contour_edge_indices(subpathLineIdxStart, prevIdx, lines);
95 } 95 }
96 } 96 }
97 lines.nextVertex++; 97 lines.nextVertex++;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 // emit attributes 138 // emit attributes
139 varyingHandler->emitAttributes(qp); 139 varyingHandler->emitAttributes(qp);
140 varyingHandler->addPassThroughAttribute(qp.inColor(), args.fOutputCo lor); 140 varyingHandler->addPassThroughAttribute(qp.inColor(), args.fOutputCo lor);
141 141
142 GrGLSLVertToFrag uv(kVec2f_GrSLType); 142 GrGLSLVertToFrag uv(kVec2f_GrSLType);
143 varyingHandler->addVarying("uv", &uv, kHigh_GrSLPrecision); 143 varyingHandler->addVarying("uv", &uv, kHigh_GrSLPrecision);
144 vsBuilder->codeAppendf("%s = %s;", uv.vsOut(), qp.inUV()->fName); 144 vsBuilder->codeAppendf("%s = %s;", uv.vsOut(), qp.inUV()->fName);
145 145
146 // Setup position 146 // Setup position
147 this->setupPosition(vsBuilder, uniformHandler, gpArgs, qp.inPosition ()->fName, 147 this->setupPosition(vsBuilder, uniformHandler, gpArgs, qp.inPosition ()->fName,
148 qp.viewMatrix(), &fViewMatrixUniform); 148 qp.viewMatrix(), &fViewMatrixUniform);
149 149
150 // emit transforms 150 // emit transforms
151 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr gs->fPositionVar, 151 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr gs->fPositionVar,
152 qp.inPosition()->fName, SkMatrix::I(), args.fTr ansformsIn, 152 qp.inPosition()->fName, SkMatrix::I(), args.fTr ansformsIn,
153 args.fTransformsOut); 153 args.fTransformsOut);
154 154
155 GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; 155 GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
156 fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn( ), uv.fsIn(), 156 fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn( ), uv.fsIn(),
157 uv.fsIn( )); 157 uv.fsIn( ));
158 fsBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputCoverage); 158 fsBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputCoverage);
159 } 159 }
160 160
161 static inline void GenKey(const GrGeometryProcessor& gp, 161 static inline void GenKey(const GrGeometryProcessor& gp,
162 const GrGLSLCaps&, 162 const GrGLSLCaps&,
163 GrProcessorKeyBuilder* b) { 163 GrProcessorKeyBuilder* b) {
164 const MSAAQuadProcessor& qp = gp.cast<MSAAQuadProcessor>(); 164 const MSAAQuadProcessor& qp = gp.cast<MSAAQuadProcessor>();
165 uint32_t key = 0; 165 uint32_t key = 0;
166 key |= qp.viewMatrix().hasPerspective() ? 0x1 : 0x0; 166 key |= qp.viewMatrix().hasPerspective() ? 0x1 : 0x0;
(...skipping 30 matching lines...) Expand all
197 } 197 }
198 198
199 virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) cons t override { 199 virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) cons t override {
200 return new GLSLProcessor(*this); 200 return new GLSLProcessor(*this);
201 } 201 }
202 202
203 private: 203 private:
204 MSAAQuadProcessor(const SkMatrix& viewMatrix) 204 MSAAQuadProcessor(const SkMatrix& viewMatrix)
205 : fViewMatrix(viewMatrix) { 205 : fViewMatrix(viewMatrix) {
206 this->initClassID<MSAAQuadProcessor>(); 206 this->initClassID<MSAAQuadProcessor>();
207 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType, 207 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType,
208 kHigh_GrSLPrecision)); 208 kHigh_GrSLPrecision));
209 fInUV = &this->addVertexAttrib(Attribute("inUV", kVec2f_GrVertexAttribTy pe, 209 fInUV = &this->addVertexAttrib(Attribute("inUV", kVec2f_GrVertexAttribTy pe,
210 kHigh_GrSLPrecision)); 210 kHigh_GrSLPrecision));
211 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType)); 211 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA ttribType));
212 this->setSampleShading(1.0f); 212 this->setSampleShading(1.0f);
213 } 213 }
214 214
215 const Attribute* fInPosition; 215 const Attribute* fInPosition;
216 const Attribute* fInUV; 216 const Attribute* fInUV;
217 const Attribute* fInColor; 217 const Attribute* fInColor;
218 SkMatrix fViewMatrix; 218 SkMatrix fViewMatrix;
219 219
220 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 220 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
221 221
222 typedef GrGeometryProcessor INHERITED; 222 typedef GrGeometryProcessor INHERITED;
223 }; 223 };
224 224
225 class MSAAPathBatch : public GrVertexBatch { 225 class MSAAPathBatch : public GrVertexBatch {
226 public: 226 public:
227 DEFINE_BATCH_CLASS_ID 227 DEFINE_BATCH_CLASS_ID
228 228
229 struct Geometry { 229 struct Geometry {
230 GrColor fColor; 230 GrColor fColor;
231 SkPath fPath; 231 SkPath fPath;
232 SkScalar fTolerance; 232 SkScalar fTolerance;
233 }; 233 };
234 234
235 static MSAAPathBatch* Create(const Geometry& geometry, const SkMatrix& viewM atrix, 235 static MSAAPathBatch* Create(const Geometry& geometry, const SkMatrix& viewM atrix,
236 const SkRect& devBounds) { 236 const SkRect& devBounds) {
237 return new MSAAPathBatch(geometry, viewMatrix, devBounds); 237 return new MSAAPathBatch(geometry, viewMatrix, devBounds);
238 } 238 }
239 239
240 const char* name() const override { return "MSAAPathBatch"; } 240 const char* name() const override { return "MSAAPathBatch"; }
241 241
242 void computePipelineOptimizations(GrInitInvariantOutput* color, 242 void computePipelineOptimizations(GrInitInvariantOutput* color,
243 GrInitInvariantOutput* coverage, 243 GrInitInvariantOutput* coverage,
244 GrBatchToXPOverrides* overrides) const ove rride { 244 GrBatchToXPOverrides* overrides) const ove rride {
245 // When this is called on a batch, there is only one geometry bundle 245 // When this is called on a batch, there is only one geometry bundle
246 color->setKnownFourComponents(fGeoData[0].fColor); 246 color->setKnownFourComponents(fGeoData[0].fColor);
247 coverage->setKnownSingleComponent(0xff); 247 coverage->setKnownSingleComponent(0xff);
248 } 248 }
249 249
250 bool isValid() const { 250 bool isValid() const {
251 return !fIsIndexed || fMaxLineIndices <= SK_MaxU16; 251 return !fIsIndexed || fMaxLineIndices <= SK_MaxU16;
252 } 252 }
253 253
254 private: 254 private:
255 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { 255 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
256 // Handle any color overrides 256 // Handle any color overrides
257 if (!overrides.readsColor()) { 257 if (!overrides.readsColor()) {
258 fGeoData[0].fColor = GrColor_ILLEGAL; 258 fGeoData[0].fColor = GrColor_ILLEGAL;
259 } 259 }
260 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 260 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
261 } 261 }
262 262
263 void computeWorstCasePointCount(const SkPath& path, int* subpaths, SkScalar tol, 263 void computeWorstCasePointCount(const SkPath& path, int* subpaths, SkScalar tol,
264 int* outLinePointCount, int* outQuadPointCou nt) const { 264 int* outLinePointCount, int* outQuadPointCou nt) const {
265 int linePointCount = 0; 265 int linePointCount = 0;
266 int quadPointCount = 0; 266 int quadPointCount = 0;
267 *subpaths = 1; 267 *subpaths = 1;
268 268
269 bool first = true; 269 bool first = true;
270 270
271 SkPath::Iter iter(path, false); 271 SkPath::Iter iter(path, false);
272 SkPath::Verb verb; 272 SkPath::Verb verb;
273 273
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 *outQuadPointCount = quadPointCount; 312 *outQuadPointCount = quadPointCount;
313 } 313 }
314 314
315 void onPrepareDraws(Target* target) const override { 315 void onPrepareDraws(Target* target) const override {
316 SkASSERT(this->isValid()); 316 SkASSERT(this->isValid());
317 if (fMaxLineVertices == 0) { 317 if (fMaxLineVertices == 0) {
318 SkASSERT(fMaxQuadVertices == 0); 318 SkASSERT(fMaxQuadVertices == 0);
319 return; 319 return;
320 } 320 }
321 321
322 GrPrimitiveType primitiveType = fIsIndexed ? kTriangles_GrPrimitiveType 322 GrPrimitiveType primitiveType = fIsIndexed ? kTriangles_GrPrimitiveType
323 : kTriangleFan_GrPrimitiveTyp e; 323 : kTriangleFan_GrPrimitiveTyp e;
324 324
325 // allocate vertex / index buffers 325 // allocate vertex / index buffers
326 const GrBuffer* lineVertexBuffer; 326 const GrBuffer* lineVertexBuffer;
327 int firstLineVertex; 327 int firstLineVertex;
328 MSAALineVertices lines; 328 MSAALineVertices lines;
329 size_t lineVertexStride = sizeof(MSAALineVertices::Vertex); 329 size_t lineVertexStride = sizeof(MSAALineVertices::Vertex);
330 lines.vertices = (MSAALineVertices::Vertex*) target->makeVertexSpace(lin eVertexStride, 330 lines.vertices = (MSAALineVertices::Vertex*) target->makeVertexSpace(lin eVertexStride,
331 fMa xLineVertices, 331 fMa xLineVertices,
332 &li neVertexBuffer, 332 &li neVertexBuffer,
333 &fi rstLineVertex); 333 &fi rstLineVertex);
334 if (!lines.vertices) { 334 if (!lines.vertices) {
335 SkDebugf("Could not allocate vertices\n"); 335 SkDebugf("Could not allocate vertices\n");
336 return; 336 return;
337 } 337 }
338 lines.nextVertex = lines.vertices; 338 lines.nextVertex = lines.vertices;
339 SkDEBUGCODE(lines.verticesEnd = lines.vertices + fMaxLineVertices;) 339 SkDEBUGCODE(lines.verticesEnd = lines.vertices + fMaxLineVertices;)
340 340
341 MSAAQuadVertices quads; 341 MSAAQuadVertices quads;
342 size_t quadVertexStride = sizeof(MSAAQuadVertices::Vertex); 342 size_t quadVertexStride = sizeof(MSAAQuadVertices::Vertex);
343 SkAutoFree quadVertexPtr(sk_malloc_throw(fMaxQuadVertices * quadVertexSt ride)); 343 SkAutoFree quadVertexPtr(sk_malloc_throw(fMaxQuadVertices * quadVertexSt ride));
344 quads.vertices = (MSAAQuadVertices::Vertex*) quadVertexPtr.get(); 344 quads.vertices = (MSAAQuadVertices::Vertex*) quadVertexPtr.get();
345 quads.nextVertex = quads.vertices; 345 quads.nextVertex = quads.vertices;
346 SkDEBUGCODE(quads.verticesEnd = quads.vertices + fMaxQuadVertices;) 346 SkDEBUGCODE(quads.verticesEnd = quads.vertices + fMaxQuadVertices;)
347 347
348 const GrBuffer* lineIndexBuffer = nullptr; 348 const GrBuffer* lineIndexBuffer = nullptr;
349 int firstLineIndex; 349 int firstLineIndex;
350 if (fIsIndexed) { 350 if (fIsIndexed) {
351 lines.indices = target->makeIndexSpace(fMaxLineIndices, &lineIndexBu ffer, 351 lines.indices = target->makeIndexSpace(fMaxLineIndices, &lineIndexBu ffer,
352 &firstLineIndex); 352 &firstLineIndex);
353 if (!lines.indices) { 353 if (!lines.indices) {
354 SkDebugf("Could not allocate indices\n"); 354 SkDebugf("Could not allocate indices\n");
355 return; 355 return;
356 } 356 }
357 lines.nextIndex = lines.indices; 357 lines.nextIndex = lines.indices;
358 } else { 358 } else {
359 lines.indices = nullptr; 359 lines.indices = nullptr;
360 lines.nextIndex = nullptr; 360 lines.nextIndex = nullptr;
361 } 361 }
(...skipping 23 matching lines...) Expand all
385 } 385 }
386 } 386 }
387 int lineVertexOffset = (int) (lines.nextVertex - lines.vertices); 387 int lineVertexOffset = (int) (lines.nextVertex - lines.vertices);
388 int lineIndexOffset = (int) (lines.nextIndex - lines.indices); 388 int lineIndexOffset = (int) (lines.nextIndex - lines.indices);
389 SkASSERT(lineVertexOffset <= fMaxLineVertices && lineIndexOffset <= fMax LineIndices); 389 SkASSERT(lineVertexOffset <= fMaxLineVertices && lineIndexOffset <= fMax LineIndices);
390 int quadVertexOffset = (int) (quads.nextVertex - quads.vertices); 390 int quadVertexOffset = (int) (quads.nextVertex - quads.vertices);
391 int quadIndexOffset = (int) (quads.nextIndex - quads.indices); 391 int quadIndexOffset = (int) (quads.nextIndex - quads.indices);
392 SkASSERT(quadVertexOffset <= fMaxQuadVertices && quadIndexOffset <= fMax QuadIndices); 392 SkASSERT(quadVertexOffset <= fMaxQuadVertices && quadIndexOffset <= fMax QuadIndices);
393 393
394 if (lineVertexOffset) { 394 if (lineVertexOffset) {
395 SkAutoTUnref<const GrGeometryProcessor> lineGP; 395 sk_sp<GrGeometryProcessor> lineGP;
396 { 396 {
397 using namespace GrDefaultGeoProcFactory; 397 using namespace GrDefaultGeoProcFactory;
398 lineGP.reset(GrDefaultGeoProcFactory::Create(Color(Color::kAttri bute_Type), 398 lineGP = GrDefaultGeoProcFactory::Make(Color(Color::kAttribute_T ype),
399 Coverage(255), 399 Coverage(255),
400 LocalCoords(LocalCo ords::kUnused_Type), 400 LocalCoords(LocalCoords:: kUnused_Type),
401 fViewMatrix)); 401 fViewMatrix);
402 } 402 }
403 SkASSERT(lineVertexStride == lineGP->getVertexStride()); 403 SkASSERT(lineVertexStride == lineGP->getVertexStride());
404 404
405 GrMesh lineMeshes; 405 GrMesh lineMeshes;
406 if (fIsIndexed) { 406 if (fIsIndexed) {
407 lineMeshes.initIndexed(primitiveType, lineVertexBuffer, lineInde xBuffer, 407 lineMeshes.initIndexed(primitiveType, lineVertexBuffer, lineInde xBuffer,
408 firstLineVertex, firstLineIndex, lineVe rtexOffset, 408 firstLineVertex, firstLineIndex, lineVe rtexOffset,
409 lineIndexOffset); 409 lineIndexOffset);
410 } else { 410 } else {
411 lineMeshes.init(primitiveType, lineVertexBuffer, firstLineVertex , 411 lineMeshes.init(primitiveType, lineVertexBuffer, firstLineVertex ,
412 lineVertexOffset); 412 lineVertexOffset);
413 } 413 }
414 target->draw(lineGP, lineMeshes); 414 target->draw(lineGP.get(), lineMeshes);
415 } 415 }
416 416
417 if (quadVertexOffset) { 417 if (quadVertexOffset) {
418 SkAutoTUnref<const GrGeometryProcessor> quadGP(MSAAQuadProcessor::Cr eate(fViewMatrix)); 418 SkAutoTUnref<const GrGeometryProcessor> quadGP(MSAAQuadProcessor::Cr eate(fViewMatrix));
419 SkASSERT(quadVertexStride == quadGP->getVertexStride()); 419 SkASSERT(quadVertexStride == quadGP->getVertexStride());
420 420
421 const GrBuffer* quadVertexBuffer; 421 const GrBuffer* quadVertexBuffer;
422 int firstQuadVertex; 422 int firstQuadVertex;
423 MSAAQuadVertices::Vertex* quadVertices = (MSAAQuadVertices::Vertex*) 423 MSAAQuadVertices::Vertex* quadVertices = (MSAAQuadVertices::Vertex*)
424 target->makeVertexSpace(quadVertexStride, quadVertexOffset, &quadVertexBuffer, 424 target->makeVertexSpace(quadVertexStride, quadVertexOffset, &quadVertexBuffer,
425 &firstQuadVertex); 425 &firstQuadVertex);
426 memcpy(quadVertices, quads.vertices, quadVertexStride * quadVertexOf fset); 426 memcpy(quadVertices, quads.vertices, quadVertexStride * quadVertexOf fset);
427 GrMesh quadMeshes; 427 GrMesh quadMeshes;
428 if (fIsIndexed) { 428 if (fIsIndexed) {
429 const GrBuffer* quadIndexBuffer; 429 const GrBuffer* quadIndexBuffer;
430 int firstQuadIndex; 430 int firstQuadIndex;
431 uint16_t* quadIndices = (uint16_t*) target->makeIndexSpace(quadI ndexOffset, 431 uint16_t* quadIndices = (uint16_t*) target->makeIndexSpace(quadI ndexOffset,
432 &quad IndexBuffer, 432 &quad IndexBuffer,
433 &firs tQuadIndex); 433 &firs tQuadIndex);
434 memcpy(quadIndices, quads.indices, sizeof(uint16_t) * quadIndexO ffset); 434 memcpy(quadIndices, quads.indices, sizeof(uint16_t) * quadIndexO ffset);
435 quadMeshes.initIndexed(kTriangles_GrPrimitiveType, quadVertexBuf fer, 435 quadMeshes.initIndexed(kTriangles_GrPrimitiveType, quadVertexBuf fer,
436 quadIndexBuffer, firstQuadVertex, firstQu adIndex, 436 quadIndexBuffer, firstQuadVertex, firstQu adIndex,
437 quadVertexOffset, quadIndexOffset); 437 quadVertexOffset, quadIndexOffset);
438 } else { 438 } else {
439 quadMeshes.init(kTriangles_GrPrimitiveType, quadVertexBuffer, fi rstQuadVertex, 439 quadMeshes.init(kTriangles_GrPrimitiveType, quadVertexBuffer, fi rstQuadVertex,
440 quadVertexOffset); 440 quadVertexOffset);
441 } 441 }
442 target->draw(quadGP, quadMeshes); 442 target->draw(quadGP, quadMeshes);
443 } 443 }
444 } 444 }
445 445
446 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 446 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
447 447
448 MSAAPathBatch(const Geometry& geometry, const SkMatrix& viewMatrix, const Sk Rect& devBounds) 448 MSAAPathBatch(const Geometry& geometry, const SkMatrix& viewMatrix, const Sk Rect& devBounds)
449 : INHERITED(ClassID()) 449 : INHERITED(ClassID())
450 , fViewMatrix(viewMatrix) { 450 , fViewMatrix(viewMatrix) {
451 fGeoData.push_back(geometry); 451 fGeoData.push_back(geometry);
452 this->setBounds(devBounds); 452 this->setBounds(devBounds);
453 int contourCount; 453 int contourCount;
454 this->computeWorstCasePointCount(geometry.fPath, &contourCount, kToleran ce, 454 this->computeWorstCasePointCount(geometry.fPath, &contourCount, kToleran ce,
455 &fMaxLineVertices, &fMaxQuadVertices); 455 &fMaxLineVertices, &fMaxQuadVertices);
456 fMaxLineIndices = fMaxLineVertices * 3; 456 fMaxLineIndices = fMaxLineVertices * 3;
457 fMaxQuadIndices = fMaxQuadVertices * 3; 457 fMaxQuadIndices = fMaxQuadVertices * 3;
458 fIsIndexed = contourCount > 1; 458 fIsIndexed = contourCount > 1;
459 } 459 }
460 460
461 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 461 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
462 MSAAPathBatch* that = t->cast<MSAAPathBatch>(); 462 MSAAPathBatch* that = t->cast<MSAAPathBatch>();
463 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 463 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
464 that->bounds(), caps)) { 464 that->bounds(), caps)) {
465 return false; 465 return false;
466 } 466 }
467 467
468 if (!fViewMatrix.cheapEqualTo(that->fViewMatrix)) { 468 if (!fViewMatrix.cheapEqualTo(that->fViewMatrix)) {
469 return false; 469 return false;
470 } 470 }
471 471
472 if ((fMaxLineIndices + that->fMaxLineIndices > SK_MaxU16) || 472 if ((fMaxLineIndices + that->fMaxLineIndices > SK_MaxU16) ||
473 (fMaxQuadIndices + that->fMaxQuadIndices > SK_MaxU16)) { 473 (fMaxQuadIndices + that->fMaxQuadIndices > SK_MaxU16)) {
474 return false; 474 return false;
475 } 475 }
476 476
477 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ; 477 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ;
478 this->joinBounds(that->bounds()); 478 this->joinBounds(that->bounds());
479 fIsIndexed = true; 479 fIsIndexed = true;
480 fMaxLineVertices += that->fMaxLineVertices; 480 fMaxLineVertices += that->fMaxLineVertices;
481 fMaxQuadVertices += that->fMaxQuadVertices; 481 fMaxQuadVertices += that->fMaxQuadVertices;
482 fMaxLineIndices += that->fMaxLineIndices; 482 fMaxLineIndices += that->fMaxLineIndices;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 if (prevIdx > subpathIdxStart) { 517 if (prevIdx > subpathIdxStart) {
518 append_contour_edge_indices(subpathIdxStart, pre vIdx, lines); 518 append_contour_edge_indices(subpathIdxStart, pre vIdx, lines);
519 } 519 }
520 } 520 }
521 SkASSERT(lines.nextVertex < lines.verticesEnd); 521 SkASSERT(lines.nextVertex < lines.verticesEnd);
522 *(lines.nextVertex++) = { pts[1], color }; 522 *(lines.nextVertex++) = { pts[1], color };
523 break; 523 break;
524 case SkPath::kConic_Verb: { 524 case SkPath::kConic_Verb: {
525 SkScalar weight = iter.conicWeight(); 525 SkScalar weight = iter.conicWeight();
526 SkAutoConicToQuads converter; 526 SkAutoConicToQuads converter;
527 const SkPoint* quadPts = converter.computeQuads(pts, wei ght, 527 const SkPoint* quadPts = converter.computeQuads(pts, wei ght,
528 kToleran ce); 528 kToleran ce);
529 for (int i = 0; i < converter.countQuads(); ++i) { 529 for (int i = 0; i < converter.countQuads(); ++i) {
530 add_quad(lines, quads, quadPts + i * 2, color, isInd exed, 530 add_quad(lines, quads, quadPts + i * 2, color, isInd exed,
531 subpathIdxStart); 531 subpathIdxStart);
532 } 532 }
533 break; 533 break;
534 } 534 }
535 case SkPath::kQuad_Verb: { 535 case SkPath::kQuad_Verb: {
536 add_quad(lines, quads, pts, color, isIndexed, subpathIdx Start); 536 add_quad(lines, quads, pts, color, isIndexed, subpathIdx Start);
537 break; 537 break;
538 } 538 }
539 case SkPath::kCubic_Verb: { 539 case SkPath::kCubic_Verb: {
540 SkSTArray<15, SkPoint, true> quadPts; 540 SkSTArray<15, SkPoint, true> quadPts;
541 GrPathUtils::convertCubicToQuads(pts, kTolerance, &quadP ts); 541 GrPathUtils::convertCubicToQuads(pts, kTolerance, &quadP ts);
542 int count = quadPts.count(); 542 int count = quadPts.count();
543 for (int i = 0; i < count; i += 3) { 543 for (int i = 0; i < count; i += 3) {
544 add_quad(lines, quads, &quadPts[i], color, isIndexed , subpathIdxStart); 544 add_quad(lines, quads, &quadPts[i], color, isIndexed , subpathIdxStart);
545 } 545 }
546 break; 546 break;
547 } 547 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 pipelineBuilder.setUserStencil(userStencilSettings); 675 pipelineBuilder.setUserStencil(userStencilSettings);
676 } 676 }
677 677
678 drawContext->drawBatch(pipelineBuilder, clip, batch); 678 drawContext->drawBatch(pipelineBuilder, clip, batch);
679 } else { 679 } else {
680 MSAAPathBatch::Geometry geometry; 680 MSAAPathBatch::Geometry geometry;
681 geometry.fColor = color; 681 geometry.fColor = color;
682 geometry.fPath = path; 682 geometry.fPath = path;
683 geometry.fTolerance = kTolerance; 683 geometry.fTolerance = kTolerance;
684 684
685 SkAutoTUnref<MSAAPathBatch> batch(MSAAPathBatch::Create(geometry, vi ewMatrix, 685 SkAutoTUnref<MSAAPathBatch> batch(MSAAPathBatch::Create(geometry, vi ewMatrix,
686 devBounds)); 686 devBounds));
687 if (!batch->isValid()) { 687 if (!batch->isValid()) {
688 return false; 688 return false;
689 } 689 }
690 690
691 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int)); 691 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int));
692 pipelineBuilder.setDrawFace(drawFace[p]); 692 pipelineBuilder.setDrawFace(drawFace[p]);
693 if (passes[p]) { 693 if (passes[p]) {
694 pipelineBuilder.setUserStencil(passes[p]); 694 pipelineBuilder.setUserStencil(passes[p]);
695 } else { 695 } else {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 false); 742 false);
743 } 743 }
744 744
745 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) { 745 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) {
746 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 746 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
747 "GrMSAAPathRenderer::onStencilPath"); 747 "GrMSAAPathRenderer::onStencilPath");
748 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType()); 748 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType());
749 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType()); 749 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType());
750 750
751 GrPaint paint; 751 GrPaint paint;
752 SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create())); 752 paint.setXPFactory(GrDisableColorXPFactory::Make());
753 paint.setAntiAlias(args.fIsAA); 753 paint.setAntiAlias(args.fIsAA);
754 754
755 this->internalDrawPath(args.fDrawContext, 755 this->internalDrawPath(args.fDrawContext,
756 paint, 756 paint,
757 &GrUserStencilSettings::kUnused, 757 &GrUserStencilSettings::kUnused,
758 *args.fClip, 758 *args.fClip,
759 GrColor_WHITE, 759 GrColor_WHITE,
760 *args.fViewMatrix, 760 *args.fViewMatrix,
761 *args.fPath, 761 *args.fPath,
762 true); 762 true);
763 } 763 }
764 764
765 //////////////////////////////////////////////////////////////////////////////// /////////////////// 765 //////////////////////////////////////////////////////////////////////////////// ///////////////////
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDrawVerticesBatch.cpp ('k') | src/gpu/batches/GrNinePatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698