зеркало из https://github.com/mozilla/moz-skia.git
DM: test SkRecord with and without optimization.
BUG=skia:2378 R=fmalita@chromium.org, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/271443007 git-svn-id: http://skia.googlecode.com/svn/trunk@14598 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
901c43c26f
Коммит
93043bc252
|
@ -40,7 +40,8 @@ void CpuGMTask::draw() {
|
|||
SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, false);
|
||||
SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, true);
|
||||
SPAWN(QuiltTask, fGMFactory(NULL), bitmap);
|
||||
SPAWN(RecordTask, fGMFactory(NULL), bitmap);
|
||||
SPAWN(RecordTask, fGMFactory(NULL), bitmap, true);
|
||||
SPAWN(RecordTask, fGMFactory(NULL), bitmap, false);
|
||||
SPAWN(ReplayTask, fGMFactory(NULL), bitmap, false);
|
||||
SPAWN(ReplayTask, fGMFactory(NULL), bitmap, true);
|
||||
SPAWN(SerializeTask, fGMFactory(NULL), bitmap);
|
||||
|
|
|
@ -2,31 +2,40 @@
|
|||
#include "DMUtil.h"
|
||||
#include "DMWriteTask.h"
|
||||
#include "SkCommandLineFlags.h"
|
||||
#include "SkRecording.h"
|
||||
#include "SkRecord.h"
|
||||
#include "SkRecordDraw.h"
|
||||
#include "SkRecordOpts.h"
|
||||
#include "SkRecorder.h"
|
||||
|
||||
DEFINE_bool(skr, true, "If true, run SKR tests.");
|
||||
|
||||
namespace DM {
|
||||
|
||||
RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference)
|
||||
RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference, bool optimize)
|
||||
: CpuTask(parent)
|
||||
, fName(UnderJoin(parent.name().c_str(), "skr"))
|
||||
, fName(UnderJoin(parent.name().c_str(), optimize ? "skr" : "skr-noopt"))
|
||||
, fGM(gm)
|
||||
, fReference(reference)
|
||||
, fOptimize(optimize)
|
||||
{}
|
||||
|
||||
void RecordTask::draw() {
|
||||
// Record the GM into an SkRecord.
|
||||
EXPERIMENTAL::SkRecording recording(fReference.width(), fReference.height());
|
||||
recording.canvas()->concat(fGM->getInitialTransform());
|
||||
fGM->draw(recording.canvas());
|
||||
SkAutoTDelete<const EXPERIMENTAL::SkPlayback> playback(recording.releasePlayback());
|
||||
SkRecord record;
|
||||
SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record,
|
||||
fReference.width(), fReference.height());
|
||||
recorder.concat(fGM->getInitialTransform());
|
||||
fGM->draw(&recorder);
|
||||
|
||||
if (fOptimize) {
|
||||
SkRecordOptimize(&record);
|
||||
}
|
||||
|
||||
// Draw the SkRecord back into a bitmap.
|
||||
SkBitmap bitmap;
|
||||
SetupBitmap(fReference.colorType(), fGM.get(), &bitmap);
|
||||
SkCanvas target(bitmap);
|
||||
playback->draw(&target);
|
||||
SkRecordDraw(record, &target);
|
||||
|
||||
if (!BitmapsEqual(bitmap, fReference)) {
|
||||
this->fail();
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace DM {
|
|||
class RecordTask : public CpuTask {
|
||||
|
||||
public:
|
||||
RecordTask(const Task& parent, skiagm::GM*, SkBitmap reference);
|
||||
RecordTask(const Task& parent, skiagm::GM*, SkBitmap reference, bool optimize);
|
||||
|
||||
virtual void draw() SK_OVERRIDE;
|
||||
virtual bool shouldSkip() const SK_OVERRIDE;
|
||||
|
@ -24,6 +24,7 @@ private:
|
|||
const SkString fName;
|
||||
SkAutoTDelete<skiagm::GM> fGM;
|
||||
const SkBitmap fReference;
|
||||
bool fOptimize;
|
||||
};
|
||||
|
||||
} // namespace DM
|
||||
|
|
Загрузка…
Ссылка в новой задаче