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