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 SKY_SHELL_UI_ENGINE_H_ | 5 #ifndef SKY_SHELL_UI_ENGINE_H_ |
6 #define SKY_SHELL_UI_ENGINE_H_ | 6 #define SKY_SHELL_UI_ENGINE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "mojo/public/cpp/bindings/binding.h" | 12 #include "mojo/public/cpp/bindings/binding.h" |
13 #include "mojo/public/cpp/system/core.h" | 13 #include "mojo/public/cpp/system/core.h" |
14 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 14 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
15 #include "mojo/services/asset_bundle/public/interfaces/asset_bundle.mojom.h" | 15 #include "mojo/services/asset_bundle/public/interfaces/asset_bundle.mojom.h" |
16 #include "mojo/services/navigation/public/interfaces/navigation.mojom.h" | 16 #include "mojo/services/navigation/public/interfaces/navigation.mojom.h" |
| 17 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
17 #include "skia/ext/refptr.h" | 18 #include "skia/ext/refptr.h" |
18 #include "sky/engine/public/platform/ServiceProvider.h" | 19 #include "sky/engine/public/platform/ServiceProvider.h" |
19 #include "sky/engine/public/sky/sky_view.h" | 20 #include "sky/engine/public/sky/sky_view.h" |
20 #include "sky/engine/public/sky/sky_view_client.h" | 21 #include "sky/engine/public/sky/sky_view_client.h" |
21 #include "sky/shell/gpu_delegate.h" | 22 #include "sky/shell/gpu_delegate.h" |
| 23 #include "sky/shell/service_provider.h" |
22 #include "sky/shell/ui_delegate.h" | 24 #include "sky/shell/ui_delegate.h" |
23 #include "sky/shell/service_provider.h" | |
24 #include "third_party/skia/include/core/SkPicture.h" | 25 #include "third_party/skia/include/core/SkPicture.h" |
25 #include "ui/gfx/geometry/size.h" | 26 #include "ui/gfx/geometry/size.h" |
26 | 27 |
27 namespace sky { | 28 namespace sky { |
28 class PlatformImpl; | 29 class PlatformImpl; |
29 namespace shell { | 30 namespace shell { |
30 class Animator; | 31 class Animator; |
31 | 32 |
32 class Engine : public UIDelegate, | 33 class Engine : public UIDelegate, |
33 public SkyEngine, | 34 public SkyEngine, |
34 public blink::ServiceProvider, | 35 public blink::ServiceProvider, |
35 public mojo::NavigatorHost, | 36 public mojo::NavigatorHost, |
36 public blink::SkyViewClient { | 37 public blink::SkyViewClient { |
37 public: | 38 public: |
38 struct Config { | 39 struct Config { |
39 Config(); | 40 Config(); |
40 ~Config(); | 41 ~Config(); |
41 | 42 |
42 ServiceProviderContext* service_provider_context; | 43 ServiceProviderContext* service_provider_context; |
43 | 44 |
44 base::WeakPtr<GPUDelegate> gpu_delegate; | 45 base::WeakPtr<GPUDelegate> gpu_delegate; |
45 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner; | 46 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner; |
46 }; | 47 }; |
47 | 48 |
48 explicit Engine(const Config& config); | 49 explicit Engine(const Config& config); |
49 ~Engine() override; | 50 ~Engine() override; |
50 | 51 |
51 base::WeakPtr<Engine> GetWeakPtr(); | 52 base::WeakPtr<Engine> GetWeakPtr(); |
52 | 53 |
53 static void Init(ServiceProviderContext* service_provider_context); | 54 static void Init(); |
54 | 55 |
55 void BeginFrame(base::TimeTicks frame_time); | 56 void BeginFrame(base::TimeTicks frame_time); |
56 skia::RefPtr<SkPicture> Paint(); | 57 skia::RefPtr<SkPicture> Paint(); |
57 | 58 |
58 private: | 59 private: |
59 // UIDelegate implementation: | 60 // UIDelegate implementation: |
60 void ConnectToEngine(mojo::InterfaceRequest<SkyEngine> request) override; | 61 void ConnectToEngine(mojo::InterfaceRequest<SkyEngine> request) override; |
61 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override; | 62 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override; |
62 void OnOutputSurfaceDestroyed() override; | 63 void OnOutputSurfaceDestroyed() override; |
63 | 64 |
(...skipping 26 matching lines...) Expand all Loading... |
90 void RunFromLibrary(const std::string& name); | 91 void RunFromLibrary(const std::string& name); |
91 void RunFromSnapshotStream(const std::string& name, | 92 void RunFromSnapshotStream(const std::string& name, |
92 mojo::ScopedDataPipeConsumerHandle snapshot); | 93 mojo::ScopedDataPipeConsumerHandle snapshot); |
93 | 94 |
94 void StopAnimator(); | 95 void StopAnimator(); |
95 void StartAnimatorIfPossible(); | 96 void StartAnimatorIfPossible(); |
96 | 97 |
97 Config config_; | 98 Config config_; |
98 scoped_ptr<Animator> animator_; | 99 scoped_ptr<Animator> animator_; |
99 | 100 |
| 101 mojo::NetworkServicePtr network_service_; |
100 mojo::asset_bundle::AssetBundlePtr root_bundle_; | 102 mojo::asset_bundle::AssetBundlePtr root_bundle_; |
101 scoped_ptr<blink::DartLibraryProvider> dart_library_provider_; | 103 scoped_ptr<blink::DartLibraryProvider> dart_library_provider_; |
102 std::unique_ptr<blink::SkyView> sky_view_; | 104 std::unique_ptr<blink::SkyView> sky_view_; |
103 | 105 |
104 gfx::Size physical_size_; | 106 gfx::Size physical_size_; |
105 blink::SkyDisplayMetrics display_metrics_; | 107 blink::SkyDisplayMetrics display_metrics_; |
106 mojo::Binding<SkyEngine> binding_; | 108 mojo::Binding<SkyEngine> binding_; |
107 | 109 |
108 // TODO(eseidel): This should move into an AnimatorStateMachine. | 110 // TODO(eseidel): This should move into an AnimatorStateMachine. |
109 bool activity_running_; | 111 bool activity_running_; |
110 bool have_surface_; | 112 bool have_surface_; |
111 | 113 |
112 base::WeakPtrFactory<Engine> weak_factory_; | 114 base::WeakPtrFactory<Engine> weak_factory_; |
113 | 115 |
114 DISALLOW_COPY_AND_ASSIGN(Engine); | 116 DISALLOW_COPY_AND_ASSIGN(Engine); |
115 }; | 117 }; |
116 | 118 |
117 } // namespace shell | 119 } // namespace shell |
118 } // namespace sky | 120 } // namespace sky |
119 | 121 |
120 #endif // SKY_SHELL_UI_ENGINE_H_ | 122 #endif // SKY_SHELL_UI_ENGINE_H_ |
OLD | NEW |