2013-10-28 19:51:26 +00:00
|
|
|
#include "DMPipeTask.h"
|
|
|
|
#include "DMUtil.h"
|
|
|
|
#include "DMWriteTask.h"
|
|
|
|
|
|
|
|
#include "SamplePipeControllers.h"
|
|
|
|
#include "SkCommandLineFlags.h"
|
|
|
|
#include "SkGPipe.h"
|
|
|
|
|
2013-12-02 13:50:38 +00:00
|
|
|
DEFINE_bool(pipe, true, "If true, check several pipe variants against the reference bitmap.");
|
2013-10-28 19:51:26 +00:00
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2014-05-14 17:55:32 +00:00
|
|
|
static uint32_t get_flags(PipeTask::Mode mode) {
|
2013-10-28 19:51:26 +00:00
|
|
|
uint32_t flags = 0;
|
2014-05-14 17:55:32 +00:00
|
|
|
if (mode != PipeTask::kInProcess_Mode) {
|
2013-10-28 19:51:26 +00:00
|
|
|
flags |= SkGPipeWriter::kCrossProcess_Flag;
|
2014-05-14 17:55:32 +00:00
|
|
|
}
|
|
|
|
if (mode == PipeTask::kSharedAddress_Mode) {
|
|
|
|
flags |= SkGPipeWriter::kSharedAddressSpace_Flag;
|
2013-10-28 19:51:26 +00:00
|
|
|
}
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* get_name(const uint32_t flags) {
|
|
|
|
if (flags & SkGPipeWriter::kCrossProcess_Flag &&
|
|
|
|
flags & SkGPipeWriter::kSharedAddressSpace_Flag) {
|
2014-09-23 16:20:13 +00:00
|
|
|
return "shared-address-space-pipe";
|
2013-10-28 19:51:26 +00:00
|
|
|
} else if (flags & SkGPipeWriter::kCrossProcess_Flag) {
|
2014-09-23 16:20:13 +00:00
|
|
|
return "cross-process-pipe";
|
2013-10-28 19:51:26 +00:00
|
|
|
} else {
|
|
|
|
return "pipe";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PipeTask::PipeTask(const Task& parent,
|
|
|
|
skiagm::GM* gm,
|
|
|
|
SkBitmap reference,
|
2014-05-14 17:55:32 +00:00
|
|
|
Mode mode)
|
2014-02-28 20:31:31 +00:00
|
|
|
: CpuTask(parent)
|
2014-05-14 17:55:32 +00:00
|
|
|
, fFlags(get_flags(mode))
|
2013-10-28 19:51:26 +00:00
|
|
|
, fName(UnderJoin(parent.name().c_str(), get_name(fFlags)))
|
|
|
|
, fGM(gm)
|
|
|
|
, fReference(reference)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void PipeTask::draw() {
|
|
|
|
SkBitmap bitmap;
|
2014-05-15 17:33:31 +00:00
|
|
|
AllocatePixels(fReference, &bitmap);
|
2013-10-28 19:51:26 +00:00
|
|
|
|
|
|
|
SkCanvas canvas(bitmap);
|
|
|
|
PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory);
|
|
|
|
SkGPipeWriter writer;
|
|
|
|
|
|
|
|
SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
|
|
|
|
fFlags,
|
|
|
|
bitmap.width(),
|
|
|
|
bitmap.height());
|
2014-09-11 19:30:12 +00:00
|
|
|
CanvasPreflight(pipeCanvas);
|
2013-10-28 19:51:26 +00:00
|
|
|
pipeCanvas->concat(fGM->getInitialTransform());
|
|
|
|
fGM->draw(pipeCanvas);
|
|
|
|
writer.endRecording();
|
|
|
|
|
|
|
|
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-28 19:51:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PipeTask::shouldSkip() const {
|
|
|
|
if (!FLAGS_pipe) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (fGM->getFlags() & skiagm::GM::kSkipPipe_Flag) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (fFlags == SkGPipeWriter::kCrossProcess_Flag &&
|
|
|
|
fGM->getFlags() & skiagm::GM::kSkipPipeCrossProcess_Flag) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|