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

Side by Side Diff: chrome/browser/gpu_process_host_ui_shim.cc

Issue 6840060: Progress towards fixing 77536 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "" Created 9 years, 8 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 // TODO(jam): move this file to src/content once we have an interface that the 1 // TODO(jam): move this file to src/content once we have an interface that the
2 // embedder provides. We can then use it to get the resource and resize the 2 // embedder provides. We can then use it to get the resource and resize the
3 // window. 3 // window.
4 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style license that can be 5 // Use of this source code is governed by a BSD-style license that can be
6 // found in the LICENSE file. 6 // found in the LICENSE file.
7 7
8 #include "chrome/browser/gpu_process_host_ui_shim.h" 8 #include "chrome/browser/gpu_process_host_ui_shim.h"
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 RouteToGpuProcessHostUIShimTask::~RouteToGpuProcessHostUIShimTask() { 106 RouteToGpuProcessHostUIShimTask::~RouteToGpuProcessHostUIShimTask() {
107 } 107 }
108 108
109 void RouteToGpuProcessHostUIShimTask::Run() { 109 void RouteToGpuProcessHostUIShimTask::Run() {
110 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id_); 110 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id_);
111 if (ui_shim) 111 if (ui_shim)
112 ui_shim->OnMessageReceived(msg_); 112 ui_shim->OnMessageReceived(msg_);
113 } 113 }
114 114
115 class GpuProcessHostUIShim::ViewSurface { 115 #if defined(OS_LINUX)
116 // Used to put a lock on surfaces so that the window to which the GPU
117 // process is drawing to doesn't disappear while it is drawing when
118 // a tab is closed.
119 class GpuProcessHostUIShim::SurfaceRef {
116 public: 120 public:
117 explicit ViewSurface(ViewID view_id); 121 explicit SurfaceRef(gfx::PluginWindowHandle surface);
118 ~ViewSurface(); 122 ~SurfaceRef();
119 gfx::PluginWindowHandle surface() { return surface_; }
120 private: 123 private:
121 RenderWidgetHostView* GetRenderWidgetHostView();
122 ViewID view_id_;
123 gfx::PluginWindowHandle surface_; 124 gfx::PluginWindowHandle surface_;
124 }; 125 };
125 126
126 GpuProcessHostUIShim::ViewSurface::ViewSurface(ViewID view_id) 127 GpuProcessHostUIShim::SurfaceRef::SurfaceRef(gfx::PluginWindowHandle surface)
127 : view_id_(view_id), surface_(gfx::kNullPluginWindow) { 128 : surface_(surface) {
128 RenderWidgetHostView* view = GetRenderWidgetHostView(); 129 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
129 if (view) 130 if (!manager->AddRefPermanentXID(surface_)) {
130 surface_ = view->AcquireCompositingSurface(); 131 LOG(ERROR) << "Surface " << surface << " cannot be referenced.";
132 }
131 } 133 }
132 134
133 GpuProcessHostUIShim::ViewSurface::~ViewSurface() { 135 GpuProcessHostUIShim::SurfaceRef::~SurfaceRef() {
134 if (!surface_) 136 // TODO(backer): ReleasePermanentXID has to be done on the UI thread.
135 return; 137 // Post task to release once we move this code to the IO thread.
136 138 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
137 RenderWidgetHostView* view = GetRenderWidgetHostView(); 139 manager->ReleasePermanentXID(surface_);
138 if (view)
139 view->ReleaseCompositingSurface(surface_);
140 } 140 }
141 141 #endif // defined(OS_LINUX)
142 // We do separate lookups for the RenderWidgetHostView when acquiring
143 // and releasing surfaces (rather than caching) because the
144 // RenderWidgetHostView could die without warning. In such a case,
145 // it's the RenderWidgetHostView's responsibility to cleanup.
146 RenderWidgetHostView* GpuProcessHostUIShim::ViewSurface::
147 GetRenderWidgetHostView() {
148 RenderProcessHost* process = RenderProcessHost::FromID(view_id_.first);
149 RenderWidgetHost* host = NULL;
150 if (process) {
151 host = static_cast<RenderWidgetHost*>(
152 process->GetListenerByID(view_id_.second));
153 }
154
155 RenderWidgetHostView* view = NULL;
156 if (host)
157 view = host->view();
158
159 return view;
160 }
161 142
162 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id, 143 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id,
163 content::CauseForGpuLaunch cause_for_gpu_launch) 144 content::CauseForGpuLaunch cause_for_gpu_launch)
164 : host_id_(host_id), 145 : host_id_(host_id),
165 gpu_process_(base::kNullProcessHandle), 146 gpu_process_(base::kNullProcessHandle),
166 gpu_channel_manager_(NULL), 147 gpu_channel_manager_(NULL),
167 ui_thread_sender_(NULL) { 148 ui_thread_sender_(NULL) {
168 g_hosts_by_id.AddWithID(this, host_id_); 149 g_hosts_by_id.AddWithID(this, host_id_);
169 gpu_data_manager_ = GpuDataManager::GetInstance(); 150 gpu_data_manager_ = GpuDataManager::GetInstance();
170 DCHECK(gpu_data_manager_); 151 DCHECK(gpu_data_manager_);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 linked_ptr<SynchronizeCallback> wrapped_callback(callback); 392 linked_ptr<SynchronizeCallback> wrapped_callback(callback);
412 393
413 if (Send(new GpuMsg_Synchronize())) { 394 if (Send(new GpuMsg_Synchronize())) {
414 synchronize_requests_.push(wrapped_callback); 395 synchronize_requests_.push(wrapped_callback);
415 } else { 396 } else {
416 SynchronizeError(wrapped_callback.release()); 397 SynchronizeError(wrapped_callback.release());
417 } 398 }
418 } 399 }
419 400
420 void GpuProcessHostUIShim::CreateViewCommandBuffer( 401 void GpuProcessHostUIShim::CreateViewCommandBuffer(
402 gfx::PluginWindowHandle compositing_surface,
421 int32 render_view_id, 403 int32 render_view_id,
422 int32 renderer_id, 404 int32 renderer_id,
423 const GPUCreateCommandBufferConfig& init_params, 405 const GPUCreateCommandBufferConfig& init_params,
424 CreateCommandBufferCallback* callback) { 406 CreateCommandBufferCallback* callback) {
425 DCHECK(CalledOnValidThread()); 407 DCHECK(CalledOnValidThread());
426 linked_ptr<CreateCommandBufferCallback> wrapped_callback(callback); 408 linked_ptr<CreateCommandBufferCallback> wrapped_callback(callback);
409
410 #if defined(OS_LINUX)
427 ViewID view_id(renderer_id, render_view_id); 411 ViewID view_id(renderer_id, render_view_id);
428 412
429 // There should only be one such command buffer (for the compositor). In 413 // There should only be one such command buffer (for the compositor). In
430 // practice, if the GPU process lost a context, GraphicsContext3D with 414 // practice, if the GPU process lost a context, GraphicsContext3D with
431 // associated command buffer and view surface will not be gone until new 415 // associated command buffer and view surface will not be gone until new
432 // one is in place and all layers are reattached. 416 // one is in place and all layers are reattached.
433 linked_ptr<ViewSurface> view_surface; 417 linked_ptr<SurfaceRef> surface_ref;
434 ViewSurfaceMap::iterator it = acquired_surfaces_.find(view_id); 418 SurfaceRefMap::iterator it = surface_refs_.find(view_id);
435 if (it != acquired_surfaces_.end()) 419 if (it != surface_refs_.end())
436 view_surface = (*it).second; 420 surface_ref = (*it).second;
437 else 421 else
438 view_surface.reset(new ViewSurface(view_id)); 422 surface_ref.reset(new SurfaceRef(compositing_surface));
423 #endif // defined(OS_LINUX)
439 424
440 if (view_surface->surface() != gfx::kNullPluginWindow && 425 if (compositing_surface != gfx::kNullPluginWindow &&
441 Send(new GpuMsg_CreateViewCommandBuffer( 426 Send(new GpuMsg_CreateViewCommandBuffer(
442 view_surface->surface(), render_view_id, renderer_id, init_params))) { 427 compositing_surface, render_view_id, renderer_id, init_params))) {
443 create_command_buffer_requests_.push(wrapped_callback); 428 create_command_buffer_requests_.push(wrapped_callback);
444 acquired_surfaces_.insert(std::pair<ViewID, linked_ptr<ViewSurface> >( 429 #if defined(OS_LINUX)
445 view_id, view_surface)); 430 surface_refs_.insert(std::pair<ViewID, linked_ptr<SurfaceRef> >(
431 view_id, surface_ref));
432 #endif // defined(OS_LINUX)
446 } else { 433 } else {
447 CreateCommandBufferError(wrapped_callback.release(), MSG_ROUTING_NONE); 434 CreateCommandBufferError(wrapped_callback.release(), MSG_ROUTING_NONE);
448 } 435 }
449 } 436 }
450 437
451 #if defined(OS_MACOSX) 438 #if defined(OS_MACOSX)
452 439
453 void GpuProcessHostUIShim::DidDestroyAcceleratedSurface(int renderer_id, 440 void GpuProcessHostUIShim::DidDestroyAcceleratedSurface(int renderer_id,
454 int render_view_id) { 441 int render_view_id) {
455 // Destroy the command buffer that owns the accelerated surface. 442 // Destroy the command buffer that owns the accelerated surface.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 if (route_id == MSG_ROUTING_NONE) 574 if (route_id == MSG_ROUTING_NONE)
588 CreateCommandBufferError(callback.release(), route_id); 575 CreateCommandBufferError(callback.release(), route_id);
589 else 576 else
590 callback->Run(route_id); 577 callback->Run(route_id);
591 } 578 }
592 } 579 }
593 580
594 void GpuProcessHostUIShim::OnDestroyCommandBuffer( 581 void GpuProcessHostUIShim::OnDestroyCommandBuffer(
595 gfx::PluginWindowHandle window, int32 renderer_id, 582 gfx::PluginWindowHandle window, int32 renderer_id,
596 int32 render_view_id) { 583 int32 render_view_id) {
584 #if defined(OS_LINUX)
597 ViewID view_id(renderer_id, render_view_id); 585 ViewID view_id(renderer_id, render_view_id);
598 ViewSurfaceMap::iterator it = acquired_surfaces_.find(view_id); 586 SurfaceRefMap::iterator it = surface_refs_.find(view_id);
599 if (it != acquired_surfaces_.end()) 587 if (it != surface_refs_.end())
600 acquired_surfaces_.erase(it); 588 surface_refs_.erase(it);
589 #endif // defined(OS_LINUX)
601 } 590 }
602 591
603 void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) { 592 void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) {
604 gpu_data_manager_->UpdateGpuInfo(gpu_info); 593 gpu_data_manager_->UpdateGpuInfo(gpu_info);
605 } 594 }
606 595
607 void GpuProcessHostUIShim::OnLogMessage(int level, 596 void GpuProcessHostUIShim::OnLogMessage(int level,
608 const std::string& header, 597 const std::string& header,
609 const std::string& message) { 598 const std::string& message) {
610 DictionaryValue* dict = new DictionaryValue(); 599 DictionaryValue* dict = new DictionaryValue();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 int render_view_id) { 661 int render_view_id) {
673 RenderViewHost* host = RenderViewHost::FromID(renderer_id, 662 RenderViewHost* host = RenderViewHost::FromID(renderer_id,
674 render_view_id); 663 render_view_id);
675 if (!host) { 664 if (!host) {
676 return; 665 return;
677 } 666 }
678 host->ScheduleComposite(); 667 host->ScheduleComposite();
679 } 668 }
680 669
681 #endif 670 #endif
OLDNEW
« no previous file with comments | « chrome/browser/gpu_process_host_ui_shim.h ('k') | chrome/browser/renderer_host/render_widget_host_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698