diff options
author | Mike Reed <reed@google.com> | 2017-01-07 11:16:28 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-08 03:06:06 +0000 |
commit | ff80c2ab305a25434d17fbcbec02b20d69b05227 (patch) | |
tree | 0d0a1beaac4c14b85419d330b17078a0c870a2ba | |
parent | 1523dbdd7211561957eec466c87af84f1f2bf5c5 (diff) |
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>
-rw-r--r-- | include/core/SkStream.h | 14 | ||||
-rw-r--r-- | src/core/SkStream.cpp | 17 | ||||
-rw-r--r-- | tests/PathOpsExtendedTest.cpp | 43 | ||||
-rw-r--r-- | tests/PathOpsExtendedTest.h | 2 | ||||
-rw-r--r-- | tests/PathOpsOpCircleThreadedTest.cpp | 2 | ||||
-rw-r--r-- | tests/PathOpsOpCubicThreadedTest.cpp | 2 | ||||
-rw-r--r-- | tests/PathOpsOpLoopThreadedTest.cpp | 2 | ||||
-rw-r--r-- | tests/PathOpsOpRectThreadedTest.cpp | 2 | ||||
-rw-r--r-- | tests/PathOpsSimplifyDegenerateThreadedTest.cpp | 4 | ||||
-rw-r--r-- | tests/PathOpsSimplifyQuadThreadedTest.cpp | 4 | ||||
-rw-r--r-- | tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp | 4 | ||||
-rw-r--r-- | tests/PathOpsSimplifyRectThreadedTest.cpp | 4 | ||||
-rw-r--r-- | tests/PathOpsSimplifyTrianglesThreadedTest.cpp | 4 | ||||
-rw-r--r-- | tests/PathOpsThreadedCommon.h | 7 | ||||
-rw-r--r-- | tests/StreamTest.cpp | 8 |
15 files changed, 40 insertions, 79 deletions
diff --git a/include/core/SkStream.h b/include/core/SkStream.h index f3c99b72a3..419ef7b723 100644 --- a/include/core/SkStream.h +++ b/include/core/SkStream.h @@ -366,20 +366,6 @@ private: 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 202762a93d..db9caee541 100644 --- a/src/core/SkStream.cpp +++ b/src/core/SkStream.cpp @@ -431,23 +431,6 @@ void SkFILEWStream::fsync() //////////////////////////////////////////////////////////////////////// -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 9b08ba923b..abc1770efd 100644 --- a/tests/PathOpsExtendedTest.cpp +++ b/tests/PathOpsExtendedTest.cpp @@ -370,17 +370,16 @@ static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons 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 @@ static void outputToStream(const char* pathStr, const char* pathPrefix, const ch 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 @@ static void outputToStream(const char* pathStr, const char* pathPrefix, const ch writeTestName(nameSuffix, outFile); outFile.writeText("),\n"); #endif - outFile.flush(); } SK_DECLARE_STATIC_MUTEX(simplifyDebugOut); @@ -444,9 +439,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); - 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 @@ bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st 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 initializeTests(skiatest::Reporter* reporter, const char* test) { } } -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 @@ void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFill 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 35c14e78d7..9f8b0aeaac 100644 --- a/tests/PathOpsExtendedTest.h +++ b/tests/PathOpsExtendedTest.h @@ -49,8 +49,6 @@ extern bool testSimplifyFuzz(skiatest::Reporter* reporter, const SkPath& path, 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 40a02c111e..7711dd029a 100644 --- a/tests/PathOpsOpCircleThreadedTest.cpp +++ b/tests/PathOpsOpCircleThreadedTest.cpp @@ -45,7 +45,7 @@ static void testOpCirclesMain(PathOpsThreadState* data) { 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 e76eb06477..0bb8c19934 100644 --- a/tests/PathOpsOpCubicThreadedTest.cpp +++ b/tests/PathOpsOpCubicThreadedTest.cpp @@ -56,7 +56,7 @@ static void testOpCubicsMain(PathOpsThreadState* data) { 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 3854f90b08..04caac9926 100644 --- a/tests/PathOpsOpLoopThreadedTest.cpp +++ b/tests/PathOpsOpLoopThreadedTest.cpp @@ -76,7 +76,7 @@ static void testOpLoopsMain(PathOpsThreadState* data) { 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 57615727f8..e904a8d23e 100644 --- a/tests/PathOpsOpRectThreadedTest.cpp +++ b/tests/PathOpsOpRectThreadedTest.cpp @@ -64,7 +64,7 @@ static void testPathOpsRectsMain(PathOpsThreadState* data) 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 71933df8c3..3f49718c41 100644 --- a/tests/PathOpsSimplifyDegenerateThreadedTest.cpp +++ b/tests/PathOpsSimplifyDegenerateThreadedTest.cpp @@ -50,12 +50,12 @@ static void testSimplifyDegeneratesMain(PathOpsThreadState* data) { 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 bca8d5a8e4..55dc07b752 100644 --- a/tests/PathOpsSimplifyQuadThreadedTest.cpp +++ b/tests/PathOpsSimplifyQuadThreadedTest.cpp @@ -61,12 +61,12 @@ static void testSimplifyQuadsMain(PathOpsThreadState* data) 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 1ea55e24c0..61330429d4 100644 --- a/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp +++ b/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp @@ -63,12 +63,12 @@ static void testSimplifyQuadralateralsMain(PathOpsThreadState* data) 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 4ddc6f7f34..384d1b0cce 100644 --- a/tests/PathOpsSimplifyRectThreadedTest.cpp +++ b/tests/PathOpsSimplifyRectThreadedTest.cpp @@ -166,11 +166,11 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data) } 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 671616c2b9..372b667d9c 100644 --- a/tests/PathOpsSimplifyTrianglesThreadedTest.cpp +++ b/tests/PathOpsSimplifyTrianglesThreadedTest.cpp @@ -53,13 +53,13 @@ static void testSimplifyTrianglesMain(PathOpsThreadState* data) { 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 54586d95cc..8fe573f722 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 @@ struct PathOpsThreadState { 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 4b8923f399..4c1b3dfe98 100644 --- a/tests/StreamTest.cpp +++ b/tests/StreamTest.cpp @@ -146,18 +146,16 @@ static void TestPackedUInt(skiatest::Reporter* reporter) { 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); } |