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

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

Issue 20017005: gpu: Refactor GpuMemoryBuffer framework for multi-process support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_COMMAND_BUFFER_SERVICE_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_
7 7
8 #include <map>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/memory/shared_memory.h" 11 #include "base/memory/shared_memory.h"
10 #include "gpu/command_buffer/common/command_buffer.h" 12 #include "gpu/command_buffer/common/command_buffer.h"
11 #include "gpu/command_buffer/common/command_buffer_shared.h" 13 #include "gpu/command_buffer/common/command_buffer_shared.h"
14 #include "ui/gfx/gpu_memory_buffer.h"
12 15
13 namespace gpu { 16 namespace gpu {
17 class GpuMemoryBufferFactory;
18 class TransferBufferManagerInterface;
14 19
15 class TransferBufferManagerInterface; 20 namespace gles2 {
21 class ImageManager;
22 }
16 23
17 // An object that implements a shared memory command buffer and a synchronous 24 // An object that implements a shared memory command buffer and a synchronous
18 // API to manage the put and get pointers. 25 // API to manage the put and get pointers.
19 class GPU_EXPORT CommandBufferService : public CommandBuffer { 26 class GPU_EXPORT CommandBufferService : public CommandBuffer {
20 public: 27 public:
21 typedef base::Callback<bool(int32)> GetBufferChangedCallback; 28 typedef base::Callback<bool(int32)> GetBufferChangedCallback;
22 explicit CommandBufferService( 29 CommandBufferService(
23 TransferBufferManagerInterface* transfer_buffer_manager); 30 TransferBufferManagerInterface* transfer_buffer_manager,
31 gles2::ImageManager* image_manager,
32 GpuMemoryBufferFactory* gpu_memory_buffer_factory);
24 virtual ~CommandBufferService(); 33 virtual ~CommandBufferService();
25 34
26 // CommandBuffer implementation: 35 // CommandBuffer implementation:
27 virtual bool Initialize() OVERRIDE; 36 virtual bool Initialize() OVERRIDE;
28 virtual State GetState() OVERRIDE; 37 virtual State GetState() OVERRIDE;
29 virtual State GetLastState() OVERRIDE; 38 virtual State GetLastState() OVERRIDE;
30 virtual int32 GetLastToken() OVERRIDE; 39 virtual int32 GetLastToken() OVERRIDE;
31 virtual void Flush(int32 put_offset) OVERRIDE; 40 virtual void Flush(int32 put_offset) OVERRIDE;
32 virtual State FlushSync(int32 put_offset, int32 last_known_get) OVERRIDE; 41 virtual State FlushSync(int32 put_offset, int32 last_known_get) OVERRIDE;
33 virtual void SetGetBuffer(int32 transfer_buffer_id) OVERRIDE; 42 virtual void SetGetBuffer(int32 transfer_buffer_id) OVERRIDE;
34 virtual void SetGetOffset(int32 get_offset) OVERRIDE; 43 virtual void SetGetOffset(int32 get_offset) OVERRIDE;
35 virtual Buffer CreateTransferBuffer(size_t size, int32* id) OVERRIDE; 44 virtual Buffer CreateTransferBuffer(size_t size, int32* id) OVERRIDE;
36 virtual void DestroyTransferBuffer(int32 id) OVERRIDE; 45 virtual void DestroyTransferBuffer(int32 id) OVERRIDE;
37 virtual Buffer GetTransferBuffer(int32 id) OVERRIDE; 46 virtual Buffer GetTransferBuffer(int32 id) OVERRIDE;
38 virtual void SetToken(int32 token) OVERRIDE; 47 virtual void SetToken(int32 token) OVERRIDE;
39 virtual void SetParseError(error::Error error) OVERRIDE; 48 virtual void SetParseError(error::Error error) OVERRIDE;
40 virtual void SetContextLostReason(error::ContextLostReason) OVERRIDE; 49 virtual void SetContextLostReason(error::ContextLostReason) OVERRIDE;
41 virtual uint32 InsertSyncPoint() OVERRIDE; 50 virtual uint32 InsertSyncPoint() OVERRIDE;
51 virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer(
52 size_t width,
53 size_t height,
54 unsigned internalformat,
55 int32* id) OVERRIDE;
56 virtual void DestroyGpuMemoryBuffer(int32 id) OVERRIDE;
42 57
43 // Sets a callback that is called whenever the put offset is changed. When 58 // Sets a callback that is called whenever the put offset is changed. When
44 // called with sync==true, the callback must not return until some progress 59 // called with sync==true, the callback must not return until some progress
45 // has been made (unless the command buffer is empty), i.e. the get offset 60 // has been made (unless the command buffer is empty), i.e. the get offset
46 // must have changed. It need not process the entire command buffer though. 61 // must have changed. It need not process the entire command buffer though.
47 // This allows concurrency between the writer and the reader while giving the 62 // This allows concurrency between the writer and the reader while giving the
48 // writer a means of waiting for the reader to make some progress before 63 // writer a means of waiting for the reader to make some progress before
49 // attempting to write more to the command buffer. Takes ownership of 64 // attempting to write more to the command buffer. Takes ownership of
50 // callback. 65 // callback.
51 virtual void SetPutOffsetChangeCallback(const base::Closure& callback); 66 virtual void SetPutOffsetChangeCallback(const base::Closure& callback);
52 // Sets a callback that is called whenever the get buffer is changed. 67 // Sets a callback that is called whenever the get buffer is changed.
53 virtual void SetGetBufferChangeCallback( 68 virtual void SetGetBufferChangeCallback(
54 const GetBufferChangedCallback& callback); 69 const GetBufferChangedCallback& callback);
55 virtual void SetParseErrorCallback(const base::Closure& callback); 70 virtual void SetParseErrorCallback(const base::Closure& callback);
56 71
57 // Setup the shared memory that shared state should be copied into. 72 // Setup the shared memory that shared state should be copied into.
58 bool SetSharedStateBuffer(scoped_ptr<base::SharedMemory> shared_state_shm); 73 bool SetSharedStateBuffer(scoped_ptr<base::SharedMemory> shared_state_shm);
59 74
60 // Copy the current state into the shared state transfer buffer. 75 // Copy the current state into the shared state transfer buffer.
61 void UpdateState(); 76 void UpdateState();
62 77
63 // Register an existing shared memory object and get an ID that can be used 78 // Register an existing shared memory object and get an ID that can be used
64 // to identify it in the command buffer. Callee dups the handle until 79 // to identify it in the command buffer. Callee dups the handle until
65 // DestroyTransferBuffer is called. 80 // DestroyTransferBuffer is called.
66 bool RegisterTransferBuffer(int32 id, 81 bool RegisterTransferBuffer(int32 id,
67 base::SharedMemory* shared_memory, 82 base::SharedMemory* shared_memory,
68 size_t size); 83 size_t size);
69 84
85 // Register an existing gpu memory buffer and get an ID that can be used
kaanb 2013/07/24 03:31:23 nit: s/Registers/Register/
reveman 2013/07/24 05:47:12 It describes what the function is used for and not
86 // to identify it in the command buffer.
87 bool RegisterGpuMemoryBuffer(int32 id,
88 gfx::GpuMemoryBufferHandle buffer,
89 size_t width,
90 size_t height,
91 unsigned internalformat);
92
70 private: 93 private:
71 int32 ring_buffer_id_; 94 int32 ring_buffer_id_;
72 Buffer ring_buffer_; 95 Buffer ring_buffer_;
73 scoped_ptr<base::SharedMemory> shared_state_shm_; 96 scoped_ptr<base::SharedMemory> shared_state_shm_;
74 CommandBufferSharedState* shared_state_; 97 CommandBufferSharedState* shared_state_;
75 int32 num_entries_; 98 int32 num_entries_;
76 int32 get_offset_; 99 int32 get_offset_;
77 int32 put_offset_; 100 int32 put_offset_;
78 base::Closure put_offset_change_callback_; 101 base::Closure put_offset_change_callback_;
79 GetBufferChangedCallback get_buffer_change_callback_; 102 GetBufferChangedCallback get_buffer_change_callback_;
80 base::Closure parse_error_callback_; 103 base::Closure parse_error_callback_;
81 TransferBufferManagerInterface* transfer_buffer_manager_; 104 TransferBufferManagerInterface* transfer_buffer_manager_;
82 int32 token_; 105 int32 token_;
83 uint32 generation_; 106 uint32 generation_;
84 error::Error error_; 107 error::Error error_;
85 error::ContextLostReason context_lost_reason_; 108 error::ContextLostReason context_lost_reason_;
109 GpuMemoryBufferFactory* gpu_memory_buffer_factory_;
110 gles2::ImageManager* image_manager_;
111 typedef std::map<int32, gfx::GpuMemoryBuffer*> GpuMemoryBufferMap;
112 GpuMemoryBufferMap gpu_memory_buffers_;
86 113
87 DISALLOW_COPY_AND_ASSIGN(CommandBufferService); 114 DISALLOW_COPY_AND_ASSIGN(CommandBufferService);
88 }; 115 };
89 116
90 } // namespace gpu 117 } // namespace gpu
91 118
92 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ 119 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698