| OLD | NEW |
| 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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 FROM_HERE, | 172 FROM_HERE, |
| 173 base::Bind(&GpuChannel::HandleMessage, weak_factory_.GetWeakPtr())); | 173 base::Bind(&GpuChannel::HandleMessage, weak_factory_.GetWeakPtr())); |
| 174 handle_messages_scheduled_ = true; | 174 handle_messages_scheduled_ = true; |
| 175 } | 175 } |
| 176 | 176 |
| 177 void GpuChannel::CreateViewCommandBuffer( | 177 void GpuChannel::CreateViewCommandBuffer( |
| 178 const gfx::GLSurfaceHandle& window, | 178 const gfx::GLSurfaceHandle& window, |
| 179 int32 surface_id, | 179 int32 surface_id, |
| 180 const GPUCreateCommandBufferConfig& init_params, | 180 const GPUCreateCommandBufferConfig& init_params, |
| 181 int32* route_id) { | 181 int32* route_id) { |
| 182 TRACE_EVENT1("gpu", |
| 183 "GpuChannel::CreateViewCommandBuffer", |
| 184 "surface_id", |
| 185 surface_id); |
| 186 |
| 182 *route_id = MSG_ROUTING_NONE; | 187 *route_id = MSG_ROUTING_NONE; |
| 183 content::GetContentClient()->SetActiveURL(init_params.active_url); | 188 content::GetContentClient()->SetActiveURL(init_params.active_url); |
| 184 | 189 |
| 185 #if defined(ENABLE_GPU) | 190 #if defined(ENABLE_GPU) |
| 186 WillCreateCommandBuffer(init_params.gpu_preference); | 191 WillCreateCommandBuffer(init_params.gpu_preference); |
| 187 | 192 |
| 188 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id); | 193 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id); |
| 189 | 194 |
| 190 *route_id = GenerateRouteID(); | 195 *route_id = GenerateRouteID(); |
| 191 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub( | 196 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub( |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 weak_factory_.GetWeakPtr(), | 334 weak_factory_.GetWeakPtr(), |
| 330 stub->route_id()), | 335 stub->route_id()), |
| 331 base::TimeDelta::FromMilliseconds(delay)); | 336 base::TimeDelta::FromMilliseconds(delay)); |
| 332 } | 337 } |
| 333 } | 338 } |
| 334 | 339 |
| 335 void GpuChannel::OnCreateOffscreenCommandBuffer( | 340 void GpuChannel::OnCreateOffscreenCommandBuffer( |
| 336 const gfx::Size& size, | 341 const gfx::Size& size, |
| 337 const GPUCreateCommandBufferConfig& init_params, | 342 const GPUCreateCommandBufferConfig& init_params, |
| 338 IPC::Message* reply_message) { | 343 IPC::Message* reply_message) { |
| 344 TRACE_EVENT0("gpu", "GpuChannel::OnCreateOffscreenCommandBuffer"); |
| 345 |
| 339 int32 route_id = MSG_ROUTING_NONE; | 346 int32 route_id = MSG_ROUTING_NONE; |
| 340 | 347 |
| 341 content::GetContentClient()->SetActiveURL(init_params.active_url); | 348 content::GetContentClient()->SetActiveURL(init_params.active_url); |
| 342 #if defined(ENABLE_GPU) | 349 #if defined(ENABLE_GPU) |
| 343 WillCreateCommandBuffer(init_params.gpu_preference); | 350 WillCreateCommandBuffer(init_params.gpu_preference); |
| 344 | 351 |
| 345 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id); | 352 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id); |
| 346 | 353 |
| 347 route_id = GenerateRouteID(); | 354 route_id = GenerateRouteID(); |
| 348 | 355 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 366 #endif | 373 #endif |
| 367 | 374 |
| 368 GpuChannelMsg_CreateOffscreenCommandBuffer::WriteReplyParams( | 375 GpuChannelMsg_CreateOffscreenCommandBuffer::WriteReplyParams( |
| 369 reply_message, | 376 reply_message, |
| 370 route_id); | 377 route_id); |
| 371 Send(reply_message); | 378 Send(reply_message); |
| 372 } | 379 } |
| 373 | 380 |
| 374 void GpuChannel::OnDestroyCommandBuffer(int32 route_id, | 381 void GpuChannel::OnDestroyCommandBuffer(int32 route_id, |
| 375 IPC::Message* reply_message) { | 382 IPC::Message* reply_message) { |
| 376 #if defined(ENABLE_GPU) | |
| 377 TRACE_EVENT1("gpu", "GpuChannel::OnDestroyCommandBuffer", | 383 TRACE_EVENT1("gpu", "GpuChannel::OnDestroyCommandBuffer", |
| 378 "route_id", route_id); | 384 "route_id", route_id); |
| 385 |
| 379 if (router_.ResolveRoute(route_id)) { | 386 if (router_.ResolveRoute(route_id)) { |
| 380 GpuCommandBufferStub* stub = stubs_.Lookup(route_id); | 387 GpuCommandBufferStub* stub = stubs_.Lookup(route_id); |
| 381 bool need_reschedule = (stub && !stub->IsScheduled()); | 388 bool need_reschedule = (stub && !stub->IsScheduled()); |
| 382 gfx::GpuPreference gpu_preference = | 389 gfx::GpuPreference gpu_preference = |
| 383 stub ? stub->gpu_preference() : gfx::PreferIntegratedGpu; | 390 stub ? stub->gpu_preference() : gfx::PreferIntegratedGpu; |
| 384 router_.RemoveRoute(route_id); | 391 router_.RemoveRoute(route_id); |
| 385 stubs_.Remove(route_id); | 392 stubs_.Remove(route_id); |
| 386 // In case the renderer is currently blocked waiting for a sync reply from | 393 // In case the renderer is currently blocked waiting for a sync reply from |
| 387 // the stub, we need to make sure to reschedule the GpuChannel here. | 394 // the stub, we need to make sure to reschedule the GpuChannel here. |
| 388 if (need_reschedule) | 395 if (need_reschedule) |
| 389 OnScheduled(); | 396 OnScheduled(); |
| 390 DidDestroyCommandBuffer(gpu_preference); | 397 DidDestroyCommandBuffer(gpu_preference); |
| 391 } | 398 } |
| 392 #endif | |
| 393 | 399 |
| 394 if (reply_message) | 400 if (reply_message) |
| 395 Send(reply_message); | 401 Send(reply_message); |
| 396 } | 402 } |
| 397 | 403 |
| 398 | 404 |
| 399 void GpuChannel::OnWillGpuSwitchOccur(bool is_creating_context, | 405 void GpuChannel::OnWillGpuSwitchOccur(bool is_creating_context, |
| 400 gfx::GpuPreference gpu_preference, | 406 gfx::GpuPreference gpu_preference, |
| 401 IPC::Message* reply_message) { | 407 IPC::Message* reply_message) { |
| 402 TRACE_EVENT0("gpu", "GpuChannel::OnWillGpuSwitchOccur"); | 408 TRACE_EVENT0("gpu", "GpuChannel::OnWillGpuSwitchOccur"); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 426 void GpuChannel::WillCreateCommandBuffer(gfx::GpuPreference gpu_preference) { | 432 void GpuChannel::WillCreateCommandBuffer(gfx::GpuPreference gpu_preference) { |
| 427 if (gpu_preference == gfx::PreferDiscreteGpu) | 433 if (gpu_preference == gfx::PreferDiscreteGpu) |
| 428 ++num_contexts_preferring_discrete_gpu_; | 434 ++num_contexts_preferring_discrete_gpu_; |
| 429 } | 435 } |
| 430 | 436 |
| 431 void GpuChannel::DidDestroyCommandBuffer(gfx::GpuPreference gpu_preference) { | 437 void GpuChannel::DidDestroyCommandBuffer(gfx::GpuPreference gpu_preference) { |
| 432 if (gpu_preference == gfx::PreferDiscreteGpu) | 438 if (gpu_preference == gfx::PreferDiscreteGpu) |
| 433 --num_contexts_preferring_discrete_gpu_; | 439 --num_contexts_preferring_discrete_gpu_; |
| 434 DCHECK_GE(num_contexts_preferring_discrete_gpu_, 0); | 440 DCHECK_GE(num_contexts_preferring_discrete_gpu_, 0); |
| 435 } | 441 } |
| OLD | NEW |