epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 7 | |
reed@google.com | 2ade086 | 2011-03-17 17:48:04 +0000 | [diff] [blame] | 8 | #include "SkBitmap.h" |
| 9 | #include "SkCanvas.h" |
Ben Wagner | d90cd3b | 2018-05-22 10:48:08 -0400 | [diff] [blame] | 10 | #include "SkColor.h" |
| 11 | #include "SkMatrix.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 12 | #include "SkMatrixUtils.h" |
reed@google.com | cef5bb4 | 2013-10-15 20:05:24 +0000 | [diff] [blame] | 13 | #include "SkPaint.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 14 | #include "SkPath.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 15 | #include "SkRandom.h" |
Ben Wagner | d90cd3b | 2018-05-22 10:48:08 -0400 | [diff] [blame] | 16 | #include "SkRect.h" |
| 17 | #include "SkScalar.h" |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 18 | #include "SkShader.h" |
Ben Wagner | d90cd3b | 2018-05-22 10:48:08 -0400 | [diff] [blame] | 19 | #include "SkSize.h" |
| 20 | #include "SkTypes.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 21 | #include "Test.h" |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 22 | |
reed@google.com | cef5bb4 | 2013-10-15 20:05:24 +0000 | [diff] [blame] | 23 | /////////////////////////////////////////////////////////////////////////////// |
| 24 | |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 25 | static void rand_matrix(SkMatrix* mat, SkRandom& rand, unsigned mask) { |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 26 | mat->setIdentity(); |
| 27 | if (mask & SkMatrix::kTranslate_Mask) { |
| 28 | mat->postTranslate(rand.nextSScalar1(), rand.nextSScalar1()); |
| 29 | } |
| 30 | if (mask & SkMatrix::kScale_Mask) { |
| 31 | mat->postScale(rand.nextSScalar1(), rand.nextSScalar1()); |
| 32 | } |
| 33 | if (mask & SkMatrix::kAffine_Mask) { |
| 34 | mat->postRotate(rand.nextSScalar1() * 360); |
| 35 | } |
| 36 | if (mask & SkMatrix::kPerspective_Mask) { |
| 37 | mat->setPerspX(rand.nextSScalar1()); |
| 38 | mat->setPerspY(rand.nextSScalar1()); |
| 39 | } |
| 40 | } |
| 41 | |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 42 | static void rand_size(SkISize* size, SkRandom& rand) { |
reed@google.com | ae57358 | 2013-01-03 15:22:40 +0000 | [diff] [blame] | 43 | size->set(rand.nextU() & 0xFFFF, rand.nextU() & 0xFFFF); |
| 44 | } |
| 45 | |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 46 | static void test_treatAsSprite(skiatest::Reporter* reporter) { |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 47 | |
| 48 | SkMatrix mat; |
reed@google.com | ae57358 | 2013-01-03 15:22:40 +0000 | [diff] [blame] | 49 | SkISize size; |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 50 | SkRandom rand; |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 51 | |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 52 | SkPaint noaaPaint; |
| 53 | SkPaint aaPaint; |
| 54 | aaPaint.setAntiAlias(true); |
| 55 | |
| 56 | // assert: translate-only no-aa can always be treated as sprite |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 57 | for (int i = 0; i < 1000; ++i) { |
| 58 | rand_matrix(&mat, rand, SkMatrix::kTranslate_Mask); |
| 59 | for (int j = 0; j < 1000; ++j) { |
reed@google.com | ae57358 | 2013-01-03 15:22:40 +0000 | [diff] [blame] | 60 | rand_size(&size, rand); |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 61 | REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, noaaPaint)); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 62 | } |
| 63 | } |
skia.committer@gmail.com | 422188f | 2013-01-03 02:01:32 +0000 | [diff] [blame] | 64 | |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 65 | // assert: rotate/perspect is never treated as sprite |
| 66 | for (int i = 0; i < 1000; ++i) { |
| 67 | rand_matrix(&mat, rand, SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask); |
| 68 | for (int j = 0; j < 1000; ++j) { |
reed@google.com | ae57358 | 2013-01-03 15:22:40 +0000 | [diff] [blame] | 69 | rand_size(&size, rand); |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 70 | REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, noaaPaint)); |
| 71 | REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 72 | } |
| 73 | } |
| 74 | |
reed@google.com | ae57358 | 2013-01-03 15:22:40 +0000 | [diff] [blame] | 75 | size.set(500, 600); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 76 | |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 77 | const SkScalar tooMuchSubpixel = 100.1f; |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 78 | mat.setTranslate(tooMuchSubpixel, 0); |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 79 | REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 80 | mat.setTranslate(0, tooMuchSubpixel); |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 81 | REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 82 | |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 83 | const SkScalar tinySubPixel = 100.02f; |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 84 | mat.setTranslate(tinySubPixel, 0); |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 85 | REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, aaPaint)); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 86 | mat.setTranslate(0, tinySubPixel); |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 87 | REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, aaPaint)); |
skia.committer@gmail.com | 422188f | 2013-01-03 02:01:32 +0000 | [diff] [blame] | 88 | |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 89 | const SkScalar twoThirds = SK_Scalar1 * 2 / 3; |
reed | 80ea19c | 2015-05-12 10:37:34 -0700 | [diff] [blame] | 90 | const SkScalar bigScale = (size.width() + twoThirds) / size.width(); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 91 | mat.setScale(bigScale, bigScale); |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 92 | REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, noaaPaint)); |
| 93 | REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
skia.committer@gmail.com | 422188f | 2013-01-03 02:01:32 +0000 | [diff] [blame] | 94 | |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 95 | const SkScalar oneThird = SK_Scalar1 / 3; |
reed | 80ea19c | 2015-05-12 10:37:34 -0700 | [diff] [blame] | 96 | const SkScalar smallScale = (size.width() + oneThird) / size.width(); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 97 | mat.setScale(smallScale, smallScale); |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 98 | REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, noaaPaint)); |
| 99 | REPORTER_ASSERT(reporter, !SkTreatAsSprite(mat, size, aaPaint)); |
skia.committer@gmail.com | 422188f | 2013-01-03 02:01:32 +0000 | [diff] [blame] | 100 | |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 101 | const SkScalar oneFortyth = SK_Scalar1 / 40; |
reed | 80ea19c | 2015-05-12 10:37:34 -0700 | [diff] [blame] | 102 | const SkScalar tinyScale = (size.width() + oneFortyth) / size.width(); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 103 | mat.setScale(tinyScale, tinyScale); |
fmalita | c7e211a | 2016-01-07 10:34:46 -0800 | [diff] [blame] | 104 | REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, noaaPaint)); |
| 105 | REPORTER_ASSERT(reporter, SkTreatAsSprite(mat, size, aaPaint)); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 106 | } |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 107 | |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 108 | static void test_wacky_bitmapshader(skiatest::Reporter* reporter, |
Mike Klein | dac694d | 2018-12-18 10:13:52 -0500 | [diff] [blame] | 109 | int width, int height) { |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 110 | SkBitmap dev; |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 111 | dev.allocN32Pixels(0x56F, 0x4f6); |
junov@google.com | dbfac8a | 2012-12-06 21:47:40 +0000 | [diff] [blame] | 112 | dev.eraseColor(SK_ColorTRANSPARENT); // necessary, so we know if we draw to it |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 113 | |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 114 | SkMatrix matrix; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 115 | |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 116 | SkCanvas c(dev); |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 117 | matrix.setAll(-119.34097f, |
| 118 | -43.436558f, |
| 119 | 93489.945f, |
| 120 | 43.436558f, |
| 121 | -119.34097f, |
| 122 | 123.98426f, |
robertphillips@google.com | 4debcac | 2012-05-14 16:33:36 +0000 | [diff] [blame] | 123 | 0, 0, SK_Scalar1); |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 124 | c.concat(matrix); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 125 | |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 126 | SkBitmap bm; |
reed | 8482504 | 2014-09-02 12:50:45 -0700 | [diff] [blame] | 127 | if (bm.tryAllocN32Pixels(width, height)) { |
Mike Reed | f0ffb89 | 2017-10-03 14:47:21 -0400 | [diff] [blame] | 128 | bm.eraseColor(SK_ColorRED); |
| 129 | } else { |
Mike Klein | dac694d | 2018-12-18 10:13:52 -0500 | [diff] [blame] | 130 | SkASSERT(false); |
| 131 | return; |
reed | 8482504 | 2014-09-02 12:50:45 -0700 | [diff] [blame] | 132 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 133 | |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 134 | matrix.setAll(0.0078740157f, |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 135 | 0, |
robertphillips@google.com | 4debcac | 2012-05-14 16:33:36 +0000 | [diff] [blame] | 136 | SkIntToScalar(249), |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 137 | 0, |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 138 | 0.0078740157f, |
robertphillips@google.com | 4debcac | 2012-05-14 16:33:36 +0000 | [diff] [blame] | 139 | SkIntToScalar(239), |
| 140 | 0, 0, SK_Scalar1); |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 141 | SkPaint paint; |
reed | 1a9b964 | 2016-03-13 14:13:58 -0700 | [diff] [blame] | 142 | paint.setShader(SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, |
| 143 | SkShader::kRepeat_TileMode, &matrix)); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 144 | |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 145 | SkRect r = SkRect::MakeXYWH(681, 239, 695, 253); |
| 146 | c.drawRect(r, paint); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 147 | |
Mike Klein | dac694d | 2018-12-18 10:13:52 -0500 | [diff] [blame] | 148 | for (int y = 0; y < dev.height(); ++y) { |
| 149 | for (int x = 0; x < dev.width(); ++x) { |
| 150 | if (SK_ColorTRANSPARENT == *dev.getAddr32(x, y)) { |
| 151 | REPORTER_ASSERT(reporter, false); |
| 152 | return; |
| 153 | } |
| 154 | } |
| 155 | } |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 156 | } |
| 157 | |
Mike Klein | dac694d | 2018-12-18 10:13:52 -0500 | [diff] [blame] | 158 | // ATTENTION We should always draw each of these sizes safely now. ATTENTION |
| 159 | // ATTENTION I'm leaving this next /*comment*/ for posterity. ATTENTION |
| 160 | |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 161 | /* |
| 162 | * Original bug was asserting that the matrix-proc had generated a (Y) value |
| 163 | * that was out of range. This led (in the release build) to the sampler-proc |
| 164 | * reading memory out-of-bounds of the original bitmap. |
| 165 | * |
| 166 | * We were numerically overflowing our 16bit coordinates that we communicate |
| 167 | * between these two procs. The fixes was in two parts: |
| 168 | * |
| 169 | * 1. Just don't draw bitmaps larger than 64K-1 in width or height, since we |
| 170 | * can't represent those coordinates in our transport format (yet). |
| 171 | * 2. Perform an unsigned shift during the calculation, so we don't get |
| 172 | * sign-extension bleed when packing the two values (X,Y) into our 32bit |
| 173 | * slot. |
| 174 | * |
Mike Reed | f0ffb89 | 2017-10-03 14:47:21 -0400 | [diff] [blame] | 175 | * This tests exercises the original setup, plus 2 more to ensure that we can, |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 176 | * in fact, handle bitmaps at 64K-1 (assuming we don't exceed the total |
| 177 | * memory allocation limit). |
| 178 | */ |
| 179 | static void test_giantrepeat_crbug118018(skiatest::Reporter* reporter) { |
| 180 | static const struct { |
| 181 | int fWidth; |
| 182 | int fHeight; |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 183 | } gTests[] = { |
Mike Klein | dac694d | 2018-12-18 10:13:52 -0500 | [diff] [blame] | 184 | { 0x1b294, 0x7f}, // crbug 118018 (width exceeds 64K)... should draw safely now. |
| 185 | { 0xFFFF, 0x7f }, // should draw, test max width |
| 186 | { 0x7f, 0xFFFF }, // should draw, test max height |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 187 | }; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 188 | |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 189 | for (size_t i = 0; i < SK_ARRAY_COUNT(gTests); ++i) { |
| 190 | test_wacky_bitmapshader(reporter, |
Mike Klein | dac694d | 2018-12-18 10:13:52 -0500 | [diff] [blame] | 191 | gTests[i].fWidth, gTests[i].fHeight); |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 192 | } |
| 193 | } |
reed@google.com | 0da0627 | 2012-05-03 20:26:06 +0000 | [diff] [blame] | 194 | |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 195 | /////////////////////////////////////////////////////////////////////////////// |
reed@google.com | 2ade086 | 2011-03-17 17:48:04 +0000 | [diff] [blame] | 196 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 197 | static void test_nan_antihair() { |
reed@google.com | 6de0bfc | 2012-03-30 17:43:33 +0000 | [diff] [blame] | 198 | SkBitmap bm; |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 199 | bm.allocN32Pixels(20, 20); |
reed@google.com | 6de0bfc | 2012-03-30 17:43:33 +0000 | [diff] [blame] | 200 | |
| 201 | SkCanvas canvas(bm); |
| 202 | |
| 203 | SkPath path; |
| 204 | path.moveTo(0, 0); |
| 205 | path.lineTo(10, SK_ScalarNaN); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 206 | |
reed@google.com | 6de0bfc | 2012-03-30 17:43:33 +0000 | [diff] [blame] | 207 | SkPaint paint; |
| 208 | paint.setAntiAlias(true); |
| 209 | paint.setStyle(SkPaint::kStroke_Style); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 210 | |
reed@google.com | 6de0bfc | 2012-03-30 17:43:33 +0000 | [diff] [blame] | 211 | // before our fix to SkScan_Antihair.cpp to check for integral NaN (0x800...) |
| 212 | // this would trigger an assert/crash. |
| 213 | // |
| 214 | // see rev. 3558 |
| 215 | canvas.drawPath(path, paint); |
| 216 | } |
| 217 | |
reed@google.com | 2ade086 | 2011-03-17 17:48:04 +0000 | [diff] [blame] | 218 | static bool check_for_all_zeros(const SkBitmap& bm) { |
reed@google.com | 2ade086 | 2011-03-17 17:48:04 +0000 | [diff] [blame] | 219 | size_t count = bm.width() * bm.bytesPerPixel(); |
| 220 | for (int y = 0; y < bm.height(); y++) { |
| 221 | const uint8_t* ptr = reinterpret_cast<const uint8_t*>(bm.getAddr(0, y)); |
| 222 | for (size_t i = 0; i < count; i++) { |
| 223 | if (ptr[i]) { |
| 224 | return false; |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | return true; |
| 229 | } |
| 230 | |
| 231 | static const int gWidth = 256; |
| 232 | static const int gHeight = 256; |
| 233 | |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 234 | static void create(SkBitmap* bm, SkColor color) { |
| 235 | bm->allocN32Pixels(gWidth, gHeight); |
reed@google.com | 2ade086 | 2011-03-17 17:48:04 +0000 | [diff] [blame] | 236 | bm->eraseColor(color); |
| 237 | } |
| 238 | |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 239 | DEF_TEST(DrawBitmapRect, reporter) { |
reed@google.com | 2ade086 | 2011-03-17 17:48:04 +0000 | [diff] [blame] | 240 | SkBitmap src, dst; |
| 241 | |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 242 | create(&src, 0xFFFFFFFF); |
| 243 | create(&dst, 0); |
reed@google.com | 2ade086 | 2011-03-17 17:48:04 +0000 | [diff] [blame] | 244 | |
| 245 | SkCanvas canvas(dst); |
| 246 | |
| 247 | SkIRect srcR = { gWidth, 0, gWidth + 16, 16 }; |
| 248 | SkRect dstR = { 0, 0, SkIntToScalar(16), SkIntToScalar(16) }; |
| 249 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 250 | canvas.drawBitmapRect(src, srcR, dstR, nullptr); |
reed@google.com | 2ade086 | 2011-03-17 17:48:04 +0000 | [diff] [blame] | 251 | |
| 252 | // ensure that we draw nothing if srcR does not intersect the bitmap |
| 253 | REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); |
reed@google.com | 6de0bfc | 2012-03-30 17:43:33 +0000 | [diff] [blame] | 254 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 255 | test_nan_antihair(); |
reed@google.com | 99c114e | 2012-05-03 20:14:26 +0000 | [diff] [blame] | 256 | test_giantrepeat_crbug118018(reporter); |
reed@google.com | ad51430 | 2013-01-02 20:19:45 +0000 | [diff] [blame] | 257 | |
| 258 | test_treatAsSprite(reporter); |
reed@google.com | 2ade086 | 2011-03-17 17:48:04 +0000 | [diff] [blame] | 259 | } |