• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
name()27     const char* name() const override { return "ClearStencilClip"; }
28 
29 #ifdef SK_DEBUG
dumpInfo()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 
GrClearStencilClipOp(const GrFixedClip & clip,bool insideStencilMask,GrRenderTargetProxy * proxy)47     GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask,
48                          GrRenderTargetProxy* proxy)
49             : INHERITED(ClassID())
50             , fClip(clip)
51             , fInsideStencilMask(insideStencilMask) {
52         const SkRect& bounds = fClip.scissorEnabled()
53                                             ? SkRect::Make(fClip.scissorRect())
54                                             : SkRect::MakeIWH(proxy->width(), proxy->height());
55         this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
56     }
57 
onPrepare(GrOpFlushState *)58     void onPrepare(GrOpFlushState*) override {}
59 
60     void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
61 
62     const GrFixedClip fClip;
63     const bool        fInsideStencilMask;
64 
65     typedef GrOp INHERITED;
66 };
67 
68 #endif
69