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
|
|
|
|
2014-05-02 20:51:13 +00:00
|
|
|
DEFINE_bool(skr, false, "If true, run SKR tests.");
|
2014-04-01 16:24:06 +00:00
|
|
|
|
|
|
|
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.
|
2014-04-24 15:22:55 +00:00
|
|
|
EXPERIMENTAL::SkRecording recording(fReference.width(), fReference.height());
|
2014-05-01 21:06:39 +00:00
|
|
|
recording.canvas()->concat(fGM->getInitialTransform());
|
2014-04-24 15:22:55 +00:00
|
|
|
fGM->draw(recording.canvas());
|
|
|
|
SkAutoTDelete<const EXPERIMENTAL::SkPlayback> playback(recording.releasePlayback());
|
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
|