Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1502)

Unified Diff: tests/DrawBitmapRectTest.cpp

Issue 1566943002: SkTreatAsSprite should take AA into account (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: SkLeftShift Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkMatrixUtils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DrawBitmapRectTest.cpp
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index 2eb181960b36aacda4ceb2c8081c67be72ae2366..88b9437935cebe326a2ce51b0ebe7c7ecdfc91b0 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -82,24 +82,22 @@ static void rand_size(SkISize* size, SkRandom& rand) {
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;
- // assert: translate-only no-filter can always be treated as sprite
+ SkPaint noaaPaint;
+ SkPaint aaPaint;
+ aaPaint.setAntiAlias(true);
+
+ // assert: translate-only no-aa 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, treat_as_sprite(mat, size, 0));
+ REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, noaaPaint));
}
}
@@ -108,8 +106,8 @@ static void test_treatAsSprite(skiatest::Reporter* reporter) {
rand_matrix(&mat, rand, SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask);
for (int j = 0; j < 1000; ++j) {
rand_size(&size, rand);
- REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, 0));
- REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
+ REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, noaaPaint));
+ REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint));
}
}
@@ -117,33 +115,33 @@ static void test_treatAsSprite(skiatest::Reporter* reporter) {
const SkScalar tooMuchSubpixel = 100.1f;
mat.setTranslate(tooMuchSubpixel, 0);
- REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
+ REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint));
mat.setTranslate(0, tooMuchSubpixel);
- REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
+ REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint));
const SkScalar tinySubPixel = 100.02f;
mat.setTranslate(tinySubPixel, 0);
- REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));
+ REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, aaPaint));
mat.setTranslate(0, tinySubPixel);
- REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));
+ REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, aaPaint));
const SkScalar twoThirds = SK_Scalar1 * 2 / 3;
const SkScalar bigScale = (size.width() + twoThirds) / size.width();
mat.setScale(bigScale, bigScale);
- REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false));
- REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
+ REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, noaaPaint));
+ REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint));
const SkScalar oneThird = SK_Scalar1 / 3;
const SkScalar smallScale = (size.width() + oneThird) / size.width();
mat.setScale(smallScale, smallScale);
- REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false));
- REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits));
+ REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, noaaPaint));
+ REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint));
const SkScalar oneFortyth = SK_Scalar1 / 40;
const SkScalar tinyScale = (size.width() + oneFortyth) / size.width();
mat.setScale(tinyScale, tinyScale);
- REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false));
- REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits));
+ REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, noaaPaint));
+ REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, aaPaint));
}
static void assert_ifDrawnTo(skiatest::Reporter* reporter,
« no previous file with comments | « src/core/SkMatrixUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698