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 #include "SkTraceEvent.h" |
| 12 |
| 13 DrawData::DrawData(const SkRecord& r, |
| 14 SkCanvas* c, |
| 15 SkPicture const* const dp[], |
| 16 SkDrawable* const dw[], |
| 17 int dc, |
| 18 const SkBBoxHierarchy* b, |
| 19 SkPicture::AbortCallback* cb) |
| 20 : record(r), |
| 21 canvas(c), |
| 22 drawablePicts(dp), |
| 23 drawables(dw), |
| 24 drawableCount(dc), |
| 25 bbh(b), |
| 26 callback(cb), |
| 27 draw(c, dp, dw, dc), |
| 28 ops_count(0), |
| 29 record_count(0) {} |
| 30 |
| 31 void SkRecordDrawPrasInit(DrawData& data) { |
| 32 TRACE_EVENT0("pras_skia", "SkRecordDrawPrasInit"); |
| 33 data.canvas->save(); |
| 34 |
| 35 if (data.bbh) { |
| 36 // Draw only ops that affect pixels in the canvas's current clip. |
| 37 // The SkRecord and BBH were recorded in identity space. This canvas |
| 38 // is not necessarily in that same space. getClipBounds() returns us |
| 39 // this canvas' clip bounds transformed back into identity space, which |
| 40 // lets us query the BBH. |
| 41 SkRect query; |
| 42 if (!data.canvas->getClipBounds(&query)) { |
| 43 query.setEmpty(); |
| 44 } |
| 45 |
| 46 data.bbh->search(query, &data.ops); |
| 47 } |
| 48 } |
| 49 |
| 50 bool SkRecordDrawPrasDo(DrawData& data) { |
| 51 TRACE_EVENT0("pras_skia", "SkRecordDrawPrasDo"); |
| 52 if (data.bbh) { |
| 53 if (data.ops_count >= data.ops.count()) |
| 54 return true; |
| 55 |
| 56 if (data.callback && data.callback->abort()) { |
| 57 return true; |
| 58 } |
| 59 data.record.visit<void>(data.ops[data.ops_count], data.draw); |
| 60 data.ops_count++; |
| 61 return false; |
| 62 } else { |
| 63 if (data.record_count >= data.record.count()) |
| 64 return true; |
| 65 |
| 66 if (data.callback && data.callback->abort()) { |
| 67 return true; |
| 68 } |
| 69 data.record.visit<void>(data.record_count, data.draw); |
| 70 data.record_count++; |
| 71 return false; |
| 72 } |
| 73 } |
| 74 |
| 75 void SkRecordDrawPrasDeInit(DrawData& data) { |
| 76 TRACE_EVENT0("pras_skia", "SkRecordDrawPrasDeInit"); |
| 77 data.canvas->restore(); |
| 78 } |
| 79 |
| 80 void SkRecordDrawPras(DrawData& data) { |
| 81 SkAutoCanvasRestore saveRestore(data.canvas, |
| 82 true /*save now, restore at exit*/); |
| 83 TRACE_EVENT0("skia", "SkRecordDrawPras"); |
| 84 |
| 85 if (data.bbh) { |
| 86 // Draw only ops that affect pixels in the canvas's current clip. |
| 87 // The SkRecord and BBH were recorded in identity space. This canvas |
| 88 // is not necessarily in that same space. getClipBounds() returns us |
| 89 // this canvas' clip bounds transformed back into identity space, which |
| 90 // lets us query the BBH. |
| 91 SkRect query; |
| 92 if (!data.canvas->getClipBounds(&query)) { |
| 93 query.setEmpty(); |
| 94 } |
| 95 |
| 96 data.bbh->search(query, &data.ops); |
| 97 |
| 98 SkRecords::Draw draw(data.canvas, data.drawablePicts, data.drawables, |
| 99 data.drawableCount); |
| 100 for (int i = 0; i < data.ops.count(); i++) { |
| 101 if (data.callback && data.callback->abort()) { |
| 102 return; |
| 103 } |
| 104 // This visit call uses the SkRecords::Draw::operator() to call |
| 105 // methods on the |canvas|, wrapped by methods defined with the |
| 106 // DRAW() macro. |
| 107 data.record.visit<void>(data.ops[i], draw); |
| 108 } |
| 109 } else { |
| 110 // Draw all ops. |
| 111 SkRecords::Draw draw(data.canvas, data.drawablePicts, data.drawables, |
| 112 data.drawableCount); |
| 113 for (int i = 0; i < data.record.count(); i++) { |
| 114 if (data.callback && data.callback->abort()) { |
| 115 return; |
| 116 } |
| 117 // This visit call uses the SkRecords::Draw::operator() to call |
| 118 // methods on the |canvas|, wrapped by methods defined with the |
| 119 // DRAW() macro. |
| 120 data.record.visit<void>(i, draw); |
| 121 } |
| 122 } |
| 123 } |
11 | 124 |
12 void SkRecordDraw(const SkRecord& record, | 125 void SkRecordDraw(const SkRecord& record, |
13 SkCanvas* canvas, | 126 SkCanvas* canvas, |
14 SkPicture const* const drawablePicts[], | 127 SkPicture const* const drawablePicts[], |
15 SkDrawable* const drawables[], | 128 SkDrawable* const drawables[], |
16 int drawableCount, | 129 int drawableCount, |
17 const SkBBoxHierarchy* bbh, | 130 const SkBBoxHierarchy* bbh, |
18 SkPicture::AbortCallback* callback) { | 131 SkPicture::AbortCallback* callback) { |
19 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); | 132 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
| 133 TRACE_EVENT0("pras", "SkRecordDraw"); |
20 | 134 |
21 if (bbh) { | 135 if (bbh) { |
22 // Draw only ops that affect pixels in the canvas's current clip. | 136 // Draw only ops that affect pixels in the canvas's current clip. |
23 // The SkRecord and BBH were recorded in identity space. This canvas | 137 // The SkRecord and BBH were recorded in identity space. This canvas |
24 // is not necessarily in that same space. getClipBounds() returns us | 138 // is not necessarily in that same space. getClipBounds() returns us |
25 // this canvas' clip bounds transformed back into identity space, which | 139 // this canvas' clip bounds transformed back into identity space, which |
26 // lets us query the BBH. | 140 // lets us query the BBH. |
27 SkRect query; | 141 SkRect query; |
28 if (!canvas->getClipBounds(&query)) { | 142 if (!canvas->getClipBounds(&query)) { |
29 query.setEmpty(); | 143 query.setEmpty(); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, SkRec
t bounds[], | 914 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, SkRec
t bounds[], |
801 const SkBigPicture::SnapshotArray* pictList, SkLayerI
nfo* data) { | 915 const SkBigPicture::SnapshotArray* pictList, SkLayerI
nfo* data) { |
802 SkRecords::CollectLayers visitor(cullRect, record, bounds, pictList, data); | 916 SkRecords::CollectLayers visitor(cullRect, record, bounds, pictList, data); |
803 for (int curOp = 0; curOp < record.count(); curOp++) { | 917 for (int curOp = 0; curOp < record.count(); curOp++) { |
804 visitor.setCurrentOp(curOp); | 918 visitor.setCurrentOp(curOp); |
805 record.visit<void>(curOp, visitor); | 919 record.visit<void>(curOp, visitor); |
806 } | 920 } |
807 visitor.cleanUp(); | 921 visitor.cleanUp(); |
808 } | 922 } |
809 | 923 |
OLD | NEW |