| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2011 Google Inc. | 2  * Copyright 2011 Google Inc. | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 | 7 | 
| 8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" | 
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" | 
| 10 #include "SkData.h" | 10 #include "SkData.h" | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 117     mat.setTranslate(0, tooMuchSubpixel); | 117     mat.setTranslate(0, tooMuchSubpixel); | 
| 118     REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); | 118     REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); | 
| 119 | 119 | 
| 120     const SkScalar tinySubPixel = 100.02f; | 120     const SkScalar tinySubPixel = 100.02f; | 
| 121     mat.setTranslate(tinySubPixel, 0); | 121     mat.setTranslate(tinySubPixel, 0); | 
| 122     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); | 122     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); | 
| 123     mat.setTranslate(0, tinySubPixel); | 123     mat.setTranslate(0, tinySubPixel); | 
| 124     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); | 124     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); | 
| 125 | 125 | 
| 126     const SkScalar twoThirds = SK_Scalar1 * 2 / 3; | 126     const SkScalar twoThirds = SK_Scalar1 * 2 / 3; | 
| 127     const SkScalar bigScale = SkScalarDiv(size.width() + twoThirds, size.width()
     ); | 127     const SkScalar bigScale = (size.width() + twoThirds) / size.width(); | 
| 128     mat.setScale(bigScale, bigScale); | 128     mat.setScale(bigScale, bigScale); | 
| 129     REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false)); | 129     REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, false)); | 
| 130     REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); | 130     REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); | 
| 131 | 131 | 
| 132     const SkScalar oneThird = SK_Scalar1 / 3; | 132     const SkScalar oneThird = SK_Scalar1 / 3; | 
| 133     const SkScalar smallScale = SkScalarDiv(size.width() + oneThird, size.width(
     )); | 133     const SkScalar smallScale = (size.width() + oneThird) / size.width(); | 
| 134     mat.setScale(smallScale, smallScale); | 134     mat.setScale(smallScale, smallScale); | 
| 135     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); | 135     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); | 
| 136     REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); | 136     REPORTER_ASSERT(reporter, !treat_as_sprite(mat, size, bilerBits)); | 
| 137 | 137 | 
| 138     const SkScalar oneFortyth = SK_Scalar1 / 40; | 138     const SkScalar oneFortyth = SK_Scalar1 / 40; | 
| 139     const SkScalar tinyScale = SkScalarDiv(size.width() + oneFortyth, size.width
     ()); | 139     const SkScalar tinyScale = (size.width() + oneFortyth) / size.width(); | 
| 140     mat.setScale(tinyScale, tinyScale); | 140     mat.setScale(tinyScale, tinyScale); | 
| 141     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); | 141     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, false)); | 
| 142     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); | 142     REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, bilerBits)); | 
| 143 } | 143 } | 
| 144 | 144 | 
| 145 static void assert_ifDrawnTo(skiatest::Reporter* reporter, | 145 static void assert_ifDrawnTo(skiatest::Reporter* reporter, | 
| 146                              const SkBitmap& bm, bool shouldBeDrawn) { | 146                              const SkBitmap& bm, bool shouldBeDrawn) { | 
| 147     for (int y = 0; y < bm.height(); ++y) { | 147     for (int y = 0; y < bm.height(); ++y) { | 
| 148         for (int x = 0; x < bm.width(); ++x) { | 148         for (int x = 0; x < bm.width(); ++x) { | 
| 149             if (shouldBeDrawn) { | 149             if (shouldBeDrawn) { | 
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 303 | 303 | 
| 304     // ensure that we draw nothing if srcR does not intersect the bitmap | 304     // ensure that we draw nothing if srcR does not intersect the bitmap | 
| 305     REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); | 305     REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); | 
| 306 | 306 | 
| 307     test_nan_antihair(); | 307     test_nan_antihair(); | 
| 308     test_giantrepeat_crbug118018(reporter); | 308     test_giantrepeat_crbug118018(reporter); | 
| 309 | 309 | 
| 310     test_treatAsSprite(reporter); | 310     test_treatAsSprite(reporter); | 
| 311     test_faulty_pixelref(reporter); | 311     test_faulty_pixelref(reporter); | 
| 312 } | 312 } | 
| OLD | NEW | 
|---|