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 7namespace cc { 8FakeLayerTreeHost::FakeLayerTreeHost(FakeLayerTreeHostClient* client, 9 const LayerTreeSettings& settings) 10 : LayerTreeHost(client, NULL, settings), 11 client_(client), 12 host_impl_(settings, &proxy_, &manager_), 13 needs_commit_(false) { 14 client_->SetLayerTreeHost(this); 15} 16 17scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( 18 FakeLayerTreeHostClient* client) { 19 LayerTreeSettings settings; 20 return make_scoped_ptr(new FakeLayerTreeHost(client, settings)); 21} 22 23scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( 24 FakeLayerTreeHostClient* client, 25 const LayerTreeSettings& settings) { 26 return make_scoped_ptr(new FakeLayerTreeHost(client, settings)); 27} 28 29FakeLayerTreeHost::~FakeLayerTreeHost() { 30 client_->SetLayerTreeHost(NULL); 31} 32 33void FakeLayerTreeHost::SetNeedsCommit() { needs_commit_ = true; } 34 35LayerImpl* FakeLayerTreeHost::CommitAndCreateLayerImplTree() { 36 scoped_ptr<LayerImpl> old_root_layer_impl = active_tree()->DetachLayerTree(); 37 38 scoped_ptr<LayerImpl> layer_impl = TreeSynchronizer::SynchronizeTrees( 39 root_layer(), old_root_layer_impl.Pass(), active_tree()); 40 TreeSynchronizer::PushProperties(root_layer(), layer_impl.get()); 41 42 active_tree()->SetRootLayer(layer_impl.Pass()); 43 return active_tree()->root_layer(); 44} 45 46} // namespace cc 47