1 | /* |
2 | * Copyright 2016 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 GrClearStencilClipOp_DEFINED |
9 | #define GrClearStencilClipOp_DEFINED |
10 | |
11 | #include "src/gpu/GrFixedClip.h" |
12 | #include "src/gpu/GrRenderTargetProxy.h" |
13 | #include "src/gpu/ops/GrOp.h" |
14 | |
15 | class GrOpFlushState; |
16 | class GrRecordingContext; |
17 | |
18 | class GrClearStencilClipOp final : public GrOp { |
19 | public: |
20 | DEFINE_OP_CLASS_ID |
21 | |
22 | static std::unique_ptr<GrOp> Make(GrRecordingContext* context, |
23 | const GrFixedClip& clip, |
24 | bool insideStencilMask, |
25 | GrRenderTargetProxy* proxy); |
26 | |
27 | const char* name() const override { return "ClearStencilClip" ; } |
28 | |
29 | #ifdef SK_DEBUG |
30 | SkString dumpInfo() const override { |
31 | SkString string("Scissor [" ); |
32 | if (fClip.scissorEnabled()) { |
33 | const SkIRect& r = fClip.scissorRect(); |
34 | string.appendf("L: %d, T: %d, R: %d, B: %d" , r.fLeft, r.fTop, r.fRight, r.fBottom); |
35 | } else { |
36 | string.append("disabled" ); |
37 | } |
38 | string.appendf("], insideMask: %s\n" , fInsideStencilMask ? "true" : "false" ); |
39 | string.append(INHERITED::dumpInfo()); |
40 | return string; |
41 | } |
42 | #endif |
43 | |
44 | private: |
45 | friend class GrOpMemoryPool; // for ctor |
46 | |
47 | GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask, |
48 | GrRenderTargetProxy* proxy) |
49 | : INHERITED(ClassID()) |
50 | , fClip(clip) |
51 | , fInsideStencilMask(insideStencilMask) { |
52 | const SkRect& bounds = |
53 | fClip.scissorEnabled() ? SkRect::Make(fClip.scissorRect()) : proxy->getBoundsRect(); |
54 | this->setBounds(bounds, HasAABloat::kNo, IsHairline::kNo); |
55 | } |
56 | |
57 | void onPrePrepare(GrRecordingContext*, |
58 | const GrSurfaceProxyView* writeView, |
59 | GrAppliedClip*, |
60 | const GrXferProcessor::DstProxyView&) override {} |
61 | |
62 | void onPrepare(GrOpFlushState*) override {} |
63 | |
64 | void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; |
65 | |
66 | const GrFixedClip fClip; |
67 | const bool fInsideStencilMask; |
68 | |
69 | typedef GrOp INHERITED; |
70 | }; |
71 | |
72 | #endif |
73 | |