Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / cc / test / fake_layer_tree_host.cc
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 "cc/test/fake_layer_tree_host.h"
6
7 namespace cc {
8 FakeLayerTreeHost::FakeLayerTreeHost(LayerTreeHostClient* client,
9                                      const LayerTreeSettings& settings)
10     : LayerTreeHost(client, NULL, settings),
11       host_impl_(settings, &proxy_, &manager_),
12       needs_commit_(false) {}
13
14 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create() {
15   static FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
16   static LayerTreeSettings settings;
17   return make_scoped_ptr(new FakeLayerTreeHost(&client, settings));
18 }
19
20 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create(
21     const LayerTreeSettings& settings) {
22   static FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
23   return make_scoped_ptr(new FakeLayerTreeHost(&client, settings));
24 }
25
26 void FakeLayerTreeHost::SetNeedsCommit() { needs_commit_ = true; }
27
28 LayerImpl* FakeLayerTreeHost::CommitAndCreateLayerImplTree() {
29   scoped_ptr<LayerImpl> old_root_layer_impl = active_tree()->DetachLayerTree();
30
31   scoped_ptr<LayerImpl> layer_impl = TreeSynchronizer::SynchronizeTrees(
32       root_layer(), old_root_layer_impl.Pass(), active_tree());
33   TreeSynchronizer::PushProperties(root_layer(), layer_impl.get());
34
35   active_tree()->SetRootLayer(layer_impl.Pass());
36   return active_tree()->root_layer();
37 }
38
39 }  // namespace cc