| 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 |  | 
|---|
| 11 | #include "src/gpu/GrPath.h" | 
|---|
| 12 | #include "src/gpu/GrPathRendering.h" | 
|---|
| 13 | #include "src/gpu/GrScissorState.h" | 
|---|
| 14 | #include "src/gpu/GrStencilSettings.h" | 
|---|
| 15 | #include "src/gpu/ops/GrOp.h" | 
|---|
| 16 |  | 
|---|
| 17 | class GrOpFlushState; | 
|---|
| 18 | class GrRecordingContext; | 
|---|
| 19 |  | 
|---|
| 20 | class GrStencilPathOp final : public GrOp { | 
|---|
| 21 | public: | 
|---|
| 22 | DEFINE_OP_CLASS_ID | 
|---|
| 23 |  | 
|---|
| 24 | static std::unique_ptr<GrOp> Make(GrRecordingContext* context, | 
|---|
| 25 | const SkMatrix& viewMatrix, | 
|---|
| 26 | bool useHWAA, | 
|---|
| 27 | bool hasStencilClip, | 
|---|
| 28 | const GrScissorState& scissor, | 
|---|
| 29 | sk_sp<const GrPath> path); | 
|---|
| 30 |  | 
|---|
| 31 | const char* name() const override { return "StencilPathOp"; } | 
|---|
| 32 |  | 
|---|
| 33 | #ifdef SK_DEBUG | 
|---|
| 34 | SkString dumpInfo() const override { | 
|---|
| 35 | SkString string; | 
|---|
| 36 | string.printf( "Path: 0x%p, AA: %d", fPath.get(), fUseHWAA); | 
|---|
| 37 | string.append(INHERITED::dumpInfo()); | 
|---|
| 38 | return string; | 
|---|
| 39 | } | 
|---|
| 40 | #endif | 
|---|
| 41 |  | 
|---|
| 42 | private: | 
|---|
| 43 | friend class GrOpMemoryPool; // for ctor | 
|---|
| 44 |  | 
|---|
| 45 | GrStencilPathOp(const SkMatrix& viewMatrix, | 
|---|
| 46 | bool useHWAA, | 
|---|
| 47 | bool hasStencilClip, | 
|---|
| 48 | const GrScissorState& scissor, | 
|---|
| 49 | sk_sp<const GrPath> path) | 
|---|
| 50 | : INHERITED(ClassID()) | 
|---|
| 51 | , fViewMatrix(viewMatrix) | 
|---|
| 52 | , fUseHWAA(useHWAA) | 
|---|
| 53 | , fHasStencilClip(hasStencilClip) | 
|---|
| 54 | , fScissor(scissor) | 
|---|
| 55 | , fPath(std::move(path)) { | 
|---|
| 56 | this->setBounds(fPath->getBounds(), HasAABloat::kNo, IsHairline::kNo); | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | void onPrePrepare(GrRecordingContext*, | 
|---|
| 60 | const GrSurfaceProxyView* writeView, | 
|---|
| 61 | GrAppliedClip*, | 
|---|
| 62 | const GrXferProcessor::DstProxyView&) override {} | 
|---|
| 63 |  | 
|---|
| 64 | void onPrepare(GrOpFlushState*) override {} | 
|---|
| 65 |  | 
|---|
| 66 | void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; | 
|---|
| 67 |  | 
|---|
| 68 | SkMatrix                  fViewMatrix; | 
|---|
| 69 | bool                      fUseHWAA; | 
|---|
| 70 | bool                      fHasStencilClip; | 
|---|
| 71 | GrScissorState            fScissor; | 
|---|
| 72 | sk_sp<const GrPath>       fPath; | 
|---|
| 73 |  | 
|---|
| 74 | typedef GrOp INHERITED; | 
|---|
| 75 | }; | 
|---|
| 76 |  | 
|---|
| 77 | #endif | 
|---|
| 78 |  | 
|---|