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 <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
Hal Canary 2019-12-03 14:27:04 -05:00 committed by Skia Commit-Bot
parent f78aa16af1
commit a06f9d0787
3 changed files with 32 additions and 5 deletions

View File

@ -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'),

View File

@ -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

View File

@ -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;
}