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(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(); | |
131 void OnParseError(); | 129 void OnParseError(); |
132 | 130 |
133 #if defined(OS_MACOSX) | 131 #if defined(OS_MACOSX) |
134 void OnSetWindowSize(const gfx::Size& size); | 132 void OnSetWindowSize(const gfx::Size& size); |
135 #endif // defined(OS_MACOSX) | 133 #endif // defined(OS_MACOSX) |
136 | 134 |
137 #if defined(OS_MACOSX) || defined(TOUCH_UI) | 135 #if defined(OS_MACOSX) || defined(TOUCH_UI) |
138 void SwapBuffersCallback(); | 136 void SwapBuffersCallback(); |
139 #endif // defined(TOUCH_UI) | 137 #endif // defined(TOUCH_UI) |
140 | 138 |
(...skipping 16 matching lines...) Expand all Loading... |
157 int32 route_id_; | 155 int32 route_id_; |
158 uint32 last_flush_count_; | 156 uint32 last_flush_count_; |
159 | 157 |
160 // The following two fields are used on Mac OS X to identify the window | 158 // The following two fields are used on Mac OS X to identify the window |
161 // for the rendering results on the browser side. | 159 // for the rendering results on the browser side. |
162 int32 renderer_id_; | 160 int32 renderer_id_; |
163 int32 render_view_id_; | 161 int32 render_view_id_; |
164 | 162 |
165 scoped_ptr<gpu::CommandBufferService> command_buffer_; | 163 scoped_ptr<gpu::CommandBufferService> command_buffer_; |
166 scoped_ptr<gpu::GpuScheduler> scheduler_; | 164 scoped_ptr<gpu::GpuScheduler> scheduler_; |
167 std::queue<IPC::Message*> deferred_messages_; | |
168 std::vector<base::Callback<void(int32)> > set_token_callbacks_; | 165 std::vector<base::Callback<void(int32)> > set_token_callbacks_; |
169 | 166 |
170 // SetParent may be called before Initialize, in which case we need to keep | 167 // SetParent may be called before Initialize, in which case we need to keep |
171 // around the parent stub, so that Initialize can set the parent correctly. | 168 // around the parent stub, so that Initialize can set the parent correctly. |
172 base::WeakPtr<GpuCommandBufferStub> parent_stub_for_initialization_; | 169 base::WeakPtr<GpuCommandBufferStub> parent_stub_for_initialization_; |
173 uint32 parent_texture_for_initialization_; | 170 uint32 parent_texture_for_initialization_; |
174 | 171 |
175 GpuWatchdog* watchdog_; | 172 GpuWatchdog* watchdog_; |
176 ScopedRunnableMethodFactory<GpuCommandBufferStub> task_factory_; | 173 ScopedRunnableMethodFactory<GpuCommandBufferStub> task_factory_; |
177 | 174 |
178 // The video decoder associated with this stub, if any. | 175 // The video decoder associated with this stub, if any. |
179 scoped_ptr<GpuVideoDecodeAccelerator> video_decoder_; | 176 scoped_ptr<GpuVideoDecodeAccelerator> video_decoder_; |
180 | 177 |
181 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); | 178 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); |
182 }; | 179 }; |
183 | 180 |
184 #endif // defined(ENABLE_GPU) | 181 #endif // defined(ENABLE_GPU) |
185 | 182 |
186 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 183 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
OLD | NEW |