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 #include "surface_glue_android.h" | 8 #include "surface_glue_android.h" |
9 | 9 |
10 #include <jni.h> | 10 #include <jni.h> |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 case kSurfaceCreated: { | 108 case kSurfaceCreated: { |
109 SkASSERT(!skiaAndroidApp->fNativeWindow && message.fNativeWindow); | 109 SkASSERT(!skiaAndroidApp->fNativeWindow && message.fNativeWindow); |
110 skiaAndroidApp->fNativeWindow = message.fNativeWindow; | 110 skiaAndroidApp->fNativeWindow = message.fNativeWindow; |
111 auto window_android = (Window_android*)skiaAndroidApp->fWindow; | 111 auto window_android = (Window_android*)skiaAndroidApp->fWindow; |
112 window_android->initDisplay(skiaAndroidApp->fNativeWindow); | 112 window_android->initDisplay(skiaAndroidApp->fNativeWindow); |
113 ((Window_android*)skiaAndroidApp->fWindow)->paintIfNeeded(); | 113 ((Window_android*)skiaAndroidApp->fWindow)->paintIfNeeded(); |
114 break; | 114 break; |
115 } | 115 } |
116 case kSurfaceChanged: { | 116 case kSurfaceChanged: { |
117 SkASSERT(message.fNativeWindow == skiaAndroidApp->fNativeWindow && | 117 SkASSERT(message.fNativeWindow); |
118 message.fNativeWindow); | |
119 int width = ANativeWindow_getWidth(skiaAndroidApp->fNativeWindow); | 118 int width = ANativeWindow_getWidth(skiaAndroidApp->fNativeWindow); |
120 int height = ANativeWindow_getHeight(skiaAndroidApp->fNativeWindow); | 119 int height = ANativeWindow_getHeight(skiaAndroidApp->fNativeWindow); |
121 auto window_android = (Window_android*)skiaAndroidApp->fWindow; | 120 auto window_android = (Window_android*)skiaAndroidApp->fWindow; |
| 121 if (message.fNativeWindow != skiaAndroidApp->fNativeWindow) { |
| 122 window_android->onDisplayDestroyed(); |
| 123 ANativeWindow_release(skiaAndroidApp->fNativeWindow); |
| 124 skiaAndroidApp->fNativeWindow = message.fNativeWindow; |
| 125 window_android->initDisplay(skiaAndroidApp->fNativeWindow); |
| 126 } |
122 window_android->setContentRect(0, 0, width, height); | 127 window_android->setContentRect(0, 0, width, height); |
123 window_android->paintIfNeeded(); | 128 window_android->paintIfNeeded(); |
124 break; | 129 break; |
125 } | 130 } |
126 case kSurfaceDestroyed: { | 131 case kSurfaceDestroyed: { |
127 if (skiaAndroidApp->fNativeWindow) { | 132 if (skiaAndroidApp->fNativeWindow) { |
128 auto window_android = (Window_android*)skiaAndroidApp->fWindow; | 133 auto window_android = (Window_android*)skiaAndroidApp->fWindow; |
129 window_android->onDisplayDestroyed(); | 134 window_android->onDisplayDestroyed(); |
130 ANativeWindow_release(skiaAndroidApp->fNativeWindow); | 135 ANativeWindow_release(skiaAndroidApp->fNativeWindow); |
131 skiaAndroidApp->fNativeWindow = nullptr; | 136 skiaAndroidApp->fNativeWindow = nullptr; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 const char* nameChars = env->GetStringUTFChars(stateName, nullptr); | 265 const char* nameChars = env->GetStringUTFChars(stateName, nullptr); |
261 const char* valueChars = env->GetStringUTFChars(stateValue, nullptr); | 266 const char* valueChars = env->GetStringUTFChars(stateValue, nullptr); |
262 message.stateName = new SkString(nameChars); | 267 message.stateName = new SkString(nameChars); |
263 message.stateValue = new SkString(valueChars); | 268 message.stateValue = new SkString(valueChars); |
264 skiaAndroidApp->postMessage(message); | 269 skiaAndroidApp->postMessage(message); |
265 env->ReleaseStringUTFChars(stateName, nameChars); | 270 env->ReleaseStringUTFChars(stateName, nameChars); |
266 env->ReleaseStringUTFChars(stateValue, valueChars); | 271 env->ReleaseStringUTFChars(stateValue, valueChars); |
267 } | 272 } |
268 | 273 |
269 } // namespace sk_app | 274 } // namespace sk_app |
OLD | NEW |