Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [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 | |
| 8 | #ifndef GrStencilPathOp_DEFINED |
| 9 | #define GrStencilPathOp_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/GrPath.h" |
| 12 | #include "src/gpu/GrPathRendering.h" |
| 13 | #include "src/gpu/GrStencilSettings.h" |
| 14 | #include "src/gpu/ops/GrOp.h" |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 15 | |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 16 | class GrOpFlushState; |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 17 | class GrRecordingContext; |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 18 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 19 | class GrStencilPathOp final : public GrOp { |
| 20 | public: |
| 21 | DEFINE_OP_CLASS_ID |
| 22 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 23 | static std::unique_ptr<GrOp> Make(GrRecordingContext* context, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 24 | const SkMatrix& viewMatrix, |
Brian Salomon | f833478 | 2017-01-03 09:42:58 -0500 | [diff] [blame] | 25 | bool useHWAA, |
Brian Salomon | f833478 | 2017-01-03 09:42:58 -0500 | [diff] [blame] | 26 | bool hasStencilClip, |
Brian Salomon | f833478 | 2017-01-03 09:42:58 -0500 | [diff] [blame] | 27 | const GrScissorState& scissor, |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 28 | sk_sp<const GrPath> path); |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 29 | |
| 30 | const char* name() const override { return "StencilPathOp"; } |
| 31 | |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 32 | #ifdef SK_DEBUG |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 33 | SkString dumpInfo() const override { |
| 34 | SkString string; |
Robert Phillips | b9a02a1 | 2017-04-06 11:08:40 -0400 | [diff] [blame] | 35 | string.printf("Path: 0x%p, AA: %d", fPath.get(), fUseHWAA); |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 36 | string.append(INHERITED::dumpInfo()); |
| 37 | return string; |
| 38 | } |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 39 | #endif |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 40 | |
| 41 | private: |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 42 | friend class GrOpMemoryPool; // for ctor |
| 43 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 44 | GrStencilPathOp(const SkMatrix& viewMatrix, |
| 45 | bool useHWAA, |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 46 | bool hasStencilClip, |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 47 | const GrScissorState& scissor, |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 48 | sk_sp<const GrPath> path) |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 49 | : INHERITED(ClassID()) |
| 50 | , fViewMatrix(viewMatrix) |
| 51 | , fUseHWAA(useHWAA) |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 52 | , fHasStencilClip(hasStencilClip) |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 53 | , fScissor(scissor) |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 54 | , fPath(std::move(path)) { |
| 55 | this->setBounds(fPath->getBounds(), HasAABloat::kNo, IsZeroArea::kNo); |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 56 | } |
| 57 | |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 58 | void onPrepare(GrOpFlushState*) override {} |
| 59 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 60 | void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 61 | |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 62 | SkMatrix fViewMatrix; |
| 63 | bool fUseHWAA; |
| 64 | bool fHasStencilClip; |
| 65 | GrScissorState fScissor; |
| 66 | sk_sp<const GrPath> fPath; |
Brian Salomon | 82c263f | 2016-12-15 09:54:06 -0500 | [diff] [blame] | 67 | |
| 68 | typedef GrOp INHERITED; |
| 69 | }; |
| 70 | |
| 71 | #endif |