aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@google.com>2017-04-14 07:46:07 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-14 14:37:16 +0000
commit389c557338afd82be5d87735b5ec1cf57e85b26c (patch)
tree67587953698e32ce8082d3d812a964c4901bebcb
parent479366cd148136dd0e5657ffc5816ab30f18fa3c (diff)
fix pathops_unittest test strings
Using std::string is tons faster than SkString; multiple callers to std::string don't run into thread contention but SkString does. R=csmartdalton@google.com Change-Id: I0357c6a9c73856bfffbb76e65c275acdfe7d8159 Reviewed-on: https://skia-review.googlesource.com/13471 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
-rw-r--r--tests/PathOpsExtendedTest.cpp26
-rw-r--r--tests/PathOpsThreadedCommon.h5
2 files changed, 23 insertions, 8 deletions
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp
index 8f24adf3ba..c668963185 100644
--- a/tests/PathOpsExtendedTest.cpp
+++ b/tests/PathOpsExtendedTest.cpp
@@ -21,6 +21,17 @@
#include <sys/sysctl.h>
#endif
+// std::to_string isn't implemented on android
+#include <sstream>
+
+template <typename T>
+std::string std_to_string(T value)
+{
+ std::ostringstream os ;
+ os << value ;
+ return os.str() ;
+}
+
bool OpDebug(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result
SkDEBUGPARAMS(bool skipAssert)
SkDEBUGPARAMS(const char* testName));
@@ -179,7 +190,7 @@ void ShowTestName(PathOpsThreadState* state, int a, int b, int c, int d) {
state->fSerialNo[8] = '\0';
SkDebugf("%s\n", state->fSerialNo);
if (strcmp(state->fSerialNo, state->fKey) == 0) {
- SkDebugf("%s\n", state->fPathStr);
+ SkDebugf("%s\n", state->fPathStr.c_str());
}
#endif
}
@@ -371,8 +382,9 @@ static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons
static int testNumber = 55;
static const char* testName = "pathOpTest";
-static void appendTestName(const char* nameSuffix, SkString& out) {
- out.appendf("%s%d", testName, testNumber);
+static void appendTestName(const char* nameSuffix, std::string& out) {
+ out += testName;
+ out += std_to_string(testNumber);
++testNumber;
if (nameSuffix) {
out.append(nameSuffix);
@@ -380,7 +392,7 @@ static void appendTestName(const char* nameSuffix, SkString& out) {
}
static void appendTest(const char* pathStr, const char* pathPrefix, const char* nameSuffix,
- const char* testFunction, bool twoPaths, SkString& out) {
+ const char* testFunction, bool twoPaths, std::string& out) {
#if 0
out.append("\n<div id=\"");
appendTestName(nameSuffix, out);
@@ -406,7 +418,9 @@ static void appendTest(const char* pathStr, const char* pathPrefix, const char*
if (pathPrefix) {
out.append(pathPrefix);
}
- out.appendf("%s %s\n}\n\n", pathStr, testFunction);
+ out += pathStr;
+ out += " ";
+ out += testFunction;
#if 0
out.append("static void (*firstTest)() = ");
appendTestName(nameSuffix, out);
@@ -440,7 +454,7 @@ bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st
int result = comparePaths(state.fReporter, nullptr, path, out, *state.fBitmap);
if (result) {
SkAutoMutexAcquire autoM(simplifyDebugOut);
- SkString str;
+ std::string str;
const char* pathPrefix = nullptr;
const char* nameSuffix = nullptr;
if (fillType == SkPath::kEvenOdd_FillType) {
diff --git a/tests/PathOpsThreadedCommon.h b/tests/PathOpsThreadedCommon.h
index 1462aa2251..706da6b110 100644
--- a/tests/PathOpsThreadedCommon.h
+++ b/tests/PathOpsThreadedCommon.h
@@ -11,9 +11,10 @@
#include "SkGraphics.h"
#include "SkPath.h"
#include "SkPathOps.h"
-#include "SkString.h"
#include "SkTDArray.h"
+#include <string>
+
#define PATH_STR_SIZE 512
class PathOpsThreadedRunnable;
@@ -27,7 +28,7 @@ struct PathOpsThreadState {
unsigned char fB;
unsigned char fC;
unsigned char fD;
- SkString fPathStr;
+ std::string fPathStr;
const char* fKey;
char fSerialNo[256];
skiatest::Reporter* fReporter;