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

Unified Diff: src/record/SkRecordDraw.cpp

Issue 272723007: Add timing to dump_record. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: always walk with fDraw Created 6 years, 7 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') | tools/dump_record.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.cpp b/src/record/SkRecordDraw.cpp
index 666cfc9000e5ce37abdfd1fa99e76c5274523e00..324946e5d7a218364d3305b46606e5db652f01a3 100644
--- a/src/record/SkRecordDraw.cpp
+++ b/src/record/SkRecordDraw.cpp
@@ -7,52 +7,30 @@
#include "SkRecordDraw.h"
-namespace {
-
-// This is an SkRecord visitor that will draw that SkRecord to an SkCanvas.
-class Draw : SkNoncopyable {
-public:
- explicit Draw(SkCanvas* canvas) : fCanvas(canvas), fIndex(0) {}
-
- unsigned index() const { return fIndex; }
- void next() { ++fIndex; }
-
- template <typename T> void operator()(const T& r) {
- if (!this->skip(r)) {
- this->draw(r);
- }
+void SkRecordDraw(const SkRecord& record, SkCanvas* canvas) {
+ for (SkRecords::Draw draw(canvas); draw.index() < record.count(); draw.next()) {
+ record.visit<void>(draw.index(), draw);
}
+}
-private:
- // No base case, so we'll be compile-time checked that we implemented all possibilities below.
- template <typename T> void draw(const T&);
-
- // skip() should return true if we can skip this command, false if not.
- // It may update fIndex directly to skip more than just this one command.
-
- // Mostly we just blindly call fCanvas and let it handle quick rejects itself.
- template <typename T> bool skip(const T&) { return false; }
+namespace SkRecords {
- // We add our own quick rejects for commands added by optimizations.
- bool skip(const SkRecords::PairedPushCull& r) {
- if (fCanvas->quickReject(r.base->rect)) {
- fIndex += r.skip;
- return true;
- }
- return false;
- }
- bool skip(const SkRecords::BoundedDrawPosTextH& r) {
- return fCanvas->quickRejectY(r.minY, r.maxY);
+bool Draw::skip(const PairedPushCull& r) {
+ if (fCanvas->quickReject(r.base->rect)) {
+ fIndex += r.skip;
+ return true;
}
+ return false;
+}
- SkCanvas* fCanvas;
- unsigned fIndex;
-};
+bool Draw::skip(const BoundedDrawPosTextH& r) {
+ return fCanvas->quickRejectY(r.minY, r.maxY);
+}
// NoOps draw nothing.
-template <> void Draw::draw(const SkRecords::NoOp&) {}
+template <> void Draw::draw(const NoOp&) {}
-#define DRAW(T, call) template <> void Draw::draw(const SkRecords::T& r) { fCanvas->call; }
+#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
DRAW(Restore, restore());
DRAW(Save, save(r.flags));
DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
@@ -87,13 +65,7 @@ DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.co
r.xmode.get(), r.indices, r.indexCount, r.paint));
#undef DRAW
-template <> void Draw::draw(const SkRecords::PairedPushCull& r) { this->draw(*r.base); }
-template <> void Draw::draw(const SkRecords::BoundedDrawPosTextH& r) { this->draw(*r.base); }
-
-} // namespace
+template <> void Draw::draw(const PairedPushCull& r) { this->draw(*r.base); }
+template <> void Draw::draw(const BoundedDrawPosTextH& r) { this->draw(*r.base); }
-void SkRecordDraw(const SkRecord& record, SkCanvas* canvas) {
- for (Draw draw(canvas); draw.index() < record.count(); draw.next()) {
- record.visit<void>(draw.index(), draw);
- }
-}
+} // namespace SkRecords
« no previous file with comments | « src/record/SkRecordDraw.h ('k') | tools/dump_record.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698