OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/test/fake_layer_tree_host_client.h" | 5 #include "cc/test/fake_layer_tree_host_client.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "cc/output/context_provider.h" | 8 #include "cc/output/context_provider.h" |
9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
10 #include "cc/test/test_web_graphics_context_3d.h" | 10 #include "cc/test/test_web_graphics_context_3d.h" |
11 #include "cc/trees/layer_tree_host.h" | 11 #include "cc/trees/layer_tree_host.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 FakeLayerTreeHostClient::FakeLayerTreeHostClient(RendererOptions options) | 15 FakeLayerTreeHostClient::FakeLayerTreeHostClient() = default; |
16 : use_software_rendering_(options == DIRECT_SOFTWARE || | 16 FakeLayerTreeHostClient::~FakeLayerTreeHostClient() = default; |
17 options == DELEGATED_SOFTWARE), | |
18 use_delegating_renderer_(options == DELEGATED_3D || | |
19 options == DELEGATED_SOFTWARE), | |
20 host_(NULL) { | |
21 } | |
22 | |
23 FakeLayerTreeHostClient::~FakeLayerTreeHostClient() {} | |
24 | 17 |
25 void FakeLayerTreeHostClient::RequestNewOutputSurface() { | 18 void FakeLayerTreeHostClient::RequestNewOutputSurface() { |
26 DCHECK(host_); | 19 DCHECK(host_); |
27 std::unique_ptr<OutputSurface> surface; | 20 host_->SetOutputSurface(FakeOutputSurface::CreateDelegating3d()); |
28 if (use_software_rendering_) { | |
29 if (use_delegating_renderer_) { | |
30 surface = FakeOutputSurface::CreateDelegatingSoftware( | |
31 base::WrapUnique(new SoftwareOutputDevice)); | |
32 } else { | |
33 surface = FakeOutputSurface::CreateSoftware( | |
34 base::WrapUnique(new SoftwareOutputDevice)); | |
35 } | |
36 } else if (use_delegating_renderer_) { | |
37 surface = FakeOutputSurface::CreateDelegating3d(); | |
38 } else { | |
39 surface = FakeOutputSurface::Create3d(); | |
40 } | |
41 host_->SetOutputSurface(std::move(surface)); | |
42 } | 21 } |
43 | 22 |
44 void FakeLayerTreeHostClient::DidFailToInitializeOutputSurface() { | 23 void FakeLayerTreeHostClient::DidFailToInitializeOutputSurface() { |
45 RequestNewOutputSurface(); | 24 RequestNewOutputSurface(); |
46 } | 25 } |
47 | 26 |
48 } // namespace cc | 27 } // namespace cc |
OLD | NEW |