OLD | NEW |
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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ui/compositor/compositor.h" | 25 #include "ui/compositor/compositor.h" |
26 #include "ui/compositor/compositor_setup.h" | 26 #include "ui/compositor/compositor_setup.h" |
27 #include "ui/compositor/test_web_graphics_context_3d.h" | 27 #include "ui/compositor/test_web_graphics_context_3d.h" |
28 #include "ui/gfx/native_widget_types.h" | 28 #include "ui/gfx/native_widget_types.h" |
29 #include "ui/gfx/size.h" | 29 #include "ui/gfx/size.h" |
30 | 30 |
31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
32 #include "ui/surface/accelerated_surface_win.h" | 32 #include "ui/surface/accelerated_surface_win.h" |
33 #endif | 33 #endif |
34 | 34 |
35 using content::BrowserGpuChannelHostFactory; | 35 namespace content { |
36 using content::GLHelper; | |
37 using content::GpuChannelHostFactory; | |
38 using content::GpuDataManagerImpl; | |
39 using content::GpuSurfaceTracker; | |
40 using content::WebGraphicsContext3DCommandBufferImpl; | |
41 using content::WebGraphicsContext3DSwapBuffersClient; | |
42 | |
43 namespace { | 36 namespace { |
44 | 37 |
45 ImageTransportFactory* g_factory; | 38 ImageTransportFactory* g_factory; |
46 | 39 |
47 class DefaultTransportFactory | 40 class DefaultTransportFactory |
48 : public ui::DefaultContextFactory, | 41 : public ui::DefaultContextFactory, |
49 public ImageTransportFactory { | 42 public ImageTransportFactory { |
50 public: | 43 public: |
51 DefaultTransportFactory() { | 44 DefaultTransportFactory() { |
52 ui::DefaultContextFactory::Initialize(); | 45 ui::DefaultContextFactory::Initialize(); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); | 414 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); |
422 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 415 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
423 new WebGraphicsContext3DCommandBufferImpl( | 416 new WebGraphicsContext3DCommandBufferImpl( |
424 surface_id, | 417 surface_id, |
425 url, | 418 url, |
426 factory, | 419 factory, |
427 swap_client)); | 420 swap_client)); |
428 if (!context->Initialize( | 421 if (!context->Initialize( |
429 attrs, | 422 attrs, |
430 false, | 423 false, |
431 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INIT
IALIZE)) | 424 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) |
432 return NULL; | 425 return NULL; |
433 return context.release(); | 426 return context.release(); |
434 } | 427 } |
435 | 428 |
436 void CreateSharedContextLazy() { | 429 void CreateSharedContextLazy() { |
437 if (shared_context_.get()) | 430 if (shared_context_.get()) |
438 return; | 431 return; |
439 | 432 |
440 shared_context_.reset(CreateOffscreenContext()); | 433 shared_context_.reset(CreateOffscreenContext()); |
441 if (!shared_context_.get()) { | 434 if (!shared_context_.get()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 } // anonymous namespace | 481 } // anonymous namespace |
489 | 482 |
490 // static | 483 // static |
491 void ImageTransportFactory::Initialize() { | 484 void ImageTransportFactory::Initialize() { |
492 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 485 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
493 if (command_line->HasSwitch(switches::kTestCompositor)) { | 486 if (command_line->HasSwitch(switches::kTestCompositor)) { |
494 ui::SetupTestCompositor(); | 487 ui::SetupTestCompositor(); |
495 } | 488 } |
496 if (ui::IsTestCompositorEnabled()) { | 489 if (ui::IsTestCompositorEnabled()) { |
497 g_factory = new DefaultTransportFactory(); | 490 g_factory = new DefaultTransportFactory(); |
498 content::WebKitPlatformSupportImpl::SetOffscreenContextFactoryForTest( | 491 WebKitPlatformSupportImpl::SetOffscreenContextFactoryForTest( |
499 CreateTestContext); | 492 CreateTestContext); |
500 } else { | 493 } else { |
501 g_factory = new GpuProcessTransportFactory(); | 494 g_factory = new GpuProcessTransportFactory(); |
502 } | 495 } |
503 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); | 496 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); |
504 } | 497 } |
505 | 498 |
506 // static | 499 // static |
507 void ImageTransportFactory::Terminate() { | 500 void ImageTransportFactory::Terminate() { |
508 ui::ContextFactory::SetInstance(NULL); | 501 ui::ContextFactory::SetInstance(NULL); |
509 delete g_factory; | 502 delete g_factory; |
510 g_factory = NULL; | 503 g_factory = NULL; |
511 } | 504 } |
512 | 505 |
513 // static | 506 // static |
514 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 507 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
515 return g_factory; | 508 return g_factory; |
516 } | 509 } |
| 510 |
| 511 } // namespace content |
OLD | NEW |