2014-04-01 16:24:06 +00:00
|
|
|
#include "DMRecordTask.h"
|
|
|
|
#include "DMUtil.h"
|
|
|
|
#include "DMWriteTask.h"
|
|
|
|
#include "SkCommandLineFlags.h"
|
2014-04-14 20:33:05 +00:00
|
|
|
#include "SkRecording.h"
|
2014-04-01 16:24:06 +00:00
|
|
|
|
|
|
|
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() {
|
2014-04-14 20:33:05 +00:00
|
|
|
using EXPERIMENTAL::SkRecording;
|
|
|
|
using EXPERIMENTAL::SkPlayback;
|
|
|
|
|
2014-04-01 16:24:06 +00:00
|
|
|
// Record the GM into an SkRecord.
|
2014-04-14 20:33:05 +00:00
|
|
|
SkRecording* recording = SkRecording::Create(fReference.width(), fReference.height());
|
|
|
|
fGM->draw(recording->canvas());
|
|
|
|
SkAutoTDelete<const SkPlayback> playback(SkRecording::Delete(recording));
|
2014-04-01 16:24:06 +00:00
|
|
|
|
|
|
|
// Draw the SkRecord back into a bitmap.
|
|
|
|
SkBitmap bitmap;
|
|
|
|
SetupBitmap(fReference.colorType(), fGM.get(), &bitmap);
|
|
|
|
SkCanvas target(bitmap);
|
2014-04-14 20:33:05 +00:00
|
|
|
playback->draw(&target);
|
2014-04-01 16:24:06 +00:00
|
|
|
|
|
|
|
if (!BitmapsEqual(bitmap, fReference)) {
|
|
|
|
this->fail();
|
|
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RecordTask::shouldSkip() const {
|
|
|
|
return !FLAGS_skr;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|