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

Side by Side Diff: content/browser/aura/gpu_process_transport_factory.cc

Issue 111063003: Aura: Don't create GL context for CreateSharedSurfaceHandle() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/aura/gpu_process_transport_factory.h" 5 #include "content/browser/aura/gpu_process_transport_factory.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "cc/output/compositor_frame.h" 14 #include "cc/output/compositor_frame.h"
15 #include "cc/output/output_surface.h" 15 #include "cc/output/output_surface.h"
16 #include "content/browser/aura/browser_compositor_output_surface.h" 16 #include "content/browser/aura/browser_compositor_output_surface.h"
17 #include "content/browser/aura/browser_compositor_output_surface_proxy.h" 17 #include "content/browser/aura/browser_compositor_output_surface_proxy.h"
18 #include "content/browser/aura/gpu_browser_compositor_output_surface.h" 18 #include "content/browser/aura/gpu_browser_compositor_output_surface.h"
19 #include "content/browser/aura/reflector_impl.h" 19 #include "content/browser/aura/reflector_impl.h"
20 #include "content/browser/aura/software_browser_compositor_output_surface.h" 20 #include "content/browser/aura/software_browser_compositor_output_surface.h"
21 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 21 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
22 #include "content/browser/gpu/gpu_data_manager_impl.h" 22 #include "content/browser/gpu/gpu_data_manager_impl.h"
23 #include "content/browser/gpu/gpu_surface_tracker.h" 23 #include "content/browser/gpu/gpu_surface_tracker.h"
24 #include "content/browser/renderer_host/render_widget_host_impl.h" 24 #include "content/browser/renderer_host/render_widget_host_impl.h"
25 #include "content/common/gpu/client/context_provider_command_buffer.h" 25 #include "content/common/gpu/client/context_provider_command_buffer.h"
26 #include "content/common/gpu/client/gl_helper.h" 26 #include "content/common/gpu/client/gl_helper.h"
27 #include "content/common/gpu/client/gpu_channel_host.h" 27 #include "content/common/gpu/client/gpu_channel_host.h"
28 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 28 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
29 #include "content/common/gpu/gpu_process_launch_causes.h" 29 #include "content/common/gpu/gpu_process_launch_causes.h"
30 #include "content/public/browser/render_process_host.h"
30 #include "gpu/GLES2/gl2extchromium.h" 31 #include "gpu/GLES2/gl2extchromium.h"
31 #include "third_party/khronos/GLES2/gl2.h" 32 #include "third_party/khronos/GLES2/gl2.h"
32 #include "ui/compositor/compositor.h" 33 #include "ui/compositor/compositor.h"
33 #include "ui/compositor/compositor_switches.h" 34 #include "ui/compositor/compositor_switches.h"
34 #include "ui/gfx/native_widget_types.h" 35 #include "ui/gfx/native_widget_types.h"
35 #include "ui/gfx/size.h" 36 #include "ui/gfx/size.h"
36 37
37 #if defined(OS_WIN) 38 #if defined(OS_WIN)
38 #include "content/browser/aura/software_output_device_win.h" 39 #include "content/browser/aura/software_output_device_win.h"
39 #include "ui/surface/accelerated_surface_win.h" 40 #include "ui/surface/accelerated_surface_win.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 141
141 private: 142 private:
142 std::string mailbox_name_; 143 std::string mailbox_name_;
143 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); 144 DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture);
144 }; 145 };
145 146
146 GpuProcessTransportFactory::GpuProcessTransportFactory() 147 GpuProcessTransportFactory::GpuProcessTransportFactory()
147 : callback_factory_(this) { 148 : callback_factory_(this) {
148 output_surface_proxy_ = new BrowserCompositorOutputSurfaceProxy( 149 output_surface_proxy_ = new BrowserCompositorOutputSurfaceProxy(
149 &output_surface_map_); 150 &output_surface_map_);
151 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) {
152 CauseForGpuLaunch cause = CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP;
153 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
154 cause,
155 base::Bind(&GpuProcessTransportFactory::OnGpuChannelReady,
156 callback_factory_.GetWeakPtr()));
157 }
150 } 158 }
151 159
152 GpuProcessTransportFactory::~GpuProcessTransportFactory() { 160 GpuProcessTransportFactory::~GpuProcessTransportFactory() {
153 DCHECK(per_compositor_data_.empty()); 161 DCHECK(per_compositor_data_.empty());
154 162
155 // Make sure the lost context callback doesn't try to run during destruction. 163 // Make sure the lost context callback doesn't try to run during destruction.
156 callback_factory_.InvalidateWeakPtrs(); 164 callback_factory_.InvalidateWeakPtrs();
157 } 165 }
158 166
159 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 167 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 gl_helper_.reset(); 286 gl_helper_.reset();
279 } 287 }
280 288
281 bool GpuProcessTransportFactory::DoesCreateTestContexts() { return false; } 289 bool GpuProcessTransportFactory::DoesCreateTestContexts() { return false; }
282 290
283 ui::ContextFactory* GpuProcessTransportFactory::AsContextFactory() { 291 ui::ContextFactory* GpuProcessTransportFactory::AsContextFactory() {
284 return this; 292 return this;
285 } 293 }
286 294
287 gfx::GLSurfaceHandle GpuProcessTransportFactory::CreateSharedSurfaceHandle() { 295 gfx::GLSurfaceHandle GpuProcessTransportFactory::CreateSharedSurfaceHandle() {
288 scoped_refptr<cc::ContextProvider> provider = 296 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor())
piman 2013/12/11 01:14:03 In the rest of the patch, we're essentially assumi
no sievers 2013/12/11 01:49:24 I think on windows with SwiftShader it's possible
289 SharedMainThreadContextProvider();
290 if (!provider.get())
291 return gfx::GLSurfaceHandle(); 297 return gfx::GLSurfaceHandle();
292 typedef WebGraphicsContext3DCommandBufferImpl WGC3DCBI; 298
293 WGC3DCBI* context = static_cast<WGC3DCBI*>(provider->Context3d());
294 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( 299 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle(
295 gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT); 300 gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT);
296 handle.parent_gpu_process_id = context->GetGPUProcessID();
297 handle.parent_client_id = 301 handle.parent_client_id =
298 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId(); 302 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId();
299 return handle; 303 return handle;
300 } 304 }
301 305
302 void GpuProcessTransportFactory::DestroySharedSurfaceHandle( 306 void GpuProcessTransportFactory::DestroySharedSurfaceHandle(
303 gfx::GLSurfaceHandle surface) {} 307 gfx::GLSurfaceHandle surface) {}
304 308
305 scoped_refptr<ui::Texture> GpuProcessTransportFactory::CreateTransportClient( 309 scoped_refptr<ui::Texture> GpuProcessTransportFactory::CreateTransportClient(
306 float device_scale_factor) { 310 float device_scale_factor) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 shared_main_thread_contexts_; 490 shared_main_thread_contexts_;
487 offscreen_compositor_contexts_ = NULL; 491 offscreen_compositor_contexts_ = NULL;
488 shared_main_thread_contexts_ = NULL; 492 shared_main_thread_contexts_ = NULL;
489 493
490 scoped_ptr<GLHelper> lost_gl_helper = gl_helper_.Pass(); 494 scoped_ptr<GLHelper> lost_gl_helper = gl_helper_.Pass();
491 495
492 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, 496 FOR_EACH_OBSERVER(ImageTransportFactoryObserver,
493 observer_list_, 497 observer_list_,
494 OnLostResources()); 498 OnLostResources());
495 499
500 // This needs to happen after we notified the observers, because until then
501 // we want to block renderers' CreateViewCommandBuffer requests.
502 CauseForGpuLaunch cause =
503 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
504 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
505 cause,
506 base::Bind(&GpuProcessTransportFactory::OnGpuChannelReady,
507 callback_factory_.GetWeakPtr()));
508
496 // Kill things that use the shared context before killing the shared context. 509 // Kill things that use the shared context before killing the shared context.
497 lost_gl_helper.reset(); 510 lost_gl_helper.reset();
498 lost_offscreen_compositor_contexts = NULL; 511 lost_offscreen_compositor_contexts = NULL;
499 lost_shared_main_thread_contexts = NULL; 512 lost_shared_main_thread_contexts = NULL;
500 } 513 }
501 514
515 void GpuProcessTransportFactory::OnGpuChannelReady() {
piman 2013/12/11 01:14:03 nit: this could be static, so you wouldn't need we
516 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
517 !i.IsAtEnd();
518 i.Advance()) {
519 i.GetCurrentValue()->OnParentGpuChannelEstablished();
520 }
521 }
522
502 } // namespace content 523 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698