Index: src/record/SkRecordDraw.cpp |
diff --git a/src/record/SkRecordDraw.h b/src/record/SkRecordDraw.cpp |
similarity index 72% |
copy from src/record/SkRecordDraw.h |
copy to src/record/SkRecordDraw.cpp |
index 042147df997082c4982403458e8ec6179497566c..66b48a35593e9ad37abc7dd87dd66f2d7fa8aa2c 100644 |
--- a/src/record/SkRecordDraw.h |
+++ b/src/record/SkRecordDraw.cpp |
@@ -1,31 +1,34 @@ |
-#ifndef SkRecordDraw_DEFINED |
-#define SkRecordDraw_DEFINED |
+#include "SkRecordDraw.h" |
-#include "SkRecord.h" |
-#include "SkRecords.h" |
-#include "SkCanvas.h" |
+namespace { |
// This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. |
- |
-struct SkRecordDraw { |
- explicit SkRecordDraw(SkCanvas* canvas) : canvas(canvas) {} |
+struct Draw { |
+ unsigned index; |
+ SkCanvas* canvas; |
// No base case, so we'll be compile-time checked that we implemented all possibilities below. |
- template <typename T> void operator()(const T& record); |
- |
- SkCanvas* canvas; |
+ template <typename T> void operator()(const T&); |
}; |
-// Nothing fancy here. |
-// The structs in SkRecord are completely isomorphic to their corresponding SkCanvas calls. |
+template <> void Draw::operator()(const SkRecords::PushCull& pushCull) { |
+ if (pushCull.popOffset != SkRecords::kUnsetPopOffset && |
+ canvas->quickReject(pushCull.rect)) { |
+ // We skip to the popCull, then the loop moves us just beyond it. |
+ index += pushCull.popOffset; |
+ } else { |
+ canvas->pushCull(pushCull.rect); |
+ } |
+} |
+ |
+// Nothing fancy below here. |
-#define CASE(T) template <> void SkRecordDraw::operator()(const SkRecords::T& r) |
+#define CASE(T) template <> void Draw::operator()(const SkRecords::T& r) |
CASE(Restore) { canvas->restore(); } |
CASE(Save) { canvas->save(r.flags); } |
CASE(SaveLayer) { canvas->saveLayer(r.bounds, r.paint, r.flags); } |
-CASE(PushCull) { canvas->pushCull(r.rect); } |
CASE(PopCull) { canvas->popCull(); } |
CASE(Concat) { canvas->concat(r.matrix); } |
@@ -59,7 +62,17 @@ CASE(DrawVertices) { |
canvas->drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors, |
r.xmode.get(), r.indices, r.indexCount, r.paint); |
} |
- |
#undef CASE |
-#endif//SkRecordDraw_DEFINED |
+} // namespace |
+ |
+void SkRecordDraw(const SkRecord& record, SkCanvas* canvas) { |
+ Draw draw; |
+ draw.canvas = canvas; |
+ |
+ for (draw.index = 0; draw.index < record.count(); draw.index++) { |
+ record.visit(draw.index, draw); |
+ } |
+} |
+ |
+ |