Add environment variable to manually set DPI
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-render-surface.cpp
index 2ff7944..8bb94c5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -32,6 +32,7 @@
 #include <dali/internal/window-system/common/window-factory.h>
 #include <dali/internal/window-system/common/window-system.h>
 #include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/system/common/environment-variables.h>
 
 
 namespace Dali
@@ -53,7 +54,9 @@ Debug::Filter* gWindowRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose
 } // unnamed namespace
 
 WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
-: mPositionSize( positionSize ),
+: mEGL( nullptr ),
+  mDisplayConnection( nullptr ),
+  mPositionSize( positionSize ),
   mWindowBase(),
   mThreadSynchronization( NULL ),
   mRenderNotification( NULL ),
@@ -69,7 +72,9 @@ WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, Any s
   mRotationSupported( false ),
   mRotationFinished( true ),
   mScreenRotationFinished( true ),
-  mResizeFinished( true )
+  mResizeFinished( true ),
+  mDpiHorizontal( 0 ),
+  mDpiVertical( 0 )
 {
   DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
   Initialize( surface );
@@ -81,6 +86,11 @@ WindowRenderSurface::~WindowRenderSurface()
   {
     delete mRotationTrigger;
   }
+
+  if ( mEGLSurface )
+  {
+    DestroySurface();
+  }
 }
 
 void WindowRenderSurface::Initialize( Any surface )
@@ -177,7 +187,22 @@ PositionSize WindowRenderSurface::GetPositionSize() const
 
 void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
 {
-  mWindowBase->GetDpi( dpiHorizontal, dpiVertical );
+  if( mDpiHorizontal == 0 || mDpiVertical == 0 )
+  {
+    const char* environmentDpiHorizontal = std::getenv( DALI_ENV_DPI_HORIZONTAL );
+    mDpiHorizontal = environmentDpiHorizontal ? std::atoi( environmentDpiHorizontal ) : 0;
+
+    const char* environmentDpiVertical = std::getenv( DALI_ENV_DPI_VERTICAL );
+    mDpiVertical = environmentDpiVertical ? std::atoi( environmentDpiVertical ) : 0;
+
+    if( mDpiHorizontal == 0 || mDpiVertical == 0 )
+    {
+      mWindowBase->GetDpi( mDpiHorizontal, mDpiVertical );
+    }
+  }
+
+  dpiHorizontal = mDpiHorizontal;
+  dpiVertical = mDpiVertical;
 }
 
 void WindowRenderSurface::InitializeGraphics()
@@ -227,7 +252,10 @@ void WindowRenderSurface::CreateSurface()
   // Check rotation capability
   mRotationSupported = mWindowBase->IsEglWindowRotationSupported();
 
-  DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::CreateSurface: w = %d h = %d angle = %d screen rotation = %d\n", mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle );
+  int screenWidth, screenHeight;
+  WindowSystem::GetScreenSize( screenWidth, screenHeight );
+  DALI_LOG_RELEASE_INFO("WindowRenderSurface::CreateSurface: w = %d h = %d screenWidth = %d screenHeight = %d angle = %d screen rotation = %d\n",
+      mPositionSize.width, mPositionSize.height, screenWidth, screenHeight, mRotationAngle, mScreenRotationAngle );
 }
 
 void WindowRenderSurface::DestroySurface()
@@ -329,7 +357,6 @@ bool WindowRenderSurface::PreRender( bool resizingSurface )
 
   if( resizingSurface )
   {
-#ifdef OVER_TIZEN_VERSION_4
     // Window rotate or screen rotate
     if( !mRotationFinished || !mScreenRotationFinished )
     {
@@ -349,7 +376,6 @@ bool WindowRenderSurface::PreRender( bool resizingSurface )
     {
       mWindowBase->SetEglWindowTransform( mRotationAngle );
     }
-#endif
 
     // Resize case
     if( !mResizeFinished )