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; } |
Robert Phillips | 3968fcb | 2019-12-05 16:40:31 -0500 | [diff] [blame] | 46 | bool doAA() const { return fDoAA; } |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 47 | const GrProcessorSet& processors() const { return fProcessorSet; } |
Robert Phillips | 3968fcb | 2019-12-05 16:40:31 -0500 | [diff] [blame] | 48 | GrProcessorSet detachProcessorSet() { return std::move(fProcessorSet); } |
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: |
Robert Phillips | c655c3a | 2020-03-18 13:23:45 -0400 | [diff] [blame] | 57 | void onPrePrepare(GrRecordingContext*, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame^] | 58 | const GrSurfaceProxyView* writeView, |
Robert Phillips | c655c3a | 2020-03-18 13:23:45 -0400 | [diff] [blame] | 59 | GrAppliedClip*, |
| 60 | const GrXferProcessor::DstProxyView&) final {} |
| 61 | |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 62 | void onPrepare(GrOpFlushState*) final {} |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 63 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 64 | SkMatrix fViewMatrix; |
Brian Osman | cf86085 | 2018-10-31 14:04:39 -0400 | [diff] [blame] | 65 | SkPMColor4f fInputColor; |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 66 | GrProcessorSet::Analysis fAnalysis; |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 67 | GrPathRendering::FillType fFillType; |
Chris Dalton | 09e5689 | 2019-03-13 00:22:01 -0600 | [diff] [blame] | 68 | bool fDoAA; |
Brian Salomon | 611572c | 2017-04-28 08:57:12 -0400 | [diff] [blame] | 69 | GrProcessorSet fProcessorSet; |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 70 | |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 71 | typedef GrDrawOp INHERITED; |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 74 | class GrDrawPathOp final : public GrDrawPathOpBase { |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 75 | public: |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 76 | DEFINE_OP_CLASS_ID |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 77 | |
Chris Dalton | 09e5689 | 2019-03-13 00:22:01 -0600 | [diff] [blame] | 78 | static std::unique_ptr<GrDrawOp> Make( |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 79 | GrRecordingContext*, const SkMatrix& viewMatrix, GrPaint&&, GrAA, sk_sp<const GrPath>); |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 80 | |
| 81 | const char* name() const override { return "DrawPath"; } |
| 82 | |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 83 | #ifdef SK_DEBUG |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 84 | SkString dumpInfo() const override; |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 85 | #endif |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 86 | |
| 87 | private: |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 88 | friend class GrOpMemoryPool; // for ctor |
| 89 | |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 90 | 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] | 91 | : GrDrawPathOpBase( |
| 92 | ClassID(), viewMatrix, std::move(paint), path->getFillType(), aa) |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 93 | , fPath(std::move(path)) { |
Greg Daniel | 5faf474 | 2019-10-01 15:14:44 -0400 | [diff] [blame] | 94 | this->setTransformedBounds(fPath->getBounds(), viewMatrix, HasAABloat::kNo, |
| 95 | IsHairline::kNo); |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 96 | } |
stephana | 1dc1721 | 2016-04-25 07:01:22 -0700 | [diff] [blame] | 97 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 98 | void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 99 | |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 100 | sk_sp<const GrPath> fPath; |
stephana | 1dc1721 | 2016-04-25 07:01:22 -0700 | [diff] [blame] | 101 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 102 | typedef GrDrawPathOpBase INHERITED; |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 103 | }; |
| 104 | |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 105 | #endif |