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 "GrGpuCommandBuffer.h" | 14 #include "GrGpuCommandBuffer.h" |
15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
16 | 16 |
17 class GrClearBatch final : public GrBatch { | 17 class GrClearBatch final : public GrBatch { |
18 public: | 18 public: |
19 DEFINE_BATCH_CLASS_ID | 19 DEFINE_BATCH_CLASS_ID |
20 | 20 |
21 GrClearBatch(const SkIRect& rect, GrColor color, GrRenderTarget* rt) | 21 static sk_sp<GrBatch> Make(const SkIRect& rect, GrColor color, GrRenderTarg
et* rt) { |
22 : INHERITED(ClassID()) | 22 return sk_sp<GrBatch>(new GrClearBatch(rect, color, rt)); |
23 , fRect(rect) | |
24 , fColor(color) | |
25 , fRenderTarget(rt) { | |
26 this->setBounds(SkRect::Make(rect), HasAABloat::kNo, IsZeroArea::kNo); | |
27 } | 23 } |
28 | 24 |
29 const char* name() const override { return "Clear"; } | 25 const char* name() const override { return "Clear"; } |
30 | 26 |
31 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } | 27 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } |
32 GrRenderTarget* renderTarget() const override { return fRenderTarget.get();
} | 28 GrRenderTarget* renderTarget() const override { return fRenderTarget.get();
} |
33 | 29 |
34 SkString dumpInfo() const override { | 30 SkString dumpInfo() const override { |
35 SkString string; | 31 SkString string; |
36 string.printf("Color: 0x%08x, Rect [L: %d, T: %d, R: %d, B: %d], RT: %d"
, | 32 string.printf("Color: 0x%08x, Rect [L: %d, T: %d, R: %d, B: %d], RT: %d"
, |
37 fColor, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBott
om, | 33 fColor, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBott
om, |
38 fRenderTarget.get()->getUniqueID()); | 34 fRenderTarget.get()->getUniqueID()); |
39 string.append(INHERITED::dumpInfo()); | 35 string.append(INHERITED::dumpInfo()); |
40 return string; | 36 return string; |
41 } | 37 } |
42 | 38 |
43 private: | 39 private: |
| 40 GrClearBatch(const SkIRect& rect, GrColor color, GrRenderTarget* rt) |
| 41 : INHERITED(ClassID()) |
| 42 , fRect(rect) |
| 43 , fColor(color) |
| 44 , fRenderTarget(rt) { |
| 45 this->setBounds(SkRect::Make(rect), HasAABloat::kNo, IsZeroArea::kNo); |
| 46 } |
| 47 |
44 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 48 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
45 // This could be much more complicated. Currently we look at cases where
the new clear | 49 // This could be much more complicated. Currently we look at cases where
the new clear |
46 // contains the old clear, or when the new clear is a subset of the old
clear and is the | 50 // contains the old clear, or when the new clear is a subset of the old
clear and is the |
47 // same color. | 51 // same color. |
48 GrClearBatch* cb = t->cast<GrClearBatch>(); | 52 GrClearBatch* cb = t->cast<GrClearBatch>(); |
49 SkASSERT(cb->fRenderTarget == fRenderTarget); | 53 SkASSERT(cb->fRenderTarget == fRenderTarget); |
50 if (cb->fRect.contains(fRect)) { | 54 if (cb->fRect.contains(fRect)) { |
51 fRect = cb->fRect; | 55 fRect = cb->fRect; |
52 this->replaceBounds(*t); | 56 this->replaceBounds(*t); |
53 fColor = cb->fColor; | 57 fColor = cb->fColor; |
(...skipping 10 matching lines...) Expand all Loading... |
64 state->commandBuffer()->clear(fRect, fColor, fRenderTarget.get()); | 68 state->commandBuffer()->clear(fRect, fColor, fRenderTarget.get()); |
65 } | 69 } |
66 | 70 |
67 SkIRect fRect; | 71 SkIRect fRect; |
68 GrColor fColor; | 72 GrColor fColor; |
69 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 73 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
70 | 74 |
71 typedef GrBatch INHERITED; | 75 typedef GrBatch INHERITED; |
72 }; | 76 }; |
73 | 77 |
74 class GrClearStencilClipBatch final : public GrBatch { | |
75 public: | |
76 DEFINE_BATCH_CLASS_ID | |
77 | |
78 GrClearStencilClipBatch(const SkIRect& rect, bool insideClip, GrRenderTarget
* rt) | |
79 : INHERITED(ClassID()) | |
80 , fRect(rect) | |
81 , fInsideClip(insideClip) | |
82 , fRenderTarget(rt) { | |
83 this->setBounds(SkRect::Make(rect), HasAABloat::kNo, IsZeroArea::kNo); | |
84 } | |
85 | |
86 const char* name() const override { return "ClearStencilClip"; } | |
87 | |
88 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } | |
89 GrRenderTarget* renderTarget() const override { return fRenderTarget.get();
} | |
90 | |
91 SkString dumpInfo() const override { | |
92 SkString string; | |
93 string.printf("Rect [L: %d, T: %d, R: %d, B: %d], IC: %d, RT: 0x%p", | |
94 fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom, fIns
ideClip, | |
95 fRenderTarget.get()); | |
96 string.append(INHERITED::dumpInfo()); | |
97 return string; | |
98 } | |
99 | |
100 private: | |
101 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } | |
102 | |
103 void onPrepare(GrBatchFlushState*) override {} | |
104 | |
105 void onDraw(GrBatchFlushState* state) override { | |
106 state->commandBuffer()->clearStencilClip(fRect, fInsideClip, fRenderTarg
et.get()); | |
107 } | |
108 | |
109 SkIRect fRect; | |
110 bool fInsideClip; | |
111 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | |
112 | |
113 typedef GrBatch INHERITED; | |
114 }; | |
115 | |
116 #endif | 78 #endif |
OLD | NEW |