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 "SkLayerInfo.h" | 8 #include "SkLayerInfo.h" |
9 #include "SkRecordDraw.h" | 9 #include "SkRecordDraw.h" |
10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
11 | 11 |
12 void SkRecordDraw(const SkRecord& record, | 12 void SkRecordDraw(const SkRecord& record, |
13 SkCanvas* canvas, | 13 SkCanvas* canvas, |
14 SkPicture const* const drawablePicts[], int drawableCount, | 14 SkPicture const* const drawablePicts[], int drawableCount, |
15 const SkBBoxHierarchy* bbh, | 15 const SkBBoxHierarchy* bbh, |
16 SkDrawPictureCallback* callback) { | 16 SkDrawPictureCallback* callback) { |
17 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); | 17 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
18 | 18 |
19 if (bbh) { | 19 if (bbh) { |
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 // The SkRecord and BBH were recorded in identity space. This canvas | 21 // The SkRecord and BBH were recorded in identity space. This canvas |
22 // is not necessarily in that same space. getClipBounds() returns us | 22 // is not necessarily in that same space. getClipBounds() returns us |
23 // this canvas' clip bounds transformed back into identity space, which | 23 // this canvas' clip bounds transformed back into identity space, which |
24 // lets us query the BBH. | 24 // lets us query the BBH. |
25 SkRect query; | 25 SkRect query = { 0, 0, 0, 0 }; |
26 if (!canvas->getClipBounds(&query)) { | 26 (void)canvas->getClipBounds(&query); |
27 return; | |
28 } | |
29 | 27 |
30 SkTDArray<unsigned> ops; | 28 SkTDArray<unsigned> ops; |
31 bbh->search(query, &ops); | 29 bbh->search(query, &ops); |
32 | 30 |
33 SkRecords::Draw draw(canvas, drawablePicts, drawableCount); | 31 SkRecords::Draw draw(canvas, drawablePicts, drawableCount); |
34 for (int i = 0; i < ops.count(); i++) { | 32 for (int i = 0; i < ops.count(); i++) { |
35 if (callback && callback->abortDrawing()) { | 33 if (callback && callback->abortDrawing()) { |
36 return; | 34 return; |
37 } | 35 } |
38 // This visit call uses the SkRecords::Draw::operator() to call | 36 // This visit call uses the SkRecords::Draw::operator() to call |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 SkRecords::CollectLayers visitor(cullRect, record, data); | 754 SkRecords::CollectLayers visitor(cullRect, record, data); |
757 | 755 |
758 for (unsigned curOp = 0; curOp < record.count(); curOp++) { | 756 for (unsigned curOp = 0; curOp < record.count(); curOp++) { |
759 visitor.setCurrentOp(curOp); | 757 visitor.setCurrentOp(curOp); |
760 record.visit<void>(curOp, visitor); | 758 record.visit<void>(curOp, visitor); |
761 } | 759 } |
762 | 760 |
763 visitor.cleanUp(bbh); | 761 visitor.cleanUp(bbh); |
764 } | 762 } |
765 | 763 |
OLD | NEW |