| 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_GPU_PROCESSOR_H_ | 5 #ifndef O3D_GPU_PLUGIN_GPU_PROCESSOR_H_ |
| 6 #define O3D_GPU_PLUGIN_GPU_PROCESSOR_H_ | 6 #define O3D_GPU_PLUGIN_GPU_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include "base/ref_counted.h" | 8 #include "o3d/command_buffer/service/cross/cmd_buffer_engine.h" |
| 9 #include "o3d/command_buffer/service/cross/cmd_parser.h" |
| 10 #include "o3d/command_buffer/service/cross/gapi_decoder.h" |
| 9 #include "o3d/gpu_plugin/command_buffer.h" | 11 #include "o3d/gpu_plugin/command_buffer.h" |
| 10 #include "o3d/gpu_plugin/np_utils/np_object_pointer.h" | 12 #include "o3d/gpu_plugin/np_utils/np_object_pointer.h" |
| 11 | 13 |
| 14 #if defined(OS_WIN) |
| 15 #include "o3d/command_buffer/service/win/d3d9/gapi_d3d9.h" |
| 16 #endif |
| 17 |
| 12 namespace o3d { | 18 namespace o3d { |
| 13 namespace gpu_plugin { | 19 namespace gpu_plugin { |
| 14 | 20 |
| 15 // This class processes commands in a command buffer. It is event driven and | 21 // This class processes commands in a command buffer. It is event driven and |
| 16 // posts tasks to the current message loop to do additional work. | 22 // posts tasks to the current message loop to do additional work. |
| 17 class GPUProcessor : public base::RefCountedThreadSafe<GPUProcessor> { | 23 class GPUProcessor : public base::RefCountedThreadSafe<GPUProcessor>, |
| 24 public command_buffer::CommandBufferUpcallInterface { |
| 18 public: | 25 public: |
| 19 explicit GPUProcessor(const NPObjectPointer<CommandBuffer>& command_buffer); | 26 GPUProcessor(NPP npp, |
| 27 const NPObjectPointer<CommandBuffer>& command_buffer); |
| 28 |
| 29 #if defined(OS_WIN) |
| 30 // This constructor is for unit tests. |
| 31 GPUProcessor(NPP npp, |
| 32 const NPObjectPointer<CommandBuffer>& command_buffer, |
| 33 command_buffer::GAPID3D9* gapi, |
| 34 command_buffer::GAPIDecoder* decoder, |
| 35 command_buffer::CommandParser* parser, |
| 36 int commands_per_update); |
| 37 |
| 38 bool Initialize(HWND hwnd); |
| 39 #endif // OS_WIN |
| 40 |
| 41 void Destroy(); |
| 20 | 42 |
| 21 void ProcessCommands(); | 43 void ProcessCommands(); |
| 22 | 44 |
| 23 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 24 void SetWindow(HWND handle, int width, int height); | 46 void SetWindow(HWND handle, int width, int height); |
| 25 #endif | 47 #endif |
| 26 | 48 |
| 27 void DrawRectangle(uint32 color, int left, int top, int right, int bottom); | 49 // Implementation of CommandBufferUpcallInterface. |
| 50 |
| 51 // Gets the base address of a registered shared memory buffer. |
| 52 // Parameters: |
| 53 // shm_id: the identifier for the shared memory buffer. |
| 54 virtual void *GetSharedMemoryAddress(unsigned int shm_id); |
| 55 |
| 56 // Gets the size of a registered shared memory buffer. |
| 57 // Parameters: |
| 58 // shm_id: the identifier for the shared memory buffer. |
| 59 virtual size_t GetSharedMemorySize(unsigned int shm_id); |
| 60 |
| 61 // Sets the token value. |
| 62 virtual void set_token(unsigned int token); |
| 28 | 63 |
| 29 private: | 64 private: |
| 65 NPP npp_; |
| 30 NPObjectPointer<CommandBuffer> command_buffer_; | 66 NPObjectPointer<CommandBuffer> command_buffer_; |
| 67 int commands_per_update_; |
| 31 | 68 |
| 32 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
| 33 HWND window_handle_; | 70 scoped_ptr<command_buffer::GAPID3D9> gapi_; |
| 34 int window_width_; | 71 scoped_ptr<command_buffer::GAPIDecoder> decoder_; |
| 35 int window_height_; | 72 scoped_ptr<command_buffer::CommandParser> parser_; |
| 36 #endif | 73 #endif |
| 37 }; | 74 }; |
| 38 | 75 |
| 39 } // namespace gpu_plugin | 76 } // namespace gpu_plugin |
| 40 } // namespace o3d | 77 } // namespace o3d |
| 41 | 78 |
| 42 #endif // O3D_GPU_PLUGIN_GPU_PROCESSOR_H_ | 79 #endif // O3D_GPU_PLUGIN_GPU_PROCESSOR_H_ |
| OLD | NEW |