Index: src/core/SkRecordDraw.cpp |
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp |
index 5ca9517d3f81cb7adef234596a3e1db9de5e87e5..c7e5e423a19c36e1d5c87f30149e9805870330f6 100644 |
--- a/src/core/SkRecordDraw.cpp |
+++ b/src/core/SkRecordDraw.cpp |
@@ -8,6 +8,119 @@ |
#include "SkLayerInfo.h" |
#include "SkRecordDraw.h" |
#include "SkPatchUtils.h" |
+#include "SkTraceEvent.h" |
+ |
+DrawData::DrawData(const SkRecord& r, |
+ SkCanvas* c, |
+ SkPicture const* const dp[], |
+ SkDrawable* const dw[], |
+ int dc, |
+ const SkBBoxHierarchy* b, |
+ SkPicture::AbortCallback* cb) |
+ : record(r), |
+ canvas(c), |
+ drawablePicts(dp), |
+ drawables(dw), |
+ drawableCount(dc), |
+ bbh(b), |
+ callback(cb), |
+ draw(c, dp, dw, dc), |
+ ops_count(0), |
+ record_count(0) {} |
+ |
+void SkRecordDrawPrasInit(DrawData& data) { |
+ TRACE_EVENT0("pras_skia", "SkRecordDrawPrasInit"); |
+ data.canvas->save(); |
+ |
+ if (data.bbh) { |
+ // Draw only ops that affect pixels in the canvas's current clip. |
+ // The SkRecord and BBH were recorded in identity space. This canvas |
+ // is not necessarily in that same space. getClipBounds() returns us |
+ // this canvas' clip bounds transformed back into identity space, which |
+ // lets us query the BBH. |
+ SkRect query; |
+ if (!data.canvas->getClipBounds(&query)) { |
+ query.setEmpty(); |
+ } |
+ |
+ data.bbh->search(query, &data.ops); |
+ } |
+} |
+ |
+bool SkRecordDrawPrasDo(DrawData& data) { |
+ TRACE_EVENT0("pras_skia", "SkRecordDrawPrasDo"); |
+ if (data.bbh) { |
+ if (data.ops_count >= data.ops.count()) |
+ return true; |
+ |
+ if (data.callback && data.callback->abort()) { |
+ return true; |
+ } |
+ data.record.visit<void>(data.ops[data.ops_count], data.draw); |
+ data.ops_count++; |
+ return false; |
+ } else { |
+ if (data.record_count >= data.record.count()) |
+ return true; |
+ |
+ if (data.callback && data.callback->abort()) { |
+ return true; |
+ } |
+ data.record.visit<void>(data.record_count, data.draw); |
+ data.record_count++; |
+ return false; |
+ } |
+} |
+ |
+void SkRecordDrawPrasDeInit(DrawData& data) { |
+ TRACE_EVENT0("pras_skia", "SkRecordDrawPrasDeInit"); |
+ data.canvas->restore(); |
+} |
+ |
+void SkRecordDrawPras(DrawData& data) { |
+ SkAutoCanvasRestore saveRestore(data.canvas, |
+ true /*save now, restore at exit*/); |
+ TRACE_EVENT0("skia", "SkRecordDrawPras"); |
+ |
+ if (data.bbh) { |
+ // Draw only ops that affect pixels in the canvas's current clip. |
+ // The SkRecord and BBH were recorded in identity space. This canvas |
+ // is not necessarily in that same space. getClipBounds() returns us |
+ // this canvas' clip bounds transformed back into identity space, which |
+ // lets us query the BBH. |
+ SkRect query; |
+ if (!data.canvas->getClipBounds(&query)) { |
+ query.setEmpty(); |
+ } |
+ |
+ data.bbh->search(query, &data.ops); |
+ |
+ SkRecords::Draw draw(data.canvas, data.drawablePicts, data.drawables, |
+ data.drawableCount); |
+ for (int i = 0; i < data.ops.count(); i++) { |
+ if (data.callback && data.callback->abort()) { |
+ return; |
+ } |
+ // This visit call uses the SkRecords::Draw::operator() to call |
+ // methods on the |canvas|, wrapped by methods defined with the |
+ // DRAW() macro. |
+ data.record.visit<void>(data.ops[i], draw); |
+ } |
+ } else { |
+ // Draw all ops. |
+ SkRecords::Draw draw(data.canvas, data.drawablePicts, data.drawables, |
+ data.drawableCount); |
+ for (int i = 0; i < data.record.count(); i++) { |
+ if (data.callback && data.callback->abort()) { |
+ return; |
+ } |
+ // This visit call uses the SkRecords::Draw::operator() to call |
+ // methods on the |canvas|, wrapped by methods defined with the |
+ // DRAW() macro. |
+ data.record.visit<void>(i, draw); |
+ } |
+ } |
+} |
void SkRecordDraw(const SkRecord& record, |
SkCanvas* canvas, |
@@ -17,6 +130,7 @@ void SkRecordDraw(const SkRecord& record, |
const SkBBoxHierarchy* bbh, |
SkPicture::AbortCallback* callback) { |
SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
+ TRACE_EVENT0("pras", "SkRecordDraw"); |
if (bbh) { |
// Draw only ops that affect pixels in the canvas's current clip. |