Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: gpu/command_buffer/tests/gl_test_utils.h

Issue 2602563002: Refactor DrawTextureQuad and CheckPixels in gl_tests util (Closed)
Patch Set: rebase only Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 13 #include <vector>
14 14
15 namespace gfx {
16 class Size;
17 } // namespace gfx
18
19 class GLTestHelper { 15 class GLTestHelper {
20 public: 16 public:
21 static const uint8_t kCheckClearValue = 123u; 17 static const uint8_t kCheckClearValue = 123u;
22 18
23 static bool HasExtension(const char* extension); 19 static bool HasExtension(const char* extension);
24 static bool CheckGLError(const char* msg, int line); 20 static bool CheckGLError(const char* msg, int line);
25 21
26 // Compiles a shader. 22 // Compiles a shader.
27 // Does not check for errors, always returns shader. 23 // Does not check for errors, always returns shader.
28 static GLuint CompileShader(GLenum type, const char* shaderSrc); 24 static GLuint CompileShader(GLenum type, const char* shaderSrc);
(...skipping 23 matching lines...) Expand all
52 // Returns a vector of size 2. The first is the array buffer object, 48 // Returns a vector of size 2. The first is the array buffer object,
53 // the second is the element array buffer object. 49 // the second is the element array buffer object.
54 static std::vector<GLuint> SetupIndexedUnitQuad(GLint position_location); 50 static std::vector<GLuint> SetupIndexedUnitQuad(GLint position_location);
55 51
56 // Make a 6 vertex colors. 52 // Make a 6 vertex colors.
57 // Returns the created buffer. 53 // Returns the created buffer.
58 static GLuint SetupColorsForUnitQuad( 54 static GLuint SetupColorsForUnitQuad(
59 GLint location, const GLfloat color[4], GLenum usage); 55 GLint location, const GLfloat color[4], GLenum usage);
60 56
61 // Checks an area of pixels for a color. 57 // Checks an area of pixels for a color.
58 // If mask is nullptr, compare all color channels; otherwise, compare the
59 // channels whose corresponding mask bit is true.
62 static bool CheckPixels(GLint x, 60 static bool CheckPixels(GLint x,
63 GLint y, 61 GLint y,
64 GLsizei width, 62 GLsizei width,
65 GLsizei height, 63 GLsizei height,
66 GLint tolerance, 64 GLint tolerance,
67 const uint8_t* color); 65 const uint8_t* color,
66 const uint8_t* mask);
68 67
69 // Uses ReadPixels to save an area of the current FBO/Backbuffer. 68 // Uses ReadPixels to save an area of the current FBO/Backbuffer.
70 static bool SaveBackbufferAsBMP(const char* filename, int width, int height); 69 static bool SaveBackbufferAsBMP(const char* filename, int width, int height);
71 70
72 static void DrawTextureQuad(GLenum target, const gfx::Size& size); 71 static void DrawTextureQuad(const char* vertex_src,
72 const char* fragment_src,
73 const char* position_name,
74 const char* sampler_name);
73 }; 75 };
74 76
75 #endif // GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_ 77 #endif // GPU_COMMAND_BUFFER_TESTS_GL_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_stream_draw_unittest.cc ('k') | gpu/command_buffer/tests/gl_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698