OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_SERVICE_GPU_PROCESSOR_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ |
7 | 7 |
8 #include "app/gfx/native_widget_types.h" | 8 #include "app/gfx/native_widget_types.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
12 #include "gpu/command_buffer/common/command_buffer.h" | 12 #include "gpu/command_buffer/common/command_buffer.h" |
13 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 13 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
14 #include "gpu/command_buffer/service/cmd_parser.h" | 14 #include "gpu/command_buffer/service/cmd_parser.h" |
15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
16 | 16 |
17 namespace gpu { | 17 namespace gpu { |
18 | 18 |
19 // This class processes commands in a command buffer. It is event driven and | 19 // This class processes commands in a command buffer. It is event driven and |
20 // posts tasks to the current message loop to do additional work. | 20 // posts tasks to the current message loop to do additional work. |
21 class GPUProcessor : public ::base::RefCounted<GPUProcessor>, | 21 class GPUProcessor : public base::RefCounted<GPUProcessor>, |
22 public gpu::CommandBufferEngine { | 22 public CommandBufferEngine { |
23 public: | 23 public: |
24 explicit GPUProcessor(CommandBuffer* command_buffer); | 24 explicit GPUProcessor(CommandBuffer* command_buffer); |
25 | 25 |
26 // This constructor is for unit tests. | 26 // This constructor is for unit tests. |
27 GPUProcessor(CommandBuffer* command_buffer, | 27 GPUProcessor(CommandBuffer* command_buffer, |
28 gles2::GLES2Decoder* decoder, | 28 gles2::GLES2Decoder* decoder, |
29 CommandParser* parser, | 29 CommandParser* parser, |
30 int commands_per_update); | 30 int commands_per_update); |
31 | 31 |
32 virtual bool Initialize(gfx::PluginWindowHandle hwnd); | 32 virtual bool Initialize(gfx::PluginWindowHandle hwnd); |
33 | 33 |
34 virtual ~GPUProcessor(); | 34 virtual ~GPUProcessor(); |
35 | 35 |
36 virtual void Destroy(); | 36 virtual void Destroy(); |
37 | 37 |
38 virtual void ProcessCommands(); | 38 virtual void ProcessCommands(); |
39 | 39 |
40 virtual bool SetWindow(gfx::PluginWindowHandle handle, int width, int height); | |
41 | |
42 // Implementation of CommandBufferEngine. | 40 // Implementation of CommandBufferEngine. |
43 | 41 virtual Buffer GetSharedMemoryBuffer(int32 shm_id); |
44 // Gets the base address of a registered shared memory buffer. | |
45 // Parameters: | |
46 // shm_id: the identifier for the shared memory buffer. | |
47 virtual void *GetSharedMemoryAddress(int32 shm_id); | |
48 | |
49 // Gets the size of a registered shared memory buffer. | |
50 // Parameters: | |
51 // shm_id: the identifier for the shared memory buffer. | |
52 virtual size_t GetSharedMemorySize(int32 shm_id); | |
53 | |
54 // Sets the token value. | |
55 virtual void set_token(int32 token); | 42 virtual void set_token(int32 token); |
56 | 43 |
57 private: | 44 private: |
58 // The GPUProcessor holds a weak reference to the CommandBuffer. The | 45 // The GPUProcessor holds a weak reference to the CommandBuffer. The |
59 // CommandBuffer owns the GPUProcessor and holds a strong reference to it | 46 // CommandBuffer owns the GPUProcessor and holds a strong reference to it |
60 // through the ProcessCommands callback. | 47 // through the ProcessCommands callback. |
61 CommandBuffer* command_buffer_; | 48 CommandBuffer* command_buffer_; |
62 | 49 |
63 scoped_ptr< ::base::SharedMemory> mapped_ring_buffer_; | 50 scoped_ptr< ::base::SharedMemory> mapped_ring_buffer_; |
64 int commands_per_update_; | 51 int commands_per_update_; |
(...skipping 21 matching lines...) Expand all Loading... |
86 | 73 |
87 protected: | 74 protected: |
88 gpu::GPUProcessor* obj_; | 75 gpu::GPUProcessor* obj_; |
89 Method meth_; | 76 Method meth_; |
90 | 77 |
91 private: | 78 private: |
92 DISALLOW_COPY_AND_ASSIGN(CallbackStorage); | 79 DISALLOW_COPY_AND_ASSIGN(CallbackStorage); |
93 }; | 80 }; |
94 | 81 |
95 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ | 82 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ |
OLD | NEW |