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 GrDiscardBatch_DEFINED | 8 #ifndef GrDiscardBatch_DEFINED |
9 #define GrDiscardBatch_DEFINED | 9 #define GrDiscardBatch_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 GrDiscardBatch final : public GrBatch { | 16 class GrDiscardBatch final : public GrBatch { |
17 public: | 17 public: |
18 DEFINE_BATCH_CLASS_ID | |
19 | |
20 GrDiscardBatch(GrRenderTarget* rt) | 18 GrDiscardBatch(GrRenderTarget* rt) |
21 : INHERITED(ClassID()) | 19 : fRenderTarget(rt) { |
22 , fRenderTarget(rt) { | 20 this->initClassID<GrDiscardBatch>(); |
23 fBounds = SkRect::MakeWH(SkIntToScalar(rt->width()), SkIntToScalar(rt->h
eight())); | 21 fBounds = SkRect::MakeWH(SkIntToScalar(rt->width()), SkIntToScalar(rt->h
eight())); |
24 } | 22 } |
25 | 23 |
26 const char* name() const override { return "Discard"; } | 24 const char* name() const override { return "Discard"; } |
27 | 25 |
28 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } | 26 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } |
29 | 27 |
30 SkString dumpInfo() const override { | 28 SkString dumpInfo() const override { |
31 SkString string; | 29 SkString string; |
32 string.printf("RT: 0x%p", fRenderTarget.get()); | 30 string.printf("RT: 0x%p", fRenderTarget.get()); |
33 return string; | 31 return string; |
34 } | 32 } |
35 | 33 |
36 private: | 34 private: |
37 bool onCombineIfPossible(GrBatch* that, const GrCaps& caps) override { | 35 bool onCombineIfPossible(GrBatch* that, const GrCaps& caps) override { |
38 return fRenderTarget == that->cast<GrDiscardBatch>()->fRenderTarget; | 36 return fRenderTarget == that->cast<GrDiscardBatch>()->fRenderTarget; |
39 } | 37 } |
40 | 38 |
41 void onPrepare(GrBatchFlushState*) override {} | 39 void onPrepare(GrBatchFlushState*) override {} |
42 | 40 |
43 void onDraw(GrBatchFlushState* state) override { | 41 void onDraw(GrBatchFlushState* state) override { |
44 state->gpu()->discard(fRenderTarget.get()); | 42 state->gpu()->discard(fRenderTarget.get()); |
45 } | 43 } |
46 | 44 |
47 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 45 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
48 | |
49 typedef GrBatch INHERITED; | |
50 }; | 46 }; |
51 | 47 |
52 #endif | 48 #endif |
OLD | NEW |