OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrDrawTarget.h" | 9 #include "GrDrawTarget.h" |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 const Options& options) | 36 const Options& options) |
37 : fGpu(SkRef(gpu)) | 37 : fGpu(SkRef(gpu)) |
38 , fResourceProvider(resourceProvider) | 38 , fResourceProvider(resourceProvider) |
39 , fFlushing(false) | 39 , fFlushing(false) |
40 , fFlags(0) | 40 , fFlags(0) |
41 , fRenderTarget(rt) { | 41 , fRenderTarget(rt) { |
42 // TODO: Stop extracting the context (currently needed by GrClipMaskManager) | 42 // TODO: Stop extracting the context (currently needed by GrClipMaskManager) |
43 fContext = fGpu->getContext(); | 43 fContext = fGpu->getContext(); |
44 fClipMaskManager.reset(new GrClipMaskManager(this, options.fClipBatchToBound
s)); | 44 fClipMaskManager.reset(new GrClipMaskManager(this, options.fClipBatchToBound
s)); |
45 | 45 |
| 46 fDrawBatchBounds = options.fDrawBatchBounds; |
| 47 |
46 rt->setLastDrawTarget(this); | 48 rt->setLastDrawTarget(this); |
47 | 49 |
48 #ifdef SK_DEBUG | 50 #ifdef SK_DEBUG |
49 static int debugID = 0; | 51 static int debugID = 0; |
50 fDebugID = debugID++; | 52 fDebugID = debugID++; |
51 #endif | 53 #endif |
52 } | 54 } |
53 | 55 |
54 GrDrawTarget::~GrDrawTarget() { | 56 GrDrawTarget::~GrDrawTarget() { |
55 if (fRenderTarget && this == fRenderTarget->getLastDrawTarget()) { | 57 if (fRenderTarget && this == fRenderTarget->getLastDrawTarget()) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 this->makeClosed(); | 190 this->makeClosed(); |
189 | 191 |
190 // Loop over the batches that haven't yet generated their geometry | 192 // Loop over the batches that haven't yet generated their geometry |
191 for (int i = 0; i < fBatches.count(); ++i) { | 193 for (int i = 0; i < fBatches.count(); ++i) { |
192 fBatches[i]->prepare(flushState); | 194 fBatches[i]->prepare(flushState); |
193 } | 195 } |
194 } | 196 } |
195 | 197 |
196 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { | 198 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { |
197 // Draw all the generated geometry. | 199 // Draw all the generated geometry. |
| 200 SkRandom random; |
198 for (int i = 0; i < fBatches.count(); ++i) { | 201 for (int i = 0; i < fBatches.count(); ++i) { |
| 202 if (fDrawBatchBounds) { |
| 203 const SkRect& bounds = fBatches[i]->bounds(); |
| 204 SkIRect ibounds; |
| 205 bounds.roundOut(&ibounds); |
| 206 // In multi-draw buffer all the batches use the same render target a
nd we won't need to |
| 207 // get the batchs bounds. |
| 208 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { |
| 209 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU()
); |
| 210 } |
| 211 } |
199 fBatches[i]->draw(flushState); | 212 fBatches[i]->draw(flushState); |
200 } | 213 } |
201 | 214 |
202 fFlushing = false; | 215 fFlushing = false; |
203 } | 216 } |
204 | 217 |
205 void GrDrawTarget::reset() { | 218 void GrDrawTarget::reset() { |
206 fBatches.reset(); | 219 fBatches.reset(); |
207 } | 220 } |
208 | 221 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 } | 568 } |
556 | 569 |
557 return true; | 570 return true; |
558 } | 571 } |
559 | 572 |
560 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 573 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
561 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 574 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
562 this->recordBatch(batch); | 575 this->recordBatch(batch); |
563 batch->unref(); | 576 batch->unref(); |
564 } | 577 } |
OLD | NEW |