| 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 <set> |
| 9 #include <vector> |
| 10 |
| 8 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 9 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 10 #include "base/task.h" | 13 #include "base/task.h" |
| 11 #include "o3d/gpu_plugin/np_utils/default_np_object.h" | 14 #include "o3d/gpu_plugin/np_utils/default_np_object.h" |
| 12 #include "o3d/gpu_plugin/np_utils/np_dispatcher.h" | 15 #include "o3d/gpu_plugin/np_utils/np_dispatcher.h" |
| 13 #include "o3d/gpu_plugin/system_services/shared_memory_public.h" | 16 #include "o3d/gpu_plugin/system_services/shared_memory_public.h" |
| 14 | 17 |
| 15 namespace o3d { | 18 namespace o3d { |
| 16 namespace gpu_plugin { | 19 namespace gpu_plugin { |
| 17 | 20 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 48 // offset is changed. The callback must not return until some progress has | 51 // offset is changed. The callback must not return until some progress has |
| 49 // been made (unless the command buffer is empty), i.e. the | 52 // been made (unless the command buffer is empty), i.e. the |
| 50 // get offset must have changed. It need not process the entire command | 53 // get offset must have changed. It need not process the entire command |
| 51 // buffer though. This allows concurrency between the writer and the reader | 54 // buffer though. This allows concurrency between the writer and the reader |
| 52 // while giving the writer a means of waiting for the reader to make some | 55 // while giving the writer a means of waiting for the reader to make some |
| 53 // progress before attempting to write more to the command buffer. Avoiding | 56 // progress before attempting to write more to the command buffer. Avoiding |
| 54 // the use of a synchronization primitive like a condition variable to | 57 // the use of a synchronization primitive like a condition variable to |
| 55 // synchronize reader and writer reduces the risk of deadlock. | 58 // synchronize reader and writer reduces the risk of deadlock. |
| 56 // Takes ownership of callback. The callback is invoked on the plugin thread. | 59 // Takes ownership of callback. The callback is invoked on the plugin thread. |
| 57 virtual void SetPutOffsetChangeCallback(Callback0::Type* callback); | 60 virtual void SetPutOffsetChangeCallback(Callback0::Type* callback); |
| 58 | 61 |
| 62 // Get an opaque integer handle for an NPObject. This can be used |
| 63 // to identify the shared memory object from the ring buffer. Note that the |
| 64 // object will be retained. Consider reference cycle issues. Returns zero for |
| 65 // NULL, positive for non-NULL and -1 on error. Objects may be registered |
| 66 // multiple times and have multiple associated handles. Each handle for a |
| 67 // distinct object must be separately unregistered. |
| 68 virtual int32 RegisterObject(NPObjectPointer<NPObject> object); |
| 69 |
| 70 // Unregister a previously registered NPObject. It is safe to unregister the |
| 71 // zero handle. |
| 72 virtual void UnregisterObject(NPObjectPointer<NPObject> object, int32 handle); |
| 73 |
| 74 virtual NPObjectPointer<NPObject> GetRegisteredObject(int32 handle); |
| 75 |
| 59 NP_UTILS_BEGIN_DISPATCHER_CHAIN(CommandBuffer, DefaultNPObject<NPObject>) | 76 NP_UTILS_BEGIN_DISPATCHER_CHAIN(CommandBuffer, DefaultNPObject<NPObject>) |
| 60 NP_UTILS_DISPATCHER(Initialize, bool(int32)) | 77 NP_UTILS_DISPATCHER(Initialize, bool(int32)) |
| 61 NP_UTILS_DISPATCHER(GetRingBuffer, NPObjectPointer<CHRSharedMemory>()) | 78 NP_UTILS_DISPATCHER(GetRingBuffer, NPObjectPointer<CHRSharedMemory>()) |
| 62 NP_UTILS_DISPATCHER(GetSize, int32()) | 79 NP_UTILS_DISPATCHER(GetSize, int32()) |
| 63 NP_UTILS_DISPATCHER(SyncOffsets, int32(int32)) | 80 NP_UTILS_DISPATCHER(SyncOffsets, int32(int32)) |
| 64 NP_UTILS_DISPATCHER(GetGetOffset, int32()); | 81 NP_UTILS_DISPATCHER(GetGetOffset, int32()); |
| 65 NP_UTILS_DISPATCHER(GetPutOffset, int32()); | 82 NP_UTILS_DISPATCHER(GetPutOffset, int32()); |
| 83 NP_UTILS_DISPATCHER(RegisterObject, int32(NPObjectPointer<NPObject>)); |
| 84 NP_UTILS_DISPATCHER(UnregisterObject, |
| 85 void(NPObjectPointer<NPObject>, int32)); |
| 66 NP_UTILS_END_DISPATCHER_CHAIN | 86 NP_UTILS_END_DISPATCHER_CHAIN |
| 67 | 87 |
| 68 private: | 88 private: |
| 69 NPP npp_; | 89 NPP npp_; |
| 70 NPObjectPointer<CHRSharedMemory> shared_memory_; | 90 NPObjectPointer<CHRSharedMemory> shared_memory_; |
| 71 int32 size_; | 91 int32 size_; |
| 72 int32 get_offset_; | 92 int32 get_offset_; |
| 73 int32 put_offset_; | 93 int32 put_offset_; |
| 74 scoped_ptr<Callback0::Type> put_offset_change_callback_; | 94 scoped_ptr<Callback0::Type> put_offset_change_callback_; |
| 95 std::vector<NPObjectPointer<NPObject> > registered_objects_; |
| 96 std::set<int32> unused_registered_object_elements_; |
| 75 }; | 97 }; |
| 76 | 98 |
| 77 } // namespace gpu_plugin | 99 } // namespace gpu_plugin |
| 78 } // namespace o3d | 100 } // namespace o3d |
| 79 | 101 |
| 80 #endif // O3D_GPU_PLUGIN_COMMAND_BUFFER_H_ | 102 #endif // O3D_GPU_PLUGIN_COMMAND_BUFFER_H_ |
| OLD | NEW |