Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: gpu/command_buffer/service/gpu_processor.h

Issue 465040: Added CommandBufferClient, CommandBufferStub and some IPC messages.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 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 "base/ref_counted.h" 9 #include "base/ref_counted.h"
9 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
10 #include "base/shared_memory.h" 11 #include "base/shared_memory.h"
11 #include "gpu/command_buffer/common/command_buffer.h" 12 #include "gpu/command_buffer/common/command_buffer.h"
12 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 13 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
13 #include "gpu/command_buffer/service/cmd_parser.h" 14 #include "gpu/command_buffer/service/cmd_parser.h"
14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
15 16
16 namespace command_buffer { 17 namespace gpu {
17 18
18 // 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
19 // posts tasks to the current message loop to do additional work. 20 // posts tasks to the current message loop to do additional work.
20 class GPUProcessor : public ::base::RefCounted<GPUProcessor>, 21 class GPUProcessor : public ::base::RefCounted<GPUProcessor>,
21 public command_buffer::CommandBufferEngine { 22 public gpu::CommandBufferEngine {
22 public: 23 public:
23 explicit GPUProcessor(CommandBuffer* command_buffer); 24 explicit GPUProcessor(CommandBuffer* command_buffer);
24 25
25 // This constructor is for unit tests. 26 // This constructor is for unit tests.
26 GPUProcessor(CommandBuffer* command_buffer, 27 GPUProcessor(CommandBuffer* command_buffer,
27 gles2::GLES2Decoder* decoder, 28 gles2::GLES2Decoder* decoder,
28 CommandParser* parser, 29 CommandParser* parser,
29 int commands_per_update); 30 int commands_per_update);
30 31
31 virtual bool Initialize(HWND hwnd); 32 virtual bool Initialize(gfx::PluginWindowHandle hwnd);
32 33
33 virtual ~GPUProcessor(); 34 virtual ~GPUProcessor();
34 35
35 virtual void Destroy(); 36 virtual void Destroy();
36 37
37 virtual void ProcessCommands(); 38 virtual void ProcessCommands();
38 39
39 #if defined(OS_WIN) 40 virtual bool SetWindow(gfx::PluginWindowHandle handle, int width, int height);
40 virtual bool SetWindow(HWND handle, int width, int height);
41 #endif
42 41
43 // Implementation of CommandBufferEngine. 42 // Implementation of CommandBufferEngine.
44 43
45 // Gets the base address of a registered shared memory buffer. 44 // Gets the base address of a registered shared memory buffer.
46 // Parameters: 45 // Parameters:
47 // shm_id: the identifier for the shared memory buffer. 46 // shm_id: the identifier for the shared memory buffer.
48 virtual void *GetSharedMemoryAddress(int32 shm_id); 47 virtual void *GetSharedMemoryAddress(int32 shm_id);
49 48
50 // Gets the size of a registered shared memory buffer. 49 // Gets the size of a registered shared memory buffer.
51 // Parameters: 50 // Parameters:
52 // shm_id: the identifier for the shared memory buffer. 51 // shm_id: the identifier for the shared memory buffer.
53 virtual size_t GetSharedMemorySize(int32 shm_id); 52 virtual size_t GetSharedMemorySize(int32 shm_id);
54 53
55 // Sets the token value. 54 // Sets the token value.
56 virtual void set_token(int32 token); 55 virtual void set_token(int32 token);
57 56
58 private: 57 private:
59 // The GPUProcessor holds a weak reference to the CommandBuffer. The 58 // The GPUProcessor holds a weak reference to the CommandBuffer. The
60 // CommandBuffer owns the GPUProcessor and holds a strong reference to it 59 // CommandBuffer owns the GPUProcessor and holds a strong reference to it
61 // through the ProcessCommands callback. 60 // through the ProcessCommands callback.
62 CommandBuffer* command_buffer_; 61 CommandBuffer* command_buffer_;
63 62
64 scoped_ptr< ::base::SharedMemory> mapped_ring_buffer_; 63 scoped_ptr< ::base::SharedMemory> mapped_ring_buffer_;
65 int commands_per_update_; 64 int commands_per_update_;
66 65
67 scoped_ptr<gles2::GLES2Decoder> decoder_; 66 scoped_ptr<gles2::GLES2Decoder> decoder_;
68 scoped_ptr<CommandParser> parser_; 67 scoped_ptr<CommandParser> parser_;
69 }; 68 };
70 69
71 } // namespace command_buffer 70 } // namespace gpu
72 71
73 // Callbacks to the GPUProcessor hold a reference count. 72 // Callbacks to the GPUProcessor hold a reference count.
74 template <typename Method> 73 template <typename Method>
75 class CallbackStorage<command_buffer::GPUProcessor, Method> { 74 class CallbackStorage<gpu::GPUProcessor, Method> {
76 public: 75 public:
77 CallbackStorage(command_buffer::GPUProcessor* obj, Method method) 76 CallbackStorage(gpu::GPUProcessor* obj, Method method)
78 : obj_(obj), 77 : obj_(obj),
79 meth_(method) { 78 meth_(method) {
80 DCHECK(obj_); 79 DCHECK(obj_);
81 obj_->AddRef(); 80 obj_->AddRef();
82 } 81 }
83 82
84 ~CallbackStorage() { 83 ~CallbackStorage() {
85 obj_->Release(); 84 obj_->Release();
86 } 85 }
87 86
88 protected: 87 protected:
89 command_buffer::GPUProcessor* obj_; 88 gpu::GPUProcessor* obj_;
90 Method meth_; 89 Method meth_;
91 90
92 private: 91 private:
93 DISALLOW_COPY_AND_ASSIGN(CallbackStorage); 92 DISALLOW_COPY_AND_ASSIGN(CallbackStorage);
94 }; 93 };
95 94
96 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ 95 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_validate.h ('k') | gpu/command_buffer/service/gpu_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698