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/output/context_provider.h"
8 #include "cc/test/test_web_graphics_context_3d.h"
12 FakeLayerTreeHostClient::FakeLayerTreeHostClient(RendererOptions options
)
13 : use_software_rendering_(options
== DIRECT_SOFTWARE
||
14 options
== DELEGATED_SOFTWARE
),
15 use_delegating_renderer_(options
== DELEGATED_3D
||
16 options
== DELEGATED_SOFTWARE
) {}
18 FakeLayerTreeHostClient::~FakeLayerTreeHostClient() {}
20 scoped_ptr
<OutputSurface
> FakeLayerTreeHostClient::CreateOutputSurface() {
21 if (use_software_rendering_
) {
22 if (use_delegating_renderer_
) {
23 return FakeOutputSurface::CreateDelegatingSoftware(
24 make_scoped_ptr(new SoftwareOutputDevice
)).PassAs
<OutputSurface
>();
27 return FakeOutputSurface::CreateSoftware(
28 make_scoped_ptr(new SoftwareOutputDevice
)).PassAs
<OutputSurface
>();
31 WebKit::WebGraphicsContext3D::Attributes attrs
;
32 if (use_delegating_renderer_
) {
33 return FakeOutputSurface::CreateDelegating3d(
34 TestWebGraphicsContext3D::Create(attrs
)
35 .PassAs
<WebKit::WebGraphicsContext3D
>())
36 .PassAs
<OutputSurface
>();
39 return FakeOutputSurface::Create3d(
40 TestWebGraphicsContext3D::Create(attrs
)
41 .PassAs
<WebKit::WebGraphicsContext3D
>())
42 .PassAs
<OutputSurface
>();
45 scoped_ptr
<InputHandler
> FakeLayerTreeHostClient::CreateInputHandler() {
46 return scoped_ptr
<InputHandler
>();
49 scoped_refptr
<cc::ContextProvider
> FakeLayerTreeHostClient::
50 OffscreenContextProviderForMainThread() {
51 if (!main_thread_contexts_
||
52 main_thread_contexts_
->DestroyedOnMainThread()) {
53 main_thread_contexts_
= FakeContextProvider::Create();
54 if (!main_thread_contexts_
->BindToCurrentThread())
55 main_thread_contexts_
= NULL
;
57 return main_thread_contexts_
;
60 scoped_refptr
<cc::ContextProvider
> FakeLayerTreeHostClient::
61 OffscreenContextProviderForCompositorThread() {
62 if (!compositor_thread_contexts_
||
63 compositor_thread_contexts_
->DestroyedOnMainThread())
64 compositor_thread_contexts_
= FakeContextProvider::Create();
65 return compositor_thread_contexts_
;