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 "SkAbortCallback.h" |
8 #include "SkLayerInfo.h" | 9 #include "SkLayerInfo.h" |
9 #include "SkRecordDraw.h" | 10 #include "SkRecordDraw.h" |
10 #include "SkPatchUtils.h" | 11 #include "SkPatchUtils.h" |
11 | 12 |
12 void SkRecordDraw(const SkRecord& record, | 13 void SkRecordDraw(const SkRecord& record, |
13 SkCanvas* canvas, | 14 SkCanvas* canvas, |
14 SkPicture const* const drawablePicts[], | 15 SkPicture const* const drawablePicts[], |
15 SkCanvasDrawable* const drawables[], | 16 SkCanvasDrawable* const drawables[], |
16 int drawableCount, | 17 int drawableCount, |
17 const SkBBoxHierarchy* bbh, | 18 const SkBBoxHierarchy* bbh, |
18 SkDrawPictureCallback* callback) { | 19 SkAbortCallback* callback) { |
19 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); | 20 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
20 | 21 |
21 if (bbh) { | 22 if (bbh) { |
22 // Draw only ops that affect pixels in the canvas's current clip. | 23 // Draw only ops that affect pixels in the canvas's current clip. |
23 // The SkRecord and BBH were recorded in identity space. This canvas | 24 // The SkRecord and BBH were recorded in identity space. This canvas |
24 // is not necessarily in that same space. getClipBounds() returns us | 25 // is not necessarily in that same space. getClipBounds() returns us |
25 // this canvas' clip bounds transformed back into identity space, which | 26 // this canvas' clip bounds transformed back into identity space, which |
26 // lets us query the BBH. | 27 // lets us query the BBH. |
27 SkRect query; | 28 SkRect query; |
28 if (!canvas->getClipBounds(&query)) { | 29 if (!canvas->getClipBounds(&query)) { |
29 query.setEmpty(); | 30 query.setEmpty(); |
30 } | 31 } |
31 | 32 |
32 SkTDArray<unsigned> ops; | 33 SkTDArray<unsigned> ops; |
33 bbh->search(query, &ops); | 34 bbh->search(query, &ops); |
34 | 35 |
35 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount); | 36 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount); |
36 for (int i = 0; i < ops.count(); i++) { | 37 for (int i = 0; i < ops.count(); i++) { |
37 if (callback && callback->abortDrawing()) { | 38 if (callback && callback->abort()) { |
38 return; | 39 return; |
39 } | 40 } |
40 // This visit call uses the SkRecords::Draw::operator() to call | 41 // This visit call uses the SkRecords::Draw::operator() to call |
41 // methods on the |canvas|, wrapped by methods defined with the | 42 // methods on the |canvas|, wrapped by methods defined with the |
42 // DRAW() macro. | 43 // DRAW() macro. |
43 record.visit<void>(ops[i], draw); | 44 record.visit<void>(ops[i], draw); |
44 } | 45 } |
45 } else { | 46 } else { |
46 // Draw all ops. | 47 // Draw all ops. |
47 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount); | 48 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount); |
48 for (unsigned i = 0; i < record.count(); i++) { | 49 for (unsigned i = 0; i < record.count(); i++) { |
49 if (callback && callback->abortDrawing()) { | 50 if (callback && callback->abort()) { |
50 return; | 51 return; |
51 } | 52 } |
52 // This visit call uses the SkRecords::Draw::operator() to call | 53 // This visit call uses the SkRecords::Draw::operator() to call |
53 // methods on the |canvas|, wrapped by methods defined with the | 54 // methods on the |canvas|, wrapped by methods defined with the |
54 // DRAW() macro. | 55 // DRAW() macro. |
55 record.visit<void>(i, draw); | 56 record.visit<void>(i, draw); |
56 } | 57 } |
57 } | 58 } |
58 } | 59 } |
59 | 60 |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); | 788 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); |
788 | 789 |
789 for (unsigned curOp = 0; curOp < record.count(); curOp++) { | 790 for (unsigned curOp = 0; curOp < record.count(); curOp++) { |
790 visitor.setCurrentOp(curOp); | 791 visitor.setCurrentOp(curOp); |
791 record.visit<void>(curOp, visitor); | 792 record.visit<void>(curOp, visitor); |
792 } | 793 } |
793 | 794 |
794 visitor.cleanUp(bbh); | 795 visitor.cleanUp(bbh); |
795 } | 796 } |
796 | 797 |
OLD | NEW |