OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/compositor/test/test_context_factory.h" | |
6 | |
7 #include "cc/output/output_surface.h" | |
8 #include "cc/test/test_context_provider.h" | |
9 #include "ui/compositor/reflector.h" | |
10 | |
11 namespace ui { | |
12 | |
13 TestContextFactory::TestContextFactory() {} | |
14 | |
15 TestContextFactory::~TestContextFactory() {} | |
16 | |
17 scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface( | |
18 Compositor* compositor, bool software_fallback) { | |
19 DCHECK(!software_fallback); | |
20 return make_scoped_ptr( | |
21 new cc::OutputSurface(cc::TestContextProvider::Create())); | |
22 } | |
23 | |
24 scoped_refptr<Reflector> TestContextFactory::CreateReflector( | |
25 Compositor* mirrored_compositor, | |
26 Layer* mirroring_layer) { | |
27 return new Reflector(); | |
28 } | |
29 | |
30 void TestContextFactory::RemoveReflector(scoped_refptr<Reflector> reflector) { | |
31 } | |
32 | |
33 scoped_refptr<cc::ContextProvider> | |
34 TestContextFactory::OffscreenCompositorContextProvider() { | |
35 if (!offscreen_compositor_contexts_.get() || | |
36 offscreen_compositor_contexts_->DestroyedOnMainThread()) | |
37 offscreen_compositor_contexts_ = cc::TestContextProvider::Create(); | |
38 return offscreen_compositor_contexts_; | |
39 } | |
40 | |
41 scoped_refptr<cc::ContextProvider> | |
42 TestContextFactory::SharedMainThreadContextProvider() { | |
43 if (shared_main_thread_contexts_ && | |
44 !shared_main_thread_contexts_->DestroyedOnMainThread()) | |
45 return shared_main_thread_contexts_; | |
46 | |
47 if (ui::Compositor::WasInitializedWithThread()) { | |
48 shared_main_thread_contexts_ = cc::TestContextProvider::Create(); | |
49 } else { | |
50 shared_main_thread_contexts_ = | |
51 static_cast<cc::TestContextProvider*>( | |
52 OffscreenCompositorContextProvider().get()); | |
53 } | |
54 if (shared_main_thread_contexts_ && | |
55 !shared_main_thread_contexts_->BindToCurrentThread()) | |
56 shared_main_thread_contexts_ = NULL; | |
57 | |
58 return shared_main_thread_contexts_; | |
59 } | |
60 | |
61 void TestContextFactory::RemoveCompositor(Compositor* compositor) { | |
62 } | |
63 | |
64 bool TestContextFactory::DoesCreateTestContexts() { return true; } | |
65 | |
66 } // namespace ui | |
OLD | NEW |