| 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 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 SkString dumpInfo() const override { | 33 SkString dumpInfo() const override { |
| 34 SkString string; | 34 SkString string; |
| 35 string.printf("Color: 0x%08x, Rect [L: %d, T: %d, R: %d, B: %d], RT: %d"
, | 35 string.printf("Color: 0x%08x, Rect [L: %d, T: %d, R: %d, B: %d], RT: %d"
, |
| 36 fColor, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBott
om, | 36 fColor, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBott
om, |
| 37 fRenderTarget.get()->getUniqueID()); | 37 fRenderTarget.get()->getUniqueID()); |
| 38 return string; | 38 return string; |
| 39 } | 39 } |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 42 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 43 // We could combine clears. TBD how much complexity to put here. | 43 // This could be much more complicated. Currently we look at cases where
the new clear |
| 44 // contains the old clear, or when the new clear is a subset of the old
clear and is the |
| 45 // same color. |
| 46 GrClearBatch* cb = t->cast<GrClearBatch>(); |
| 47 SkASSERT(cb->fRenderTarget == fRenderTarget); |
| 48 if (cb->fRect.contains(fRect)) { |
| 49 fRect = cb->fRect; |
| 50 fBounds = cb->fBounds; |
| 51 fColor = cb->fColor; |
| 52 return true; |
| 53 } else if (cb->fColor == fColor && fRect.contains(cb->fRect)) { |
| 54 return true; |
| 55 } |
| 44 return false; | 56 return false; |
| 45 } | 57 } |
| 46 | 58 |
| 47 void onPrepare(GrBatchFlushState*) override {} | 59 void onPrepare(GrBatchFlushState*) override {} |
| 48 | 60 |
| 49 void onDraw(GrBatchFlushState* state) override { | 61 void onDraw(GrBatchFlushState* state) override { |
| 50 state->gpu()->clear(fRect, fColor, fRenderTarget.get()); | 62 state->gpu()->clear(fRect, fColor, fRenderTarget.get()); |
| 51 } | 63 } |
| 52 | 64 |
| 53 SkIRect fRect; | 65 SkIRect fRect; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 104 } |
| 93 | 105 |
| 94 SkIRect fRect; | 106 SkIRect fRect; |
| 95 bool fInsideClip; | 107 bool fInsideClip; |
| 96 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 108 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 97 | 109 |
| 98 typedef GrBatch INHERITED; | 110 typedef GrBatch INHERITED; |
| 99 }; | 111 }; |
| 100 | 112 |
| 101 #endif | 113 #endif |
| OLD | NEW |