diff --git a/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp b/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp index 0d47b68f509eefe288119cf5b065ff7463e917bf..fc304ac9399d59a08fdee5fde73973f8bb8e3ac3 100644 --- a/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp +++ b/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp @@ -497,6 +497,13 @@ FrameBufferWindow* FrameBuffer::createWindow(int x, int y, int width, int height return window; } +void FrameBuffer::updateWindow(FrameBufferWindow *window, int x, int y, int width, int height) { + if (!window) + return; + + updateSubWindow(window->native_window, x, y, width, height); +} + void FrameBuffer::destroyWindow(FrameBufferWindow *window) { if (!window) return; diff --git a/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.h b/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.h index 5eb9c60dfc8b50d533ad5fd5b6c6b889ebbbf0cf..1a4808d543d33a153c67318a6bf3286b9bce3304 100644 --- a/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.h +++ b/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.h @@ -79,6 +79,7 @@ public: static bool initialize(EGLNativeDisplayType nativeDisplay); FrameBufferWindow* createWindow(int x, int y, int width, int height); + void updateWindow(FrameBufferWindow *window, int x, int y, int width, int height); void destroyWindow(FrameBufferWindow *window); // Finalize the instance. diff --git a/external/android-emugl/host/libs/libOpenglRender/LayerManager.cpp b/external/android-emugl/host/libs/libOpenglRender/LayerManager.cpp index e5e65fb64e3c4736ed07f5b6fb5f7947f8f8b379..ee62a7274d125903e867aa3d3788c115ff3296e3 100644 --- a/external/android-emugl/host/libs/libOpenglRender/LayerManager.cpp +++ b/external/android-emugl/host/libs/libOpenglRender/LayerManager.cpp @@ -82,13 +82,16 @@ void LayerManager::post_layer(const LayerInfo &layer) { l.second.updated = true; } } - else { - printf("New layer '%s' {%d,%d,%d,%d}\n", layer.name.c_str()); - window = FrameBuffer::getFB()->createWindow( - layer.display_frame.left, - layer.display_frame.top, - layer.display_frame.right, - layer.display_frame.bottom); + + auto width = layer.display_frame.right - layer.display_frame.left; + auto height = layer.display_frame.bottom - layer.display_frame.top; + + if (!window) { + auto buffer = FrameBuffer::getFB()->getColorBufferFromHandle(layer.buffer_handle); + + window = FrameBuffer::getFB()->createWindow(layer.display_frame.left, + layer.display_frame.top, + width, height); if (!window) { printf("Failed to create window for layer '%s'\n", layer.name.c_str()); return; @@ -97,7 +100,10 @@ void LayerManager::post_layer(const LayerInfo &layer) { } printf("%s: window %p buffer %d\n", __func__, window, layer.buffer_handle); - + FrameBuffer::getFB()->updateWindow(window, + layer.display_frame.left, + layer.display_frame.top, + width, height); FrameBuffer::getFB()->post(window, layer.buffer_handle); } diff --git a/external/android-emugl/host/libs/libOpenglRender/NativeSubWindow.h b/external/android-emugl/host/libs/libOpenglRender/NativeSubWindow.h index 21a379c4370e0f52db0530d82eb6d1bf4718ce45..bc3540c25c5c5f030d925947537eb96f04452ec0 100644 --- a/external/android-emugl/host/libs/libOpenglRender/NativeSubWindow.h +++ b/external/android-emugl/host/libs/libOpenglRender/NativeSubWindow.h @@ -30,6 +30,7 @@ class SubWindowHandler { public: virtual ~SubWindowHandler() { } virtual EGLNativeWindowType create_window(int x, int y, int width, int height) = 0; + virtual void update_window(EGLNativeWindowType win, int x, int y, int width, int height) = 0; virtual void destroy_window(EGLNativeWindowType win) = 0; }; @@ -55,6 +56,8 @@ EGLNativeWindowType createSubWindow(FBNativeWindowType p_window, int width, int height); +void updateSubWindow(EGLNativeWindowType win, int x, int y, int width, int height); + // Destroy a sub-window previously created through createSubWindow() above. void destroySubWindow(EGLNativeWindowType win); diff --git a/external/android-emugl/host/libs/libOpenglRender/NativeSubWindow_delegate.cpp b/external/android-emugl/host/libs/libOpenglRender/NativeSubWindow_delegate.cpp index 1eab521f67133c9f583a8ac7e4b0925f2a8e4d36..172e3da219ba1862d1025af402d89931e67ccc7c 100644 --- a/external/android-emugl/host/libs/libOpenglRender/NativeSubWindow_delegate.cpp +++ b/external/android-emugl/host/libs/libOpenglRender/NativeSubWindow_delegate.cpp @@ -44,6 +44,13 @@ EGLNativeWindowType createSubWindow(FBNativeWindowType p_window, return current_handler->create_window(x, y, width, height); } +void updateSubWindow(EGLNativeWindowType win, int x, int y, int width, int height) { + if (!current_handler) + return; + + return current_handler->update_window(win, x, y, width, height); +} + void destroySubWindow(EGLNativeWindowType win) { if (!current_handler) return; diff --git a/src/anbox/ubuntu/window.cpp b/src/anbox/ubuntu/window.cpp index e5c59c0aa2b91e104e4ff07c4ddf45856dd8e347..53b67ed8046fee6f6e7921b76c28d11358f3684a 100644 --- a/src/anbox/ubuntu/window.cpp +++ b/src/anbox/ubuntu/window.cpp @@ -62,6 +62,14 @@ Window::~Window() { SDL_DestroyWindow(window_); } +void Window::resize(int width, int height) { + SDL_SetWindowSize(window_, width, height); +} + +int Window::update_position(int x, int y) { + SDL_SetWindowPosition(window_, x, y); +} + EGLNativeWindowType Window::native_window() const { return native_window_; } diff --git a/src/anbox/ubuntu/window.h b/src/anbox/ubuntu/window.h index 7911082631a3268632e5e3a6c1096561e61f9174..a0ef3f786386ebb9a14a4c10f3a488a8f6c30129 100644 --- a/src/anbox/ubuntu/window.h +++ b/src/anbox/ubuntu/window.h @@ -32,6 +32,9 @@ public: Window(int x, int y, int width, int height); ~Window(); + void resize(int width, int height); + int update_position(int x, int y); + EGLNativeWindowType native_window() const; private: diff --git a/src/anbox/ubuntu/window_creator.cpp b/src/anbox/ubuntu/window_creator.cpp index 80522aed9ba0f32409e02fc0022466f9eeab2e82..6bd21f1c163e2245cdd0486c7d4006719b04d78b 100644 --- a/src/anbox/ubuntu/window_creator.cpp +++ b/src/anbox/ubuntu/window_creator.cpp @@ -91,6 +91,15 @@ catch (std::exception &err) { return 0; } +void WindowCreator::update_window(EGLNativeWindowType win, int x, int y, int width, int height) { + auto iter = windows_.find(win); + if (iter == windows_.end()) + return; + + iter->second->resize(width, height); + iter->second->update_position(x, y); +} + void WindowCreator::destroy_window(EGLNativeWindowType win) { auto iter = windows_.find(win); if (iter == windows_.end()) diff --git a/src/anbox/ubuntu/window_creator.h b/src/anbox/ubuntu/window_creator.h index b8e827ec93478cf2cd70bf5130c2262372597344..3f353949545e7907f2b65fb108736a3256c60114 100644 --- a/src/anbox/ubuntu/window_creator.h +++ b/src/anbox/ubuntu/window_creator.h @@ -39,6 +39,7 @@ public: ~WindowCreator(); EGLNativeWindowType create_window(int x, int y, int width, int height) override; + void update_window(EGLNativeWindowType win, int x, int y, int width, int height) override; void destroy_window(EGLNativeWindowType win) override; DisplayInfo display_info() const override;