OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // A class to emluate GLES2 over command buffers. | 5 // A class to emluate GLES2 over command buffers. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 // TODO(gman): remove when all functions have been implemented. | |
9 #include "gpu/command_buffer/client/gles2_implementation_gen.h" | |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
11 | 9 |
12 namespace gpu { | 10 namespace gpu { |
13 namespace gles2 { | 11 namespace gles2 { |
14 | 12 |
15 // A 32-bit and 64-bit compatible way of converting a pointer to a GLuint. | 13 // A 32-bit and 64-bit compatible way of converting a pointer to a GLuint. |
16 static GLuint ToGLuint(const void* ptr) { | 14 static GLuint ToGLuint(const void* ptr) { |
17 return static_cast<GLuint>(reinterpret_cast<size_t>(ptr)); | 15 return static_cast<GLuint>(reinterpret_cast<size_t>(ptr)); |
18 } | 16 } |
19 | 17 |
(...skipping 29 matching lines...) Expand all Loading... |
49 ids[ii] = id_allocator_.AllocateID(); | 47 ids[ii] = id_allocator_.AllocateID(); |
50 } | 48 } |
51 } | 49 } |
52 | 50 |
53 void GLES2Implementation::FreeIds(GLsizei n, const GLuint* ids) { | 51 void GLES2Implementation::FreeIds(GLsizei n, const GLuint* ids) { |
54 for (GLsizei ii = 0; ii < n; ++ii) { | 52 for (GLsizei ii = 0; ii < n; ++ii) { |
55 id_allocator_.FreeID(ids[ii]); | 53 id_allocator_.FreeID(ids[ii]); |
56 } | 54 } |
57 } | 55 } |
58 | 56 |
| 57 void GLES2Implementation::CopyResult(void* dst) { |
| 58 SizedResult* result = static_cast<SizedResult*>(result_buffer_); |
| 59 memcpy(dst, result->GetDataAs<void*>(), result->size); |
| 60 } |
| 61 |
59 void GLES2Implementation::WaitForCmd() { | 62 void GLES2Implementation::WaitForCmd() { |
60 int32 token = helper_->InsertToken(); | 63 int32 token = helper_->InsertToken(); |
61 helper_->WaitForToken(token); | 64 helper_->WaitForToken(token); |
62 } | 65 } |
63 | 66 |
64 void GLES2Implementation::DrawElements( | 67 void GLES2Implementation::DrawElements( |
65 GLenum mode, GLsizei count, GLenum type, const void* indices) { | 68 GLenum mode, GLsizei count, GLenum type, const void* indices) { |
66 helper_->DrawElements(mode, count, type, ToGLuint(indices)); | 69 helper_->DrawElements(mode, count, type, ToGLuint(indices)); |
67 } | 70 } |
68 | 71 |
69 void GLES2Implementation::Finish() { | 72 void GLES2Implementation::Finish() { |
70 helper_->Finish(); | 73 helper_->Finish(); |
71 WaitForCmd(); | 74 WaitForCmd(); |
72 } | 75 } |
73 | 76 |
74 void GLES2Implementation::SwapBuffers() { | 77 void GLES2Implementation::SwapBuffers() { |
75 helper_->SwapBuffers(); | 78 helper_->SwapBuffers(); |
76 Finish(); | 79 Finish(); |
77 } | 80 } |
78 | 81 |
| 82 void GLES2Implementation::GetVertexAttribPointerv( |
| 83 GLuint index, GLenum pname, void** ptr) { |
| 84 helper_->GetVertexAttribPointerv( |
| 85 index, pname, result_shm_id(), result_shm_offset()); |
| 86 WaitForCmd(); |
| 87 CopyResult(ptr); |
| 88 }; |
| 89 |
79 GLint GLES2Implementation::GetAttribLocation( | 90 GLint GLES2Implementation::GetAttribLocation( |
80 GLuint program, const char* name) { | 91 GLuint program, const char* name) { |
81 helper_->GetAttribLocationImmediate( | 92 helper_->GetAttribLocationImmediate( |
82 program, name, result_shm_id(), result_shm_offset()); | 93 program, name, result_shm_id(), result_shm_offset()); |
83 WaitForCmd(); | 94 WaitForCmd(); |
84 return GetResultAs<GLint>(); | 95 return GetResultAs<GLint>(); |
85 } | 96 } |
86 | 97 |
87 GLint GLES2Implementation::GetUniformLocation( | 98 GLint GLES2Implementation::GetUniformLocation( |
88 GLuint program, const char* name) { | 99 GLuint program, const char* name) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 temp_xoffset += num_pixels; | 274 temp_xoffset += num_pixels; |
264 temp_width -= num_pixels; | 275 temp_width -= num_pixels; |
265 } | 276 } |
266 ++yoffset; | 277 ++yoffset; |
267 source += padded_row_size; | 278 source += padded_row_size; |
268 } | 279 } |
269 } | 280 } |
270 } | 281 } |
271 | 282 |
272 | 283 |
| 284 GLenum GLES2Implementation::CheckFramebufferStatus(GLenum target) { |
| 285 // TODO(gman): implement. |
| 286 return 0; |
| 287 } |
| 288 |
| 289 void GLES2Implementation::GetActiveAttrib( |
| 290 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| 291 GLenum* type, char* name) { |
| 292 // TODO(gman): implement. |
| 293 } |
| 294 |
| 295 void GLES2Implementation::GetActiveUniform( |
| 296 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| 297 GLenum* type, char* name) { |
| 298 // TODO(gman): implement. |
| 299 } |
| 300 |
| 301 void GLES2Implementation::GetAttachedShaders( |
| 302 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { |
| 303 // TODO(gman): implement. |
| 304 } |
| 305 |
| 306 void GLES2Implementation::GetProgramInfoLog( |
| 307 GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { |
| 308 // TODO(gman): implement. |
| 309 } |
| 310 |
| 311 void GLES2Implementation::GetShaderInfoLog( |
| 312 GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { |
| 313 // TODO(gman): implement. |
| 314 } |
| 315 |
| 316 void GLES2Implementation::GetShaderPrecisionFormat( |
| 317 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { |
| 318 // TODO(gman): implement. |
| 319 } |
| 320 |
| 321 void GLES2Implementation::GetShaderSource( |
| 322 GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { |
| 323 // TODO(gman): implement. |
| 324 } |
| 325 |
| 326 const GLubyte* GLES2Implementation::GetString(GLenum name) { |
| 327 // TODO(gman): implement. |
| 328 return 0; |
| 329 } |
| 330 |
| 331 void GLES2Implementation::GetUniformfv( |
| 332 GLuint program, GLint location, GLfloat* params) { |
| 333 // TODO(gman): implement. |
| 334 } |
| 335 |
| 336 void GLES2Implementation::GetUniformiv( |
| 337 GLuint program, GLint location, GLint* params) { |
| 338 // TODO(gman): implement. |
| 339 } |
| 340 |
| 341 void GLES2Implementation::ReadPixels( |
| 342 GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, |
| 343 void* pixels) { |
| 344 // TODO(gman): implement. |
| 345 } |
| 346 |
273 } // namespace gles2 | 347 } // namespace gles2 |
274 } // namespace gpu | 348 } // namespace gpu |
OLD | NEW |