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

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

Issue 10828088: aura: use TestWebGraphicsContext3D for the shared contexts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix Created 8 years, 4 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
« no previous file with comments | « no previous file | content/common/webkitplatformsupport_impl.h » ('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/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/browser_gpu_channel_host_factory.h" 14 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
15 #include "content/browser/gpu/gpu_surface_tracker.h" 15 #include "content/browser/gpu/gpu_surface_tracker.h"
16 #include "content/common/gpu/client/gl_helper.h" 16 #include "content/common/gpu/client/gl_helper.h"
17 #include "content/common/gpu/client/gpu_channel_host.h" 17 #include "content/common/gpu/client/gpu_channel_host.h"
18 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 18 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
19 #include "content/common/gpu/gpu_process_launch_causes.h" 19 #include "content/common/gpu/gpu_process_launch_causes.h"
20 #include "content/common/webkitplatformsupport_impl.h"
20 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
21 #include "gpu/ipc/command_buffer_proxy.h" 22 #include "gpu/ipc/command_buffer_proxy.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
23 #include "ui/compositor/compositor.h" 24 #include "ui/compositor/compositor.h"
24 #include "ui/compositor/compositor_setup.h" 25 #include "ui/compositor/compositor_setup.h"
26 #include "ui/compositor/test_web_graphics_context_3d.h"
25 #include "ui/gfx/native_widget_types.h" 27 #include "ui/gfx/native_widget_types.h"
26 #include "ui/gfx/size.h" 28 #include "ui/gfx/size.h"
27 29
28 using content::BrowserGpuChannelHostFactory; 30 using content::BrowserGpuChannelHostFactory;
29 using content::GLHelper; 31 using content::GLHelper;
30 32
31 namespace { 33 namespace {
32 34
33 ImageTransportFactory* g_factory; 35 ImageTransportFactory* g_factory;
34 36
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 ObserverList<ImageTransportFactoryObserver> observer_list_; 369 ObserverList<ImageTransportFactoryObserver> observer_list_;
368 370
369 DISALLOW_COPY_AND_ASSIGN(GpuProcessTransportFactory); 371 DISALLOW_COPY_AND_ASSIGN(GpuProcessTransportFactory);
370 }; 372 };
371 373
372 void CompositorSwapClient::OnLostContext() { 374 void CompositorSwapClient::OnLostContext() {
373 factory_->OnLostContext(compositor_); 375 factory_->OnLostContext(compositor_);
374 // Note: previous line destroyed this. Don't access members from now on. 376 // Note: previous line destroyed this. Don't access members from now on.
375 } 377 }
376 378
379 WebKit::WebGraphicsContext3D* CreateTestContext() {
380 ui::TestWebGraphicsContext3D* test_context =
381 new ui::TestWebGraphicsContext3D();
382 test_context->Initialize();
383 return test_context;
384 }
385
377 } // anonymous namespace 386 } // anonymous namespace
378 387
379 // static 388 // static
380 void ImageTransportFactory::Initialize() { 389 void ImageTransportFactory::Initialize() {
381 CommandLine* command_line = CommandLine::ForCurrentProcess(); 390 CommandLine* command_line = CommandLine::ForCurrentProcess();
382 if (command_line->HasSwitch(switches::kTestCompositor)) { 391 if (command_line->HasSwitch(switches::kTestCompositor)) {
383 ui::SetupTestCompositor(); 392 ui::SetupTestCompositor();
384 } 393 }
385 if (ui::IsTestCompositorEnabled()) { 394 if (ui::IsTestCompositorEnabled()) {
386 g_factory = new DefaultTransportFactory(); 395 g_factory = new DefaultTransportFactory();
396 content::WebKitPlatformSupportImpl::SetOffscreenContextFactoryForTest(
397 CreateTestContext);
387 } else { 398 } else {
388 #if defined(OS_WIN) 399 #if defined(OS_WIN)
389 g_factory = new DefaultTransportFactory(); 400 g_factory = new DefaultTransportFactory();
390 #else 401 #else
391 g_factory = new GpuProcessTransportFactory(); 402 g_factory = new GpuProcessTransportFactory();
392 #endif 403 #endif
393 } 404 }
394 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); 405 ui::ContextFactory::SetInstance(g_factory->AsContextFactory());
395 } 406 }
396 407
397 // static 408 // static
398 void ImageTransportFactory::Terminate() { 409 void ImageTransportFactory::Terminate() {
399 ui::ContextFactory::SetInstance(NULL); 410 ui::ContextFactory::SetInstance(NULL);
400 delete g_factory; 411 delete g_factory;
401 g_factory = NULL; 412 g_factory = NULL;
402 } 413 }
403 414
404 // static 415 // static
405 ImageTransportFactory* ImageTransportFactory::GetInstance() { 416 ImageTransportFactory* ImageTransportFactory::GetInstance() {
406 return g_factory; 417 return g_factory;
407 } 418 }
OLDNEW
« no previous file with comments | « no previous file | content/common/webkitplatformsupport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698