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 | |
48 rt->setLastDrawTarget(this); | 46 rt->setLastDrawTarget(this); |
49 | 47 |
50 #ifdef SK_DEBUG | 48 #ifdef SK_DEBUG |
51 static int debugID = 0; | 49 static int debugID = 0; |
52 fDebugID = debugID++; | 50 fDebugID = debugID++; |
53 #endif | 51 #endif |
54 } | 52 } |
55 | 53 |
56 GrDrawTarget::~GrDrawTarget() { | 54 GrDrawTarget::~GrDrawTarget() { |
57 if (fRenderTarget && this == fRenderTarget->getLastDrawTarget()) { | 55 if (fRenderTarget && this == fRenderTarget->getLastDrawTarget()) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 this->makeClosed(); | 188 this->makeClosed(); |
191 | 189 |
192 // Loop over the batches that haven't yet generated their geometry | 190 // Loop over the batches that haven't yet generated their geometry |
193 for (int i = 0; i < fBatches.count(); ++i) { | 191 for (int i = 0; i < fBatches.count(); ++i) { |
194 fBatches[i]->prepare(flushState); | 192 fBatches[i]->prepare(flushState); |
195 } | 193 } |
196 } | 194 } |
197 | 195 |
198 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { | 196 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { |
199 // Draw all the generated geometry. | 197 // Draw all the generated geometry. |
200 SkRandom random; | |
201 for (int i = 0; i < fBatches.count(); ++i) { | 198 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 } | |
212 fBatches[i]->draw(flushState); | 199 fBatches[i]->draw(flushState); |
213 } | 200 } |
214 | 201 |
215 fFlushing = false; | 202 fFlushing = false; |
216 } | 203 } |
217 | 204 |
218 void GrDrawTarget::reset() { | 205 void GrDrawTarget::reset() { |
219 fBatches.reset(); | 206 fBatches.reset(); |
220 } | 207 } |
221 | 208 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 } | 555 } |
569 | 556 |
570 return true; | 557 return true; |
571 } | 558 } |
572 | 559 |
573 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 560 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
574 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 561 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
575 this->recordBatch(batch); | 562 this->recordBatch(batch); |
576 batch->unref(); | 563 batch->unref(); |
577 } | 564 } |
OLD | NEW |