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 "ui/compositor/test/in_process_context_factory.h" | 5 #include "ui/compositor/test/in_process_context_factory.h" |
6 | 6 |
7 #include "cc/output/output_surface.h" | 7 #include "cc/output/output_surface.h" |
8 #include "ui/compositor/reflector.h" | 8 #include "ui/compositor/reflector.h" |
9 #include "ui/gl/gl_implementation.h" | 9 #include "ui/gl/gl_implementation.h" |
10 #include "ui/gl/gl_surface.h" | 10 #include "ui/gl/gl_surface.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector( | 47 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector( |
48 Compositor* mirroed_compositor, | 48 Compositor* mirroed_compositor, |
49 Layer* mirroring_layer) { | 49 Layer* mirroring_layer) { |
50 return new Reflector(); | 50 return new Reflector(); |
51 } | 51 } |
52 | 52 |
53 void InProcessContextFactory::RemoveReflector( | 53 void InProcessContextFactory::RemoveReflector( |
54 scoped_refptr<Reflector> reflector) {} | 54 scoped_refptr<Reflector> reflector) {} |
55 | 55 |
56 scoped_refptr<cc::ContextProvider> | 56 scoped_refptr<cc::ContextProvider> |
57 InProcessContextFactory::OffscreenCompositorContextProvider() { | |
58 if (!offscreen_compositor_contexts_.get() || | |
59 !offscreen_compositor_contexts_->DestroyedOnMainThread()) { | |
60 bool lose_context_when_out_of_memory = true; | |
61 offscreen_compositor_contexts_ = | |
62 webkit::gpu::ContextProviderInProcess::CreateOffscreen( | |
63 lose_context_when_out_of_memory); | |
64 } | |
65 return offscreen_compositor_contexts_; | |
66 } | |
67 | |
68 scoped_refptr<cc::ContextProvider> | |
69 InProcessContextFactory::SharedMainThreadContextProvider() { | 57 InProcessContextFactory::SharedMainThreadContextProvider() { |
70 if (shared_main_thread_contexts_ && | 58 if (shared_main_thread_contexts_ && |
71 !shared_main_thread_contexts_->DestroyedOnMainThread()) | 59 !shared_main_thread_contexts_->DestroyedOnMainThread()) |
72 return shared_main_thread_contexts_; | 60 return shared_main_thread_contexts_; |
73 | 61 |
74 if (ui::Compositor::WasInitializedWithThread()) { | 62 bool lose_context_when_out_of_memory = false; |
75 bool lose_context_when_out_of_memory = false; | 63 shared_main_thread_contexts_ = |
76 shared_main_thread_contexts_ = | 64 webkit::gpu::ContextProviderInProcess::CreateOffscreen( |
77 webkit::gpu::ContextProviderInProcess::CreateOffscreen( | 65 lose_context_when_out_of_memory); |
78 lose_context_when_out_of_memory); | |
79 } else { | |
80 shared_main_thread_contexts_ = | |
81 static_cast<webkit::gpu::ContextProviderInProcess*>( | |
82 OffscreenCompositorContextProvider().get()); | |
83 } | |
84 if (shared_main_thread_contexts_ && | 66 if (shared_main_thread_contexts_ && |
85 !shared_main_thread_contexts_->BindToCurrentThread()) | 67 !shared_main_thread_contexts_->BindToCurrentThread()) |
86 shared_main_thread_contexts_ = NULL; | 68 shared_main_thread_contexts_ = NULL; |
87 | 69 |
88 return shared_main_thread_contexts_; | 70 return shared_main_thread_contexts_; |
89 } | 71 } |
90 | 72 |
91 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} | 73 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} |
92 | 74 |
93 bool InProcessContextFactory::DoesCreateTestContexts() { return false; } | 75 bool InProcessContextFactory::DoesCreateTestContexts() { return false; } |
94 | 76 |
95 } // namespace ui | 77 } // namespace ui |
OLD | NEW |