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.
5 #include "ui/compositor/test/test_context_factory.h"
7 #include "cc/output/output_surface.h"
8 #include "cc/test/test_context_provider.h"
9 #include "ui/compositor/reflector.h"
13 TestContextFactory::TestContextFactory() {}
15 TestContextFactory::~TestContextFactory() {}
17 scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface(
18 Compositor* compositor) {
19 return make_scoped_ptr(
20 new cc::OutputSurface(cc::TestContextProvider::Create()));
23 scoped_refptr<Reflector> TestContextFactory::CreateReflector(
24 Compositor* mirrored_compositor,
25 Layer* mirroring_layer) {
26 return new Reflector();
29 void TestContextFactory::RemoveReflector(scoped_refptr<Reflector> reflector) {
32 scoped_refptr<cc::ContextProvider>
33 TestContextFactory::OffscreenCompositorContextProvider() {
34 if (!offscreen_compositor_contexts_.get() ||
35 offscreen_compositor_contexts_->DestroyedOnMainThread())
36 offscreen_compositor_contexts_ = cc::TestContextProvider::Create();
37 return offscreen_compositor_contexts_;
40 scoped_refptr<cc::ContextProvider>
41 TestContextFactory::SharedMainThreadContextProvider() {
42 if (shared_main_thread_contexts_ &&
43 !shared_main_thread_contexts_->DestroyedOnMainThread())
44 return shared_main_thread_contexts_;
46 if (ui::Compositor::WasInitializedWithThread()) {
47 shared_main_thread_contexts_ = cc::TestContextProvider::Create();
49 shared_main_thread_contexts_ =
50 static_cast<cc::TestContextProvider*>(
51 OffscreenCompositorContextProvider().get());
53 if (shared_main_thread_contexts_ &&
54 !shared_main_thread_contexts_->BindToCurrentThread())
55 shared_main_thread_contexts_ = NULL;
57 return shared_main_thread_contexts_;
60 void TestContextFactory::RemoveCompositor(Compositor* compositor) {
63 bool TestContextFactory::DoesCreateTestContexts() { return true; }