b17a24fedb
Also, switch Skia internal tools over to use the public headers where possible. Where it's not, the tools -Isrc/record explicitly now, and if it's not obvious, note why they don't use SkRecording.h. BUG=skia:2378 R=reed@google.com, mtklein@google.com, fmalita@chromium.org Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/231853006 git-svn-id: http://skia.googlecode.com/svn/trunk@14191 2bbb7eff-a529-9590-31e7-b0007b416f81
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include "DMRecordTask.h"
|
|
#include "DMUtil.h"
|
|
#include "DMWriteTask.h"
|
|
#include "SkCommandLineFlags.h"
|
|
#include "SkRecording.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() {
|
|
using EXPERIMENTAL::SkRecording;
|
|
using EXPERIMENTAL::SkPlayback;
|
|
|
|
// Record the GM into an SkRecord.
|
|
SkRecording* recording = SkRecording::Create(fReference.width(), fReference.height());
|
|
fGM->draw(recording->canvas());
|
|
SkAutoTDelete<const SkPlayback> playback(SkRecording::Delete(recording));
|
|
|
|
// Draw the SkRecord back into a bitmap.
|
|
SkBitmap bitmap;
|
|
SetupBitmap(fReference.colorType(), fGM.get(), &bitmap);
|
|
SkCanvas target(bitmap);
|
|
playback->draw(&target);
|
|
|
|
if (!BitmapsEqual(bitmap, fReference)) {
|
|
this->fail();
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
|
|
}
|
|
}
|
|
|
|
bool RecordTask::shouldSkip() const {
|
|
return !FLAGS_skr;
|
|
}
|
|
|
|
} // namespace DM
|