| OLD | NEW |
| 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2011 The Native Client 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 NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_COMMAND_BUFFER_NACL_H | 5 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_COMMAND_BUFFER_NACL_H |
| 6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_COMMAND_BUFFER_NACL_H | 6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_COMMAND_BUFFER_NACL_H |
| 7 | 7 |
| 8 #include "gpu/command_buffer/common/command_buffer.h" | 8 #include "gpu/command_buffer/common/command_buffer.h" |
| 9 #include "native_client/src/third_party/ppapi/c/dev/ppb_context_3d_trusted_dev.h
" | 9 #include "native_client/src/third_party/ppapi/c/dev/pp_graphics_3d_dev.h" |
| 10 #include "native_client/src/third_party/ppapi/c/dev/ppb_graphics_3d_trusted_dev.
h" |
| 10 #include "native_client/src/third_party/ppapi/c/pp_resource.h" | 11 #include "native_client/src/third_party/ppapi/c/pp_resource.h" |
| 11 | 12 |
| 12 struct PPB_Core; | 13 struct PPB_Core; |
| 13 | 14 |
| 14 // A CommandBuffer proxy implementation that uses trusted PPAPI interface to | 15 // A CommandBuffer proxy implementation that uses trusted PPAPI interface to |
| 15 // access a CommandBuffer. | 16 // access a CommandBuffer. |
| 16 | 17 |
| 17 class CommandBufferNacl : public gpu::CommandBuffer { | 18 class CommandBufferNacl : public gpu::CommandBuffer { |
| 18 public: | 19 public: |
| 19 // This class will addref the context 3d resource using the core interface. | 20 // This class will addref the graphics 3d resource using the core interface. |
| 20 CommandBufferNacl(PP_Resource context_3d, const PPB_Core* iface_core); | 21 CommandBufferNacl(PP_Resource graphics_3d, const PPB_Core* iface_core); |
| 21 virtual ~CommandBufferNacl(); | 22 virtual ~CommandBufferNacl(); |
| 22 | 23 |
| 23 // CommandBuffer implementation. | 24 // CommandBuffer implementation. |
| 24 virtual bool Initialize(int32 size); | 25 virtual bool Initialize(int32 size); |
| 25 virtual bool Initialize(base::SharedMemory* buffer, int32 size) { | 26 virtual bool Initialize(base::SharedMemory* buffer, int32 size) { |
| 26 // TODO(neb): support for nacl if neccessary | 27 // TODO(neb): support for nacl if neccessary |
| 27 return false; | 28 return false; |
| 28 } | 29 } |
| 29 virtual gpu::Buffer GetRingBuffer(); | 30 virtual gpu::Buffer GetRingBuffer(); |
| 30 virtual State GetState(); | 31 virtual State GetState(); |
| 31 virtual State GetLastState(); | 32 virtual State GetLastState(); |
| 32 virtual void Flush(int32 put_offset); | 33 virtual void Flush(int32 put_offset); |
| 33 virtual State FlushSync(int32 put_offset, int32 last_known_get); | 34 virtual State FlushSync(int32 put_offset, int32 last_known_get); |
| 34 virtual void SetGetOffset(int32 get_offset); | 35 virtual void SetGetOffset(int32 get_offset); |
| 35 virtual int32 CreateTransferBuffer(size_t size, int32 id_request); | 36 virtual int32 CreateTransferBuffer(size_t size, int32 id_request); |
| 36 virtual int32 RegisterTransferBuffer(base::SharedMemory* buffer, | 37 virtual int32 RegisterTransferBuffer(base::SharedMemory* buffer, |
| 37 size_t size, | 38 size_t size, |
| 38 int32 id_request) { | 39 int32 id_request) { |
| 39 // TODO(neb): support for nacl if neccessary | 40 // TODO(neb): support for nacl if neccessary |
| 40 return -1; | 41 return -1; |
| 41 } | 42 } |
| 42 virtual void DestroyTransferBuffer(int32 id); | 43 virtual void DestroyTransferBuffer(int32 id); |
| 43 virtual gpu::Buffer GetTransferBuffer(int32 handle); | 44 virtual gpu::Buffer GetTransferBuffer(int32 handle); |
| 44 virtual void SetToken(int32 token); | 45 virtual void SetToken(int32 token); |
| 45 virtual void SetParseError(gpu::error::Error error); | 46 virtual void SetParseError(gpu::error::Error error); |
| 46 virtual void SetContextLostReason(gpu::error::ContextLostReason); | 47 virtual void SetContextLostReason(gpu::error::ContextLostReason); |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 PP_Resource context_3d_; | 50 PP_Resource graphics_3d_; |
| 50 const PPB_Core* iface_core_; | 51 const PPB_Core* iface_core_; |
| 51 gpu::Buffer buffer_; | 52 gpu::Buffer buffer_; |
| 52 State last_state_; | 53 State last_state_; |
| 53 | 54 |
| 54 static gpu::CommandBuffer::State PpapiToGpuState(PP_Context3DTrustedState s); | 55 static gpu::CommandBuffer::State PpapiToGpuState(PP_Graphics3DTrustedState s); |
| 55 static gpu::CommandBuffer::State ErrorGpuState(); | 56 static gpu::CommandBuffer::State ErrorGpuState(); |
| 56 static gpu::Buffer BufferFromShm(int shm_handle, uint32_t shm_size); | 57 static gpu::Buffer BufferFromShm(int shm_handle, uint32_t shm_size); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_COMMAND_BUFFER_NACL_H | 60 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_COMMAND_BUFFER_NACL_H |
| OLD | NEW |