OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrDefaultPathRenderer.h" | 8 #include "GrDefaultPathRenderer.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); | 121 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
122 | 122 |
123 // setup batch properties | 123 // setup batch properties |
124 fBatch.fColorIgnored = !overrides.readsColor(); | 124 fBatch.fColorIgnored = !overrides.readsColor(); |
125 fBatch.fColor = fGeoData[0].fColor; | 125 fBatch.fColor = fGeoData[0].fColor; |
126 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); | 126 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); |
127 fBatch.fCoverageIgnored = !overrides.readsCoverage(); | 127 fBatch.fCoverageIgnored = !overrides.readsCoverage(); |
128 } | 128 } |
129 | 129 |
130 void onPrepareDraws(Target* target) const override { | 130 void onPrepareDraws(Target* target) const override { |
131 SkAutoTUnref<const GrGeometryProcessor> gp; | 131 sk_sp<GrGeometryProcessor> gp; |
132 { | 132 { |
133 using namespace GrDefaultGeoProcFactory; | 133 using namespace GrDefaultGeoProcFactory; |
134 Color color(this->color()); | 134 Color color(this->color()); |
135 Coverage coverage(this->coverage()); | 135 Coverage coverage(this->coverage()); |
136 if (this->coverageIgnored()) { | 136 if (this->coverageIgnored()) { |
137 coverage.fType = Coverage::kNone_Type; | 137 coverage.fType = Coverage::kNone_Type; |
138 } | 138 } |
139 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP
osition_Type : | 139 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP
osition_Type : |
140 LocalCoords::kUnus
ed_Type); | 140 LocalCoords::kUnus
ed_Type); |
141 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord
s, | 141 gp = GrDefaultGeoProcFactory::Make(color, coverage, localCoords, thi
s->viewMatrix()); |
142 this->viewMatrix())); | |
143 } | 142 } |
144 | 143 |
145 size_t vertexStride = gp->getVertexStride(); | 144 size_t vertexStride = gp->getVertexStride(); |
146 SkASSERT(vertexStride == sizeof(SkPoint)); | 145 SkASSERT(vertexStride == sizeof(SkPoint)); |
147 | 146 |
148 int instanceCount = fGeoData.count(); | 147 int instanceCount = fGeoData.count(); |
149 | 148 |
150 // compute number of vertices | 149 // compute number of vertices |
151 int maxVertices = 0; | 150 int maxVertices = 0; |
152 | 151 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 SkASSERT(vertexOffset <= maxVertices && indexOffset <= maxIndices); | 235 SkASSERT(vertexOffset <= maxVertices && indexOffset <= maxIndices); |
237 } | 236 } |
238 | 237 |
239 GrMesh mesh; | 238 GrMesh mesh; |
240 if (isIndexed) { | 239 if (isIndexed) { |
241 mesh.initIndexed(primitiveType, vertexBuffer, indexBuffer, firstVert
ex, firstIndex, | 240 mesh.initIndexed(primitiveType, vertexBuffer, indexBuffer, firstVert
ex, firstIndex, |
242 vertexOffset, indexOffset); | 241 vertexOffset, indexOffset); |
243 } else { | 242 } else { |
244 mesh.init(primitiveType, vertexBuffer, firstVertex, vertexOffset); | 243 mesh.init(primitiveType, vertexBuffer, firstVertex, vertexOffset); |
245 } | 244 } |
246 target->draw(gp, mesh); | 245 target->draw(gp.get(), mesh); |
247 | 246 |
248 // put back reserves | 247 // put back reserves |
249 target->putBackIndices((size_t)(maxIndices - indexOffset)); | 248 target->putBackIndices((size_t)(maxIndices - indexOffset)); |
250 target->putBackVertices((size_t)(maxVertices - vertexOffset), (size_t)ve
rtexStride); | 249 target->putBackVertices((size_t)(maxVertices - vertexOffset), (size_t)ve
rtexStride); |
251 } | 250 } |
252 | 251 |
253 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 252 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
254 | 253 |
255 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, | 254 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, |
256 bool isHairline, const SkRect& devBounds) | 255 bool isHairline, const SkRect& devBounds) |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 false); | 619 false); |
621 } | 620 } |
622 | 621 |
623 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) { | 622 void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) { |
624 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), | 623 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), |
625 "GrDefaultPathRenderer::onStencilPath"); | 624 "GrDefaultPathRenderer::onStencilPath"); |
626 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType()); | 625 SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType()); |
627 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType()); | 626 SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType()); |
628 | 627 |
629 GrPaint paint; | 628 GrPaint paint; |
630 SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create())); | 629 paint.setXPFactory(GrDisableColorXPFactory::Make()); |
631 paint.setAntiAlias(args.fIsAA); | 630 paint.setAntiAlias(args.fIsAA); |
632 | 631 |
633 this->internalDrawPath(args.fDrawContext, | 632 this->internalDrawPath(args.fDrawContext, |
634 paint, | 633 paint, |
635 &GrUserStencilSettings::kUnused, | 634 &GrUserStencilSettings::kUnused, |
636 *args.fClip, | 635 *args.fClip, |
637 GrColor_WHITE, | 636 GrColor_WHITE, |
638 *args.fViewMatrix, | 637 *args.fViewMatrix, |
639 *args.fPath, | 638 *args.fPath, |
640 GrStyle::SimpleFill(), | 639 GrStyle::SimpleFill(), |
(...skipping 22 matching lines...) Expand all Loading... |
663 geometry.fColor = color; | 662 geometry.fColor = color; |
664 geometry.fPath = path; | 663 geometry.fPath = path; |
665 geometry.fTolerance = srcSpaceTol; | 664 geometry.fTolerance = srcSpaceTol; |
666 | 665 |
667 viewMatrix.mapRect(&bounds); | 666 viewMatrix.mapRect(&bounds); |
668 uint8_t coverage = GrRandomCoverage(random); | 667 uint8_t coverage = GrRandomCoverage(random); |
669 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); | 668 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); |
670 } | 669 } |
671 | 670 |
672 #endif | 671 #endif |
OLD | NEW |