aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/record
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-09 14:59:29 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-09 14:59:29 +0000
commit27f6b0d013572184dc980462cce8d0f3caec1c8e (patch)
treeba9e30a32cfae5f3241047e30523ec674da193cb /src/record
parent36b3d34ef2a1c1fc7a88420c8d3856335f99e95d (diff)
Add timing to dump_record.
Prints microsecond timing for each command in the left-hand column: optimized flat/http___mobile_news_sandbox_google_com_news_pt0_scroll_layer_7.skp 4.0 1 Save 2075.0 2 DrawRect 104.0 3 BoundedDrawPosTextH 135.4 4 DrawRect 9.4 5 DrawRect 5.6 6 DrawRect 8.2 7 DrawRect 6.8 8 DrawRect ... (I'm sure Rietveld will just mangle the crap out of that. It's helpfully right-aligned.) To do this, I made Draw from SkRecordDraw Skia-public as SkRecords::Draw, and time it command-by-command. BUG=skia:2378 R=fmalita@chromium.org, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/272723007 git-svn-id: http://skia.googlecode.com/svn/trunk@14672 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/record')
-rw-r--r--src/record/SkRecordDraw.cpp66
-rw-r--r--src/record/SkRecordDraw.h38
2 files changed, 56 insertions, 48 deletions
diff --git a/src/record/SkRecordDraw.cpp b/src/record/SkRecordDraw.cpp
index 666cfc9000..324946e5d7 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
diff --git a/src/record/SkRecordDraw.h b/src/record/SkRecordDraw.h
index 8bf0e6694a..4ec6e68e92 100644
--- a/src/record/SkRecordDraw.h
+++ b/src/record/SkRecordDraw.h
@@ -11,7 +11,43 @@
#include "SkRecord.h"
#include "SkCanvas.h"
-// Draw an SkRecord into an SkCanvas.
+// Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::Draw.
void SkRecordDraw(const SkRecord&, SkCanvas*);
+namespace SkRecords {
+
+// 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);
+ }
+ }
+
+private:
+ // No base case, so we'll be compile-time checked that we implement all possibilities.
+ 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; }
+
+ // We add our own quick rejects for commands added by optimizations.
+ bool skip(const PairedPushCull&);
+ bool skip(const BoundedDrawPosTextH&);
+
+ SkCanvas* fCanvas;
+ unsigned fIndex;
+};
+
+} // namespace SkRecords
+
#endif//SkRecordDraw_DEFINED