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

Side by Side Diff: content/browser/gpu/gpu_process_host.cc

Issue 11434072: Send notification from GPU process to browser process of offscreen context creation and destruction… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/common/gpu/gpu_command_buffer_stub.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/gpu/gpu_process_host.h" 5 #include "content/browser/gpu/gpu_process_host.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 500 }
501 501
502 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { 502 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
503 DCHECK(CalledOnValidThread()); 503 DCHECK(CalledOnValidThread());
504 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) 504 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message)
505 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized) 505 IPC_MESSAGE_HANDLER(GpuHostMsg_Initialized, OnInitialized)
506 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) 506 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished)
507 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) 507 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated)
508 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) 508 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer)
509 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated) 509 IPC_MESSAGE_HANDLER(GpuHostMsg_ImageCreated, OnImageCreated)
510 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext,
511 OnDidCreateOffscreenContext)
512 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext)
513 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext,
514 OnDidDestroyOffscreenContext)
510 #if defined(OS_MACOSX) 515 #if defined(OS_MACOSX)
511 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, 516 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
512 OnAcceleratedSurfaceBuffersSwapped) 517 OnAcceleratedSurfaceBuffersSwapped)
513 #endif 518 #endif
514 #if defined(OS_WIN) 519 #if defined(OS_WIN)
515 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, 520 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
516 OnAcceleratedSurfaceBuffersSwapped) 521 OnAcceleratedSurfaceBuffersSwapped)
517 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, 522 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer,
518 OnAcceleratedSurfacePostSubBuffer) 523 OnAcceleratedSurfacePostSubBuffer)
519 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend, 524 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 void GpuProcessHost::OnImageCreated(const gfx::Size size) { 684 void GpuProcessHost::OnImageCreated(const gfx::Size size) {
680 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated"); 685 TRACE_EVENT0("gpu", "GpuProcessHost::OnImageCreated");
681 686
682 if (!create_image_requests_.empty()) { 687 if (!create_image_requests_.empty()) {
683 CreateImageCallback callback = create_image_requests_.front(); 688 CreateImageCallback callback = create_image_requests_.front();
684 create_image_requests_.pop(); 689 create_image_requests_.pop();
685 callback.Run(size); 690 callback.Run(size);
686 } 691 }
687 } 692 }
688 693
694 void GpuProcessHost::OnDidCreateOffscreenContext(
695 const GURL& containing_document_url) {
696 urls_with_live_offscreen_contexts_.insert(containing_document_url);
697 }
698
699 void GpuProcessHost::OnDidLoseContext(bool offscreen,
700 gpu::error::ContextLostReason reason,
701 const GURL& containing_document_url) {
702 // TODO(kbr): would be nice to see the "offscreen" flag too.
703 TRACE_EVENT2("gpu", "GpuProcessHost::OnDidLoseContext",
704 "reason", reason,
705 "containing_document_url",
706 containing_document_url.possibly_invalid_spec());
707
708 if (!offscreen) {
709 // Assume that the loss of the compositor's context is a serious
710 // event and blame the loss on all live offscreen contexts. This
711 // more robustly handles situations where the GPU process may not
712 // actually detect the context loss in the offscreen context.
713 for (std::multiset<GURL>::iterator iter =
714 urls_with_live_offscreen_contexts_.begin();
715 iter != urls_with_live_offscreen_contexts_.end(); ++iter) {
apatrick 2012/12/03 20:35:33 If the GPU process crashes, the GpuProcessHost is
Ken Russell (switch to Gerrit) 2012/12/04 05:11:50 Good point. As it happens, the mechanism I added i
716 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(
apatrick 2012/12/03 20:35:33 I see BlockDomainFrom3DAPIs takes an AutoLock and
Ken Russell (switch to Gerrit) 2012/12/04 05:11:50 Yes, understood, and this is what was intended.
717 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN);
718 }
719 return;
720 }
721
722 GpuDataManagerImpl::DomainGuilt guilt;
723
724 switch (reason) {
725 case gpu::error::kGuilty:
726 guilt = GpuDataManagerImpl::DOMAIN_GUILT_KNOWN;
727 break;
728 case gpu::error::kUnknown:
729 guilt = GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN;
730 break;
731 case gpu::error::kInnocent:
732 return;
733 }
734
735 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(
736 containing_document_url, guilt);
737 }
738
739 void GpuProcessHost::OnDidDestroyOffscreenContext(
740 const GURL& containing_document_url) {
741 urls_with_live_offscreen_contexts_.erase(containing_document_url);
742 }
743
689 #if defined(OS_MACOSX) 744 #if defined(OS_MACOSX)
690 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( 745 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped(
691 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { 746 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
692 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); 747 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped");
693 748
694 gfx::PluginWindowHandle handle = 749 gfx::PluginWindowHandle handle =
695 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); 750 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id);
696 // Compositor window is always gfx::kNullPluginWindow. 751 // Compositor window is always gfx::kNullPluginWindow.
697 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no 752 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no
698 // plugin windows. 753 // plugin windows.
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 const CreateCommandBufferCallback& callback, int32 route_id) { 1037 const CreateCommandBufferCallback& callback, int32 route_id) {
983 callback.Run(route_id); 1038 callback.Run(route_id);
984 } 1039 }
985 1040
986 void GpuProcessHost::CreateImageError( 1041 void GpuProcessHost::CreateImageError(
987 const CreateImageCallback& callback, const gfx::Size size) { 1042 const CreateImageCallback& callback, const gfx::Size size) {
988 callback.Run(size); 1043 callback.Run(size);
989 } 1044 }
990 1045
991 } // namespace content 1046 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/common/gpu/gpu_command_buffer_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698