OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
6 #define CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 6 #define CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #if defined(ENABLE_GPU) | 9 #if defined(ENABLE_GPU) |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 GpuWatchdog* watchdog); | 44 GpuWatchdog* watchdog); |
45 | 45 |
46 virtual ~GpuCommandBufferStub(); | 46 virtual ~GpuCommandBufferStub(); |
47 | 47 |
48 // IPC::Channel::Listener implementation: | 48 // IPC::Channel::Listener implementation: |
49 virtual bool OnMessageReceived(const IPC::Message& message); | 49 virtual bool OnMessageReceived(const IPC::Message& message); |
50 | 50 |
51 // IPC::Message::Sender implementation: | 51 // IPC::Message::Sender implementation: |
52 virtual bool Send(IPC::Message* msg); | 52 virtual bool Send(IPC::Message* msg); |
53 | 53 |
| 54 // Whether this command buffer can currently handle IPC messages. |
| 55 bool IsScheduled(); |
| 56 |
54 // Get the GLContext associated with this object. | 57 // Get the GLContext associated with this object. |
55 gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } | 58 gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } |
56 | 59 |
57 // Identifies the renderer process. | 60 // Identifies the renderer process. |
58 int32 renderer_id() const { return renderer_id_; } | 61 int32 renderer_id() const { return renderer_id_; } |
59 | 62 |
60 // Identifies a particular renderer belonging to the same renderer process. | 63 // Identifies a particular renderer belonging to the same renderer process. |
61 int32 render_view_id() const { return render_view_id_; } | 64 int32 render_view_id() const { return render_view_id_; } |
62 | 65 |
63 // Identifies the various GpuCommandBufferStubs in the GPU process belonging | 66 // Identifies the various GpuCommandBufferStubs in the GPU process belonging |
(...skipping 16 matching lines...) Expand all Loading... |
80 #if defined(TOUCH_UI) | 83 #if defined(TOUCH_UI) |
81 void AcceleratedSurfaceIOSurfaceSet(uint64 surface_id); | 84 void AcceleratedSurfaceIOSurfaceSet(uint64 surface_id); |
82 void AcceleratedSurfaceReleased(uint64 surface_id); | 85 void AcceleratedSurfaceReleased(uint64 surface_id); |
83 #endif // defined(TOUCH_UI) | 86 #endif // defined(TOUCH_UI) |
84 | 87 |
85 #if defined(OS_MACOSX) || defined(TOUCH_UI) | 88 #if defined(OS_MACOSX) || defined(TOUCH_UI) |
86 // Called only by the GpuChannel. | 89 // Called only by the GpuChannel. |
87 void AcceleratedSurfaceBuffersSwapped(uint64 swap_buffers_count); | 90 void AcceleratedSurfaceBuffersSwapped(uint64 swap_buffers_count); |
88 #endif // defined(OS_MACOSX) || defined(TOUCH_UI) | 91 #endif // defined(OS_MACOSX) || defined(TOUCH_UI) |
89 | 92 |
90 // Called when the command buffer was destroyed, and the stub should now | |
91 // unblock itself and handle pending messages. | |
92 void CommandBufferWasDestroyed(); | |
93 | |
94 // Register a callback to be Run() whenever the underlying scheduler receives | 93 // Register a callback to be Run() whenever the underlying scheduler receives |
95 // a set_token() call. The callback will be Run() with the just-set token as | 94 // a set_token() call. The callback will be Run() with the just-set token as |
96 // its only parameter. Multiple callbacks may be registered. | 95 // its only parameter. Multiple callbacks may be registered. |
97 void AddSetTokenCallback(const base::Callback<void(int32)>& callback); | 96 void AddSetTokenCallback(const base::Callback<void(int32)>& callback); |
98 | 97 |
99 private: | 98 private: |
100 // Message handlers: | 99 // Message handlers: |
101 void OnInitialize(base::SharedMemoryHandle ring_buffer, | 100 void OnInitialize(base::SharedMemoryHandle ring_buffer, |
102 int32 size, | 101 int32 size, |
103 IPC::Message* reply_message); | 102 IPC::Message* reply_message); |
104 void OnSetParent(int32 parent_route_id, | 103 void OnSetParent(int32 parent_route_id, |
105 uint32 parent_texture_id, | 104 uint32 parent_texture_id, |
106 IPC::Message* reply_message); | 105 IPC::Message* reply_message); |
107 void OnGetState(IPC::Message* reply_message); | 106 void OnGetState(IPC::Message* reply_message); |
108 void OnFlush(int32 put_offset, | 107 void OnFlush(int32 put_offset, |
109 int32 last_known_get, | 108 int32 last_known_get, |
110 uint32 flush_count, | 109 uint32 flush_count, |
111 IPC::Message* reply_message); | 110 IPC::Message* reply_message); |
112 void OnAsyncFlush(int32 put_offset, uint32 flush_count); | 111 void OnAsyncFlush(int32 put_offset, uint32 flush_count); |
| 112 void OnRescheduled(); |
113 void OnCreateTransferBuffer(int32 size, | 113 void OnCreateTransferBuffer(int32 size, |
114 int32 id_request, | 114 int32 id_request, |
115 IPC::Message* reply_message); | 115 IPC::Message* reply_message); |
116 void OnRegisterTransferBuffer(base::SharedMemoryHandle transfer_buffer, | 116 void OnRegisterTransferBuffer(base::SharedMemoryHandle transfer_buffer, |
117 size_t size, | 117 size_t size, |
118 int32 id_request, | 118 int32 id_request, |
119 IPC::Message* reply_message); | 119 IPC::Message* reply_message); |
120 void OnDestroyTransferBuffer(int32 id, IPC::Message* reply_message); | 120 void OnDestroyTransferBuffer(int32 id, IPC::Message* reply_message); |
121 void OnGetTransferBuffer(int32 id, IPC::Message* reply_message); | 121 void OnGetTransferBuffer(int32 id, IPC::Message* reply_message); |
122 void OnResizeOffscreenFrameBuffer(const gfx::Size& size); | 122 void OnResizeOffscreenFrameBuffer(const gfx::Size& size); |
123 | 123 |
124 void OnCreateVideoDecoder(int32 decoder_host_id, | 124 void OnCreateVideoDecoder(int32 decoder_host_id, |
125 const std::vector<uint32>& configs); | 125 const std::vector<uint32>& configs); |
126 void OnDestroyVideoDecoder(); | 126 void OnDestroyVideoDecoder(); |
127 | 127 |
128 void OnSwapBuffers(); | 128 void OnSwapBuffers(); |
129 void OnCommandProcessed(); | 129 void OnCommandProcessed(); |
130 void HandleDeferredMessages(); | |
131 void OnScheduled(); | |
132 void OnParseError(); | 130 void OnParseError(); |
133 | 131 |
134 #if defined(OS_MACOSX) | 132 #if defined(OS_MACOSX) |
135 void OnSetWindowSize(const gfx::Size& size); | 133 void OnSetWindowSize(const gfx::Size& size); |
136 #endif // defined(OS_MACOSX) | 134 #endif // defined(OS_MACOSX) |
137 | 135 |
138 #if defined(OS_MACOSX) || defined(TOUCH_UI) | 136 #if defined(OS_MACOSX) || defined(TOUCH_UI) |
139 void SwapBuffersCallback(); | 137 void SwapBuffersCallback(); |
140 #endif // defined(TOUCH_UI) | 138 #endif // defined(TOUCH_UI) |
141 | 139 |
(...skipping 16 matching lines...) Expand all Loading... |
158 int32 route_id_; | 156 int32 route_id_; |
159 uint32 last_flush_count_; | 157 uint32 last_flush_count_; |
160 | 158 |
161 // The following two fields are used on Mac OS X to identify the window | 159 // The following two fields are used on Mac OS X to identify the window |
162 // for the rendering results on the browser side. | 160 // for the rendering results on the browser side. |
163 int32 renderer_id_; | 161 int32 renderer_id_; |
164 int32 render_view_id_; | 162 int32 render_view_id_; |
165 | 163 |
166 scoped_ptr<gpu::CommandBufferService> command_buffer_; | 164 scoped_ptr<gpu::CommandBufferService> command_buffer_; |
167 scoped_ptr<gpu::GpuScheduler> scheduler_; | 165 scoped_ptr<gpu::GpuScheduler> scheduler_; |
168 std::queue<IPC::Message*> deferred_messages_; | |
169 std::vector<base::Callback<void(int32)> > set_token_callbacks_; | 166 std::vector<base::Callback<void(int32)> > set_token_callbacks_; |
170 | 167 |
171 // SetParent may be called before Initialize, in which case we need to keep | 168 // SetParent may be called before Initialize, in which case we need to keep |
172 // around the parent stub, so that Initialize can set the parent correctly. | 169 // around the parent stub, so that Initialize can set the parent correctly. |
173 base::WeakPtr<GpuCommandBufferStub> parent_stub_for_initialization_; | 170 base::WeakPtr<GpuCommandBufferStub> parent_stub_for_initialization_; |
174 uint32 parent_texture_for_initialization_; | 171 uint32 parent_texture_for_initialization_; |
175 | 172 |
176 GpuWatchdog* watchdog_; | 173 GpuWatchdog* watchdog_; |
177 ScopedRunnableMethodFactory<GpuCommandBufferStub> task_factory_; | 174 ScopedRunnableMethodFactory<GpuCommandBufferStub> task_factory_; |
178 | 175 |
179 // The video decoder associated with this stub, if any. | 176 // The video decoder associated with this stub, if any. |
180 scoped_ptr<GpuVideoDecodeAccelerator> video_decoder_; | 177 scoped_ptr<GpuVideoDecodeAccelerator> video_decoder_; |
181 | 178 |
182 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); | 179 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); |
183 }; | 180 }; |
184 | 181 |
185 #endif // defined(ENABLE_GPU) | 182 #endif // defined(ENABLE_GPU) |
186 | 183 |
187 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 184 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
OLD | NEW |