OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "SkRecordDraw.h" | 8 #include "SkRecordDraw.h" |
9 #include "SkTSort.h" | 9 #include "SkTSort.h" |
10 | 10 |
11 void SkRecordDraw(const SkRecord& record, | 11 void SkRecordDraw(const SkRecord& record, |
12 SkCanvas* canvas, | 12 SkCanvas* canvas, |
13 const SkBBoxHierarchy* bbh, | 13 const SkBBoxHierarchy* bbh, |
14 SkDrawPictureCallback* callback) { | 14 SkDrawPictureCallback* callback) { |
15 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); | 15 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
16 | 16 |
17 if (NULL != bbh) { | 17 if (NULL != bbh) { |
18 // Draw only ops that affect pixels in the canvas's current clip. | 18 // Draw only ops that affect pixels in the canvas's current clip. |
19 SkIRect query; | 19 SkIRect query; |
20 #if 1 // TODO: Why is this the right way to make the query? I'd think it'd be
the else branch. | 20 #if 1 // TODO: Why is this the right way to make the query? I'd think it'd be
the else branch. |
21 SkRect clipBounds; | 21 SkRect clipBounds; |
22 canvas->getClipBounds(&clipBounds); | 22 canvas->getClipBounds(&clipBounds); |
23 clipBounds.roundOut(&query); | 23 clipBounds.roundOut(&query); |
24 #else | 24 #else |
25 canvas->getClipDeviceBounds(&query); | 25 canvas->getClipDeviceBounds(&query); |
26 #endif | 26 #endif |
27 SkTDArray<void*> ops; | 27 SkTDArray<void*> ops; |
28 bbh->search(query, &ops); | 28 bbh->search(query, &ops); |
29 | 29 |
30 // FIXME: QuadTree doesn't send these back in the order we inserted them
. :( | |
31 // Also remove the sort in SkPictureData::getActiveOps()? | |
32 if (ops.count() > 0) { | |
33 SkTQSort(ops.begin(), ops.end() - 1, SkTCompareLT<void*>()); | |
34 } | |
35 | |
36 SkRecords::Draw draw(canvas); | 30 SkRecords::Draw draw(canvas); |
37 for (int i = 0; i < ops.count(); i++) { | 31 for (int i = 0; i < ops.count(); i++) { |
38 if (NULL != callback && callback->abortDrawing()) { | 32 if (NULL != callback && callback->abortDrawing()) { |
39 return; | 33 return; |
40 } | 34 } |
41 record.visit<void>((uintptr_t)ops[i], draw); // See FillBounds belo
w. | 35 record.visit<void>((uintptr_t)ops[i], draw); // See FillBounds belo
w. |
42 } | 36 } |
43 } else { | 37 } else { |
44 // Draw all ops. | 38 // Draw all ops. |
45 for (SkRecords::Draw draw(canvas); draw.index() < record.count(); draw.n
ext()) { | 39 for (SkRecords::Draw draw(canvas); draw.index() < record.count(); draw.n
ext()) { |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. | 288 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. |
295 SkTDArray<SaveBounds> fSaveStack; | 289 SkTDArray<SaveBounds> fSaveStack; |
296 SkTDArray<unsigned> fControlIndices; | 290 SkTDArray<unsigned> fControlIndices; |
297 }; | 291 }; |
298 | 292 |
299 } // namespace SkRecords | 293 } // namespace SkRecords |
300 | 294 |
301 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 295 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
302 SkRecords::FillBounds(record, bbh); | 296 SkRecords::FillBounds(record, bbh); |
303 } | 297 } |
OLD | NEW |