OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // This file defines tests that implementations of GLImage should pass in order | 5 // This file defines tests that implementations of GLImage should pass in order |
6 // to be conformant. | 6 // to be conformant. |
7 | 7 |
8 #ifndef UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ | 8 #ifndef UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ |
9 #define UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ | 9 #define UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ |
10 | 10 |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 #include "base/strings/stringize_macros.h" | 15 #include "base/strings/stringize_macros.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/gfx/buffer_format_util.h" | 19 #include "ui/gfx/buffer_format_util.h" |
20 #include "ui/gfx/buffer_types.h" | 20 #include "ui/gfx/buffer_types.h" |
21 #include "ui/gl/gl_bindings.h" | 21 #include "ui/gl/gl_bindings.h" |
22 #include "ui/gl/gl_context.h" | 22 #include "ui/gl/gl_context.h" |
23 #include "ui/gl/gl_helper.h" | 23 #include "ui/gl/gl_helper.h" |
24 #include "ui/gl/gl_image.h" | 24 #include "ui/gl/gl_image.h" |
25 #include "ui/gl/gl_implementation.h" | |
26 #include "ui/gl/gl_surface.h" | 25 #include "ui/gl/gl_surface.h" |
| 26 #include "ui/gl/gl_version_info.h" |
27 #include "ui/gl/init/gl_factory.h" | 27 #include "ui/gl/init/gl_factory.h" |
28 #include "ui/gl/test/gl_image_test_support.h" | 28 #include "ui/gl/test/gl_image_test_support.h" |
29 #include "ui/gl/test/gl_test_helper.h" | 29 #include "ui/gl/test/gl_test_helper.h" |
30 | 30 |
31 #if defined(OS_MACOSX) | 31 #if defined(OS_MACOSX) |
32 #include "base/mac/mac_util.h" | 32 #include "base/mac/mac_util.h" |
33 #endif | 33 #endif |
34 | 34 |
35 namespace gl { | 35 namespace gl { |
36 namespace { | 36 namespace { |
37 | 37 |
38 // Compiles a fragment shader for sampling out of a texture of |size| bound to | 38 // Compiles a fragment shader for sampling out of a texture of |size| bound to |
39 // |target| and checks for compilation errors. | 39 // |target| and checks for compilation errors. |
40 GLuint LoadFragmentShader(unsigned target, const gfx::Size& size) { | 40 GLuint LoadFragmentShader(unsigned target, const gfx::Size& size) { |
41 // clang-format off | 41 // clang-format off |
42 const char kFragmentShader[] = STRINGIZE( | 42 const char kFragmentShader[] = STRINGIZE( |
43 uniform SamplerType a_texture; | 43 uniform SamplerType a_texture; |
44 varying vec2 v_texCoord; | 44 varying vec2 v_texCoord; |
45 void main() { | 45 void main() { |
46 gl_FragColor = TextureLookup(a_texture, v_texCoord * TextureScale); | 46 gl_FragColor = TextureLookup(a_texture, v_texCoord * TextureScale); |
47 } | 47 } |
48 ); | 48 ); |
49 const char kShaderFloatPrecision[] = STRINGIZE( | 49 const char kShaderFloatPrecision[] = STRINGIZE( |
50 precision mediump float; | 50 precision mediump float; |
51 ); | 51 ); |
52 // clang-format on | 52 // clang-format on |
53 | 53 |
54 bool is_gles = GetGLImplementation() == kGLImplementationEGLGLES2; | 54 bool is_gles = GLContext::GetCurrent()->GetVersionInfo()->is_es; |
55 switch (target) { | 55 switch (target) { |
56 case GL_TEXTURE_2D: | 56 case GL_TEXTURE_2D: |
57 return GLHelper::LoadShader( | 57 return GLHelper::LoadShader( |
58 GL_FRAGMENT_SHADER, | 58 GL_FRAGMENT_SHADER, |
59 base::StringPrintf("%s\n" | 59 base::StringPrintf("%s\n" |
60 "#define SamplerType sampler2D\n" | 60 "#define SamplerType sampler2D\n" |
61 "#define TextureLookup texture2D\n" | 61 "#define TextureLookup texture2D\n" |
62 "#define TextureScale vec2(1.0, 1.0)\n" | 62 "#define TextureScale vec2(1.0, 1.0)\n" |
63 "%s", | 63 "%s", |
64 is_gles ? kShaderFloatPrecision : "", | 64 is_gles ? kShaderFloatPrecision : "", |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 image->Destroy(true /* have_context */); | 357 image->Destroy(true /* have_context */); |
358 } | 358 } |
359 | 359 |
360 // The GLImageCopyTest test case verifies that the GLImage implementation | 360 // The GLImageCopyTest test case verifies that the GLImage implementation |
361 // handles CopyTexImage correctly. | 361 // handles CopyTexImage correctly. |
362 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); | 362 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); |
363 | 363 |
364 } // namespace gl | 364 } // namespace gl |
365 | 365 |
366 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ | 366 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ |
OLD | NEW |