Chromium Code Reviews| 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(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
| 12 #include "base/time.h" | |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "content/common/gpu/gpu_channel.h" | 14 #include "content/common/gpu/gpu_channel.h" |
| 14 #include "content/common/gpu/gpu_channel_manager.h" | 15 #include "content/common/gpu/gpu_channel_manager.h" |
| 15 #include "content/common/gpu/gpu_command_buffer_stub.h" | 16 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 16 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
| 18 #include "content/common/gpu/gpu_memory_manager.h" | |
| 17 #include "content/common/gpu/gpu_watchdog.h" | 19 #include "content/common/gpu/gpu_watchdog.h" |
| 18 #include "content/common/gpu/image_transport_surface.h" | 20 #include "content/common/gpu/image_transport_surface.h" |
| 19 #include "gpu/command_buffer/common/constants.h" | 21 #include "gpu/command_buffer/common/constants.h" |
| 20 #include "ui/gfx/gl/gl_bindings.h" | 22 #include "ui/gfx/gl/gl_bindings.h" |
| 21 #include "ui/gfx/gl/gl_switches.h" | 23 #include "ui/gfx/gl/gl_switches.h" |
| 22 | 24 |
| 23 GpuCommandBufferStub::GpuCommandBufferStub( | 25 GpuCommandBufferStub::GpuCommandBufferStub( |
| 24 GpuChannel* channel, | 26 GpuChannel* channel, |
| 25 GpuCommandBufferStub* share_group, | 27 GpuCommandBufferStub* share_group, |
| 26 gfx::PluginWindowHandle handle, | 28 gfx::PluginWindowHandle handle, |
| 27 const gfx::Size& size, | 29 const gfx::Size& size, |
| 28 const gpu::gles2::DisallowedFeatures& disallowed_features, | 30 const gpu::gles2::DisallowedFeatures& disallowed_features, |
| 29 const std::string& allowed_extensions, | 31 const std::string& allowed_extensions, |
| 30 const std::vector<int32>& attribs, | 32 const std::vector<int32>& attribs, |
| 31 gfx::GpuPreference gpu_preference, | 33 gfx::GpuPreference gpu_preference, |
| 32 int32 route_id, | 34 int32 route_id, |
| 33 int32 surface_id, | 35 int32 surface_id, |
| 34 GpuWatchdog* watchdog, | 36 GpuWatchdog* watchdog, |
| 35 bool software) | 37 bool software) |
| 36 : channel_(channel), | 38 : channel_(channel), |
| 37 handle_(handle), | 39 handle_(handle), |
| 38 initial_size_(size), | 40 initial_size_(size), |
| 39 disallowed_features_(disallowed_features), | 41 disallowed_features_(disallowed_features), |
| 40 allowed_extensions_(allowed_extensions), | 42 allowed_extensions_(allowed_extensions), |
| 41 requested_attribs_(attribs), | 43 requested_attribs_(attribs), |
| 42 gpu_preference_(gpu_preference), | 44 gpu_preference_(gpu_preference), |
| 43 route_id_(route_id), | 45 route_id_(route_id), |
| 44 software_(software), | 46 software_(software), |
| 45 last_flush_count_(0), | 47 last_flush_count_(0), |
| 48 surface_state_(), | |
|
nduca
2012/01/31 06:53:47
once you get this sorted, I think you should initi
mmocny
2012/01/31 18:54:57
Done.
| |
| 49 affected_surface_ids_(), | |
| 46 surface_id_(surface_id), | 50 surface_id_(surface_id), |
| 47 parent_stub_for_initialization_(), | 51 parent_stub_for_initialization_(), |
| 48 parent_texture_for_initialization_(0), | 52 parent_texture_for_initialization_(0), |
| 49 watchdog_(watchdog) { | 53 watchdog_(watchdog) { |
| 50 if (share_group) { | 54 if (share_group) { |
| 51 context_group_ = share_group->context_group_; | 55 context_group_ = share_group->context_group_; |
| 52 } else { | 56 } else { |
| 53 // TODO(gman): this needs to be false for everything but Pepper. | 57 // TODO(gman): this needs to be false for everything but Pepper. |
| 54 bool bind_generates_resource = true; | 58 bool bind_generates_resource = true; |
| 55 context_group_ = new gpu::gles2::ContextGroup(bind_generates_resource); | 59 context_group_ = new gpu::gles2::ContextGroup(bind_generates_resource); |
| 56 } | 60 } |
| 61 surface_state_.surface_id = surface_id_; | |
| 57 } | 62 } |
| 58 | 63 |
| 59 GpuCommandBufferStub::~GpuCommandBufferStub() { | 64 GpuCommandBufferStub::~GpuCommandBufferStub() { |
| 60 Destroy(); | 65 Destroy(); |
| 61 | 66 |
| 62 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 67 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
| 63 gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer(surface_id_)); | 68 gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer(surface_id_)); |
| 64 } | 69 } |
| 65 | 70 |
| 66 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { | 71 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 | 151 |
| 147 if (decoder_.get()) { | 152 if (decoder_.get()) { |
| 148 decoder_->Destroy(); | 153 decoder_->Destroy(); |
| 149 decoder_.reset(); | 154 decoder_.reset(); |
| 150 } | 155 } |
| 151 | 156 |
| 152 command_buffer_.reset(); | 157 command_buffer_.reset(); |
| 153 | 158 |
| 154 context_ = NULL; | 159 context_ = NULL; |
| 155 surface_ = NULL; | 160 surface_ = NULL; |
| 161 | |
| 162 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); | |
| 156 } | 163 } |
| 157 | 164 |
| 158 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { | 165 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { |
| 159 Destroy(); | 166 Destroy(); |
| 160 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); | 167 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); |
| 161 Send(reply_message); | 168 Send(reply_message); |
| 162 } | 169 } |
| 163 | 170 |
| 164 void GpuCommandBufferStub::OnInitialize( | 171 void GpuCommandBufferStub::OnInitialize( |
| 165 IPC::Message* reply_message) { | 172 IPC::Message* reply_message) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 | 274 |
| 268 if (parent_stub_for_initialization_) { | 275 if (parent_stub_for_initialization_) { |
| 269 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), | 276 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), |
| 270 parent_texture_for_initialization_); | 277 parent_texture_for_initialization_); |
| 271 parent_stub_for_initialization_.reset(); | 278 parent_stub_for_initialization_.reset(); |
| 272 parent_texture_for_initialization_ = 0; | 279 parent_texture_for_initialization_ = 0; |
| 273 } | 280 } |
| 274 | 281 |
| 275 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); | 282 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); |
| 276 Send(reply_message); | 283 Send(reply_message); |
| 284 | |
| 285 surface_state_.visible = true; | |
|
jonathan.backer
2012/01/31 18:13:58
If I open up a tab in the background, what happens
mmocny
2012/01/31 18:54:57
Tabs open in the background get a "WasHidden" mess
| |
| 286 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); | |
| 277 } | 287 } |
| 278 | 288 |
| 279 void GpuCommandBufferStub::OnSetGetBuffer( | 289 void GpuCommandBufferStub::OnSetGetBuffer( |
| 280 int32 shm_id, IPC::Message* reply_message) { | 290 int32 shm_id, IPC::Message* reply_message) { |
| 281 if (command_buffer_.get()) { | 291 if (command_buffer_.get()) { |
| 282 command_buffer_->SetGetBuffer(shm_id); | 292 command_buffer_->SetGetBuffer(shm_id); |
| 283 } else { | 293 } else { |
| 284 DLOG(ERROR) << "no command_buffer."; | 294 DLOG(ERROR) << "no command_buffer."; |
| 285 reply_message->set_reply_error(); | 295 reply_message->set_reply_error(); |
| 286 } | 296 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 channel_->renderer_process()); | 499 channel_->renderer_process()); |
| 490 } | 500 } |
| 491 | 501 |
| 492 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { | 502 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { |
| 493 channel_->RemoveRoute(decoder_route_id); | 503 channel_->RemoveRoute(decoder_route_id); |
| 494 video_decoders_.Remove(decoder_route_id); | 504 video_decoders_.Remove(decoder_route_id); |
| 495 } | 505 } |
| 496 | 506 |
| 497 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { | 507 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { |
| 498 surface_->SetVisible(visible); | 508 surface_->SetVisible(visible); |
| 509 surface_state_.visible = visible; | |
| 510 surface_state_.last_used_time = base::TimeTicks::Now(); | |
| 511 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); | |
| 499 } | 512 } |
| 500 | 513 |
| 501 void GpuCommandBufferStub::SendConsoleMessage( | 514 void GpuCommandBufferStub::SendConsoleMessage( |
| 502 int32 id, | 515 int32 id, |
| 503 const std::string& message) { | 516 const std::string& message) { |
| 504 GPUCommandBufferConsoleMessage console_message; | 517 GPUCommandBufferConsoleMessage console_message; |
| 505 console_message.id = id; | 518 console_message.id = id; |
| 506 console_message.message = message; | 519 console_message.message = message; |
| 507 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( | 520 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( |
| 508 route_id_, console_message); | 521 route_id_, console_message); |
| 509 msg->set_unblock(true); | 522 msg->set_unblock(true); |
| 510 Send(msg); | 523 Send(msg); |
| 511 } | 524 } |
| 512 | 525 |
| 526 const GpuSurfaceState& GpuCommandBufferStub::surface_state() { | |
| 527 return surface_state_; | |
| 528 } | |
| 529 | |
| 530 const std::vector<int32>& GpuCommandBufferStub::affected_surface_ids() { | |
| 531 return affected_surface_ids_; | |
|
nduca
2012/01/31 06:53:47
does affected_surface_ids for a view-command-buffe
mmocny
2012/01/31 18:54:57
Done.
| |
| 532 } | |
| 533 | |
| 534 void GpuCommandBufferStub::SendMemoryAllocation( | |
| 535 const GpuMemoryAllocation& allocation) { | |
| 536 // TODO(mmocny): Send callback once gl extensions are added | |
|
nduca
2012/01/31 06:53:47
sentences end with .
mmocny
2012/01/31 18:54:57
Done.
| |
| 537 } | |
| 538 | |
| 513 #endif // defined(ENABLE_GPU) | 539 #endif // defined(ENABLE_GPU) |
| OLD | NEW |