Flutter Engine
The Flutter Engine
Window_android.cpp
Go to the documentation of this file.
1/*
2* Copyright 2016 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
11
12namespace sk_app {
13
14Window* Window::CreateNativeWindow(void* platformData) {
16 if (!window->init((SkiaAndroidApp*)platformData)) {
17 delete window;
18 return nullptr;
19 }
20 return window;
21}
22
23bool Window_android::init(SkiaAndroidApp* skiaAndroidApp) {
24 SkASSERT(skiaAndroidApp);
25 fSkiaAndroidApp = skiaAndroidApp;
26 fSkiaAndroidApp->fWindow = this;
27 return true;
28}
29
30void Window_android::setTitle(const char* title) {
31 fSkiaAndroidApp->setTitle(title);
32}
33
35 fSkiaAndroidApp->setUIState(state);
36}
37
39 fBackendType = attachType;
40
41 // We delay the creation of fWindowContext until Android informs us that
42 // the native window is ready to use.
43 // The creation will be done in initDisplay, which is initiated by kSurfaceCreated event.
44 return true;
45}
46
49 switch (fBackendType) {
50#ifdef SK_GL
51 case kNativeGL_BackendType:
52 default:
54 break;
55#else
56 default:
57#endif
60 break;
61#ifdef SK_VULKAN
62 case kVulkan_BackendType:
64 break;
65#if defined(SK_GRAPHITE)
66 case kGraphiteVulkan_BackendType:
69 break;
70#endif
71#endif
72 }
73 this->onBackendCreated();
74}
75
77 detach();
78}
79
81 fSkiaAndroidApp->postMessage(Message(kContentInvalidated));
82}
83
85 if (fWindowContext) { // Check if initDisplay has already been called
86 onPaint();
87 } else {
89 }
90}
91
92} // namespace sk_app
#define SkASSERT(cond)
Definition: SkAssert.h:116
void onInval() override
void setTitle(const char *) override
bool init(SkiaAndroidApp *skiaAndroidApp)
bool attach(BackendType) override
void initDisplay(ANativeWindow *window)
void setUIState(const char *state) override
static Window * CreateNativeWindow(void *platformData)
void detach()
Definition: Window.cpp:25
@ kRaster_BackendType
Definition: Window.h:90
void markInvalProcessed()
Definition: Window.cpp:205
DisplayParams fRequestedDisplayParams
Definition: Window.h:176
std::unique_ptr< skwindow::WindowContext > fWindowContext
Definition: Window.h:179
void onPaint()
Definition: Window.cpp:81
void onBackendCreated()
Definition: Window.cpp:44
GLFWwindow * window
Definition: main.cc:45
AtkStateType state
std::unique_ptr< WindowContext > MakeGraphiteVulkanForAndroid(ANativeWindow *window, const DisplayParams &params)
std::unique_ptr< WindowContext > MakeGLForAndroid(ANativeWindow *window, const DisplayParams &params)
std::unique_ptr< WindowContext > MakeRasterForAndroid(ANativeWindow *window, const DisplayParams &params)
std::unique_ptr< WindowContext > MakeVulkanForAndroid(ANativeWindow *window, const DisplayParams &params)
void setUIState(const char *state) const
void setTitle(const char *title) const
void postMessage(const Message &message) const
struct ANativeWindow ANativeWindow