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 SkASSERT(bbh->getCount() == SkToInt(record.count())); | 18 SkASSERT(bbh->getCount() == SkToInt(record.count())); |
19 | 19 |
20 // Draw only ops that affect pixels in the canvas's current clip. | 20 // Draw only ops that affect pixels in the canvas's current clip. |
21 SkIRect devBounds; | 21 SkIRect devBounds; |
22 canvas->getClipDeviceBounds(&devBounds); | 22 canvas->getClipDeviceBounds(&devBounds); |
23 SkTDArray<void*> ops; | 23 SkTDArray<void*> ops; |
24 bbh->search(devBounds, &ops); | 24 bbh->search(devBounds, &ops); |
25 | 25 |
26 // Until we start filling in real bounds, we should get every op back. | 26 // Until we start filling in real bounds, we should get every op back. |
27 SkASSERT(ops.count() == SkToInt(record.count())); | 27 SkASSERT(ops.count() == SkToInt(record.count())); |
28 | 28 |
29 // FIXME: QuadTree doesn't send these back in the order we inserted them
. :( | 29 // FIXME: QuadTree doesn't send these back in the order we inserted them
. :( |
| 30 // Also remove the sort in SkPictureData::getActiveOps()? |
30 if (ops.count() > 0) { | 31 if (ops.count() > 0) { |
31 SkTQSort(ops.begin(), ops.end() - 1, SkTCompareLT<void*>()); | 32 SkTQSort(ops.begin(), ops.end() - 1, SkTCompareLT<void*>()); |
32 } | 33 } |
33 | 34 |
34 SkRecords::Draw draw(canvas); | 35 SkRecords::Draw draw(canvas); |
35 for (int i = 0; i < ops.count(); i++) { | 36 for (int i = 0; i < ops.count(); i++) { |
36 if (NULL != callback && callback->abortDrawing()) { | 37 if (NULL != callback && callback->abortDrawing()) { |
37 return; | 38 return; |
38 } | 39 } |
39 record.visit<void>((uintptr_t)ops[i], draw); // See FillBounds belo
w. | 40 record.visit<void>((uintptr_t)ops[i], draw); // See FillBounds belo
w. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 }; | 123 }; |
123 | 124 |
124 } // namespace SkRecords | 125 } // namespace SkRecords |
125 | 126 |
126 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 127 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
127 SkASSERT(NULL != bbh); | 128 SkASSERT(NULL != bbh); |
128 for(SkRecords::FillBounds fb(bbh); fb.index() < record.count(); fb.next()) { | 129 for(SkRecords::FillBounds fb(bbh); fb.index() < record.count(); fb.next()) { |
129 record.visit<void>(fb.index(), fb); | 130 record.visit<void>(fb.index(), fb); |
130 } | 131 } |
131 } | 132 } |
OLD | NEW |