2015-03-25 14:11:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2014-11-13 16:06:40 +00:00
|
|
|
#include "CrashHandler.h"
|
2015-01-15 18:56:12 +00:00
|
|
|
#include "DMJsonWriter.h"
|
|
|
|
#include "DMSrcSink.h"
|
2015-02-23 20:18:05 +00:00
|
|
|
#include "DMSrcSinkAndroid.h"
|
2015-01-15 18:56:12 +00:00
|
|
|
#include "OverwriteLine.h"
|
|
|
|
#include "ProcStats.h"
|
|
|
|
#include "SkBBHFactory.h"
|
2015-01-27 22:46:26 +00:00
|
|
|
#include "SkChecksum.h"
|
2015-08-14 15:32:46 +00:00
|
|
|
#include "SkCodec.h"
|
2014-07-22 17:15:34 +00:00
|
|
|
#include "SkCommonFlags.h"
|
2015-06-10 16:31:09 +00:00
|
|
|
#include "SkFontMgr.h"
|
2013-10-16 13:02:15 +00:00
|
|
|
#include "SkForceLinking.h"
|
|
|
|
#include "SkGraphics.h"
|
2015-01-15 18:56:12 +00:00
|
|
|
#include "SkMD5.h"
|
2015-07-07 19:21:21 +00:00
|
|
|
#include "SkMutex.h"
|
Start to rework DM JSON handling.
DM's striking off into its own JSON world. This gets strawman implementations
in place for writing and reading a JSON file mapping test name to hashes.
For what it's worth, I basically want to change _all_ these pieces,
- MD5 is slow and we can replace it with something faster,
- JSON schema needs room to grow more data,
- it'd be nice to hash once instead of twice when reading and writing,
- this code wants lots of refactoring,
but this gives us a starting platform to work on these bits at our leisure.
E.x. file for now:
mtklein@mtklein ~/skia (dm)> cat good/dm.json
{
"3x3bitmaprect_565" : "fc70d985fbfbe70e3a3c9dc626d4f5bc",
"3x3bitmaprect_8888" : "df1591dde35907399734ea19feb76663",
"3x3bitmaprect_gpu" : "df1591dde35907399734ea19feb76663",
"aaclip_565" : "1862798689b838a7ab0dc0652b9ace3a",
"aaclip_8888" : "47bb314329f0ce243f1d83fd583decb7",
"aaclip_gpu" : "75f72412d0ef4815770202d297246e7d",
...
BUG=skia:
R=jcgregorio@google.com, stephana@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/546873002
2014-09-08 15:05:18 +00:00
|
|
|
#include "SkOSFile.h"
|
2015-02-20 20:30:19 +00:00
|
|
|
#include "SkTHash.h"
|
SkThreadPool ~~> SkTaskGroup
SkTaskGroup is like SkThreadPool except the threads stay in
one global pool. Each SkTaskGroup itself is tiny (4 bytes)
and its wait() method applies only to tasks add()ed to that
instance, not the whole thread pool.
This means we don't need to bring up new thread pools when
tests themselves want to use multithreading (e.g. pathops,
quilt). We just create a new SkTaskGroup and wait for that
to complete. This should be more efficient, and allow us
to expand where we use threads to really latency sensitive
places. E.g. we can probably now use these in nanobench
for CPU .skp rendering.
Now that all threads are sharing the same pool, I think we
can remove most of the custom mechanism pathops tests use
to control threading. They'll just ride on the global pool
with all other tests now.
This (temporarily?) removes the GPU multithreading feature
from DM, which we don't use.
On my desktop, DM runs a little faster (57s -> 55s) in
Debug, and a lot faster in Release (36s -> 24s). The bots
show speedups of similar proportions, cutting more than a
minute off the N4/Release and Win7/Debug runtimes.
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/9c7207b5dc71dc5a96a2eb107d401133333d5b6f
R=caryclark@google.com, bsalomon@google.com, bungeman@google.com, mtklein@google.com, reed@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/531653002
2014-09-03 22:34:37 +00:00
|
|
|
#include "SkTaskGroup.h"
|
2015-03-12 13:28:54 +00:00
|
|
|
#include "SkThreadUtils.h"
|
2014-02-26 16:31:22 +00:00
|
|
|
#include "Test.h"
|
2015-01-15 18:56:12 +00:00
|
|
|
#include "Timer.h"
|
2015-06-10 16:31:09 +00:00
|
|
|
#include "sk_tool_utils.h"
|
2014-06-03 20:57:14 +00:00
|
|
|
|
2015-08-24 20:27:01 +00:00
|
|
|
#ifdef SKIA_PNG_PREFIXED
|
|
|
|
// this must proceed png.h
|
|
|
|
#include "pngprefix.h"
|
|
|
|
#endif
|
|
|
|
#include "png.h"
|
|
|
|
|
2015-08-26 12:15:46 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2015-04-03 14:24:48 +00:00
|
|
|
DEFINE_string(src, "tests gm skp image", "Source types to test.");
|
2015-01-15 18:56:12 +00:00
|
|
|
DEFINE_bool(nameByHash, false,
|
|
|
|
"If true, write to FLAGS_writePath[0]/<hash>.png instead of "
|
2015-04-03 14:24:48 +00:00
|
|
|
"to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>.png");
|
2015-01-15 18:56:12 +00:00
|
|
|
DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
|
2015-02-17 19:13:33 +00:00
|
|
|
DEFINE_string(matrix, "1 0 0 1",
|
|
|
|
"2x2 scale+skew matrix to apply or upright when using "
|
|
|
|
"'matrix' or 'upright' in config.");
|
2015-01-15 20:46:02 +00:00
|
|
|
DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2015-01-15 21:44:22 +00:00
|
|
|
DEFINE_string(blacklist, "",
|
2015-04-03 14:24:48 +00:00
|
|
|
"Space-separated config/src/srcOptions/name quadruples to blacklist. '_' matches anything. E.g. \n"
|
|
|
|
"'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu config.\n"
|
|
|
|
"'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aarects GM on 8888.");
|
2015-01-15 21:44:22 +00:00
|
|
|
|
2015-01-27 22:46:26 +00:00
|
|
|
DEFINE_string2(readPath, r, "", "If set check for equality with golden results in this directory.");
|
|
|
|
|
2015-04-03 21:15:33 +00:00
|
|
|
DEFINE_string(uninterestingHashesFile, "",
|
|
|
|
"File containing a list of uninteresting hashes. If a result hashes to something in "
|
|
|
|
"this list, no image is written for that result.");
|
|
|
|
|
2015-04-27 15:45:01 +00:00
|
|
|
DEFINE_int32(shards, 1, "We're splitting source data into this many shards.");
|
|
|
|
DEFINE_int32(shard, 0, "Which shard do I run?");
|
2015-06-04 21:15:33 +00:00
|
|
|
DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading");
|
2015-04-27 15:45:01 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
__SK_FORCE_IMAGE_DECODER_LINKING;
|
|
|
|
using namespace DM;
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
2014-06-30 13:36:31 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
|
|
|
|
static SkTArray<SkString> gFailures;
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
static void fail(ImplicitString err) {
|
|
|
|
SkAutoMutexAcquire lock(gFailuresMutex);
|
|
|
|
SkDebugf("\n\nFAILURE: %s\n\n", err.c_str());
|
|
|
|
gFailures.push_back(err);
|
|
|
|
}
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2015-03-18 12:27:14 +00:00
|
|
|
static int32_t gPending = 0; // Atomic. Total number of running and queued tasks.
|
|
|
|
|
|
|
|
SK_DECLARE_STATIC_MUTEX(gRunningMutex);
|
|
|
|
static SkTArray<SkString> gRunning;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
static void done(double ms,
|
2015-04-03 14:24:48 +00:00
|
|
|
ImplicitString config, ImplicitString src, ImplicitString srcOptions,
|
|
|
|
ImplicitString name, ImplicitString note, ImplicitString log) {
|
|
|
|
SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(),
|
|
|
|
srcOptions.c_str(), name.c_str());
|
2015-03-18 12:27:14 +00:00
|
|
|
{
|
|
|
|
SkAutoMutexAcquire lock(gRunningMutex);
|
|
|
|
for (int i = 0; i < gRunning.count(); i++) {
|
|
|
|
if (gRunning[i] == id) {
|
|
|
|
gRunning.removeShuffle(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!FLAGS_verbose) {
|
|
|
|
note = "";
|
|
|
|
}
|
2015-02-03 02:26:03 +00:00
|
|
|
if (!log.isEmpty()) {
|
|
|
|
log.prepend("\n");
|
|
|
|
}
|
2015-02-05 17:53:44 +00:00
|
|
|
auto pending = sk_atomic_dec(&gPending)-1;
|
2015-05-19 21:13:31 +00:00
|
|
|
if (!FLAGS_quiet) {
|
2015-07-08 15:49:20 +00:00
|
|
|
SkDebugf("%s(%4d/%-4dMB %6d) %s\t%s%s%s", FLAGS_verbose ? "\n" : kSkOverwriteLine
|
2015-05-19 21:13:31 +00:00
|
|
|
, sk_tools::getCurrResidentSetSizeMB()
|
|
|
|
, sk_tools::getMaxResidentSetSizeMB()
|
|
|
|
, pending
|
|
|
|
, HumanizeMs(ms).c_str()
|
|
|
|
, id.c_str()
|
|
|
|
, note.c_str()
|
|
|
|
, log.c_str());
|
|
|
|
}
|
2015-01-23 13:48:00 +00:00
|
|
|
// We write our dm.json file every once in a while in case we crash.
|
|
|
|
// Notice this also handles the final dm.json when pending == 0.
|
|
|
|
if (pending % 500 == 0) {
|
|
|
|
JsonWriter::DumpJson();
|
|
|
|
}
|
2015-01-10 19:18:04 +00:00
|
|
|
}
|
|
|
|
|
2015-04-03 14:24:48 +00:00
|
|
|
static void start(ImplicitString config, ImplicitString src,
|
|
|
|
ImplicitString srcOptions, ImplicitString name) {
|
|
|
|
SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(),
|
|
|
|
srcOptions.c_str(), name.c_str());
|
2015-03-18 12:27:14 +00:00
|
|
|
SkAutoMutexAcquire lock(gRunningMutex);
|
|
|
|
gRunning.push_back(id);
|
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2015-01-27 22:46:26 +00:00
|
|
|
struct Gold : public SkString {
|
2015-02-20 20:30:19 +00:00
|
|
|
Gold() : SkString("") {}
|
2015-04-03 14:24:48 +00:00
|
|
|
Gold(ImplicitString sink, ImplicitString src, ImplicitString srcOptions,
|
|
|
|
ImplicitString name, ImplicitString md5)
|
2015-01-27 22:46:26 +00:00
|
|
|
: SkString("") {
|
|
|
|
this->append(sink);
|
|
|
|
this->append(src);
|
2015-04-03 14:24:48 +00:00
|
|
|
this->append(srcOptions);
|
2015-01-27 22:46:26 +00:00
|
|
|
this->append(name);
|
|
|
|
this->append(md5);
|
|
|
|
}
|
2015-03-20 20:48:42 +00:00
|
|
|
static uint32_t Hash(const Gold& g) { return SkGoodHash((const SkString&)g); }
|
2015-01-27 22:46:26 +00:00
|
|
|
};
|
2015-02-20 20:30:19 +00:00
|
|
|
static SkTHashSet<Gold, Gold::Hash> gGold;
|
2015-01-27 22:46:26 +00:00
|
|
|
|
|
|
|
static void add_gold(JsonWriter::BitmapResult r) {
|
2015-04-03 14:24:48 +00:00
|
|
|
gGold.add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5));
|
2015-01-27 22:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gather_gold() {
|
|
|
|
if (!FLAGS_readPath.isEmpty()) {
|
|
|
|
SkString path(FLAGS_readPath[0]);
|
|
|
|
path.append("/dm.json");
|
|
|
|
if (!JsonWriter::ReadJson(path.c_str(), add_gold)) {
|
|
|
|
fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2015-04-03 21:15:33 +00:00
|
|
|
static SkTHashSet<SkString> gUninterestingHashes;
|
|
|
|
|
|
|
|
static void gather_uninteresting_hashes() {
|
|
|
|
if (!FLAGS_uninterestingHashesFile.isEmpty()) {
|
|
|
|
SkAutoTUnref<SkData> data(SkData::NewFromFileName(FLAGS_uninterestingHashesFile[0]));
|
|
|
|
SkTArray<SkString> hashes;
|
|
|
|
SkStrSplit((const char*)data->data(), "\n", &hashes);
|
|
|
|
for (const SkString& hash : hashes) {
|
|
|
|
gUninterestingHashes.add(hash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2015-07-29 13:37:28 +00:00
|
|
|
struct TaggedSrc : public SkAutoTDelete<Src> {
|
2015-09-01 21:57:57 +00:00
|
|
|
ImplicitString tag;
|
|
|
|
ImplicitString options;
|
2015-07-29 13:37:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TaggedSink : public SkAutoTDelete<Sink> {
|
|
|
|
const char* tag;
|
2015-04-03 14:24:48 +00:00
|
|
|
};
|
2015-01-15 18:56:12 +00:00
|
|
|
|
|
|
|
static const bool kMemcpyOK = true;
|
|
|
|
|
2015-07-29 13:37:28 +00:00
|
|
|
static SkTArray<TaggedSrc, kMemcpyOK> gSrcs;
|
|
|
|
static SkTArray<TaggedSink, kMemcpyOK> gSinks;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2015-04-27 15:45:01 +00:00
|
|
|
static bool in_shard() {
|
|
|
|
static int N = 0;
|
|
|
|
return N++ % FLAGS_shards == FLAGS_shard;
|
|
|
|
}
|
|
|
|
|
2015-09-01 21:57:57 +00:00
|
|
|
static void push_src(ImplicitString tag, ImplicitString options, Src* s) {
|
2015-01-15 18:56:12 +00:00
|
|
|
SkAutoTDelete<Src> src(s);
|
2015-04-27 15:45:01 +00:00
|
|
|
if (in_shard() &&
|
2015-09-01 21:57:57 +00:00
|
|
|
FLAGS_src.contains(tag.c_str()) &&
|
2015-01-15 18:56:12 +00:00
|
|
|
!SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
|
2015-07-29 13:37:28 +00:00
|
|
|
TaggedSrc& s = gSrcs.push_back();
|
2015-01-15 18:56:12 +00:00
|
|
|
s.reset(src.detach());
|
|
|
|
s.tag = tag;
|
2015-04-03 14:24:48 +00:00
|
|
|
s.options = options;
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-01 21:57:57 +00:00
|
|
|
static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorType dstColorType,
|
|
|
|
float scale) {
|
|
|
|
SkString folder;
|
|
|
|
switch (mode) {
|
|
|
|
case CodecSrc::kCodec_Mode:
|
|
|
|
folder.append("codec");
|
|
|
|
break;
|
|
|
|
case CodecSrc::kScaledCodec_Mode:
|
|
|
|
folder.append("scaled_codec");
|
|
|
|
break;
|
|
|
|
case CodecSrc::kScanline_Mode:
|
|
|
|
folder.append("scanline");
|
|
|
|
break;
|
|
|
|
case CodecSrc::kScanline_Subset_Mode:
|
|
|
|
folder.append("scanline_subset");
|
|
|
|
break;
|
|
|
|
case CodecSrc::kStripe_Mode:
|
|
|
|
folder.append("stripe");
|
|
|
|
break;
|
|
|
|
case CodecSrc::kSubset_Mode:
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
folder.append("codec_subset");
|
2015-09-01 21:57:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (dstColorType) {
|
|
|
|
case CodecSrc::kGrayscale_Always_DstColorType:
|
|
|
|
folder.append("_kGray8");
|
|
|
|
break;
|
|
|
|
case CodecSrc::kIndex8_Always_DstColorType:
|
|
|
|
folder.append("_kIndex8");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (1.0f != scale) {
|
|
|
|
folder.appendf("_%.3f", scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
CodecSrc* src = new CodecSrc(path, mode, dstColorType, scale);
|
|
|
|
push_src("image", folder, src);
|
|
|
|
}
|
|
|
|
|
2015-04-09 19:43:10 +00:00
|
|
|
static void push_codec_srcs(Path path) {
|
|
|
|
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
|
|
|
|
if (!encoded) {
|
|
|
|
SkDebugf("Couldn't read %s.", path.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
|
2015-08-27 14:41:13 +00:00
|
|
|
if (nullptr == codec.get()) {
|
2015-04-09 19:43:10 +00:00
|
|
|
SkDebugf("Couldn't create codec for %s.", path.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
// Native Scales
|
2015-06-11 21:27:27 +00:00
|
|
|
// TODO (msarett): Implement scaling tests for SkImageDecoder in order to compare with these
|
|
|
|
// tests. SkImageDecoder supports downscales by integer factors.
|
2015-08-14 14:44:46 +00:00
|
|
|
// SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f };
|
|
|
|
|
|
|
|
const CodecSrc::Mode nativeModes[] = { CodecSrc::kCodec_Mode, CodecSrc::kScanline_Mode,
|
|
|
|
CodecSrc::kScanline_Subset_Mode, CodecSrc::kStripe_Mode, CodecSrc::kSubset_Mode };
|
|
|
|
|
|
|
|
CodecSrc::DstColorType colorTypes[3];
|
|
|
|
uint32_t numColorTypes;
|
|
|
|
switch (codec->getInfo().colorType()) {
|
|
|
|
case kGray_8_SkColorType:
|
|
|
|
// FIXME: Is this a long term solution for testing wbmps decodes to kIndex8?
|
|
|
|
// Further discussion on this topic is at skbug.com/3683
|
|
|
|
colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType;
|
|
|
|
colorTypes[1] = CodecSrc::kGrayscale_Always_DstColorType;
|
|
|
|
colorTypes[2] = CodecSrc::kIndex8_Always_DstColorType;
|
|
|
|
numColorTypes = 3;
|
|
|
|
break;
|
|
|
|
case kIndex_8_SkColorType:
|
|
|
|
colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType;
|
|
|
|
colorTypes[1] = CodecSrc::kIndex8_Always_DstColorType;
|
|
|
|
numColorTypes = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType;
|
|
|
|
numColorTypes = 1;
|
|
|
|
break;
|
|
|
|
}
|
2015-06-11 21:27:27 +00:00
|
|
|
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
for (float scale : nativeScales) {
|
|
|
|
if (scale != 1.0f && (path.endsWith(".webp") || path.endsWith(".WEBP"))) {
|
|
|
|
// FIXME: skbug.com/4038 Scaling webp seems to leave some pixels uninitialized/
|
|
|
|
// compute their colors based on uninitialized values.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (CodecSrc::Mode mode : nativeModes) {
|
|
|
|
for (uint32_t i = 0; i < numColorTypes; i++) {
|
|
|
|
push_codec_src(path, mode, colorTypes[i], scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-01 21:57:57 +00:00
|
|
|
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
// SkScaledCodec Scales
|
|
|
|
// The native scales are included to make sure that SkScaledCodec defaults to the native
|
|
|
|
// scaling strategy when possible.
|
|
|
|
// 0.1, 0.16, 0.2 etc allow us to test SkScaledCodec with sampleSize 10, 6, 5, etc.
|
|
|
|
// 0.4, 0.7 etc allow to test what happens when the client requests a scale that
|
|
|
|
// does not exactly match a sampleSize or native scaling capability.
|
|
|
|
const float samplingScales[] = { 0.1f, 0.125f, 0.166f, 0.2f, 0.25f, 0.333f, 0.375f, 0.4f, 0.5f,
|
|
|
|
0.6f, 0.625f, 0.750f, 0.8f, 0.875f, 1.0f };
|
2015-09-01 21:57:57 +00:00
|
|
|
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
for (float scale : samplingScales) {
|
2015-08-07 19:53:25 +00:00
|
|
|
if (scale != 1.0f && (path.endsWith(".webp") || path.endsWith(".WEBP"))) {
|
|
|
|
// FIXME: skbug.com/4038 Scaling webp seems to leave some pixels uninitialized/
|
|
|
|
// compute their colors based on uninitialized values.
|
|
|
|
continue;
|
|
|
|
}
|
2015-04-09 19:43:10 +00:00
|
|
|
|
Remove unwanted images in Gold
These extra outputs were caused by recent changes to
push_codec_srcs.
https://codereview.chromium.org/1327433003/
*** First, I would argue that we do not want to test
"native" modes (ex: codec, scanline, etc) to scales
that require sampling (ex: 0.1, 0.2, etc). Right now,
we are trying to scale jpegs to 0.1, settling for 0.125
as the closest option, and then trying to compare the
0.125 scaled image to the actual 0.1 scaled image in
Gold.
*** Second, I messed up and caused our test setup to
try to decode to kIndex8 and kGray8 "always" instead
of only when it is recommended. The bad effect of this
happens because we can decode jpegs to kGray8 even if
they are color images. Right now in Gold, we have a
bunch of untriaged gray versions of color images.
The second issue would have been caught if we signaled
a fatal failure for invalid conversions. Maybe we should
look into this now that 565 is supported everywhere?
BUG=skia:
Review URL: https://codereview.chromium.org/1314163007
2015-09-02 20:20:52 +00:00
|
|
|
for (uint32_t i = 0; i < numColorTypes; i++) {
|
|
|
|
push_codec_src(path, CodecSrc::kScaledCodec_Mode, colorTypes[i], scale);
|
2015-09-01 21:57:57 +00:00
|
|
|
}
|
2015-06-11 21:27:27 +00:00
|
|
|
}
|
2015-04-09 19:43:10 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 13:59:48 +00:00
|
|
|
static bool codec_supported(const char* ext) {
|
|
|
|
// FIXME: Once other versions of SkCodec are available, we can add them to this
|
|
|
|
// list (and eventually we can remove this check once they are all supported).
|
2015-04-01 13:58:48 +00:00
|
|
|
static const char* const exts[] = {
|
2015-09-08 13:59:48 +00:00
|
|
|
"bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp",
|
|
|
|
"BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP",
|
2015-04-01 13:58:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
|
|
|
|
if (0 == strcmp(exts[i], ext)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2015-03-19 13:03:39 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
static void gather_srcs() {
|
|
|
|
for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->next()) {
|
2015-04-03 14:24:48 +00:00
|
|
|
push_src("gm", "", new GMSrc(r->factory()));
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
2015-01-30 15:31:19 +00:00
|
|
|
for (int i = 0; i < FLAGS_skps.count(); i++) {
|
|
|
|
const char* path = FLAGS_skps[i];
|
|
|
|
if (sk_isdir(path)) {
|
|
|
|
SkOSFile::Iter it(path, "skp");
|
|
|
|
for (SkString file; it.next(&file); ) {
|
2015-04-03 14:24:48 +00:00
|
|
|
push_src("skp", "", new SKPSrc(SkOSPath::Join(path, file.c_str())));
|
2015-01-30 15:31:19 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-04-03 14:24:48 +00:00
|
|
|
push_src("skp", "", new SKPSrc(path));
|
2014-02-28 20:31:31 +00:00
|
|
|
}
|
2014-02-26 16:31:22 +00:00
|
|
|
}
|
2015-01-30 17:58:58 +00:00
|
|
|
static const char* const exts[] = {
|
|
|
|
"bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
|
|
|
|
"BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
|
|
|
|
};
|
|
|
|
for (int i = 0; i < FLAGS_images.count(); i++) {
|
|
|
|
const char* flag = FLAGS_images[i];
|
|
|
|
if (sk_isdir(flag)) {
|
|
|
|
for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) {
|
|
|
|
SkOSFile::Iter it(flag, exts[j]);
|
|
|
|
for (SkString file; it.next(&file); ) {
|
|
|
|
SkString path = SkOSPath::Join(flag, file.c_str());
|
2015-04-03 14:24:48 +00:00
|
|
|
push_src("image", "decode", new ImageSrc(path)); // Decode entire image
|
|
|
|
push_src("image", "subset", new ImageSrc(path, 2)); // Decode into 2x2 subsets
|
2015-09-08 13:59:48 +00:00
|
|
|
if (codec_supported(exts[j])) {
|
|
|
|
push_codec_srcs(path);
|
2015-03-19 13:03:39 +00:00
|
|
|
}
|
2015-01-30 17:58:58 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
2015-01-30 17:58:58 +00:00
|
|
|
} else if (sk_exists(flag)) {
|
|
|
|
// assume that FLAGS_images[i] is a valid image if it is a file.
|
2015-04-03 14:24:48 +00:00
|
|
|
push_src("image", "decode", new ImageSrc(flag)); // Decode entire image.
|
|
|
|
push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets
|
2015-04-09 19:43:10 +00:00
|
|
|
push_codec_srcs(flag);
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-15 16:30:25 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
static GrGLStandard get_gpu_api() {
|
|
|
|
if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; }
|
|
|
|
if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; }
|
|
|
|
return kNone_GrGLStandard;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void push_sink(const char* tag, Sink* s) {
|
|
|
|
SkAutoTDelete<Sink> sink(s);
|
|
|
|
if (!FLAGS_config.contains(tag)) {
|
|
|
|
return;
|
|
|
|
}
|
2015-07-29 13:37:28 +00:00
|
|
|
// Try a simple Src as a canary. If it fails, skip this sink.
|
2015-01-15 18:56:12 +00:00
|
|
|
struct : public Src {
|
2015-07-29 13:37:28 +00:00
|
|
|
Error draw(SkCanvas* c) const override {
|
|
|
|
c->drawRect(SkRect::MakeWH(1,1), SkPaint());
|
|
|
|
return "";
|
|
|
|
}
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize size() const override { return SkISize::Make(16, 16); }
|
2015-07-29 13:37:28 +00:00
|
|
|
Name name() const override { return "justOneRect"; }
|
|
|
|
} justOneRect;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
|
|
|
SkBitmap bitmap;
|
|
|
|
SkDynamicMemoryWStream stream;
|
2015-02-03 02:26:03 +00:00
|
|
|
SkString log;
|
2015-07-29 13:37:28 +00:00
|
|
|
Error err = sink->draw(justOneRect, &bitmap, &stream, &log);
|
2015-03-05 16:40:28 +00:00
|
|
|
if (err.isFatal()) {
|
2015-04-21 17:49:13 +00:00
|
|
|
SkDebugf("Could not run %s: %s\n", tag, err.c_str());
|
|
|
|
exit(1);
|
2014-07-28 14:21:24 +00:00
|
|
|
}
|
2015-01-15 16:30:25 +00:00
|
|
|
|
2015-07-29 13:37:28 +00:00
|
|
|
TaggedSink& ts = gSinks.push_back();
|
2015-01-15 18:56:12 +00:00
|
|
|
ts.reset(sink.detach());
|
|
|
|
ts.tag = tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool gpu_supported() {
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
return FLAGS_gpu;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static Sink* create_sink(const char* tag) {
|
|
|
|
#define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS__); }
|
|
|
|
if (gpu_supported()) {
|
2015-01-15 20:46:02 +00:00
|
|
|
typedef GrContextFactory Gr;
|
2015-01-15 18:56:12 +00:00
|
|
|
const GrGLStandard api = get_gpu_api();
|
2015-08-27 17:38:39 +00:00
|
|
|
SINK("gpunull", GPUSink, Gr::kNull_GLContextType, api, 0, false, FLAGS_gpu_threading);
|
|
|
|
SINK("gpudebug", GPUSink, Gr::kDebug_GLContextType, api, 0, false, FLAGS_gpu_threading);
|
|
|
|
SINK("gpu", GPUSink, Gr::kNative_GLContextType, api, 0, false, FLAGS_gpu_threading);
|
|
|
|
SINK("gpudft", GPUSink, Gr::kNative_GLContextType, api, 0, true, FLAGS_gpu_threading);
|
|
|
|
SINK("msaa4", GPUSink, Gr::kNative_GLContextType, api, 4, false, FLAGS_gpu_threading);
|
|
|
|
SINK("msaa16", GPUSink, Gr::kNative_GLContextType, api, 16, false, FLAGS_gpu_threading);
|
|
|
|
SINK("nvprmsaa4", GPUSink, Gr::kNVPR_GLContextType, api, 4, false, FLAGS_gpu_threading);
|
|
|
|
SINK("nvprmsaa16", GPUSink, Gr::kNVPR_GLContextType, api, 16, false, FLAGS_gpu_threading);
|
2015-01-15 18:56:12 +00:00
|
|
|
#if SK_ANGLE
|
2015-08-27 17:38:39 +00:00
|
|
|
SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0, false, FLAGS_gpu_threading);
|
|
|
|
#endif
|
|
|
|
#if SK_COMMAND_BUFFER
|
|
|
|
SINK("commandbuffer", GPUSink, Gr::kCommandBuffer_GLContextType, api, 0, false, FLAGS_gpu_threading);
|
2015-01-15 18:56:12 +00:00
|
|
|
#endif
|
|
|
|
#if SK_MESA
|
2015-08-27 17:38:39 +00:00
|
|
|
SINK("mesa", GPUSink, Gr::kMESA_GLContextType, api, 0, false, FLAGS_gpu_threading);
|
2015-01-15 18:56:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-23 20:18:05 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
|
|
|
SINK("hwui", HWUISink);
|
|
|
|
#endif
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
if (FLAGS_cpu) {
|
|
|
|
SINK("565", RasterSink, kRGB_565_SkColorType);
|
|
|
|
SINK("8888", RasterSink, kN32_SkColorType);
|
2015-01-20 21:34:39 +00:00
|
|
|
SINK("pdf", PDFSink);
|
2015-01-28 19:35:18 +00:00
|
|
|
SINK("skp", SKPSink);
|
2015-02-01 04:00:58 +00:00
|
|
|
SINK("svg", SVGSink);
|
|
|
|
SINK("null", NullSink);
|
2015-03-03 17:13:09 +00:00
|
|
|
SINK("xps", XPSSink);
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
|
|
|
#undef SINK
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Sink* create_via(const char* tag, Sink* wrapped) {
|
|
|
|
#define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__); }
|
2015-08-27 14:41:13 +00:00
|
|
|
VIA("twice", ViaTwice, wrapped);
|
|
|
|
VIA("pipe", ViaPipe, wrapped);
|
|
|
|
VIA("serialize", ViaSerialization, wrapped);
|
|
|
|
VIA("2ndpic", ViaSecondPicture, wrapped);
|
2015-05-05 19:59:56 +00:00
|
|
|
VIA("sp", ViaSingletonPictures, wrapped);
|
2015-08-27 14:41:13 +00:00
|
|
|
VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped);
|
2015-01-21 21:18:51 +00:00
|
|
|
VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped);
|
2015-01-15 18:56:12 +00:00
|
|
|
|
2015-02-17 19:13:33 +00:00
|
|
|
if (FLAGS_matrix.count() == 4) {
|
2015-01-15 18:56:12 +00:00
|
|
|
SkMatrix m;
|
2015-02-17 19:13:33 +00:00
|
|
|
m.reset();
|
|
|
|
m.setScaleX((SkScalar)atof(FLAGS_matrix[0]));
|
|
|
|
m.setSkewX ((SkScalar)atof(FLAGS_matrix[1]));
|
|
|
|
m.setSkewY ((SkScalar)atof(FLAGS_matrix[2]));
|
|
|
|
m.setScaleY((SkScalar)atof(FLAGS_matrix[3]));
|
|
|
|
VIA("matrix", ViaMatrix, m, wrapped);
|
|
|
|
VIA("upright", ViaUpright, m, wrapped);
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2015-03-05 16:01:07 +00:00
|
|
|
|
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
|
|
|
VIA("androidsdk", ViaAndroidSDK, wrapped);
|
|
|
|
#endif
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
#undef VIA
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2014-07-28 14:21:24 +00:00
|
|
|
}
|
2014-05-14 17:55:32 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
static void gather_sinks() {
|
|
|
|
for (int i = 0; i < FLAGS_config.count(); i++) {
|
|
|
|
const char* config = FLAGS_config[i];
|
|
|
|
SkTArray<SkString> parts;
|
|
|
|
SkStrSplit(config, "-", &parts);
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
Sink* sink = nullptr;
|
2015-01-15 18:56:12 +00:00
|
|
|
for (int i = parts.count(); i-- > 0;) {
|
|
|
|
const char* part = parts[i].c_str();
|
2015-08-27 14:41:13 +00:00
|
|
|
Sink* next = (sink == nullptr) ? create_sink(part) : create_via(part, sink);
|
|
|
|
if (next == nullptr) {
|
2015-01-15 18:56:12 +00:00
|
|
|
SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part);
|
|
|
|
delete sink;
|
2015-08-27 14:41:13 +00:00
|
|
|
sink = nullptr;
|
2015-01-15 18:56:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
sink = next;
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
if (sink) {
|
|
|
|
push_sink(config, sink);
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2014-05-14 17:55:32 +00:00
|
|
|
}
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2014-05-14 17:55:32 +00:00
|
|
|
|
2015-08-24 20:27:01 +00:00
|
|
|
static bool dump_png(SkBitmap bitmap, const char* path, const char* md5) {
|
|
|
|
const int w = bitmap.width(),
|
|
|
|
h = bitmap.height();
|
|
|
|
|
|
|
|
// First get the bitmap into N32 color format. The next step will work only there.
|
|
|
|
if (bitmap.colorType() != kN32_SkColorType) {
|
|
|
|
SkBitmap n32;
|
|
|
|
if (!bitmap.copyTo(&n32, kN32_SkColorType)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bitmap = n32;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert our N32 bitmap into unpremul RGBA for libpng.
|
|
|
|
SkAutoTMalloc<uint32_t> rgba(w*h);
|
|
|
|
if (!bitmap.readPixels(SkImageInfo::Make(w,h, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType),
|
|
|
|
rgba, 4*w, 0,0)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We don't need bitmap anymore. Might as well drop our ref.
|
2015-08-24 21:13:29 +00:00
|
|
|
bitmap.reset();
|
2015-08-24 20:27:01 +00:00
|
|
|
|
2015-08-25 17:56:08 +00:00
|
|
|
FILE* f = fopen(path, "wb");
|
2015-08-24 20:27:01 +00:00
|
|
|
if (!f) { return false; }
|
|
|
|
|
|
|
|
png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
|
|
|
|
if (!png) {
|
|
|
|
fclose(f);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
png_infop info = png_create_info_struct(png);
|
|
|
|
if (!info) {
|
|
|
|
png_destroy_write_struct(&png, &info);
|
|
|
|
fclose(f);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
png_text text[2];
|
|
|
|
text[0].key = (png_charp)"Author";
|
|
|
|
text[0].text = (png_charp)"DM dump_png()";
|
|
|
|
text[0].compression = PNG_TEXT_COMPRESSION_NONE;
|
|
|
|
text[1].key = (png_charp)"Description";
|
|
|
|
text[1].text = (png_charp)md5;
|
|
|
|
text[1].compression = PNG_TEXT_COMPRESSION_NONE;
|
|
|
|
png_set_text(png, info, text, 2);
|
|
|
|
|
|
|
|
png_init_io(png, f);
|
|
|
|
png_set_IHDR(png, info, (png_uint_32)w, (png_uint_32)h, 8,
|
|
|
|
PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
|
|
|
|
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
|
|
|
png_write_info(png, info);
|
|
|
|
for (int j = 0; j < h; j++) {
|
|
|
|
png_bytep row = (png_bytep)(rgba.get() + w*j);
|
|
|
|
png_write_rows(png, &row, 1);
|
|
|
|
}
|
|
|
|
png_write_end(png, info);
|
|
|
|
|
|
|
|
png_destroy_write_struct(&png, &info);
|
|
|
|
fclose(f);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-15 21:44:22 +00:00
|
|
|
static bool match(const char* needle, const char* haystack) {
|
2015-08-27 14:41:13 +00:00
|
|
|
return 0 == strcmp("_", needle) || nullptr != strstr(haystack, needle);
|
2015-01-15 21:44:22 +00:00
|
|
|
}
|
|
|
|
|
2015-04-03 14:24:48 +00:00
|
|
|
static ImplicitString is_blacklisted(const char* sink, const char* src,
|
|
|
|
const char* srcOptions, const char* name) {
|
2015-04-03 14:51:00 +00:00
|
|
|
for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) {
|
2015-01-15 21:44:22 +00:00
|
|
|
if (match(FLAGS_blacklist[i+0], sink) &&
|
2015-04-03 14:24:48 +00:00
|
|
|
match(FLAGS_blacklist[i+1], src) &&
|
|
|
|
match(FLAGS_blacklist[i+2], srcOptions) &&
|
|
|
|
match(FLAGS_blacklist[i+3], name)) {
|
|
|
|
return SkStringPrintf("%s %s %s %s",
|
|
|
|
FLAGS_blacklist[i+0], FLAGS_blacklist[i+1],
|
|
|
|
FLAGS_blacklist[i+2], FLAGS_blacklist[i+3]);
|
2015-01-15 21:44:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
// The finest-grained unit of work we can run: draw a single Src into a single Sink,
|
|
|
|
// report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream.
|
|
|
|
struct Task {
|
2015-07-29 13:37:28 +00:00
|
|
|
Task(const TaggedSrc& src, const TaggedSink& sink) : src(src), sink(sink) {}
|
|
|
|
const TaggedSrc& src;
|
|
|
|
const TaggedSink& sink;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
|
|
|
static void Run(Task* task) {
|
2015-01-15 21:44:22 +00:00
|
|
|
SkString name = task->src->name();
|
2015-07-29 13:37:28 +00:00
|
|
|
|
|
|
|
// We'll skip drawing this Src/Sink pair if:
|
|
|
|
// - the Src vetoes the Sink;
|
|
|
|
// - this Src / Sink combination is on the blacklist;
|
|
|
|
// - it's a dry run.
|
2015-07-31 13:43:04 +00:00
|
|
|
SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : "");
|
2015-09-01 21:57:57 +00:00
|
|
|
SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag.c_str(),
|
|
|
|
task->src.options.c_str(), name.c_str());
|
2015-03-18 12:27:14 +00:00
|
|
|
if (!whyBlacklisted.isEmpty()) {
|
|
|
|
note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
|
|
|
|
}
|
2015-07-29 13:37:28 +00:00
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
SkString log;
|
2015-01-15 18:56:12 +00:00
|
|
|
WallTimer timer;
|
|
|
|
timer.start();
|
2015-07-29 13:37:28 +00:00
|
|
|
if (!FLAGS_dryRun && note.isEmpty()) {
|
2015-01-15 18:56:12 +00:00
|
|
|
SkBitmap bitmap;
|
|
|
|
SkDynamicMemoryWStream stream;
|
2015-06-04 21:15:33 +00:00
|
|
|
if (FLAGS_pre_log) {
|
|
|
|
SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag);
|
|
|
|
}
|
2015-04-03 14:24:48 +00:00
|
|
|
start(task->sink.tag, task->src.tag, task->src.options, name.c_str());
|
2015-02-03 02:26:03 +00:00
|
|
|
Error err = task->sink->draw(*task->src, &bitmap, &stream, &log);
|
2015-01-15 18:56:12 +00:00
|
|
|
if (!err.isEmpty()) {
|
2015-03-05 16:40:28 +00:00
|
|
|
timer.end();
|
|
|
|
if (err.isFatal()) {
|
2015-04-03 14:24:48 +00:00
|
|
|
fail(SkStringPrintf("%s %s %s %s: %s",
|
2015-03-05 16:40:28 +00:00
|
|
|
task->sink.tag,
|
2015-09-01 21:57:57 +00:00
|
|
|
task->src.tag.c_str(),
|
|
|
|
task->src.options.c_str(),
|
2015-03-05 16:40:28 +00:00
|
|
|
name.c_str(),
|
|
|
|
err.c_str()));
|
2015-03-18 12:27:14 +00:00
|
|
|
} else {
|
|
|
|
note.appendf(" (skipped: %s)", err.c_str());
|
2015-03-05 16:40:28 +00:00
|
|
|
}
|
2015-04-03 14:24:48 +00:00
|
|
|
done(timer.fWall, task->sink.tag, task->src.tag, task->src.options,
|
|
|
|
name, note, log);
|
2015-03-05 16:40:28 +00:00
|
|
|
return;
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
2015-01-27 22:46:26 +00:00
|
|
|
SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream());
|
|
|
|
|
|
|
|
SkString md5;
|
|
|
|
if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) {
|
|
|
|
SkMD5 hash;
|
|
|
|
if (data->getLength()) {
|
|
|
|
hash.writeStream(data, data->getLength());
|
|
|
|
data->rewind();
|
|
|
|
} else {
|
DM: swizzle BGRA to RGBA before calculating pixel MD5.
We name our .pngs by pixel hashes for gold. For 8888 images, we're hashing
SkPMColors, which have platform-dependent order: BGRA on Linux and Windows,
RGBA otherwise. This means we can end up with pixel-identical pngs with
different hashes, which is confusing.
This CL standardizes on RGBA for 8888 configs, arbitrarily chosen so that
Android ends up a no-op. Long-term, this should eliminate most of the
0-pixel-diff problems we see on gold.skia.org. There are other ways to end up
with the same .png from different SkBitmaps (think, red 565 square vs. red 8888
square) but they're rather less common / likely.
This will temporarily create a giant 0-pixel-diff problem on gold.skia.org.
Any Linux or Windows images which are not already pixel-identical to a Mac or
Android image should show up as untriaged hashes that are pixel-identical to
their version just before landing (we're only changing the hash, not the .png).
This means anything vaguely platform dependent (fonts, GPUs) will probably show
up as needing a triage but with a zero diff from a previous image.
If this goes well, we might do the same for 565. Just want to leave them out
for now to cut down on the triaging I need to do in one go.
BUG=skia:
Review URL: https://codereview.chromium.org/1226933005
2015-07-08 14:25:27 +00:00
|
|
|
// If we're BGRA (Linux, Windows), swizzle over to RGBA (Mac, Android).
|
|
|
|
// This helps eliminate multiple 0-pixel-diff hashes on gold.skia.org.
|
|
|
|
// (Android's general slow speed breaks the tie arbitrarily in RGBA's favor.)
|
|
|
|
// We might consider promoting 565 to RGBA too.
|
|
|
|
if (bitmap.colorType() == kBGRA_8888_SkColorType) {
|
|
|
|
SkBitmap swizzle;
|
|
|
|
SkAssertResult(bitmap.copyTo(&swizzle, kRGBA_8888_SkColorType));
|
|
|
|
hash.write(swizzle.getPixels(), swizzle.getSize());
|
|
|
|
} else {
|
|
|
|
hash.write(bitmap.getPixels(), bitmap.getSize());
|
|
|
|
}
|
2015-01-27 22:46:26 +00:00
|
|
|
}
|
|
|
|
SkMD5::Digest digest;
|
|
|
|
hash.finish(digest);
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
md5.appendf("%02x", digest.data[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!FLAGS_readPath.isEmpty() &&
|
2015-09-01 21:57:57 +00:00
|
|
|
!gGold.contains(Gold(task->sink.tag, task->src.tag.c_str(),
|
|
|
|
task->src.options.c_str(), name, md5))) {
|
2015-04-03 14:24:48 +00:00
|
|
|
fail(SkStringPrintf("%s not found for %s %s %s %s in %s",
|
2015-01-27 22:46:26 +00:00
|
|
|
md5.c_str(),
|
|
|
|
task->sink.tag,
|
2015-09-01 21:57:57 +00:00
|
|
|
task->src.tag.c_str(),
|
|
|
|
task->src.options.c_str(),
|
2015-01-27 22:46:26 +00:00
|
|
|
name.c_str(),
|
|
|
|
FLAGS_readPath[0]));
|
|
|
|
}
|
|
|
|
|
2015-04-07 20:38:48 +00:00
|
|
|
if (!FLAGS_writePath.isEmpty()) {
|
2015-01-15 18:56:12 +00:00
|
|
|
const char* ext = task->sink->fileExtension();
|
2015-01-27 22:46:26 +00:00
|
|
|
if (data->getLength()) {
|
2015-08-27 14:41:13 +00:00
|
|
|
WriteToDisk(*task, md5, ext, data, data->getLength(), nullptr);
|
2015-01-30 19:00:12 +00:00
|
|
|
SkASSERT(bitmap.drawsNothing());
|
|
|
|
} else if (!bitmap.drawsNothing()) {
|
2015-08-27 14:41:13 +00:00
|
|
|
WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap);
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
timer.end();
|
2015-09-01 21:57:57 +00:00
|
|
|
done(timer.fWall, task->sink.tag, task->src.tag.c_str(), task->src.options.c_str(), name,
|
|
|
|
note, log);
|
2014-12-13 00:41:12 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
static void WriteToDisk(const Task& task,
|
2015-01-27 22:46:26 +00:00
|
|
|
SkString md5,
|
|
|
|
const char* ext,
|
2015-01-15 18:56:12 +00:00
|
|
|
SkStream* data, size_t len,
|
2015-01-27 22:46:26 +00:00
|
|
|
const SkBitmap* bitmap) {
|
2015-01-15 18:56:12 +00:00
|
|
|
JsonWriter::BitmapResult result;
|
2015-04-03 14:24:48 +00:00
|
|
|
result.name = task.src->name();
|
|
|
|
result.config = task.sink.tag;
|
|
|
|
result.sourceType = task.src.tag;
|
|
|
|
result.sourceOptions = task.src.options;
|
|
|
|
result.ext = ext;
|
|
|
|
result.md5 = md5;
|
2015-01-15 18:56:12 +00:00
|
|
|
JsonWriter::AddBitmapResult(result);
|
2015-01-15 16:30:25 +00:00
|
|
|
|
2015-04-07 20:38:48 +00:00
|
|
|
// If an MD5 is uninteresting, we want it noted in the JSON file,
|
|
|
|
// but don't want to dump it out as a .png (or whatever ext is).
|
|
|
|
if (gUninterestingHashes.contains(md5)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
const char* dir = FLAGS_writePath[0];
|
|
|
|
if (0 == strcmp(dir, "@")) { // Needed for iOS.
|
|
|
|
dir = FLAGS_resourcePath[0];
|
|
|
|
}
|
|
|
|
sk_mkdir(dir);
|
|
|
|
|
|
|
|
SkString path;
|
|
|
|
if (FLAGS_nameByHash) {
|
|
|
|
path = SkOSPath::Join(dir, result.md5.c_str());
|
|
|
|
path.append(".");
|
|
|
|
path.append(ext);
|
|
|
|
if (sk_exists(path.c_str())) {
|
|
|
|
return; // Content-addressed. If it exists already, we're done.
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
path = SkOSPath::Join(dir, task.sink.tag);
|
|
|
|
sk_mkdir(path.c_str());
|
2015-09-01 21:57:57 +00:00
|
|
|
path = SkOSPath::Join(path.c_str(), task.src.tag.c_str());
|
2015-01-15 18:56:12 +00:00
|
|
|
sk_mkdir(path.c_str());
|
2015-09-01 21:57:57 +00:00
|
|
|
if (strcmp(task.src.options.c_str(), "") != 0) {
|
|
|
|
path = SkOSPath::Join(path.c_str(), task.src.options.c_str());
|
2015-04-03 14:24:48 +00:00
|
|
|
sk_mkdir(path.c_str());
|
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
path = SkOSPath::Join(path.c_str(), task.src->name().c_str());
|
|
|
|
path.append(".");
|
|
|
|
path.append(ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bitmap) {
|
2015-08-24 20:27:01 +00:00
|
|
|
if (!dump_png(*bitmap, path.c_str(), result.md5.c_str())) {
|
2015-01-15 18:56:12 +00:00
|
|
|
fail(SkStringPrintf("Can't encode PNG to %s.\n", path.c_str()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2015-08-24 20:27:01 +00:00
|
|
|
SkFILEWStream file(path.c_str());
|
|
|
|
if (!file.isValid()) {
|
|
|
|
fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str()));
|
|
|
|
return;
|
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
if (!file.writeStream(data, len)) {
|
|
|
|
fail(SkStringPrintf("Can't write to %s.\n", path.c_str()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
};
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
// Run all tasks in the same enclave serially on the same thread.
|
|
|
|
// They can't possibly run concurrently with each other.
|
|
|
|
static void run_enclave(SkTArray<Task>* tasks) {
|
|
|
|
for (int i = 0; i < tasks->count(); i++) {
|
|
|
|
Task::Run(tasks->begin() + i);
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
|
|
|
// Unit tests don't fit so well into the Src/Sink model, so we give them special treatment.
|
|
|
|
|
2015-01-21 23:50:13 +00:00
|
|
|
static SkTDArray<skiatest::Test> gThreadedTests, gGPUTests;
|
2015-01-15 18:56:12 +00:00
|
|
|
|
|
|
|
static void gather_tests() {
|
2015-01-20 21:47:23 +00:00
|
|
|
if (!FLAGS_src.contains("tests")) {
|
2015-01-15 18:56:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-04-27 15:45:01 +00:00
|
|
|
for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) {
|
|
|
|
if (!in_shard()) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-01-20 17:30:20 +00:00
|
|
|
// Despite its name, factory() is returning a reference to
|
|
|
|
// link-time static const POD data.
|
|
|
|
const skiatest::Test& test = r->factory();
|
|
|
|
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) {
|
2015-01-15 18:56:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
2015-01-20 17:30:20 +00:00
|
|
|
if (test.needsGpu && gpu_supported()) {
|
2015-01-21 23:50:13 +00:00
|
|
|
(FLAGS_gpu_threading ? gThreadedTests : gGPUTests).push(test);
|
2015-01-20 17:30:20 +00:00
|
|
|
} else if (!test.needsGpu && FLAGS_cpu) {
|
2015-01-21 23:50:13 +00:00
|
|
|
gThreadedTests.push(test);
|
2015-01-15 20:46:02 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
2014-06-30 13:36:31 +00:00
|
|
|
}
|
|
|
|
|
2015-01-20 17:30:20 +00:00
|
|
|
static void run_test(skiatest::Test* test) {
|
|
|
|
struct : public skiatest::Reporter {
|
2015-03-26 01:17:31 +00:00
|
|
|
void reportFailed(const skiatest::Failure& failure) override {
|
2015-01-20 17:30:20 +00:00
|
|
|
fail(failure.toString());
|
|
|
|
JsonWriter::AddTestFailure(failure);
|
|
|
|
}
|
2015-03-26 01:17:31 +00:00
|
|
|
bool allowExtendedTest() const override {
|
2015-01-20 17:30:20 +00:00
|
|
|
return FLAGS_pathOpsExtended;
|
|
|
|
}
|
2015-03-26 01:17:31 +00:00
|
|
|
bool verbose() const override { return FLAGS_veryVerbose; }
|
2015-01-20 17:30:20 +00:00
|
|
|
} reporter;
|
2015-06-12 19:06:22 +00:00
|
|
|
|
|
|
|
SkString note;
|
|
|
|
SkString whyBlacklisted = is_blacklisted("_", "tests", "_", test->name);
|
|
|
|
if (!whyBlacklisted.isEmpty()) {
|
|
|
|
note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
|
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
WallTimer timer;
|
|
|
|
timer.start();
|
2015-06-12 19:06:22 +00:00
|
|
|
if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) {
|
2015-04-03 14:24:48 +00:00
|
|
|
start("unit", "test", "", test->name);
|
2015-01-21 23:50:13 +00:00
|
|
|
GrContextFactory factory;
|
2015-06-04 21:15:33 +00:00
|
|
|
if (FLAGS_pre_log) {
|
|
|
|
SkDebugf("\nRunning test %s", test->name);
|
|
|
|
}
|
2015-01-21 23:50:13 +00:00
|
|
|
test->proc(&reporter, &factory);
|
2014-02-26 23:01:57 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
timer.end();
|
2015-06-12 19:06:22 +00:00
|
|
|
done(timer.fWall, "unit", "test", "", test->name, note, "");
|
2015-01-15 18:15:02 +00:00
|
|
|
}
|
2014-02-26 23:01:57 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
|
2015-01-21 23:50:13 +00:00
|
|
|
// If we're isolating all GPU-bound work to one thread (the default), this function runs all that.
|
|
|
|
static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) {
|
|
|
|
run_enclave(tasks);
|
|
|
|
for (int i = 0; i < gGPUTests.count(); i++) {
|
|
|
|
run_test(&gGPUTests[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-12 13:28:54 +00:00
|
|
|
// Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've hung.
|
|
|
|
// This prints something every once in a while so that it knows we're still working.
|
2015-03-12 14:16:56 +00:00
|
|
|
static void start_keepalive() {
|
|
|
|
struct Loop {
|
|
|
|
static void forever(void*) {
|
|
|
|
for (;;) {
|
|
|
|
static const int kSec = 300;
|
|
|
|
#if defined(SK_BUILD_FOR_WIN)
|
|
|
|
Sleep(kSec * 1000);
|
|
|
|
#else
|
|
|
|
sleep(kSec);
|
|
|
|
#endif
|
2015-03-18 12:27:14 +00:00
|
|
|
SkString running;
|
|
|
|
{
|
|
|
|
SkAutoMutexAcquire lock(gRunningMutex);
|
|
|
|
for (int i = 0; i < gRunning.count(); i++) {
|
|
|
|
running.appendf("\n\t%s", gRunning[i].c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkDebugf("\nCurrently running:%s\n", running.c_str());
|
2015-03-12 14:16:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static SkThread* intentionallyLeaked = new SkThread(Loop::forever);
|
|
|
|
intentionallyLeaked->start();
|
2015-03-12 13:28:54 +00:00
|
|
|
}
|
|
|
|
|
2015-06-10 16:31:09 +00:00
|
|
|
#define PORTABLE_FONT_PREFIX "Toy Liberation "
|
|
|
|
|
|
|
|
static SkTypeface* create_from_name(const char familyName[], SkTypeface::Style style) {
|
|
|
|
if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX)
|
|
|
|
&& !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_PREFIX) - 1)) {
|
2015-07-24 19:09:25 +00:00
|
|
|
return sk_tool_utils::create_portable_typeface(familyName, style);
|
2015-06-10 16:31:09 +00:00
|
|
|
}
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2015-06-10 16:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef PORTABLE_FONT_PREFIX
|
|
|
|
|
|
|
|
extern SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style );
|
|
|
|
|
2015-01-15 18:15:02 +00:00
|
|
|
int dm_main();
|
|
|
|
int dm_main() {
|
|
|
|
SetupCrashHandler();
|
|
|
|
SkAutoGraphics ag;
|
|
|
|
SkTaskGroup::Enabler enabled(FLAGS_threads);
|
2015-06-10 16:31:09 +00:00
|
|
|
gCreateTypefaceDelegate = &create_from_name;
|
2015-01-15 16:30:25 +00:00
|
|
|
|
2015-03-12 14:16:56 +00:00
|
|
|
start_keepalive();
|
2015-03-12 13:28:54 +00:00
|
|
|
|
2015-01-27 22:46:26 +00:00
|
|
|
gather_gold();
|
2015-04-03 21:15:33 +00:00
|
|
|
gather_uninteresting_hashes();
|
2015-01-27 22:46:26 +00:00
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
gather_srcs();
|
|
|
|
gather_sinks();
|
|
|
|
gather_tests();
|
|
|
|
|
2015-01-21 23:50:13 +00:00
|
|
|
gPending = gSrcs.count() * gSinks.count() + gThreadedTests.count() + gGPUTests.count();
|
2015-01-15 18:56:12 +00:00
|
|
|
SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n",
|
2015-01-21 23:50:13 +00:00
|
|
|
gSrcs.count(), gSinks.count(), gThreadedTests.count() + gGPUTests.count(), gPending);
|
2015-01-15 18:56:12 +00:00
|
|
|
|
|
|
|
// We try to exploit as much parallelism as is safe. Most Src/Sink pairs run on any thread,
|
|
|
|
// but Sinks that identify as part of a particular enclave run serially on a single thread.
|
2015-01-15 20:46:02 +00:00
|
|
|
// CPU tests run on any thread. GPU tests depend on --gpu_threading.
|
2015-01-15 18:56:12 +00:00
|
|
|
SkTArray<Task> enclaves[kNumEnclaves];
|
|
|
|
for (int j = 0; j < gSinks.count(); j++) {
|
|
|
|
SkTArray<Task>& tasks = enclaves[gSinks[j]->enclave()];
|
|
|
|
for (int i = 0; i < gSrcs.count(); i++) {
|
|
|
|
tasks.push_back(Task(gSrcs[i], gSinks[j]));
|
|
|
|
}
|
2014-02-26 23:01:57 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 18:56:12 +00:00
|
|
|
SkTaskGroup tg;
|
2015-01-21 23:50:13 +00:00
|
|
|
tg.batch(run_test, gThreadedTests.begin(), gThreadedTests.count());
|
|
|
|
for (int i = 0; i < kNumEnclaves; i++) {
|
|
|
|
switch(i) {
|
|
|
|
case kAnyThread_Enclave:
|
|
|
|
tg.batch(Task::Run, enclaves[i].begin(), enclaves[i].count());
|
|
|
|
break;
|
|
|
|
case kGPU_Enclave:
|
|
|
|
tg.add(run_enclave_and_gpu_tests, &enclaves[i]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tg.add(run_enclave, &enclaves[i]);
|
|
|
|
break;
|
2015-01-15 20:46:02 +00:00
|
|
|
}
|
2015-01-21 23:50:13 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
tg.wait();
|
|
|
|
// At this point we're back in single-threaded land.
|
2015-06-15 13:48:30 +00:00
|
|
|
sk_tool_utils::release_portable_typefaces();
|
2013-10-16 13:02:15 +00:00
|
|
|
|
2015-01-15 22:20:41 +00:00
|
|
|
SkDebugf("\n");
|
2015-01-15 18:56:12 +00:00
|
|
|
if (gFailures.count() > 0) {
|
|
|
|
SkDebugf("Failures:\n");
|
|
|
|
for (int i = 0; i < gFailures.count(); i++) {
|
2015-01-15 23:47:33 +00:00
|
|
|
SkDebugf("\t%s\n", gFailures[i].c_str());
|
2015-01-15 18:56:12 +00:00
|
|
|
}
|
|
|
|
SkDebugf("%d failures\n", gFailures.count());
|
|
|
|
return 1;
|
2014-12-13 00:41:12 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
if (gPending > 0) {
|
|
|
|
SkDebugf("Hrm, we didn't seem to run everything we intended to! Please file a bug.\n");
|
|
|
|
return 1;
|
2014-07-31 12:58:44 +00:00
|
|
|
}
|
2015-01-15 18:56:12 +00:00
|
|
|
return 0;
|
2013-10-16 13:02:15 +00:00
|
|
|
}
|
2014-11-13 16:06:40 +00:00
|
|
|
|
2015-04-02 19:16:36 +00:00
|
|
|
#if !defined(SK_BUILD_FOR_IOS)
|
2014-11-13 16:06:40 +00:00
|
|
|
int main(int argc, char** argv) {
|
|
|
|
SkCommandLineFlags::Parse(argc, argv);
|
|
|
|
return dm_main();
|
|
|
|
}
|
|
|
|
#endif
|