From a06f9d0787caafd42c8826e3f33389f38044eff2 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Tue, 3 Dec 2019 14:27:04 -0500 Subject: [PATCH] SkQP: model-creation improvements - cut_release/find_commit: use cookies, handle errors. - tools/skqp/make_skqp_model.cpp: better error handling Change-Id: I702e9a13d3a2123c30e3a870fcb942759cfc47c3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257682 Reviewed-by: Ben Wagner Commit-Queue: Hal Canary --- tools/skqp/cut_release.py | 6 +++++- .../find_commit_with_best_gold_results.py | 11 +++++++++- tools/skqp/make_skqp_model.cpp | 20 ++++++++++++++++--- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/tools/skqp/cut_release.py b/tools/skqp/cut_release.py index fba4f6c12c..584f1b5414 100755 --- a/tools/skqp/cut_release.py +++ b/tools/skqp/cut_release.py @@ -19,6 +19,10 @@ assert '/' in [os.sep, os.altsep] and os.pardir == '..' ASSETS = 'platform_tools/android/apps/skqp/src/main/assets' BUCKET = 'skia-skqp-assets' +def urlopen(url): + cookie = os.environ.get('SKIA_GOLD_COOKIE', '') + return urllib2.urlopen(urllib2.Request(url, headers={'Cookie': cookie})) + def make_skqp_model(arg): name, urls, exe = arg tmp = tempfile.mkdtemp() @@ -46,7 +50,7 @@ def goldgetter(meta, exe): def gold(first_commit, last_commit): c1, c2 = (check_output(['git', 'rev-parse', c]).strip() for c in (first_commit, last_commit)) - f = urllib2.urlopen('https://public-gold.skia.org/json/export?' + urllib.urlencode([ + f = urlopen('https://public-gold.skia.org/json/export?' + urllib.urlencode([ ('fbegin', c1), ('fend', c2), ('query', 'config=gles&config=vk&source_type=gm'), diff --git a/tools/skqp/find_commit_with_best_gold_results.py b/tools/skqp/find_commit_with_best_gold_results.py index 49d2a4af56..d825b1ace8 100755 --- a/tools/skqp/find_commit_with_best_gold_results.py +++ b/tools/skqp/find_commit_with_best_gold_results.py @@ -54,13 +54,22 @@ def gold_export_url(job, config, first_commit, last_commit): return 'https://public-gold.skia.org/json/export?' + urllib.urlencode(query) +def urlopen(url): + cookie = os.environ.get('SKIA_GOLD_COOKIE', '') + return urllib2.urlopen(urllib2.Request(url, headers={'Cookie': cookie})) + + def get_results_for_commit(commit, jobs): sys.stderr.write('%s\n' % commit) sys.stderr.flush() CONFIGS = ['gles', 'vk'] passing_tests_for_all_jobs = [] def process(url): - testResults = json.load(urllib2.urlopen(url)) + try: + testResults = json.load(urlopen(url)) + except urllib2.URLError: + sys.stderr.write('\nerror "%s":\n' % url) + return sys.stderr.write('.') sys.stderr.flush() passing_tests = 0 diff --git a/tools/skqp/make_skqp_model.cpp b/tools/skqp/make_skqp_model.cpp index 62ae5d0880..574e2e0bdc 100644 --- a/tools/skqp/make_skqp_model.cpp +++ b/tools/skqp/make_skqp_model.cpp @@ -6,7 +6,7 @@ #include "include/encode/SkPngEncoder.h" #include "src/core/SkOSFile.h" -static void update(SkBitmap* maxBitmap, SkBitmap* minBitmap, const SkBitmap& bm) { +static bool update(SkBitmap* maxBitmap, SkBitmap* minBitmap, const SkBitmap& bm) { SkASSERT(!bm.drawsNothing()); SkASSERT(4 == bm.bytesPerPixel()); if (maxBitmap->drawsNothing()) { @@ -15,6 +15,9 @@ static void update(SkBitmap* maxBitmap, SkBitmap* minBitmap, const SkBitmap& bm) minBitmap->allocPixels(bm.info()); minBitmap->eraseColor(0xFFFFFFFF); } + if (maxBitmap->dimensions() != bm.dimensions()) { + return false; + } SkASSERT_RELEASE(maxBitmap->info() == bm.info()); const SkPixmap& pmin = minBitmap->pixmap(); const SkPixmap& pmax = maxBitmap->pixmap(); @@ -35,6 +38,7 @@ static void update(SkBitmap* maxBitmap, SkBitmap* minBitmap, const SkBitmap& bm) memcpy(maxPtr, maxColor, 4); } } + return true; } static SkBitmap decode_to_srgb_8888_unpremul(const char* path) { @@ -72,11 +76,21 @@ int main(int argc, char** argv) { while (iter.next(&name)) { name.prependf("%s/", src_dir); SkBitmap bm = decode_to_srgb_8888_unpremul(name.c_str()); - if (!bm.drawsNothing()) { - update(&maxBitmap, &minBitmap, bm); + if (bm.drawsNothing()) { + SkDebugf("'%s' failed to decode.\n", name.c_str()); + continue; + } + if (!update(&maxBitmap, &minBitmap, bm)) { + SkDebugf("'%s' has unmatched dimensions.\n", name.c_str()); + continue; } } SkASSERT_RELEASE(sk_mkdir(dst_dir)); + if ((maxBitmap.drawsNothing()) || (maxBitmap.drawsNothing())) { + SkDebugf("Failure: '%s' '%s'\n", src_dir, dst_dir); + return 1; + } encode_png(SkStringPrintf("%s/min.png", dst_dir).c_str(), minBitmap.pixmap()); encode_png(SkStringPrintf("%s/max.png", dst_dir).c_str(), maxBitmap.pixmap()); + return 0; }