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

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

Issue 9380037: Use shared memory to update the renderer's view of the command buffer state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor unit test change Created 8 years, 10 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 <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/shared_memory.h" 14 #include "base/shared_memory.h"
15 #include "gpu/command_buffer/common/command_buffer.h" 15 #include "gpu/command_buffer/common/command_buffer.h"
16 #include "gpu/command_buffer/common/command_buffer_shared.h"
16 17
17 namespace gpu { 18 namespace gpu {
18 19
19 // An object that implements a shared memory command buffer and a synchronous 20 // An object that implements a shared memory command buffer and a synchronous
20 // API to manage the put and get pointers. 21 // API to manage the put and get pointers.
21 class CommandBufferService : public CommandBuffer { 22 class CommandBufferService : public CommandBuffer {
22 public: 23 public:
23 typedef base::Callback<bool(int32)> GetBufferChangedCallback; 24 typedef base::Callback<bool(int32)> GetBufferChangedCallback;
24 CommandBufferService(); 25 CommandBufferService();
25 virtual ~CommandBufferService(); 26 virtual ~CommandBufferService();
(...skipping 23 matching lines...) Expand all
49 // This allows concurrency between the writer and the reader while giving the 50 // This allows concurrency between the writer and the reader while giving the
50 // writer a means of waiting for the reader to make some progress before 51 // writer a means of waiting for the reader to make some progress before
51 // attempting to write more to the command buffer. Takes ownership of 52 // attempting to write more to the command buffer. Takes ownership of
52 // callback. 53 // callback.
53 virtual void SetPutOffsetChangeCallback(const base::Closure& callback); 54 virtual void SetPutOffsetChangeCallback(const base::Closure& callback);
54 // Sets a callback that is called whenever the get buffer is changed. 55 // Sets a callback that is called whenever the get buffer is changed.
55 virtual void SetGetBufferChangeCallback( 56 virtual void SetGetBufferChangeCallback(
56 const GetBufferChangedCallback& callback); 57 const GetBufferChangedCallback& callback);
57 virtual void SetParseErrorCallback(const base::Closure& callback); 58 virtual void SetParseErrorCallback(const base::Closure& callback);
58 59
60 // Setup the transfer buffer that shared state should be copied into.
61 void SetSharedStateBuffer(int32 transfer_buffer_id);
62
63 // Copy the current state into the shared state transfer buffer.
64 void UpdateState();
65
59 private: 66 private:
60 int32 ring_buffer_id_; 67 int32 ring_buffer_id_;
61 Buffer ring_buffer_; 68 Buffer ring_buffer_;
69 CommandBufferSharedState* shared_state_;
62 int32 num_entries_; 70 int32 num_entries_;
63 int32 get_offset_; 71 int32 get_offset_;
64 int32 put_offset_; 72 int32 put_offset_;
65 base::Closure put_offset_change_callback_; 73 base::Closure put_offset_change_callback_;
66 GetBufferChangedCallback get_buffer_change_callback_; 74 GetBufferChangedCallback get_buffer_change_callback_;
67 base::Closure parse_error_callback_; 75 base::Closure parse_error_callback_;
68 std::vector<Buffer> registered_objects_; 76 std::vector<Buffer> registered_objects_;
69 std::set<int32> unused_registered_object_elements_; 77 std::set<int32> unused_registered_object_elements_;
70 int32 token_; 78 int32 token_;
71 uint32 generation_; 79 uint32 generation_;
72 error::Error error_; 80 error::Error error_;
73 error::ContextLostReason context_lost_reason_; 81 error::ContextLostReason context_lost_reason_;
74 size_t shared_memory_bytes_allocated_; 82 size_t shared_memory_bytes_allocated_;
75 }; 83 };
76 84
77 } // namespace gpu 85 } // namespace gpu
78 86
79 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ 87 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698