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
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 1ace7d1..c0f6da9 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -22,7 +22,6 @@
#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 @@
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 @@
}
// 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 c0471d5..01eaaeb 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 @@
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 @@
}
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 040f7a4..27f80ce 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 7a8308f..da63d42 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -159,6 +159,44 @@
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 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 @@
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 b088b4e..ed8db8e 100644
--- a/tools/flags/SkCommandLineFlags.cpp
+++ b/tools/flags/SkCommandLineFlags.cpp
@@ -303,34 +303,3 @@
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 51af933..d0e7450 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 @@
*/
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.