| 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 "ui/compositor/compositor.h" | 5 #include "ui/compositor/compositor.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 g_context_factory = instance; | 134 g_context_factory = instance; |
| 135 } | 135 } |
| 136 | 136 |
| 137 DefaultContextFactory::DefaultContextFactory() { | 137 DefaultContextFactory::DefaultContextFactory() { |
| 138 } | 138 } |
| 139 | 139 |
| 140 DefaultContextFactory::~DefaultContextFactory() { | 140 DefaultContextFactory::~DefaultContextFactory() { |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool DefaultContextFactory::Initialize() { | 143 bool DefaultContextFactory::Initialize() { |
| 144 if (g_test_compositor_enabled) |
| 145 return true; |
| 146 |
| 144 // The following line of code exists soley to disable IO restrictions | 147 // The following line of code exists soley to disable IO restrictions |
| 145 // on this thread long enough to perform the GL bindings. | 148 // on this thread long enough to perform the GL bindings. |
| 146 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. | 149 // TODO(wjmaclean) Remove this when GL initialisation cleaned up. |
| 147 base::ThreadRestrictions::ScopedAllowIO allow_io; | 150 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 148 if (!gfx::GLSurface::InitializeOneOff() || | 151 if (!gfx::GLSurface::InitializeOneOff() || |
| 149 gfx::GetGLImplementation() == gfx::kGLImplementationNone) { | 152 gfx::GetGLImplementation() == gfx::kGLImplementationNone) { |
| 150 LOG(ERROR) << "Could not load the GL bindings"; | 153 LOG(ERROR) << "Could not load the GL bindings"; |
| 151 return false; | 154 return false; |
| 152 } | 155 } |
| 153 return true; | 156 return true; |
| 154 } | 157 } |
| 155 | 158 |
| 156 cc::OutputSurface* DefaultContextFactory::CreateOutputSurface( | 159 cc::OutputSurface* DefaultContextFactory::CreateOutputSurface( |
| 157 Compositor* compositor) { | 160 Compositor* compositor) { |
| 158 return new WebGraphicsContextToOutputSurfaceAdapter( | 161 return new WebGraphicsContextToOutputSurfaceAdapter( |
| 159 CreateContextCommon(compositor, false)); | 162 CreateContextCommon(compositor, false)); |
| 160 } | 163 } |
| 161 | 164 |
| 162 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() { | 165 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() { |
| 163 return CreateContextCommon(NULL, true); | 166 return CreateContextCommon(NULL, true); |
| 164 } | 167 } |
| 165 | 168 |
| 169 WebKit::WebGraphicsContext3D* DefaultContextFactory:: |
| 170 OffscreenContextForMainThread() { |
| 171 if (!test_offscreen_context_main_thread_) { |
| 172 scoped_ptr<ui::TestWebGraphicsContext3D> test_context( |
| 173 new ui::TestWebGraphicsContext3D()); |
| 174 test_context->Initialize(); |
| 175 test_offscreen_context_main_thread_ = |
| 176 test_context.PassAs<WebKit::WebGraphicsContext3D>(); |
| 177 } |
| 178 return test_offscreen_context_main_thread_.get(); |
| 179 } |
| 180 |
| 181 WebKit::WebGraphicsContext3D* DefaultContextFactory:: |
| 182 OffscreenContextForCompositorThread() { |
| 183 if (!test_offscreen_context_compositor_thread_) { |
| 184 scoped_ptr<ui::TestWebGraphicsContext3D> test_context( |
| 185 new ui::TestWebGraphicsContext3D()); |
| 186 test_context->Initialize(); |
| 187 test_offscreen_context_compositor_thread_ = |
| 188 test_context.PassAs<WebKit::WebGraphicsContext3D>(); |
| 189 } |
| 190 return test_offscreen_context_compositor_thread_.get(); |
| 191 } |
| 192 |
| 166 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { | 193 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { |
| 167 } | 194 } |
| 168 | 195 |
| 169 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateContextCommon( | 196 WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateContextCommon( |
| 170 Compositor* compositor, | 197 Compositor* compositor, |
| 171 bool offscreen) { | 198 bool offscreen) { |
| 172 DCHECK(offscreen || compositor); | 199 DCHECK(offscreen || compositor); |
| 173 WebKit::WebGraphicsContext3D::Attributes attrs; | 200 WebKit::WebGraphicsContext3D::Attributes attrs; |
| 174 attrs.depth = false; | 201 attrs.depth = false; |
| 175 attrs.stencil = false; | 202 attrs.stencil = false; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 new WebGraphicsContextToOutputSurfaceAdapter(test_context)); | 541 new WebGraphicsContextToOutputSurfaceAdapter(test_context)); |
| 515 } else { | 542 } else { |
| 516 return scoped_ptr<cc::OutputSurface>( | 543 return scoped_ptr<cc::OutputSurface>( |
| 517 ContextFactory::GetInstance()->CreateOutputSurface(this)); | 544 ContextFactory::GetInstance()->CreateOutputSurface(this)); |
| 518 } | 545 } |
| 519 } | 546 } |
| 520 | 547 |
| 521 void Compositor::didRecreateOutputSurface(bool success) { | 548 void Compositor::didRecreateOutputSurface(bool success) { |
| 522 } | 549 } |
| 523 | 550 |
| 551 WebKit::WebGraphicsContext3D* |
| 552 Compositor::OffscreenContext3dForMainThread() { |
| 553 return ContextFactory::GetInstance()->OffscreenContextForMainThread(); |
| 554 } |
| 555 |
| 556 WebKit::WebGraphicsContext3D* |
| 557 Compositor::OffscreenContext3dForCompositorThread() { |
| 558 return ContextFactory::GetInstance()->OffscreenContextForCompositorThread(); |
| 559 } |
| 560 |
| 524 scoped_ptr<cc::InputHandler> Compositor::createInputHandler() { | 561 scoped_ptr<cc::InputHandler> Compositor::createInputHandler() { |
| 525 return scoped_ptr<cc::InputHandler>(); | 562 return scoped_ptr<cc::InputHandler>(); |
| 526 } | 563 } |
| 527 | 564 |
| 528 void Compositor::willCommit() { | 565 void Compositor::willCommit() { |
| 529 } | 566 } |
| 530 | 567 |
| 531 void Compositor::didCommit() { | 568 void Compositor::didCommit() { |
| 532 DCHECK(!IsLocked()); | 569 DCHECK(!IsLocked()); |
| 533 FOR_EACH_OBSERVER(CompositorObserver, | 570 FOR_EACH_OBSERVER(CompositorObserver, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 | 641 |
| 605 COMPOSITOR_EXPORT void DisableTestCompositor() { | 642 COMPOSITOR_EXPORT void DisableTestCompositor() { |
| 606 g_test_compositor_enabled = false; | 643 g_test_compositor_enabled = false; |
| 607 } | 644 } |
| 608 | 645 |
| 609 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { | 646 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { |
| 610 return g_test_compositor_enabled; | 647 return g_test_compositor_enabled; |
| 611 } | 648 } |
| 612 | 649 |
| 613 } // namespace ui | 650 } // namespace ui |
| OLD | NEW |