ea65bfa8de
Ex. dm --match patch -w bad --key arch x86 gpu nvidia model z620 --properties git_hash abcd build_number 20 -> { "build_number" : "20", "git_hash" : "abcd", "key" : { "arch" : "x86", "gpu" : "nvidia", "model" : "z620" }, "results" : [ { "key" : { "config" : "565", "name" : "ninepatch-stretch" }, "md5" : "f78cfafcbabaf815f3dfcf61fb59acc7", "options" : { "source_type" : "GM" } }, { "key" : { "config" : "8888", "name" : "ninepatch-stretch" }, "md5" : "3e8a42f35a1e76f00caa191e6310d789", "options" : { "source_type" : "GM" } }, ... This breaks -r, but that's okay. Going to follow up this CL with one that removes that entirely. BUG=skia: R=stephana@google.com, jcgregorio@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/551873003
54 lines
1.6 KiB
C++
54 lines
1.6 KiB
C++
#include "DMSerializeTask.h"
|
|
#include "DMUtil.h"
|
|
#include "DMWriteTask.h"
|
|
|
|
#include "SkCommandLineFlags.h"
|
|
#include "SkPicture.h"
|
|
#include "SkPixelRef.h"
|
|
|
|
DEFINE_bool(serialize, true, "If true, run picture serialization tests via SkPictureData.");
|
|
DEFINE_bool(serialize_skr, true, "If true, run picture serialization tests via SkRecord.");
|
|
|
|
static const char* kSuffixes[] = { "serialize", "serialize_skr" };
|
|
static const bool* kEnabled[] = { &FLAGS_serialize, &FLAGS_serialize_skr };
|
|
|
|
namespace DM {
|
|
|
|
SerializeTask::SerializeTask(const Task& parent,
|
|
skiagm::GM* gm,
|
|
SkBitmap reference,
|
|
SerializeTask::Mode mode)
|
|
: CpuTask(parent)
|
|
, fMode(mode)
|
|
, fName(UnderJoin(parent.name().c_str(), kSuffixes[mode]))
|
|
, fGM(gm)
|
|
, fReference(reference)
|
|
{}
|
|
|
|
void SerializeTask::draw() {
|
|
SkAutoTUnref<SkPicture> recorded(
|
|
RecordPicture(fGM.get(), NULL/*no BBH*/, kSkRecord_Mode == fMode));
|
|
|
|
SkDynamicMemoryWStream wStream;
|
|
recorded->serialize(&wStream, NULL);
|
|
SkAutoTUnref<SkStream> rStream(wStream.detachAsStream());
|
|
SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream));
|
|
|
|
SkBitmap bitmap;
|
|
AllocatePixels(fReference, &bitmap);
|
|
DrawPicture(*reconstructed, &bitmap);
|
|
if (!BitmapsEqual(bitmap, fReference)) {
|
|
this->fail();
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
|
|
}
|
|
}
|
|
|
|
bool SerializeTask::shouldSkip() const {
|
|
if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
|
|
return true;
|
|
}
|
|
return !*kEnabled[fMode];
|
|
}
|
|
|
|
} // namespace DM
|