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_PLATFORM_VIEW_ANDROID_H_ | 5 #ifndef SKY_SHELL_PLATFORM_VIEW_ANDROID_H_ |
6 #define SKY_SHELL_PLATFORM_VIEW_ANDROID_H_ | 6 #define SKY_SHELL_PLATFORM_VIEW_ANDROID_H_ |
7 | 7 |
8 #include "sky/shell/platform_view.h" | 8 #include "sky/shell/platform_view.h" |
9 | 9 |
10 struct ANativeWindow; | 10 struct ANativeWindow; |
11 | 11 |
12 namespace sky { | 12 namespace sky { |
13 namespace shell { | 13 namespace shell { |
| 14 class Instance; |
14 | 15 |
15 class PlatformViewAndroid : public PlatformView { | 16 class PlatformViewAndroid : public PlatformView { |
16 public: | 17 public: |
17 static bool Register(JNIEnv* env); | 18 static bool Register(JNIEnv* env); |
| 19 |
| 20 PlatformViewAndroid(const Config& config); |
18 ~PlatformViewAndroid() override; | 21 ~PlatformViewAndroid() override; |
19 | 22 |
20 // Called from Java | 23 // Called from Java |
21 void Detach(JNIEnv* env, jobject obj); | 24 void Detach(JNIEnv* env, jobject obj); |
22 void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface); | 25 void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface); |
23 void SurfaceDestroyed(JNIEnv* env, jobject obj); | 26 void SurfaceDestroyed(JNIEnv* env, jobject obj); |
24 | 27 |
| 28 void SetInstance(scoped_ptr<Instance> instance); |
| 29 |
25 private: | 30 private: |
26 void ReleaseWindow(); | 31 void ReleaseWindow(); |
27 | 32 |
| 33 // In principle, the Instance should own the PlatformView, but because our |
| 34 // lifetime is controlled by the Android view hierarchy, we flip around the |
| 35 // ownership and have the Instance owned by Java. We reset this pointer in |
| 36 // |Detach|, which will eventually cause |~PlatformViewAndroid|. |
| 37 scoped_ptr<Instance> instance_; |
| 38 |
28 DISALLOW_COPY_AND_ASSIGN(PlatformViewAndroid); | 39 DISALLOW_COPY_AND_ASSIGN(PlatformViewAndroid); |
29 }; | 40 }; |
30 | 41 |
31 } // namespace shell | 42 } // namespace shell |
32 } // namespace sky | 43 } // namespace sky |
33 | 44 |
34 #endif // SKY_SHELL_PLATFORM_VIEW_ANDROID_H_ | 45 #endif // SKY_SHELL_PLATFORM_VIEW_ANDROID_H_ |
OLD | NEW |