Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: src/record/SkRecordDraw.cpp

Issue 229523002: SkRecord: make culling work if SkRecordAnnotateCullingPairs is called. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/record/SkRecordDraw.h ('k') | src/record/SkRecorder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ }
+}
+
+
« no previous file with comments | « src/record/SkRecordDraw.h ('k') | src/record/SkRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698