| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrClearStencilClipBatch_DEFINED | 8 #ifndef GrClearStencilClipBatch_DEFINED |
| 9 #define GrClearStencilClipBatch_DEFINED | 9 #define GrClearStencilClipBatch_DEFINED |
| 10 | 10 |
| 11 #include "GrBatch.h" | 11 #include "GrBatch.h" |
| 12 #include "GrBatchFlushState.h" | 12 #include "GrBatchFlushState.h" |
| 13 #include "GrFixedClip.h" |
| 13 #include "GrGpu.h" | 14 #include "GrGpu.h" |
| 14 #include "GrGpuCommandBuffer.h" | 15 #include "GrGpuCommandBuffer.h" |
| 15 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
| 16 | 17 |
| 17 class GrClearStencilClipBatch final : public GrBatch { | 18 class GrClearStencilClipBatch final : public GrBatch { |
| 18 public: | 19 public: |
| 19 DEFINE_BATCH_CLASS_ID | 20 DEFINE_BATCH_CLASS_ID |
| 20 | 21 |
| 21 GrClearStencilClipBatch(const SkIRect& rect, bool insideClip, GrRenderTarget
* rt) | 22 GrClearStencilClipBatch(const GrFixedClip& clip, bool insideStencilMask, GrR
enderTarget* rt) |
| 22 : INHERITED(ClassID()) | 23 : INHERITED(ClassID()) |
| 23 , fRect(rect) | 24 , fClip(clip) |
| 24 , fInsideClip(insideClip) | 25 , fInsideStencilMask(insideStencilMask) |
| 25 , fRenderTarget(rt) { | 26 , fRenderTarget(rt) { |
| 26 this->setBounds(SkRect::Make(rect), HasAABloat::kNo, IsZeroArea::kNo); | 27 const SkRect& bounds = fClip.scissorEnabled() ? SkRect::Make(fClip.sciss
orRect()) |
| 28 : SkRect::MakeIWH(rt->widt
h(), rt->height()); |
| 29 this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo); |
| 27 } | 30 } |
| 28 | 31 |
| 29 const char* name() const override { return "ClearStencilClip"; } | 32 const char* name() const override { return "ClearStencilClip"; } |
| 30 | 33 |
| 31 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } | 34 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } |
| 32 GrRenderTarget* renderTarget() const override { return fRenderTarget.get();
} | 35 GrRenderTarget* renderTarget() const override { return fRenderTarget.get();
} |
| 33 | 36 |
| 34 SkString dumpInfo() const override { | 37 SkString dumpInfo() const override { |
| 35 SkString string; | 38 SkString string("Scissor ["); |
| 36 string.printf("Rect [L: %d, T: %d, R: %d, B: %d], IC: %d, RT: %d", | 39 if (fClip.scissorEnabled()) { |
| 37 fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom, fIns
ideClip, | 40 const SkIRect& r = fClip.scissorRect(); |
| 38 fRenderTarget.get()->getUniqueID()); | 41 string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRig
ht, r.fBottom); |
| 42 } |
| 43 string.appendf("], IC: %d, RT: %d", fInsideStencilMask, fRenderTarget.ge
t()->getUniqueID()); |
| 39 string.append(INHERITED::dumpInfo()); | 44 string.append(INHERITED::dumpInfo()); |
| 40 return string; | 45 return string; |
| 41 } | 46 } |
| 42 | 47 |
| 43 private: | 48 private: |
| 44 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } | 49 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } |
| 45 | 50 |
| 46 void onPrepare(GrBatchFlushState*) override {} | 51 void onPrepare(GrBatchFlushState*) override {} |
| 47 | 52 |
| 48 void onDraw(GrBatchFlushState* state) override { | 53 void onDraw(GrBatchFlushState* state) override { |
| 49 state->commandBuffer()->clearStencilClip(fRect, fInsideClip, fRenderTarg
et.get()); | 54 state->commandBuffer()->clearStencilClip(fClip, fInsideStencilMask, fRen
derTarget.get()); |
| 50 } | 55 } |
| 51 | 56 |
| 52 SkIRect fRect; | 57 const GrFixedClip fClip; |
| 53 bool fInsideClip; | 58 const bool fInsideStencilMask; |
| 54 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 59 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 55 | 60 |
| 56 typedef GrBatch INHERITED; | 61 typedef GrBatch INHERITED; |
| 57 }; | 62 }; |
| 58 | 63 |
| 59 #endif | 64 #endif |
| OLD | NEW |