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