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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 28 matching lines...) Loading... |
39 : channel_(channel), | 39 : channel_(channel), |
40 handle_(handle), | 40 handle_(handle), |
41 initial_size_(size), | 41 initial_size_(size), |
42 disallowed_extensions_(disallowed_extensions), | 42 disallowed_extensions_(disallowed_extensions), |
43 allowed_extensions_(allowed_extensions), | 43 allowed_extensions_(allowed_extensions), |
44 requested_attribs_(attribs), | 44 requested_attribs_(attribs), |
45 route_id_(route_id), | 45 route_id_(route_id), |
46 last_flush_count_(0), | 46 last_flush_count_(0), |
47 renderer_id_(renderer_id), | 47 renderer_id_(renderer_id), |
48 render_view_id_(render_view_id), | 48 render_view_id_(render_view_id), |
| 49 parent_stub_for_initialization_(), |
| 50 parent_texture_for_initialization_(0), |
49 watchdog_(watchdog), | 51 watchdog_(watchdog), |
50 task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 52 task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
51 } | 53 } |
52 | 54 |
53 GpuCommandBufferStub::~GpuCommandBufferStub() { | 55 GpuCommandBufferStub::~GpuCommandBufferStub() { |
54 if (scheduler_.get()) { | 56 if (scheduler_.get()) { |
55 scheduler_->Destroy(); | 57 scheduler_->Destroy(); |
56 } | 58 } |
57 | 59 |
58 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 60 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
(...skipping 105 matching lines...) Loading... |
164 NewCallback(this, | 166 NewCallback(this, |
165 &GpuCommandBufferStub::SwapBuffersCallback)); | 167 &GpuCommandBufferStub::SwapBuffersCallback)); |
166 } | 168 } |
167 #endif // defined(OS_MACOSX) | 169 #endif // defined(OS_MACOSX) |
168 | 170 |
169 // Set up a pathway for resizing the output window or framebuffer at the | 171 // Set up a pathway for resizing the output window or framebuffer at the |
170 // right time relative to other GL commands. | 172 // right time relative to other GL commands. |
171 scheduler_->SetResizeCallback( | 173 scheduler_->SetResizeCallback( |
172 NewCallback(this, &GpuCommandBufferStub::ResizeCallback)); | 174 NewCallback(this, &GpuCommandBufferStub::ResizeCallback)); |
173 | 175 |
| 176 if (parent_stub_for_initialization_) { |
| 177 scheduler_->SetParent(parent_stub_for_initialization_->scheduler_.get(), |
| 178 parent_texture_for_initialization_); |
| 179 parent_stub_for_initialization_.reset(); |
| 180 parent_texture_for_initialization_ = 0; |
| 181 } |
| 182 |
174 result = true; | 183 result = true; |
175 } else { | 184 } else { |
176 scheduler_.reset(); | 185 scheduler_.reset(); |
177 command_buffer_.reset(); | 186 command_buffer_.reset(); |
178 } | 187 } |
179 } | 188 } |
180 | 189 |
181 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, result); | 190 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, result); |
182 Send(reply_message); | 191 Send(reply_message); |
183 } | 192 } |
184 | 193 |
185 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, | 194 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, |
186 uint32 parent_texture_id, | 195 uint32 parent_texture_id, |
187 IPC::Message* reply_message) { | 196 IPC::Message* reply_message) { |
188 bool result = false; | |
189 | 197 |
190 if (parent_route_id == MSG_ROUTING_NONE) { | 198 GpuCommandBufferStub* parent_stub = NULL; |
191 result = scheduler_->SetParent(NULL, 0); | 199 if (parent_route_id != MSG_ROUTING_NONE) { |
192 } else { | 200 parent_stub = channel_->LookupCommandBuffer(parent_route_id); |
193 GpuCommandBufferStub* parent_stub = channel_->LookupCommandBuffer( | |
194 parent_route_id); | |
195 if (parent_stub) { | |
196 result = scheduler_->SetParent(parent_stub->scheduler_.get(), | |
197 parent_texture_id); | |
198 } | |
199 } | 201 } |
200 | 202 |
| 203 bool result = true; |
| 204 if (scheduler_.get()) { |
| 205 gpu::GpuScheduler* parent_scheduler = |
| 206 parent_stub ? parent_stub->scheduler_.get() : NULL; |
| 207 result = scheduler_->SetParent(parent_scheduler, parent_texture_id); |
| 208 } else { |
| 209 // If we don't have a scheduler, it means that Initialize hasn't been called |
| 210 // yet. Keep around the requested parent stub and texture so that we can set |
| 211 // it in Initialize(). |
| 212 parent_stub_for_initialization_ = parent_stub ? |
| 213 parent_stub->AsWeakPtr() : base::WeakPtr<GpuCommandBufferStub>(); |
| 214 parent_texture_for_initialization_ = parent_texture_id; |
| 215 } |
201 GpuCommandBufferMsg_SetParent::WriteReplyParams(reply_message, result); | 216 GpuCommandBufferMsg_SetParent::WriteReplyParams(reply_message, result); |
202 Send(reply_message); | 217 Send(reply_message); |
203 } | 218 } |
204 | 219 |
205 void GpuCommandBufferStub::OnGetState(IPC::Message* reply_message) { | 220 void GpuCommandBufferStub::OnGetState(IPC::Message* reply_message) { |
206 gpu::CommandBuffer::State state = command_buffer_->GetState(); | 221 gpu::CommandBuffer::State state = command_buffer_->GetState(); |
207 if (state.error == gpu::error::kLostContext && | 222 if (state.error == gpu::error::kLostContext && |
208 gfx::GLContext::LosesAllContextsOnContextLost()) | 223 gfx::GLContext::LosesAllContextsOnContextLost()) |
209 channel_->LoseAllContexts(); | 224 channel_->LoseAllContexts(); |
210 | 225 |
(...skipping 269 matching lines...) Loading... |
480 gfx::GLContext::LosesAllContextsOnContextLost()) { | 495 gfx::GLContext::LosesAllContextsOnContextLost()) { |
481 channel_->LoseAllContexts(); | 496 channel_->LoseAllContexts(); |
482 } else { | 497 } else { |
483 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); | 498 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); |
484 msg->set_unblock(true); | 499 msg->set_unblock(true); |
485 Send(msg); | 500 Send(msg); |
486 } | 501 } |
487 } | 502 } |
488 | 503 |
489 #endif // defined(ENABLE_GPU) | 504 #endif // defined(ENABLE_GPU) |
OLD | NEW |