diff options
author | Cary Clark <caryclark@skia.org> | 2017-10-20 12:14:33 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-20 16:49:57 +0000 |
commit | 6d6d603c812a6c9bb3e70157be909d355233ba6d (patch) | |
tree | 71f1700b4f93dc48d15736bc0f4eb19c458b5a19 /tests | |
parent | 5a83f590911f30b125bc6edce01a26ac971d6e1d (diff) |
make matrix serialization private
Moves readFromMemory, writeToMemory to private section.
No sign that these are called from google3, android,
chromium, but function names are common enough that
it's hard to know for sure.
These are used inside templates internally and for
testing, so it is not quite as simple as adding alternate
entry points in SkMatrixPriv.
R=reed@google.com
Bug: skia:6898
Change-Id: I1fac142f4bf0f38608ea93438c46f39147606c4d
Reviewed-on: https://skia-review.googlesource.com/62361
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/MatrixTest.cpp | 14 | ||||
-rw-r--r-- | tests/SerializationTest.cpp | 9 |
2 files changed, 14 insertions, 9 deletions
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp index 578e8b06cf..18d4908416 100644 --- a/tests/MatrixTest.cpp +++ b/tests/MatrixTest.cpp @@ -6,7 +6,7 @@ */ #include "SkMath.h" -#include "SkMatrix.h" +#include "SkMatrixPriv.h" #include "SkMatrixUtils.h" #include "SkPoint3.h" #include "SkRandom.h" @@ -141,20 +141,20 @@ static void test_matrix_recttorect(skiatest::Reporter* reporter) { static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) { // add 100 in case we have a bug, I don't want to kill my stack in the test - static const size_t kBufferSize = SkMatrix::kMaxFlattenSize + 100; + static const size_t kBufferSize = SkMatrixPriv::kMaxFlattenSize + 100; char buffer[kBufferSize]; - size_t size1 = m.writeToMemory(nullptr); - size_t size2 = m.writeToMemory(buffer); + size_t size1 = SkMatrixPriv::WriteToMemory(m, nullptr); + size_t size2 = SkMatrixPriv::WriteToMemory(m, buffer); REPORTER_ASSERT(reporter, size1 == size2); - REPORTER_ASSERT(reporter, size1 <= SkMatrix::kMaxFlattenSize); + REPORTER_ASSERT(reporter, size1 <= SkMatrixPriv::kMaxFlattenSize); SkMatrix m2; - size_t size3 = m2.readFromMemory(buffer, kBufferSize); + size_t size3 = SkMatrixPriv::ReadFromMemory(&m2, buffer, kBufferSize); REPORTER_ASSERT(reporter, size1 == size3); REPORTER_ASSERT(reporter, are_equal(reporter, m, m2)); char buffer2[kBufferSize]; - size3 = m2.writeToMemory(buffer2); + size3 = SkMatrixPriv::WriteToMemory(m2, buffer2); REPORTER_ASSERT(reporter, size1 == size3); REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); } diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp index 898b12f220..da3c47cfe9 100644 --- a/tests/SerializationTest.cpp +++ b/tests/SerializationTest.cpp @@ -14,6 +14,7 @@ #include "SkImageSource.h" #include "SkMakeUnique.h" #include "SkMallocPixelRef.h" +#include "SkMatrixPriv.h" #include "SkOSFile.h" #include "SkPictureRecorder.h" #include "SkShaderBase.h" @@ -29,6 +30,9 @@ static const uint32_t kArraySize = 64; static const int kBitmapSize = 256; +class SerializationTest { +public: + template<typename T> static void TestAlignment(T* testObj, skiatest::Reporter* reporter) { // Test memory read/write functions directly @@ -38,6 +42,7 @@ static void TestAlignment(T* testObj, skiatest::Reporter* reporter) { size_t bytesReadFromMemory = testObj->readFromMemory(dataWritten, bytesWrittenToMemory); REPORTER_ASSERT(reporter, SkAlign4(bytesReadFromMemory) == bytesReadFromMemory); } +}; template<typename T> struct SerializationUtils { // Generic case for flattenables @@ -183,7 +188,7 @@ static void TestObjectSerializationNoAlign(T* testObj, skiatest::Reporter* repor template<typename T> static void TestObjectSerialization(T* testObj, skiatest::Reporter* reporter) { TestObjectSerializationNoAlign<T, false>(testObj, reporter); - TestAlignment(testObj, reporter); + SerializationTest::TestAlignment(testObj, reporter); } template<typename T> @@ -467,7 +472,7 @@ DEF_TEST(Serialization, reporter) { SkRect rect = SkRect::MakeXYWH(1, 2, 20, 30); SkVector corners[4] = { {1, 2}, {2, 3}, {3,4}, {4,5} }; rrect.setRectRadii(rect, corners); - TestAlignment(&rrect, reporter); + SerializationTest::TestAlignment(&rrect, reporter); } // Test readByteArray |