| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 4 * | 3 * |
| 5 * 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 |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 7 |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
| 9 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 11 #include "SkData.h" | 12 #include "SkData.h" |
| 12 #include "SkDiscardableMemoryPool.h" | 13 #include "SkDiscardableMemoryPool.h" |
| 13 #include "SkImageGenerator.h" | 14 #include "SkImageGenerator.h" |
| 14 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 15 #include "SkShader.h" | 16 #include "SkShader.h" |
| 16 #include "SkSurface.h" | 17 #include "SkSurface.h" |
| 17 #include "SkRandom.h" | 18 #include "SkRandom.h" |
| 18 #include "SkMatrixUtils.h" | 19 #include "SkMatrixUtils.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 302 |
| 302 static const int gWidth = 256; | 303 static const int gWidth = 256; |
| 303 static const int gHeight = 256; | 304 static const int gHeight = 256; |
| 304 | 305 |
| 305 static void create(SkBitmap* bm, SkBitmap::Config config, SkColor color) { | 306 static void create(SkBitmap* bm, SkBitmap::Config config, SkColor color) { |
| 306 bm->setConfig(config, gWidth, gHeight); | 307 bm->setConfig(config, gWidth, gHeight); |
| 307 bm->allocPixels(); | 308 bm->allocPixels(); |
| 308 bm->eraseColor(color); | 309 bm->eraseColor(color); |
| 309 } | 310 } |
| 310 | 311 |
| 311 static void TestDrawBitmapRect(skiatest::Reporter* reporter) { | 312 DEF_TEST(DrawBitmapRect, reporter) { |
| 312 SkBitmap src, dst; | 313 SkBitmap src, dst; |
| 313 | 314 |
| 314 create(&src, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); | 315 create(&src, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); |
| 315 create(&dst, SkBitmap::kARGB_8888_Config, 0); | 316 create(&dst, SkBitmap::kARGB_8888_Config, 0); |
| 316 | 317 |
| 317 SkCanvas canvas(dst); | 318 SkCanvas canvas(dst); |
| 318 | 319 |
| 319 SkIRect srcR = { gWidth, 0, gWidth + 16, 16 }; | 320 SkIRect srcR = { gWidth, 0, gWidth + 16, 16 }; |
| 320 SkRect dstR = { 0, 0, SkIntToScalar(16), SkIntToScalar(16) }; | 321 SkRect dstR = { 0, 0, SkIntToScalar(16), SkIntToScalar(16) }; |
| 321 | 322 |
| 322 canvas.drawBitmapRect(src, &srcR, dstR, NULL); | 323 canvas.drawBitmapRect(src, &srcR, dstR, NULL); |
| 323 | 324 |
| 324 // ensure that we draw nothing if srcR does not intersect the bitmap | 325 // ensure that we draw nothing if srcR does not intersect the bitmap |
| 325 REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); | 326 REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); |
| 326 | 327 |
| 327 test_nan_antihair(); | 328 test_nan_antihair(); |
| 328 test_giantrepeat_crbug118018(reporter); | 329 test_giantrepeat_crbug118018(reporter); |
| 329 | 330 |
| 330 test_treatAsSprite(reporter); | 331 test_treatAsSprite(reporter); |
| 331 test_faulty_pixelref(reporter); | 332 test_faulty_pixelref(reporter); |
| 332 } | 333 } |
| 333 | |
| 334 #include "TestClassDef.h" | |
| 335 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect) | |
| OLD | NEW |