Index: tests/DrawBitmapRectTest.cpp |
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp |
index 88b9437935cebe326a2ce51b0ebe7c7ecdfc91b0..2eb181960b36aacda4ceb2c8081c67be72ae2366 100644 |
--- a/tests/DrawBitmapRectTest.cpp |
+++ b/tests/DrawBitmapRectTest.cpp |
@@ -82,22 +82,24 @@ |
size->set(rand.nextU() & 0xFFFF, rand.nextU() & 0xFFFF); |
} |
+static bool treat_as_sprite(const SkMatrix& mat, const SkISize& size, |
+ unsigned bits) { |
+ return SkTreatAsSprite(mat, size.width(), size.height(), bits); |
+} |
+ |
static void test_treatAsSprite(skiatest::Reporter* reporter) { |
+ const unsigned bilerBits = kSkSubPixelBitsForBilerp; |
SkMatrix mat; |
SkISize size; |
SkRandom rand; |
- SkPaint noaaPaint; |
- SkPaint aaPaint; |
- aaPaint.setAntiAlias(true); |
- |
- // assert: translate-only no-aa can always be treated as sprite |
+ // assert: translate-only no-filter can always be treated as sprite |
for (int i = 0; i < 1000; ++i) { |
rand_matrix(&mat, rand, SkMatrix::kTranslate_Mask); |
for (int j = 0; j < 1000; ++j) { |
rand_size(&size, rand); |
- REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, noaaPaint)); |
+ REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, 0)); |
} |
} |
@@ -106,8 +108,8 @@ |
rand_matrix(&mat, rand, SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask); |
for (int j = 0; j < 1000; ++j) { |
rand_size(&size, rand); |
- REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, noaaPaint)); |
- REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
+ REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, 0)); |
+ REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); |
} |
} |
@@ -115,33 +117,33 @@ |
const SkScalar tooMuchSubpixel = 100.1f; |
mat.setTranslate(tooMuchSubpixel, 0); |
- REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
+ REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); |
mat.setTranslate(0, tooMuchSubpixel); |
- REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
+ REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); |
const SkScalar tinySubPixel = 100.02f; |
mat.setTranslate(tinySubPixel, 0); |
- REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, aaPaint)); |
+ REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); |
mat.setTranslate(0, tinySubPixel); |
- REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, aaPaint)); |
+ REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); |
const SkScalar twoThirds = SK_Scalar1 * 2 / 3; |
const SkScalar bigScale = (size.width() + twoThirds) / size.width(); |
mat.setScale(bigScale, bigScale); |
- REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, noaaPaint)); |
- REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
+ REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false)); |
+ REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); |
const SkScalar oneThird = SK_Scalar1 / 3; |
const SkScalar smallScale = (size.width() + oneThird) / size.width(); |
mat.setScale(smallScale, smallScale); |
- REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, noaaPaint)); |
- REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
+ REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); |
+ REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); |
const SkScalar oneFortyth = SK_Scalar1 / 40; |
const SkScalar tinyScale = (size.width() + oneFortyth) / size.width(); |
mat.setScale(tinyScale, tinyScale); |
- REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, noaaPaint)); |
- REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, aaPaint)); |
+ REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); |
+ REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); |
} |
static void assert_ifDrawnTo(skiatest::Reporter* reporter, |