From 2ee98a57619a579e1a33bbcb340bf538eee90fff Mon Sep 17 00:00:00 2001 From: Jiyun Yang Date: Mon, 12 Nov 2018 15:07:26 +0900 Subject: [PATCH] Add Window::SetPositionSize() and remove redundant value check For Window::SetPosition() and Window::SetSize(), calling one after another does not guarantee to be displayed on the screen at once. The new API SetPositionSize() can guarantee atomic "move + resize". And this commit also removes duplicate and wrong surface rect check in Window::SetPosition() and Window::SetSize(). Previously, WindowRenderSurface only allowed at least 2 pixel bigger/smaller size update, but codes in Window did not fit this condition so that it could cause a bug. Change-Id: I7479e5124906af8baafc5e2ec8d1a07d8845f007 Signed-off-by: Jiyun Yang --- build/tizen/adaptor/configure.ac | 2 +- dali/devel-api/adaptor-framework/window-devel.cpp | 35 +++++++++++++ dali/devel-api/adaptor-framework/window-devel.h | 42 ++++++++++++++++ dali/devel-api/file.list | 6 ++- dali/internal/window-system/common/window-impl.cpp | 58 +++++++++++++++------- dali/internal/window-system/common/window-impl.h | 5 ++ .../ecore-wl2/window-base-ecore-wl2.cpp | 15 ++++-- .../ecore-wl2/window-base-ecore-wl2.h | 3 ++ packaging/dali-adaptor.spec | 1 + 9 files changed, 143 insertions(+), 24 deletions(-) create mode 100644 dali/devel-api/adaptor-framework/window-devel.cpp create mode 100644 dali/devel-api/adaptor-framework/window-devel.h diff --git a/build/tizen/adaptor/configure.ac b/build/tizen/adaptor/configure.ac index 6fc5844..11a6816 100644 --- a/build/tizen/adaptor/configure.ac +++ b/build/tizen/adaptor/configure.ac @@ -306,7 +306,7 @@ fi if test "x$enable_wayland" = "xyes"; then if test "x$enable_ecore_wayland2" = "xyes"; then -PKG_CHECK_MODULES(WAYLAND, [ecore-wl2 egl wayland-egl wayland-client >= 1.2.0 xkbcommon libtbm]) +PKG_CHECK_MODULES(WAYLAND, [ecore-wl2 egl wayland-egl wayland-egl-tizen wayland-client >= 1.2.0 xkbcommon libtbm]) else PKG_CHECK_MODULES(WAYLAND, [ecore-wayland egl wayland-egl wayland-client >= 1.2.0 xkbcommon libtbm]) fi diff --git a/dali/devel-api/adaptor-framework/window-devel.cpp b/dali/devel-api/adaptor-framework/window-devel.cpp new file mode 100644 index 0000000..f14bc8d --- /dev/null +++ b/dali/devel-api/adaptor-framework/window-devel.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace DevelWindow +{ + +void SetPositionSize( Window window, PositionSize positionSize ) +{ + GetImplementation( window ).SetPositionSize( positionSize ); +} + +} // namespace DevelWindow + +} // namespace Dali diff --git a/dali/devel-api/adaptor-framework/window-devel.h b/dali/devel-api/adaptor-framework/window-devel.h new file mode 100644 index 0000000..9ed8a18 --- /dev/null +++ b/dali/devel-api/adaptor-framework/window-devel.h @@ -0,0 +1,42 @@ +#ifndef DALI_WINDOW_DEVEL_H +#define DALI_WINDOW_DEVEL_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace DevelWindow +{ + +/** + * @brief Sets position and size of the window. This API guarantees that both moving and resizing of window will appear on the screen at once. + * + * @param[in] window The window instance + * @param[in] positionSize The new window position and size + */ +DALI_ADAPTOR_API void SetPositionSize( Window window, PositionSize positionSize ); + +} // namespace DevelWindow + +} // namespace Dali + +#endif // DALI_WINDOW_DEVEL_H diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 59a216f..735f7b9 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -29,7 +29,8 @@ devel_api_src_files = \ $(adaptor_devel_api_dir)/adaptor-framework/video-player.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/thread-settings.cpp \ - $(adaptor_devel_api_dir)/adaptor-framework/web-engine.cpp + $(adaptor_devel_api_dir)/adaptor-framework/web-engine.cpp \ + $(adaptor_devel_api_dir)/adaptor-framework/window-devel.cpp @@ -74,7 +75,8 @@ devel_api_adaptor_framework_header_files = \ $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.h \ $(adaptor_devel_api_dir)/adaptor-framework/physical-keyboard.h \ $(adaptor_devel_api_dir)/adaptor-framework/key-devel.h \ - $(adaptor_devel_api_dir)/adaptor-framework/thread-settings.h + $(adaptor_devel_api_dir)/adaptor-framework/thread-settings.h \ + $(adaptor_devel_api_dir)/adaptor-framework/window-devel.h devel_api_text_abstraction_src_files = \ $(adaptor_devel_api_dir)/text-abstraction/bidirectional-support.cpp \ diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 8412d53..2ea6269 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -488,21 +488,22 @@ void Window::SetSize( Dali::Window::WindowSize size ) mResizeEnabled = true; } - PositionSize positionSize = mSurface->GetPositionSize(); + PositionSize oldRect = mSurface->GetPositionSize(); - if( positionSize.width != size.GetWidth() || positionSize.height != size.GetHeight() ) - { - positionSize.width = size.GetWidth(); - positionSize.height = size.GetHeight(); + mSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) ); - mSurface->MoveResize( positionSize ); + PositionSize newRect = mSurface->GetPositionSize(); + + // When surface size is updated, inform adaptor of resizing and emit ResizeSignal + if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) ) + { + Uint16Pair newSize( newRect.width, newRect.height ); - mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) ); + mAdaptor->SurfaceResizePrepare( newSize ); - // Emit signal - mResizedSignal.Emit( Dali::Window::WindowSize( positionSize.width, positionSize.height ) ); + mResizedSignal.Emit( newSize ); - mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) ); + mAdaptor->SurfaceResizeComplete( newSize ); } } @@ -521,15 +522,9 @@ void Window::SetPosition( Dali::Window::WindowPosition position ) mResizeEnabled = true; } - PositionSize positionSize = mSurface->GetPositionSize(); - - if( positionSize.x != position.GetX() || positionSize.y != position.GetY() ) - { - positionSize.x = position.GetX(); - positionSize.y = position.GetY(); + PositionSize oldRect = mSurface->GetPositionSize(); - mSurface->MoveResize( positionSize ); - } + mSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) ); } Dali::Window::WindowPosition Window::GetPosition() const @@ -539,6 +534,33 @@ Dali::Window::WindowPosition Window::GetPosition() const return Dali::Window::WindowPosition( positionSize.x, positionSize.y ); } +void Window::SetPositionSize( PositionSize positionSize ) +{ + if( !mResizeEnabled ) + { + AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" ); + mResizeEnabled = true; + } + + PositionSize oldRect = mSurface->GetPositionSize(); + + mSurface->MoveResize( positionSize ); + + PositionSize newRect = mSurface->GetPositionSize(); + + // When surface size is updated, inform adaptor of resizing and emit ResizeSignal + if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) ) + { + Uint16Pair newSize( newRect.width, newRect.height ); + + mAdaptor->SurfaceResizePrepare( newSize ); + + mResizedSignal.Emit( newSize ); + + mAdaptor->SurfaceResizeComplete( newSize ); + } +} + void Window::SetTransparency( bool transparent ) { mSurface->SetTransparency( transparent ); diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index c2a2b48..fff44b7 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -300,6 +300,11 @@ public: Dali::Window::WindowPosition GetPosition() const; /** + * @copydoc Dali::DevelWindow::SetPositionSize() + */ + void SetPositionSize( PositionSize positionSize ); + + /** * @copydoc Dali::Window::SetTransparency() */ void SetTransparency( bool transparent ); diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp index c1b4534..c95ba10 100755 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp @@ -35,6 +35,7 @@ #include #include #include +#include namespace Dali { @@ -606,7 +607,9 @@ WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any sur mBrightness( 0 ), mBrightnessChangeState( 0 ), mBrightnessChangeDone( true ), - mOwnSurface( false ) + mOwnSurface( false ), + mMoveResizeSerial( 0 ), + mLastSubmittedMoveResizeSerial( 0 ) #ifdef DALI_ELDBUS_AVAILABLE , mSystemConnection( NULL ) #endif @@ -1332,6 +1335,13 @@ void WindowBaseEcoreWl2::SetEglWindowTransform( int angle ) void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize ) { wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y ); + + // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number + if( mMoveResizeSerial != mLastSubmittedMoveResizeSerial ) + { + wl_egl_window_tizen_set_window_serial( mEglWindow, mMoveResizeSerial ); + mLastSubmittedMoveResizeSerial = mMoveResizeSerial; + } } bool WindowBaseEcoreWl2::IsEglWindowRotationSupported() @@ -1358,8 +1368,7 @@ void WindowBaseEcoreWl2::Resize( PositionSize positionSize ) void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize ) { - ecore_wl2_window_position_set( mEcoreWindow, positionSize.x, positionSize.y ); - ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height ); + ecore_wl2_window_sync_geometry_set( mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height ); } void WindowBaseEcoreWl2::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h index 246bd3a..ae00a8c 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h @@ -495,6 +495,9 @@ private: bool mOwnSurface; + volatile uint32_t mMoveResizeSerial; + uint32_t mLastSubmittedMoveResizeSerial; + #ifdef DALI_ELDBUS_AVAILABLE Eldbus_Connection* mSystemConnection; #endif // DALI_ELDBUS_AVAILABLE diff --git a/packaging/dali-adaptor.spec b/packaging/dali-adaptor.spec index 440b19c..6a9a927 100644 --- a/packaging/dali-adaptor.spec +++ b/packaging/dali-adaptor.spec @@ -98,6 +98,7 @@ BuildRequires: wayland-extension-client-devel # dali-adaptor uses ecore mainloop %if 0%{?tizen_version_major} >= 5 BuildRequires: pkgconfig(ecore-wl2) +BuildRequires: pkgconfig(wayland-egl-tizen) %else BuildRequires: pkgconfig(ecore-wayland) %endif -- 2.7.4