Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Side by Side Diff: tests/ShaderOpacityTest.cpp

Issue 25275004: store SkAlphaType inside SkBitmap, on road to support unpremul (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/image/SkSurface_Gpu.cpp ('K') | « tests/DeferredCanvasTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« src/image/SkSurface_Gpu.cpp ('K') | « tests/DeferredCanvasTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698