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