| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/examples/aura_demo/demo_context_factory.h" | 5 #include "mojo/examples/aura_demo/demo_context_factory.h" |
| 6 | 6 |
| 7 #include "cc/output/output_surface.h" | 7 #include "cc/output/output_surface.h" |
| 8 #include "mojo/examples/aura_demo/window_tree_host_mojo.h" | 8 #include "mojo/examples/aura_demo/window_tree_host_mojo.h" |
| 9 #include "mojo/examples/compositor_app/mojo_context_provider.h" | 9 #include "mojo/examples/compositor_app/mojo_context_provider.h" |
| 10 #include "ui/compositor/reflector.h" | 10 #include "ui/compositor/reflector.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 scoped_refptr<cc::ContextProvider> | 51 scoped_refptr<cc::ContextProvider> |
| 52 DemoContextFactory::OffscreenCompositorContextProvider() { | 52 DemoContextFactory::OffscreenCompositorContextProvider() { |
| 53 if (!offscreen_compositor_contexts_.get() || | 53 if (!offscreen_compositor_contexts_.get() || |
| 54 offscreen_compositor_contexts_->DestroyedOnMainThread()) { | 54 offscreen_compositor_contexts_->DestroyedOnMainThread()) { |
| 55 // If the compositor was initialized with its own thread then we would need | 55 // If the compositor was initialized with its own thread then we would need |
| 56 // to leak the context provider when we shutdown to avoid destroying the | 56 // to leak the context provider when we shutdown to avoid destroying the |
| 57 // contexts on the wrong thread. | 57 // contexts on the wrong thread. |
| 58 DCHECK(!ui::Compositor::WasInitializedWithThread()); | 58 DCHECK(!ui::Compositor::WasInitializedWithThread()); |
| 59 bool lose_context_when_out_of_memory = true; |
| 59 offscreen_compositor_contexts_ = | 60 offscreen_compositor_contexts_ = |
| 60 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); | 61 webkit::gpu::ContextProviderInProcess::CreateOffscreen( |
| 62 lose_context_when_out_of_memory); |
| 61 } | 63 } |
| 62 return offscreen_compositor_contexts_; | 64 return offscreen_compositor_contexts_; |
| 63 } | 65 } |
| 64 | 66 |
| 65 scoped_refptr<cc::ContextProvider> | 67 scoped_refptr<cc::ContextProvider> |
| 66 DemoContextFactory::SharedMainThreadContextProvider() { | 68 DemoContextFactory::SharedMainThreadContextProvider() { |
| 67 if (!shared_main_thread_contexts_ || | 69 if (!shared_main_thread_contexts_ || |
| 68 shared_main_thread_contexts_->DestroyedOnMainThread()) { | 70 shared_main_thread_contexts_->DestroyedOnMainThread()) { |
| 71 bool lose_context_when_out_of_memory = false; |
| 69 shared_main_thread_contexts_ = | 72 shared_main_thread_contexts_ = |
| 70 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); | 73 webkit::gpu::ContextProviderInProcess::CreateOffscreen( |
| 74 lose_context_when_out_of_memory); |
| 71 if (shared_main_thread_contexts_ && | 75 if (shared_main_thread_contexts_ && |
| 72 !shared_main_thread_contexts_->BindToCurrentThread()) | 76 !shared_main_thread_contexts_->BindToCurrentThread()) |
| 73 shared_main_thread_contexts_ = NULL; | 77 shared_main_thread_contexts_ = NULL; |
| 74 } | 78 } |
| 75 return shared_main_thread_contexts_; | 79 return shared_main_thread_contexts_; |
| 76 } | 80 } |
| 77 | 81 |
| 78 void DemoContextFactory::RemoveCompositor(ui::Compositor* compositor) { | 82 void DemoContextFactory::RemoveCompositor(ui::Compositor* compositor) { |
| 79 } | 83 } |
| 80 | 84 |
| 81 bool DemoContextFactory::DoesCreateTestContexts() { return false; } | 85 bool DemoContextFactory::DoesCreateTestContexts() { return false; } |
| 82 | 86 |
| 83 } // namespace examples | 87 } // namespace examples |
| 84 } // namespace mojo | 88 } // namespace mojo |
| 85 | 89 |
| OLD | NEW |