1 // Copyright 2012 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 "cc/test/fake_layer_tree_host_client.h"
7 #include "cc/debug/test_web_graphics_context_3d.h"
8 #include "cc/output/context_provider.h"
9 #include "cc/test/fake_output_surface.h"
13 FakeLayerTreeHostClient::FakeLayerTreeHostClient(RendererOptions options
)
14 : use_software_rendering_(options
== DIRECT_SOFTWARE
||
15 options
== DELEGATED_SOFTWARE
),
16 use_delegating_renderer_(options
== DELEGATED_3D
||
17 options
== DELEGATED_SOFTWARE
) {}
19 FakeLayerTreeHostClient::~FakeLayerTreeHostClient() {}
21 scoped_ptr
<OutputSurface
> FakeLayerTreeHostClient::CreateOutputSurface(
23 if (use_software_rendering_
) {
24 if (use_delegating_renderer_
) {
25 return FakeOutputSurface::CreateDelegatingSoftware(
26 make_scoped_ptr(new SoftwareOutputDevice
)).PassAs
<OutputSurface
>();
29 return FakeOutputSurface::CreateSoftware(
30 make_scoped_ptr(new SoftwareOutputDevice
)).PassAs
<OutputSurface
>();
33 if (use_delegating_renderer_
)
34 return FakeOutputSurface::CreateDelegating3d().PassAs
<OutputSurface
>();
35 return FakeOutputSurface::Create3d().PassAs
<OutputSurface
>();
38 scoped_refptr
<ContextProvider
> FakeLayerTreeHostClient::
39 OffscreenContextProviderForMainThread() {
40 if (!main_thread_contexts_
.get() ||
41 main_thread_contexts_
->DestroyedOnMainThread()) {
42 main_thread_contexts_
= TestContextProvider::Create();
43 if (main_thread_contexts_
&& !main_thread_contexts_
->BindToCurrentThread())
44 main_thread_contexts_
= NULL
;
46 return main_thread_contexts_
;
49 scoped_refptr
<ContextProvider
> FakeLayerTreeHostClient::
50 OffscreenContextProviderForCompositorThread() {
51 if (!compositor_thread_contexts_
.get() ||
52 compositor_thread_contexts_
->DestroyedOnMainThread())
53 compositor_thread_contexts_
= TestContextProvider::Create();
54 return compositor_thread_contexts_
;