------------------------------------------------------------------------------
| 249 | |
| 250 | //------------------------------------------------------------------------------ |
| 251 | void vtkAndroidRenderWindowInteractor::StartEventLoop() |
| 252 | { |
| 253 | this->StartedMessageLoop = 1; |
| 254 | this->Done = false; |
| 255 | |
| 256 | LOGW("Starting event loop"); |
| 257 | while (!this->Done) |
| 258 | { |
| 259 | // Read all pending events. |
| 260 | int ident; |
| 261 | int events; |
| 262 | struct android_poll_source* source; |
| 263 | |
| 264 | ident = ALooper_pollOnce(500, nullptr, &events, (void**)&source); |
| 265 | if (ident == ALOOPER_POLL_TIMEOUT) |
| 266 | { |
| 267 | // just watch for resize events |
| 268 | if (this->AndroidApplication->window && this->Enabled) |
| 269 | { |
| 270 | // so it seems that andoid's configuration changes first |
| 271 | // then the size of the native window changes a bit later |
| 272 | // then after some rendering is done the egl surface gets resized |
| 273 | // we try to handle that mess by watching for when the native window |
| 274 | // changes size, then we update our size, render to push the change |
| 275 | // down to egl, then render again. I suspect there may be a |
| 276 | // better way to get the change down to egl than doing a full render |
| 277 | int width = ANativeWindow_getWidth(this->AndroidApplication->window); |
| 278 | int height = ANativeWindow_getHeight(this->AndroidApplication->window); |
| 279 | if (width != this->Size[0] || height != this->Size[1]) |
| 280 | { |
| 281 | this->UpdateSize(width, height); |
| 282 | this->RenderWindow->Render(); |
| 283 | this->RenderWindow->Render(); |
| 284 | vtkErrorMacro("Config Resized to " << width << " by " << height); |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | if (ident >= 0) |
| 290 | { |
| 291 | LOGW("Processing Event"); |
| 292 | // Process this event. |
| 293 | if (source != nullptr) |
| 294 | { |
| 295 | source->process(this->AndroidApplication, source); |
| 296 | } |
| 297 | |
| 298 | // Check if we are exiting. |
| 299 | if (this->AndroidApplication->destroyRequested != 0) |
| 300 | { |
| 301 | LOGW("Destroying Window"); |
| 302 | this->RenderWindow->Finalize(); |
| 303 | LOGW("Destroyed"); |
| 304 | return; |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | } |
nothing calls this directly
no test coverage detected