skia2/tools/skqp/goldgetter.py
Hal Canary 5b39dc8153 SkQP: fix model colorspace (16-bit gold images)
Problem: `make_gmkb.go `was ignoring the ignoring the embedded ICC
profile in the images it was getting from Gold.

Replace make_gmkb.go with two small programs: `goldgetter.py` and
`make_skqp_model.cpp`.

`make_skqp_model` uses Skia to create the model from a bunch of images.

`goldgetter` wraps `make_skqp_model` and handles:
  - json parsing
  - downloading images from gold
  - multiprocessing

CQ_INCLUDE_TRYBOTS=skia.primary:Build-Debian9-Clang-x86-devrel-Android_SKQP,Test-Debian9-Clang-NUC7i5BNK-CPU-Emulator-x86-devrel-All-Android_SKQP

Change-Id: I7add1a1dfd83bbd0ab07ab126d4183c36325263c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209101
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2019-04-17 20:26:39 +00:00

49 lines
1.5 KiB
Python
Executable File

#! /usr/bin/env python
# Copyright 2019 Google LLC.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import json
import multiprocessing
import os
import shutil
import subprocess
import sys
import tempfile
import urllib
def make_skqp_model(arg):
name, urls, dst_dir, exe = arg
tmp = tempfile.mkdtemp()
for url in urls:
urllib.urlretrieve(url, tmp + '/' + url[url.rindex('/') + 1:])
subprocess.check_call([exe, tmp, dst_dir + '/' + name])
shutil.rmtree(tmp)
sys.stdout.write(name + ' ')
sys.stdout.flush()
def main(meta, dst, exe):
assert os.path.exists(exe)
jobs = []
with open(meta, 'r') as f:
for rec in json.load(f):
urls = [d['URL'] for d in rec['digests']
if d['status'] == 'positive' and
(set(d['paramset']['config']) & set(['vk', 'gles']))]
if urls:
jobs.append((rec['testName'], urls, dst, exe))
if not os.path.exists(dst):
os.mkdir(dst)
pool = multiprocessing.Pool(processes=20)
pool.map(make_skqp_model, jobs)
sys.stdout.write('\n')
with open(dst + '/models.txt', 'w') as o:
for n, _, _, _ in jobs:
o.write(n + '\n')
if __name__ == '__main__':
if len(sys.argv) != 4:
sys.stderr.write('Usage:\n %s META.JSON DST_DIR MAKE_SKQP_MODEL_EXE\n\n' % sys.argv[0])
sys.exit(1)
main(sys.argv[1], sys.argv[2], sys.argv[3])