| 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 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 9 | 9 |
| 10 namespace gpu { | 10 namespace gpu { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 id_allocator_.FreeID(ids[ii]); | 53 id_allocator_.FreeID(ids[ii]); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 void GLES2Implementation::CopyResult(void* dst) { | 57 void GLES2Implementation::CopyResult(void* dst) { |
| 58 SizedResult* result = static_cast<SizedResult*>(result_buffer_); | 58 SizedResult* result = static_cast<SizedResult*>(result_buffer_); |
| 59 memcpy(dst, result->GetDataAs<void*>(), result->size); | 59 memcpy(dst, result->GetDataAs<void*>(), result->size); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void GLES2Implementation::WaitForCmd() { | 62 void GLES2Implementation::WaitForCmd() { |
| 63 int32 token = helper_->InsertToken(); | 63 helper_->CommandBufferHelper::Finish(); |
| 64 helper_->WaitForToken(token); | |
| 65 } | 64 } |
| 66 | 65 |
| 67 void GLES2Implementation::DrawElements( | 66 void GLES2Implementation::DrawElements( |
| 68 GLenum mode, GLsizei count, GLenum type, const void* indices) { | 67 GLenum mode, GLsizei count, GLenum type, const void* indices) { |
| 69 helper_->DrawElements(mode, count, type, ToGLuint(indices)); | 68 helper_->DrawElements(mode, count, type, ToGLuint(indices)); |
| 70 } | 69 } |
| 71 | 70 |
| 71 void GLES2Implementation::Flush() { |
| 72 // Insert the cmd to call glFlush |
| 73 helper_->Flush(); |
| 74 // Flush our command buffer |
| 75 // (tell the service to execute upto the flush cmd.) |
| 76 helper_->CommandBufferHelper::Flush(); |
| 77 } |
| 78 |
| 72 void GLES2Implementation::Finish() { | 79 void GLES2Implementation::Finish() { |
| 80 // Insert the cmd to call glFinish |
| 73 helper_->Finish(); | 81 helper_->Finish(); |
| 74 WaitForCmd(); | 82 // Flinish our command buffer |
| 83 // (tell the service to execute upto the Finish cmd and wait for it to |
| 84 // execute.) |
| 85 helper_->CommandBufferHelper::Finish(); |
| 75 } | 86 } |
| 76 | 87 |
| 77 void GLES2Implementation::SwapBuffers() { | 88 void GLES2Implementation::SwapBuffers() { |
| 78 helper_->SwapBuffers(); | 89 helper_->SwapBuffers(); |
| 79 Finish(); | 90 Flush(); |
| 80 } | 91 } |
| 81 | 92 |
| 82 void GLES2Implementation::GetVertexAttribPointerv( | 93 void GLES2Implementation::GetVertexAttribPointerv( |
| 83 GLuint index, GLenum pname, void** ptr) { | 94 GLuint index, GLenum pname, void** ptr) { |
| 84 helper_->GetVertexAttribPointerv( | 95 helper_->GetVertexAttribPointerv( |
| 85 index, pname, result_shm_id(), result_shm_offset()); | 96 index, pname, result_shm_id(), result_shm_offset()); |
| 86 WaitForCmd(); | 97 WaitForCmd(); |
| 87 CopyResult(ptr); | 98 CopyResult(ptr); |
| 88 }; | 99 }; |
| 89 | 100 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 350 } |
| 340 | 351 |
| 341 void GLES2Implementation::ReadPixels( | 352 void GLES2Implementation::ReadPixels( |
| 342 GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, | 353 GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, |
| 343 void* pixels) { | 354 void* pixels) { |
| 344 // TODO(gman): implement. | 355 // TODO(gman): implement. |
| 345 } | 356 } |
| 346 | 357 |
| 347 } // namespace gles2 | 358 } // namespace gles2 |
| 348 } // namespace gpu | 359 } // namespace gpu |
| OLD | NEW |