Line data Source code
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 "GrFixedClip.h"
12 : #include "GrGpu.h"
13 : #include "GrGpuCommandBuffer.h"
14 : #include "GrOp.h"
15 : #include "GrOpFlushState.h"
16 : #include "GrRenderTarget.h"
17 :
18 0 : class GrClearStencilClipOp final : public GrOp {
19 : public:
20 0 : DEFINE_OP_CLASS_ID
21 :
22 : // MDB TODO: replace the renderTargetContext with just the renderTargetProxy.
23 : // For now, we need the renderTargetContext for its accessRenderTarget powers.
24 0 : static std::unique_ptr<GrOp> Make(const GrFixedClip& clip, bool insideStencilMask,
25 : GrRenderTargetContext* rtc) {
26 :
27 : // MDB TODO: remove this. In this hybrid state we need to be sure the RT is instantiable
28 : // so it can carry the IO refs. In the future we will just get the proxy and
29 : // it carry the IO refs.
30 0 : if (!rtc->accessRenderTarget()) {
31 0 : return nullptr;
32 : }
33 :
34 0 : return std::unique_ptr<GrOp>(new GrClearStencilClipOp(clip, insideStencilMask, rtc));
35 : }
36 :
37 0 : const char* name() const override { return "ClearStencilClip"; }
38 :
39 0 : SkString dumpInfo() const override {
40 0 : SkString string("Scissor [");
41 0 : if (fClip.scissorEnabled()) {
42 0 : const SkIRect& r = fClip.scissorRect();
43 0 : string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
44 : }
45 0 : string.appendf("], IC: %d, rtID: %d proxyID: %d",
46 0 : fInsideStencilMask,
47 0 : fRenderTarget.get()->uniqueID().asUInt(),
48 0 : fProxyUniqueID.asUInt());
49 0 : string.append(INHERITED::dumpInfo());
50 0 : return string;
51 : }
52 :
53 : private:
54 0 : GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask,
55 : GrRenderTargetContext* rtc)
56 0 : : INHERITED(ClassID())
57 : , fClip(clip)
58 : , fInsideStencilMask(insideStencilMask)
59 0 : , fProxyUniqueID(rtc->asSurfaceProxy()->uniqueID()) {
60 0 : const SkRect& bounds = fClip.scissorEnabled()
61 0 : ? SkRect::Make(fClip.scissorRect())
62 0 : : SkRect::MakeIWH(rtc->width(), rtc->height());
63 0 : this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
64 :
65 0 : fRenderTarget.reset(rtc->accessRenderTarget());
66 0 : }
67 :
68 0 : bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; }
69 :
70 0 : void onPrepare(GrOpFlushState*) override {}
71 :
72 0 : void onExecute(GrOpFlushState* state) override {
73 : // MDB TODO: instantiate the renderTarget from the proxy in here
74 0 : state->commandBuffer()->clearStencilClip(fRenderTarget.get(), fClip, fInsideStencilMask);
75 0 : }
76 :
77 : const GrFixedClip fClip;
78 : const bool fInsideStencilMask;
79 : // MDB TODO: remove this. When the renderTargetProxy carries the refs this will be redundant.
80 : GrSurfaceProxy::UniqueID fProxyUniqueID;
81 : GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
82 :
83 : typedef GrOp INHERITED;
84 : };
85 :
86 : #endif
|