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

Side by Side Diff: ui/gl/test/gl_image_test_template.h

Issue 2094823002: gl_unittests: on a core profile, use VAOs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« ui/gl/gl_helper.cc ('K') | « ui/gl/gl_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 const char kVertexShader[] = STRINGIZE( 103 const char kVertexShader[] = STRINGIZE(
104 attribute vec2 a_position; 104 attribute vec2 a_position;
105 varying vec2 v_texCoord; 105 varying vec2 v_texCoord;
106 void main() { 106 void main() {
107 gl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0); 107 gl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);
108 v_texCoord = (a_position + vec2(1.0, 1.0)) * 0.5; 108 v_texCoord = (a_position + vec2(1.0, 1.0)) * 0.5;
109 } 109 }
110 ); 110 );
111 // clang-format on 111 // clang-format on
112 112
113 GLuint vao = 0;
114 if (GLHelper::ShouldTestsUseVAOs()) {
115 glGenVertexArraysOES(1, &vao);
116 glBindVertexArrayOES(vao);
117 }
118
113 GLuint vertex_shader = GLHelper::LoadShader(GL_VERTEX_SHADER, kVertexShader); 119 GLuint vertex_shader = GLHelper::LoadShader(GL_VERTEX_SHADER, kVertexShader);
114 GLuint fragment_shader = LoadFragmentShader(target, size); 120 GLuint fragment_shader = LoadFragmentShader(target, size);
115 GLuint program = GLHelper::SetupProgram(vertex_shader, fragment_shader); 121 GLuint program = GLHelper::SetupProgram(vertex_shader, fragment_shader);
116 EXPECT_NE(program, 0u); 122 EXPECT_NE(program, 0u);
117 glUseProgram(program); 123 glUseProgram(program);
118 124
119 GLint sampler_location = glGetUniformLocation(program, "a_texture"); 125 GLint sampler_location = glGetUniformLocation(program, "a_texture");
120 ASSERT_NE(sampler_location, -1); 126 ASSERT_NE(sampler_location, -1);
121 glUniform1i(sampler_location, 0); 127 glUniform1i(sampler_location, 0);
122 128
123 GLuint vertex_buffer = GLHelper::SetupQuadVertexBuffer(); 129 GLuint vertex_buffer = GLHelper::SetupQuadVertexBuffer();
124 GLHelper::DrawQuad(vertex_buffer); 130 GLHelper::DrawQuad(vertex_buffer);
125 131
132 if (vao != 0) {
133 glDeleteVertexArraysOES(1, &vao);
134 }
135
126 glDeleteShader(vertex_shader); 136 glDeleteShader(vertex_shader);
127 glDeleteShader(fragment_shader); 137 glDeleteShader(fragment_shader);
128 glDeleteProgram(program); 138 glDeleteProgram(program);
129 glDeleteBuffersARB(1, &vertex_buffer); 139 glDeleteBuffersARB(1, &vertex_buffer);
130 } 140 }
131 141
132 } // namespace 142 } // namespace
133 143
134 template <typename GLImageTestDelegate> 144 template <typename GLImageTestDelegate>
135 class GLImageTest : public testing::Test { 145 class GLImageTest : public testing::Test {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 image->Destroy(true /* have_context */); 352 image->Destroy(true /* have_context */);
343 } 353 }
344 354
345 // The GLImageCopyTest test case verifies that the GLImage implementation 355 // The GLImageCopyTest test case verifies that the GLImage implementation
346 // handles CopyTexImage correctly. 356 // handles CopyTexImage correctly.
347 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); 357 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage);
348 358
349 } // namespace gl 359 } // namespace gl
350 360
351 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ 361 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_
OLDNEW
« ui/gl/gl_helper.cc ('K') | « ui/gl/gl_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698