diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/BitmapCopyTest.cpp | 13 | ||||
-rw-r--r-- | tests/GpuBitmapCopyTest.cpp | 2 | ||||
-rw-r--r-- | tests/Matrix44Test.cpp | 78 | ||||
-rw-r--r-- | tests/PathTest.cpp | 2 | ||||
-rw-r--r-- | tests/ShaderImageFilterTest.cpp | 3 | ||||
-rw-r--r-- | tests/Writer32Test.cpp | 10 | ||||
-rw-r--r-- | tests/XfermodeTest.cpp | 4 |
7 files changed, 61 insertions, 51 deletions
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp index bf0d2f7813..5cef1eb986 100644 --- a/tests/BitmapCopyTest.cpp +++ b/tests/BitmapCopyTest.cpp @@ -96,7 +96,7 @@ static uint32_t getPixel(int x, int y, const SkBitmap& bm) { SkAutoLockPixels lock(bm); const void* rawAddr = bm.getAddr(x,y); - switch (bm.getConfig()) { + switch (bm.config()) { case SkBitmap::kARGB_8888_Config: memcpy(&val, rawAddr, sizeof(uint32_t)); break; @@ -130,7 +130,7 @@ static void setPixel(int x, int y, uint32_t val, SkBitmap& bm) { SkAutoLockPixels lock(bm); void* rawAddr = bm.getAddr(x,y); - switch (bm.getConfig()) { + switch (bm.config()) { case SkBitmap::kARGB_8888_Config: memcpy(rawAddr, &val, sizeof(uint32_t)); break; @@ -162,7 +162,7 @@ static void setPixel(int x, int y, uint32_t val, SkBitmap& bm) { // Utility to return string containing name of each format, to // simplify diagnostic output. static const char* getSkConfigName(const SkBitmap& bm) { - switch (bm.getConfig()) { + switch (bm.config()) { case SkBitmap::kNo_Config: return "SkBitmap::kNo_Config"; case SkBitmap::kA1_Config: return "SkBitmap::kA1_Config"; case SkBitmap::kA8_Config: return "SkBitmap::kA8_Config"; @@ -458,7 +458,7 @@ static void TestBitmapCopy(skiatest::Reporter* reporter) { srcReady = src.extractSubset(&subset, r); } else { - srcReady = src.copyTo(&subset, src.getConfig()); + srcReady = src.copyTo(&subset, src.config()); } // Not all configurations will generate a valid 'subset'. @@ -469,7 +469,7 @@ static void TestBitmapCopy(skiatest::Reporter* reporter) { // buf to a SkBitmap, but copies are done using the // raw buffer pointer. const size_t bufSize = subH * - SkBitmap::ComputeRowBytes(src.getConfig(), subW) * 2; + SkBitmap::ComputeRowBytes(src.config(), subW) * 2; SkAutoMalloc autoBuf (bufSize); uint8_t* buf = static_cast<uint8_t*>(autoBuf.get()); @@ -496,8 +496,7 @@ static void TestBitmapCopy(skiatest::Reporter* reporter) { memset(buf, 0xFF, bufSize); // Config with stride greater than src but that fits in buf. bufBm.setConfig(gPairs[i].fConfig, subW, subH, - SkBitmap::ComputeRowBytes(subset.getConfig(), subW) - * 2); + SkBitmap::ComputeRowBytes(subset.config(), subW) * 2); bufBm.setPixels(buf); successExpected = false; // Then attempt to copy with a stride that is too large diff --git a/tests/GpuBitmapCopyTest.cpp b/tests/GpuBitmapCopyTest.cpp index 0d9cf2ba85..6e1d74dd97 100644 --- a/tests/GpuBitmapCopyTest.cpp +++ b/tests/GpuBitmapCopyTest.cpp @@ -139,7 +139,7 @@ static void TestGpuBitmapCopy(skiatest::Reporter* reporter, GrContextFactory* fa SkCanvas drawingCanvas(device); SkPaint paint; paint.setColor(SK_ColorRED); - drawingCanvas.drawRect(SkRect::MakeFromIRect(subsetRect), paint); + drawingCanvas.drawRect(SkRect::Make(subsetRect), paint); // Extract a subset. If this succeeds we will test copying the subset. SkBitmap subset; diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp index 772d7b2cf3..51a6e7f950 100644 --- a/tests/Matrix44Test.cpp +++ b/tests/Matrix44Test.cpp @@ -73,8 +73,7 @@ static bool nearly_equal(const SkMatrix44& a, const SkMatrix44& b) { } static bool is_identity(const SkMatrix44& m) { - SkMatrix44 identity; - identity.reset(); + SkMatrix44 identity(SkMatrix44::kIdentity_Constructor); return nearly_equal(m, identity); } @@ -85,7 +84,7 @@ static bool bits_isonly(int value, int mask) { static void test_constructor(skiatest::Reporter* reporter) { // Allocate a matrix on the heap - SkMatrix44* placeholderMatrix = new SkMatrix44(); + SkMatrix44* placeholderMatrix = new SkMatrix44(SkMatrix44::kUninitialized_Constructor); SkAutoTDelete<SkMatrix44> deleteMe(placeholderMatrix); for (int row = 0; row < 4; ++row) { @@ -115,7 +114,8 @@ static void test_constructor(skiatest::Reporter* reporter) { } static void test_translate(skiatest::Reporter* reporter) { - SkMatrix44 mat, inverse; + SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); mat.setTranslate(0, 0, 0); REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kIdentity_Mask)); @@ -124,7 +124,9 @@ static void test_translate(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, mat.invert(&inverse)); REPORTER_ASSERT(reporter, bits_isonly(inverse.getType(), SkMatrix44::kTranslate_Mask)); - SkMatrix44 a, b, c; + SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 c(SkMatrix44::kUninitialized_Constructor); a.set3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); b.setTranslate(10, 11, 12); @@ -140,7 +142,8 @@ static void test_translate(skiatest::Reporter* reporter) { } static void test_scale(skiatest::Reporter* reporter) { - SkMatrix44 mat, inverse; + SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); mat.setScale(1, 1, 1); REPORTER_ASSERT(reporter, bits_isonly(mat.getType(), SkMatrix44::kIdentity_Mask)); @@ -149,7 +152,9 @@ static void test_scale(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, mat.invert(&inverse)); REPORTER_ASSERT(reporter, bits_isonly(inverse.getType(), SkMatrix44::kScale_Mask)); - SkMatrix44 a, b, c; + SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 c(SkMatrix44::kUninitialized_Constructor); a.set3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); b.setScale(10, 11, 12); @@ -207,7 +212,7 @@ static void test_map2(skiatest::Reporter* reporter, const SkMatrix44& mat) { } static void test_map2(skiatest::Reporter* reporter) { - SkMatrix44 mat; + SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); for (size_t i = 0; i < SK_ARRAY_COUNT(gMakeProcs); ++i) { gMakeProcs[i](&mat); @@ -216,7 +221,7 @@ static void test_map2(skiatest::Reporter* reporter) { } static void test_gettype(skiatest::Reporter* reporter) { - SkMatrix44 matrix; + SkMatrix44 matrix(SkMatrix44::kIdentity_Constructor); REPORTER_ASSERT(reporter, matrix.isIdentity()); REPORTER_ASSERT(reporter, SkMatrix44::kIdentity_Mask == matrix.getType()); @@ -251,7 +256,7 @@ static void test_gettype(skiatest::Reporter* reporter) { } static void test_common_angles(skiatest::Reporter* reporter) { - SkMatrix44 rot; + SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor); // Test precision of rotation in common cases int common_angles[] = { 0, 90, -90, 180, -180, 270, -270, 360, -360 }; for (int i = 0; i < 9; ++i) { @@ -264,7 +269,10 @@ static void test_common_angles(skiatest::Reporter* reporter) { static void test_concat(skiatest::Reporter* reporter) { int i; - SkMatrix44 a, b, c, d; + SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 c(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 d(SkMatrix44::kUninitialized_Constructor); a.setTranslate(10, 10, 10); b.setScale(2, 2, 2); @@ -301,11 +309,11 @@ static void test_concat(skiatest::Reporter* reporter) { } static void test_determinant(skiatest::Reporter* reporter) { - SkMatrix44 a; + SkMatrix44 a(SkMatrix44::kIdentity_Constructor); REPORTER_ASSERT(reporter, nearly_equal_double(1, a.determinant())); a.set(1, 1, 2); REPORTER_ASSERT(reporter, nearly_equal_double(2, a.determinant())); - SkMatrix44 b; + SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); REPORTER_ASSERT(reporter, a.invert(&b)); REPORTER_ASSERT(reporter, nearly_equal_double(0.5, b.determinant())); SkMatrix44 c = b = a; @@ -326,11 +334,10 @@ static void test_determinant(skiatest::Reporter* reporter) { } static void test_invert(skiatest::Reporter* reporter) { - SkMatrix44 inverse; + SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); double inverseData[16]; - SkMatrix44 identity; - identity.setIdentity(); + SkMatrix44 identity(SkMatrix44::kIdentity_Constructor); identity.invert(&inverse); inverse.asRowMajord(inverseData); assert16<double>(reporter, inverseData, @@ -339,7 +346,7 @@ static void test_invert(skiatest::Reporter* reporter) { 0, 0, 1, 0, 0, 0, 0, 1); - SkMatrix44 translation; + SkMatrix44 translation(SkMatrix44::kUninitialized_Constructor); translation.setTranslate(2, 3, 4); translation.invert(&inverse); inverse.asRowMajord(inverseData); @@ -349,7 +356,7 @@ static void test_invert(skiatest::Reporter* reporter) { 0, 0, 1, -4, 0, 0, 0, 1); - SkMatrix44 scale; + SkMatrix44 scale(SkMatrix44::kUninitialized_Constructor); scale.setScale(2, 4, 8); scale.invert(&inverse); inverse.asRowMajord(inverseData); @@ -359,7 +366,7 @@ static void test_invert(skiatest::Reporter* reporter) { 0, 0, 0.125, 0, 0, 0, 0, 1); - SkMatrix44 scaleTranslation; + SkMatrix44 scaleTranslation(SkMatrix44::kUninitialized_Constructor); scaleTranslation.setScale(10, 100, 1000); scaleTranslation.preTranslate(2, 3, 4); scaleTranslation.invert(&inverse); @@ -370,10 +377,10 @@ static void test_invert(skiatest::Reporter* reporter) { 0, 0, 0.001, -4, 0, 0, 0, 1); - SkMatrix44 rotation; + SkMatrix44 rotation(SkMatrix44::kUninitialized_Constructor); rotation.setRotateDegreesAbout(0, 0, 1, 90); rotation.invert(&inverse); - SkMatrix44 expected; + SkMatrix44 expected(SkMatrix44::kUninitialized_Constructor); double expectedInverseRotation[16] = {0, 1, 0, 0, -1, 0, 0, 0, @@ -382,7 +389,7 @@ static void test_invert(skiatest::Reporter* reporter) { expected.setRowMajord(expectedInverseRotation); REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); - SkMatrix44 affine; + SkMatrix44 affine(SkMatrix44::kUninitialized_Constructor); affine.setRotateDegreesAbout(0, 0, 1, 90); affine.preScale(10, 20, 100); affine.preTranslate(2, 3, 4); @@ -395,8 +402,7 @@ static void test_invert(skiatest::Reporter* reporter) { expected.setRowMajord(expectedInverseAffine); REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); - SkMatrix44 perspective; - perspective.setIdentity(); + SkMatrix44 perspective(SkMatrix44::kIdentity_Constructor); perspective.setDouble(3, 2, 1.0); perspective.invert(&inverse); double expectedInversePerspective[16] = @@ -407,8 +413,7 @@ static void test_invert(skiatest::Reporter* reporter) { expected.setRowMajord(expectedInversePerspective); REPORTER_ASSERT(reporter, nearly_equal(expected, inverse)); - SkMatrix44 affineAndPerspective; - affineAndPerspective.setIdentity(); + SkMatrix44 affineAndPerspective(SkMatrix44::kIdentity_Constructor); affineAndPerspective.setDouble(3, 2, 1.0); affineAndPerspective.preScale(10, 20, 100); affineAndPerspective.preTranslate(2, 3, 4); @@ -423,8 +428,8 @@ static void test_invert(skiatest::Reporter* reporter) { } static void test_transpose(skiatest::Reporter* reporter) { - SkMatrix44 a; - SkMatrix44 b; + SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); int i = 0; for (int row = 0; row < 4; ++row) { @@ -439,7 +444,7 @@ static void test_transpose(skiatest::Reporter* reporter) { } static void test_get_set_double(skiatest::Reporter* reporter) { - SkMatrix44 a; + SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); for (int row = 0; row < 4; ++row) { for (int col = 0; col < 4; ++col) { a.setDouble(row, col, 3.141592653589793); @@ -454,7 +459,9 @@ static void test_get_set_double(skiatest::Reporter* reporter) { } static void test_set_row_col_major(skiatest::Reporter* reporter) { - SkMatrix44 a, b, c, d; + SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); + for (int row = 0; row < 4; ++row) { for (int col = 0; col < 4; ++col) { a.setDouble(row, col, row * 4 + col); @@ -489,7 +496,7 @@ static void test_3x3_conversion(skiatest::Reporter* reporter) { 5, 6, 0, 8, 0, 0, 1, 0, 13, 14, 0, 16 }; - SkMatrix44 a44; + SkMatrix44 a44(SkMatrix44::kUninitialized_Constructor); a44.setRowMajor(values4x4); SkMatrix a33 = a44; @@ -498,7 +505,7 @@ static void test_3x3_conversion(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, expected33 == a33); SkMatrix44 a44flattened = a33; - SkMatrix44 expected44flattened; + SkMatrix44 expected44flattened(SkMatrix44::kUninitialized_Constructor); expected44flattened.setRowMajor(values4x4flattened); REPORTER_ASSERT(reporter, nearly_equal(a44flattened, expected44flattened)); @@ -522,9 +529,12 @@ static void test_3x3_conversion(skiatest::Reporter* reporter) { } static void TestMatrix44(skiatest::Reporter* reporter) { - SkMatrix44 mat, inverse, iden1, iden2, rot; + SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 iden1(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 iden2(SkMatrix44::kUninitialized_Constructor); + SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor); - mat.reset(); mat.setTranslate(1, 1, 1); mat.invert(&inverse); iden1.setConcat(mat, inverse); diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index 6544c0b8d7..d879ea6e33 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -1768,7 +1768,7 @@ static void write_and_read_back(skiatest::Reporter* reporter, const SkPath& p) { SkWriter32 writer(100); writer.writePath(p); - size_t size = writer.size(); + size_t size = writer.bytesWritten(); SkAutoMalloc storage(size); writer.flatten(storage.get()); SkReader32 reader(storage.get(), size); diff --git a/tests/ShaderImageFilterTest.cpp b/tests/ShaderImageFilterTest.cpp index 78aa796caa..49fc6e040b 100644 --- a/tests/ShaderImageFilterTest.cpp +++ b/tests/ShaderImageFilterTest.cpp @@ -37,7 +37,8 @@ static void test_asShaderMode(skiatest::Reporter* reporter) { SkShader* s = SkGradientShader::CreateRadial( center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode); SkPaint paint; - paint.setImageFilter(SkRectShaderImageFilter::Create(s, r))->unref(); + SkImageFilter::CropRect cr(r); + paint.setImageFilter(SkRectShaderImageFilter::Create(s, &cr))->unref(); canvasFilter.drawRect(r, paint); s->unref(); } diff --git a/tests/Writer32Test.cpp b/tests/Writer32Test.cpp index 8b4aba5ec3..15218378ec 100644 --- a/tests/Writer32Test.cpp +++ b/tests/Writer32Test.cpp @@ -86,7 +86,7 @@ static void test_ptr(skiatest::Reporter* reporter) { writer.writePtr(p1); writer.write8(0x66); - size_t size = writer.size(); + size_t size = writer.bytesWritten(); REPORTER_ASSERT(reporter, 2 * sizeof(void*) + 2 * sizeof(int32_t)); char buffer[32]; @@ -103,14 +103,14 @@ static void test_ptr(skiatest::Reporter* reporter) { static void test1(skiatest::Reporter* reporter, SkWriter32* writer) { const uint32_t data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; for (size_t i = 0; i < SK_ARRAY_COUNT(data); ++i) { - REPORTER_ASSERT(reporter, i*4 == writer->size()); + REPORTER_ASSERT(reporter, i*4 == writer->bytesWritten()); writer->write32(data[i]); uint32_t* addr = writer->peek32(i * 4); REPORTER_ASSERT(reporter, data[i] == *addr); } char buffer[sizeof(data)]; - REPORTER_ASSERT(reporter, sizeof(buffer) == writer->size()); + REPORTER_ASSERT(reporter, sizeof(buffer) == writer->bytesWritten()); writer->flatten(buffer); REPORTER_ASSERT(reporter, !memcmp(data, buffer, sizeof(buffer))); } @@ -124,7 +124,7 @@ static void test2(skiatest::Reporter* reporter, SkWriter32* writer) { len += SkWriter32::WriteStringSize(gStr, i); writer->writeString(gStr, i); } - REPORTER_ASSERT(reporter, writer->size() == len); + REPORTER_ASSERT(reporter, writer->bytesWritten() == len); SkAutoMalloc storage(len); writer->flatten(storage.get()); @@ -167,7 +167,7 @@ static void testWritePad(skiatest::Reporter* reporter, SkWriter32* writer) { } } - uint32_t totalBytes = writer->size(); + uint32_t totalBytes = writer->bytesWritten(); SkAutoMalloc readStorage(totalBytes); writer->flatten(readStorage.get()); diff --git a/tests/XfermodeTest.cpp b/tests/XfermodeTest.cpp index 620fbf4c93..7d23b8530a 100644 --- a/tests/XfermodeTest.cpp +++ b/tests/XfermodeTest.cpp @@ -23,7 +23,7 @@ static void test_asMode(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, reportedMode != mode); // test IsMode - REPORTER_ASSERT(reporter, SkXfermode::IsMode(xfer, &reportedMode)); + REPORTER_ASSERT(reporter, SkXfermode::AsMode(xfer, &reportedMode)); REPORTER_ASSERT(reporter, reportedMode == mode); // repeat that test, but with asMode instead @@ -41,7 +41,7 @@ static void test_asMode(skiatest::Reporter* reporter) { SkXfermode::Mode reportedMode = ILLEGAL_MODE; REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode)); REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE); - REPORTER_ASSERT(reporter, !SkXfermode::IsMode(bogusXfer, &reportedMode)); + REPORTER_ASSERT(reporter, !SkXfermode::AsMode(bogusXfer, &reportedMode)); REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE); bogusXfer->unref(); } |