OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef Window_android_DEFINED | 8 #ifndef Window_android_DEFINED |
9 #define Window_android_DEFINED | 9 #define Window_android_DEFINED |
10 | 10 |
| 11 #include <android/native_window_jni.h> |
| 12 |
11 #include "../Window.h" | 13 #include "../Window.h" |
12 #include "surface_glue_android.h" | 14 #include "surface_glue_android.h" |
13 | 15 |
14 namespace sk_app { | 16 namespace sk_app { |
15 | 17 |
| 18 struct ContextPlatformData_android { |
| 19 ANativeWindow* fNativeWindow; |
| 20 }; |
| 21 |
16 class Window_android : public Window { | 22 class Window_android : public Window { |
17 public: | 23 public: |
18 Window_android() : Window() {} | 24 Window_android() : Window() {} |
19 ~Window_android() override {} | 25 ~Window_android() override {} |
20 | 26 |
21 bool init(SkiaAndroidApp* skiaAndroidApp); | 27 bool init(SkiaAndroidApp* skiaAndroidApp); |
22 void initDisplay(ANativeWindow* window); | 28 void initDisplay(ANativeWindow* window); |
23 void onDisplayDestroyed(); | 29 void onDisplayDestroyed(); |
24 | 30 |
25 const DisplayParams& getDisplayParams() override; | 31 const DisplayParams& getDisplayParams() override; |
26 void setTitle(const char*) override; | 32 void setTitle(const char*) override; |
27 void show() override {} | 33 void show() override {} |
28 | 34 |
29 bool attach(BackendType attachType, const DisplayParams& params) override; | 35 bool attach(BackendType attachType, const DisplayParams& params) override; |
30 void onInval() override; | 36 void onInval() override; |
31 void setUIState(const Json::Value& state) override; | 37 void setUIState(const Json::Value& state) override; |
32 | 38 |
33 void paintIfNeeded(); | 39 void paintIfNeeded(); |
34 | 40 |
35 bool scaleContentToFit() const override { return true; } | 41 bool scaleContentToFit() const override { return true; } |
36 bool supportsContentRect() const override { return true; } | 42 bool supportsContentRect() const override { return true; } |
37 SkRect getContentRect() override { return fContentRect; } | 43 SkRect getContentRect() override { return fContentRect; } |
38 void setContentRect(int l, int t, int r, int b) { fContentRect.set(l,t,r,b);
} | 44 void setContentRect(int l, int t, int r, int b) { fContentRect.set(l,t,r,b);
} |
39 | 45 |
40 private: | 46 private: |
| 47 // We need fNativeWindow for attaching with another backend. |
| 48 // (in that case, attach is called without initDisplay being called later) |
| 49 ANativeWindow* fNativeWindow = nullptr; |
41 SkiaAndroidApp* fSkiaAndroidApp = nullptr; | 50 SkiaAndroidApp* fSkiaAndroidApp = nullptr; |
42 SkRect fContentRect; | 51 SkRect fContentRect; |
43 DisplayParams fDisplayParams; | 52 DisplayParams fDisplayParams; |
| 53 BackendType fBackendType; |
44 }; | 54 }; |
45 | 55 |
46 } // namespace sk_app | 56 } // namespace sk_app |
47 | 57 |
48 #endif | 58 #endif |
OLD | NEW |