Reland "Non-SFI mode: Switch to newlib. (patchset #4 id:60001 of https://codereview...
[chromium-blink-merge.git] / cc / test / fake_layer_tree_host.cc
blob09f2fc9c17cd9c1e9729ce63eb5dee2a8df66fb1
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 "cc/test/fake_layer_tree_host.h"
7 #include "cc/test/test_task_graph_runner.h"
9 namespace cc {
10 FakeLayerTreeHost::FakeLayerTreeHost(FakeLayerTreeHostClient* client,
11 LayerTreeHost::InitParams* params)
12 : LayerTreeHost(params),
13 client_(client),
14 host_impl_(*params->settings,
15 &proxy_,
16 &manager_,
17 params->task_graph_runner),
18 needs_commit_(false) {
19 client_->SetLayerTreeHost(this);
22 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create(
23 FakeLayerTreeHostClient* client,
24 TestTaskGraphRunner* task_graph_runner) {
25 LayerTreeSettings settings;
26 return Create(client, task_graph_runner, settings);
29 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create(
30 FakeLayerTreeHostClient* client,
31 TestTaskGraphRunner* task_graph_runner,
32 const LayerTreeSettings& settings) {
33 LayerTreeHost::InitParams params;
34 params.client = client;
35 params.settings = &settings;
36 params.task_graph_runner = task_graph_runner;
37 return make_scoped_ptr(new FakeLayerTreeHost(client, &params));
40 FakeLayerTreeHost::~FakeLayerTreeHost() {
41 client_->SetLayerTreeHost(NULL);
44 void FakeLayerTreeHost::SetNeedsCommit() { needs_commit_ = true; }
46 LayerImpl* FakeLayerTreeHost::CommitAndCreateLayerImplTree() {
47 scoped_ptr<LayerImpl> old_root_layer_impl = active_tree()->DetachLayerTree();
49 scoped_ptr<LayerImpl> layer_impl = TreeSynchronizer::SynchronizeTrees(
50 root_layer(), old_root_layer_impl.Pass(), active_tree());
51 active_tree()->SetPropertyTrees(*property_trees());
52 TreeSynchronizer::PushProperties(root_layer(), layer_impl.get());
54 active_tree()->SetRootLayer(layer_impl.Pass());
55 return active_tree()->root_layer();
58 } // namespace cc