| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)
) = | 89 *reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)
) = |
| 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, | |
| 100 const SkMatrix& localMatrix, | |
| 101 bool usesLocalCoords, | |
| 102 bool coverageIgnored) { | |
| 103 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; | |
| 104 if (!tweakAlphaForCoverage) { | |
| 105 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; | |
| 106 } | |
| 107 | |
| 108 return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords
, coverageIgnored, | |
| 109 SkMatrix::I(), localMatrix); | |
| 110 } | |
| 111 | |
| 112 class AAFlatteningConvexPathBatch : public GrBatch { | 99 class AAFlatteningConvexPathBatch : public GrBatch { |
| 113 public: | 100 public: |
| 114 struct Geometry { | 101 struct Geometry { |
| 115 GrColor fColor; | 102 GrColor fColor; |
| 116 SkMatrix fViewMatrix; | 103 SkMatrix fViewMatrix; |
| 117 SkPath fPath; | 104 SkPath fPath; |
| 118 SkScalar fStrokeWidth; | 105 SkScalar fStrokeWidth; |
| 119 SkPaint::Join fJoin; | 106 SkPaint::Join fJoin; |
| 120 SkScalar fMiterLimit; | 107 SkScalar fMiterLimit; |
| 121 }; | 108 }; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 return; | 161 return; |
| 175 } | 162 } |
| 176 memcpy(idxs, indices, indexCount * sizeof(uint16_t)); | 163 memcpy(idxs, indices, indexCount * sizeof(uint16_t)); |
| 177 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer,
firstVertex, | 164 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer,
firstVertex, |
| 178 firstIndex, vertexCount, indexCount); | 165 firstIndex, vertexCount, indexCount); |
| 179 batchTarget->draw(info); | 166 batchTarget->draw(info); |
| 180 } | 167 } |
| 181 | 168 |
| 182 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 169 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
| 183 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); | 170 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); |
| 184 | 171 SkAutoTUnref<const GrGeometryProcessor> gp( |
| 185 SkMatrix invert; | 172 GrDefaultGeoProcFactory::CreateForDeviceSpaceAlphaTweakIfPossibl
e( |
| 186 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { | 173 this->viewMatrix(), this->usesLocalCoords(), this->cover
ageIgnored(), |
| 187 SkDebugf("Could not invert viewmatrix\n"); | 174 canTweakAlphaForCoverage)); |
| 175 if (!gp) { |
| 176 SkDebugf("Couldn't create a GrGeometryProcessor\n"); |
| 188 return; | 177 return; |
| 189 } | 178 } |
| 190 | 179 |
| 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); | 180 batchTarget->initDraw(gp, pipeline); |
| 198 | 181 |
| 199 size_t vertexStride = gp->getVertexStride(); | 182 size_t vertexStride = gp->getVertexStride(); |
| 200 | 183 |
| 201 SkASSERT(canTweakAlphaForCoverage ? | 184 SkASSERT(canTweakAlphaForCoverage ? |
| 202 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt
tr) : | 185 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt
tr) : |
| 203 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo
verageAttr)); | 186 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo
verageAttr)); |
| 204 | 187 |
| 205 int instanceCount = fGeoData.count(); | 188 int instanceCount = fGeoData.count(); |
| 206 | 189 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { | 317 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { |
| 335 AAFlatteningConvexPathBatch::Geometry geometry; | 318 AAFlatteningConvexPathBatch::Geometry geometry; |
| 336 geometry.fColor = GrRandomColor(random); | 319 geometry.fColor = GrRandomColor(random); |
| 337 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 320 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
| 338 geometry.fPath = GrTest::TestPathConvex(random); | 321 geometry.fPath = GrTest::TestPathConvex(random); |
| 339 | 322 |
| 340 return AAFlatteningConvexPathBatch::Create(geometry); | 323 return AAFlatteningConvexPathBatch::Create(geometry); |
| 341 } | 324 } |
| 342 | 325 |
| 343 #endif | 326 #endif |
| OLD | NEW |