d9ce2be6b2
- Adds tests for SkRecordDraw's two main features: cull- and clip- based skipping. - Adds full SkCanvas semantic mode to SkRecorder, so it can be used as a target for SkRecordDraw. BUG=skia:2378 R=fmalita@chromium.org, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/231653002 git-svn-id: http://skia.googlecode.com/svn/trunk@14124 2bbb7eff-a529-9590-31e7-b0007b416f81
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#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(SkRecorder::kWriteOnly_Mode, &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);
|
|
|
|
SkRecordDraw(record, &target);
|
|
|
|
if (!BitmapsEqual(bitmap, fReference)) {
|
|
this->fail();
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
|
|
}
|
|
}
|
|
|
|
bool RecordTask::shouldSkip() const {
|
|
return !FLAGS_skr;
|
|
}
|
|
|
|
} // namespace DM
|