Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 1365563002: Make channel preemption not require view contexts for hookup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wakeup_gpu
Patch Set: . Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool use_virtualized_gl_context, 188 bool use_virtualized_gl_context,
189 int32 stream_id, 189 int32 stream_id,
190 int32 route_id, 190 int32 route_id,
191 int32 surface_id, 191 bool offscreen,
192 GpuWatchdog* watchdog, 192 GpuWatchdog* watchdog,
193 bool software,
194 const GURL& active_url) 193 const GURL& active_url)
195 : channel_(channel), 194 : channel_(channel),
196 task_runner_(task_runner), 195 task_runner_(task_runner),
197 initialized_(false), 196 initialized_(false),
198 handle_(handle), 197 handle_(handle),
199 initial_size_(size), 198 initial_size_(size),
200 disallowed_features_(disallowed_features), 199 disallowed_features_(disallowed_features),
201 requested_attribs_(attribs), 200 requested_attribs_(attribs),
202 gpu_preference_(gpu_preference), 201 gpu_preference_(gpu_preference),
203 use_virtualized_gl_context_(use_virtualized_gl_context), 202 use_virtualized_gl_context_(use_virtualized_gl_context),
204 command_buffer_id_(GetCommandBufferID(channel->client_id(), route_id)), 203 command_buffer_id_(GetCommandBufferID(channel->client_id(), route_id)),
205 stream_id_(stream_id), 204 stream_id_(stream_id),
206 route_id_(route_id), 205 route_id_(route_id),
207 surface_id_(surface_id), 206 offscreen_(offscreen),
208 software_(software),
209 last_flush_count_(0), 207 last_flush_count_(0),
210 last_memory_allocation_valid_(false), 208 last_memory_allocation_valid_(false),
211 watchdog_(watchdog), 209 watchdog_(watchdog),
212 waiting_for_sync_point_(false), 210 waiting_for_sync_point_(false),
213 previous_processed_num_(0), 211 previous_processed_num_(0),
214 active_url_(active_url), 212 active_url_(active_url),
215 total_gpu_memory_(0) { 213 total_gpu_memory_(0) {
216 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec()); 214 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec());
217 FastSetActiveURL(active_url_, active_url_hash_); 215 FastSetActiveURL(active_url_, active_url_hash_);
218 216
(...skipping 10 matching lines...) Expand all
229 new GpuCommandBufferMemoryTracker(channel, command_buffer_id_), 227 new GpuCommandBufferMemoryTracker(channel, command_buffer_id_),
230 channel_->gpu_channel_manager()->shader_translator_cache(), 228 channel_->gpu_channel_manager()->shader_translator_cache(),
231 channel_->gpu_channel_manager()->framebuffer_completeness_cache(), NULL, 229 channel_->gpu_channel_manager()->framebuffer_completeness_cache(), NULL,
232 subscription_ref_set, pending_valuebuffer_state, 230 subscription_ref_set, pending_valuebuffer_state,
233 attrib_parser.bind_generates_resource); 231 attrib_parser.bind_generates_resource);
234 } 232 }
235 233
236 use_virtualized_gl_context_ |= 234 use_virtualized_gl_context_ |=
237 context_group_->feature_info()->UseVirtualizedGLContexts(); 235 context_group_->feature_info()->UseVirtualizedGLContexts();
238 236
239 bool is_offscreen = surface_id_ == 0; 237 if (offscreen && initial_size_.IsEmpty()) {
240 if (is_offscreen && initial_size_.IsEmpty()) {
241 // If we're an offscreen surface with zero width and/or height, set to a 238 // If we're an offscreen surface with zero width and/or height, set to a
242 // non-zero size so that we have a complete framebuffer for operations like 239 // non-zero size so that we have a complete framebuffer for operations like
243 // glClear. 240 // glClear.
244 initial_size_ = gfx::Size(1, 1); 241 initial_size_ = gfx::Size(1, 1);
245 } 242 }
246 } 243 }
247 244
248 GpuCommandBufferStub::~GpuCommandBufferStub() { 245 GpuCommandBufferStub::~GpuCommandBufferStub() {
249 Destroy(); 246 Destroy();
250 } 247 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 Send(wait_for_get_offset_->reply.release()); 459 Send(wait_for_get_offset_->reply.release());
463 wait_for_get_offset_.reset(); 460 wait_for_get_offset_.reset();
464 } 461 }
465 462
466 if (initialized_) { 463 if (initialized_) {
467 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); 464 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
468 if (handle_.is_null() && !active_url_.is_empty()) { 465 if (handle_.is_null() && !active_url_.is_empty()) {
469 gpu_channel_manager->Send( 466 gpu_channel_manager->Send(
470 new GpuHostMsg_DidDestroyOffscreenContext(active_url_)); 467 new GpuHostMsg_DidDestroyOffscreenContext(active_url_));
471 } 468 }
472 gpu_channel_manager->Send(
473 new GpuHostMsg_DestroyCommandBuffer(surface_id()));
474 } 469 }
475 470
476 memory_manager_client_state_.reset(); 471 memory_manager_client_state_.reset();
477 472
478 while (!sync_points_.empty()) 473 while (!sync_points_.empty())
479 OnRetireSyncPoint(sync_points_.front()); 474 OnRetireSyncPoint(sync_points_.front());
480 475
481 if (decoder_) 476 if (decoder_)
482 decoder_->set_engine(NULL); 477 decoder_->set_engine(NULL);
483 478
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 channel_->GetSyncPointClientState(), 540 channel_->GetSyncPointClientState(),
546 gpu::CommandBufferNamespace::GPU_IO, 541 gpu::CommandBufferNamespace::GPU_IO,
547 command_buffer_id_); 542 command_buffer_id_);
548 543
549 if (preemption_flag_.get()) 544 if (preemption_flag_.get())
550 scheduler_->SetPreemptByFlag(preemption_flag_); 545 scheduler_->SetPreemptByFlag(preemption_flag_);
551 546
552 decoder_->set_engine(scheduler_.get()); 547 decoder_->set_engine(scheduler_.get());
553 548
554 if (!handle_.is_null()) { 549 if (!handle_.is_null()) {
555 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
556 if (software_) {
557 LOG(ERROR) << "No software support.";
558 OnInitializeFailed(reply_message);
559 return;
560 }
561 #endif
562
563 surface_ = ImageTransportSurface::CreateSurface( 550 surface_ = ImageTransportSurface::CreateSurface(
564 channel_->gpu_channel_manager(), 551 channel_->gpu_channel_manager(),
565 this, 552 this,
566 handle_); 553 handle_);
567 } else { 554 } else {
568 surface_ = manager->GetDefaultOffscreenSurface(); 555 surface_ = manager->GetDefaultOffscreenSurface();
569 } 556 }
570 557
571 if (!surface_.get()) { 558 if (!surface_.get()) {
572 DLOG(ERROR) << "Failed to create surface."; 559 DLOG(ERROR) << "Failed to create surface.";
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 if (!context->GetTotalGpuMemory(&total_gpu_memory_)) 616 if (!context->GetTotalGpuMemory(&total_gpu_memory_))
630 total_gpu_memory_ = 0; 617 total_gpu_memory_ = 0;
631 618
632 if (!context_group_->has_program_cache() && 619 if (!context_group_->has_program_cache() &&
633 !context_group_->feature_info()->workarounds().disable_program_cache) { 620 !context_group_->feature_info()->workarounds().disable_program_cache) {
634 context_group_->set_program_cache( 621 context_group_->set_program_cache(
635 channel_->gpu_channel_manager()->program_cache()); 622 channel_->gpu_channel_manager()->program_cache());
636 } 623 }
637 624
638 // Initialize the decoder with either the view or pbuffer GLContext. 625 // Initialize the decoder with either the view or pbuffer GLContext.
639 if (!decoder_->Initialize(surface_, 626 if (!decoder_->Initialize(surface_, context, offscreen_, initial_size_,
640 context, 627 disallowed_features_, requested_attribs_)) {
641 !surface_id(),
642 initial_size_,
643 disallowed_features_,
644 requested_attribs_)) {
645 DLOG(ERROR) << "Failed to initialize decoder."; 628 DLOG(ERROR) << "Failed to initialize decoder.";
646 OnInitializeFailed(reply_message); 629 OnInitializeFailed(reply_message);
647 return; 630 return;
648 } 631 }
649 632
650 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 633 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
651 switches::kEnableGPUServiceLogging)) { 634 switches::kEnableGPUServiceLogging)) {
652 decoder_->set_log_commands(true); 635 decoder_->set_log_commands(true);
653 } 636 }
654 637
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 } 1014 }
1032 1015
1033 1016
1034 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( 1017 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback(
1035 bool has_callback) { 1018 bool has_callback) {
1036 TRACE_EVENT0( 1019 TRACE_EVENT0(
1037 "gpu", 1020 "gpu",
1038 "GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback"); 1021 "GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback");
1039 if (has_callback) { 1022 if (has_callback) {
1040 if (!memory_manager_client_state_) { 1023 if (!memory_manager_client_state_) {
1041 memory_manager_client_state_.reset(GetMemoryManager()->CreateClientState( 1024 memory_manager_client_state_.reset(
1042 this, surface_id_ != 0, true)); 1025 GetMemoryManager()->CreateClientState(this, !offscreen_, true));
1043 } 1026 }
1044 } else { 1027 } else {
1045 memory_manager_client_state_.reset(); 1028 memory_manager_client_state_.reset();
1046 } 1029 }
1047 } 1030 }
1048 1031
1049 void GpuCommandBufferStub::OnCreateImage(int32 id, 1032 void GpuCommandBufferStub::OnCreateImage(int32 id,
1050 gfx::GpuMemoryBufferHandle handle, 1033 gfx::GpuMemoryBufferHandle handle,
1051 gfx::Size size, 1034 gfx::Size size,
1052 gfx::BufferFormat format, 1035 gfx::BufferFormat format,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 result)); 1216 result));
1234 } 1217 }
1235 1218
1236 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1219 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1237 base::TimeDelta interval) { 1220 base::TimeDelta interval) {
1238 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1221 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1239 interval)); 1222 interval));
1240 } 1223 }
1241 1224
1242 } // namespace content 1225 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698