OLD | NEW |
(Empty) | |
| 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 GrClearBatch_DEFINED |
| 9 #define GrClearBatch_DEFINED |
| 10 |
| 11 #include "GrBatch.h" |
| 12 #include "GrBatchFlushState.h" |
| 13 #include "GrGpu.h" |
| 14 #include "GrRenderTarget.h" |
| 15 |
| 16 class GrClearBatch final : public GrBatch { |
| 17 public: |
| 18 GrClearBatch(const SkIRect& rect, GrColor color, GrRenderTarget* rt) |
| 19 : fRect(rect) |
| 20 , fColor(color) |
| 21 , fRenderTarget(rt) { |
| 22 this->initClassID<GrClearBatch>(); |
| 23 fBounds = SkRect::Make(rect); |
| 24 } |
| 25 |
| 26 const char* name() const override { return "Clear"; } |
| 27 |
| 28 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } |
| 29 |
| 30 SkString dumpInfo() const { |
| 31 SkString string; |
| 32 string.printf("Color: 0x%08x, Rect [L: %d, T: %d, R: %d, B: %d], RT: 0x%
p", |
| 33 fColor, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBott
om, |
| 34 fRenderTarget.get()); |
| 35 return string; |
| 36 } |
| 37 |
| 38 private: |
| 39 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 40 // We could combine clears. TBD how much complexity to put here. |
| 41 return false; |
| 42 } |
| 43 |
| 44 void onPrepare(GrBatchFlushState*) override {} |
| 45 |
| 46 void onDraw(GrBatchFlushState* state) override { |
| 47 state->gpu()->clear(fRect, fColor, fRenderTarget.get()); |
| 48 } |
| 49 |
| 50 SkIRect fRect; |
| 51 GrColor fColor; |
| 52 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 53 }; |
| 54 |
| 55 #endif |
OLD | NEW |