#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() {
    // Record the GM into an SkRecord.
    EXPERIMENTAL::SkRecording recording(fReference.width(), fReference.height());
    fGM->draw(recording.canvas());
    SkAutoTDelete<const EXPERIMENTAL::SkPlayback> playback(recording.releasePlayback());

    // 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

#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() {
    // 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());

    // 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

Apply initial transform in --skr mode.
DM: Apply initial transform in --skr mode.

BUG=skia:2378
R=reed@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/263853005

git-svn-id: e8541e15acce502a64c929015570ad1648e548cd@14521 2bbb7eff-a529-9590-31e7-b0007b416f81
