| 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 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
| 6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
| 7 | 7 |
| 8 #include <GLES2/gl2.h> | 8 #include <GLES2/gl2.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 struct GLUniformDefinitionCHROMIUM; | 87 struct GLUniformDefinitionCHROMIUM; |
| 88 | 88 |
| 89 namespace gpu { | 89 namespace gpu { |
| 90 | 90 |
| 91 class MappedMemoryManager; | 91 class MappedMemoryManager; |
| 92 class ScopedTransferBufferPtr; | 92 class ScopedTransferBufferPtr; |
| 93 class TransferBufferInterface; | 93 class TransferBufferInterface; |
| 94 | 94 |
| 95 namespace gles2 { | 95 namespace gles2 { |
| 96 | 96 |
| 97 class ClientSideBufferHelper; | 97 class VertexArrayObjectManager; |
| 98 | 98 |
| 99 // This class emulates GLES2 over command buffers. It can be used by a client | 99 // This class emulates GLES2 over command buffers. It can be used by a client |
| 100 // program so that the program does not need deal with shared memory and command | 100 // program so that the program does not need deal with shared memory and command |
| 101 // buffer management. See gl2_lib.h. Note that there is a performance gain to | 101 // buffer management. See gl2_lib.h. Note that there is a performance gain to |
| 102 // be had by changing your code to use command buffers directly by using the | 102 // be had by changing your code to use command buffers directly by using the |
| 103 // GLES2CmdHelper but that entails changing your code to use and deal with | 103 // GLES2CmdHelper but that entails changing your code to use and deal with |
| 104 // shared memory and synchronization issues. | 104 // shared memory and synchronization issues. |
| 105 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { | 105 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { |
| 106 public: | 106 public: |
| 107 class ErrorMessageCallback { | 107 class ErrorMessageCallback { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 205 |
| 206 void SetErrorMessageCallback(ErrorMessageCallback* callback) { | 206 void SetErrorMessageCallback(ErrorMessageCallback* callback) { |
| 207 error_message_callback_ = callback; | 207 error_message_callback_ = callback; |
| 208 } | 208 } |
| 209 | 209 |
| 210 ShareGroup* share_group() const { | 210 ShareGroup* share_group() const { |
| 211 return share_group_.get(); | 211 return share_group_.get(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 private: | 214 private: |
| 215 friend class ClientSideBufferHelper; | |
| 216 friend class GLES2ImplementationTest; | 215 friend class GLES2ImplementationTest; |
| 216 friend class VertexArrayObjectManager; |
| 217 | 217 |
| 218 // Used to track whether an extension is available | 218 // Used to track whether an extension is available |
| 219 enum ExtensionStatus { | 219 enum ExtensionStatus { |
| 220 kAvailableExtensionStatus, | 220 kAvailableExtensionStatus, |
| 221 kUnavailableExtensionStatus, | 221 kUnavailableExtensionStatus, |
| 222 kUnknownExtensionStatus | 222 kUnknownExtensionStatus |
| 223 }; | 223 }; |
| 224 | 224 |
| 225 // Base class for mapped resources. | 225 // Base class for mapped resources. |
| 226 struct MappedResource { | 226 struct MappedResource { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 bool IsRenderbufferReservedId(GLuint id) { return false; } | 382 bool IsRenderbufferReservedId(GLuint id) { return false; } |
| 383 bool IsTextureReservedId(GLuint id) { return false; } | 383 bool IsTextureReservedId(GLuint id) { return false; } |
| 384 bool IsVertexArrayReservedId(GLuint id) { return false; } | 384 bool IsVertexArrayReservedId(GLuint id) { return false; } |
| 385 | 385 |
| 386 void BindBufferHelper(GLenum target, GLuint texture); | 386 void BindBufferHelper(GLenum target, GLuint texture); |
| 387 void BindFramebufferHelper(GLenum target, GLuint texture); | 387 void BindFramebufferHelper(GLenum target, GLuint texture); |
| 388 void BindRenderbufferHelper(GLenum target, GLuint texture); | 388 void BindRenderbufferHelper(GLenum target, GLuint texture); |
| 389 void BindTextureHelper(GLenum target, GLuint texture); | 389 void BindTextureHelper(GLenum target, GLuint texture); |
| 390 void BindVertexArrayHelper(GLuint array); | 390 void BindVertexArrayHelper(GLuint array); |
| 391 | 391 |
| 392 void GenBuffersHelper(GLsizei n, const GLuint* buffers); |
| 393 void GenFramebuffersHelper(GLsizei n, const GLuint* framebuffers); |
| 394 void GenRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); |
| 395 void GenTexturesHelper(GLsizei n, const GLuint* textures); |
| 396 void GenVertexArraysOESHelper(GLsizei n, const GLuint* arrays); |
| 397 void GenQueriesEXTHelper(GLsizei n, const GLuint* queries); |
| 398 |
| 392 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); | 399 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); |
| 393 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); | 400 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); |
| 394 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); | 401 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); |
| 395 void DeleteTexturesHelper(GLsizei n, const GLuint* textures); | 402 void DeleteTexturesHelper(GLsizei n, const GLuint* textures); |
| 396 bool DeleteProgramHelper(GLuint program); | 403 bool DeleteProgramHelper(GLuint program); |
| 397 bool DeleteShaderHelper(GLuint shader); | 404 bool DeleteShaderHelper(GLuint shader); |
| 398 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* textures); | 405 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* queries); |
| 399 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays); | 406 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays); |
| 400 | 407 |
| 401 void DeleteBuffersStub(GLsizei n, const GLuint* buffers); | 408 void DeleteBuffersStub(GLsizei n, const GLuint* buffers); |
| 402 void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers); | 409 void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers); |
| 403 void DeleteRenderbuffersStub(GLsizei n, const GLuint* renderbuffers); | 410 void DeleteRenderbuffersStub(GLsizei n, const GLuint* renderbuffers); |
| 404 void DeleteTexturesStub(GLsizei n, const GLuint* textures); | 411 void DeleteTexturesStub(GLsizei n, const GLuint* textures); |
| 405 void DeleteProgramStub(GLsizei n, const GLuint* programs); | 412 void DeleteProgramStub(GLsizei n, const GLuint* programs); |
| 406 void DeleteShaderStub(GLsizei n, const GLuint* shaders); | 413 void DeleteShaderStub(GLsizei n, const GLuint* shaders); |
| 407 // TODO(gman): Remove this as queries are not shared. | 414 // TODO(gman): Remove this as queries are not shared. |
| 408 void DeleteQueriesStub(GLsizei n, const GLuint* queries); | 415 void DeleteQueriesStub(GLsizei n, const GLuint* queries); |
| 409 void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays); | 416 void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays); |
| 410 | 417 |
| 411 void BufferDataHelper( | 418 void BufferDataHelper( |
| 412 GLenum target, GLsizeiptr size, const void* data, GLenum usage); | 419 GLenum target, GLsizeiptr size, const void* data, GLenum usage); |
| 413 void BufferSubDataHelper( | 420 void BufferSubDataHelper( |
| 414 GLenum target, GLintptr offset, GLsizeiptr size, const void* data); | 421 GLenum target, GLintptr offset, GLsizeiptr size, const void* data); |
| 415 void BufferSubDataHelperImpl( | 422 void BufferSubDataHelperImpl( |
| 416 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, | 423 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, |
| 417 ScopedTransferBufferPtr* buffer); | 424 ScopedTransferBufferPtr* buffer); |
| 418 | 425 |
| 419 // Helper for GetVertexAttrib | 426 // Helper for GetVertexAttrib |
| 420 bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param); | 427 bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param); |
| 421 | 428 |
| 422 GLuint GetMaxValueInBufferCHROMIUMHelper( | 429 GLuint GetMaxValueInBufferCHROMIUMHelper( |
| 423 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); | 430 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); |
| 424 | 431 |
| 432 void RestoreElementAndArrayBuffers(bool restore); |
| 433 void RestoreArrayBuffer(bool restrore); |
| 434 |
| 425 // The pixels pointer should already account for unpack skip rows and skip | 435 // The pixels pointer should already account for unpack skip rows and skip |
| 426 // pixels. | 436 // pixels. |
| 427 void TexSubImage2DImpl( | 437 void TexSubImage2DImpl( |
| 428 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, | 438 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, |
| 429 GLsizei height, GLenum format, GLenum type, uint32 unpadded_row_size, | 439 GLsizei height, GLenum format, GLenum type, uint32 unpadded_row_size, |
| 430 const void* pixels, uint32 pixels_padded_row_size, GLboolean internal, | 440 const void* pixels, uint32 pixels_padded_row_size, GLboolean internal, |
| 431 ScopedTransferBufferPtr* buffer, uint32 buffer_padded_row_size); | 441 ScopedTransferBufferPtr* buffer, uint32 buffer_padded_row_size); |
| 432 | 442 |
| 433 // Helpers for query functions. | 443 // Helpers for query functions. |
| 434 bool GetHelper(GLenum pname, GLint* params); | 444 bool GetHelper(GLenum pname, GLint* params); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 515 |
| 506 // 0 to gl_state_.max_combined_texture_image_units. | 516 // 0 to gl_state_.max_combined_texture_image_units. |
| 507 GLuint active_texture_unit_; | 517 GLuint active_texture_unit_; |
| 508 | 518 |
| 509 GLuint bound_framebuffer_; | 519 GLuint bound_framebuffer_; |
| 510 GLuint bound_renderbuffer_; | 520 GLuint bound_renderbuffer_; |
| 511 | 521 |
| 512 // The currently bound array buffer. | 522 // The currently bound array buffer. |
| 513 GLuint bound_array_buffer_id_; | 523 GLuint bound_array_buffer_id_; |
| 514 | 524 |
| 515 // The currently bound element array buffer. | |
| 516 GLuint bound_element_array_buffer_id_; | |
| 517 | |
| 518 // The currently bound pixel transfer buffer. | 525 // The currently bound pixel transfer buffer. |
| 519 GLuint bound_pixel_unpack_transfer_buffer_id_; | 526 GLuint bound_pixel_unpack_transfer_buffer_id_; |
| 520 | 527 |
| 521 // GL names for the buffers used to emulate client side buffers. | 528 // Client side management for vertex array objects. Needed to correctly |
| 522 GLuint client_side_array_id_; | 529 // track client side arrays. |
| 523 GLuint client_side_element_array_id_; | 530 scoped_ptr<VertexArrayObjectManager> vertex_array_object_manager_; |
| 524 | |
| 525 // Info for each vertex attribute saved so we can simulate client side | |
| 526 // buffers. | |
| 527 scoped_ptr<ClientSideBufferHelper> client_side_buffer_helper_; | |
| 528 | |
| 529 // The currently bound vertex array object (VAO) | |
| 530 GLuint bound_vertex_array_id_; | |
| 531 | 531 |
| 532 GLuint reserved_ids_[2]; | 532 GLuint reserved_ids_[2]; |
| 533 | 533 |
| 534 // Current GL error bits. | 534 // Current GL error bits. |
| 535 uint32 error_bits_; | 535 uint32 error_bits_; |
| 536 | 536 |
| 537 // Whether or not to print debugging info. | 537 // Whether or not to print debugging info. |
| 538 bool debug_; | 538 bool debug_; |
| 539 | 539 |
| 540 // Used to check for single threaded access. | 540 // Used to check for single threaded access. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 | 599 |
| 600 inline bool GLES2Implementation::GetTexParameterivHelper( | 600 inline bool GLES2Implementation::GetTexParameterivHelper( |
| 601 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 601 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
| 602 return false; | 602 return false; |
| 603 } | 603 } |
| 604 | 604 |
| 605 } // namespace gles2 | 605 } // namespace gles2 |
| 606 } // namespace gpu | 606 } // namespace gpu |
| 607 | 607 |
| 608 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 608 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
| OLD | NEW |