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

Side by Side Diff: content/browser/renderer_host/image_transport_factory.cc

Issue 9667012: Fix --single-process mode issues with GpuChannelHostFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 #include "content/browser/renderer_host/image_transport_factory.h" 5 #include "content/browser/renderer_host/image_transport_factory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "content/browser/gpu/gpu_surface_tracker.h" 14 #include "content/browser/gpu/gpu_surface_tracker.h"
15 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
15 #include "content/browser/renderer_host/image_transport_client.h" 16 #include "content/browser/renderer_host/image_transport_client.h"
16 #include "content/common/gpu/client/command_buffer_proxy.h" 17 #include "content/common/gpu/client/command_buffer_proxy.h"
17 #include "content/common/gpu/client/gpu_channel_host.h" 18 #include "content/common/gpu/client/gpu_channel_host.h"
18 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 19 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 #include "ui/gfx/compositor/compositor.h" 21 #include "ui/gfx/compositor/compositor.h"
21 #include "ui/gfx/compositor/compositor_setup.h" 22 #include "ui/gfx/compositor/compositor_setup.h"
22 #include "ui/gfx/gl/gl_context.h" 23 #include "ui/gfx/gl/gl_context.h"
23 #include "ui/gfx/gl/gl_surface.h" 24 #include "ui/gfx/gl/gl_surface.h"
24 #include "ui/gfx/gl/scoped_make_current.h" 25 #include "ui/gfx/gl/scoped_make_current.h"
25 #include "ui/gfx/native_widget_types.h" 26 #include "ui/gfx/native_widget_types.h"
26 #include "ui/gfx/size.h" 27 #include "ui/gfx/size.h"
27 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 28 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
28 29
30 using content::BrowserGpuChannelHostFactory;
31
29 namespace { 32 namespace {
30 33
31 ImageTransportFactory* g_factory; 34 ImageTransportFactory* g_factory;
32 35
33 class DefaultTransportFactory 36 class DefaultTransportFactory
34 : public ui::DefaultContextFactory, 37 : public ui::DefaultContextFactory,
35 public ImageTransportFactory { 38 public ImageTransportFactory {
36 public: 39 public:
37 DefaultTransportFactory() { 40 DefaultTransportFactory() {
38 ui::DefaultContextFactory::Initialize(); 41 ui::DefaultContextFactory::Initialize();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 229 }
227 230
228 virtual WebKit::WebGraphicsContext3D* CreateContext( 231 virtual WebKit::WebGraphicsContext3D* CreateContext(
229 ui::Compositor* compositor) OVERRIDE { 232 ui::Compositor* compositor) OVERRIDE {
230 PerCompositorData* data = per_compositor_data_[compositor]; 233 PerCompositorData* data = per_compositor_data_[compositor];
231 if (!data) 234 if (!data)
232 data = CreatePerCompositorData(compositor); 235 data = CreatePerCompositorData(compositor);
233 236
234 WebKit::WebGraphicsContext3D::Attributes attrs; 237 WebKit::WebGraphicsContext3D::Attributes attrs;
235 attrs.shareResources = true; 238 attrs.shareResources = true;
239 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
236 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( 240 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
237 new WebGraphicsContext3DCommandBufferImpl( 241 new WebGraphicsContext3DCommandBufferImpl(
238 data->surface_id, GURL(), data->swap_client->AsWeakPtr())); 242 data->surface_id, GURL(), factory, data->swap_client->AsWeakPtr()));
239 if (!context->Initialize(attrs)) 243 if (!context->Initialize(attrs))
240 return NULL; 244 return NULL;
241 return context.release(); 245 return context.release();
242 } 246 }
243 247
244 virtual void RemoveCompositor(ui::Compositor* compositor) OVERRIDE { 248 virtual void RemoveCompositor(ui::Compositor* compositor) OVERRIDE {
245 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); 249 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor);
246 if (it == per_compositor_data_.end()) 250 if (it == per_compositor_data_.end())
247 return; 251 return;
248 PerCompositorData* data = it->second; 252 PerCompositorData* data = it->second;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 359
356 return data; 360 return data;
357 } 361 }
358 362
359 void CreateSharedContext(ui::Compositor* compositor) { 363 void CreateSharedContext(ui::Compositor* compositor) {
360 PerCompositorData* data = per_compositor_data_[compositor]; 364 PerCompositorData* data = per_compositor_data_[compositor];
361 DCHECK(data); 365 DCHECK(data);
362 366
363 data->swap_client.reset(new CompositorSwapClient(compositor, this)); 367 data->swap_client.reset(new CompositorSwapClient(compositor, this));
364 368
369 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
365 WebKit::WebGraphicsContext3D::Attributes attrs; 370 WebKit::WebGraphicsContext3D::Attributes attrs;
366 attrs.shareResources = true; 371 attrs.shareResources = true;
367 data->shared_context.reset(new WebGraphicsContext3DCommandBufferImpl( 372 data->shared_context.reset(new WebGraphicsContext3DCommandBufferImpl(
368 data->surface_id, GURL(), data->swap_client->AsWeakPtr())); 373 data->surface_id, GURL(), factory, data->swap_client->AsWeakPtr()));
369 if (!data->shared_context->Initialize(attrs)) { 374 if (!data->shared_context->Initialize(attrs)) {
370 // If we can't recreate contexts, we won't be able to show the UI. Better 375 // If we can't recreate contexts, we won't be able to show the UI. Better
371 // crash at this point. 376 // crash at this point.
372 LOG(FATAL) << "Failed to initialize compositor shared context."; 377 LOG(FATAL) << "Failed to initialize compositor shared context.";
373 } 378 }
374 if (!data->shared_context->makeContextCurrent()) { 379 if (!data->shared_context->makeContextCurrent()) {
375 // If we can't recreate contexts, we won't be able to show the UI. Better 380 // If we can't recreate contexts, we won't be able to show the UI. Better
376 // crash at this point. 381 // crash at this point.
377 LOG(FATAL) << "Failed to make compositor shared context current."; 382 LOG(FATAL) << "Failed to make compositor shared context current.";
378 } 383 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 void ImageTransportFactory::Terminate() { 421 void ImageTransportFactory::Terminate() {
417 ui::ContextFactory::SetInstance(NULL); 422 ui::ContextFactory::SetInstance(NULL);
418 delete g_factory; 423 delete g_factory;
419 g_factory = NULL; 424 g_factory = NULL;
420 } 425 }
421 426
422 // static 427 // static
423 ImageTransportFactory* ImageTransportFactory::GetInstance() { 428 ImageTransportFactory* ImageTransportFactory::GetInstance() {
424 return g_factory; 429 return g_factory;
425 } 430 }
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc ('k') | content/common/gpu/client/gpu_channel_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698