bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 8 | #ifndef GrDrawPathOp_DEFINED |
| 9 | #define GrDrawPathOp_DEFINED |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/GrOpFlushState.h" |
| 12 | #include "src/gpu/GrPath.h" |
| 13 | #include "src/gpu/GrPathProcessor.h" |
| 14 | #include "src/gpu/GrPathRendering.h" |
| 15 | #include "src/gpu/GrProcessorSet.h" |
| 16 | #include "src/gpu/GrStencilSettings.h" |
| 17 | #include "src/gpu/ops/GrDrawOp.h" |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 18 | |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 19 | class GrPaint; |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 20 | class GrRecordingContext; |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 21 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 22 | class GrDrawPathOpBase : public GrDrawOp { |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 23 | protected: |
Brian Salomon | 48d1b4c | 2017-04-08 07:38:53 -0400 | [diff] [blame] | 24 | GrDrawPathOpBase(uint32_t classID, const SkMatrix& viewMatrix, GrPaint&&, |
Chris Dalton | 09e5689 | 2019-03-13 00:22:01 -0600 | [diff] [blame] | 25 | GrPathRendering::FillType, GrAA); |
Robert Phillips | b493eeb | 2017-09-13 13:10:52 -0400 | [diff] [blame] | 26 | |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 27 | FixedFunctionFlags fixedFunctionFlags() const override { |
Chris Dalton | 09e5689 | 2019-03-13 00:22:01 -0600 | [diff] [blame] | 28 | return (fDoAA) |
| 29 | ? FixedFunctionFlags::kUsesHWAA | FixedFunctionFlags::kUsesStencil |
| 30 | : FixedFunctionFlags::kUsesStencil; |
Brian Salomon | c48af93 | 2017-03-16 19:51:42 +0000 | [diff] [blame] | 31 | } |
Chris Dalton | 6ce447a | 2019-06-23 18:07:38 -0600 | [diff] [blame] | 32 | GrProcessorSet::Analysis finalize( |
| 33 | const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage, |
| 34 | GrClampType clampType) override { |
| 35 | return this->doProcessorAnalysis(caps, clip, hasMixedSampledCoverage, clampType); |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 36 | } |
| 37 | |
Chris Dalton | 1706cbf | 2019-05-21 19:35:29 -0600 | [diff] [blame] | 38 | void visitProxies(const VisitProxyFunc& func) const override { |
Robert Phillips | b493eeb | 2017-09-13 13:10:52 -0400 | [diff] [blame] | 39 | fProcessorSet.visitProxies(func); |
| 40 | } |
| 41 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 42 | protected: |
joshualitt | f238469 | 2015-09-10 11:00:51 -0700 | [diff] [blame] | 43 | const SkMatrix& viewMatrix() const { return fViewMatrix; } |
Brian Osman | cf86085 | 2018-10-31 14:04:39 -0400 | [diff] [blame] | 44 | const SkPMColor4f& color() const { return fInputColor; } |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 45 | GrPathRendering::FillType fillType() const { return fFillType; } |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 46 | const GrProcessorSet& processors() const { return fProcessorSet; } |
Brian Salomon | 91326c3 | 2017-08-09 16:02:19 -0400 | [diff] [blame] | 47 | GrProcessorSet detachProcessors() { return std::move(fProcessorSet); } |
Brian Salomon | 972b2f6 | 2017-07-31 12:37:02 -0400 | [diff] [blame] | 48 | inline GrPipeline::InitArgs pipelineInitArgs(const GrOpFlushState&); |
Chris Dalton | b8fff0d | 2019-03-05 10:11:58 -0700 | [diff] [blame] | 49 | const GrProcessorSet::Analysis& doProcessorAnalysis( |
Chris Dalton | 6ce447a | 2019-06-23 18:07:38 -0600 | [diff] [blame] | 50 | const GrCaps&, const GrAppliedClip*, bool hasMixedSampledCoverage, GrClampType); |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 51 | const GrProcessorSet::Analysis& processorAnalysis() const { |
Brian Salomon | 48d1b4c | 2017-04-08 07:38:53 -0400 | [diff] [blame] | 52 | SkASSERT(fAnalysis.isInitialized()); |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 53 | return fAnalysis; |
| 54 | } |
joshualitt | f238469 | 2015-09-10 11:00:51 -0700 | [diff] [blame] | 55 | |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 56 | private: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 57 | void onPrepare(GrOpFlushState*) final {} |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 58 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 59 | SkMatrix fViewMatrix; |
Brian Osman | cf86085 | 2018-10-31 14:04:39 -0400 | [diff] [blame] | 60 | SkPMColor4f fInputColor; |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 61 | GrProcessorSet::Analysis fAnalysis; |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 62 | GrPathRendering::FillType fFillType; |
Chris Dalton | 09e5689 | 2019-03-13 00:22:01 -0600 | [diff] [blame] | 63 | bool fDoAA; |
Brian Salomon | 611572c | 2017-04-28 08:57:12 -0400 | [diff] [blame] | 64 | GrProcessorSet fProcessorSet; |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 65 | |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 66 | typedef GrDrawOp INHERITED; |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 67 | }; |
| 68 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 69 | class GrDrawPathOp final : public GrDrawPathOpBase { |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 70 | public: |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 71 | DEFINE_OP_CLASS_ID |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 72 | |
Chris Dalton | 09e5689 | 2019-03-13 00:22:01 -0600 | [diff] [blame] | 73 | static std::unique_ptr<GrDrawOp> Make( |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 74 | GrRecordingContext*, const SkMatrix& viewMatrix, GrPaint&&, GrAA, sk_sp<const GrPath>); |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 75 | |
| 76 | const char* name() const override { return "DrawPath"; } |
| 77 | |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 78 | #ifdef SK_DEBUG |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 79 | SkString dumpInfo() const override; |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 80 | #endif |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 81 | |
| 82 | private: |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 83 | friend class GrOpMemoryPool; // for ctor |
| 84 | |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 85 | GrDrawPathOp(const SkMatrix& viewMatrix, GrPaint&& paint, GrAA aa, sk_sp<const GrPath> path) |
Chris Dalton | 09e5689 | 2019-03-13 00:22:01 -0600 | [diff] [blame] | 86 | : GrDrawPathOpBase( |
| 87 | ClassID(), viewMatrix, std::move(paint), path->getFillType(), aa) |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 88 | , fPath(std::move(path)) { |
| 89 | this->setTransformedBounds(fPath->getBounds(), viewMatrix, HasAABloat::kNo, IsZeroArea::kNo); |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 90 | } |
stephana | 1dc1721 | 2016-04-25 07:01:22 -0700 | [diff] [blame] | 91 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 92 | void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 93 | |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 94 | sk_sp<const GrPath> fPath; |
stephana | 1dc1721 | 2016-04-25 07:01:22 -0700 | [diff] [blame] | 95 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 96 | typedef GrDrawPathOpBase INHERITED; |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 99 | #endif |