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 "SkShader.h" | 10 #include "SkShader.h" |
10 #include "SkGradientShader.h" | 11 #include "SkGradientShader.h" |
11 #include "SkColorShader.h" | 12 #include "SkColorShader.h" |
12 | 13 |
13 static void test_bitmap(skiatest::Reporter* reporter) { | 14 static void test_bitmap(skiatest::Reporter* reporter) { |
14 SkBitmap bmp; | 15 SkBitmap bmp; |
15 bmp.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); | 16 bmp.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); |
16 | 17 |
17 // test 1: bitmap without pixel data | 18 // test 1: bitmap without pixel data |
18 SkShader* shader = SkShader::CreateBitmapShader(bmp, | 19 SkShader* shader = SkShader::CreateBitmapShader(bmp, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 REPORTER_ASSERT(reporter, colorShader2.isOpaque()); | 102 REPORTER_ASSERT(reporter, colorShader2.isOpaque()); |
102 SkColorShader colorShader3(SkColorSetARGB(0x7F,0,0,0)); | 103 SkColorShader colorShader3(SkColorSetARGB(0x7F,0,0,0)); |
103 REPORTER_ASSERT(reporter, !colorShader3.isOpaque()); | 104 REPORTER_ASSERT(reporter, !colorShader3.isOpaque()); |
104 | 105 |
105 // with inherrited color, shader must declare itself as opaque, | 106 // with inherrited color, shader must declare itself as opaque, |
106 // since lack of opacity will depend solely on the paint | 107 // since lack of opacity will depend solely on the paint |
107 SkColorShader colorShader4; | 108 SkColorShader colorShader4; |
108 REPORTER_ASSERT(reporter, colorShader4.isOpaque()); | 109 REPORTER_ASSERT(reporter, colorShader4.isOpaque()); |
109 } | 110 } |
110 | 111 |
111 static void test_shader_opacity(skiatest::Reporter* reporter) | 112 DEF_TEST(ShaderOpacity, reporter) { |
112 { | |
113 test_gradient(reporter); | 113 test_gradient(reporter); |
114 test_color(reporter); | 114 test_color(reporter); |
115 test_bitmap(reporter); | 115 test_bitmap(reporter); |
116 } | 116 } |
117 | |
118 #include "TestClassDef.h" | |
119 DEFINE_TESTCLASS("ShaderOpacity", ShaderOpacityTestClass, test_shader_opacity) | |
OLD | NEW |