diff options
author | mtklein <mtklein@chromium.org> | 2014-09-09 07:36:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-09 07:36:57 -0700 |
commit | 197ceda92966359962c51923a01dd2b0018b080f (patch) | |
tree | 3ac45faf60baccb5033d557edc977098f5be7c8f /dm | |
parent | 49e3199e638595d7e8b8bf41081eb9cac5daaa2d (diff) |
Remove expectations / -r from DM entirely.
It's getting tricky to coordinate changes to output for bots with -r,
and -r is not widely used. The suggested alternative is to run skdiff.
BUG=skia:
R=jcgregorio@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/553583004
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DM.cpp | 46 | ||||
-rw-r--r-- | dm/DMCpuGMTask.cpp | 5 | ||||
-rw-r--r-- | dm/DMCpuGMTask.h | 3 | ||||
-rw-r--r-- | dm/DMExpectations.h | 19 | ||||
-rw-r--r-- | dm/DMExpectationsTask.cpp | 21 | ||||
-rw-r--r-- | dm/DMExpectationsTask.h | 29 | ||||
-rw-r--r-- | dm/DMGpuGMTask.cpp | 4 | ||||
-rw-r--r-- | dm/DMGpuGMTask.h | 3 | ||||
-rw-r--r-- | dm/DMPDFRasterizeTask.cpp | 1 | ||||
-rw-r--r-- | dm/DMPDFTask.h | 1 | ||||
-rw-r--r-- | dm/DMSKPTask.cpp | 4 | ||||
-rw-r--r-- | dm/DMSKPTask.h | 4 | ||||
-rw-r--r-- | dm/DMUtil.h | 2 | ||||
-rw-r--r-- | dm/DMWriteTask.cpp | 43 | ||||
-rw-r--r-- | dm/DMWriteTask.h | 11 |
15 files changed, 18 insertions, 178 deletions
@@ -43,11 +43,6 @@ using skiatest::TestRegistry; static const char kGpuAPINameGL[] = "gl"; static const char kGpuAPINameGLES[] = "gles"; -DEFINE_string2(expectations, r, "", - "If a directory, compare generated images against images under this path. " - "If a file, compare generated images against JSON expectations at this path." -); - DEFINE_bool(gms, true, "Run GMs?"); DEFINE_bool(tests, true, "Run tests?"); DEFINE_bool(reportUsedChars, false, "Output test font construction data to be pasted into" @@ -77,7 +72,6 @@ static const GrContextFactory::GLContextType mesa = GrContextFactory::kMESA_GL static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms, const SkTArray<SkString>& configs, GrGLStandard gpuAPI, - const DM::Expectations& expectations, DM::Reporter* reporter, DM::TaskRunner* tasks) { #define START(name, type, ...) \ @@ -87,20 +81,20 @@ static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms, for (int i = 0; i < gms.count(); i++) { for (int j = 0; j < configs.count(); j++) { - START("565", CpuGMTask, expectations, kRGB_565_SkColorType); - START("8888", CpuGMTask, expectations, kN32_SkColorType); - START("gpu", GpuGMTask, expectations, native, gpuAPI, 0); - START("msaa4", GpuGMTask, expectations, native, gpuAPI, 4); - START("msaa16", GpuGMTask, expectations, native, gpuAPI, 16); - START("nvprmsaa4", GpuGMTask, expectations, nvpr, gpuAPI, 4); - START("nvprmsaa16", GpuGMTask, expectations, nvpr, gpuAPI, 16); - START("gpunull", GpuGMTask, expectations, null, gpuAPI, 0); - START("gpudebug", GpuGMTask, expectations, debug, gpuAPI, 0); + START("565", CpuGMTask, kRGB_565_SkColorType); + START("8888", CpuGMTask, kN32_SkColorType); + START("gpu", GpuGMTask, native, gpuAPI, 0); + START("msaa4", GpuGMTask, native, gpuAPI, 4); + START("msaa16", GpuGMTask, native, gpuAPI, 16); + START("nvprmsaa4", GpuGMTask, nvpr, gpuAPI, 4); + START("nvprmsaa16", GpuGMTask, nvpr, gpuAPI, 16); + START("gpunull", GpuGMTask, null, gpuAPI, 0); + START("gpudebug", GpuGMTask, debug, gpuAPI, 0); #if SK_ANGLE - START("angle", GpuGMTask, expectations, angle, gpuAPI, 0); + START("angle", GpuGMTask, angle, gpuAPI, 0); #endif #if SK_MESA - START("mesa", GpuGMTask, expectations, mesa, gpuAPI, 0); + START("mesa", GpuGMTask, mesa, gpuAPI, 0); #endif START("pdf", PDFTask, RASTERIZE_PDF_PROC); } @@ -136,7 +130,6 @@ static void find_skps(SkTArray<SkString>* skps) { } static void kick_off_skps(const SkTArray<SkString>& skps, - const DM::Expectations& expectations, DM::Reporter* reporter, DM::TaskRunner* tasks) { for (int i = 0; i < skps.count(); ++i) { @@ -153,9 +146,8 @@ static void kick_off_skps(const SkTArray<SkString>& skps, } SkString filename = SkOSPath::Basename(skps[i].c_str()); - tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, expectations, pic, filename))); - tasks->add(SkNEW_ARGS(DM::PDFTask, (reporter, tasks, pic, filename, - RASTERIZE_PDF_PROC))); + tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, pic, filename))); + tasks->add(SkNEW_ARGS(DM::PDFTask, (reporter, tasks, pic, filename, RASTERIZE_PDF_PROC))); } } @@ -211,14 +203,6 @@ int dm_main() { GrGLStandard gpuAPI = get_gl_standard(); - SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::Expectations)); - if (FLAGS_expectations.count() > 0) { - expectations.reset(DM::WriteTask::Expectations::Create(FLAGS_expectations[0])); - if (!expectations.get()) { - return 1; - } - } - SkTDArray<GMRegistry::Factory> gms; if (FLAGS_gms) { append_matching_factories<GM>(GMRegistry::Head(), &gms); @@ -238,8 +222,8 @@ int dm_main() { DM::TaskRunner tasks; kick_off_tests(tests, &reporter, &tasks); - kick_off_gms(gms, configs, gpuAPI, *expectations, &reporter, &tasks); - kick_off_skps(skps, *expectations, &reporter, &tasks); + kick_off_gms(gms, configs, gpuAPI, &reporter, &tasks); + kick_off_skps(skps, &reporter, &tasks); tasks.wait(); DM::WriteTask::DumpJson(); diff --git a/dm/DMCpuGMTask.cpp b/dm/DMCpuGMTask.cpp index e3dd0eaf98..da650c454b 100644 --- a/dm/DMCpuGMTask.cpp +++ b/dm/DMCpuGMTask.cpp @@ -1,5 +1,4 @@ #include "DMCpuGMTask.h" -#include "DMExpectationsTask.h" #include "DMPipeTask.h" #include "DMQuiltTask.h" #include "DMSerializeTask.h" @@ -12,13 +11,11 @@ CpuGMTask::CpuGMTask(const char* config, Reporter* reporter, TaskRunner* taskRunner, skiagm::GMRegistry::Factory gmFactory, - const Expectations& expectations, SkColorType colorType) : CpuTask(reporter, taskRunner) , fGMFactory(gmFactory) , fGM(fGMFactory(NULL)) , fName(UnderJoin(fGM->getName(), config)) - , fExpectations(expectations) , fColorType(colorType) {} @@ -32,8 +29,6 @@ void CpuGMTask::draw() { canvas.flush(); #define SPAWN(ChildTask, ...) this->spawnChild(SkNEW_ARGS(ChildTask, (*this, __VA_ARGS__))) - SPAWN(ExpectationsTask, fExpectations, bm); - SPAWN(PipeTask, fGMFactory(NULL), bm, PipeTask::kInProcess_Mode); SPAWN(PipeTask, fGMFactory(NULL), bm, PipeTask::kCrossProcess_Mode); SPAWN(PipeTask, fGMFactory(NULL), bm, PipeTask::kSharedAddress_Mode); diff --git a/dm/DMCpuGMTask.h b/dm/DMCpuGMTask.h index 968dd27c25..301cfd3864 100644 --- a/dm/DMCpuGMTask.h +++ b/dm/DMCpuGMTask.h @@ -1,7 +1,6 @@ #ifndef DMCpuGMTask_DEFINED #define DMCpuGMTask_DEFINED -#include "DMExpectations.h" #include "DMReporter.h" #include "DMTask.h" #include "DMTaskRunner.h" @@ -21,7 +20,6 @@ public: Reporter*, TaskRunner*, skiagm::GMRegistry::Factory, - const Expectations&, SkColorType); virtual void draw() SK_OVERRIDE; @@ -32,7 +30,6 @@ private: skiagm::GMRegistry::Factory fGMFactory; SkAutoTDelete<skiagm::GM> fGM; const SkString fName; - const Expectations& fExpectations; const SkColorType fColorType; }; diff --git a/dm/DMExpectations.h b/dm/DMExpectations.h deleted file mode 100644 index 7993a55be9..0000000000 --- a/dm/DMExpectations.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef DMExpectations_DEFINED -#define DMExpectations_DEFINED - -#include "DMTask.h" - -namespace DM { - -struct Expectations { - virtual ~Expectations() {} - - // Return true if bitmap is the correct output for task, else false. - virtual bool check(const Task& task, SkBitmap bitmap) const { - return true; - } -}; - -} // namespace DM - -#endif // DMExpectations_DEFINED diff --git a/dm/DMExpectationsTask.cpp b/dm/DMExpectationsTask.cpp deleted file mode 100644 index e29257afbd..0000000000 --- a/dm/DMExpectationsTask.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "DMExpectationsTask.h" -#include "DMUtil.h" - -namespace DM { - -ExpectationsTask::ExpectationsTask(const Task& parent, - const Expectations& expectations, - SkBitmap bitmap) - : CpuTask(parent) - , fName(parent.name()) // Masquerade as parent so failures are attributed to it. - , fExpectations(expectations) - , fBitmap(bitmap) - {} - -void ExpectationsTask::draw() { - if (!fExpectations.check(*this, fBitmap)) { - this->fail(); - } -} - -} // namespace DM diff --git a/dm/DMExpectationsTask.h b/dm/DMExpectationsTask.h deleted file mode 100644 index 7000de4b68..0000000000 --- a/dm/DMExpectationsTask.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef DMExpectationsTask_DEFINED -#define DMExpectationsTask_DEFINED - -#include "DMExpectations.h" -#include "DMTask.h" -#include "SkBitmap.h" -#include "SkString.h" - -namespace DM { - -// ExpectationsTask compares an SkBitmap against some Expectations. -// Moving this off the GPU threadpool is a nice (~30%) runtime win. -class ExpectationsTask : public CpuTask { -public: - ExpectationsTask(const Task& parent, const Expectations&, SkBitmap); - - virtual void draw() SK_OVERRIDE; - virtual bool shouldSkip() const SK_OVERRIDE { return false; } - virtual SkString name() const SK_OVERRIDE { return fName; } - -private: - const SkString fName; - const Expectations& fExpectations; - const SkBitmap fBitmap; -}; - -} // namespace DM - -#endif // DMExpectationsTask_DEFINED diff --git a/dm/DMGpuGMTask.cpp b/dm/DMGpuGMTask.cpp index 4c44fae970..63c9649037 100644 --- a/dm/DMGpuGMTask.cpp +++ b/dm/DMGpuGMTask.cpp @@ -1,6 +1,5 @@ #include "DMGpuGMTask.h" -#include "DMExpectationsTask.h" #include "DMUtil.h" #include "DMWriteTask.h" #include "SkCommandLineFlags.h" @@ -13,14 +12,12 @@ GpuGMTask::GpuGMTask(const char* config, Reporter* reporter, TaskRunner* taskRunner, skiagm::GMRegistry::Factory gmFactory, - const Expectations& expectations, GrContextFactory::GLContextType contextType, GrGLStandard gpuAPI, int sampleCount) : GpuTask(reporter, taskRunner) , fGM(gmFactory(NULL)) , fName(UnderJoin(fGM->getName(), config)) - , fExpectations(expectations) , fContextType(contextType) , fGpuAPI(gpuAPI) , fSampleCount(sampleCount) @@ -47,7 +44,6 @@ void GpuGMTask::draw(GrContextFactory* grFactory) { bitmap.setInfo(info); canvas->readPixels(&bitmap, 0, 0); - this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap))); this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); } diff --git a/dm/DMGpuGMTask.h b/dm/DMGpuGMTask.h index 46b4c981bc..23f3a45b0c 100644 --- a/dm/DMGpuGMTask.h +++ b/dm/DMGpuGMTask.h @@ -1,7 +1,6 @@ #ifndef DMGpuGMTask_DEFINED #define DMGpuGMTask_DEFINED -#include "DMExpectations.h" #include "DMGpuSupport.h" #include "DMReporter.h" #include "DMTask.h" @@ -21,7 +20,6 @@ public: Reporter*, TaskRunner*, skiagm::GMRegistry::Factory, - const Expectations&, GrContextFactory::GLContextType, GrGLStandard gpuAPI, int sampleCount); @@ -33,7 +31,6 @@ public: private: SkAutoTDelete<skiagm::GM> fGM; const SkString fName; - const Expectations& fExpectations; const GrContextFactory::GLContextType fContextType; GrGLStandard fGpuAPI; const int fSampleCount; diff --git a/dm/DMPDFRasterizeTask.cpp b/dm/DMPDFRasterizeTask.cpp index 40b9d8bfbc..f9573e4912 100644 --- a/dm/DMPDFRasterizeTask.cpp +++ b/dm/DMPDFRasterizeTask.cpp @@ -6,7 +6,6 @@ */ #include "DMPDFRasterizeTask.h" -#include "DMExpectationsTask.h" #include "DMUtil.h" #include "DMWriteTask.h" #include "SkBitmap.h" diff --git a/dm/DMPDFTask.h b/dm/DMPDFTask.h index ae0dcce4e0..72c023282a 100644 --- a/dm/DMPDFTask.h +++ b/dm/DMPDFTask.h @@ -1,7 +1,6 @@ #ifndef DMPDFTask_DEFINED #define DMPDFTask_DEFINED -#include "DMExpectations.h" #include "DMPDFRasterizeTask.h" #include "DMTask.h" #include "SkBitmap.h" diff --git a/dm/DMSKPTask.cpp b/dm/DMSKPTask.cpp index 9e376e7eb2..21bd9b13fd 100644 --- a/dm/DMSKPTask.cpp +++ b/dm/DMSKPTask.cpp @@ -1,5 +1,4 @@ #include "DMSKPTask.h" -#include "DMExpectationsTask.h" #include "DMUtil.h" #include "DMWriteTask.h" @@ -13,12 +12,10 @@ namespace DM { SKPTask::SKPTask(Reporter* r, TaskRunner* tr, - const Expectations& expectations, const SkPicture* pic, SkString filename) : CpuTask(r, tr) , fPicture(SkRef(pic)) - , fExpectations(expectations) , fName(FileToTaskName(filename)) {} void SKPTask::draw() { @@ -29,7 +26,6 @@ void SKPTask::draw() { DrawPicture(*fPicture, &bitmap); this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); - this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap))); } } // namespace DM diff --git a/dm/DMSKPTask.h b/dm/DMSKPTask.h index 6764a9ce09..b8a288e037 100644 --- a/dm/DMSKPTask.h +++ b/dm/DMSKPTask.h @@ -1,7 +1,6 @@ #ifndef DMSKPTask_DEFINED #define DMSKPTask_DEFINED -#include "DMExpectations.h" #include "DMReporter.h" #include "DMTask.h" #include "DMTaskRunner.h" @@ -15,7 +14,7 @@ namespace DM { class SKPTask : public CpuTask { public: - SKPTask(Reporter*, TaskRunner*, const Expectations&, const SkPicture*, SkString name); + SKPTask(Reporter*, TaskRunner*, const SkPicture*, SkString name); virtual void draw() SK_OVERRIDE; virtual bool shouldSkip() const SK_OVERRIDE { return false; } @@ -23,7 +22,6 @@ public: private: SkAutoTUnref<const SkPicture> fPicture; - const Expectations& fExpectations; const SkString fName; }; diff --git a/dm/DMUtil.h b/dm/DMUtil.h index 8de767db2b..fa29c76757 100644 --- a/dm/DMUtil.h +++ b/dm/DMUtil.h @@ -3,7 +3,7 @@ #include "SkBitmap.h" #include "SkString.h" -#include "gm_expectations.h" +#include "gm.h" class SkBBHFactory; diff --git a/dm/DMWriteTask.cpp b/dm/DMWriteTask.cpp index efc1415a1b..f8073e3390 100644 --- a/dm/DMWriteTask.cpp +++ b/dm/DMWriteTask.cpp @@ -3,6 +3,7 @@ #include "DMUtil.h" #include "SkColorPriv.h" #include "SkCommonFlags.h" +#include "SkData.h" #include "SkImageEncoder.h" #include "SkMD5.h" #include "SkMallocPixelRef.h" @@ -158,48 +159,6 @@ bool WriteTask::shouldSkip() const { return FLAGS_writePath.isEmpty(); } -WriteTask::Expectations* WriteTask::Expectations::Create(const char* path) { - if (!FLAGS_writePath.isEmpty() && 0 == strcmp(FLAGS_writePath[0], path)) { - SkDebugf("We seem to be reading and writing %s concurrently. This won't work.\n", path); - return NULL; - } - - SkString jsonPath; - if (sk_isdir(path)) { - jsonPath = SkOSPath::Join(path, "dm.json"); - } else { - jsonPath.set(path); - } - - SkAutoDataUnref json(SkData::NewFromFileName(jsonPath.c_str())); - if (NULL == json.get()) { - SkDebugf("Can't read %s!\n", jsonPath.c_str()); - return NULL; - } - - SkAutoTDelete<Expectations> expectations(SkNEW(Expectations)); - Json::Reader reader; - const char* begin = (const char*)json->bytes(); - const char* end = begin + json->size(); - if (!reader.parse(begin, end, expectations->fJson)) { - SkDebugf("Can't read %s as JSON!\n", jsonPath.c_str()); - return NULL; - } - return expectations.detach(); -} - -bool WriteTask::Expectations::check(const Task& task, SkBitmap bitmap) const { - const SkString name = task.name(); - if (fJson[name.c_str()].isNull()) { - return true; // No expectations. - } - - const char* expected = fJson[name.c_str()].asCString(); - SkAutoTDelete<SkStreamAsset> png(encode_to_png(bitmap)); - SkString actual = get_md5(png); - return actual.equals(expected); -} - void WriteTask::DumpJson() { if (FLAGS_writePath.isEmpty()) { return; diff --git a/dm/DMWriteTask.h b/dm/DMWriteTask.h index fad9262c33..f83289ca2e 100644 --- a/dm/DMWriteTask.h +++ b/dm/DMWriteTask.h @@ -1,7 +1,6 @@ #ifndef DMWriteTask_DEFINED #define DMWriteTask_DEFINED -#include "DMExpectations.h" #include "DMTask.h" #include "SkBitmap.h" #include "SkJSONCPP.h" @@ -29,16 +28,6 @@ public: virtual bool shouldSkip() const SK_OVERRIDE; virtual SkString name() const SK_OVERRIDE; - // Reads JSON file WriteTask wrote under root and compares the bitmap with checksums inside. - class Expectations : public DM::Expectations { - public: - static Expectations* Create(const char*); - bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE; - private: - Expectations() {} - Json::Value fJson; - }; - static void DumpJson(); private: |