| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Helper functions for GL. | 5 // Helper functions for GL. |
| 6 | 6 |
| 7 #ifndef GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_ | 7 #ifndef GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_ |
| 8 #define GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_ | 8 #define GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_ |
| 9 | 9 |
| 10 #include <GLES2/gl2.h> | 10 #include <GLES2/gl2.h> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include <vector> |
| 14 |
| 13 namespace gfx { | 15 namespace gfx { |
| 14 class Size; | 16 class Size; |
| 15 } // namespace gfx | 17 } // namespace gfx |
| 16 | 18 |
| 17 class GLTestHelper { | 19 class GLTestHelper { |
| 18 public: | 20 public: |
| 19 static const uint8_t kCheckClearValue = 123u; | 21 static const uint8_t kCheckClearValue = 123u; |
| 20 | 22 |
| 21 static bool HasExtension(const char* extension); | 23 static bool HasExtension(const char* extension); |
| 22 static bool CheckGLError(const char* msg, int line); | 24 static bool CheckGLError(const char* msg, int line); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 // Compiles 2 shaders, attaches and links them to a program | 42 // Compiles 2 shaders, attaches and links them to a program |
| 41 // Returns program, 0 on failure. | 43 // Returns program, 0 on failure. |
| 42 static GLuint LoadProgram( | 44 static GLuint LoadProgram( |
| 43 const char* vertex_shader_source, | 45 const char* vertex_shader_source, |
| 44 const char* fragment_shader_source); | 46 const char* fragment_shader_source); |
| 45 | 47 |
| 46 // Make a unit quad with position only. | 48 // Make a unit quad with position only. |
| 47 // Returns the created buffer. | 49 // Returns the created buffer. |
| 48 static GLuint SetupUnitQuad(GLint position_location); | 50 static GLuint SetupUnitQuad(GLint position_location); |
| 49 | 51 |
| 52 // Returns a vector of size 2. The first is the array buffer object, |
| 53 // the second is the element array buffer object. |
| 54 static std::vector<GLuint> SetupIndexedUnitQuad(GLint position_location); |
| 55 |
| 50 // Make a 6 vertex colors. | 56 // Make a 6 vertex colors. |
| 51 // Returns the created buffer. | 57 // Returns the created buffer. |
| 52 static GLuint SetupColorsForUnitQuad( | 58 static GLuint SetupColorsForUnitQuad( |
| 53 GLint location, const GLfloat color[4], GLenum usage); | 59 GLint location, const GLfloat color[4], GLenum usage); |
| 54 | 60 |
| 55 // Checks an area of pixels for a color. | 61 // Checks an area of pixels for a color. |
| 56 static bool CheckPixels(GLint x, | 62 static bool CheckPixels(GLint x, |
| 57 GLint y, | 63 GLint y, |
| 58 GLsizei width, | 64 GLsizei width, |
| 59 GLsizei height, | 65 GLsizei height, |
| 60 GLint tolerance, | 66 GLint tolerance, |
| 61 const uint8_t* color); | 67 const uint8_t* color); |
| 62 | 68 |
| 63 // Uses ReadPixels to save an area of the current FBO/Backbuffer. | 69 // Uses ReadPixels to save an area of the current FBO/Backbuffer. |
| 64 static bool SaveBackbufferAsBMP(const char* filename, int width, int height); | 70 static bool SaveBackbufferAsBMP(const char* filename, int width, int height); |
| 65 | 71 |
| 66 static void DrawTextureQuad(GLenum target, const gfx::Size& size); | 72 static void DrawTextureQuad(GLenum target, const gfx::Size& size); |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 #endif // GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_ | 75 #endif // GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_ |
| OLD | NEW |