2013-10-21 18:40:25 +00:00
|
|
|
#include "DMSerializeTask.h"
|
|
|
|
#include "DMUtil.h"
|
|
|
|
#include "DMWriteTask.h"
|
|
|
|
|
|
|
|
#include "SkCommandLineFlags.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkPixelRef.h"
|
|
|
|
|
2014-09-29 15:44:46 +00:00
|
|
|
DEFINE_bool(serialize, true, "If true, run picture serialization tests via SkPictureData.");
|
2013-10-21 18:40:25 +00:00
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2014-09-29 15:44:46 +00:00
|
|
|
SerializeTask::SerializeTask(const Task& parent, skiagm::GM* gm, SkBitmap reference)
|
2014-02-28 20:31:31 +00:00
|
|
|
: CpuTask(parent)
|
2014-09-29 15:44:46 +00:00
|
|
|
, fName(UnderJoin(parent.name().c_str(), "serialize"))
|
2013-10-21 18:40:25 +00:00
|
|
|
, fGM(gm)
|
|
|
|
, fReference(reference)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void SerializeTask::draw() {
|
2014-09-29 15:44:46 +00:00
|
|
|
SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), NULL/*no BBH*/));
|
2013-10-21 18:40:25 +00:00
|
|
|
|
|
|
|
SkDynamicMemoryWStream wStream;
|
2014-04-13 19:09:42 +00:00
|
|
|
recorded->serialize(&wStream, NULL);
|
2013-10-21 18:40:25 +00:00
|
|
|
SkAutoTUnref<SkStream> rStream(wStream.detachAsStream());
|
|
|
|
SkAutoTUnref<SkPicture> reconstructed(SkPicture::CreateFromStream(rStream));
|
|
|
|
|
|
|
|
SkBitmap bitmap;
|
2014-05-15 17:33:31 +00:00
|
|
|
AllocatePixels(fReference, &bitmap);
|
2014-06-24 19:28:34 +00:00
|
|
|
DrawPicture(*reconstructed, &bitmap);
|
2013-10-21 18:40:25 +00:00
|
|
|
if (!BitmapsEqual(bitmap, fReference)) {
|
|
|
|
this->fail();
|
Update DM JSON format.
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
2014-09-09 14:59:46 +00:00
|
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
|
2013-10-21 18:40:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SerializeTask::shouldSkip() const {
|
2014-06-24 19:28:34 +00:00
|
|
|
if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) {
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-29 15:44:46 +00:00
|
|
|
return !FLAGS_serialize;
|
2013-10-21 18:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|