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