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 #include <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
7 | 7 |
8 #include "gpu/command_buffer/tests/gl_manager.h" | 8 #include "gpu/command_buffer/tests/gl_manager.h" |
9 #include "gpu/command_buffer/tests/gl_test_utils.h" | 9 #include "gpu/command_buffer/tests/gl_test_utils.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 GLManager gl_; | 34 GLManager gl_; |
35 }; | 35 }; |
36 | 36 |
37 GLuint PointCoordTest::SetupQuad( | 37 GLuint PointCoordTest::SetupQuad( |
38 GLint position_location, GLfloat pixel_offset) { | 38 GLint position_location, GLfloat pixel_offset) { |
39 GLuint vbo = 0; | 39 GLuint vbo = 0; |
40 glGenBuffers(1, &vbo); | 40 glGenBuffers(1, &vbo); |
41 glBindBuffer(GL_ARRAY_BUFFER, vbo); | 41 glBindBuffer(GL_ARRAY_BUFFER, vbo); |
42 float vertices[] = { | 42 float vertices[] = { |
43 -0.5 + pixel_offset, -0.5 + pixel_offset, | 43 -0.5f + pixel_offset, -0.5f + pixel_offset, |
44 0.5 + pixel_offset, -0.5 + pixel_offset, | 44 0.5f + pixel_offset, -0.5f + pixel_offset, |
45 -0.5 + pixel_offset, 0.5 + pixel_offset, | 45 -0.5f + pixel_offset, 0.5f + pixel_offset, |
46 0.5 + pixel_offset, 0.5 + pixel_offset, | 46 0.5f + pixel_offset, 0.5f + pixel_offset, |
47 }; | 47 }; |
48 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); | 48 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); |
49 glEnableVertexAttribArray(position_location); | 49 glEnableVertexAttribArray(position_location); |
50 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0); | 50 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0); |
51 | 51 |
52 return vbo; | 52 return vbo; |
53 } | 53 } |
54 | 54 |
55 namespace { | 55 namespace { |
56 | 56 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // formula for s and t from OpenGL ES 2.0 spec section 3.3 | 129 // formula for s and t from OpenGL ES 2.0 spec section 3.3 |
130 GLfloat xw = s2p(point_x); | 130 GLfloat xw = s2p(point_x); |
131 GLfloat yw = s2p(point_y); | 131 GLfloat yw = s2p(point_y); |
132 GLfloat u = xx / max_point_size * 2 - 1; | 132 GLfloat u = xx / max_point_size * 2 - 1; |
133 GLfloat v = yy / max_point_size * 2 - 1; | 133 GLfloat v = yy / max_point_size * 2 - 1; |
134 GLint xf = s2p(point_x + u * point_width); | 134 GLint xf = s2p(point_x + u * point_width); |
135 GLint yf = s2p(point_y + v * point_width); | 135 GLint yf = s2p(point_y + v * point_width); |
136 GLfloat s = 0.5 + (xf + 0.5 - xw) / max_point_size; | 136 GLfloat s = 0.5 + (xf + 0.5 - xw) / max_point_size; |
137 GLfloat t = 0.5 + (yf + 0.5 - yw) / max_point_size; | 137 GLfloat t = 0.5 + (yf + 0.5 - yw) / max_point_size; |
138 uint8 color[4] = { | 138 uint8 color[4] = { |
139 s * 255, | 139 static_cast<uint8>(s * 255), |
140 (1 - t) * 255, | 140 static_cast<uint8>((1 - t) * 255), |
141 0, | 141 0, |
142 255, | 142 255, |
143 }; | 143 }; |
144 GLTestHelper::CheckPixels(xf, yf, 1, 1, 4, color); | 144 GLTestHelper::CheckPixels(xf, yf, 1, 1, 4, color); |
145 } | 145 } |
146 } | 146 } |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 GLTestHelper::CheckGLError("no errors", __LINE__); | 150 GLTestHelper::CheckGLError("no errors", __LINE__); |
151 } | 151 } |
152 | 152 |
153 } // namespace gpu | 153 } // namespace gpu |
154 | 154 |
155 | 155 |
156 | 156 |
OLD | NEW |