| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
| 9 | 9 |
| 10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 virtual ~DIEllipseGeometryProcessor() {} | 371 virtual ~DIEllipseGeometryProcessor() {} |
| 372 | 372 |
| 373 const char* name() const override { return "DIEllipseEdge"; } | 373 const char* name() const override { return "DIEllipseEdge"; } |
| 374 | 374 |
| 375 const Attribute* inPosition() const { return fInPosition; } | 375 const Attribute* inPosition() const { return fInPosition; } |
| 376 const Attribute* inColor() const { return fInColor; } | 376 const Attribute* inColor() const { return fInColor; } |
| 377 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } | 377 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } |
| 378 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } | 378 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } |
| 379 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 379 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 380 | 380 |
| 381 class GLSLProcessor : public GrGLSLGeometryProcessor { | 381 class GLSLProcessor : public GrGLSLGeometryProcessor { |
| 382 public: | 382 public: |
| 383 GLSLProcessor() | 383 GLSLProcessor() |
| 384 : fViewMatrix(SkMatrix::InvalidMatrix()) {} | 384 : fViewMatrix(SkMatrix::InvalidMatrix()) {} |
| 385 | 385 |
| 386 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { | 386 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
| 387 const DIEllipseGeometryProcessor& diegp = args.fGP.cast<DIEllipseGeo
metryProcessor>(); | 387 const DIEllipseGeometryProcessor& diegp = args.fGP.cast<DIEllipseGeo
metryProcessor>(); |
| 388 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; | 388 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; |
| 389 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; | 389 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; |
| 390 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 390 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 523 |
| 524 GrDrawBatch* GrOvalRenderer::CreateOvalBatch(GrColor color, | 524 GrDrawBatch* GrOvalRenderer::CreateOvalBatch(GrColor color, |
| 525 const SkMatrix& viewMatrix, | 525 const SkMatrix& viewMatrix, |
| 526 const SkRect& oval, | 526 const SkRect& oval, |
| 527 const SkStrokeRec& stroke, | 527 const SkStrokeRec& stroke, |
| 528 GrShaderCaps* shaderCaps) { | 528 GrShaderCaps* shaderCaps) { |
| 529 // we can draw circles | 529 // we can draw circles |
| 530 if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(
viewMatrix)) { | 530 if (SkScalarNearlyEqual(oval.width(), oval.height()) && circle_stays_circle(
viewMatrix)) { |
| 531 return CreateCircleBatch(color, viewMatrix, oval, stroke); | 531 return CreateCircleBatch(color, viewMatrix, oval, stroke); |
| 532 } | 532 } |
| 533 | 533 |
| 534 // if we have shader derivative support, render as device-independent | 534 // if we have shader derivative support, render as device-independent |
| 535 if (shaderCaps->shaderDerivativeSupport()) { | 535 if (shaderCaps->shaderDerivativeSupport()) { |
| 536 return CreateDIEllipseBatch(color, viewMatrix, oval, stroke); | 536 return CreateDIEllipseBatch(color, viewMatrix, oval, stroke); |
| 537 } | 537 } |
| 538 | 538 |
| 539 // otherwise axis-aligned ellipses only | 539 // otherwise axis-aligned ellipses only |
| 540 if (viewMatrix.rectStaysRect()) { | 540 if (viewMatrix.rectStaysRect()) { |
| 541 return CreateEllipseBatch(color, viewMatrix, oval, stroke); | 541 return CreateEllipseBatch(color, viewMatrix, oval, stroke); |
| 542 } | 542 } |
| 543 | 543 |
| 544 return nullptr; | 544 return nullptr; |
| 545 } | 545 } |
| 546 | 546 |
| 547 /////////////////////////////////////////////////////////////////////////////// | 547 /////////////////////////////////////////////////////////////////////////////// |
| 548 | 548 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 574 fGeoData[i].fColor, | 574 fGeoData[i].fColor, |
| 575 fGeoData[i].fDevBounds.fLeft, fGeoData[i].fDevBounds.
fTop, | 575 fGeoData[i].fDevBounds.fLeft, fGeoData[i].fDevBounds.
fTop, |
| 576 fGeoData[i].fDevBounds.fRight, fGeoData[i].fDevBounds
.fBottom, | 576 fGeoData[i].fDevBounds.fRight, fGeoData[i].fDevBounds
.fBottom, |
| 577 fGeoData[i].fInnerRadius, | 577 fGeoData[i].fInnerRadius, |
| 578 fGeoData[i].fOuterRadius); | 578 fGeoData[i].fOuterRadius); |
| 579 } | 579 } |
| 580 string.append(INHERITED::dumpInfo()); | 580 string.append(INHERITED::dumpInfo()); |
| 581 return string; | 581 return string; |
| 582 } | 582 } |
| 583 | 583 |
| 584 void computePipelineOptimizations(GrInitInvariantOutput* color, | 584 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 585 GrInitInvariantOutput* coverage, | 585 GrInitInvariantOutput* coverage, |
| 586 GrBatchToXPOverrides* overrides) const ove
rride { | 586 GrBatchToXPOverrides* overrides) const ove
rride { |
| 587 // When this is called on a batch, there is only one geometry bundle | 587 // When this is called on a batch, there is only one geometry bundle |
| 588 color->setKnownFourComponents(fGeoData[0].fColor); | 588 color->setKnownFourComponents(fGeoData[0].fColor); |
| 589 coverage->setUnknownSingleComponent(); | 589 coverage->setUnknownSingleComponent(); |
| 590 } | 590 } |
| 591 | 591 |
| 592 private: | 592 private: |
| 593 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 593 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 594 // Handle any overrides that affect our GP. | 594 // Handle any overrides that affect our GP. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 EllipseBatch(const Geometry& geometry, const SkMatrix& viewMatrix, bool stro
ked) | 758 EllipseBatch(const Geometry& geometry, const SkMatrix& viewMatrix, bool stro
ked) |
| 759 : INHERITED(ClassID()) | 759 : INHERITED(ClassID()) |
| 760 , fStroked(stroked) | 760 , fStroked(stroked) |
| 761 , fViewMatrixIfUsingLocalCoords(viewMatrix) { | 761 , fViewMatrixIfUsingLocalCoords(viewMatrix) { |
| 762 fGeoData.push_back(geometry); | 762 fGeoData.push_back(geometry); |
| 763 this->setBounds(geometry.fDevBounds); | 763 this->setBounds(geometry.fDevBounds); |
| 764 } | 764 } |
| 765 | 765 |
| 766 const char* name() const override { return "EllipseBatch"; } | 766 const char* name() const override { return "EllipseBatch"; } |
| 767 | 767 |
| 768 void computePipelineOptimizations(GrInitInvariantOutput* color, | 768 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 769 GrInitInvariantOutput* coverage, | 769 GrInitInvariantOutput* coverage, |
| 770 GrBatchToXPOverrides* overrides) const ove
rride { | 770 GrBatchToXPOverrides* overrides) const ove
rride { |
| 771 // When this is called on a batch, there is only one geometry bundle | 771 // When this is called on a batch, there is only one geometry bundle |
| 772 color->setKnownFourComponents(fGeoData[0].fColor); | 772 color->setKnownFourComponents(fGeoData[0].fColor); |
| 773 coverage->setUnknownSingleComponent(); | 773 coverage->setUnknownSingleComponent(); |
| 774 } | 774 } |
| 775 | 775 |
| 776 private: | 776 private: |
| 777 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 777 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 778 // Handle any overrides that affect our GP. | 778 // Handle any overrides that affect our GP. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 GrColor fColor; | 983 GrColor fColor; |
| 984 DIEllipseStyle fStyle; | 984 DIEllipseStyle fStyle; |
| 985 }; | 985 }; |
| 986 | 986 |
| 987 static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) { | 987 static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) { |
| 988 return new DIEllipseBatch(geometry, bounds); | 988 return new DIEllipseBatch(geometry, bounds); |
| 989 } | 989 } |
| 990 | 990 |
| 991 const char* name() const override { return "DIEllipseBatch"; } | 991 const char* name() const override { return "DIEllipseBatch"; } |
| 992 | 992 |
| 993 void computePipelineOptimizations(GrInitInvariantOutput* color, | 993 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 994 GrInitInvariantOutput* coverage, | 994 GrInitInvariantOutput* coverage, |
| 995 GrBatchToXPOverrides* overrides) const ove
rride { | 995 GrBatchToXPOverrides* overrides) const ove
rride { |
| 996 // When this is called on a batch, there is only one geometry bundle | 996 // When this is called on a batch, there is only one geometry bundle |
| 997 color->setKnownFourComponents(fGeoData[0].fColor); | 997 color->setKnownFourComponents(fGeoData[0].fColor); |
| 998 coverage->setUnknownSingleComponent(); | 998 coverage->setUnknownSingleComponent(); |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 private: | 1001 private: |
| 1002 | 1002 |
| 1003 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 1003 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 | 1056 |
| 1057 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); | 1057 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); |
| 1058 verts[3].fColor = color; | 1058 verts[3].fColor = color; |
| 1059 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offse
tDy); | 1059 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offse
tDy); |
| 1060 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -inner
RatioY - offsetDy); | 1060 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -inner
RatioY - offsetDy); |
| 1061 | 1061 |
| 1062 verts += kVerticesPerQuad; | 1062 verts += kVerticesPerQuad; |
| 1063 } | 1063 } |
| 1064 helper.recordDraw(target); | 1064 helper.recordDraw(target); |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) : INHERITED(C
lassID()) { | 1067 DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) : INHERITED(C
lassID()) { |
| 1068 fGeoData.push_back(geometry); | 1068 fGeoData.push_back(geometry); |
| 1069 | 1069 |
| 1070 this->setBounds(bounds); | 1070 this->setBounds(bounds); |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 1073 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 1074 DIEllipseBatch* that = t->cast<DIEllipseBatch>(); | 1074 DIEllipseBatch* that = t->cast<DIEllipseBatch>(); |
| 1075 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 1075 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| 1076 that->bounds(), caps)) { | 1076 that->bounds(), caps)) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 : INHERITED(ClassID()) | 1244 : INHERITED(ClassID()) |
| 1245 , fStroked(stroked) | 1245 , fStroked(stroked) |
| 1246 , fViewMatrixIfUsingLocalCoords(viewMatrix) { | 1246 , fViewMatrixIfUsingLocalCoords(viewMatrix) { |
| 1247 fGeoData.push_back(geometry); | 1247 fGeoData.push_back(geometry); |
| 1248 | 1248 |
| 1249 this->setBounds(geometry.fDevBounds); | 1249 this->setBounds(geometry.fDevBounds); |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 const char* name() const override { return "RRectCircleBatch"; } | 1252 const char* name() const override { return "RRectCircleBatch"; } |
| 1253 | 1253 |
| 1254 void computePipelineOptimizations(GrInitInvariantOutput* color, | 1254 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 1255 GrInitInvariantOutput* coverage, | 1255 GrInitInvariantOutput* coverage, |
| 1256 GrBatchToXPOverrides* overrides) const ove
rride { | 1256 GrBatchToXPOverrides* overrides) const ove
rride { |
| 1257 // When this is called on a batch, there is only one geometry bundle | 1257 // When this is called on a batch, there is only one geometry bundle |
| 1258 color->setKnownFourComponents(fGeoData[0].fColor); | 1258 color->setKnownFourComponents(fGeoData[0].fColor); |
| 1259 coverage->setUnknownSingleComponent(); | 1259 coverage->setUnknownSingleComponent(); |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 private: | 1262 private: |
| 1263 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 1263 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 1264 // Handle any overrides that affect our GP. | 1264 // Handle any overrides that affect our GP. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 RRectEllipseRendererBatch(const Geometry& geometry, const SkMatrix& viewMatr
ix, bool stroked) | 1393 RRectEllipseRendererBatch(const Geometry& geometry, const SkMatrix& viewMatr
ix, bool stroked) |
| 1394 : INHERITED(ClassID()) | 1394 : INHERITED(ClassID()) |
| 1395 , fStroked(stroked) | 1395 , fStroked(stroked) |
| 1396 , fViewMatrixIfUsingLocalCoords(viewMatrix) { | 1396 , fViewMatrixIfUsingLocalCoords(viewMatrix) { |
| 1397 fGeoData.push_back(geometry); | 1397 fGeoData.push_back(geometry); |
| 1398 this->setBounds(geometry.fDevBounds); | 1398 this->setBounds(geometry.fDevBounds); |
| 1399 } | 1399 } |
| 1400 | 1400 |
| 1401 const char* name() const override { return "RRectEllipseRendererBatch"; } | 1401 const char* name() const override { return "RRectEllipseRendererBatch"; } |
| 1402 | 1402 |
| 1403 void computePipelineOptimizations(GrInitInvariantOutput* color, | 1403 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 1404 GrInitInvariantOutput* coverage, | 1404 GrInitInvariantOutput* coverage, |
| 1405 GrBatchToXPOverrides* overrides) const ove
rride { | 1405 GrBatchToXPOverrides* overrides) const ove
rride { |
| 1406 // When this is called on a batch, there is only one geometry bundle | 1406 // When this is called on a batch, there is only one geometry bundle |
| 1407 color->setKnownFourComponents(fGeoData[0].fColor); | 1407 color->setKnownFourComponents(fGeoData[0].fColor); |
| 1408 coverage->setUnknownSingleComponent(); | 1408 coverage->setUnknownSingleComponent(); |
| 1409 } | 1409 } |
| 1410 | 1410 |
| 1411 private: | 1411 private: |
| 1412 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 1412 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 1413 // Handle overrides that affect our GP. | 1413 // Handle overrides that affect our GP. |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 } | 1724 } |
| 1725 | 1725 |
| 1726 DRAW_BATCH_TEST_DEFINE(RRectBatch) { | 1726 DRAW_BATCH_TEST_DEFINE(RRectBatch) { |
| 1727 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 1727 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
| 1728 GrColor color = GrRandomColor(random); | 1728 GrColor color = GrRandomColor(random); |
| 1729 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 1729 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
| 1730 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 1730 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
| 1731 } | 1731 } |
| 1732 | 1732 |
| 1733 #endif | 1733 #endif |
| OLD | NEW |