[3.0] Add function to set top margin of the stage 39/102439/1 accepted/tizen/3.0/common/20161207.195845 accepted/tizen/3.0/ivi/20161207.140048 accepted/tizen/3.0/mobile/20161207.135951 accepted/tizen/3.0/tv/20161207.135701 accepted/tizen/3.0/wearable/20161207.140200 submit/tizen_3.0/20161207.093446
authorsuhyung Eom <suhyung.eom@samsung.com>
Fri, 9 Sep 2016 01:49:56 +0000 (10:49 +0900)
committersuhyung Eom <suhyung.eom@samsung.com>
Tue, 6 Dec 2016 00:14:41 +0000 (09:14 +0900)
Signed-off-by: suhyung Eom <suhyung.eom@samsung.com>
Change-Id: I9b0da6c2e17cca7894245d36013fe1d04a24d11d

automated-tests/src/dali-internal/CMakeLists.txt
automated-tests/src/dali-internal/utc-Dali-Internal-Core.cpp [new file with mode: 0644]
automated-tests/src/dali/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali/dali-test-suite-utils/test-application.h
dali/integration-api/core.cpp
dali/integration-api/core.h
dali/internal/common/core-impl.cpp
dali/internal/common/core-impl.h
dali/internal/event/common/stage-impl.cpp
dali/internal/event/common/stage-impl.h
dali/internal/update/render-tasks/scene-graph-render-task.h

index 4bc9f10..39d274c 100644 (file)
@@ -6,6 +6,7 @@ SET(RPM_NAME "core-${PKG_NAME}-tests")
 SET(CAPI_LIB "dali-internal")
 
 SET(TC_SOURCES
+        utc-Dali-Internal-Core.cpp
         utc-Dali-Internal-Handles.cpp
         utc-Dali-Internal-ImageFactory.cpp
         utc-Dali-Internal-ResourceClient.cpp
diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Core.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Core.cpp
new file mode 100644 (file)
index 0000000..77c7a1f
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2016 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 <iostream>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+
+#include <dali-test-suite-utils.h>
+
+// Internal headers are allowed here
+
+
+using namespace Dali;
+
+void utc_dali_internal_core_startup()
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_internal_core_cleanup()
+{
+  test_return_value = TET_PASS;
+}
+
+
+int UtcDaliCoreTopMargin(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Dali::Integration::Core::SetTopMargin");
+
+  Stage stage = Stage::GetCurrent();
+
+  // Test Stage size without top-margin
+
+  const unsigned int initialWidth(  stage.GetSize().width );
+  const unsigned int initialHeight( stage.GetSize().height );
+
+  DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_WIDTH,  initialWidth,  TEST_LOCATION );
+  DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_HEIGHT, initialHeight, TEST_LOCATION );
+
+  // Retest with top-margin
+
+  unsigned int margin( 10 );
+  application.SetTopMargin( margin );
+
+  const unsigned int newWidth(  stage.GetSize().width );
+  const unsigned int newHeight( stage.GetSize().height );
+
+  DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_WIDTH,             newWidth,  TEST_LOCATION );
+  DALI_TEST_EQUALS( (TestApplication::DEFAULT_SURFACE_HEIGHT - margin), newHeight, TEST_LOCATION );
+
+  END_TEST;
+}
index f2e3cd7..e8d9be4 100644 (file)
@@ -154,6 +154,11 @@ void TestApplication::SetSurfaceWidth( unsigned int width, unsigned height )
   mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
 }
 
+void TestApplication::SetTopMargin( unsigned int margin )
+{
+  mCore->SetTopMargin( margin );
+}
+
 void TestApplication::DoUpdate( unsigned int intervalMilliseconds, const char* location )
 {
   if( GetUpdateStatus() == 0 &&
index d6dab48..49a7f51 100644 (file)
@@ -73,6 +73,7 @@ public:
   void ProcessEvent(const Integration::Event& event);
   void SendNotification();
   void SetSurfaceWidth( unsigned int width, unsigned height );
+  void SetTopMargin( unsigned int margin );
   bool Render( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL );
   unsigned int GetUpdateStatus();
   bool UpdateOnly( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL );
index dc08bb9..ca76112 100644 (file)
@@ -69,6 +69,11 @@ void Core::SurfaceResized(unsigned int width, unsigned int height)
   mImpl->SurfaceResized(width, height);
 }
 
+void Core::SetTopMargin( unsigned int margin )
+{
+  mImpl->SetTopMargin(margin);
+}
+
 void Core::SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical)
 {
   mImpl->SetDpi(dpiHorizontal, dpiVertical);
index c99258b..19693d8 100644 (file)
@@ -255,6 +255,15 @@ public:
    */
   void SurfaceResized(unsigned int width, unsigned int height);
 
+  /**
+   * Notify the Core about the top margin size.
+   * Available stage size is reduced by this size.
+   * The stage is located below the size at the top of the display
+   * It is mainly useful for indicator in mobile device
+   * @param[in] margin margin size
+   */
+  void SetTopMargin( unsigned int margin );
+
   // Core setters
 
   /**
index 7f2bc71..fafe5b3 100644 (file)
@@ -243,8 +243,20 @@ void Core::ContextDestroyed()
 
 void Core::SurfaceResized( unsigned int width, unsigned int height )
 {
-  mStage->SetSize( width, height );
-  mRelayoutController->SetStageSize( width, height );
+  mStage->SurfaceResized( width, height );
+
+  // The stage-size may be less than surface-size (reduced by top-margin)
+  Vector2 size = mStage->GetSize();
+  mRelayoutController->SetStageSize( size.width, size.height );
+}
+
+void Core::SetTopMargin( unsigned int margin )
+{
+  mStage->SetTopMargin( margin );
+
+  // The stage-size may be less than surface-size (reduced by top-margin)
+  Vector2 size = mStage->GetSize();
+  mRelayoutController->SetStageSize( size.width, size.height );
 }
 
 void Core::SetDpi( unsigned int dpiHorizontal, unsigned int dpiVertical )
index 61f20fd..3d90545 100644 (file)
@@ -117,6 +117,11 @@ public:
   void SurfaceResized(unsigned int width, unsigned int height);
 
   /**
+   * @copydoc Dali::Integration::Core::SetTopMargin( unsigned int margin )
+   */
+  void SetTopMargin( unsigned int margin );
+
+  /**
    * @copydoc Dali::Integration::Core::SetDpi(unsigned int, unsigned int)
    */
   void SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical);
index aea8308..bbdf7b0 100644 (file)
@@ -186,22 +186,29 @@ void Stage::Remove( Actor& actor )
   mRootLayer->Remove( actor );
 }
 
-void Stage::SetSize(float width, float height)
+void Stage::SurfaceResized(float width, float height)
 {
+  mSurfaceSize.width = width;
+  mSurfaceSize.height = height;
+
   // Internally we want to report the actual size of the stage.
-  mSize.width  = width;
-  mSize.height = height;
+  mSize.width = width;
+  mSize.height = height - mTopMargin;
 
   // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
-  mDefaultCamera->SetPerspectiveProjection( mSize );
+  mDefaultCamera->SetPerspectiveProjection( mSurfaceSize );
+
+  // Adjust the camera height to allow for top-margin
+  SetDefaultCameraPosition();
 
-  // The depth of the stage gets set to the maximun of these values
-  mRootLayer->SetSize( mSize );
+  mRootLayer->SetSize( mSize.width, mSize.height );
 
   // Repeat for SystemOverlay actors
   if( mSystemOverlay )
   {
-    mSystemOverlay->GetImpl()->SetSize( mSize.width, mSize.height );
+    // Note that the SystemOverlay has a separate camera, configured for the full surface-size.
+    // This will remain unaffected by changes in SetDefaultCameraPosition()
+    mSystemOverlay->GetImpl()->SetSize( width, height );
   }
 
   SetDefaultSurfaceRectMessage( mUpdateManager, Rect<int>( 0, 0, width, height ) );
@@ -224,6 +231,23 @@ Vector2 Stage::GetSize() const
   return mSize;
 }
 
+void Stage::SetTopMargin( unsigned int margin )
+{
+  if (mTopMargin == margin)
+  {
+    return;
+  }
+  mTopMargin = margin;
+
+  mSize.width = mSurfaceSize.width;
+  mSize.height = mSurfaceSize.height - mTopMargin;
+
+  // Adjust the camera height to allow for top-margin
+  SetDefaultCameraPosition();
+
+  mRootLayer->SetSize( mSize.width, mSize.height );
+}
+
 RenderTaskList& Stage::GetRenderTaskList() const
 {
   return *mRenderTaskList;
@@ -239,6 +263,11 @@ void Stage::CreateDefaultCameraActor()
   Add(*(mDefaultCamera.Get()));
 }
 
+void Stage::SetDefaultCameraPosition()
+{
+  mDefaultCamera->SetY( -(static_cast<float>(mTopMargin) * 0.5f) );
+}
+
 Actor& Stage::GetDefaultRootActor()
 {
   return *mRootLayer;
@@ -623,6 +652,7 @@ Stage::Stage( AnimationPlaylist& playlist,
   mBackgroundColor(Dali::Stage::DEFAULT_BACKGROUND_COLOR),
   mViewMode( MONO ),
   mStereoBase( DEFAULT_STEREO_BASE ),
+  mTopMargin( 0 ),
   mSystemOverlay(NULL)
 {
 }
index e2b4cb4..415f87b 100644 (file)
@@ -138,11 +138,20 @@ public:
   void Remove( Actor& actor );
 
   /**
-   * Sets the size of the stage and indirectly, the root actor.
-   * @param [in] width  The new width.
-   * @param [in] height The new height.
+   * Used to calculate the size of the stage and indirectly, the root actor.
+   * @param [in] width  The new surface width.
+   * @param [in] height The new surface height.
    */
-  void SetSize( float width, float height );
+  void SurfaceResized( float width, float height );
+
+  /**
+   * Sets the top margin size.
+   * Available stage size is reduced by this size.
+   * The stage is located below the size at the top of the display
+   * initial size is zero before it is assigned
+   * @param[in] margin margin size
+   */
+  void SetTopMargin( unsigned int margin );
 
   /**
    * Returns the size of the Stage in pixels as a Vector.
@@ -163,6 +172,11 @@ public:
   void CreateDefaultCameraActor();
 
   /**
+   * Set position of default camera for current stage size
+   */
+  void SetDefaultCameraPosition();
+
+  /**
    * From RenderTaskDefaults; retrieve the default root actor.
    * @return The default root actor.
    */
@@ -433,8 +447,9 @@ private:
 
   NotificationManager& mNotificationManager;
 
-  // The Actual size of the stage.
+  // The stage-size may be less than surface-size (reduced by top-margin)
   Vector2 mSize;
+  Vector2 mSurfaceSize;
 
   // Cached for public GetBackgroundColor()
   Vector4 mBackgroundColor;
@@ -449,6 +464,7 @@ private:
   ViewMode mViewMode;
   float mStereoBase;
 
+  unsigned int mTopMargin;
   Vector2 mDpi;
 
   // The object registry
index 1c7274e..4ac9c28 100644 (file)
@@ -388,7 +388,6 @@ private:
   bool mCullMode: 1; ///< Whether renderers should be frustum culled
 
   FrameBufferTexture* mRenderTarget;
-  Viewport mViewport;
 
   State mState;                     ///< Render state.
   unsigned int mRefreshRate;        ///< REFRESH_ONCE, REFRESH_ALWAYS or render every N frames