| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shader.h" | 5 #include "cc/output/shader.h" |
| 6 | 6 |
| 7 #include "cc/test/test_gles2_interface.h" | 7 #include "cc/test/test_gles2_interface.h" |
| 8 #include "cc/test/test_web_graphics_context_3d.h" | 8 #include "cc/test/test_web_graphics_context_3d.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/gfx/geometry/point.h" | 10 #include "ui/gfx/geometry/point.h" |
| 11 #include "ui/gfx/geometry/size.h" | 11 #include "ui/gfx/geometry/size.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 TEST(ShaderTest, HighpThresholds) { | 15 TEST(ShaderTest, HighpThresholds) { |
| 16 // The test context always uses a mediump precision of 10 bits which | 16 // The test context always uses a mediump precision of 10 bits which |
| 17 // corresponds to a native highp threshold of 2^10 = 1024 | 17 // corresponds to a native highp threshold of 2^10 = 1024 |
| 18 scoped_ptr<TestWebGraphicsContext3D> stub_context = | 18 scoped_ptr<TestWebGraphicsContext3D> stub_context = |
| 19 TestWebGraphicsContext3D::Create(); | 19 TestWebGraphicsContext3D::Create(); |
| 20 TestGLES2Interface stub_gl(stub_context.get()); | 20 TestGLES2Interface stub_gl(stub_context.get()); |
| 21 | 21 |
| 22 int threshold_cache = 0; | 22 int threshold_cache = 0; |
| 23 int threshold_min; | 23 int threshold_min; |
| 24 gfx::Point closePoint(512, 512); | 24 gfx::Point closePoint(512, 512); |
| 25 gfx::Size smallSize(512, 512); | 25 gfx::Size smallSize(512, 512); |
| 26 gfx::Point farPoint(2560, 2560); | 26 gfx::Point farPoint(2560, 2560); |
| 27 gfx::Size bigSize(2560, 2560); | 27 gfx::Size bigSize(2560, 2560); |
| 28 | 28 |
| 29 threshold_min = 0; | 29 threshold_min = 0; |
| 30 EXPECT_EQ(TEX_COORD_PRECISION_MEDIUM, | 30 EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired( |
| 31 TexCoordPrecisionRequired(&stub_gl, &threshold_cache, threshold_min, | 31 &stub_gl, &threshold_cache, threshold_min, closePoint)); |
| 32 closePoint)); | 32 EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired( |
| 33 EXPECT_EQ(TEX_COORD_PRECISION_MEDIUM, | 33 &stub_gl, &threshold_cache, threshold_min, smallSize)); |
| 34 TexCoordPrecisionRequired(&stub_gl, &threshold_cache, threshold_min, | 34 EXPECT_EQ(TexCoordPrecisionHigh, TexCoordPrecisionRequired( |
| 35 smallSize)); | 35 &stub_gl, &threshold_cache, threshold_min, farPoint)); |
| 36 EXPECT_EQ(TEX_COORD_PRECISION_HIGH, | 36 EXPECT_EQ(TexCoordPrecisionHigh, TexCoordPrecisionRequired( |
| 37 TexCoordPrecisionRequired(&stub_gl, &threshold_cache, threshold_min, | 37 &stub_gl, &threshold_cache, threshold_min, bigSize)); |
| 38 farPoint)); | |
| 39 EXPECT_EQ(TEX_COORD_PRECISION_HIGH, | |
| 40 TexCoordPrecisionRequired(&stub_gl, &threshold_cache, threshold_min, | |
| 41 bigSize)); | |
| 42 | 38 |
| 43 threshold_min = 3000; | 39 threshold_min = 3000; |
| 44 EXPECT_EQ(TEX_COORD_PRECISION_MEDIUM, | 40 EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired( |
| 45 TexCoordPrecisionRequired(&stub_gl, &threshold_cache, threshold_min, | 41 &stub_gl, &threshold_cache, threshold_min, closePoint)); |
| 46 closePoint)); | 42 EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired( |
| 47 EXPECT_EQ(TEX_COORD_PRECISION_MEDIUM, | 43 &stub_gl, &threshold_cache, threshold_min, smallSize)); |
| 48 TexCoordPrecisionRequired(&stub_gl, &threshold_cache, threshold_min, | 44 EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired( |
| 49 smallSize)); | 45 &stub_gl, &threshold_cache, threshold_min, farPoint)); |
| 50 EXPECT_EQ(TEX_COORD_PRECISION_MEDIUM, | 46 EXPECT_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired( |
| 51 TexCoordPrecisionRequired(&stub_gl, &threshold_cache, threshold_min, | 47 &stub_gl, &threshold_cache, threshold_min, bigSize)); |
| 52 farPoint)); | |
| 53 EXPECT_EQ(TEX_COORD_PRECISION_MEDIUM, | |
| 54 TexCoordPrecisionRequired(&stub_gl, &threshold_cache, threshold_min, | |
| 55 bigSize)); | |
| 56 } | 48 } |
| 57 | 49 |
| 58 } // namespace cc | 50 } // namespace cc |
| OLD | NEW |