| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 ui::Compositor* mirroed_compositor, | 42 ui::Compositor* mirroed_compositor, |
| 43 ui::Layer* mirroring_layer) { | 43 ui::Layer* mirroring_layer) { |
| 44 return NULL; | 44 return NULL; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void DemoContextFactory::RemoveReflector( | 47 void DemoContextFactory::RemoveReflector( |
| 48 scoped_refptr<ui::Reflector> reflector) { | 48 scoped_refptr<ui::Reflector> reflector) { |
| 49 } | 49 } |
| 50 | 50 |
| 51 scoped_refptr<cc::ContextProvider> | 51 scoped_refptr<cc::ContextProvider> |
| 52 DemoContextFactory::OffscreenCompositorContextProvider() { | |
| 53 if (!offscreen_compositor_contexts_.get() || | |
| 54 offscreen_compositor_contexts_->DestroyedOnMainThread()) { | |
| 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 | |
| 57 // contexts on the wrong thread. | |
| 58 DCHECK(!ui::Compositor::WasInitializedWithThread()); | |
| 59 bool lose_context_when_out_of_memory = true; | |
| 60 offscreen_compositor_contexts_ = | |
| 61 webkit::gpu::ContextProviderInProcess::CreateOffscreen( | |
| 62 lose_context_when_out_of_memory); | |
| 63 } | |
| 64 return offscreen_compositor_contexts_; | |
| 65 } | |
| 66 | |
| 67 scoped_refptr<cc::ContextProvider> | |
| 68 DemoContextFactory::SharedMainThreadContextProvider() { | 52 DemoContextFactory::SharedMainThreadContextProvider() { |
| 69 if (!shared_main_thread_contexts_ || | 53 if (!shared_main_thread_contexts_ || |
| 70 shared_main_thread_contexts_->DestroyedOnMainThread()) { | 54 shared_main_thread_contexts_->DestroyedOnMainThread()) { |
| 71 bool lose_context_when_out_of_memory = false; | 55 bool lose_context_when_out_of_memory = false; |
| 72 shared_main_thread_contexts_ = | 56 shared_main_thread_contexts_ = |
| 73 webkit::gpu::ContextProviderInProcess::CreateOffscreen( | 57 webkit::gpu::ContextProviderInProcess::CreateOffscreen( |
| 74 lose_context_when_out_of_memory); | 58 lose_context_when_out_of_memory); |
| 75 if (shared_main_thread_contexts_ && | 59 if (shared_main_thread_contexts_ && |
| 76 !shared_main_thread_contexts_->BindToCurrentThread()) | 60 !shared_main_thread_contexts_->BindToCurrentThread()) |
| 77 shared_main_thread_contexts_ = NULL; | 61 shared_main_thread_contexts_ = NULL; |
| 78 } | 62 } |
| 79 return shared_main_thread_contexts_; | 63 return shared_main_thread_contexts_; |
| 80 } | 64 } |
| 81 | 65 |
| 82 void DemoContextFactory::RemoveCompositor(ui::Compositor* compositor) { | 66 void DemoContextFactory::RemoveCompositor(ui::Compositor* compositor) { |
| 83 } | 67 } |
| 84 | 68 |
| 85 bool DemoContextFactory::DoesCreateTestContexts() { return false; } | 69 bool DemoContextFactory::DoesCreateTestContexts() { return false; } |
| 86 | 70 |
| 87 } // namespace examples | 71 } // namespace examples |
| 88 } // namespace mojo | 72 } // namespace mojo |
| 89 | 73 |
| OLD | NEW |