remove SkMemoryWStream -- unused externally
BUG=skia:
Change-Id: Idbc9af4e703238871f56f623cd616fb7a5e686d3
Reviewed-on: https://skia-review.googlesource.com/6727
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index f3c99b7..419ef7b 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -366,20 +366,6 @@
typedef SkWStream INHERITED;
};
-class SK_API SkMemoryWStream : public SkWStream {
-public:
- SkMemoryWStream(void* buffer, size_t size);
- bool write(const void* buffer, size_t size) override;
- size_t bytesWritten() const override { return fBytesWritten; }
-
-private:
- char* fBuffer;
- size_t fMaxLength;
- size_t fBytesWritten;
-
- typedef SkWStream INHERITED;
-};
-
class SK_API SkDynamicMemoryWStream : public SkWStream {
public:
SkDynamicMemoryWStream();
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index 202762a..db9caee 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -431,23 +431,6 @@
////////////////////////////////////////////////////////////////////////
-SkMemoryWStream::SkMemoryWStream(void* buffer, size_t size)
- : fBuffer((char*)buffer), fMaxLength(size), fBytesWritten(0)
-{
-}
-
-bool SkMemoryWStream::write(const void* buffer, size_t size) {
- size = SkTMin(size, fMaxLength - fBytesWritten);
- if (size > 0) {
- memcpy(fBuffer + fBytesWritten, buffer, size);
- fBytesWritten += size;
- return true;
- }
- return false;
-}
-
-////////////////////////////////////////////////////////////////////////
-
static inline void sk_memcpy_4bytes(void* dst, const void* src, size_t size) {
if (size == 4) {
memcpy(dst, src, 4);
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp
index 9b08ba9..abc1770 100644
--- a/tests/PathOpsExtendedTest.cpp
+++ b/tests/PathOpsExtendedTest.cpp
@@ -370,17 +370,16 @@
static int testNumber = 55;
static const char* testName = "pathOpTest";
-static void writeTestName(const char* nameSuffix, SkMemoryWStream& outFile) {
- outFile.writeText(testName);
- outFile.writeDecAsText(testNumber);
+static void writeTestName(const char* nameSuffix, SkString& outFile) {
+ outFile.appendf("%s%d", testName, testNumber);
++testNumber;
if (nameSuffix) {
- outFile.writeText(nameSuffix);
+ outFile.append(nameSuffix);
}
}
static void outputToStream(const char* pathStr, const char* pathPrefix, const char* nameSuffix,
- const char* testFunction, bool twoPaths, SkMemoryWStream& outFile) {
+ const char* testFunction, bool twoPaths, SkString& outFile) {
#if 0
outFile.writeText("\n<div id=\"");
writeTestName(nameSuffix, outFile);
@@ -396,20 +395,17 @@
writeTestName(nameSuffix, outFile);
outFile.writeText(",\n\n\n");
#endif
- outFile.writeText("static void ");
+ outFile.append("static void ");
writeTestName(nameSuffix, outFile);
- outFile.writeText("(skiatest::Reporter* reporter) {\n SkPath path");
+ outFile.append("(skiatest::Reporter* reporter) {\n SkPath path");
if (twoPaths) {
- outFile.writeText(", pathB");
+ outFile.append(", pathB");
}
- outFile.writeText(";\n");
+ outFile.append(";\n");
if (pathPrefix) {
- outFile.writeText(pathPrefix);
+ outFile.append(pathPrefix);
}
- outFile.writeText(pathStr);
- outFile.writeText(" ");
- outFile.writeText(testFunction);
- outFile.writeText("\n}\n\n");
+ outFile.appendf("%s %s\n}\n\n", pathStr, testFunction);
#if 0
outFile.writeText("static void (*firstTest)() = ");
writeTestName(nameSuffix, outFile);
@@ -423,7 +419,6 @@
writeTestName(nameSuffix, outFile);
outFile.writeText("),\n");
#endif
- outFile.flush();
}
SK_DECLARE_STATIC_MUTEX(simplifyDebugOut);
@@ -444,9 +439,7 @@
int result = comparePaths(state.fReporter, nullptr, path, out, *state.fBitmap);
if (result) {
SkAutoMutexAcquire autoM(simplifyDebugOut);
- char temp[8192];
- sk_bzero(temp, sizeof(temp));
- SkMemoryWStream stream(temp, sizeof(temp));
+ SkString str;
const char* pathPrefix = nullptr;
const char* nameSuffix = nullptr;
if (fillType == SkPath::kEvenOdd_FillType) {
@@ -454,8 +447,8 @@
nameSuffix = "x";
}
const char testFunction[] = "testSimplify(reporter, path);";
- outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, stream);
- SkDebugf("%s", temp);
+ outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, str);
+ SkDebugf("%s", str.c_str());
REPORTER_ASSERT(state.fReporter, 0);
}
state.fReporter->bumpTestCount();
@@ -633,7 +626,7 @@
}
}
-void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFillType) {
+void PathOpsThreadState::outputProgress(const char* pathStr, SkPath::FillType pathFillType) {
const char testFunction[] = "testSimplify(path);";
const char* pathPrefix = nullptr;
const char* nameSuffix = nullptr;
@@ -641,16 +634,14 @@
pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n";
nameSuffix = "x";
}
- SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE);
- outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, rRamStream);
+ outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, fPathStr);
}
-void outputProgress(char* ramStr, const char* pathStr, SkPathOp op) {
+void PathOpsThreadState::outputProgress(const char* pathStr, SkPathOp op) {
const char testFunction[] = "testOp(path);";
SkASSERT((size_t) op < SK_ARRAY_COUNT(opSuffixes));
const char* nameSuffix = opSuffixes[op];
- SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE);
- outputToStream(pathStr, nullptr, nameSuffix, testFunction, true, rRamStream);
+ outputToStream(pathStr, nullptr, nameSuffix, testFunction, true, fPathStr);
}
void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count,
diff --git a/tests/PathOpsExtendedTest.h b/tests/PathOpsExtendedTest.h
index 35c14e78..9f8b0ae 100644
--- a/tests/PathOpsExtendedTest.h
+++ b/tests/PathOpsExtendedTest.h
@@ -49,8 +49,6 @@
const char* filename);
void initializeTests(skiatest::Reporter* reporter, const char* testName);
-void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType );
-void outputProgress(char* ramStr, const char* pathStr, SkPathOp op);
void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count,
void (*firstTest)(skiatest::Reporter* , const char* filename),
diff --git a/tests/PathOpsOpCircleThreadedTest.cpp b/tests/PathOpsOpCircleThreadedTest.cpp
index 40a02c1..7711dd0 100644
--- a/tests/PathOpsOpCircleThreadedTest.cpp
+++ b/tests/PathOpsOpCircleThreadedTest.cpp
@@ -45,7 +45,7 @@
pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
SkPathOpsDebug::OpStr((SkPathOp) op));
pathStr.appendf("}\n");
- outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op);
+ state.outputProgress(pathStr.c_str(), (SkPathOp) op);
}
if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "circles")) {
if (state.fReporter->verbose()) {
diff --git a/tests/PathOpsOpCubicThreadedTest.cpp b/tests/PathOpsOpCubicThreadedTest.cpp
index e76eb06..0bb8c19 100644
--- a/tests/PathOpsOpCubicThreadedTest.cpp
+++ b/tests/PathOpsOpCubicThreadedTest.cpp
@@ -56,7 +56,7 @@
pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
SkPathOpsDebug::OpStr((SkPathOp) op));
pathStr.appendf("}\n");
- outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op);
+ state.outputProgress(pathStr.c_str(), (SkPathOp) op);
}
if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubics")) {
if (state.fReporter->verbose()) {
diff --git a/tests/PathOpsOpLoopThreadedTest.cpp b/tests/PathOpsOpLoopThreadedTest.cpp
index 3854f90..04caac9 100644
--- a/tests/PathOpsOpLoopThreadedTest.cpp
+++ b/tests/PathOpsOpLoopThreadedTest.cpp
@@ -76,7 +76,7 @@
pathStr.appendf(" testPathOp(reporter, path, pathB, kIntersect_SkPathOp,"
" filename);\n");
pathStr.appendf("}\n");
- outputProgress(state.fPathStr, pathStr.c_str(), kIntersect_SkPathOp);
+ state.outputProgress(pathStr.c_str(), kIntersect_SkPathOp);
}
testPathOp(state.fReporter, pathA, pathB, kIntersect_SkPathOp, "loops");
}
diff --git a/tests/PathOpsOpRectThreadedTest.cpp b/tests/PathOpsOpRectThreadedTest.cpp
index 5761572..e904a8d 100644
--- a/tests/PathOpsOpRectThreadedTest.cpp
+++ b/tests/PathOpsOpRectThreadedTest.cpp
@@ -64,7 +64,7 @@
pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
SkPathOpsDebug::OpStr((SkPathOp) op));
pathStr.appendf("}\n\n");
- outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op);
+ state.outputProgress(pathStr.c_str(), (SkPathOp) op);
}
if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "rects")) {
if (state.fReporter->verbose()) {
diff --git a/tests/PathOpsSimplifyDegenerateThreadedTest.cpp b/tests/PathOpsSimplifyDegenerateThreadedTest.cpp
index 71933df..3f49718 100644
--- a/tests/PathOpsSimplifyDegenerateThreadedTest.cpp
+++ b/tests/PathOpsSimplifyDegenerateThreadedTest.cpp
@@ -50,12 +50,12 @@
pathStr.appendf(" path.lineTo(%d, %d);\n", ex, ey);
pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy);
pathStr.appendf(" path.close();\n");
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kWinding_FillType);
}
testSimplify(path, false, out, state, pathStr.c_str());
path.setFillType(SkPath::kEvenOdd_FillType);
if (state.fReporter->verbose()) {
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kEvenOdd_FillType);
}
testSimplify(path, true, out, state, pathStr.c_str());
}
diff --git a/tests/PathOpsSimplifyQuadThreadedTest.cpp b/tests/PathOpsSimplifyQuadThreadedTest.cpp
index bca8d5a..55dc07b 100644
--- a/tests/PathOpsSimplifyQuadThreadedTest.cpp
+++ b/tests/PathOpsSimplifyQuadThreadedTest.cpp
@@ -61,12 +61,12 @@
pathStr.appendf(" path.close();\n");
pathStr.appendf(" testSimplify(reporter, path, filename);\n");
pathStr.appendf("}\n");
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kWinding_FillType);
}
testSimplify(path, false, out, state, pathStr.c_str());
path.setFillType(SkPath::kEvenOdd_FillType);
if (state.fReporter->verbose()) {
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kEvenOdd_FillType);
}
testSimplify(path, true, out, state, pathStr.c_str());
}
diff --git a/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp b/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp
index 1ea55e2..6133042 100644
--- a/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp
+++ b/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp
@@ -63,12 +63,12 @@
pathStr.appendf(" path.close();\n");
pathStr.appendf(" testPathSimplify(reporter, path, filename);\n");
pathStr.appendf("}\n");
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kWinding_FillType);
}
testSimplify(path, false, out, state, pathStr.c_str());
path.setFillType(SkPath::kEvenOdd_FillType);
if (state.fReporter->verbose()) {
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kEvenOdd_FillType);
}
testSimplify(path, true, out, state, pathStr.c_str());
}
diff --git a/tests/PathOpsSimplifyRectThreadedTest.cpp b/tests/PathOpsSimplifyRectThreadedTest.cpp
index 4ddc6f7..384d1b0 100644
--- a/tests/PathOpsSimplifyRectThreadedTest.cpp
+++ b/tests/PathOpsSimplifyRectThreadedTest.cpp
@@ -166,11 +166,11 @@
}
path.close();
if (state.fReporter->verbose()) {
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kWinding_FillType);
}
testSimplify(path, false, out, state, pathStr.c_str());
if (state.fReporter->verbose()) {
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kEvenOdd_FillType);
}
testSimplify(path, true, out, state, pathStr.c_str());
}
diff --git a/tests/PathOpsSimplifyTrianglesThreadedTest.cpp b/tests/PathOpsSimplifyTrianglesThreadedTest.cpp
index 671616c..372b667 100644
--- a/tests/PathOpsSimplifyTrianglesThreadedTest.cpp
+++ b/tests/PathOpsSimplifyTrianglesThreadedTest.cpp
@@ -53,13 +53,13 @@
pathStr.appendf(" path.lineTo(%d, %d);\n", ex, ey);
pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy);
pathStr.appendf(" path.close();\n");
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kWinding_FillType);
}
ShowTestName(&state, d, e, f, 0);
testSimplify(path, false, out, state, pathStr.c_str());
path.setFillType(SkPath::kEvenOdd_FillType);
if (state.fReporter->verbose()) {
- outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
+ state.outputProgress(pathStr.c_str(), SkPath::kEvenOdd_FillType);
}
ShowTestName(&state, d, e, f, 1);
testSimplify(path, true, out, state, pathStr.c_str());
diff --git a/tests/PathOpsThreadedCommon.h b/tests/PathOpsThreadedCommon.h
index 54586d9..8fe573f 100644
--- a/tests/PathOpsThreadedCommon.h
+++ b/tests/PathOpsThreadedCommon.h
@@ -8,6 +8,8 @@
#define PathOpsThreadedCommon_DEFINED
#include "SkGraphics.h"
+#include "SkPath.h"
+#include "SkString.h"
#include "SkTDArray.h"
#define PATH_STR_SIZE 512
@@ -23,11 +25,14 @@
unsigned char fB;
unsigned char fC;
unsigned char fD;
- char* fPathStr;
+ SkString fPathStr;
const char* fKey;
char fSerialNo[256];
skiatest::Reporter* fReporter;
SkBitmap* fBitmap;
+
+ void outputProgress(const char* pathStr, SkPath::FillType);
+ void outputProgress(const char* pathStr, SkPathOp);
};
class PathOpsThreadedTestRunner {
diff --git a/tests/StreamTest.cpp b/tests/StreamTest.cpp
index 4b8923f..4c1b3df 100644
--- a/tests/StreamTest.cpp
+++ b/tests/StreamTest.cpp
@@ -146,18 +146,16 @@
size_t i;
- char buffer[sizeof(sizes) * 4];
+ SkDynamicMemoryWStream wstream;
- SkMemoryWStream wstream(buffer, sizeof(buffer));
for (i = 0; i < SK_ARRAY_COUNT(sizes); ++i) {
bool success = wstream.writePackedUInt(sizes[i]);
REPORTER_ASSERT(reporter, success);
}
- wstream.flush();
- SkMemoryStream rstream(buffer, sizeof(buffer));
+ std::unique_ptr<SkStreamAsset> rstream(wstream.detachAsStream());
for (i = 0; i < SK_ARRAY_COUNT(sizes); ++i) {
- size_t n = rstream.readPackedUInt();
+ size_t n = rstream->readPackedUInt();
if (sizes[i] != n) {
ERRORF(reporter, "sizes:%x != n:%x\n", i, sizes[i], n);
}