Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrAALinearizingConvexPathRenderer.h" | 9 #include "GrAALinearizingConvexPathRenderer.h" |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 tess.coverage(i); | 90 tess.coverage(i); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 for (int i = 0; i < tess.numIndices(); ++i) { | 94 for (int i = 0; i < tess.numIndices(); ++i) { |
| 95 idxs[i] = tess.index(i) + firstIndex; | 95 idxs[i] = tess.index(i) + firstIndex; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, | 99 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, |
| 100 const SkMatrix& localMatrix, | 100 const SkMatrix& viewMatrix, |
| 101 bool usesLocalCoords, | 101 bool usesLocalCoords, |
| 102 bool coverageIgnored) { | 102 bool coverageIgnored) { |
| 103 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; | 103 using namespace GrDefaultGeoProcFactory; |
| 104 if (!tweakAlphaForCoverage) { | 104 |
| 105 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; | 105 Color color(Color::kAttribute_Type); |
| 106 Coverage::Type coverageType; | |
| 107 if (coverageIgnored) { | |
| 108 coverageType = Coverage::kNone_Type; | |
| 109 } else if (tweakAlphaForCoverage) { | |
| 110 coverageType = Coverage::kSolid_Type; | |
| 111 } else { | |
| 112 coverageType = Coverage::kAttribute_Type; | |
| 106 } | 113 } |
| 114 Coverage coverage(coverageType); | |
| 107 | 115 |
| 108 return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords , coverageIgnored, | 116 if (usesLocalCoords) { |
| 109 SkMatrix::I(), localMatrix); | 117 LocalCoords localCoords(LocalCoords::kUsePosition_Type); |
| 118 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); | |
| 119 } else { | |
|
robertphillips
2015/07/29 13:09:44
extra space ?
| |
| 120 LocalCoords localCoords(LocalCoords::kUnused_Type); | |
| 121 return Create(color, coverage, localCoords); | |
| 122 } | |
| 110 } | 123 } |
| 111 | 124 |
| 112 class AAFlatteningConvexPathBatch : public GrBatch { | 125 class AAFlatteningConvexPathBatch : public GrBatch { |
| 113 public: | 126 public: |
| 114 struct Geometry { | 127 struct Geometry { |
| 115 GrColor fColor; | 128 GrColor fColor; |
| 116 SkMatrix fViewMatrix; | 129 SkMatrix fViewMatrix; |
| 117 SkPath fPath; | 130 SkPath fPath; |
| 118 SkScalar fStrokeWidth; | 131 SkScalar fStrokeWidth; |
| 119 SkPaint::Join fJoin; | 132 SkPaint::Join fJoin; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 } | 188 } |
| 176 memcpy(idxs, indices, indexCount * sizeof(uint16_t)); | 189 memcpy(idxs, indices, indexCount * sizeof(uint16_t)); |
| 177 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, | 190 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, |
| 178 firstIndex, vertexCount, indexCount); | 191 firstIndex, vertexCount, indexCount); |
| 179 batchTarget->draw(info); | 192 batchTarget->draw(info); |
| 180 } | 193 } |
| 181 | 194 |
| 182 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override { | 195 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override { |
| 183 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); | 196 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); |
| 184 | 197 |
| 185 SkMatrix invert; | 198 // Setup GrGeometryProcessor |
| 186 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { | 199 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaF orCoverage, |
| 187 SkDebugf("Could not invert viewmatrix\n"); | 200 this->viewMatr ix(), |
| 201 this->usesLoca lCoords(), | |
| 202 this->coverage Ignored())); | |
| 203 if (!gp) { | |
| 204 SkDebugf("Couldn't create a GrGeometryProcessor\n"); | |
| 188 return; | 205 return; |
| 189 } | 206 } |
| 190 | 207 |
| 191 // Setup GrGeometryProcessor | |
| 192 SkAutoTUnref<const GrGeometryProcessor> gp( | |
| 193 create_fill_gp(canTweakAlphaForC overage, invert, | |
| 194 this->usesLocalCo ords(), | |
| 195 this->coverageIgn ored())); | |
| 196 | |
| 197 batchTarget->initDraw(gp, pipeline); | 208 batchTarget->initDraw(gp, pipeline); |
| 198 | 209 |
| 199 size_t vertexStride = gp->getVertexStride(); | 210 size_t vertexStride = gp->getVertexStride(); |
| 200 | 211 |
| 201 SkASSERT(canTweakAlphaForCoverage ? | 212 SkASSERT(canTweakAlphaForCoverage ? |
| 202 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : | 213 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : |
| 203 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); | 214 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); |
| 204 | 215 |
| 205 int instanceCount = fGeoData.count(); | 216 int instanceCount = fGeoData.count(); |
| 206 | 217 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { | 345 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { |
| 335 AAFlatteningConvexPathBatch::Geometry geometry; | 346 AAFlatteningConvexPathBatch::Geometry geometry; |
| 336 geometry.fColor = GrRandomColor(random); | 347 geometry.fColor = GrRandomColor(random); |
| 337 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 348 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
| 338 geometry.fPath = GrTest::TestPathConvex(random); | 349 geometry.fPath = GrTest::TestPathConvex(random); |
| 339 | 350 |
| 340 return AAFlatteningConvexPathBatch::Create(geometry); | 351 return AAFlatteningConvexPathBatch::Create(geometry); |
| 341 } | 352 } |
| 342 | 353 |
| 343 #endif | 354 #endif |
| OLD | NEW |