| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 "blimp/client/test/compositor/blimp_compositor_with_fake_host.h" | |
| 6 | |
| 7 #include "base/memory/ptr_util.h" | |
| 8 #include "base/threading/thread_task_runner_handle.h" | |
| 9 #include "cc/animation/animation_host.h" | |
| 10 #include "cc/proto/compositor_message.pb.h" | |
| 11 #include "cc/test/fake_proxy.h" | |
| 12 | |
| 13 namespace blimp { | |
| 14 namespace client { | |
| 15 | |
| 16 // static | |
| 17 std::unique_ptr<BlimpCompositorWithFakeHost> | |
| 18 BlimpCompositorWithFakeHost::Create( | |
| 19 BlimpCompositorDependencies* compositor_dependencies, | |
| 20 BlimpCompositorClient* client) { | |
| 21 std::unique_ptr<BlimpCompositorWithFakeHost> compositor = base::WrapUnique( | |
| 22 new BlimpCompositorWithFakeHost(compositor_dependencies, client)); | |
| 23 compositor->Initialize(); | |
| 24 return compositor; | |
| 25 } | |
| 26 | |
| 27 BlimpCompositorWithFakeHost::BlimpCompositorWithFakeHost( | |
| 28 BlimpCompositorDependencies* compositor_dependencies, | |
| 29 BlimpCompositorClient* client) | |
| 30 : BlimpCompositor(compositor_dependencies, client) {} | |
| 31 | |
| 32 BlimpCompositorWithFakeHost::~BlimpCompositorWithFakeHost() = default; | |
| 33 | |
| 34 std::unique_ptr<cc::proto::CompositorMessage> | |
| 35 BlimpCompositorWithFakeHost::CreateFakeUpdate( | |
| 36 scoped_refptr<cc::Layer> root_layer) { | |
| 37 std::unique_ptr<cc::proto::CompositorMessage> message = | |
| 38 base::MakeUnique<cc::proto::CompositorMessage>(); | |
| 39 message->set_client_state_update_ack(false); | |
| 40 cc::LayerTree* layer_tree = host()->GetLayerTree(); | |
| 41 layer_tree->SetRootLayer(root_layer); | |
| 42 cc::proto::LayerTree* layer_tree_proto = | |
| 43 message->mutable_layer_tree_host()->mutable_layer_tree(); | |
| 44 layer_tree->ToProtobuf(layer_tree_proto); | |
| 45 return message; | |
| 46 } | |
| 47 | |
| 48 std::unique_ptr<cc::LayerTreeHostInProcess> | |
| 49 BlimpCompositorWithFakeHost::CreateLayerTreeHost() { | |
| 50 DCHECK(animation_host()); | |
| 51 | |
| 52 cc::LayerTreeSettings settings; | |
| 53 std::unique_ptr<cc::FakeLayerTreeHost> host = cc::FakeLayerTreeHost::Create( | |
| 54 &fake_client_, &task_graph_runner_, animation_host(), settings, | |
| 55 cc::CompositorMode::THREADED); | |
| 56 host->InitializeForTesting( | |
| 57 cc::TaskRunnerProvider::Create(base::ThreadTaskRunnerHandle::Get(), | |
| 58 base::ThreadTaskRunnerHandle::Get()), | |
| 59 base::MakeUnique<cc::FakeProxy>()); | |
| 60 fake_host_ = host.get(); | |
| 61 return std::move(host); | |
| 62 } | |
| 63 | |
| 64 } // namespace client | |
| 65 } // namespace blimp | |
| OLD | NEW |