OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 O3D_GPU_PLUGIN_COMMAND_BUFFER_H_ | 5 #ifndef O3D_GPU_PLUGIN_COMMAND_BUFFER_H_ |
6 #define O3D_GPU_PLUGIN_COMMAND_BUFFER_H_ | 6 #define O3D_GPU_PLUGIN_COMMAND_BUFFER_H_ |
7 | 7 |
8 #include "o3d/gpu_plugin/np_utils/dispatched_np_object.h" | 8 #include "o3d/gpu_plugin/np_utils/default_np_object.h" |
| 9 #include "o3d/gpu_plugin/np_utils/np_dispatcher.h" |
9 | 10 |
10 namespace o3d { | 11 namespace o3d { |
11 namespace gpu_plugin { | 12 namespace gpu_plugin { |
12 | 13 |
13 // An NPObject that implements a shared memory command buffer and a synchronous | 14 // An NPObject that implements a shared memory command buffer and a synchronous |
14 // API to manage the put and get pointers. | 15 // API to manage the put and get pointers. |
15 class CommandBuffer : public DispatchedNPObject { | 16 class CommandBuffer : public DefaultNPObject<NPObject> { |
16 public: | 17 public: |
17 explicit CommandBuffer(NPP npp); | 18 explicit CommandBuffer(NPP npp); |
18 virtual ~CommandBuffer(); | 19 virtual ~CommandBuffer(); |
19 | 20 |
20 // Create a shared memory buffer of the given size. | 21 // Create a shared memory buffer of the given size. |
21 virtual bool Initialize(int32 size); | 22 virtual bool Initialize(int32 size); |
22 | 23 |
23 // Gets the shared memory object for the command buffer. | 24 // Gets the shared memory object for the command buffer. |
24 virtual NPObjectPointer<NPObject> GetBuffer(); | 25 virtual NPObjectPointer<NPObject> GetBuffer(); |
25 | 26 |
26 // The client calls this to update its put offset. | 27 // The client calls this to update its put offset. |
27 virtual void SetPutOffset(int32 offset); | 28 virtual void SetPutOffset(int32 offset); |
28 | 29 |
29 // The client calls this to get the servers current get offset. | 30 // The client calls this to get the servers current get offset. |
30 virtual int32 GetGetOffset(); | 31 virtual int32 GetGetOffset(); |
31 | 32 |
32 protected: | 33 NP_UTILS_BEGIN_DISPATCHER_CHAIN(CommandBuffer, DefaultNPObject<NPObject>) |
33 NP_UTILS_BEGIN_DISPATCHER_CHAIN(CommandBuffer, DispatchedNPObject) | |
34 NP_UTILS_DISPATCHER(Initialize, bool(int32)) | 34 NP_UTILS_DISPATCHER(Initialize, bool(int32)) |
35 NP_UTILS_DISPATCHER(SetPutOffset, void(int32)) | 35 NP_UTILS_DISPATCHER(SetPutOffset, void(int32)) |
36 NP_UTILS_DISPATCHER(GetGetOffset, int32()) | 36 NP_UTILS_DISPATCHER(GetGetOffset, int32()) |
37 NP_UTILS_DISPATCHER(GetBuffer, NPObjectPointer<NPObject>()) | 37 NP_UTILS_DISPATCHER(GetBuffer, NPObjectPointer<NPObject>()) |
38 NP_UTILS_END_DISPATCHER_CHAIN | 38 NP_UTILS_END_DISPATCHER_CHAIN |
39 | 39 |
40 private: | 40 private: |
| 41 NPP npp_; |
41 NPObjectPointer<NPObject> buffer_object_; | 42 NPObjectPointer<NPObject> buffer_object_; |
42 NPSharedMemory* shared_memory_; | 43 NPSharedMemory* shared_memory_; |
43 }; | 44 }; |
44 | 45 |
45 } // namespace gpu_plugin | 46 } // namespace gpu_plugin |
46 } // namespace o3d | 47 } // namespace o3d |
47 | 48 |
48 #endif // O3D_GPU_PLUGIN_COMMAND_BUFFER_H_ | 49 #endif // O3D_GPU_PLUGIN_COMMAND_BUFFER_H_ |
OLD | NEW |