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

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

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
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 #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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 if (message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) { 120 if (message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) {
121 // This message should not be sent explicitly by the renderer. 121 // This message should not be sent explicitly by the renderer.
122 NOTREACHED(); 122 NOTREACHED();
123 handled = true; 123 handled = true;
124 } 124 }
125 125
126 // All other messages get processed by the GpuChannel. 126 // All other messages get processed by the GpuChannel.
127 if (!handled) { 127 if (!handled) {
128 messages_forwarded_to_channel_++; 128 messages_forwarded_to_channel_++;
129 if (preempting_flag_) 129 if (preempting_flag_.get())
130 pending_messages_.push(PendingMessage(messages_forwarded_to_channel_)); 130 pending_messages_.push(PendingMessage(messages_forwarded_to_channel_));
131 UpdatePreemptionState(); 131 UpdatePreemptionState();
132 } 132 }
133 133
134 if (message.type() == GpuCommandBufferMsg_InsertSyncPoint::ID) { 134 if (message.type() == GpuCommandBufferMsg_InsertSyncPoint::ID) {
135 uint32 sync_point = sync_point_manager_->GenerateSyncPoint(); 135 uint32 sync_point = sync_point_manager_->GenerateSyncPoint();
136 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message); 136 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message);
137 GpuCommandBufferMsg_InsertSyncPoint::WriteReplyParams(reply, sync_point); 137 GpuCommandBufferMsg_InsertSyncPoint::WriteReplyParams(reply, sync_point);
138 Send(reply); 138 Send(reply);
139 message_loop_->PostTask(FROM_HERE, base::Bind( 139 message_loop_->PostTask(FROM_HERE, base::Bind(
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 479
480 base::WeakPtr<GpuChannel>* weak_ptr(new base::WeakPtr<GpuChannel>( 480 base::WeakPtr<GpuChannel>* weak_ptr(new base::WeakPtr<GpuChannel>(
481 weak_factory_.GetWeakPtr())); 481 weak_factory_.GetWeakPtr()));
482 482
483 filter_ = new GpuChannelMessageFilter( 483 filter_ = new GpuChannelMessageFilter(
484 mailbox_manager_->private_key(), 484 mailbox_manager_->private_key(),
485 weak_ptr, 485 weak_ptr,
486 gpu_channel_manager_->sync_point_manager(), 486 gpu_channel_manager_->sync_point_manager(),
487 base::MessageLoopProxy::current()); 487 base::MessageLoopProxy::current());
488 io_message_loop_ = io_message_loop; 488 io_message_loop_ = io_message_loop;
489 channel_->AddFilter(filter_); 489 channel_->AddFilter(filter_.get());
490 490
491 return true; 491 return true;
492 } 492 }
493 493
494 std::string GpuChannel::GetChannelName() { 494 std::string GpuChannel::GetChannelName() {
495 return channel_id_; 495 return channel_id_;
496 } 496 }
497 497
498 #if defined(OS_POSIX) 498 #if defined(OS_POSIX)
499 int GpuChannel::TakeRendererFileDescriptor() { 499 int GpuChannel::TakeRendererFileDescriptor() {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 if (scheduled) { 596 if (scheduled) {
597 num_stubs_descheduled_--; 597 num_stubs_descheduled_--;
598 OnScheduled(); 598 OnScheduled();
599 } else { 599 } else {
600 num_stubs_descheduled_++; 600 num_stubs_descheduled_++;
601 } 601 }
602 DCHECK_LE(num_stubs_descheduled_, stubs_.size()); 602 DCHECK_LE(num_stubs_descheduled_, stubs_.size());
603 bool a_stub_is_descheduled = num_stubs_descheduled_ > 0; 603 bool a_stub_is_descheduled = num_stubs_descheduled_ > 0;
604 604
605 if (a_stub_is_descheduled != a_stub_was_descheduled) { 605 if (a_stub_is_descheduled != a_stub_was_descheduled) {
606 if (preempting_flag_) { 606 if (preempting_flag_.get()) {
607 io_message_loop_->PostTask( 607 io_message_loop_->PostTask(
608 FROM_HERE, 608 FROM_HERE,
609 base::Bind(&GpuChannelMessageFilter::UpdateStubSchedulingState, 609 base::Bind(&GpuChannelMessageFilter::UpdateStubSchedulingState,
610 filter_, a_stub_is_descheduled)); 610 filter_,
611 a_stub_is_descheduled));
611 } 612 }
612 } 613 }
613 } 614 }
614 615
615 void GpuChannel::CreateViewCommandBuffer( 616 void GpuChannel::CreateViewCommandBuffer(
616 const gfx::GLSurfaceHandle& window, 617 const gfx::GLSurfaceHandle& window,
617 int32 surface_id, 618 int32 surface_id,
618 const GPUCreateCommandBufferConfig& init_params, 619 const GPUCreateCommandBufferConfig& init_params,
619 int32* route_id) { 620 int32* route_id) {
620 TRACE_EVENT1("gpu", 621 TRACE_EVENT1("gpu",
621 "GpuChannel::CreateViewCommandBuffer", 622 "GpuChannel::CreateViewCommandBuffer",
622 "surface_id", 623 "surface_id",
623 surface_id); 624 surface_id);
624 625
625 *route_id = MSG_ROUTING_NONE; 626 *route_id = MSG_ROUTING_NONE;
626 627
627 #if defined(ENABLE_GPU) 628 #if defined(ENABLE_GPU)
628 629
629 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id); 630 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id);
630 631
631 // Virtualize compositor contexts on OS X to prevent performance regressions 632 // Virtualize compositor contexts on OS X to prevent performance regressions
632 // when enabling FCM. 633 // when enabling FCM.
633 // http://crbug.com/180463 634 // http://crbug.com/180463
634 bool use_virtualized_gl_context = false; 635 bool use_virtualized_gl_context = false;
635 #if defined(OS_MACOSX) 636 #if defined(OS_MACOSX)
636 use_virtualized_gl_context = true; 637 use_virtualized_gl_context = true;
637 #endif 638 #endif
638 639
639 *route_id = GenerateRouteID(); 640 *route_id = GenerateRouteID();
640 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub( 641 scoped_ptr<GpuCommandBufferStub> stub(
641 this, 642 new GpuCommandBufferStub(this,
642 share_group, 643 share_group,
643 window, 644 window,
644 mailbox_manager_, 645 mailbox_manager_.get(),
645 image_manager_, 646 image_manager_.get(),
646 gfx::Size(), 647 gfx::Size(),
647 disallowed_features_, 648 disallowed_features_,
648 init_params.allowed_extensions, 649 init_params.allowed_extensions,
649 init_params.attribs, 650 init_params.attribs,
650 init_params.gpu_preference, 651 init_params.gpu_preference,
651 use_virtualized_gl_context, 652 use_virtualized_gl_context,
652 *route_id, 653 *route_id,
653 surface_id, 654 surface_id,
654 watchdog_, 655 watchdog_,
655 software_, 656 software_,
656 init_params.active_url)); 657 init_params.active_url));
657 if (preempted_flag_) 658 if (preempted_flag_.get())
658 stub->SetPreemptByFlag(preempted_flag_); 659 stub->SetPreemptByFlag(preempted_flag_);
659 router_.AddRoute(*route_id, stub.get()); 660 router_.AddRoute(*route_id, stub.get());
660 stubs_.AddWithID(stub.release(), *route_id); 661 stubs_.AddWithID(stub.release(), *route_id);
661 #endif // ENABLE_GPU 662 #endif // ENABLE_GPU
662 } 663 }
663 664
664 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) { 665 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) {
665 return stubs_.Lookup(route_id); 666 return stubs_.Lookup(route_id);
666 } 667 }
667 668
668 void GpuChannel::CreateImage( 669 void GpuChannel::CreateImage(
669 gfx::PluginWindowHandle window, 670 gfx::PluginWindowHandle window,
670 int32 image_id, 671 int32 image_id,
671 gfx::Size* size) { 672 gfx::Size* size) {
672 TRACE_EVENT1("gpu", 673 TRACE_EVENT1("gpu",
673 "GpuChannel::CreateImage", 674 "GpuChannel::CreateImage",
674 "image_id", 675 "image_id",
675 image_id); 676 image_id);
676 677
677 *size = gfx::Size(); 678 *size = gfx::Size();
678 679
679 if (image_manager_->LookupImage(image_id)) { 680 if (image_manager_->LookupImage(image_id)) {
680 LOG(ERROR) << "CreateImage failed, image_id already in use."; 681 LOG(ERROR) << "CreateImage failed, image_id already in use.";
681 return; 682 return;
682 } 683 }
683 684
684 scoped_refptr<gfx::GLImage> image = gfx::GLImage::CreateGLImage(window); 685 scoped_refptr<gfx::GLImage> image = gfx::GLImage::CreateGLImage(window);
685 if (!image) 686 if (!image.get())
686 return; 687 return;
687 688
688 image_manager_->AddImage(image.get(), image_id); 689 image_manager_->AddImage(image.get(), image_id);
689 *size = image->GetSize(); 690 *size = image->GetSize();
690 } 691 }
691 692
692 void GpuChannel::DeleteImage(int32 image_id) { 693 void GpuChannel::DeleteImage(int32 image_id) {
693 TRACE_EVENT1("gpu", 694 TRACE_EVENT1("gpu",
694 "GpuChannel::DeleteImage", 695 "GpuChannel::DeleteImage",
695 "image_id", 696 "image_id",
(...skipping 18 matching lines...) Expand all
714 715
715 void GpuChannel::AddRoute(int32 route_id, IPC::Listener* listener) { 716 void GpuChannel::AddRoute(int32 route_id, IPC::Listener* listener) {
716 router_.AddRoute(route_id, listener); 717 router_.AddRoute(route_id, listener);
717 } 718 }
718 719
719 void GpuChannel::RemoveRoute(int32 route_id) { 720 void GpuChannel::RemoveRoute(int32 route_id) {
720 router_.RemoveRoute(route_id); 721 router_.RemoveRoute(route_id);
721 } 722 }
722 723
723 gpu::PreemptionFlag* GpuChannel::GetPreemptionFlag() { 724 gpu::PreemptionFlag* GpuChannel::GetPreemptionFlag() {
724 if (!preempting_flag_) { 725 if (!preempting_flag_.get()) {
725 preempting_flag_ = new gpu::PreemptionFlag; 726 preempting_flag_ = new gpu::PreemptionFlag;
726 io_message_loop_->PostTask( 727 io_message_loop_->PostTask(
727 FROM_HERE, base::Bind( 728 FROM_HERE, base::Bind(
728 &GpuChannelMessageFilter::SetPreemptingFlagAndSchedulingState, 729 &GpuChannelMessageFilter::SetPreemptingFlagAndSchedulingState,
729 filter_, preempting_flag_, num_stubs_descheduled_ > 0)); 730 filter_, preempting_flag_, num_stubs_descheduled_ > 0));
730 } 731 }
731 return preempting_flag_.get(); 732 return preempting_flag_.get();
732 } 733 }
733 734
734 void GpuChannel::SetPreemptByFlag( 735 void GpuChannel::SetPreemptByFlag(
735 scoped_refptr<gpu::PreemptionFlag> preempted_flag) { 736 scoped_refptr<gpu::PreemptionFlag> preempted_flag) {
736 preempted_flag_ = preempted_flag; 737 preempted_flag_ = preempted_flag;
737 738
738 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); 739 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
739 !it.IsAtEnd(); it.Advance()) { 740 !it.IsAtEnd(); it.Advance()) {
740 it.GetCurrentValue()->SetPreemptByFlag(preempted_flag_); 741 it.GetCurrentValue()->SetPreemptByFlag(preempted_flag_);
741 } 742 }
742 } 743 }
743 744
744 GpuChannel::~GpuChannel() { 745 GpuChannel::~GpuChannel() {
745 if (preempting_flag_) 746 if (preempting_flag_.get())
746 preempting_flag_->Reset(); 747 preempting_flag_->Reset();
747 } 748 }
748 749
749 void GpuChannel::OnDestroy() { 750 void GpuChannel::OnDestroy() {
750 TRACE_EVENT0("gpu", "GpuChannel::OnDestroy"); 751 TRACE_EVENT0("gpu", "GpuChannel::OnDestroy");
751 gpu_channel_manager_->RemoveChannel(client_id_); 752 gpu_channel_manager_->RemoveChannel(client_id_);
752 } 753 }
753 754
754 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { 755 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
755 bool handled = true; 756 bool handled = true;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 disallowed_features_, 866 disallowed_features_,
866 init_params.allowed_extensions, 867 init_params.allowed_extensions,
867 init_params.attribs, 868 init_params.attribs,
868 init_params.gpu_preference, 869 init_params.gpu_preference,
869 false, 870 false,
870 *route_id, 871 *route_id,
871 0, 872 0,
872 watchdog_, 873 watchdog_,
873 software_, 874 software_,
874 init_params.active_url)); 875 init_params.active_url));
875 if (preempted_flag_) 876 if (preempted_flag_.get())
876 stub->SetPreemptByFlag(preempted_flag_); 877 stub->SetPreemptByFlag(preempted_flag_);
877 router_.AddRoute(*route_id, stub.get()); 878 router_.AddRoute(*route_id, stub.get());
878 stubs_.AddWithID(stub.release(), *route_id); 879 stubs_.AddWithID(stub.release(), *route_id);
879 TRACE_EVENT1("gpu", "GpuChannel::OnCreateOffscreenCommandBuffer", 880 TRACE_EVENT1("gpu", "GpuChannel::OnCreateOffscreenCommandBuffer",
880 "route_id", route_id); 881 "route_id", route_id);
881 } 882 }
882 883
883 void GpuChannel::OnDestroyCommandBuffer(int32 route_id) { 884 void GpuChannel::OnDestroyCommandBuffer(int32 route_id) {
884 TRACE_EVENT1("gpu", "GpuChannel::OnDestroyCommandBuffer", 885 TRACE_EVENT1("gpu", "GpuChannel::OnDestroyCommandBuffer",
885 "route_id", route_id); 886 "route_id", route_id);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 if (it.GetCurrentValue()->surface_id() == surface_id) { 935 if (it.GetCurrentValue()->surface_id() == surface_id) {
935 stats->texture_upload_count += texture_upload_count; 936 stats->texture_upload_count += texture_upload_count;
936 stats->total_texture_upload_time += total_texture_upload_time; 937 stats->total_texture_upload_time += total_texture_upload_time;
937 stats->total_processing_commands_time += total_processing_commands_time; 938 stats->total_processing_commands_time += total_processing_commands_time;
938 } 939 }
939 } 940 }
940 } 941 }
941 942
942 void GpuChannel::MessageProcessed() { 943 void GpuChannel::MessageProcessed() {
943 messages_processed_++; 944 messages_processed_++;
944 if (preempting_flag_) { 945 if (preempting_flag_.get()) {
945 io_message_loop_->PostTask( 946 io_message_loop_->PostTask(
946 FROM_HERE, 947 FROM_HERE,
947 base::Bind(&GpuChannelMessageFilter::MessageProcessed, 948 base::Bind(&GpuChannelMessageFilter::MessageProcessed,
948 filter_, messages_processed_)); 949 filter_,
950 messages_processed_));
949 } 951 }
950 } 952 }
951 953
952 void GpuChannel::CacheShader(const std::string& key, 954 void GpuChannel::CacheShader(const std::string& key,
953 const std::string& shader) { 955 const std::string& shader) {
954 gpu_channel_manager_->Send( 956 gpu_channel_manager_->Send(
955 new GpuHostMsg_CacheShader(client_id_, key, shader)); 957 new GpuHostMsg_CacheShader(client_id_, key, shader));
956 } 958 }
957 959
958 } // namespace content 960 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc ('k') | content/common/gpu/gpu_channel_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698