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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
10 #include "SkShader.h" | 11 #include "SkShader.h" |
11 #include "SkRectShaderImageFilter.h" | 12 #include "SkRectShaderImageFilter.h" |
12 #include "SkGradientShader.h" | 13 #include "SkGradientShader.h" |
13 | 14 |
14 static void test_asShaderMode(skiatest::Reporter* reporter) { | 15 DEF_TEST(ShaderImageFilter, reporter) { |
15 int w = 10, h = 10; | 16 int w = 10, h = 10; |
16 SkRect r = SkRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)); // Make small
10x10 gradient | 17 SkRect r = SkRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)); // Make small
10x10 gradient |
17 | 18 |
18 SkBitmap filterResult, shaderResult; | 19 SkBitmap filterResult, shaderResult; |
19 | 20 |
20 filterResult.setConfig(SkBitmap::kARGB_8888_Config, w, h); | 21 filterResult.setConfig(SkBitmap::kARGB_8888_Config, w, h); |
21 filterResult.allocPixels(); | 22 filterResult.allocPixels(); |
22 SkCanvas canvasFilter(filterResult); | 23 SkCanvas canvasFilter(filterResult); |
23 canvasFilter.clear(0x00000000); | 24 canvasFilter.clear(0x00000000); |
24 | 25 |
(...skipping 29 matching lines...) Expand all Loading... |
54 | 55 |
55 // Assert that both paths yielded the same result | 56 // Assert that both paths yielded the same result |
56 for (int y = 0; y < r.height(); ++y) { | 57 for (int y = 0; y < r.height(); ++y) { |
57 const SkPMColor* filterPtr = filterResult.getAddr32(0, y); | 58 const SkPMColor* filterPtr = filterResult.getAddr32(0, y); |
58 const SkPMColor* shaderPtr = shaderResult.getAddr32(0, y); | 59 const SkPMColor* shaderPtr = shaderResult.getAddr32(0, y); |
59 for (int x = 0; x < r.width(); ++x, ++filterPtr, ++shaderPtr) { | 60 for (int x = 0; x < r.width(); ++x, ++filterPtr, ++shaderPtr) { |
60 REPORTER_ASSERT(reporter, *filterPtr == *shaderPtr); | 61 REPORTER_ASSERT(reporter, *filterPtr == *shaderPtr); |
61 } | 62 } |
62 } | 63 } |
63 } | 64 } |
64 | |
65 #include "TestClassDef.h" | |
66 DEFINE_TESTCLASS("ShaderImageFilter", ShaderImageFilterTestClass, test_asShaderM
ode) | |
OLD | NEW |