From: Wonsik Jung Date: Fri, 4 Sep 2020 07:20:28 +0000 (+0900) Subject: Add GlWindow X-Git-Tag: dali_1.9.31~6^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F44%2F243244%2F7;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Add GlWindow Add GlWindow feature that is to support the native GLES application in DALi/NUI. It has the interface to setup simple egl config. In addition, three callback fuctions are initialize, rendering and terminate. The functions are called on idler. Change-Id: I306bf22e8126bf02af2d5316480aa695989b26c2 --- diff --git a/automated-tests/src/dali-adaptor/CMakeLists.txt b/automated-tests/src/dali-adaptor/CMakeLists.txt index 5be920e..9e1bf2d 100644 --- a/automated-tests/src/dali-adaptor/CMakeLists.txt +++ b/automated-tests/src/dali-adaptor/CMakeLists.txt @@ -15,6 +15,7 @@ SET(TC_SOURCES utc-Dali-Timer.cpp utc-Dali-TtsPlayer.cpp utc-Dali-Window.cpp + utc-Dali-Gl-Window.cpp #utc-Dali-Watch.cpp #utc-Dali-Watch-Time.cpp #utc-Dali-KeyGrab.cpp diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Gl-Window.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Gl-Window.cpp new file mode 100644 index 0000000..d77d9bf --- /dev/null +++ b/automated-tests/src/dali-adaptor/utc-Dali-Gl-Window.cpp @@ -0,0 +1,634 @@ +/* + * Copyright (c) 2020 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. + * + */ + +#include +#include +#include +#include +#include + + +using namespace Dali; + +void utc_dali_glwindow_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_glwindow_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliGlWindowConstructorP(void) +{ + Dali::GlWindow window; + DALI_TEST_CHECK( !window ); + END_TEST; +} + +int UtcDaliGlWindowCopyConstructorP(void) +{ + Dali::GlWindow window; + Dali::GlWindow copy( window ); + DALI_TEST_CHECK( copy == window ); + + END_TEST; +} + +int UtcDaliGlWindowConstructorFromInternalPointerN(void) +{ + Internal::Adaptor::GlWindow* internalWindow = NULL; + Dali::GlWindow window(internalWindow); + DALI_TEST_CHECK( !window ); + + END_TEST; +} + +int UtcDaliGlWindowAssignmentOperatorP(void) +{ + const Dali::GlWindow window; + Dali::GlWindow copy; + DALI_TEST_CHECK( ! copy ); + copy = window; + DALI_TEST_CHECK( copy == window ); + + END_TEST; +} + +int UtcDaliGlWindowDestructorP(void) +{ + Dali::GlWindow* window = new Dali::GlWindow(); + delete window; + + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliGlWindowNew1(void) +{ + try + { + PositionSize windowPosition(0, 0, 10, 10); + Dali::GlWindow window = Dali::GlWindow::New( windowPosition, "test-window", "test-window-class", true ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION ); + } + + END_TEST; +} + +int UtcDaliGlWindowNew2(void) +{ + try + { + PositionSize windowPosition(20, 10, 10, 10); + Dali::GlWindow window = Dali::GlWindow::New( windowPosition, "test-window", "test-window-class", true ); + + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliGlWindowSetEglConfigGles20(void) +{ + Dali::GlWindow window; + try + { + window.SetEglConfig( true, true, 0, Dali::GlWindow::GlesVersion::VERSION_2_0 ); + + DALI_TEST_CHECK( false); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowSetEglConfigGles30(void) +{ + Dali::GlWindow window; + try + { + window.SetEglConfig( true, true, 0, Dali::GlWindow::GlesVersion::VERSION_3_0 ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowRaise(void) +{ + Dali::GlWindow window; + + try + { + window.Raise(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowLower(void) +{ + Dali::GlWindow window; + + try + { + window.Lower(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowActivate(void) +{ + Dali::GlWindow window; + + try + { + window.Activate(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowShow(void) +{ + Dali::GlWindow window; + + try + { + window.Show(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowHide(void) +{ + Dali::GlWindow window; + + try + { + window.Hide(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowSetGetPositionSize(void) +{ + Dali::GlWindow window; + + try + { + PositionSize setPositionSize( 0, 0, 100, 100); + window.SetPositionSize( setPositionSize ); + PositionSize getPositionSize = window.GetPositionSize(); + DALI_TEST_CHECK( setPositionSize == getPositionSize ); + + setPositionSize.x = 10; + setPositionSize.y = 20; + window.SetPositionSize( setPositionSize ); + getPositionSize = window.GetPositionSize(); + DALI_TEST_CHECK( setPositionSize == getPositionSize ); + + setPositionSize.width = 50; + setPositionSize.height = 50; + window.SetPositionSize( setPositionSize ); + getPositionSize = window.GetPositionSize(); + DALI_TEST_CHECK( setPositionSize == getPositionSize ); + + setPositionSize.x = 0; + setPositionSize.y = 0; + setPositionSize.width = 100; + setPositionSize.height = 100; + window.SetPositionSize( setPositionSize ); + getPositionSize = window.GetPositionSize(); + DALI_TEST_CHECK( setPositionSize == getPositionSize ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowSetInputRegion(void) +{ + Dali::GlWindow window; + + try + { + window.SetInputRegion( Rect< int >( 0, 0, 100, 10 ) ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowOpaqueState(void) +{ + Dali::GlWindow window; + + try + { + bool opaquestate = window.IsOpaqueState(); + DALI_TEST_CHECK( opaquestate == true ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowSetAvailableOrientations(void) +{ + Dali::GlWindow window; + + try + { + Dali::Vector< Dali::GlWindow::GlWindowOrientation> orientations; + orientations.PushBack( Dali::GlWindow::GlWindowOrientation::PORTRAIT ); + orientations.PushBack( Dali::GlWindow::GlWindowOrientation::LANDSCAPE ); + orientations.PushBack( Dali::GlWindow::GlWindowOrientation::PORTRAIT_INVERSE ); + orientations.PushBack( Dali::GlWindow::GlWindowOrientation::LANDSCAPE_INVERSE ); + orientations.PushBack( Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE ); + orientations.PushBack( Dali::GlWindow::GlWindowOrientation::PORTRAIT ); + orientations.PushBack( Dali::GlWindow::GlWindowOrientation::LANDSCAPE ); + orientations.PushBack( Dali::GlWindow::GlWindowOrientation::PORTRAIT_INVERSE ); + window.SetAvailableOrientations(orientations); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowSetPreferredOrientation(void) +{ + Dali::GlWindow window; + + try + { + window.SetPreferredOrientation(Dali::GlWindow::GlWindowOrientation::PORTRAIT); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowSetPreferredOrientation1(void) +{ + Dali::GlWindow window; + + try + { + window.SetPreferredOrientation(Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliWindowGetCurrentOrientation(void) +{ + Dali::GlWindow window; + + try + { + Dali::GlWindow::GlWindowOrientation orientation = window.GetCurrentOrientation(); + DALI_TEST_CHECK( orientation == Dali::GlWindow::GlWindowOrientation::PORTRAIT ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +// Internal callback function +void glInit() +{ +} + +void glRenderFrame() +{ +} + +void glTerminate() +{ +} + +int UtcDaliGlWindowRegisterGlCallback(void) +{ + Dali::GlWindow window; + + try + { + window.RegisterGlCallback( glInit, glRenderFrame, glTerminate ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowRenderOnce(void) +{ + Dali::GlWindow window; + + try + { + window.RegisterGlCallback( glInit, glRenderFrame, glTerminate ); + window.RenderOnce(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowGetSupportedAuxiliaryHintCount(void) +{ + Dali::GlWindow window; + + try + { + window.GetSupportedAuxiliaryHintCount(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowGetSupportedAuxiliaryHint(void) +{ + Dali::GlWindow window; + + try + { + window.GetSupportedAuxiliaryHint( 0 ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowAddAuxiliaryHint(void) +{ + Dali::GlWindow window; + + try + { + window.AddAuxiliaryHint( "stack_pop_to", "1" ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowRemoveAuxiliaryHint(void) +{ + Dali::GlWindow window; + + try + { + window.RemoveAuxiliaryHint( 0 ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowSetAuxiliaryHintValue(void) +{ + Dali::GlWindow window; + + try + { + window.SetAuxiliaryHintValue( 0, "0" ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowGetAuxiliaryHintValue(void) +{ + Dali::GlWindow window; + + try + { + window.GetAuxiliaryHintValue( 0 ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowGetAuxiliaryHintId(void) +{ + Dali::GlWindow window; + + try + { + window.GetAuxiliaryHintId( "0" ); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowFocusChangeSignal(void) +{ + Dali::GlWindow window; + + try + { + window.FocusChangeSignal(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowResizeSignal(void) +{ + Dali::GlWindow window; + + try + { + window.ResizeSignal(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowKeyEventSignal(void) +{ + Dali::GlWindow window; + + try + { + window.KeyEventSignal(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowTouchedSignal(void) +{ + Dali::GlWindow window; + + try + { + window.TouchedSignal(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} + +int UtcDaliGlWindowVisibilityChangedSignal(void) +{ + Dali::GlWindow window; + + try + { + window.VisibilityChangedSignal(); + + DALI_TEST_CHECK( false ); + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + END_TEST; +} diff --git a/dali/devel-api/adaptor-framework/gl-window.cpp b/dali/devel-api/adaptor-framework/gl-window.cpp new file mode 100644 index 0000000..bbad021 --- /dev/null +++ b/dali/devel-api/adaptor-framework/gl-window.cpp @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2020 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. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +GlWindow GlWindow::New() +{ + PositionSize positionSize( 0, 0, 0, 0 ); + return Dali::GlWindow::New( positionSize, "", "", false ); +} +GlWindow GlWindow::New(PositionSize positionSize, const std::string& name, const std::string& className, bool isTransparent ) +{ + GlWindow newWindow; + Internal::Adaptor::GlWindow* window = Internal::Adaptor::GlWindow::New( positionSize, name, className, isTransparent ); + newWindow = GlWindow(window); + + const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable(); + if( isAdaptorAvailable ) + { + Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get(); + Dali::WindowContainer windows = adaptor.GetWindows(); + if( !windows.empty() ) + { + window->SetChild( windows[0] ); + } + } + return newWindow; +} +GlWindow::GlWindow() +{ +} +GlWindow::~GlWindow() +{ +} + +GlWindow::GlWindow(const GlWindow& handle) = default; + +GlWindow& GlWindow::operator=(const GlWindow& rhs) = default; + +GlWindow::GlWindow(GlWindow&& rhs) = default; + +GlWindow& GlWindow::operator=(GlWindow&& rhs) = default; + +void GlWindow::SetEglConfig( bool depth, bool stencil, int msaa, GlesVersion version ) +{ + GetImplementation(*this).SetEglConfig( depth, stencil, msaa, version ); +} +void GlWindow::Raise() +{ + GetImplementation(*this).Raise(); +} +void GlWindow::Lower() +{ + GetImplementation(*this).Lower(); +} +void GlWindow::Activate() +{ + GetImplementation(*this).Activate(); +} +void GlWindow::Show() +{ + GetImplementation(*this).Show(); +} +void GlWindow::Hide() +{ + GetImplementation(*this).Hide(); +} +unsigned int GlWindow::GetSupportedAuxiliaryHintCount() const +{ + return GetImplementation(*this).GetSupportedAuxiliaryHintCount(); +} +std::string GlWindow::GetSupportedAuxiliaryHint( unsigned int index ) const +{ + return GetImplementation(*this).GetSupportedAuxiliaryHint( index ); +} +unsigned int GlWindow::AddAuxiliaryHint( const std::string& hint, const std::string& value ) +{ + return GetImplementation(*this).AddAuxiliaryHint( hint, value ); +} +bool GlWindow::RemoveAuxiliaryHint( unsigned int id ) +{ + return GetImplementation(*this).RemoveAuxiliaryHint( id ); +} +bool GlWindow::SetAuxiliaryHintValue( unsigned int id, const std::string& value ) +{ + return GetImplementation(*this).SetAuxiliaryHintValue( id, value ); +} +std::string GlWindow::GetAuxiliaryHintValue( unsigned int id ) const +{ + return GetImplementation(*this).GetAuxiliaryHintValue( id ); +} +unsigned int GlWindow::GetAuxiliaryHintId( const std::string& hint ) const +{ + return GetImplementation(*this).GetAuxiliaryHintId( hint ); +} +void GlWindow::SetInputRegion( const Rect< int >& inputRegion ) +{ + GetImplementation(*this).SetInputRegion( inputRegion ); +} +void GlWindow::SetOpaqueState( bool opaque ) +{ + GetImplementation(*this).SetOpaqueState( opaque ); +} +bool GlWindow::IsOpaqueState() const +{ + return GetImplementation(*this).IsOpaqueState(); +} +void GlWindow::SetPositionSize( PositionSize positionSize ) +{ + GetImplementation(*this).SetPositionSize( positionSize ); +} +PositionSize GlWindow::GetPositionSize() const +{ + return GetImplementation(*this).GetPositionSize(); +} +Dali::GlWindow::GlWindowOrientation GlWindow::GetCurrentOrientation() const +{ + return GetImplementation( *this ).GetCurrentOrientation(); +} +void GlWindow::SetAvailableOrientations( const Dali::Vector< Dali::GlWindow::GlWindowOrientation >& orientations ) +{ + GetImplementation( *this ).SetAvailableOrientations( orientations ); +} +void GlWindow::SetPreferredOrientation( Dali::GlWindow::GlWindowOrientation orientation ) +{ + GetImplementation(*this).SetPreferredOrientation( orientation ); +} +void GlWindow::RegisterGlCallback( GlInitialize glInit, GlRenderFrame glRenderFrame, GlTerminate glTerminate ) +{ + GetImplementation(*this).RegisterGlCallback( glInit, glRenderFrame, glTerminate ); +} +void GlWindow::RenderOnce() +{ + GetImplementation(*this).RenderOnce(); +} +GlWindow::FocusChangeSignalType& GlWindow::FocusChangeSignal() +{ + return GetImplementation(*this).FocusChangeSignal(); +} +GlWindow::ResizeSignalType& GlWindow::ResizeSignal() +{ + return GetImplementation(*this).ResizeSignal(); +} +GlWindow::KeyEventSignalType& GlWindow::KeyEventSignal() +{ + return GetImplementation(*this).KeyEventSignal(); +} +GlWindow::TouchEventSignalType& GlWindow::TouchedSignal() +{ + return GetImplementation(*this).TouchedSignal(); +} +GlWindow::VisibilityChangedSignalType& GlWindow::VisibilityChangedSignal() +{ + return GetImplementation(*this).VisibilityChangedSignal(); +} +GlWindow::GlWindow( Internal::Adaptor::GlWindow* window ) +: BaseHandle( window ) +{ +} + +}// Dali diff --git a/dali/devel-api/adaptor-framework/gl-window.h b/dali/devel-api/adaptor-framework/gl-window.h new file mode 100644 index 0000000..1efc014 --- /dev/null +++ b/dali/devel-api/adaptor-framework/gl-window.h @@ -0,0 +1,454 @@ +#ifndef DALI_GL_WINDOW_H +#define DALI_GL_WINDOW_H + +/* + * Copyright (c) 2020 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +/** + * @addtogroup dali_adaptor_framework + * @{ + */ + +typedef Dali::Rect PositionSize; + +namespace Internal DALI_INTERNAL +{ +namespace Adaptor +{ +class GlWindow; +} +} + +namespace +{ +typedef void (*GlInitialize)(); +typedef void (*GlRenderFrame)(); +typedef void (*GlTerminate)(); +} + +class TouchEvent; +class KeyEvent; + +/** + * @brief The GlWindow class is to draw with native GLES. + * + * This class is the special window. It is for native GLES application. + * So, some special funtions and type are supported. + * In addition, basic window's functions are supported, too. + * + */ +class DALI_ADAPTOR_API GlWindow : public BaseHandle +{ +public: + + using WindowSize = Uint16Pair ; + + typedef Signal< void ( const KeyEvent& ) > KeyEventSignalType; ///< GlWindow Key Event signal type + typedef Signal< void ( const TouchEvent& ) > TouchEventSignalType; ///< GlWindow Touch Event signal type + typedef Signal< void ( GlWindow, bool ) > FocusChangeSignalType; ///< GlWindow Focus signal type + typedef Signal< void ( WindowSize ) > ResizeSignalType; ///< GlWindow resize signal type + typedef Signal< void ( GlWindow, bool ) > VisibilityChangedSignalType; ///< GlWindow visibility change signal type + +public: + + // Enumerations + + /** + * @brief Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing. + * + * This Enumeration is used the available orientation APIs and the preferred orientation. + * + */ + enum class GlWindowOrientation + { + PORTRAIT = 0, ///< Portrait orientation. The height of the display area is greater than the width. + LANDSCAPE = 1, ///< Landscape orientation. A wide view area is needed. + PORTRAIT_INVERSE = 2, ///< Portrait inverse orientation + LANDSCAPE_INVERSE = 3, ///< Landscape inverse orientation + NO_ORIENTATION_PREFERENCE = -1 ///< Invalid angle value. It is used to initialize or unset the preferred orientation. + }; + + /** + * @brief Enumeration for GLES verion + * + * This Enumeration is used the GLES version for EGL configuration. + * If the device can not support GLES version 3.0 over, the version will be chosen with GLES version 2.0 + * + */ + enum class GlesVersion + { + VERSION_2_0 = 0, ///< GLES version 2.0 + VERSION_3_0, ///< GLES version 3.0 + }; + + /** + * @brief Creates an initialized handle to a new GlWindow. + * + * @return A new GlWindow + * @note This creates an extra GlWindow in addition to the default main GlWindow + */ + static GlWindow New(); + + /** + * @brief Creates an initialized handle to a new GlWindow. + * + * @param[in] positionSize The position and size of the GlWindow + * @param[in] name The GlWindow title + * @param[in] className The GlWindow class name + * @param[in] isTransparent Whether GlWindow is transparent + * @note This creates an extra GlWindow in addition to the default main GlWindow + * @return A new GlWindow + */ + static GlWindow New( PositionSize positionSize, const std::string& name, const std::string& className, bool isTransparent = false ); + + /** + * @brief Creates an uninitialized handle. + * + * This can be initialized using Dali::Application::GetGlWindow() or + * Dali::GlWindow::New(). + * + */ + GlWindow(); + + /** + * @brief Destructor. + * + * This is non-virtual since derived Handle types must not contain data or virtual methods. + * + */ + ~GlWindow(); + + /** + * @brief This copy constructor is required for (smart) pointer semantics. + * + * @param[in] handle A reference to the copied handle + */ + GlWindow(const GlWindow& handle); + + /** + * @brief This assignment operator is required for (smart) pointer semantics. + * + * @param[in] rhs A reference to the copied handle + * @return A reference to this + */ + GlWindow& operator=(const GlWindow& rhs); + + /** + * @brief Move constructor. + * + * @param[in] rhs A reference to the moved handle + */ + GlWindow(GlWindow&& rhs); + + /** + * @brief Move assignment operator. + * + * @param[in] rhs A reference to the moved handle + * @return A reference to this handle + */ + GlWindow& operator=(GlWindow&& rhs); + + /** + * @brief Sets egl configuration for GlWindow + * + * @param[in] depth the flag of depth buffer. If true is set, 24bit depth buffer is enabled. + * @param[in] stencil the flag of stencil. it true is set, 8bit stencil buffer is enabled. + * @param[in] msaa the bit of msaa. + * @param[in] version the GLES version + * + */ + void SetEglConfig( bool depth, bool stencil, int msaa, GlesVersion version ); + + /** + * @brief Raises GlWindow to the top of GlWindow stack. + * + */ + void Raise(); + + /** + * @brief Lowers GlWindow to the bottom of GlWindow stack. + * + */ + void Lower(); + + /** + * @brief Activates GlWindow to the top of GlWindow stack even it is iconified. + * + */ + void Activate(); + + /** + * @brief Shows the GlWindow if it is hidden. + * + */ + void Show(); + + /** + * @brief Hides the GlWindow if it is showing. + * + */ + void Hide(); + + /** + * @brief Sets a position of the GlWindow. + * + * @param[in] positionSize The new GlWindow position + */ + void SetPositionSize( PositionSize positionSize ); + + /** + * @brief Gets a position of the GlWindow. + * + * @return The position of the GlWindow + */ + PositionSize GetPositionSize() const; + + /** + * @brief Gets the count of supported auxiliary hints of the window. + * + * @return The number of supported auxiliary hints. + * + * @note The window auxiliary hint is the value which is used to decide which actions should be made available to the user by the window manager. + * If you want to set specific hint to your window, then you should check whether it exists in the supported auxiliary hints. + */ + unsigned int GetSupportedAuxiliaryHintCount() const; + + /** + * @brief Gets the supported auxiliary hint string of the window. + * + * @param[in] index The index of the supported auxiliary hint lists + * @return The auxiliary hint string of the index. + * + * @note The window auxiliary hint is the value which is used to decide which actions should be made available to the user by the window manager. + * If you want to set specific hint to your window, then you should check whether it exists in the supported auxiliary hints. + */ + std::string GetSupportedAuxiliaryHint( unsigned int index ) const; + + /** + * @brief Creates an auxiliary hint of the window. + * + * @param[in] hint The auxiliary hint string. + * @param[in] value The value string. + * @return The ID of created auxiliary hint, or @c 0 on failure. + */ + unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ); + + /** + * @brief Removes an auxiliary hint of the window. + * + * @param[in] id The ID of the auxiliary hint. + * @return True if no error occurred, false otherwise. + */ + bool RemoveAuxiliaryHint( unsigned int id ); + + /** + * @brief Changes a value of the auxiliary hint. + * + * @param[in] id The auxiliary hint ID. + * @param[in] value The value string to be set. + * @return True if no error occurred, false otherwise. + */ + bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ); + + /** + * @brief Gets a value of the auxiliary hint. + * + * @param[in] id The auxiliary hint ID. + * @return The string value of the auxiliary hint ID, or an empty string if none exists. + */ + std::string GetAuxiliaryHintValue( unsigned int id ) const; + + /** + * @brief Gets a ID of the auxiliary hint string. + * + * @param[in] hint The auxiliary hint string. + * @return The ID of the auxiliary hint string, or @c 0 if none exists. + */ + unsigned int GetAuxiliaryHintId( const std::string& hint ) const; + + /** + * @brief Sets a region to accept input events. + * + * @param[in] inputRegion The region to accept input events. + */ + void SetInputRegion( const Rect< int >& inputRegion ); + + /** + * @brief Sets a transparent window's visual state to opaque. + * @details If a visual state of a transparent window is opaque, + * then the window manager could handle it as an opaque window when calculating visibility. + * + * @param[in] opaque Whether the window's visual state is opaque. + * @remarks This will have no effect on an opaque window. + * It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window. + */ + void SetOpaqueState( bool opaque ); + + /** + * @brief Returns whether a transparent window's visual state is opaque or not. + * + * @return True if the window's visual state is opaque, false otherwise. + * @remarks The return value has no meaning on an opaque window. + */ + bool IsOpaqueState() const; + + /** + * @brief Gets current rotation angle of the window. + * + * @return The current GlWindow rotation angle if previously set, or none + */ + Dali::GlWindow::GlWindowOrientation GetCurrentOrientation() const; + + /** + * @brief Sets available orientations of the window. + * + * This API is for setting several orientations one time. + * + * @param[in] orientations The available orientations list to add + */ + void SetAvailableOrientations( const Dali::Vector& orientations ); + + /** + * @brief Sets a preferred orientation. + * + * @param[in] orientation The preferred orientation + * @pre angle is in the list of available orientation. + * + * @note To unset the preferred orientation, angle should be set NO_ORIENTATION_PREFERENCE. + */ + void SetPreferredOrientation( Dali::GlWindow::GlWindowOrientation orientation ); + + /** + * @brief Registers a GL callback function for application. + * + * @param[in] glInit the callback function for application initialize + * @param[in] glRenderFrame the callback function to render to the frame. + * @param[in] glTerminate the callback function to clean-up application GL resource. + * + */ + void RegisterGlCallback( GlInitialize glInit, GlRenderFrame glRenderFrame, GlTerminate glTerminate ); + + /** + * @brief Renders once more even if GL render functions are not added to idler. + * @note Will not work if the window is hidden or GL render functions are added to idler + * + */ + void RenderOnce(); + +public: // Signals + + /** + * @brief The user should connect to this signal to get a timing when GlWindow gains focus or loses focus. + * + * A callback of the following type may be connected: + * @code + * void YourCallbackName( GlWindow GlWindow, bool focusIn ); + * @endcode + * The parameter is true if GlWindow gains focus, otherwise false. + * and GlWindow means this signal was called from what GlWindow + * + * @return The signal to connect to + */ + FocusChangeSignalType& FocusChangeSignal(); + + /** + * @brief This signal is emitted when the GlWindow is resized. + * + * A callback of the following type may be connected: + * @code + * void YourCallbackName( GlWindow GlWindow, int width, int height ); + * @endcode + * The parameters are the resized width and height. + * and GlWindow means this signal was called from what GlWindow + * + * @return The signal to connect to + */ + ResizeSignalType& ResizeSignal(); + + /** + * @brief This signal is emitted when key event is received. + * + * A callback of the following type may be connected: + * @code + * void YourCallbackName(const KeyEvent& event); + * @endcode + * + * @return The signal to connect to + */ + KeyEventSignalType& KeyEventSignal(); + + /** + * @brief This signal is emitted when the screen is touched and when the touch ends + * (i.e. the down & up touch events only). + * + * If there are multiple touch points, then this will be emitted when the first touch occurs and + * then when the last finger is lifted. + * An interrupted event will also be emitted (if it occurs). + * A callback of the following type may be connected: + * @code + * void YourCallbackName(const TouchEvent& event); + * @endcode + * + * @return The touch signal to connect to + * + * @note Motion events are not emitted. + */ + TouchEventSignalType& TouchedSignal(); + + /** + * @brief This signal is emitted when the window is shown or hidden. + * + * A callback of the following type may be connected: + * @code + * void YourCallbackName( Window window, bool visible ); + * @endcode + * + * @return The signal to connect to + */ + VisibilityChangedSignalType& VisibilityChangedSignal(); + +public: // Not intended for application developers + /// @cond internal + /** + * @brief This constructor is used by Dali::Application::GetGlWindow(). + * @param[in] GlWindow A pointer to the GlWindow + */ + explicit DALI_INTERNAL GlWindow( Internal::Adaptor::GlWindow* GlWindow ); + /// @endcond +}; + +/** + * @} + */ +} // namespace Dali + +#endif // DALI_GL_WINDOW_H diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 91c5cee..bfbccb5 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -34,6 +34,7 @@ SET( devel_api_src_files ${adaptor_devel_api_dir}/adaptor-framework/thread-settings.cpp ${adaptor_devel_api_dir}/adaptor-framework/web-engine.cpp ${adaptor_devel_api_dir}/adaptor-framework/window-devel.cpp + ${adaptor_devel_api_dir}/adaptor-framework/gl-window.cpp ) @@ -86,6 +87,7 @@ SET( devel_api_adaptor_framework_header_files ${adaptor_devel_api_dir}/adaptor-framework/window-devel.h ${adaptor_devel_api_dir}/adaptor-framework/component-application.h ${adaptor_devel_api_dir}/adaptor-framework/video-sync-mode.h + ${adaptor_devel_api_dir}/adaptor-framework/gl-window.h ) diff --git a/dali/internal/graphics/gles/egl-graphics.cpp b/dali/internal/graphics/gles/egl-graphics.cpp index dcbf055..f78176b 100644 --- a/dali/internal/graphics/gles/egl-graphics.cpp +++ b/dali/internal/graphics/gles/egl-graphics.cpp @@ -71,6 +71,18 @@ void EglGraphics::Initialize( EnvironmentOptions* environmentOptions ) mEglContextHelper = Utils::MakeUnique< EglContextHelperImplementation >(); } +void EglGraphics::Initialize( bool depth, bool stencil, int msaa ) +{ + mDepthBufferRequired = static_cast< Integration::DepthBufferAvailable >( depth ); + mStencilBufferRequired = static_cast< Integration::StencilBufferAvailable >( stencil ); + + mMultiSamplingLevel = msaa; + + mEglSync = std::unique_ptr( new EglSyncImplementation() ); + + mEglContextHelper = std::unique_ptr( new EglContextHelperImplementation() ); +} + EglInterface* EglGraphics::Create() { mEglImplementation = Utils::MakeUnique< EglImplementation >( mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired, mPartialUpdateRequired ); diff --git a/dali/internal/graphics/gles/egl-graphics.h b/dali/internal/graphics/gles/egl-graphics.h index 8ee45bc..7476f94 100644 --- a/dali/internal/graphics/gles/egl-graphics.h +++ b/dali/internal/graphics/gles/egl-graphics.h @@ -57,6 +57,14 @@ public: void Initialize( EnvironmentOptions* environmentOptions ) override; /** + * Initialize the graphics interface with specific input parameters + * @param[in] depth The flag to enable depth buffer + * @param[in] stencil The flag to enable stencil buffer + * @param[in] msaa The value of multi sampleing bit + */ + void Initialize( bool depth, bool stencil, int msaa ); + + /** * Creates the graphics interface for EGL * @return The graphics interface for EGL */ diff --git a/dali/internal/window-system/common/event-handler.cpp b/dali/internal/window-system/common/event-handler.cpp index 7a1d02b..911a3bd 100755 --- a/dali/internal/window-system/common/event-handler.cpp +++ b/dali/internal/window-system/common/event-handler.cpp @@ -95,7 +95,7 @@ static uint32_t GetCurrentMilliSeconds(void) } // unnamed namespace #endif -EventHandler::EventHandler( WindowRenderSurface* surface, DamageObserver& damageObserver ) +EventHandler::EventHandler( WindowBase* windowBase, DamageObserver& damageObserver ) : mStyleMonitor( StyleMonitor::Get() ), mDamageObserver( damageObserver ), mAccessibilityAdaptor( AccessibilityAdaptor::Get() ), @@ -103,11 +103,9 @@ EventHandler::EventHandler( WindowRenderSurface* surface, DamageObserver& damage mClipboard( Clipboard::Get() ), mPaused( false ) { - if( surface ) + // Connect signals + if( windowBase ) { - WindowBase* windowBase = surface->GetWindowBase(); - - // Connect signals windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged ); windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged ); windowBase->RotationSignal().Connect( this, &EventHandler::OnRotation ); @@ -119,6 +117,10 @@ EventHandler::EventHandler( WindowRenderSurface* surface, DamageObserver& damage windowBase->StyleChangedSignal().Connect( this, &EventHandler::OnStyleChanged ); windowBase->AccessibilitySignal().Connect( this, &EventHandler::OnAccessibilityNotification ); } + else + { + DALI_LOG_ERROR("WindowBase is invalid!!!\n"); + } } EventHandler::~EventHandler() diff --git a/dali/internal/window-system/common/event-handler.h b/dali/internal/window-system/common/event-handler.h index 71f4ca5..ba23ce3 100644 --- a/dali/internal/window-system/common/event-handler.h +++ b/dali/internal/window-system/common/event-handler.h @@ -111,10 +111,10 @@ public: /** * Constructor. - * @param[in] surface The render surface of the window. + * @param[in] windowBase The window base to be handled * @param[in] damageObserver The damage observer (to pass damage events to). */ - EventHandler( WindowRenderSurface* surface, DamageObserver& damageObserver ); + EventHandler( WindowBase* windowBase, DamageObserver& damageObserver ); /** * Destructor. diff --git a/dali/internal/window-system/common/gl-window-impl.cpp b/dali/internal/window-system/common/gl-window-impl.cpp new file mode 100644 index 0000000..33952ea --- /dev/null +++ b/dali/internal/window-system/common/gl-window-impl.cpp @@ -0,0 +1,891 @@ +/* + * Copyright (c) 2020 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. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL HEADERS +#include +#include +#include +#include +#include +#include + +// INTERNAL HEADERS +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +namespace +{ +const int MINIMUM_DIMENSION_CHANGE( 1 ); + +#if defined(DEBUG_ENABLED) +Debug::Filter* gWindowLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW" ); +#endif + +} // unnamed namespace + +GlWindow* GlWindow::New( const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent ) +{ + GlWindow* window = new GlWindow(); + window->mIsTransparent = isTransparent; + window->Initialize( positionSize, name, className ); + return window; +} + +GlWindow::GlWindow() +: mWindowBase(), + mGraphics(), + mDisplayConnection( nullptr ), + mEventHandler( nullptr ), + mPositionSize(), + mColorDepth( COLOR_DEPTH_24 ), + mIsTransparent( false ), + mIsFocusAcceptable( false ), + mIconified( false ), + mOpaqueState( false ), + mResizeEnabled( false ), + mVisible( false ), + mIsRotated( false ), + mIsWindowRotated( false ), + mIsTouched( false ), + mAvailableAngles(), + mPreferredAngle( 0 ), + mTotalRotationAngle( 0 ), + mWindowRotationAngle( 0 ), + mScreenRotationAngle( 0 ), + mOrientationMode( 0 ), + mWindowWidth( 0 ), + mWindowHeight( 0 ), + mNativeWindowId( -1 ), + mKeyEventSignal(), + mTouchedSignal(), + mFocusChangeSignal(), + mResizeSignal(), + mVisibilityChangedSignal(), + mGLInitCallback( 0 ), + mGLRenderFrameCallback( 0 ), + mGLTerminateCallback( 0 ), + mGLRenderCallback( nullptr ), + mEGLSurface( nullptr ), + mEGLContext( nullptr ), + mGLESVersion( Dali::GlWindow::GlesVersion::VERSION_3_0 ), + mInitCallback( false ), + mDepth( false ), + mStencil( false ), + mIsEGLInitialize( false ), + mMSAA( 0 ) +{ +} + +GlWindow::~GlWindow() +{ + if( mEventHandler ) + { + mEventHandler->RemoveObserver( *this ); + } + + if( mGLTerminateCallback ) + { + mGLTerminateCallback(); + } + + if( mIsEGLInitialize ) + { + GraphicsInterface* graphics = mGraphics.get(); + EglGraphics *eglGraphics = static_cast( graphics ); + Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + + if( mEGLSurface ) + { + eglImpl.DestroySurface( mEGLSurface ); + mEGLSurface = nullptr; + } + + if( mEGLContext ) + { + eglImpl.DestroyContext( mEGLContext ); + mEGLContext = nullptr; + } + + eglImpl.TerminateGles(); + + mGraphics->Destroy(); + } +} + +void GlWindow::Initialize( const PositionSize& positionSize, const std::string& name, const std::string& className ) +{ + int screenWidth, screenHeight; + + mPositionSize = positionSize; + WindowSystem::GetScreenSize( screenWidth, screenHeight ); + if ( (mPositionSize.width == 0) || (mPositionSize.height == 0) ) + { + mPositionSize.x = 0; + mPositionSize.y = 0; + mPositionSize.width = screenWidth; + mPositionSize.height = screenHeight; + } + + if( screenWidth > screenHeight ) + { + mOrientationMode = 1; // Default mode is landscape + } + else + { + mOrientationMode = 0; // Default mode is portrate + } + + // Create a window base + auto windowFactory = Dali::Internal::Adaptor::GetWindowFactory(); + Any surface; + mWindowBase = windowFactory->CreateWindowBase( mPositionSize, surface, ( mIsTransparent ? true : false ) ); + mWindowBase->IconifyChangedSignal().Connect( this, &GlWindow::OnIconifyChanged ); + mWindowBase->FocusChangedSignal().Connect( this, &GlWindow::OnFocusChanged ); + + if( Dali::Adaptor::IsAvailable() ) + { + SetEventHandler(); + } + + if( !mPositionSize.IsEmpty() ) + { + AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" ); + mResizeEnabled = true; + } + + mWindowBase->Show(); + + if( mIsTransparent ) + { + mColorDepth = COLOR_DEPTH_32; + } + else + { + mColorDepth = COLOR_DEPTH_24; + } + + SetClass( name, className ); + + // For Debugging + mNativeWindowId = mWindowBase->GetNativeWindowId(); +} + +void GlWindow::SetEventHandler() +{ + mEventHandler = EventHandlerPtr( new EventHandler( mWindowBase.get(), *this ) ); + mEventHandler->AddObserver( *this ); +} + +void GlWindow::SetClass( const std::string& name, const std::string className ) +{ + mName = name; + mClassName = className; + mWindowBase->SetClass( name, className ); +} + +void GlWindow::SetEglConfig( bool depth, bool stencil, int msaa, Dali::GlWindow::GlesVersion version ) +{ + // Init Graphics + mDepth = depth; + mStencil = stencil; + mMSAA = msaa; + mGLESVersion = version; + + InitializeGraphics(); +} + +void GlWindow::Raise() +{ + mWindowBase->Raise(); + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId ); +} + +void GlWindow::Lower() +{ + mWindowBase->Lower(); + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId ); +} + +void GlWindow::Activate() +{ + mWindowBase->Activate(); + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId ); +} + +void GlWindow::Show() +{ + mVisible = true; + + mWindowBase->Show(); + + if( !mIconified ) + { + Dali::GlWindow handle( this ); + mVisibilityChangedSignal.Emit( handle, true ); + } + + if( mEventHandler ) + { + mEventHandler->Resume(); + } + + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible ); +} + +void GlWindow::Hide() +{ + mVisible = false; + + mWindowBase->Hide(); + + if( !mIconified ) + { + Dali::GlWindow handle( this ); + mVisibilityChangedSignal.Emit( handle, false ); + } + + if( mEventHandler ) + { + mEventHandler->Pause(); + } + + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible ); +} + +unsigned int GlWindow::GetSupportedAuxiliaryHintCount() const +{ + return mWindowBase->GetSupportedAuxiliaryHintCount(); +} + +std::string GlWindow::GetSupportedAuxiliaryHint( unsigned int index ) const +{ + return mWindowBase->GetSupportedAuxiliaryHint( index ); +} + +unsigned int GlWindow::AddAuxiliaryHint( const std::string& hint, const std::string& value ) +{ + return mWindowBase->AddAuxiliaryHint( hint, value ); +} + +bool GlWindow::RemoveAuxiliaryHint( unsigned int id ) +{ + return mWindowBase->RemoveAuxiliaryHint( id ); +} + +bool GlWindow::SetAuxiliaryHintValue( unsigned int id, const std::string& value ) +{ + return mWindowBase->SetAuxiliaryHintValue( id, value ); +} + +std::string GlWindow::GetAuxiliaryHintValue( unsigned int id ) const +{ + return mWindowBase->GetAuxiliaryHintValue( id ); +} + +unsigned int GlWindow::GetAuxiliaryHintId( const std::string& hint ) const +{ + return mWindowBase->GetAuxiliaryHintId( hint ); +} + +void GlWindow::SetInputRegion( const Rect< int >& inputRegion ) +{ + mWindowBase->SetInputRegion( inputRegion ); + + DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "GlWindow::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height ); +} + +void GlWindow::SetOpaqueState( bool opaque ) +{ + mOpaqueState = opaque; + + mWindowBase->SetOpaqueState( opaque ); + + DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "GlWindow::SetOpaqueState: opaque = %d\n", opaque ); +} + +bool GlWindow::IsOpaqueState() const +{ + return mOpaqueState; +} + +void GlWindow::SetPositionSize( PositionSize positionSize ) +{ + if( !mResizeEnabled ) + { + AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" ); + mResizeEnabled = true; + } + + bool needToMove = false; + bool needToResize = false; + + // Check moving + if( (fabs(positionSize.x - mPositionSize.x) > MINIMUM_DIMENSION_CHANGE) || + (fabs(positionSize.y - mPositionSize.y) > MINIMUM_DIMENSION_CHANGE) ) + { + needToMove = true; + } + + // Check resizing + if( (fabs(positionSize.width - mPositionSize.width) > MINIMUM_DIMENSION_CHANGE) || + (fabs(positionSize.height - mPositionSize.height) > MINIMUM_DIMENSION_CHANGE) ) + { + needToResize = true; + } + + if( needToResize ) + { + if( needToMove ) + { + mWindowBase->MoveResize( positionSize ); + } + else + { + mWindowBase->Resize( positionSize ); + } + mPositionSize = positionSize; + } + else + { + if( needToMove ) + { + mWindowBase->Move( positionSize ); + mPositionSize = positionSize; + } + } + + // If window's size or position is changed, the signal will be emitted to user. + if( ( needToMove ) || ( needToResize ) ) + { + Uint16Pair newSize( mPositionSize.width, mPositionSize.height ); + Dali::GlWindow handle( this ); + mResizeSignal.Emit( newSize ); + } +} + +PositionSize GlWindow::GetPositionSize() const +{ + PositionSize positionSize( mPositionSize ); + if( mTotalRotationAngle == 90 || mTotalRotationAngle == 270 ) + { + positionSize.height = mPositionSize.width; + positionSize.width = mPositionSize.height; + } + + return positionSize; +} + +void GlWindow::OnIconifyChanged( bool iconified ) +{ + if( iconified ) + { + mIconified = true; + + if( mVisible ) + { + Dali::GlWindow handle( this ); + mVisibilityChangedSignal.Emit( handle, false ); + } + + if( mEventHandler ) + { + mEventHandler->Pause(); + } + + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible ); + } + else + { + mIconified = false; + + if( mVisible ) + { + Dali::GlWindow handle( this ); + mVisibilityChangedSignal.Emit( handle, true ); + } + + if( mEventHandler ) + { + mEventHandler->Resume(); + } + + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible ); + } +} + +void GlWindow::OnFocusChanged( bool focusIn ) +{ + Dali::GlWindow handle( this ); + mFocusChangeSignal.Emit( handle, focusIn ); +} + +void GlWindow::OnOutputTransformed() +{ + int screenRotationAngle = mWindowBase->GetScreenRotationAngle(); + if( screenRotationAngle != mScreenRotationAngle ) + { + mScreenRotationAngle = screenRotationAngle; + mTotalRotationAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360; + + if( mTotalRotationAngle == 90 || mTotalRotationAngle == 270 ) + { + mWindowWidth = mPositionSize.height; + mWindowHeight = mPositionSize.width; + } + else + { + mWindowWidth = mPositionSize.width; + mWindowHeight = mPositionSize.height; + } + + // Emit Resize signal + Dali::GlWindow handle( this ); + mResizeSignal.Emit( Dali::Uint16Pair( mWindowWidth, mWindowHeight ) ); + } +} + +void GlWindow::OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) +{ + PointState::Type state = point.GetState(); + + if( state == PointState::DOWN ) + { + mIsTouched = true; + } + + if( state == PointState::UP ) + { + mIsTouched = false; + } + + if( !mIsTouched && state == PointState::MOTION ) + { + return; + } + + RecalculateTouchPosition( point ); + Dali::TouchEvent touchEvent = Dali::Integration::NewTouchEvent( timeStamp, point ); + Dali::GlWindow handle( this ); + mTouchedSignal.Emit( touchEvent ); +} + +void GlWindow::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) +{ + // TODO: + //FeedWheelEvent( wheelEvent ); +} + +void GlWindow::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) +{ + Dali::KeyEvent event = Dali::DevelKeyEvent::New( keyEvent.keyName, keyEvent.logicalKey, keyEvent.keyString, keyEvent.keyCode, + keyEvent.keyModifier, keyEvent.time, static_cast(keyEvent.state), + keyEvent.compose, keyEvent.deviceName, keyEvent.deviceClass, keyEvent.deviceSubclass ); + Dali::GlWindow handle( this ); + mKeyEventSignal.Emit( event ); +} + +void GlWindow::OnRotation( const RotationEvent& rotation ) +{ + mWindowRotationAngle = rotation.angle; + mTotalRotationAngle = ( mWindowRotationAngle + mScreenRotationAngle ) % 360; + if( mTotalRotationAngle == 90 || mTotalRotationAngle == 270 ) + { + mWindowWidth = mPositionSize.height; + mWindowHeight = mPositionSize.width; + } + else + { + mWindowWidth = mPositionSize.width; + mWindowHeight = mPositionSize.height; + } + + mIsRotated = true; + mIsWindowRotated = true; + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight ); + + // Emit Resize signal + Dali::GlWindow handle( this ); + mResizeSignal.Emit( Dali::Uint16Pair( mWindowWidth, mWindowHeight ) ); +} + +void GlWindow::RecalculateTouchPosition( Integration::Point& point ) +{ + Vector2 position = point.GetScreenPosition(); + Vector2 convertedPosition; + + switch( mTotalRotationAngle ) + { + case 90: + { + convertedPosition.x = static_cast( mWindowWidth ) - position.y; + convertedPosition.y = position.x; + break; + } + case 180: + { + convertedPosition.x = static_cast( mWindowWidth ) - position.x; + convertedPosition.y = static_cast( mWindowHeight ) - position.y; + break; + } + case 270: + { + convertedPosition.x = position.y; + convertedPosition.y = static_cast( mWindowHeight ) - position.x; + break; + } + default: + { + convertedPosition = position; + break; + } + } + + point.SetScreenPosition( convertedPosition ); +} + +void GlWindow::SetAvailableAnlges( const std::vector< int >& angles ) +{ + if( angles.size() > 4 ) + { + DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() ); + return; + } + + mWindowBase->SetAvailableAnlges( angles ); +} + +bool GlWindow::IsOrientationAvailable( Dali::GlWindow::GlWindowOrientation orientation ) const +{ + if( orientation <= Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE + || orientation > Dali::GlWindow::GlWindowOrientation::LANDSCAPE_INVERSE ) + { + DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation ); + return false; + } + return true; +} + +int GlWindow::ConvertToAngle( Dali::GlWindow::GlWindowOrientation orientation ) +{ + int convertAngle = 0; + if ( mOrientationMode == 0 ) + { + convertAngle = ( static_cast< int >( orientation ) ) * 90; + } + else if( mOrientationMode == 1) + { + switch( orientation ) + { + case Dali::GlWindow::GlWindowOrientation::LANDSCAPE: + { + convertAngle = 0; + break; + } + case Dali::GlWindow::GlWindowOrientation::PORTRAIT: + { + convertAngle = 90; + break; + } + case Dali::GlWindow::GlWindowOrientation::LANDSCAPE_INVERSE: + { + convertAngle = 180; + break; + } + case Dali::GlWindow::GlWindowOrientation::PORTRAIT_INVERSE: + { + convertAngle = 270; + break; + } + case Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE: + { + convertAngle = -1; + break; + } + } + } + return convertAngle; +} + +Dali::GlWindow::GlWindowOrientation GlWindow::ConvertToOrientation( int angle ) const +{ + Dali::GlWindow::GlWindowOrientation orientation = Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE; + if ( mOrientationMode == 0 ) // Portrate mode + { + orientation = static_cast< Dali::GlWindow::GlWindowOrientation >( angle / 90 ); + } + else if( mOrientationMode == 1 ) // Landscape mode + { + switch( angle ) + { + case 0: + { + orientation = Dali::GlWindow::GlWindowOrientation::LANDSCAPE; + break; + } + case 90: + { + orientation = Dali::GlWindow::GlWindowOrientation::PORTRAIT; + break; + } + case 180: + { + orientation = Dali::GlWindow::GlWindowOrientation::LANDSCAPE_INVERSE; + break; + } + case 270: + { + orientation = Dali::GlWindow::GlWindowOrientation::PORTRAIT_INVERSE; + break; + } + case -1: + { + orientation = Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE; + break; + } + } + } + return orientation; +} + +Dali::GlWindow::GlWindowOrientation GlWindow::GetCurrentOrientation() const +{ + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mTotalRotationAngle ); + return ConvertToOrientation( mTotalRotationAngle ); +} + +void GlWindow::SetAvailableOrientations( const Dali::Vector< Dali::GlWindow::GlWindowOrientation >& orientations ) +{ + Dali::Vector::SizeType count = orientations.Count(); + for( Dali::Vector::SizeType index = 0; index < count; ++index ) + { + if( IsOrientationAvailable( orientations[index] ) == false ) + { + DALI_LOG_ERROR("Window::SetAvailableRotationAngles, invalid angle: %d\n", orientations[index]); + continue; + } + + bool found = false; + int angle = ConvertToAngle( orientations[index] ); + + for( std::size_t i = 0; i < mAvailableAngles.size(); i++ ) + { + if( mAvailableAngles[i] == angle ) + { + found = true; + break; + } + } + + if( !found ) + { + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, angle ); + mAvailableAngles.push_back( angle ); + } + } + SetAvailableAnlges( mAvailableAngles ); +} + +void GlWindow::SetPreferredOrientation( Dali::GlWindow::GlWindowOrientation orientation ) +{ + if( IsOrientationAvailable( orientation ) == false ) + { + DALI_LOG_ERROR( "Window::SetPreferredOrientation, invalid orientation: %d\n", orientation ); + return; + } + mPreferredAngle = ConvertToAngle( orientation ); + DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle ); + mWindowBase->SetPreferredAngle( mPreferredAngle ); +} + +void GlWindow::SetChild( Dali::Window& child ) +{ + if( DALI_UNLIKELY( child ) ) + { + mChildWindow = child; + Internal::Adaptor::Window& windowImpl = Dali::GetImplementation( mChildWindow ); + WindowRenderSurface* renderSurface = static_cast( windowImpl.GetSurface() ); + if( renderSurface ) + { + WindowBase* childWindowBase = renderSurface->GetWindowBase(); + if( childWindowBase ) + { + childWindowBase->SetParent( mWindowBase.get() ); + } + } + } +} + +void GlWindow::RegisterGlCallback( GlInitialize glInit, GlRenderFrame glRenderFrame, GlTerminate glTerminate ) +{ + if( mIsEGLInitialize == false ) + { + InitializeGraphics(); + } + mGLInitCallback = glInit; + mGLRenderFrameCallback = glRenderFrame; + mGLTerminateCallback = glTerminate; + + mInitCallback = false; + + if( !mGLRenderCallback ) + { + mGLRenderCallback = MakeCallback( this, &GlWindow::RunCallback ); + + if( Dali::Adaptor::IsAvailable() ) + { + Dali::Adaptor::Get().AddIdle( mGLRenderCallback, true ); + } + else + { + DALI_LOG_RELEASE_INFO( "RegisterGlCallback: Adaptor is not avaiable\n" ); + } + + } +} + +bool GlWindow::RunCallback() +{ + GraphicsInterface* graphics = mGraphics.get(); + EglGraphics *eglGraphics = static_cast( graphics ); + Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + + eglImpl.MakeContextCurrent( mEGLSurface, mEGLContext ); + + if( mIsRotated ) + { + mWindowBase->SetEglWindowBufferTransform( mTotalRotationAngle ); + if( mIsWindowRotated ) + { + mWindowBase->SetEglWindowTransform( mWindowRotationAngle ); + } + mIsRotated = false; + } + + if( !mInitCallback ) + { + if( mGLInitCallback ) + { + mGLInitCallback(); + } + mInitCallback = true; + } + + if( mGLRenderFrameCallback ) + { + mGLRenderFrameCallback(); + } + + if( mIsWindowRotated ) + { + mWindowBase->WindowRotationCompleted( mWindowRotationAngle, mPositionSize.width, mPositionSize.height ); + mIsWindowRotated = false; + } + + eglImpl.SwapBuffers( mEGLSurface ); + + return true; +} + +void GlWindow::RenderOnce() +{ + RunCallback(); +} + +void GlWindow::InitializeGraphics() +{ + if( !mIsEGLInitialize ) + { + // Init Graphics + std::unique_ptr< GraphicsFactory > graphicsFactoryPtr = Utils::MakeUnique< GraphicsFactory >(); + auto graphicsFactory = *graphicsFactoryPtr.get(); + + mGraphics = std::unique_ptr< GraphicsInterface >( &graphicsFactory.Create() ); + GraphicsInterface* graphics = mGraphics.get(); + EglGraphics *eglGraphics = static_cast( graphics ); + eglGraphics->Initialize( mDepth, mStencil, mMSAA ); + eglGraphics->Create(); + + mDisplayConnection = std::unique_ptr< Dali::DisplayConnection >( Dali::DisplayConnection::New( *graphics, Dali::RenderSurfaceInterface::Type::WINDOW_RENDER_SURFACE ) ); + mDisplayConnection->Initialize(); + + Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + if( mGLESVersion == Dali::GlWindow::GlesVersion::VERSION_2_0 ) + { + eglImpl.SetGlesVersion( 20 ); + } + else if( mGLESVersion == Dali::GlWindow::GlesVersion::VERSION_3_0 ) + { + eglImpl.SetGlesVersion( 30 ); + } + + if( eglImpl.ChooseConfig(true, mColorDepth) == false ) + { + if( mGLESVersion == Dali::GlWindow::GlesVersion::VERSION_3_0 ) + { + DALI_LOG_RELEASE_INFO( "InitializeGraphics: Fail to choose config with GLES30, retry with GLES20\n" ); + eglImpl.SetGlesVersion( 20 ); + mGLESVersion = Dali::GlWindow::GlesVersion::VERSION_2_0; + if( eglImpl.ChooseConfig(true, mColorDepth) == false ) + { + DALI_LOG_ERROR("InitializeGraphics: Fail to choose config with GLES20"); + return; + } + } + else + { + DALI_LOG_ERROR("InitializeGraphics: Fail to choose config with GLES20"); + return; + } + } + eglImpl.CreateWindowContext( mEGLContext ); + + // Create the EGL window + EGLNativeWindowType window = mWindowBase->CreateEglWindow( mPositionSize.width, mPositionSize.height ); + mEGLSurface = eglImpl.CreateSurfaceWindow( window, mColorDepth ); + + mIsEGLInitialize = true; + } +} + +void GlWindow::OnDamaged( const DamageArea& area ) +{ + +} + +} // Adaptor + +} // Internal + +} // Dali diff --git a/dali/internal/window-system/common/gl-window-impl.h b/dali/internal/window-system/common/gl-window-impl.h new file mode 100644 index 0000000..fbecfc5 --- /dev/null +++ b/dali/internal/window-system/common/gl-window-impl.h @@ -0,0 +1,437 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_GL_WINDOW_IMPL_H +#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_GL_WINDOW_IMPL_H + +/* + * Copyright (c) 2020 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include + +namespace Dali +{ +class Adaptor; + +namespace Internal +{ +namespace Adaptor +{ +class WindowBase; + +class GlWindow; +using GlWindowPtr = IntrusivePtr< GlWindow >; +using EventHandlerPtr = IntrusivePtr< EventHandler >; + +/** + * Window provides a surface to render onto with orientation. + */ +class GlWindow : public BaseObject, public EventHandler::Observer, public DamageObserver, public ConnectionTracker +{ +public: + + using KeyEventSignalType = Dali::GlWindow::KeyEventSignalType; + using TouchEventSignalType = Dali::GlWindow::TouchEventSignalType; + using FocusChangeSignalType = Dali::GlWindow::FocusChangeSignalType; + using ResizeSignalType = Dali::GlWindow::ResizeSignalType; + using VisibilityChangedSignalType = Dali::GlWindow::VisibilityChangedSignalType; + using SignalType = Signal< void () >; + + /** + * @brief Create a new GlWindow. This should only be called once by the Application class + * @param[in] positionSize The position and size of the window + * @param[in] name The window title + * @param[in] className The window class name + * @param[in] isTransparent Whether window is transparent + * @return A newly allocated Window + */ + static GlWindow* New( const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false ); + + /** + * @copydoc Dali::GlWindow::SetEglConfig() + */ + void SetEglConfig( bool depth, bool stencil, int msaa, Dali::GlWindow::GlesVersion version ); + + /** + * @copydoc Dali::GlWindow::Raise() + */ + void Raise(); + + /** + * @copydoc Dali::GlWindow::Lower() + */ + void Lower(); + + /** + * @copydoc Dali::GlWindow::Activate() + */ + void Activate(); + + /** + * @copydoc Dali::GlWindow::Show() + */ + void Show(); + + /** + * @copydoc Dali::GlWindow::Hide() + */ + void Hide(); + + /** + * @copydoc Dali::GlWindow::GetSupportedAuxiliaryHintCount() + */ + unsigned int GetSupportedAuxiliaryHintCount() const; + + /** + * @copydoc Dali::GlWindow::GetSupportedAuxiliaryHint() + */ + std::string GetSupportedAuxiliaryHint( unsigned int index ) const; + + /** + * @copydoc Dali::GlWindow::AddAuxiliaryHint() + */ + unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ); + + /** + * @copydoc Dali::GlWindow::RemoveAuxiliaryHint() + */ + bool RemoveAuxiliaryHint( unsigned int id ); + + /** + * @copydoc Dali::GlWindow::SetAuxiliaryHintValue() + */ + bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ); + + /** + * @copydoc Dali::GlWindow::GetAuxiliaryHintValue() + */ + std::string GetAuxiliaryHintValue( unsigned int id ) const; + + /** + * @copydoc Dali::GlWindow::GetAuxiliaryHintId() + */ + unsigned int GetAuxiliaryHintId( const std::string& hint ) const; + + /** + * @copydoc Dali::GlWindow::SetInputRegion() + */ + void SetInputRegion( const Rect< int >& inputRegion ); + + /** + * @copydoc Dali::GlWindow::SetOpaqueState() + */ + void SetOpaqueState( bool opaque ); + + /** + * @copydoc Dali::GlWindow::IsOpaqueState() + */ + bool IsOpaqueState() const; + + /** + * @copydoc Dali::GlWindow::SetPositionSize() + */ + void SetPositionSize( PositionSize positionSize ); + + /** + * @copydoc Dali::GlWindow::GetPositionSize() + */ + PositionSize GetPositionSize() const; + + /** + * @copydoc Dali::GlWindow::GetCurrentOrientation() const + */ + Dali::GlWindow::GlWindowOrientation GetCurrentOrientation() const; + + /** + * @copydoc Dali::GlWindow::SetAvailableOrientations() + */ + void SetAvailableOrientations( const Dali::Vector< Dali::GlWindow::GlWindowOrientation >& orientations ); + + /** + * @copydoc Dali::GlWindow::SetPreferredOrientation() + */ + void SetPreferredOrientation( Dali::GlWindow::GlWindowOrientation orientation ); + + /** + * @copydoc Dali::GlWindow::RegisterGlCallback() + */ + void RegisterGlCallback( GlInitialize glInit, GlRenderFrame glRenderFrame, GlTerminate glTerminate ); + + /** + * @copydoc Dali::GlWindow::RenderOnce() + */ + void RenderOnce(); + +public: // For implementation + /** + * @brief Sets child window with Dali::Window + * + * @param[in] child The child window. + * + * Most of cases, child window is the default window in adaptor + * + * Currently the child window is default window. + */ + void SetChild( Dali::Window& child ); + +private: + + /** + * Private constructor. + * @sa Window::New() + */ + GlWindow(); + + /** + * Destructor + */ + virtual ~GlWindow(); + + /** + * Second stage initialization + * + * @param[in] positionSize The position and size of the window + * @param[in] name The window title + * @param[in] className The window class name + */ + void Initialize( const PositionSize& positionSize, const std::string& name, const std::string& className ); + + /** + * Called when the window becomes iconified or deiconified. + * + * @param[in] iconified The flag whether window is iconifed or deiconfied. + */ + void OnIconifyChanged( bool iconified ); + + /** + * Called when the window focus is changed. + * @param[in] focusIn The flag whether window is focused or not. + */ + void OnFocusChanged( bool focusIn ); + + /** + * Called when the output is transformed. + */ + void OnOutputTransformed(); + + /** + * Called when the window receives a delete request. + */ + void OnDeleteRequest(); + + /** + * @brief Set available rotation angle to window base. + * + * @param[in] angles The list of the avaiabled rotation angle. + */ + void SetAvailableAnlges( const std::vector< int >& angles ); + + /** + * @brief Check available window orientation for Available angle. + * + * @param[in] orientation the oritation value of window rotation. + * + * @return true is available window orientation. false is not available. + */ + bool IsOrientationAvailable( Dali::GlWindow::GlWindowOrientation orientation ) const; + + /** + * @brief Convert from window orientation to angle using orientation mode value. + * + * @param[in] orientation the oritation value of window rotation. + * + * @return The coverted angle value is returned. + */ + int ConvertToAngle( Dali::GlWindow::GlWindowOrientation orientation ); + + /** + * @brief Convert from angle to window orientation using orientation mode value. + * + * @param[in] angle the angle value of window rotation. + * + * @return The converted window orientation value is returned. + */ + Dali::GlWindow::GlWindowOrientation ConvertToOrientation( int angle ) const; + + /** + * @brief Run Ui GL callback function. + * + * @return true is the callback function works continuos. + */ + bool RunCallback(); + + /** + * @brief Initialize and create EGL resource + */ + void InitializeGraphics(); + + /** + * @brief Sets event handler for window's events. + */ + void SetEventHandler() ; + + /** + * @brief calculate touch position for rotation. + */ + void RecalculateTouchPosition( Integration::Point& point ) ; + + /** + * @brief Sets window and class name. + * + * @param[in] name The name of the window + * @param[in] className The class of the window + */ + void SetClass( const std::string& name, const std::string className ); + +private: + + /** + * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint + */ + void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override; + + /** + * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent + */ + void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override; + + /** + * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent + */ + void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override; + + /** + * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation + */ + void OnRotation( const RotationEvent& rotation ) override; + +private: // From Dali::Internal::Adaptor::DamageObserver + + /** + * @copydoc Dali::Internal::Adaptor::DamageObserver::OnDamaged() + */ + void OnDamaged( const DamageArea& area ); + +public: // Signals + + /** + * @copydoc Dali::GlWindow::FocusChangeSignal() + */ + FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; } + + /** + * @copydoc Dali::GlWindow::ResizeSignal() + */ + ResizeSignalType& ResizeSignal() { return mResizeSignal; } + + /** + * @copydoc Dali::GlWindow::KeyEventSignal() + */ + KeyEventSignalType& KeyEventSignal() { return mKeyEventSignal; } + + /** + * @copydoc Dali::GlWindow::TouchSignal() + */ + TouchEventSignalType& TouchedSignal() { return mTouchedSignal; } + + /** + * @copydoc Dali::GlWindow::VisibilityChangedSignal() + */ + VisibilityChangedSignalType& VisibilityChangedSignal() { return mVisibilityChangedSignal; } + +private: + + std::unique_ptr< WindowBase > mWindowBase; + std::unique_ptr< GraphicsInterface > mGraphics; ///< Graphics interface + std::unique_ptr< Dali::DisplayConnection > mDisplayConnection; + std::string mName; + std::string mClassName; + EventHandlerPtr mEventHandler; ///< The window events handler + PositionSize mPositionSize; + ColorDepth mColorDepth; + Dali::Window mChildWindow; + bool mIsTransparent:1; + bool mIsFocusAcceptable:1; + bool mIconified:1; + bool mOpaqueState:1; + bool mResizeEnabled:1; + bool mVisible:1; + bool mIsRotated:1; + bool mIsWindowRotated:1; + bool mIsTouched:1; + + std::vector< int > mAvailableAngles; + int mPreferredAngle; + int mTotalRotationAngle; ///< The angle of window + screen rotation angle % 360 + int mWindowRotationAngle; ///< The angle of window rotation angle + int mScreenRotationAngle; ///< The angle of screen rotation angle + int mOrientationMode; ///< 0: Default portrati, 1:Default landscape + int mWindowWidth; ///< The width of the window + int mWindowHeight; ///< The height of the window + int mNativeWindowId; ///< The Native Window Id + + // Signals + KeyEventSignalType mKeyEventSignal; + TouchEventSignalType mTouchedSignal; + FocusChangeSignalType mFocusChangeSignal; + ResizeSignalType mResizeSignal; + VisibilityChangedSignalType mVisibilityChangedSignal; + + // EGL, GL Resource + GlInitialize mGLInitCallback; + GlRenderFrame mGLRenderFrameCallback; + GlTerminate mGLTerminateCallback; + CallbackBase* mGLRenderCallback; + EGLSurface mEGLSurface; + EGLContext mEGLContext; + Dali::GlWindow::GlesVersion mGLESVersion; + bool mInitCallback:1; + bool mDepth:1; + bool mStencil:1; + bool mIsEGLInitialize:1; + int mMSAA; +}; + +} // namespace Adaptor +} // namepsace Internal + +// Helpers for public-api forwarding methods + +inline Internal::Adaptor::GlWindow& GetImplementation(Dali::GlWindow& window) +{ + DALI_ASSERT_ALWAYS( window && "Window handle is empty" ); + BaseObject& object = window.GetBaseObject(); + return static_cast(object); +} + +inline const Internal::Adaptor::GlWindow& GetImplementation(const Dali::GlWindow& window) +{ + DALI_ASSERT_ALWAYS( window && "Window handle is empty" ); + const BaseObject& object = window.GetBaseObject(); + return static_cast(object); +} + +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_GL_WINDOW_IMPL_H diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 5fa120c..fe1dacc 100755 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -154,7 +154,7 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std void Window::OnAdaptorSet(Dali::Adaptor& adaptor) { - mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface, *mAdaptor ) ); + mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface->GetWindowBase(), *mAdaptor ) ); mEventHandler->AddObserver( *this ); } diff --git a/dali/internal/window-system/file.list b/dali/internal/window-system/file.list index 7dffb60..d3a73ac 100644 --- a/dali/internal/window-system/file.list +++ b/dali/internal/window-system/file.list @@ -1,47 +1,48 @@ # module: window-system, backend: common -SET( adaptor_window_system_common_src_files - ${adaptor_window_system_dir}/common/display-connection.cpp - ${adaptor_window_system_dir}/common/event-handler.cpp - ${adaptor_window_system_dir}/common/native-render-surface-factory.cpp - ${adaptor_window_system_dir}/common/orientation-impl.cpp - ${adaptor_window_system_dir}/common/window-base.cpp - ${adaptor_window_system_dir}/common/window-impl.cpp +SET( adaptor_window_system_common_src_files + ${adaptor_window_system_dir}/common/display-connection.cpp + ${adaptor_window_system_dir}/common/event-handler.cpp + ${adaptor_window_system_dir}/common/native-render-surface-factory.cpp + ${adaptor_window_system_dir}/common/orientation-impl.cpp + ${adaptor_window_system_dir}/common/window-base.cpp + ${adaptor_window_system_dir}/common/window-impl.cpp ${adaptor_window_system_dir}/common/window-render-surface.cpp + ${adaptor_window_system_dir}/common/gl-window-impl.cpp ) # module: window-system, backend: tizen-wayland -SET( adaptor_window_system_tizen_wayland_src_files - ${adaptor_window_system_dir}/tizen-wayland/display-connection-factory-ecore-wl.cpp - ${adaptor_window_system_dir}/tizen-wayland/display-connection-impl-ecore-wl.cpp +SET( adaptor_window_system_tizen_wayland_src_files + ${adaptor_window_system_dir}/tizen-wayland/display-connection-factory-ecore-wl.cpp + ${adaptor_window_system_dir}/tizen-wayland/display-connection-impl-ecore-wl.cpp ${adaptor_window_system_dir}/tizen-wayland/native-render-surface-ecore-wl.cpp ) # module: window-system, backend: ecore-wl -SET( adaptor_window_system_ecore_wl_src_files - ${adaptor_window_system_dir}/tizen-wayland/ecore-wl/render-surface-factory-ecore-wl.cpp - ${adaptor_window_system_dir}/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp - ${adaptor_window_system_dir}/tizen-wayland/ecore-wl/window-factory-ecore-wl.cpp +SET( adaptor_window_system_ecore_wl_src_files + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl/render-surface-factory-ecore-wl.cpp + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl/window-factory-ecore-wl.cpp ${adaptor_window_system_dir}/tizen-wayland/ecore-wl/window-system-ecore-wl.cpp ) # module: window-system, backend: ecore-wl2 -SET( adaptor_window_system_ecore_wl2_src_files - ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.cpp - ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp - ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.cpp +SET( adaptor_window_system_ecore_wl2_src_files + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.cpp + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.cpp ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp ) # module: window-system, backend: ubuntu-x11 -SET( adaptor_window_system_ubuntu_x11_src_files - ${adaptor_window_system_dir}/ubuntu-x11/display-connection-factory-x.cpp - ${adaptor_window_system_dir}/ubuntu-x11/display-connection-impl-x.cpp - ${adaptor_window_system_dir}/ubuntu-x11/pixmap-render-surface-ecore-x.cpp - ${adaptor_window_system_dir}/ubuntu-x11/render-surface-factory-ecore-x.cpp - ${adaptor_window_system_dir}/ubuntu-x11/window-interface-ecore-x.cpp - ${adaptor_window_system_dir}/ubuntu-x11/window-base-ecore-x.cpp - ${adaptor_window_system_dir}/ubuntu-x11/window-factory-ecore-x.cpp +SET( adaptor_window_system_ubuntu_x11_src_files + ${adaptor_window_system_dir}/ubuntu-x11/display-connection-factory-x.cpp + ${adaptor_window_system_dir}/ubuntu-x11/display-connection-impl-x.cpp + ${adaptor_window_system_dir}/ubuntu-x11/pixmap-render-surface-ecore-x.cpp + ${adaptor_window_system_dir}/ubuntu-x11/render-surface-factory-ecore-x.cpp + ${adaptor_window_system_dir}/ubuntu-x11/window-interface-ecore-x.cpp + ${adaptor_window_system_dir}/ubuntu-x11/window-base-ecore-x.cpp + ${adaptor_window_system_dir}/ubuntu-x11/window-factory-ecore-x.cpp ${adaptor_window_system_dir}/ubuntu-x11/window-system-ecore-x.cpp )