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

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

Issue 2656563002: Support cube map dest target for CopyTextureCHROMIUM extension (Closed)
Patch Set: fix nits Created 3 years, 10 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
« no previous file with comments | « gpu/command_buffer/tests/gl_test_utils.h ('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 (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 #include "gpu/command_buffer/tests/gl_test_utils.h" 5 #include "gpu/command_buffer/tests/gl_test_utils.h"
6 6
7 #include <GLES2/gl2extchromium.h> 7 #include <GLES2/gl2extchromium.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
16 17
17 // GCC requires these declarations, but MSVC requires they not be present. 18 // GCC requires these declarations, but MSVC requires they not be present.
18 #ifndef COMPILER_MSVC 19 #ifndef COMPILER_MSVC
19 const uint8_t GLTestHelper::kCheckClearValue; 20 const uint8_t GLTestHelper::kCheckClearValue;
20 #endif 21 #endif
21 22
22 bool GLTestHelper::HasExtension(const char* extension) { 23 bool GLTestHelper::HasExtension(const char* extension) {
23 // Pad with an extra space to ensure that |extension| is not a substring of 24 // Pad with an extra space to ensure that |extension| is not a substring of
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 Set32BitValue(bih.clr_used, 0); 271 Set32BitValue(bih.clr_used, 0);
271 Set32BitValue(bih.clr_important, 0); 272 Set32BitValue(bih.clr_important, 0);
272 273
273 fwrite(&bhf, sizeof(bhf), 1, fp); 274 fwrite(&bhf, sizeof(bhf), 1, fp);
274 fwrite(&bih, sizeof(bih), 1, fp); 275 fwrite(&bih, sizeof(bih), 1, fp);
275 fwrite(pixels, size, 1, fp); 276 fwrite(pixels, size, 1, fp);
276 fclose(fp); 277 fclose(fp);
277 return true; 278 return true;
278 } 279 }
279 280
280 void GLTestHelper::DrawTextureQuad(const char* vertex_src, 281 void GLTestHelper::DrawTextureQuad(const GLenum texture_target,
282 const char* vertex_src,
281 const char* fragment_src, 283 const char* fragment_src,
282 const char* position_name, 284 const char* position_name,
283 const char* sampler_name) { 285 const char* sampler_name,
286 const char* face_name) {
284 GLuint program = GLTestHelper::LoadProgram(vertex_src, fragment_src); 287 GLuint program = GLTestHelper::LoadProgram(vertex_src, fragment_src);
285 EXPECT_NE(program, 0u); 288 EXPECT_NE(program, 0u);
286 glUseProgram(program); 289 glUseProgram(program);
287 290
288 GLint position_loc = glGetAttribLocation(program, position_name); 291 GLint position_loc = glGetAttribLocation(program, position_name);
289 GLint sampler_location = glGetUniformLocation(program, sampler_name); 292 GLint sampler_location = glGetUniformLocation(program, sampler_name);
290 ASSERT_NE(position_loc, -1); 293 ASSERT_NE(position_loc, -1);
291 ASSERT_NE(sampler_location, -1); 294 ASSERT_NE(sampler_location, -1);
295 GLint face_loc = -1;
296 if (gpu::gles2::GLES2Util::GLFaceTargetToTextureTarget(texture_target) ==
297 GL_TEXTURE_CUBE_MAP) {
298 ASSERT_NE(face_name, nullptr);
299 face_loc = glGetUniformLocation(program, face_name);
300 ASSERT_NE(face_loc, -1);
301 glUniform1i(face_loc, texture_target);
302 }
292 303
293 GLuint vertex_buffer = GLTestHelper::SetupUnitQuad(position_loc); 304 GLuint vertex_buffer = GLTestHelper::SetupUnitQuad(position_loc);
294 ASSERT_NE(vertex_buffer, 0u); 305 ASSERT_NE(vertex_buffer, 0u);
295 glActiveTexture(GL_TEXTURE0); 306 glActiveTexture(GL_TEXTURE0);
296 glUniform1i(sampler_location, 0); 307 glUniform1i(sampler_location, 0);
297 308
298 glDrawArrays(GL_TRIANGLES, 0, 6); 309 glDrawArrays(GL_TRIANGLES, 0, 6);
299 310
300 glDeleteProgram(program); 311 glDeleteProgram(program);
301 glDeleteBuffers(1, &vertex_buffer); 312 glDeleteBuffers(1, &vertex_buffer);
302 } 313 }
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698