Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65380d6d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixed gamma correction test."

parents 60a3f34f 39c66ac5
Loading
Loading
Loading
Loading
+7 −9
Original line number Original line Diff line number Diff line
@@ -531,8 +531,8 @@ public class BrightnessMappingStrategyTest {
    @Test
    @Test
    public void testGammaCorrectionChangeAtEdges() {
    public void testGammaCorrectionChangeAtEdges() {
        // The algorithm behaves differently at the edges, because gamma correction there tends to
        // The algorithm behaves differently at the edges, because gamma correction there tends to
        // be extreme. If we add a user data point at (x0, y0+0.3), the adjustment should be
        // be extreme. If we add a user data point at (x0, y0+0.3), the adjustment should be 0.3,
        // 0.3*2 = 0.6, resulting in a gamma of 3**-0.6 = ~0.52.
        // resulting in a gamma of 3**-0.6 = ~0.52.
        final int x0 = 100;
        final int x0 = 100;
        final int x2 = 2500;
        final int x2 = 2500;
        final int x4 = 4900;
        final int x4 = 4900;
@@ -547,17 +547,15 @@ public class BrightnessMappingStrategyTest {
        assertEquals(y2, strategy.getBrightness(x2), 0.01f /* tolerance */);
        assertEquals(y2, strategy.getBrightness(x2), 0.01f /* tolerance */);
        assertEquals(y4, strategy.getBrightness(x4), 0.01f /* tolerance */);
        assertEquals(y4, strategy.getBrightness(x4), 0.01f /* tolerance */);
        // Rollin':
        // Rollin':
        float increase = 0.3f;
        float adjustment = 0.3f;
        float adjustment = increase * 2;
        float gamma = (float) MathUtils.pow(MAXIMUM_GAMMA, -adjustment);
        float gamma = (float) MathUtils.pow(MAXIMUM_GAMMA, -adjustment);
        strategy.addUserDataPoint(x0, y0 + increase);
        strategy.addUserDataPoint(x0, y0 + adjustment);
        assertEquals(y0 + increase, strategy.getBrightness(x0), 0.01f /* tolerance */);
        assertEquals(y0 + adjustment, strategy.getBrightness(x0), 0.01f /* tolerance */);
        assertEquals(MathUtils.pow(y2, gamma), strategy.getBrightness(x2), 0.01f /* tolerance */);
        assertEquals(MathUtils.pow(y2, gamma), strategy.getBrightness(x2), 0.01f /* tolerance */);
        assertEquals(MathUtils.pow(y4, gamma), strategy.getBrightness(x4), 0.01f /* tolerance */);
        assertEquals(MathUtils.pow(y4, gamma), strategy.getBrightness(x4), 0.01f /* tolerance */);
        assertEquals(adjustment, strategy.getAutoBrightnessAdjustment(), 0.01f /* tolerance */);
        assertEquals(adjustment, strategy.getAutoBrightnessAdjustment(), 0.01f /* tolerance */);
        // Similarly, if we set a user data point at (x4, 1.0), the adjustment should be (1-y4)*2.
        // Similarly, if we set a user data point at (x4, 1.0), the adjustment should be 1 - y4.
        increase = 1.0f - y4;
        adjustment = 1.0f - y4;
        adjustment = increase * 2;
        gamma = (float) MathUtils.pow(MAXIMUM_GAMMA, -adjustment);
        gamma = (float) MathUtils.pow(MAXIMUM_GAMMA, -adjustment);
        strategy.addUserDataPoint(x4, 1.0f);
        strategy.addUserDataPoint(x4, 1.0f);
        assertEquals(MathUtils.pow(y0, gamma), strategy.getBrightness(x0), 0.01f /* tolerance */);
        assertEquals(MathUtils.pow(y0, gamma), strategy.getBrightness(x0), 0.01f /* tolerance */);