OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef SERVICES_UI_LAUNCHER_VIEW_TREE_IMPL_H_ | 5 #ifndef SERVICES_UI_LAUNCHER_VIEW_TREE_IMPL_H_ |
6 #define SERVICES_UI_LAUNCHER_VIEW_TREE_IMPL_H_ | 6 #define SERVICES_UI_LAUNCHER_VIEW_TREE_IMPL_H_ |
7 | 7 |
| 8 #include "base/callback.h" |
8 #include "base/macros.h" | 9 #include "base/macros.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | |
10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| 11 #include "mojo/services/gfx/composition/interfaces/compositor.mojom.h" |
11 #include "mojo/services/native_viewport/interfaces/native_viewport.mojom.h" | 12 #include "mojo/services/native_viewport/interfaces/native_viewport.mojom.h" |
12 #include "mojo/services/surfaces/cpp/surfaces_utils.h" | 13 #include "mojo/services/ui/input/interfaces/input_dispatcher.mojom.h" |
13 #include "mojo/services/surfaces/interfaces/display.mojom.h" | |
14 #include "mojo/services/surfaces/interfaces/quads.mojom.h" | |
15 #include "mojo/services/surfaces/interfaces/surfaces.mojom.h" | |
16 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h" | 14 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h" |
17 | 15 |
18 namespace launcher { | 16 namespace launcher { |
19 | 17 |
20 class LauncherViewTree : public mojo::ui::ViewTree { | 18 class LauncherViewTree : public mojo::ui::ViewTree, |
| 19 public mojo::gfx::composition::SceneListener { |
21 public: | 20 public: |
22 LauncherViewTree(mojo::ApplicationImpl* app_impl, | 21 LauncherViewTree(mojo::gfx::composition::Compositor* compositor, |
23 mojo::DisplayPtr display, | 22 mojo::ui::ViewManager* view_manager, |
24 mojo::ViewportMetricsPtr viewport_metrics); | 23 mojo::ContextProviderPtr context_provider, |
| 24 mojo::ViewportMetricsPtr viewport_metrics, |
| 25 const base::Closure& shutdown_callback); |
25 | 26 |
26 ~LauncherViewTree() override; | 27 ~LauncherViewTree() override; |
27 | 28 |
28 void SetRoot(mojo::ui::ViewTokenPtr token); | 29 void SetRoot(mojo::ui::ViewTokenPtr token); |
29 void SetViewportMetrics(mojo::ViewportMetricsPtr viewport_metrics); | 30 void SetViewportMetrics(mojo::ViewportMetricsPtr viewport_metrics); |
30 void DispatchEvent(mojo::EventPtr event); | 31 void DispatchEvent(mojo::EventPtr event); |
31 | 32 |
32 private: | 33 private: |
| 34 // |SceneListener|: |
| 35 void OnResourceUnavailable( |
| 36 uint32_t resource_id, |
| 37 const OnResourceUnavailableCallback& callback) override; |
| 38 |
33 // |ViewTree|: | 39 // |ViewTree|: |
34 void OnLayout(const OnLayoutCallback& callback) override; | 40 void OnLayout(const OnLayoutCallback& callback) override; |
35 void OnRootUnavailable(uint32_t root_key, | 41 void OnRootUnavailable(uint32_t root_key, |
36 const OnRootUnavailableCallback& callback) override; | 42 const OnRootUnavailableCallback& callback) override; |
37 | 43 |
38 void OnViewManagerConnectionError(); | 44 void OnRendererConnectionError(); |
39 void OnViewTreeRegistered(); | 45 void OnSceneConnectionError(); |
| 46 void OnViewTreeConnectionError(); |
| 47 void OnInputDispatcherConnectionError(); |
| 48 |
| 49 void OnSceneRegistered(mojo::gfx::composition::SceneTokenPtr scene_token); |
| 50 void OnViewTreeRegistered(mojo::ui::ViewTreeTokenPtr view_tree_token); |
40 | 51 |
41 void LayoutRoot(); | 52 void LayoutRoot(); |
42 void OnLayoutResult(mojo::ui::ViewLayoutInfoPtr info); | 53 void OnLayoutResult(mojo::ui::ViewLayoutInfoPtr info); |
43 | 54 |
44 void ScheduleFrame(); | 55 void SetRootScene(); |
45 void FinishFrame(); | |
46 void OnFrameSubmitted(); | |
47 | 56 |
48 mojo::ui::ViewManagerPtr view_manager_; | 57 void PublishFrame(); |
49 mojo::DisplayPtr display_; | 58 |
| 59 void Shutdown(); |
| 60 |
| 61 mojo::gfx::composition::Compositor* compositor_; |
| 62 mojo::ui::ViewManager* view_manager_; |
| 63 |
| 64 mojo::ContextProviderPtr context_provider_; |
50 mojo::ViewportMetricsPtr viewport_metrics_; | 65 mojo::ViewportMetricsPtr viewport_metrics_; |
51 mojo::Binding<mojo::ui::ViewTree> binding_; | 66 base::Closure shutdown_callback_; |
52 | 67 |
| 68 mojo::Binding<mojo::gfx::composition::SceneListener> scene_listener_binding_; |
| 69 mojo::Binding<mojo::ui::ViewTree> view_tree_binding_; |
| 70 |
| 71 mojo::gfx::composition::ScenePtr scene_; |
| 72 mojo::gfx::composition::SceneTokenPtr scene_token_; |
| 73 uint32_t scene_version_ = 1u; |
| 74 |
| 75 mojo::gfx::composition::RendererPtr renderer_; |
53 mojo::ui::ViewTreeHostPtr view_tree_host_; | 76 mojo::ui::ViewTreeHostPtr view_tree_host_; |
| 77 mojo::ui::InputDispatcherPtr input_dispatcher_; |
54 | 78 |
55 mojo::ui::ViewTokenPtr root_; | 79 mojo::ui::ViewTokenPtr root_; |
56 uint32_t root_key_; | 80 uint32_t root_key_ = 0u; |
57 mojo::ui::ViewLayoutInfoPtr root_layout_info_; | 81 mojo::ui::ViewLayoutInfoPtr root_layout_info_; |
58 | 82 |
59 bool frame_scheduled_; | |
60 bool frame_pending_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(LauncherViewTree); | 83 DISALLOW_COPY_AND_ASSIGN(LauncherViewTree); |
63 }; | 84 }; |
64 | 85 |
65 } // namespace launcher | 86 } // namespace launcher |
66 | 87 |
67 #endif // SERVICES_UI_LAUNCHER_VIEW_TREE_IMPL_H_ | 88 #endif // SERVICES_UI_LAUNCHER_VIEW_TREE_IMPL_H_ |
OLD | NEW |