diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-01 16:24:06 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-01 16:24:06 +0000 |
commit | e3ff558a4baf4cb924e7513a81c8073ddae385fc (patch) | |
tree | 245339b6d7d39e36212bbbe6b975fcfd802f0ff5 /dm | |
parent | d48ad8e33307ad651264a3c3068b4468201fccf6 (diff) | |
download | skia-e3ff558a4baf4cb924e7513a81c8073ddae385fc.tar.gz |
SkRecord strawman
Record performance as measured by bench_record (out/Release/bench_record --skr) improves by at least 1.9x, at most 6.7x, arithmetic mean 2.6x, geometric mean 3.0x. So, good.
Correctness as measured by DM (out/Debug/dm --skr) is ~ok. One GM (shadertext2) fails because we're assuming all paint effects are immutable, but SkShaders are still mutable.
To do after this CL:
- measure playback speed
- catch up feature-wise to SkPicture
- match today's playback speed
BUG=skia:
R=robertphillips@google.com, bsalomon@google.com, reed@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/206313003
git-svn-id: http://skia.googlecode.com/svn/trunk@14010 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DMCpuGMTask.cpp | 2 | ||||
-rw-r--r-- | dm/DMRecordTask.cpp | 42 | ||||
-rw-r--r-- | dm/DMRecordTask.h | 31 |
3 files changed, 75 insertions, 0 deletions
diff --git a/dm/DMCpuGMTask.cpp b/dm/DMCpuGMTask.cpp index 6ab0014fd5..7ab1d44ee5 100644 --- a/dm/DMCpuGMTask.cpp +++ b/dm/DMCpuGMTask.cpp @@ -1,6 +1,7 @@ #include "DMCpuGMTask.h" #include "DMExpectationsTask.h" #include "DMPipeTask.h" +#include "DMRecordTask.h" #include "DMReplayTask.h" #include "DMSerializeTask.h" #include "DMTileGridTask.h" @@ -38,6 +39,7 @@ void CpuGMTask::draw() { SPAWN(PipeTask, fGMFactory(NULL), bitmap, false, false); SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, false); SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, true); + SPAWN(RecordTask, fGMFactory(NULL), bitmap); SPAWN(ReplayTask, fGMFactory(NULL), bitmap, false); SPAWN(ReplayTask, fGMFactory(NULL), bitmap, true); SPAWN(SerializeTask, fGMFactory(NULL), bitmap); diff --git a/dm/DMRecordTask.cpp b/dm/DMRecordTask.cpp new file mode 100644 index 0000000000..0109a41d8f --- /dev/null +++ b/dm/DMRecordTask.cpp @@ -0,0 +1,42 @@ +#include "DMRecordTask.h" +#include "DMUtil.h" +#include "DMWriteTask.h" +#include "SkCommandLineFlags.h" +#include "SkRecordDraw.h" +#include "SkRecorder.h" + +DEFINE_bool(skr, false, "If true, run SKR tests."); + +namespace DM { + +RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference) + : CpuTask(parent) + , fName(UnderJoin(parent.name().c_str(), "skr")) + , fGM(gm) + , fReference(reference) + {} + +void RecordTask::draw() { + // Record the GM into an SkRecord. + SkRecord record; + SkRecorder canvas(&record, fReference.width(), fReference.height()); + canvas.concat(fGM->getInitialTransform()); + fGM->draw(&canvas); + + // Draw the SkRecord back into a bitmap. + SkBitmap bitmap; + SetupBitmap(fReference.colorType(), fGM.get(), &bitmap); + SkCanvas target(bitmap); + record.visit(SkRecordDraw(&target)); + + if (!BitmapsEqual(bitmap, fReference)) { + this->fail(); + this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); + } +} + +bool RecordTask::shouldSkip() const { + return !FLAGS_skr; +} + +} // namespace DM diff --git a/dm/DMRecordTask.h b/dm/DMRecordTask.h new file mode 100644 index 0000000000..7efd951e0f --- /dev/null +++ b/dm/DMRecordTask.h @@ -0,0 +1,31 @@ +#ifndef DMRecordTask_DEFINED +#define DMRecordTask_DEFINED + +#include "DMTask.h" +#include "SkBitmap.h" +#include "SkString.h" +#include "SkTemplates.h" +#include "gm.h" + +// Records a GM through an SkRecord, draws it, and compares against the reference bitmap. + +namespace DM { + +class RecordTask : public CpuTask { + +public: + RecordTask(const Task& parent, skiagm::GM*, SkBitmap reference); + + virtual void draw() SK_OVERRIDE; + virtual bool shouldSkip() const SK_OVERRIDE; + virtual SkString name() const SK_OVERRIDE { return fName; } + +private: + const SkString fName; + SkAutoTDelete<skiagm::GM> fGM; + const SkBitmap fReference; +}; + +} // namespace DM + +#endif // DMRecordTask_DEFINED |