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 "SkPatchUtils.h" | 9 #include "SkPatchUtils.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 (bbh) { | 17 if (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 // The SkRecord and BBH were recorded in identity space. This canvas | 19 // The SkRecord and BBH were recorded in identity space. This canvas |
20 // is not necessarily in that same space. getClipBounds() returns us | 20 // is not necessarily in that same space. getClipBounds() returns us |
21 // this canvas' clip bounds transformed back into identity space, which | 21 // this canvas' clip bounds transformed back into identity space, which |
22 // lets us query the BBH. | 22 // lets us query the BBH. |
23 SkRect query = { 0, 0, 0, 0 }; | 23 SkRect query; |
24 (void)canvas->getClipBounds(&query); | 24 if (!canvas->getClipBounds(&query)) |
mtklein
2014/10/28 17:29:43
{} ?
| |
25 return; | |
25 | 26 |
26 SkTDArray<unsigned> ops; | 27 SkTDArray<unsigned> ops; |
27 bbh->search(query, &ops); | 28 bbh->search(query, &ops); |
28 | 29 |
29 SkRecords::Draw draw(canvas); | 30 SkRecords::Draw draw(canvas); |
30 for (int i = 0; i < ops.count(); i++) { | 31 for (int i = 0; i < ops.count(); i++) { |
31 if (callback && callback->abortDrawing()) { | 32 if (callback && callback->abortDrawing()) { |
32 return; | 33 return; |
33 } | 34 } |
34 record.visit<void>(ops[i], draw); | 35 record.visit<void>(ops[i], draw); |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 // Used to track the bounds of Save/Restore blocks and the control ops insid e them. | 549 // Used to track the bounds of Save/Restore blocks and the control ops insid e them. |
549 SkTDArray<SaveBounds> fSaveStack; | 550 SkTDArray<SaveBounds> fSaveStack; |
550 SkTDArray<unsigned> fControlIndices; | 551 SkTDArray<unsigned> fControlIndices; |
551 }; | 552 }; |
552 | 553 |
553 } // namespace SkRecords | 554 } // namespace SkRecords |
554 | 555 |
555 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 556 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
556 SkRecords::FillBounds(record, bbh); | 557 SkRecords::FillBounds(record, bbh); |
557 } | 558 } |
OLD | NEW |