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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/color_transform.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer_unittest.cc
diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc
index 0cf7d508ae37abe27e2b7368ccdfb327a15a20d8..477d67f2efa97cee325b395cee66475ab951b197 100644
--- a/cc/output/gl_renderer_unittest.cc
+++ b/cc/output/gl_renderer_unittest.cc
@@ -134,7 +134,7 @@ class GLRendererShaderPixelTest : public GLRendererPixelTest {
void TestShader(const ProgramKey& program_key) {
renderer()->SetCurrentFrameForTesting(GLRenderer::DrawingFrame());
- const size_t kNumSrcColorSpaces = 3;
+ const size_t kNumSrcColorSpaces = 4;
gfx::ColorSpace src_color_spaces[kNumSrcColorSpaces] = {
gfx::ColorSpace(), gfx::ColorSpace::CreateSRGB(),
gfx::ColorSpace::CreateREC709(),
@@ -159,6 +159,38 @@ class GLRendererShaderPixelTest : public GLRendererPixelTest {
TestShader(ProgramKey::SolidColor(USE_AA));
}
+ void TestColorShaders() {
+ const size_t kNumTransferFns = 7;
+ SkColorSpaceTransferFn transfer_fns[kNumTransferFns] = {
+ // The identity.
+ {1.f, 1.f, 0.f, 1.f, 0.f, 0.f, 0.f},
+ // The identity, with an if statement.
+ {1.f, 1.f, 0.f, 1.f, 0.5f, 0.f, 0.f},
+ // Just the power function.
+ {1.1f, 1.f, 0.f, 1.f, 0.f, 0.f, 0.f},
+ // Everything but the power function, nonlinear only.
+ {1.f, 0.9f, 0.1f, 0.9f, 0.f, 0.1f, 0.1f},
+ // Everything, nonlinear only.
+ {1.1f, 0.9f, 0.1f, 0.9f, 0.f, 0.1f, 0.1f},
+ // Everything but the power function.
+ {1.f, 0.9f, 0.1f, 0.9f, 0.5f, 0.1f, 0.1f},
+ // Everything.
+ {1.1f, 0.9f, 0.1f, 0.9f, 0.5f, 0.1f, 0.1f},
+ };
+
+ for (size_t i = 0; i < kNumTransferFns; ++i) {
+ SkMatrix44 primaries;
+ gfx::ColorSpace::CreateSRGB().GetPrimaryMatrix(&primaries);
+ gfx::ColorSpace src =
+ gfx::ColorSpace::CreateCustom(primaries, transfer_fns[i]);
+
+ renderer()->SetCurrentFrameForTesting(GLRenderer::DrawingFrame());
+ renderer()->SetUseProgram(ProgramKey::SolidColor(NO_AA), src,
+ gfx::ColorSpace::CreateXYZD50());
+ EXPECT_TRUE(renderer()->current_program_->initialized());
+ }
+ }
+
void TestShadersWithPrecision(TexCoordPrecision precision) {
// This program uses external textures and sampler, so it won't compile
// everywhere.
@@ -268,6 +300,10 @@ TEST_F(GLRendererShaderPixelTest, BasicShadersCompile) {
TestBasicShaders();
}
+TEST_F(GLRendererShaderPixelTest, TestColorShadersCompile) {
+ TestColorShaders();
+}
+
class PrecisionShaderPixelTest
: public GLRendererShaderPixelTest,
public ::testing::WithParamInterface<TexCoordPrecision> {};
« 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