| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkDrawLooper.h" | 9 #include "SkDrawLooper.h" |
| 10 #include "Test.h" | 10 #include "Test.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 virtual void toString(SkString* str) const SK_OVERRIDE { | 33 virtual void toString(SkString* str) const SK_OVERRIDE { |
| 34 str->append("TestLooper:"); | 34 str->append("TestLooper:"); |
| 35 } | 35 } |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 SK_DECLARE_UNFLATTENABLE_OBJECT() | 38 SK_DECLARE_UNFLATTENABLE_OBJECT() |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 static void test_drawBitmap(skiatest::Reporter* reporter) { | 41 static void test_drawBitmap(skiatest::Reporter* reporter) { |
| 42 SkBitmap src; | 42 SkBitmap src; |
| 43 src.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); | 43 src.allocN32Pixels(10, 10); |
| 44 src.allocPixels(); | |
| 45 src.eraseColor(SK_ColorWHITE); | 44 src.eraseColor(SK_ColorWHITE); |
| 46 | 45 |
| 47 SkBitmap dst; | 46 SkBitmap dst; |
| 48 dst.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); | 47 dst.allocN32Pixels(10, 10); |
| 49 dst.allocPixels(); | |
| 50 dst.eraseColor(SK_ColorTRANSPARENT); | 48 dst.eraseColor(SK_ColorTRANSPARENT); |
| 51 | 49 |
| 52 SkCanvas canvas(dst); | 50 SkCanvas canvas(dst); |
| 53 SkPaint paint; | 51 SkPaint paint; |
| 54 | 52 |
| 55 // we are initially transparent | 53 // we are initially transparent |
| 56 REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5)); | 54 REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5)); |
| 57 | 55 |
| 58 // we see the bitmap drawn | 56 // we see the bitmap drawn |
| 59 canvas.drawBitmap(src, 0, 0, &paint); | 57 canvas.drawBitmap(src, 0, 0, &paint); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 72 // allows us through, even though sans-looper we would look like we should | 70 // allows us through, even though sans-looper we would look like we should |
| 73 // be clipped out. | 71 // be clipped out. |
| 74 paint.setLooper(new TestLooper)->unref(); | 72 paint.setLooper(new TestLooper)->unref(); |
| 75 canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); | 73 canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint); |
| 76 REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); | 74 REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); |
| 77 } | 75 } |
| 78 | 76 |
| 79 DEF_TEST(QuickReject, reporter) { | 77 DEF_TEST(QuickReject, reporter) { |
| 80 test_drawBitmap(reporter); | 78 test_drawBitmap(reporter); |
| 81 } | 79 } |
| OLD | NEW |