Fix Coverity issue
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / gl-window-impl.cpp
index 89d4398..d94dbe8 100644 (file)
@@ -74,7 +74,6 @@ GlWindow::GlWindow()
   mOpaqueState(false),
   mResizeEnabled(false),
   mVisible(false),
-  mIsRotated(false),
   mIsWindowRotated(false),
   mIsTouched(false),
   mIsEGLInitialized(false),
@@ -149,6 +148,7 @@ void GlWindow::Initialize(const PositionSize& positionSize, const std::string& n
   mWindowBase = windowFactory->CreateWindowBase(mPositionSize, surface, (mIsTransparent ? true : false));
   mWindowBase->IconifyChangedSignal().Connect(this, &GlWindow::OnIconifyChanged);
   mWindowBase->FocusChangedSignal().Connect(this, &GlWindow::OnFocusChanged);
+  mWindowBase->OutputTransformedSignal().Connect(this, &GlWindow::OnOutputTransformed);
 
   if(Dali::Adaptor::IsAvailable())
   {
@@ -385,11 +385,16 @@ void GlWindow::SetPositionSize(PositionSize positionSize)
   }
 
   // If window's size or position is changed, the signal will be emitted to user.
-  if((needToMove) || (needToResize))
+  if(needToMove || needToResize)
   {
     Uint16Pair     newSize(mPositionSize.width, mPositionSize.height);
     Dali::GlWindow handle(this);
     mResizeSignal.Emit(newSize);
+
+    if(mGlWindowRenderThread)
+    {
+      mGlWindowRenderThread->RequestWindowResize(mPositionSize.width, mPositionSize.height);
+    }
   }
 }
 
@@ -461,26 +466,12 @@ void GlWindow::OnFocusChanged(bool 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;
-    }
+  int newScreenRotationAngle = mWindowBase->GetScreenRotationAngle();
+  DALI_LOG_RELEASE_INFO("GlWindow::OnOutputTransformed(), screen rotation occurs, old[%d], new[%d\n", mScreenRotationAngle, newScreenRotationAngle);
 
-    // Emit Resize signal
-    Dali::GlWindow handle(this);
-    mResizeSignal.Emit(Dali::Uint16Pair(mWindowWidth, mWindowHeight));
+  if(newScreenRotationAngle != mScreenRotationAngle)
+  {
+    UpdateScreenRotation(newScreenRotationAngle);
   }
 }
 
@@ -537,13 +528,16 @@ void GlWindow::OnRotation(const RotationEvent& rotation)
     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));
+
+  if(mGlWindowRenderThread)
+  {
+    mGlWindowRenderThread->RequestWindowRotate(mWindowRotationAngle);
+  }
 }
 
 void GlWindow::RecalculateTouchPosition(Integration::Point& point)
@@ -823,6 +817,14 @@ void GlWindow::InitializeGraphics()
     mGlWindowRenderThread->SetOnDemandRenderMode(onDemand);
 
     mIsEGLInitialized = true;
+
+    // Check screen rotation
+    int newScreenRotationAngle = mWindowBase->GetScreenRotationAngle();
+    DALI_LOG_RELEASE_INFO("GlWindow::InitializeGraphics(), GetScreenRotationAngle(): %d\n", mScreenRotationAngle);
+    if(newScreenRotationAngle != 0)
+    {
+      UpdateScreenRotation(newScreenRotationAngle);
+    }
   }
 }
 
@@ -830,6 +832,33 @@ void GlWindow::OnDamaged(const DamageArea& area)
 {
 }
 
+void GlWindow::UpdateScreenRotation(int newAngle)
+{
+  mScreenRotationAngle = newAngle;
+  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));
+
+  if(mGlWindowRenderThread)
+  {
+    DALI_LOG_RELEASE_INFO("GlWindow::UpdateScreenRotation(), RequestScreenRotatem(), mScreenRotationAngle: %d\n", mScreenRotationAngle);
+    mGlWindowRenderThread->RequestScreenRotate(mScreenRotationAngle);
+  }
+}
+
 } // namespace Adaptor
 
 } // namespace Internal