| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "SkShader.h" | 9 #include "SkShader.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 bmp.allocPixels(); | 25 bmp.allocPixels(); |
| 26 | 26 |
| 27 // test 2: not opaque by default | 27 // test 2: not opaque by default |
| 28 shader = SkShader::CreateBitmapShader(bmp, | 28 shader = SkShader::CreateBitmapShader(bmp, |
| 29 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); | 29 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); |
| 30 REPORTER_ASSERT(reporter, shader); | 30 REPORTER_ASSERT(reporter, shader); |
| 31 REPORTER_ASSERT(reporter, !shader->isOpaque()); | 31 REPORTER_ASSERT(reporter, !shader->isOpaque()); |
| 32 shader->unref(); | 32 shader->unref(); |
| 33 | 33 |
| 34 // test 3: explicitly opaque | 34 // test 3: explicitly opaque |
| 35 bmp.setIsOpaque(true); | 35 bmp.setAlphaType(kOpaque_SkAlphaType); |
| 36 shader = SkShader::CreateBitmapShader(bmp, | 36 shader = SkShader::CreateBitmapShader(bmp, |
| 37 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); | 37 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); |
| 38 REPORTER_ASSERT(reporter, shader); | 38 REPORTER_ASSERT(reporter, shader); |
| 39 REPORTER_ASSERT(reporter, shader->isOpaque()); | 39 REPORTER_ASSERT(reporter, shader->isOpaque()); |
| 40 shader->unref(); | 40 shader->unref(); |
| 41 | 41 |
| 42 // test 4: explicitly not opaque | 42 // test 4: explicitly not opaque |
| 43 bmp.setIsOpaque(false); | 43 bmp.setAlphaType(kPremul_SkAlphaType); |
| 44 shader = SkShader::CreateBitmapShader(bmp, | 44 shader = SkShader::CreateBitmapShader(bmp, |
| 45 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); | 45 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); |
| 46 REPORTER_ASSERT(reporter, shader); | 46 REPORTER_ASSERT(reporter, shader); |
| 47 REPORTER_ASSERT(reporter, !shader->isOpaque()); | 47 REPORTER_ASSERT(reporter, !shader->isOpaque()); |
| 48 shader->unref(); | 48 shader->unref(); |
| 49 | 49 |
| 50 } | 50 } |
| 51 | 51 |
| 52 static void test_gradient(skiatest::Reporter* reporter) | 52 static void test_gradient(skiatest::Reporter* reporter) |
| 53 { | 53 { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 static void test_shader_opacity(skiatest::Reporter* reporter) | 111 static void test_shader_opacity(skiatest::Reporter* reporter) |
| 112 { | 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 | 117 |
| 118 #include "TestClassDef.h" | 118 #include "TestClassDef.h" |
| 119 DEFINE_TESTCLASS("ShaderOpacity", ShaderOpacityTestClass, test_shader_opacity) | 119 DEFINE_TESTCLASS("ShaderOpacity", ShaderOpacityTestClass, test_shader_opacity) |
| OLD | NEW |