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 DEFINE_BATCH_CLASS_ID | |
19 | |
20 GrClearBatch(const SkIRect& rect, GrColor color, GrRenderTarget* rt) | 18 GrClearBatch(const SkIRect& rect, GrColor color, GrRenderTarget* rt) |
21 : INHERITED(ClassID()) | 19 : fRect(rect) |
22 , fRect(rect) | |
23 , fColor(color) | 20 , fColor(color) |
24 , fRenderTarget(rt) { | 21 , fRenderTarget(rt) { |
| 22 this->initClassID<GrClearBatch>(); |
25 fBounds = SkRect::Make(rect); | 23 fBounds = SkRect::Make(rect); |
26 } | 24 } |
27 | 25 |
28 const char* name() const override { return "Clear"; } | 26 const char* name() const override { return "Clear"; } |
29 | 27 |
30 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } | 28 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } |
31 | 29 |
32 SkString dumpInfo() const override { | 30 SkString dumpInfo() const override { |
33 SkString string; | 31 SkString string; |
34 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", |
(...skipping 10 matching lines...) Expand all Loading... |
45 | 43 |
46 void onPrepare(GrBatchFlushState*) override {} | 44 void onPrepare(GrBatchFlushState*) override {} |
47 | 45 |
48 void onDraw(GrBatchFlushState* state) override { | 46 void onDraw(GrBatchFlushState* state) override { |
49 state->gpu()->clear(fRect, fColor, fRenderTarget.get()); | 47 state->gpu()->clear(fRect, fColor, fRenderTarget.get()); |
50 } | 48 } |
51 | 49 |
52 SkIRect fRect; | 50 SkIRect fRect; |
53 GrColor fColor; | 51 GrColor fColor; |
54 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 52 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
55 | |
56 typedef GrBatch INHERITED; | |
57 }; | 53 }; |
58 | 54 |
59 class GrClearStencilClipBatch final : public GrBatch { | 55 class GrClearStencilClipBatch final : public GrBatch { |
60 public: | 56 public: |
61 DEFINE_BATCH_CLASS_ID | |
62 | |
63 GrClearStencilClipBatch(const SkIRect& rect, bool insideClip, GrRenderTarget
* rt) | 57 GrClearStencilClipBatch(const SkIRect& rect, bool insideClip, GrRenderTarget
* rt) |
64 : INHERITED(ClassID()) | 58 : fRect(rect) |
65 , fRect(rect) | |
66 , fInsideClip(insideClip) | 59 , fInsideClip(insideClip) |
67 , fRenderTarget(rt) { | 60 , fRenderTarget(rt) { |
| 61 this->initClassID<GrClearStencilClipBatch>(); |
68 fBounds = SkRect::Make(rect); | 62 fBounds = SkRect::Make(rect); |
69 } | 63 } |
70 | 64 |
71 const char* name() const override { return "ClearStencilClip"; } | 65 const char* name() const override { return "ClearStencilClip"; } |
72 | 66 |
73 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } | 67 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } |
74 | 68 |
75 SkString dumpInfo() const override { | 69 SkString dumpInfo() const override { |
76 SkString string; | 70 SkString string; |
77 string.printf("Rect [L: %d, T: %d, R: %d, B: %d], IC: %d, RT: 0x%p", | 71 string.printf("Rect [L: %d, T: %d, R: %d, B: %d], IC: %d, RT: 0x%p", |
78 fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom, fIns
ideClip, | 72 fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom, fIns
ideClip, |
79 fRenderTarget.get()); | 73 fRenderTarget.get()); |
80 return string; | 74 return string; |
81 } | 75 } |
82 | 76 |
83 private: | 77 private: |
84 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } | 78 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } |
85 | 79 |
86 void onPrepare(GrBatchFlushState*) override {} | 80 void onPrepare(GrBatchFlushState*) override {} |
87 | 81 |
88 void onDraw(GrBatchFlushState* state) override { | 82 void onDraw(GrBatchFlushState* state) override { |
89 state->gpu()->clearStencilClip(fRect, fInsideClip, fRenderTarget.get()); | 83 state->gpu()->clearStencilClip(fRect, fInsideClip, fRenderTarget.get()); |
90 } | 84 } |
91 | 85 |
92 SkIRect fRect; | 86 SkIRect fRect; |
93 bool fInsideClip; | 87 bool fInsideClip; |
94 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 88 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
95 | |
96 typedef GrBatch INHERITED; | |
97 }; | 89 }; |
98 | 90 |
99 #endif | 91 #endif |
OLD | NEW |