2014-02-28 20:31:31 +00:00
|
|
|
#include "DMGpuGMTask.h"
|
2013-10-16 13:02:15 +00:00
|
|
|
#include "DMUtil.h"
|
2013-10-18 20:52:44 +00:00
|
|
|
#include "DMWriteTask.h"
|
2013-10-16 13:02:15 +00:00
|
|
|
#include "SkCommandLineFlags.h"
|
2014-02-16 00:59:25 +00:00
|
|
|
#include "SkSurface.h"
|
2013-10-16 13:02:15 +00:00
|
|
|
#include "SkTLS.h"
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
GpuGMTask::GpuGMTask(const char* config,
|
|
|
|
Reporter* reporter,
|
|
|
|
TaskRunner* taskRunner,
|
|
|
|
skiagm::GMRegistry::Factory gmFactory,
|
|
|
|
GrContextFactory::GLContextType contextType,
|
2014-06-30 13:36:31 +00:00
|
|
|
GrGLStandard gpuAPI,
|
2014-02-28 20:31:31 +00:00
|
|
|
int sampleCount)
|
|
|
|
: GpuTask(reporter, taskRunner)
|
2013-10-16 13:02:15 +00:00
|
|
|
, fGM(gmFactory(NULL))
|
2014-02-26 23:01:57 +00:00
|
|
|
, fName(UnderJoin(fGM->getName(), config))
|
2013-10-16 13:02:15 +00:00
|
|
|
, fContextType(contextType)
|
2014-06-30 13:36:31 +00:00
|
|
|
, fGpuAPI(gpuAPI)
|
2013-10-16 13:02:15 +00:00
|
|
|
, fSampleCount(sampleCount)
|
|
|
|
{}
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
void GpuGMTask::draw(GrContextFactory* grFactory) {
|
2014-02-16 00:59:25 +00:00
|
|
|
SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()),
|
|
|
|
SkScalarCeilToInt(fGM->height()),
|
2014-04-11 17:15:40 +00:00
|
|
|
kN32_SkColorType,
|
2014-02-26 16:31:22 +00:00
|
|
|
kPremul_SkAlphaType);
|
2014-06-30 13:36:31 +00:00
|
|
|
SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuAPI, info,
|
|
|
|
fSampleCount));
|
|
|
|
if (!surface) {
|
|
|
|
this->fail("Could not create context for the config and the api.");
|
|
|
|
return;
|
|
|
|
}
|
2014-02-16 00:59:25 +00:00
|
|
|
SkCanvas* canvas = surface->getCanvas();
|
2014-09-11 19:30:12 +00:00
|
|
|
CanvasPreflight(canvas);
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2014-02-16 00:59:25 +00:00
|
|
|
canvas->concat(fGM->getInitialTransform());
|
|
|
|
fGM->draw(canvas);
|
|
|
|
canvas->flush();
|
2013-10-16 13:02:15 +00:00
|
|
|
|
|
|
|
SkBitmap bitmap;
|
2014-05-30 13:26:10 +00:00
|
|
|
bitmap.setInfo(info);
|
2014-02-16 00:59:25 +00:00
|
|
|
canvas->readPixels(&bitmap, 0, 0);
|
2013-10-16 13:02:15 +00:00
|
|
|
|
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-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
bool GpuGMTask::shouldSkip() const {
|
2014-03-26 21:26:15 +00:00
|
|
|
return kGPUDisabled || SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag);
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|