| 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 "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/strings/stringize_macros.h" | 14 #include "base/strings/stringize_macros.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "build/build_config.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gfx/buffer_format_util.h" | 18 #include "ui/gfx/buffer_format_util.h" |
| 18 #include "ui/gfx/buffer_types.h" | 19 #include "ui/gfx/buffer_types.h" |
| 19 #include "ui/gl/gl_bindings.h" | 20 #include "ui/gl/gl_bindings.h" |
| 20 #include "ui/gl/gl_context.h" | 21 #include "ui/gl/gl_context.h" |
| 21 #include "ui/gl/gl_helper.h" | 22 #include "ui/gl/gl_helper.h" |
| 22 #include "ui/gl/gl_image.h" | 23 #include "ui/gl/gl_image.h" |
| 23 #include "ui/gl/gl_implementation.h" | 24 #include "ui/gl/gl_implementation.h" |
| 24 #include "ui/gl/gl_surface.h" | 25 #include "ui/gl/gl_surface.h" |
| 25 #include "ui/gl/test/gl_image_test_support.h" | 26 #include "ui/gl/test/gl_image_test_support.h" |
| 26 #include "ui/gl/test/gl_test_helper.h" | 27 #include "ui/gl/test/gl_test_helper.h" |
| 27 | 28 |
| 29 #if defined(OS_MACOSX) |
| 30 #include "base/mac/mac_util.h" |
| 31 #endif |
| 32 |
| 28 namespace gl { | 33 namespace gl { |
| 29 namespace { | 34 namespace { |
| 30 | 35 |
| 31 // Compiles a fragment shader for sampling out of a texture of |size| bound to | 36 // Compiles a fragment shader for sampling out of a texture of |size| bound to |
| 32 // |target| and checks for compilation errors. | 37 // |target| and checks for compilation errors. |
| 33 GLuint LoadFragmentShader(unsigned target, const gfx::Size& size) { | 38 GLuint LoadFragmentShader(unsigned target, const gfx::Size& size) { |
| 34 // clang-format off | 39 // clang-format off |
| 35 const char kFragmentShader[] = STRINGIZE( | 40 const char kFragmentShader[] = STRINGIZE( |
| 36 uniform SamplerType a_texture; | 41 uniform SamplerType a_texture; |
| 37 varying vec2 v_texCoord; | 42 varying vec2 v_texCoord; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 REGISTER_TYPED_TEST_CASE_P(GLImageTest, CreateAndDestroy); | 176 REGISTER_TYPED_TEST_CASE_P(GLImageTest, CreateAndDestroy); |
| 172 | 177 |
| 173 template <typename GLImageTestDelegate> | 178 template <typename GLImageTestDelegate> |
| 174 class GLImageZeroInitializeTest : public GLImageTest<GLImageTestDelegate> {}; | 179 class GLImageZeroInitializeTest : public GLImageTest<GLImageTestDelegate> {}; |
| 175 | 180 |
| 176 // This test verifies that if an uninitialized image is bound to a texture, the | 181 // This test verifies that if an uninitialized image is bound to a texture, the |
| 177 // result is zero-initialized. | 182 // result is zero-initialized. |
| 178 TYPED_TEST_CASE_P(GLImageZeroInitializeTest); | 183 TYPED_TEST_CASE_P(GLImageZeroInitializeTest); |
| 179 | 184 |
| 180 TYPED_TEST_P(GLImageZeroInitializeTest, ZeroInitialize) { | 185 TYPED_TEST_P(GLImageZeroInitializeTest, ZeroInitialize) { |
| 186 #if defined(OS_MACOSX) |
| 187 // This functionality is disabled on Mavericks because it breaks PDF |
| 188 // rendering. https://crbug.com/594343. |
| 189 if (base::mac::IsOSMavericks()) |
| 190 return; |
| 191 #endif |
| 192 |
| 181 const gfx::Size image_size(256, 256); | 193 const gfx::Size image_size(256, 256); |
| 182 | 194 |
| 183 GLuint framebuffer = | 195 GLuint framebuffer = |
| 184 GLTestHelper::SetupFramebuffer(image_size.width(), image_size.height()); | 196 GLTestHelper::SetupFramebuffer(image_size.width(), image_size.height()); |
| 185 ASSERT_TRUE(framebuffer); | 197 ASSERT_TRUE(framebuffer); |
| 186 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer); | 198 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer); |
| 187 glViewport(0, 0, image_size.width(), image_size.height()); | 199 glViewport(0, 0, image_size.width(), image_size.height()); |
| 188 | 200 |
| 189 // Create an uninitialized image of preferred format. | 201 // Create an uninitialized image of preferred format. |
| 190 scoped_refptr<gl::GLImage> image = this->delegate_.CreateImage(image_size); | 202 scoped_refptr<gl::GLImage> image = this->delegate_.CreateImage(image_size); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 image->Destroy(true /* have_context */); | 285 image->Destroy(true /* have_context */); |
| 274 } | 286 } |
| 275 | 287 |
| 276 // The GLImageCopyTest test case verifies that the GLImage implementation | 288 // The GLImageCopyTest test case verifies that the GLImage implementation |
| 277 // handles CopyTexImage correctly. | 289 // handles CopyTexImage correctly. |
| 278 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); | 290 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); |
| 279 | 291 |
| 280 } // namespace gl | 292 } // namespace gl |
| 281 | 293 |
| 282 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ | 294 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ |
| OLD | NEW |