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

Side by Side Diff: cc/output/gl_renderer_unittest.cc

Issue 2697413002: color: Add analytic transfer functions in shaders (Closed)
Patch Set: Disable on android Created 3 years, 10 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
« no previous file with comments | « no previous file | ui/gfx/color_transform.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 ASSERT_FALSE(renderer()->IsContextLost()); 127 ASSERT_FALSE(renderer()->IsContextLost());
128 } 128 }
129 129
130 void TearDown() override { 130 void TearDown() override {
131 GLRendererPixelTest::TearDown(); 131 GLRendererPixelTest::TearDown();
132 ASSERT_FALSE(renderer()->IsContextLost()); 132 ASSERT_FALSE(renderer()->IsContextLost());
133 } 133 }
134 134
135 void TestShader(const ProgramKey& program_key) { 135 void TestShader(const ProgramKey& program_key) {
136 renderer()->SetCurrentFrameForTesting(GLRenderer::DrawingFrame()); 136 renderer()->SetCurrentFrameForTesting(GLRenderer::DrawingFrame());
137 const size_t kNumSrcColorSpaces = 3; 137 const size_t kNumSrcColorSpaces = 4;
138 gfx::ColorSpace src_color_spaces[kNumSrcColorSpaces] = { 138 gfx::ColorSpace src_color_spaces[kNumSrcColorSpaces] = {
139 gfx::ColorSpace(), gfx::ColorSpace::CreateSRGB(), 139 gfx::ColorSpace(), gfx::ColorSpace::CreateSRGB(),
140 gfx::ColorSpace::CreateREC709(), 140 gfx::ColorSpace::CreateREC709(),
141 }; 141 };
142 const size_t kNumDstColorSpaces = 3; 142 const size_t kNumDstColorSpaces = 3;
143 gfx::ColorSpace dst_color_spaces[kNumDstColorSpaces] = { 143 gfx::ColorSpace dst_color_spaces[kNumDstColorSpaces] = {
144 gfx::ColorSpace(), gfx::ColorSpace::CreateSRGB(), 144 gfx::ColorSpace(), gfx::ColorSpace::CreateSRGB(),
145 gfx::ColorSpace::CreateSCRGBLinear(), 145 gfx::ColorSpace::CreateSCRGBLinear(),
146 }; 146 };
147 for (size_t i = 0; i < kNumDstColorSpaces; ++i) { 147 for (size_t i = 0; i < kNumDstColorSpaces; ++i) {
148 for (size_t j = 0; j < kNumSrcColorSpaces; ++j) { 148 for (size_t j = 0; j < kNumSrcColorSpaces; ++j) {
149 renderer()->SetUseProgram(program_key, src_color_spaces[j], 149 renderer()->SetUseProgram(program_key, src_color_spaces[j],
150 dst_color_spaces[i]); 150 dst_color_spaces[i]);
151 EXPECT_TRUE(renderer()->current_program_->initialized()); 151 EXPECT_TRUE(renderer()->current_program_->initialized());
152 } 152 }
153 } 153 }
154 } 154 }
155 155
156 void TestBasicShaders() { 156 void TestBasicShaders() {
157 TestShader(ProgramKey::DebugBorder()); 157 TestShader(ProgramKey::DebugBorder());
158 TestShader(ProgramKey::SolidColor(NO_AA)); 158 TestShader(ProgramKey::SolidColor(NO_AA));
159 TestShader(ProgramKey::SolidColor(USE_AA)); 159 TestShader(ProgramKey::SolidColor(USE_AA));
160 } 160 }
161 161
162 void TestColorShaders() {
163 const size_t kNumTransferFns = 7;
164 SkColorSpaceTransferFn transfer_fns[kNumTransferFns] = {
165 // The identity.
166 {1.f, 1.f, 0.f, 1.f, 0.f, 0.f, 0.f},
167 // The identity, with an if statement.
168 {1.f, 1.f, 0.f, 1.f, 0.5f, 0.f, 0.f},
169 // Just the power function.
170 {1.1f, 1.f, 0.f, 1.f, 0.f, 0.f, 0.f},
171 // Everything but the power function, nonlinear only.
172 {1.f, 0.9f, 0.1f, 0.9f, 0.f, 0.1f, 0.1f},
173 // Everything, nonlinear only.
174 {1.1f, 0.9f, 0.1f, 0.9f, 0.f, 0.1f, 0.1f},
175 // Everything but the power function.
176 {1.f, 0.9f, 0.1f, 0.9f, 0.5f, 0.1f, 0.1f},
177 // Everything.
178 {1.1f, 0.9f, 0.1f, 0.9f, 0.5f, 0.1f, 0.1f},
179 };
180
181 for (size_t i = 0; i < kNumTransferFns; ++i) {
182 SkMatrix44 primaries;
183 gfx::ColorSpace::CreateSRGB().GetPrimaryMatrix(&primaries);
184 gfx::ColorSpace src =
185 gfx::ColorSpace::CreateCustom(primaries, transfer_fns[i]);
186
187 renderer()->SetCurrentFrameForTesting(GLRenderer::DrawingFrame());
188 renderer()->SetUseProgram(ProgramKey::SolidColor(NO_AA), src,
189 gfx::ColorSpace::CreateXYZD50());
190 EXPECT_TRUE(renderer()->current_program_->initialized());
191 }
192 }
193
162 void TestShadersWithPrecision(TexCoordPrecision precision) { 194 void TestShadersWithPrecision(TexCoordPrecision precision) {
163 // This program uses external textures and sampler, so it won't compile 195 // This program uses external textures and sampler, so it won't compile
164 // everywhere. 196 // everywhere.
165 if (context_provider()->ContextCapabilities().egl_image_external) { 197 if (context_provider()->ContextCapabilities().egl_image_external) {
166 TestShader(ProgramKey::VideoStream(precision)); 198 TestShader(ProgramKey::VideoStream(precision));
167 } 199 }
168 } 200 }
169 201
170 void TestShadersWithPrecisionAndBlend(TexCoordPrecision precision, 202 void TestShadersWithPrecisionAndBlend(TexCoordPrecision precision,
171 BlendMode blend_mode) { 203 BlendMode blend_mode) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 static const SamplerType kSamplerList[] = { 293 static const SamplerType kSamplerList[] = {
262 SAMPLER_TYPE_2D, 294 SAMPLER_TYPE_2D,
263 SAMPLER_TYPE_2D_RECT, 295 SAMPLER_TYPE_2D_RECT,
264 SAMPLER_TYPE_EXTERNAL_OES, 296 SAMPLER_TYPE_EXTERNAL_OES,
265 }; 297 };
266 298
267 TEST_F(GLRendererShaderPixelTest, BasicShadersCompile) { 299 TEST_F(GLRendererShaderPixelTest, BasicShadersCompile) {
268 TestBasicShaders(); 300 TestBasicShaders();
269 } 301 }
270 302
303 TEST_F(GLRendererShaderPixelTest, TestColorShadersCompile) {
304 TestColorShaders();
305 }
306
271 class PrecisionShaderPixelTest 307 class PrecisionShaderPixelTest
272 : public GLRendererShaderPixelTest, 308 : public GLRendererShaderPixelTest,
273 public ::testing::WithParamInterface<TexCoordPrecision> {}; 309 public ::testing::WithParamInterface<TexCoordPrecision> {};
274 310
275 TEST_P(PrecisionShaderPixelTest, ShadersCompile) { 311 TEST_P(PrecisionShaderPixelTest, ShadersCompile) {
276 TestShadersWithPrecision(GetParam()); 312 TestShadersWithPrecision(GetParam());
277 } 313 }
278 314
279 INSTANTIATE_TEST_CASE_P(PrecisionShadersCompile, 315 INSTANTIATE_TEST_CASE_P(PrecisionShadersCompile,
280 PrecisionShaderPixelTest, 316 PrecisionShaderPixelTest,
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 renderer_->SetVisible(true); 2022 renderer_->SetVisible(true);
1987 Mock::VerifyAndClearExpectations(context_support_ptr_); 2023 Mock::VerifyAndClearExpectations(context_support_ptr_);
1988 2024
1989 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); 2025 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true));
1990 renderer_->SetVisible(false); 2026 renderer_->SetVisible(false);
1991 Mock::VerifyAndClearExpectations(context_support_ptr_); 2027 Mock::VerifyAndClearExpectations(context_support_ptr_);
1992 } 2028 }
1993 2029
1994 } // namespace 2030 } // namespace
1995 } // namespace cc 2031 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/color_transform.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698