| 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 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/hash.h" | 8 #include "base/hash.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 const gfx::GLSurfaceHandle& handle, | 180 const gfx::GLSurfaceHandle& handle, |
| 181 gpu::gles2::MailboxManager* mailbox_manager, | 181 gpu::gles2::MailboxManager* mailbox_manager, |
| 182 gpu::gles2::SubscriptionRefSet* subscription_ref_set, | 182 gpu::gles2::SubscriptionRefSet* subscription_ref_set, |
| 183 gpu::ValueStateMap* pending_valuebuffer_state, | 183 gpu::ValueStateMap* pending_valuebuffer_state, |
| 184 const gfx::Size& size, | 184 const gfx::Size& size, |
| 185 const gpu::gles2::DisallowedFeatures& disallowed_features, | 185 const gpu::gles2::DisallowedFeatures& disallowed_features, |
| 186 const std::vector<int32>& attribs, | 186 const std::vector<int32>& attribs, |
| 187 gfx::GpuPreference gpu_preference, | 187 gfx::GpuPreference gpu_preference, |
| 188 int32 stream_id, | 188 int32 stream_id, |
| 189 int32 route_id, | 189 int32 route_id, |
| 190 int32 surface_id, | 190 bool offscreen, |
| 191 GpuWatchdog* watchdog, | 191 GpuWatchdog* watchdog, |
| 192 bool software, | |
| 193 const GURL& active_url) | 192 const GURL& active_url) |
| 194 : channel_(channel), | 193 : channel_(channel), |
| 195 task_runner_(task_runner), | 194 task_runner_(task_runner), |
| 196 initialized_(false), | 195 initialized_(false), |
| 197 handle_(handle), | 196 handle_(handle), |
| 198 initial_size_(size), | 197 initial_size_(size), |
| 199 disallowed_features_(disallowed_features), | 198 disallowed_features_(disallowed_features), |
| 200 requested_attribs_(attribs), | 199 requested_attribs_(attribs), |
| 201 gpu_preference_(gpu_preference), | 200 gpu_preference_(gpu_preference), |
| 202 use_virtualized_gl_context_(false), | 201 use_virtualized_gl_context_(false), |
| 203 command_buffer_id_(GetCommandBufferID(channel->client_id(), route_id)), | 202 command_buffer_id_(GetCommandBufferID(channel->client_id(), route_id)), |
| 204 stream_id_(stream_id), | 203 stream_id_(stream_id), |
| 205 route_id_(route_id), | 204 route_id_(route_id), |
| 206 surface_id_(surface_id), | 205 offscreen_(offscreen), |
| 207 software_(software), | |
| 208 last_flush_count_(0), | 206 last_flush_count_(0), |
| 209 last_memory_allocation_valid_(false), | 207 last_memory_allocation_valid_(false), |
| 210 watchdog_(watchdog), | 208 watchdog_(watchdog), |
| 211 waiting_for_sync_point_(false), | 209 waiting_for_sync_point_(false), |
| 212 previous_processed_num_(0), | 210 previous_processed_num_(0), |
| 213 active_url_(active_url), | 211 active_url_(active_url), |
| 214 total_gpu_memory_(0) { | 212 total_gpu_memory_(0) { |
| 215 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec()); | 213 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec()); |
| 216 FastSetActiveURL(active_url_, active_url_hash_); | 214 FastSetActiveURL(active_url_, active_url_hash_); |
| 217 | 215 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 236 // performance regressions when enabling FCM. | 234 // performance regressions when enabling FCM. |
| 237 // http://crbug.com/180463 | 235 // http://crbug.com/180463 |
| 238 #if defined(OS_MACOSX) | 236 #if defined(OS_MACOSX) |
| 239 if (gpu_preference_ == gfx::PreferIntegratedGpu) | 237 if (gpu_preference_ == gfx::PreferIntegratedGpu) |
| 240 use_virtualized_gl_context_ = true; | 238 use_virtualized_gl_context_ = true; |
| 241 #endif | 239 #endif |
| 242 | 240 |
| 243 use_virtualized_gl_context_ |= | 241 use_virtualized_gl_context_ |= |
| 244 context_group_->feature_info()->UseVirtualizedGLContexts(); | 242 context_group_->feature_info()->UseVirtualizedGLContexts(); |
| 245 | 243 |
| 246 bool is_offscreen = surface_id_ == 0; | 244 if (offscreen && initial_size_.IsEmpty()) { |
| 247 if (is_offscreen && initial_size_.IsEmpty()) { | |
| 248 // If we're an offscreen surface with zero width and/or height, set to a | 245 // If we're an offscreen surface with zero width and/or height, set to a |
| 249 // non-zero size so that we have a complete framebuffer for operations like | 246 // non-zero size so that we have a complete framebuffer for operations like |
| 250 // glClear. | 247 // glClear. |
| 251 initial_size_ = gfx::Size(1, 1); | 248 initial_size_ = gfx::Size(1, 1); |
| 252 } | 249 } |
| 253 } | 250 } |
| 254 | 251 |
| 255 GpuCommandBufferStub::~GpuCommandBufferStub() { | 252 GpuCommandBufferStub::~GpuCommandBufferStub() { |
| 256 Destroy(); | 253 Destroy(); |
| 257 } | 254 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 Send(wait_for_get_offset_->reply.release()); | 466 Send(wait_for_get_offset_->reply.release()); |
| 470 wait_for_get_offset_.reset(); | 467 wait_for_get_offset_.reset(); |
| 471 } | 468 } |
| 472 | 469 |
| 473 if (initialized_) { | 470 if (initialized_) { |
| 474 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 471 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
| 475 if (handle_.is_null() && !active_url_.is_empty()) { | 472 if (handle_.is_null() && !active_url_.is_empty()) { |
| 476 gpu_channel_manager->Send( | 473 gpu_channel_manager->Send( |
| 477 new GpuHostMsg_DidDestroyOffscreenContext(active_url_)); | 474 new GpuHostMsg_DidDestroyOffscreenContext(active_url_)); |
| 478 } | 475 } |
| 479 gpu_channel_manager->Send( | |
| 480 new GpuHostMsg_DestroyCommandBuffer(surface_id())); | |
| 481 } | 476 } |
| 482 | 477 |
| 483 memory_manager_client_state_.reset(); | 478 memory_manager_client_state_.reset(); |
| 484 | 479 |
| 485 while (!sync_points_.empty()) | 480 while (!sync_points_.empty()) |
| 486 OnRetireSyncPoint(sync_points_.front()); | 481 OnRetireSyncPoint(sync_points_.front()); |
| 487 | 482 |
| 488 if (decoder_) | 483 if (decoder_) |
| 489 decoder_->set_engine(NULL); | 484 decoder_->set_engine(NULL); |
| 490 | 485 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 channel_->GetSyncPointClientState(), | 547 channel_->GetSyncPointClientState(), |
| 553 gpu::CommandBufferNamespace::GPU_IO, | 548 gpu::CommandBufferNamespace::GPU_IO, |
| 554 command_buffer_id_); | 549 command_buffer_id_); |
| 555 | 550 |
| 556 if (preemption_flag_.get()) | 551 if (preemption_flag_.get()) |
| 557 scheduler_->SetPreemptByFlag(preemption_flag_); | 552 scheduler_->SetPreemptByFlag(preemption_flag_); |
| 558 | 553 |
| 559 decoder_->set_engine(scheduler_.get()); | 554 decoder_->set_engine(scheduler_.get()); |
| 560 | 555 |
| 561 if (!handle_.is_null()) { | 556 if (!handle_.is_null()) { |
| 562 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | |
| 563 if (software_) { | |
| 564 LOG(ERROR) << "No software support."; | |
| 565 OnInitializeFailed(reply_message); | |
| 566 return; | |
| 567 } | |
| 568 #endif | |
| 569 | |
| 570 surface_ = ImageTransportSurface::CreateSurface( | 557 surface_ = ImageTransportSurface::CreateSurface( |
| 571 channel_->gpu_channel_manager(), | 558 channel_->gpu_channel_manager(), |
| 572 this, | 559 this, |
| 573 handle_); | 560 handle_); |
| 574 } else { | 561 } else { |
| 575 surface_ = manager->GetDefaultOffscreenSurface(); | 562 surface_ = manager->GetDefaultOffscreenSurface(); |
| 576 } | 563 } |
| 577 | 564 |
| 578 if (!surface_.get()) { | 565 if (!surface_.get()) { |
| 579 DLOG(ERROR) << "Failed to create surface."; | 566 DLOG(ERROR) << "Failed to create surface."; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 if (!context->GetTotalGpuMemory(&total_gpu_memory_)) | 623 if (!context->GetTotalGpuMemory(&total_gpu_memory_)) |
| 637 total_gpu_memory_ = 0; | 624 total_gpu_memory_ = 0; |
| 638 | 625 |
| 639 if (!context_group_->has_program_cache() && | 626 if (!context_group_->has_program_cache() && |
| 640 !context_group_->feature_info()->workarounds().disable_program_cache) { | 627 !context_group_->feature_info()->workarounds().disable_program_cache) { |
| 641 context_group_->set_program_cache( | 628 context_group_->set_program_cache( |
| 642 channel_->gpu_channel_manager()->program_cache()); | 629 channel_->gpu_channel_manager()->program_cache()); |
| 643 } | 630 } |
| 644 | 631 |
| 645 // Initialize the decoder with either the view or pbuffer GLContext. | 632 // Initialize the decoder with either the view or pbuffer GLContext. |
| 646 if (!decoder_->Initialize(surface_, | 633 if (!decoder_->Initialize(surface_, context, offscreen_, initial_size_, |
| 647 context, | 634 disallowed_features_, requested_attribs_)) { |
| 648 !surface_id(), | |
| 649 initial_size_, | |
| 650 disallowed_features_, | |
| 651 requested_attribs_)) { | |
| 652 DLOG(ERROR) << "Failed to initialize decoder."; | 635 DLOG(ERROR) << "Failed to initialize decoder."; |
| 653 OnInitializeFailed(reply_message); | 636 OnInitializeFailed(reply_message); |
| 654 return; | 637 return; |
| 655 } | 638 } |
| 656 | 639 |
| 657 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 640 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 658 switches::kEnableGPUServiceLogging)) { | 641 switches::kEnableGPUServiceLogging)) { |
| 659 decoder_->set_log_commands(true); | 642 decoder_->set_log_commands(true); |
| 660 } | 643 } |
| 661 | 644 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 } | 1021 } |
| 1039 | 1022 |
| 1040 | 1023 |
| 1041 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( | 1024 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( |
| 1042 bool has_callback) { | 1025 bool has_callback) { |
| 1043 TRACE_EVENT0( | 1026 TRACE_EVENT0( |
| 1044 "gpu", | 1027 "gpu", |
| 1045 "GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback"); | 1028 "GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback"); |
| 1046 if (has_callback) { | 1029 if (has_callback) { |
| 1047 if (!memory_manager_client_state_) { | 1030 if (!memory_manager_client_state_) { |
| 1048 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( | 1031 memory_manager_client_state_.reset( |
| 1049 this, surface_id_ != 0, true)); | 1032 GetMemoryManager()->CreateClientState(this, !offscreen_, true)); |
| 1050 } | 1033 } |
| 1051 } else { | 1034 } else { |
| 1052 memory_manager_client_state_.reset(); | 1035 memory_manager_client_state_.reset(); |
| 1053 } | 1036 } |
| 1054 } | 1037 } |
| 1055 | 1038 |
| 1056 void GpuCommandBufferStub::OnCreateImage(int32 id, | 1039 void GpuCommandBufferStub::OnCreateImage(int32 id, |
| 1057 gfx::GpuMemoryBufferHandle handle, | 1040 gfx::GpuMemoryBufferHandle handle, |
| 1058 gfx::Size size, | 1041 gfx::Size size, |
| 1059 gfx::BufferFormat format, | 1042 gfx::BufferFormat format, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 result)); | 1223 result)); |
| 1241 } | 1224 } |
| 1242 | 1225 |
| 1243 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1226 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
| 1244 base::TimeDelta interval) { | 1227 base::TimeDelta interval) { |
| 1245 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1228 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 1246 interval)); | 1229 interval)); |
| 1247 } | 1230 } |
| 1248 | 1231 |
| 1249 } // namespace content | 1232 } // namespace content |
| OLD | NEW |