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

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

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 #include <GLES2/gl2ext.h> 6 #include <GLES2/gl2ext.h>
7 #include <stdint.h>
7 8
8 #include "gpu/command_buffer/tests/gl_manager.h" 9 #include "gpu/command_buffer/tests/gl_manager.h"
9 #include "gpu/command_buffer/tests/gl_test_utils.h" 10 #include "gpu/command_buffer/tests/gl_test_utils.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 14
14 #define SHADER(Src) #Src 15 #define SHADER(Src) #Src
15 16
16 namespace gpu { 17 namespace gpu {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 GLuint program = GLTestHelper::LoadProgram(v_shader_str, f_shader_str); 57 GLuint program = GLTestHelper::LoadProgram(v_shader_str, f_shader_str);
57 glUseProgram(program); 58 glUseProgram(program);
58 return program; 59 return program;
59 } 60 }
60 61
61 } // anonymous namespace. 62 } // anonymous namespace.
62 63
63 TEST_F(GLStreamDrawTest, Basic) { 64 TEST_F(GLStreamDrawTest, Basic) {
64 static GLfloat float_red[4] = { 1.0f, 0.0f, 0.0f, 1.0f, }; 65 static GLfloat float_red[4] = { 1.0f, 0.0f, 0.0f, 1.0f, };
65 static GLfloat float_green[4] = { 0.0f, 1.0f, 0.0f, 1.0f, }; 66 static GLfloat float_green[4] = { 0.0f, 1.0f, 0.0f, 1.0f, };
66 static uint8 expected_red[4] = {255, 0, 0, 255, }; 67 static uint8_t expected_red[4] = {
67 static uint8 expected_green[4] = {0, 255, 0, 255, }; 68 255, 0, 0, 255,
69 };
70 static uint8_t expected_green[4] = {
71 0, 255, 0, 255,
72 };
68 73
69 GLuint program = SetupProgram(); 74 GLuint program = SetupProgram();
70 GLuint position_loc = glGetAttribLocation(program, "a_position"); 75 GLuint position_loc = glGetAttribLocation(program, "a_position");
71 GLuint color_loc = glGetAttribLocation(program, "a_color"); 76 GLuint color_loc = glGetAttribLocation(program, "a_color");
72 GLTestHelper::SetupUnitQuad(position_loc); 77 GLTestHelper::SetupUnitQuad(position_loc);
73 GLTestHelper::SetupColorsForUnitQuad(color_loc, float_red, GL_STREAM_DRAW); 78 GLTestHelper::SetupColorsForUnitQuad(color_loc, float_red, GL_STREAM_DRAW);
74 glDrawArrays(GL_TRIANGLES, 0, 6); 79 glDrawArrays(GL_TRIANGLES, 0, 6);
75 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, kSize, kSize, 0, expected_red)); 80 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, kSize, kSize, 0, expected_red));
76 GLTestHelper::SetupColorsForUnitQuad(color_loc, float_green, GL_STATIC_DRAW); 81 GLTestHelper::SetupColorsForUnitQuad(color_loc, float_green, GL_STATIC_DRAW);
77 glDrawArrays(GL_TRIANGLES, 0, 6); 82 glDrawArrays(GL_TRIANGLES, 0, 6);
78 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, kSize, kSize, 0, expected_green)); 83 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, kSize, kSize, 0, expected_green));
79 84
80 GLTestHelper::CheckGLError("no errors", __LINE__); 85 GLTestHelper::CheckGLError("no errors", __LINE__);
81 } 86 }
82 87
83 // http://crbug.com/281565 88 // http://crbug.com/281565
84 #if !defined(OS_ANDROID) 89 #if !defined(OS_ANDROID)
85 TEST_F(GLStreamDrawTest, DrawElements) { 90 TEST_F(GLStreamDrawTest, DrawElements) {
86 static GLfloat float_red[4] = { 1.0f, 0.0f, 0.0f, 1.0f, }; 91 static GLfloat float_red[4] = { 1.0f, 0.0f, 0.0f, 1.0f, };
87 static GLfloat float_green[4] = { 0.0f, 1.0f, 0.0f, 1.0f, }; 92 static GLfloat float_green[4] = { 0.0f, 1.0f, 0.0f, 1.0f, };
88 static uint8 expected_red[4] = {255, 0, 0, 255, }; 93 static uint8_t expected_red[4] = {
89 static uint8 expected_green[4] = {0, 255, 0, 255, }; 94 255, 0, 0, 255,
95 };
96 static uint8_t expected_green[4] = {
97 0, 255, 0, 255,
98 };
90 99
91 GLuint program = SetupProgram(); 100 GLuint program = SetupProgram();
92 GLuint position_loc = glGetAttribLocation(program, "a_position"); 101 GLuint position_loc = glGetAttribLocation(program, "a_position");
93 GLuint color_loc = glGetAttribLocation(program, "a_color"); 102 GLuint color_loc = glGetAttribLocation(program, "a_color");
94 GLTestHelper::SetupUnitQuad(position_loc); 103 GLTestHelper::SetupUnitQuad(position_loc);
95 GLTestHelper::SetupColorsForUnitQuad(color_loc, float_red, GL_STREAM_DRAW); 104 GLTestHelper::SetupColorsForUnitQuad(color_loc, float_red, GL_STREAM_DRAW);
96 105
97 GLuint index_buffer = 0; 106 GLuint index_buffer = 0;
98 glGenBuffers(1, &index_buffer); 107 glGenBuffers(1, &index_buffer);
99 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer); 108 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer);
(...skipping 13 matching lines...) Expand all
113 } 122 }
114 #endif 123 #endif
115 124
116 TEST_F(GLStreamDrawTest, VertexArrayObjects) { 125 TEST_F(GLStreamDrawTest, VertexArrayObjects) {
117 if (!GLTestHelper::HasExtension("GL_OES_vertex_array_object")) { 126 if (!GLTestHelper::HasExtension("GL_OES_vertex_array_object")) {
118 return; 127 return;
119 } 128 }
120 129
121 static GLfloat float_red[4] = { 1.0f, 0.0f, 0.0f, 1.0f, }; 130 static GLfloat float_red[4] = { 1.0f, 0.0f, 0.0f, 1.0f, };
122 static GLfloat float_green[4] = { 0.0f, 1.0f, 0.0f, 1.0f, }; 131 static GLfloat float_green[4] = { 0.0f, 1.0f, 0.0f, 1.0f, };
123 static uint8 expected_red[4] = {255, 0, 0, 255, }; 132 static uint8_t expected_red[4] = {
124 static uint8 expected_green[4] = {0, 255, 0, 255, }; 133 255, 0, 0, 255,
134 };
135 static uint8_t expected_green[4] = {
136 0, 255, 0, 255,
137 };
125 138
126 GLuint program = SetupProgram(); 139 GLuint program = SetupProgram();
127 GLuint position_loc = glGetAttribLocation(program, "a_position"); 140 GLuint position_loc = glGetAttribLocation(program, "a_position");
128 GLuint color_loc = glGetAttribLocation(program, "a_color"); 141 GLuint color_loc = glGetAttribLocation(program, "a_color");
129 142
130 GLuint vaos[2]; 143 GLuint vaos[2];
131 glGenVertexArraysOES(2, vaos); 144 glGenVertexArraysOES(2, vaos);
132 145
133 glBindVertexArrayOES(vaos[0]); 146 glBindVertexArrayOES(vaos[0]);
134 GLuint position_buffer = GLTestHelper::SetupUnitQuad(position_loc); 147 GLuint position_buffer = GLTestHelper::SetupUnitQuad(position_loc);
(...skipping 14 matching lines...) Expand all
149 glDrawArrays(GL_TRIANGLES, 0, 6); 162 glDrawArrays(GL_TRIANGLES, 0, 6);
150 EXPECT_TRUE( 163 EXPECT_TRUE(
151 GLTestHelper::CheckPixels(0, 0, kSize, kSize, 0, expected_green)); 164 GLTestHelper::CheckPixels(0, 0, kSize, kSize, 0, expected_green));
152 } 165 }
153 166
154 GLTestHelper::CheckGLError("no errors", __LINE__); 167 GLTestHelper::CheckGLError("no errors", __LINE__);
155 } 168 }
156 169
157 } // namespace gpu 170 } // namespace gpu
158 171
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_readback_unittest.cc ('k') | gpu/command_buffer/tests/gl_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698