Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / cc / test / fake_layer_tree_host_client.cc
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.
4
5 #include "cc/test/fake_layer_tree_host_client.h"
6
7 #include "cc/output/context_provider.h"
8 #include "cc/test/fake_output_surface.h"
9 #include "cc/test/test_web_graphics_context_3d.h"
10
11 namespace cc {
12
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) {}
18
19 FakeLayerTreeHostClient::~FakeLayerTreeHostClient() {}
20
21 scoped_ptr<OutputSurface> FakeLayerTreeHostClient::CreateOutputSurface(
22     bool fallback) {
23   if (use_software_rendering_) {
24     if (use_delegating_renderer_) {
25       return FakeOutputSurface::CreateDelegatingSoftware(
26           make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>();
27     }
28
29     return FakeOutputSurface::CreateSoftware(
30         make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>();
31   }
32
33   if (use_delegating_renderer_)
34     return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
35   return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
36 }
37
38 }  // namespace cc