diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-23 17:56:20 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-23 17:56:20 +0000 |
commit | ed5eb4ef2aa1d6c705bc3ed466f9caba2a230a2b (patch) | |
tree | 36c7cfa134a2d4427e1216b3f73cb45c714a187f | |
parent | 2ccc3afa474f9485c39c2e863252ddaa3f35724b (diff) |
Revert r10280, which caused https://code.google.com/p/skia/issues/detail?id=1441
Review URL: https://codereview.chromium.org/19537005
git-svn-id: http://skia.googlecode.com/svn/trunk@10284 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | bench/benchmain.cpp | 35 | ||||
-rw-r--r-- | gm/gmmain.cpp | 41 | ||||
-rw-r--r-- | gyp/bench.gyp | 1 | ||||
-rw-r--r-- | tests/skia_test.cpp | 49 | ||||
-rw-r--r-- | tools/flags/SkCommandLineFlags.cpp | 31 | ||||
-rw-r--r-- | tools/flags/SkCommandLineFlags.h | 11 |
6 files changed, 109 insertions, 59 deletions
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp index 1ace7d108a..c0f6da90ec 100644 --- a/bench/benchmain.cpp +++ b/bench/benchmain.cpp @@ -22,7 +22,6 @@ class GrContext; #include "SkBenchLogger.h" #include "SkBenchmark.h" #include "SkCanvas.h" -#include "SkCommandLineFlags.h" #include "SkDeferredCanvas.h" #include "SkDevice.h" #include "SkColorPriv.h" @@ -271,6 +270,38 @@ static int findConfig(const char config[]) { return -1; } +static bool skip_name(const SkTDArray<const char*> array, const char name[]) { + // FIXME: this duplicates the logic in skia_test.cpp, gmmain.cpp -- consolidate + int count = array.count(); + size_t testLen = strlen(name); + bool anyExclude = count == 0; + for (int i = 0; i < array.count(); ++i) { + const char* matchName = array[i]; + size_t matchLen = strlen(matchName); + bool matchExclude, matchStart, matchEnd; + if ((matchExclude = matchName[0] == '~')) { + anyExclude = true; + matchName++; + matchLen--; + } + if ((matchStart = matchName[0] == '^')) { + matchName++; + matchLen--; + } + if ((matchEnd = matchName[matchLen - 1] == '$')) { + matchLen--; + } + if (matchStart ? (!matchEnd || matchLen == testLen) + && strncmp(name, matchName, matchLen) == 0 + : matchEnd ? matchLen <= testLen + && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 + : strstr(name, matchName) != 0) { + return matchExclude; + } + } + return !anyExclude; +} + static void help() { SkString configsStr; static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs); @@ -740,7 +771,7 @@ int tool_main(int argc, char** argv) { } // only run benchmarks if their name contains matchStr - if (SkCommandLineFlags::ShouldSkip(fMatches, bench->getName())) { + if (skip_name(fMatches, bench->getName())) { continue; } diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index c0471d5868..01eaaebffd 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -38,6 +38,8 @@ #include "SkTileGridPicture.h" #include "SamplePipeControllers.h" +__SK_FORCE_IMAGE_DECODER_LINKING; + #ifdef SK_BUILD_FOR_WIN // json includes xlocale which generates warning 4530 because we're compiling without // exceptions; see https://code.google.com/p/skia/issues/detail?id=1067 @@ -1408,6 +1410,38 @@ static int findConfig(const char config[]) { return -1; } +static bool skip_name(SkCommandLineFlags::StringArray array, const char name[]) { + // FIXME: this duplicates the logic in test/skia_test.cpp -- consolidate + int count = array.count(); + size_t testLen = strlen(name); + bool anyExclude = count == 0; + for (int i = 0; i < array.count(); ++i) { + const char* matchName = array[i]; + size_t matchLen = strlen(matchName); + bool matchExclude, matchStart, matchEnd; + if ((matchExclude = matchName[0] == '~')) { + anyExclude = true; + matchName++; + matchLen--; + } + if ((matchStart = matchName[0] == '^')) { + matchName++; + matchLen--; + } + if ((matchEnd = matchName[matchLen - 1] == '$')) { + matchLen--; + } + if (matchStart ? (!matchEnd || matchLen == testLen) + && strncmp(name, matchName, matchLen) == 0 + : matchEnd ? matchLen <= testLen + && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 + : strstr(name, matchName) != 0) { + return matchExclude; + } + } + return !anyExclude; +} + namespace skiagm { #if SK_SUPPORT_GPU SkAutoTUnref<GrContext> gGrContext; @@ -2042,12 +2076,7 @@ int tool_main(int argc, char** argv) { } const char* shortName = gm->shortName(); - - SkTDArray<const char*> matchStrs; - for (int i = 0; i < FLAGS_match.count(); ++i) { - matchStrs.push(FLAGS_match[i]); - } - if (SkCommandLineFlags::ShouldSkip(matchStrs, shortName)) { + if (skip_name(FLAGS_match, shortName)) { continue; } diff --git a/gyp/bench.gyp b/gyp/bench.gyp index 040f7a4fcf..27f80cead9 100644 --- a/gyp/bench.gyp +++ b/gyp/bench.gyp @@ -19,7 +19,6 @@ 'dependencies': [ 'skia_lib.gyp:skia_lib', 'bench_timer', - 'flags.gyp:flags', ], 'conditions': [ ['skia_gpu == 1', diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp index 7a8308f641..da63d42ea5 100644 --- a/tests/skia_test.cpp +++ b/tests/skia_test.cpp @@ -159,6 +159,44 @@ private: int32_t* fFailCount; }; +/* Takes a list of the form [~][^]match[$] + ~ causes a matching test to always be skipped + ^ requires the start of the test to match + $ requires the end of the test to match + ^ and $ requires an exact match + If a test does not match any list entry, it is skipped unless some list entry starts with ~ + */ +static bool shouldSkip(const char* testName) { + int count = FLAGS_match.count(); + size_t testLen = strlen(testName); + bool anyExclude = count == 0; + for (int index = 0; index < count; ++index) { + const char* matchName = FLAGS_match[index]; + size_t matchLen = strlen(matchName); + bool matchExclude, matchStart, matchEnd; + if ((matchExclude = matchName[0] == '~')) { + anyExclude = true; + matchName++; + matchLen--; + } + if ((matchStart = matchName[0] == '^')) { + matchName++; + matchLen--; + } + if ((matchEnd = matchName[matchLen - 1] == '$')) { + matchLen--; + } + if (matchStart ? (!matchEnd || matchLen == testLen) + && strncmp(testName, matchName, matchLen) == 0 + : matchEnd ? matchLen <= testLen + && strncmp(testName + testLen - matchLen, matchName, matchLen) == 0 + : strstr(testName, matchName) != 0) { + return matchExclude; + } + } + return !anyExclude; +} + int tool_main(int argc, char** argv); int tool_main(int argc, char** argv) { SkCommandLineFlags::SetUsage(""); @@ -206,16 +244,9 @@ int tool_main(int argc, char** argv) { int total = 0; int toRun = 0; Test* test; - - SkTDArray<const char*> matchStrs; - for(int i = 0; i < FLAGS_match.count(); ++i) { - matchStrs.push(FLAGS_match[i]); - } - while ((test = iter.next()) != NULL) { SkAutoTDelete<Test> owned(test); - - if(!SkCommandLineFlags::ShouldSkip(matchStrs, test->getName())) { + if(!shouldSkip(test->getName())) { toRun++; } total++; @@ -231,7 +262,7 @@ int tool_main(int argc, char** argv) { SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnable for (int i = 0; i < total; i++) { SkAutoTDelete<Test> test(iter.next()); - if (SkCommandLineFlags::ShouldSkip(matchStrs, test->getName())) { + if (shouldSkip(test->getName())) { ++skipCount; } else if (!test->isThreadsafe()) { unsafeTests.push_back() = test.detach(); diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp index b088b4e4d3..ed8db8e705 100644 --- a/tools/flags/SkCommandLineFlags.cpp +++ b/tools/flags/SkCommandLineFlags.cpp @@ -303,34 +303,3 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { exit(0); } } - -bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) { - int count = strings.count(); - size_t testLen = strlen(name); - bool anyExclude = count == 0; - for (int i = 0; i < strings.count(); ++i) { - const char* matchName = strings[i]; - size_t matchLen = strlen(matchName); - bool matchExclude, matchStart, matchEnd; - if ((matchExclude = matchName[0] == '~')) { - anyExclude = true; - matchName++; - matchLen--; - } - if ((matchStart = matchName[0] == '^')) { - matchName++; - matchLen--; - } - if ((matchEnd = matchName[matchLen - 1] == '$')) { - matchLen--; - } - if (matchStart ? (!matchEnd || matchLen == testLen) - && strncmp(name, matchName, matchLen) == 0 - : matchEnd ? matchLen <= testLen - && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 - : strstr(name, matchName) != 0) { - return matchExclude; - } - } - return !anyExclude; -} diff --git a/tools/flags/SkCommandLineFlags.h b/tools/flags/SkCommandLineFlags.h index 51af933467..d0e74502d8 100644 --- a/tools/flags/SkCommandLineFlags.h +++ b/tools/flags/SkCommandLineFlags.h @@ -10,7 +10,6 @@ #include "SkString.h" #include "SkTArray.h" -#include "SkTDArray.h" /** * Including this file (and compiling SkCommandLineFlags.cpp) provides command line @@ -91,6 +90,7 @@ * strings) so that a flag can be followed by multiple parameters. */ + class SkFlagInfo; class SkCommandLineFlags { @@ -108,15 +108,6 @@ public: */ static void Parse(int argc, char** argv); - /* Takes a list of the form [~][^]match[$] - ~ causes a matching test to always be skipped - ^ requires the start of the test to match - $ requires the end of the test to match - ^ and $ requires an exact match - If a test does not match any list entry, it is skipped unless some list entry starts with ~ - */ - static bool ShouldSkip(const SkTDArray<const char*>& strings, const char* name); - /** * Custom class for holding the arguments for a string flag. * Publicly only has accessors so the strings cannot be modified. |