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 "SkColorShader.h" | 8 #include "SkColorShader.h" |
9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
11 #include "Test.h" | 11 #include "Test.h" |
12 | 12 |
13 static void test_bitmap(skiatest::Reporter* reporter) { | 13 static void test_bitmap(skiatest::Reporter* reporter) { |
14 SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2); | 14 SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2); |
15 | 15 |
16 SkBitmap bmp; | 16 SkBitmap bmp; |
17 bmp.setInfo(info); | 17 bmp.setConfig(info); |
18 | 18 |
19 // test 1: bitmap without pixel data | 19 // test 1: bitmap without pixel data |
20 SkShader* shader = SkShader::CreateBitmapShader(bmp, | 20 SkShader* shader = SkShader::CreateBitmapShader(bmp, |
21 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); | 21 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); |
22 REPORTER_ASSERT(reporter, shader); | 22 REPORTER_ASSERT(reporter, shader); |
23 REPORTER_ASSERT(reporter, !shader->isOpaque()); | 23 REPORTER_ASSERT(reporter, !shader->isOpaque()); |
24 shader->unref(); | 24 shader->unref(); |
25 | 25 |
26 // From this point on, we have pixels | 26 // From this point on, we have pixels |
27 bmp.allocPixels(info); | 27 bmp.allocPixels(info); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 REPORTER_ASSERT(reporter, colorShader2.isOpaque()); | 103 REPORTER_ASSERT(reporter, colorShader2.isOpaque()); |
104 SkColorShader colorShader3(SkColorSetARGB(0x7F,0,0,0)); | 104 SkColorShader colorShader3(SkColorSetARGB(0x7F,0,0,0)); |
105 REPORTER_ASSERT(reporter, !colorShader3.isOpaque()); | 105 REPORTER_ASSERT(reporter, !colorShader3.isOpaque()); |
106 } | 106 } |
107 | 107 |
108 DEF_TEST(ShaderOpacity, reporter) { | 108 DEF_TEST(ShaderOpacity, reporter) { |
109 test_gradient(reporter); | 109 test_gradient(reporter); |
110 test_color(reporter); | 110 test_color(reporter); |
111 test_bitmap(reporter); | 111 test_bitmap(reporter); |
112 } | 112 } |
OLD | NEW |