OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "gpu/tools/compositor_model_bench/render_models.h" | 5 #include "gpu/tools/compositor_model_bench/render_models.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
8 | 9 |
| 10 #include "base/memory/ptr_util.h" |
9 #include "gpu/tools/compositor_model_bench/forward_render_model.h" | 11 #include "gpu/tools/compositor_model_bench/forward_render_model.h" |
10 | 12 |
11 const char* ModelToString(RenderModel m) { | 13 const char* ModelToString(RenderModel m) { |
12 switch (m) { | 14 switch (m) { |
13 case ForwardRenderModel: | 15 case ForwardRenderModel: |
14 return "Forward Rendering"; | 16 return "Forward Rendering"; |
15 default: | 17 default: |
16 return "(unknown render model name)"; | 18 return "(unknown render model name)"; |
17 } | 19 } |
18 } | 20 } |
19 | 21 |
20 RenderModelSimulator::RenderModelSimulator(RenderNode* root) : root_(root) { | 22 RenderModelSimulator::RenderModelSimulator(std::unique_ptr<RenderNode> root) |
21 } | 23 : root_(std::move(root)) {} |
22 | 24 |
23 RenderModelSimulator::~RenderModelSimulator() { | 25 RenderModelSimulator::~RenderModelSimulator() { |
24 } | 26 } |
25 | 27 |
26 RenderModelSimulator* ConstructSimulationModel(RenderModel model, | 28 std::unique_ptr<RenderModelSimulator> ConstructSimulationModel( |
27 RenderNode* render_tree_root, | 29 RenderModel model, |
28 int window_width, | 30 std::unique_ptr<RenderNode> render_tree_root, |
29 int window_height) { | 31 int window_width, |
| 32 int window_height) { |
30 switch (model) { | 33 switch (model) { |
31 case ForwardRenderModel: | 34 case ForwardRenderModel: |
32 return new ForwardRenderSimulator(render_tree_root, | 35 return base::WrapUnique(new ForwardRenderSimulator( |
33 window_width, | 36 std::move(render_tree_root), window_width, window_height)); |
34 window_height); | |
35 default: | 37 default: |
36 LOG(ERROR) << "Unrecognized render model. " | 38 LOG(ERROR) << "Unrecognized render model. " |
37 "If we know its name, then it's..." << ModelToString(model); | 39 "If we know its name, then it's..." << ModelToString(model); |
38 return 0; | 40 return nullptr; |
39 } | 41 } |
40 } | 42 } |
41 | |
OLD | NEW |