Add handling for context loss and regain behaviour 70/27370/17
authorDavid Steele <david.steele@partner.samsung.com>
Thu, 11 Sep 2014 18:01:07 +0000 (19:01 +0100)
committerDavid Steele <david.steele@partner.samsung.com>
Wed, 5 Nov 2014 13:19:21 +0000 (13:19 +0000)
[Problem] Dali doesn't handle context loss
[Cause] Never tested.
[Solution]

Fixed ReplaceSurface handling for window surface case. Fixed window destructor to ensure
indicator is correctly removed.

Added new application policy for dealing with context loss. If the application
doesn't support context loss, then Dali must instead retain resource data or have
some means to re-load it.

Added a new data retention policy to PlatformAbstraction. This allows Core to query
what to do with bitmap data and mesh data on context loss / resume.

Change-Id: Ic98d04ada6915eaa600490c1e9465232b3ed6b64
Signed-off-by: David Steele <david.steele@partner.samsung.com>
26 files changed:
adaptors/base/render-thread.cpp
adaptors/common/adaptor-impl.cpp
adaptors/common/adaptor-impl.h
adaptors/common/adaptor.cpp
adaptors/common/adaptor.h
adaptors/common/application-impl.cpp
adaptors/common/application-impl.h
adaptors/common/window-impl.cpp [deleted file]
adaptors/public-api/adaptor-framework/application-configuration.h [new file with mode: 0644]
adaptors/public-api/adaptor-framework/application.cpp
adaptors/public-api/adaptor-framework/application.h
adaptors/public-api/dali.h
adaptors/public-api/file.list
adaptors/wayland/window-impl-wl.cpp
adaptors/x11/egl-implementation-x.cpp
adaptors/x11/window-impl-x.cpp
automated-tests/src/dali-adaptor-internal/image-loaders.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.h
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h
platform-abstractions/slp/image-loaders/image-loader.cpp
platform-abstractions/slp/resource-loader/loader-font.cpp
platform-abstractions/slp/resource-loader/resource-loader.cpp
platform-abstractions/slp/resource-loader/resource-thread-distance-field.cpp
platform-abstractions/slp/resource-loader/resource-thread-text.cpp

index fdf3509..e5f93b2 100644 (file)
@@ -270,7 +270,7 @@ void RenderThread::ReplaceSurface( RenderSurface* newSurface )
   if( contextLost )
   {
     DALI_LOG_WARNING("Context lost\n");
-    mCore.ContextToBeDestroyed();
+    mCore.ContextDestroyed();
     mCore.ContextCreated();
   }
 
@@ -287,8 +287,8 @@ void RenderThread::ReplaceSurface( RenderSurface* newSurface )
 
 void RenderThread::ShutdownEgl()
 {
-  // inform core the context is about to be destroyed,
-  mCore.ContextToBeDestroyed();
+  // inform core of context destruction
+  mCore.ContextDestroyed();
 
   // give a chance to destroy the OpenGL surface that created externally
   mSurface->DestroyEglSurface( *mEGL );
index 47b0bb3..fe46a85 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/public-api/common/dali-common.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/core.h>
+#include <dali/integration-api/context-notifier.h>
 #include <dali/integration-api/profiling.h>
 #include <dali/integration-api/input-options.h>
 #include <dali/integration-api/events/touch-event-integ.h>
@@ -35,6 +36,7 @@
 
 #include <callback-manager.h>
 #include <trigger-event.h>
+#include <window-render-surface.h>
 #include <render-surface-impl.h>
 #include <tts-player-impl.h>
 #include <accessibility-manager-impl.h>
@@ -107,7 +109,8 @@ bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
 
 } // unnamed namespace
 
-Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLayout )
+Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLayout,
+                             Dali::Configuration::ContextLoss configuration )
 {
   DALI_ASSERT_ALWAYS( surface->GetType() != Dali::RenderSurface::NO_SURFACE && "No surface for adaptor" );
 
@@ -115,7 +118,7 @@ Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLay
   Adaptor* impl = new Adaptor( *adaptor, surface, baseLayout );
   adaptor->mImpl = impl;
 
-  impl->Initialize();
+  impl->Initialize(configuration);
 
   return adaptor;
 }
@@ -181,12 +184,20 @@ void Adaptor::ParseEnvironmentOptions()
   mEnvironmentOptions.InstallLogFunction();
 }
 
-void Adaptor::Initialize()
+void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
 {
   ParseEnvironmentOptions();
 
   mPlatformAbstraction = new SlpPlatform::SlpPlatformAbstraction;
 
+  ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
+  if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
+  {
+    dataRetentionPolicy = ResourcePolicy::DALI_RETAINS_MESH_DATA;
+  }
+  // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
+  // files automatically.
+
   if( mEnvironmentOptions.GetPerformanceLoggingLevel() > 0 )
   {
     mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, mEnvironmentOptions );
@@ -211,7 +222,7 @@ void Adaptor::Initialize()
 
   EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
 
-  mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager );
+  mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy );
 
   mObjectProfiler = new ObjectProfiler();
 
@@ -489,6 +500,13 @@ void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
   RenderSurface* internalSurface = dynamic_cast<Internal::Adaptor::RenderSurface*>( &surface );
   DALI_ASSERT_ALWAYS( internalSurface && "Incorrect surface" );
 
+  ECore::WindowRenderSurface* windowSurface = dynamic_cast<Internal::Adaptor::ECore::WindowRenderSurface*>( &surface);
+  if( windowSurface != NULL )
+  {
+    windowSurface->Map();
+    // @todo Restart event handler with new surface
+  }
+
   mSurface = internalSurface;
 
   SurfaceSizeChanged( internalSurface->GetPositionSize() );
@@ -497,8 +515,15 @@ void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
   // to start processing messages for new camera setup etc as soon as possible
   ProcessCoreEvents();
 
-  // this method is synchronous
+  mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
+
+  // this method blocks until the render thread has completed the replace.
   mUpdateRenderController->ReplaceSurface(internalSurface);
+
+  // Inform core, so that texture resources can be reloaded
+  mCore->RecoverFromContextLoss();
+
+  mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
 }
 
 Dali::RenderSurface& Adaptor::GetSurface() const
@@ -679,6 +704,7 @@ void Adaptor::SetMinimumPinchDistance(float distance)
   }
 }
 
+
 void Adaptor::AddObserver( LifeCycleObserver& observer )
 {
   ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
@@ -811,7 +837,9 @@ void Adaptor::ProcessCoreEventsFromIdle()
 }
 
 Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
-: mAdaptor(adaptor),
+: mResizedSignalV2(),
+  mLanguageChangedSignalV2(),
+  mAdaptor(adaptor),
   mState(READY),
   mCore(NULL),
   mUpdateRenderController(NULL),
index 4979cc3..7b1ddbd 100644 (file)
@@ -96,13 +96,16 @@ public:
    *                         - Pixmap, adaptor will use existing Pixmap to draw on to
    *                         - Window, adaptor will use existing Window to draw on to
    * @param[in]  baseLayout  The base layout that the application has been written for
+   * @param[in]  configuration The context loss configuration ( to choose resource discard policy )
    */
-  static Dali::Adaptor* New( RenderSurface* surface, const DeviceLayout& baseLayout );
+  static Dali::Adaptor* New( RenderSurface* surface,
+                             const DeviceLayout& baseLayout,
+                             Dali::Configuration::ContextLoss configuration );
 
   /**
    * 2-step initialisation, this should be called after creating an adaptor instance.
    */
-  void Initialize();
+  void Initialize(Dali::Configuration::ContextLoss configuration);
 
   /**
    * Virtual destructor.
index c63ae26..bbede1e 100644 (file)
@@ -35,13 +35,13 @@ namespace Dali
 
 Adaptor& Adaptor::New( Window window )
 {
-  return New( window, DeviceLayout::DEFAULT_BASE_LAYOUT );
+  return New( window, DeviceLayout::DEFAULT_BASE_LAYOUT, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS );
 }
 
-Adaptor& Adaptor::New( Window window, const DeviceLayout& baseLayout )
+Adaptor& Adaptor::New( Window window, const DeviceLayout& baseLayout, Configuration::ContextLoss configuration )
 {
   Internal::Adaptor::Window& windowImpl = GetImplementation(window);
-  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( windowImpl.GetSurface(), baseLayout );
+  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( windowImpl.GetSurface(), baseLayout, configuration );
   windowImpl.SetAdaptor(*adaptor);
   return *adaptor;
 }
index 9200a35..cffa76b 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <boost/function.hpp>
 #include "window.h"
+#include "application-configuration.h"
 #include "tts-player.h"
 #include <dali/public-api/signals/dali-signal-v2.h>
 #include <dali/public-api/math/rect.h>
@@ -119,9 +120,10 @@ public:
    *
    * @param[in] window The window to draw onto
    * @param[in] baseLayout  The base layout that the application has been written for
+   * @param[in] configuration The context loss configuration.
    * @return a reference to the adaptor handle
    */
-  static Adaptor& New( Window window, const DeviceLayout& baseLayout );
+  static Adaptor& New( Window window, const DeviceLayout& baseLayout, Configuration::ContextLoss configuration );
 
   /**
    * @brief Virtual Destructor.
index b1fb349..a925de5 100644 (file)
@@ -119,7 +119,7 @@ void Application::CreateAdaptor()
 {
   DALI_ASSERT_ALWAYS( mWindow && "Window required to create adaptor" );
 
-  mAdaptor = &Dali::Adaptor::New( mWindow, mBaseLayout);
+  mAdaptor = &Dali::Adaptor::New( mWindow, mBaseLayout, mContextLossConfiguration );
 
   // Allow DPI to be overridden from command line.
   unsigned int hDPI=DEFAULT_HORIZONTAL_DPI;
@@ -135,8 +135,10 @@ void Application::CreateAdaptor()
   mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize );
 }
 
-void Application::MainLoop()
+void Application::MainLoop(Dali::Configuration::ContextLoss configuration)
 {
+  mContextLossConfiguration = configuration;
+
   // Run the application
   mFramework->Run();
 }
@@ -294,6 +296,18 @@ float Application::GetStereoBase() const
   return Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetStereoBase();
 }
 
+
+void Application::ReplaceWindow(PositionSize windowPosition, const std::string& name)
+{
+  Dali::Window newWindow = Dali::Window::New( windowPosition, name, mWindowMode == Dali::Application::TRANSPARENT );
+  Window& windowImpl = GetImplementation(newWindow);
+  windowImpl.SetAdaptor(*mAdaptor);
+  newWindow.ShowIndicator(Dali::Window::INVISIBLE);
+  Dali::RenderSurface* renderSurface = windowImpl.GetSurface();
+  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(*renderSurface);
+  mWindow = newWindow;
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index 8301f00..e9bdf0b 100644 (file)
@@ -85,7 +85,7 @@ public:
   /**
    * @copydoc Dali::Application::MainLoop()
    */
-  void MainLoop();
+  void MainLoop(Dali::Configuration::ContextLoss configuration);
 
   /**
    * @copydoc Dali::Application::Lower()
@@ -122,6 +122,11 @@ public:
    */
   void SetTheme(const std::string& themeFilePath);
 
+  /**
+   * @copydoc Dali::Application::ReplaceWindow();
+   */
+  void ReplaceWindow(PositionSize windowPosition, const std::string& name);
+
 public: // Stereoscopy
 
   /**
@@ -256,6 +261,7 @@ private:
   EventLoop*                            mEventLoop;
   Framework*                            mFramework;
 
+  Dali::Configuration::ContextLoss      mContextLossConfiguration;
   CommandLineOptions*                   mCommandLineOptions;
 
   Dali::SingletonService                mSingletonService;
diff --git a/adaptors/common/window-impl.cpp b/adaptors/common/window-impl.cpp
deleted file mode 100644 (file)
index 20c6bde..0000000
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * Copyright (c) 2014 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 "window-impl.h"
-
-// EXTERNAL HEADERS
-#include <Ecore.h>
-#ifdef WAYLAND
-#include <Ecore_Wayland.h>
-#else
-#include <Ecore_X.h>
-#endif
-
-#include <dali/integration-api/core.h>
-#include <dali/integration-api/system-overlay.h>
-#include <dali/public-api/render-tasks/render-task.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
-#include <orientation.h>
-
-// INTERNAL HEADERS
-#ifdef WAYLAND
-#include <ecore-wl/wl-window-render-surface.h>
-#else
-#include <ecore-x/window-render-surface.h>
-#endif
-#include <drag-and-drop-detector-impl.h>
-#include <indicator-impl.h>
-#include <window-visibility-observer.h>
-#include <orientation-impl.h>
-
-namespace
-{
-const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
-const float INDICATOR_SHOW_Y_POSITION( 0.0f );
-const float INDICATOR_HIDE_Y_POSITION( -52.0f );
-}
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
-#endif
-
-/**
- * TODO: Abstract Window class out and move this into a window implementation for Ecore
- */
-struct Window::EventHandler
-{
-  /**
-   * Constructor
-   * @param[in]  window  A pointer to the window class.
-   */
-  EventHandler( Window* window )
-  : mWindow( window ),
-#ifndef WAYLAND
-    mWindowPropertyHandler( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY,  EcoreEventWindowPropertyChanged, this ) ),
-    mClientMessagehandler( ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE,  EcoreEventClientMessage, this ) ),
-#endif
-    mEcoreWindow( 0 )
-  {
-#ifndef WAYLAND
-    // store ecore window handle
-    ECoreX::WindowRenderSurface* x11Window( dynamic_cast< ECoreX::WindowRenderSurface * >( mWindow->mSurface ) );
-    if( x11Window )
-    {
-      mEcoreWindow = x11Window->GetXWindow();
-    }
-    DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore x window");
-
-    // set property on window to get deiconify approve client message
-    unsigned int tmp = 1;
-    ecore_x_window_prop_card32_set(mEcoreWindow,
-                             ECORE_X_ATOM_E_DEICONIFY_APPROVE,
-                             &tmp, 1);
-#endif
-  }
-
-  /**
-   * Destructor
-   */
-  ~EventHandler()
-  {
-    if ( mWindowPropertyHandler )
-    {
-      ecore_event_handler_del( mWindowPropertyHandler );
-    }
-    if ( mClientMessagehandler )
-    {
-      ecore_event_handler_del( mClientMessagehandler );
-    }
-  }
-
-  // Static methods
-
-  /// Called when the window properties are changed.
-  static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
-  {
-#ifdef WAYLAND
-    return EINA_FALSE;
-#else
-    Ecore_X_Event_Window_Property* propertyChangedEvent( (Ecore_X_Event_Window_Property*)event );
-    EventHandler* handler( (EventHandler*)data );
-    Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
-
-    if ( handler && handler->mWindow )
-    {
-      WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
-      if ( observer && ( propertyChangedEvent->win == handler->mEcoreWindow ) )
-      {
-        Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) );
-
-        switch ( state )
-        {
-          case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
-          {
-            // Window was hidden.
-            observer->OnWindowHidden();
-            DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Withdrawn\n", handler->mEcoreWindow );
-            handled = ECORE_CALLBACK_DONE;
-          }
-          break;
-
-          case ECORE_X_WINDOW_STATE_HINT_ICONIC:
-          {
-            // Window was iconified (minimised).
-            observer->OnWindowHidden();
-            DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Iconfied\n", handler->mEcoreWindow );
-            handled = ECORE_CALLBACK_DONE;
-          }
-          break;
-
-          case ECORE_X_WINDOW_STATE_HINT_NORMAL:
-          {
-            // Window was shown.
-            observer->OnWindowShown();
-            DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Shown\n", handler->mEcoreWindow );
-            handled = ECORE_CALLBACK_DONE;
-          }
-          break;
-
-          default:
-            // Ignore
-            break;
-        }
-      }
-    }
-
-    return handled;
-#endif
-  }
-
-  /// Called when the window properties are changed.
-  static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
-  {
-#ifdef WAYLAND
-    return EINA_FALSE;
-#else
-    Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
-    Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
-    EventHandler* handler( (EventHandler*)data );
-
-    if (clientMessageEvent->message_type == ECORE_X_ATOM_E_DEICONIFY_APPROVE)
-    {
-      ECoreX::WindowRenderSurface* x11Window( dynamic_cast< ECoreX::WindowRenderSurface * >( handler->mWindow->mSurface ) );
-      WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
-
-      if ( observer && ( (unsigned int)clientMessageEvent->data.l[0] == handler->mEcoreWindow ) )
-      {
-        if (clientMessageEvent->data.l[1] == 0) //wm sends request message using value 0
-        {
-          observer->OnWindowShown();
-
-          // request to approve the deiconify. render-surface should send proper event after real rendering
-          if(x11Window)
-          {
-            x11Window->RequestToApproveDeiconify();
-          }
-
-          handled = ECORE_CALLBACK_DONE;
-        }
-      }
-    }
-
-    return handled;
-#endif
-  }
-
-  // Data
-  Window* mWindow;
-  Ecore_Event_Handler* mWindowPropertyHandler;
-  Ecore_Event_Handler* mClientMessagehandler;
-#ifdef WAYLAND
-  Ecore_Wl_Window* mEcoreWindow;
-#else
-  Ecore_X_Window mEcoreWindow;
-#endif
-};
-
-
-Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
-{
-  Window* window = new Window();
-  window->mIsTransparent = isTransparent;
-  window->Initialize(posSize, name);
-  return window;
-}
-
-void Window::SetAdaptor(Dali::Adaptor& adaptor)
-{
-  DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
-  mStarted = true;
-
-  // Only create one overlay per window
-  Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
-  Integration::Core& core = adaptorImpl.GetCore();
-  mOverlay = &core.GetSystemOverlay();
-
-  Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
-  taskList.CreateTask();
-
-  mAdaptor = &adaptorImpl;
-  mAdaptor->AddObserver( *this );
-
-  // Can only create the detector when we know the Core has been instantiated.
-  mDragAndDropDetector = DragAndDropDetector::New();
-  mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
-
-  if( mOrientation )
-  {
-    mOrientation->SetAdaptor(adaptor);
-  }
-
-  if( mIndicator != NULL )
-  {
-    mIndicator->SetAdaptor(mAdaptor);
-  }
-}
-
-RenderSurface* Window::GetSurface()
-{
-  return mSurface;
-}
-
-void Window::SetIndicatorStyle( Dali::Window::IndicatorStyle style )
-{
-  mIndicatorStyle = style;
-}
-
-void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
-{
-  DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
-  DALI_ASSERT_DEBUG(mOverlay);
-
-#ifndef WAYLAND
-  ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-  DALI_ASSERT_DEBUG(x11Window);
-  Ecore_X_Window xWinId = x11Window->GetXWindow();
-
-  mIndicatorVisible = visibleMode;
-
-  if ( mIndicatorVisible == Dali::Window::VISIBLE )
-  {
-    // when the indicator is visible, set proper mode for indicator server according to bg mode
-    if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
-    {
-      ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_OPAQUE);
-    }
-    else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
-    {
-      ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
-    }
-#if defined(DALI_PROFILE_MOBILE)
-    else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
-    {
-      ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_BG_TRANSPARENT);
-    }
-#endif
-  }
-  else
-  {
-    // when the indicator is not visible, set TRANSPARENT mode for indicator server
-    ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSPARENT); // it means hidden indicator
-  }
-#endif
-
-  DoShowIndicator( mIndicatorOrientation );
-}
-
-void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
-{
-  DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
-
-  DoRotateIndicator( orientation );
-}
-
-void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
-{
-  mIndicatorOpacityMode = opacityMode;
-
-  if( mIndicator != NULL )
-  {
-    mIndicator->SetOpacityMode( opacityMode );
-  }
-}
-
-void Window::SetClass(std::string name, std::string klass)
-{
-  // Get render surface's x11 window
-  if( mSurface )
-  {
-#ifndef WAYLAND
-    ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-    if( x11Window )
-    {
-      ecore_x_icccm_name_class_set( x11Window->GetXWindow(), name.c_str(), klass.c_str() );
-    }
-#endif
-  }
-}
-
-Window::Window()
-: mSurface(NULL),
-  mIndicatorStyle(Dali::Window::CHANGEABLE_COLOR),
-  mIndicatorVisible(Dali::Window::VISIBLE),
-  mIndicatorIsShown(false),
-  mShowRotatedIndicatorOnClose(false),
-  mStarted(false),
-  mIsTransparent(false),
-  mWMRotationAppSet(false),
-  mIndicator(NULL),
-  mIndicatorOrientation(Dali::Window::PORTRAIT),
-  mNextIndicatorOrientation(Dali::Window::PORTRAIT),
-  mIndicatorOpacityMode(Dali::Window::OPAQUE),
-  mOverlay(NULL),
-  mAdaptor(NULL)
-{
-}
-
-Window::~Window()
-{
-  delete mEventHandler;
-
-  if ( mAdaptor )
-  {
-    mAdaptor->RemoveObserver( *this );
-    mAdaptor->SetDragAndDropDetector( NULL );
-    mAdaptor = NULL;
-  }
-
-  delete mSurface;
-}
-
-void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
-{
-  // create an X11 window by default
-  Any surface;
-  Any display;
-#ifdef WAYLAND
-  mSurface = new ECoreWayland::WindowRenderSurface( windowPosition, surface, display, name, mIsTransparent );
-#else
-  mSurface = new ECoreX::WindowRenderSurface( windowPosition, surface, display, name, mIsTransparent );
-#endif
-  mOrientation = Orientation::New(this);
-
-  // create event handler for X11 window
-  mEventHandler = new EventHandler( this );
-}
-
-void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
-{
-  if( mIndicator == NULL )
-  {
-    if( mIndicatorVisible != Dali::Window::INVISIBLE )
-    {
-      mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, mIndicatorStyle, this );
-      mIndicator->SetOpacityMode( mIndicatorOpacityMode );
-      Dali::Actor actor = mIndicator->GetActor();
-      SetIndicatorActorRotation();
-      mOverlay->Add(actor);
-    }
-    // else don't create a hidden indicator
-  }
-  else // Already have indicator
-  {
-    if( mIndicatorVisible == Dali::Window::VISIBLE )
-    {
-      // If we are resuming, and rotation has changed,
-      if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
-      {
-        // then close current indicator and open new one
-        mShowRotatedIndicatorOnClose = true;
-        mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
-        // Don't show actor - will contain indicator for old orientation.
-      }
-    }
-  }
-
-  // set indicator visible mode
-  if( mIndicator != NULL )
-  {
-    mIndicator->SetVisible( mIndicatorVisible );
-  }
-
-  bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
-  SetIndicatorProperties( show, lastOrientation );
-  mIndicatorIsShown = show;
-}
-
-void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
-{
-  if( mIndicatorIsShown )
-  {
-    mShowRotatedIndicatorOnClose = true;
-    mNextIndicatorOrientation = orientation;
-    mIndicator->Close(); // May synchronously call IndicatorClosed() callback
-  }
-  else
-  {
-    // Save orientation for when the indicator is next shown
-    mShowRotatedIndicatorOnClose = false;
-    mNextIndicatorOrientation = orientation;
-  }
-}
-
-void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
-{
-#ifndef WAYLAND
-  ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-  if( x11Window )
-  {
-    Ecore_X_Window win = x11Window->GetXWindow();
-
-    int show_state = static_cast<int>( isShow );
-    ecore_x_window_prop_property_set( win,
-                                      ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE,
-                                      ECORE_X_ATOM_CARDINAL, 32, &show_state, 1);
-
-    if ( isShow )
-    {
-      ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_ON);
-    }
-    else
-    {
-      ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
-    }
-  }
-#endif
-}
-
-void Window::IndicatorTypeChanged(Indicator::Type type)
-{
-#ifndef WAYLAND
-  ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-  if( x11Window )
-  {
-    Ecore_X_Window win = x11Window->GetXWindow();
-    switch(type)
-    {
-      case Indicator::INDICATOR_TYPE_1:
-        ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_1 );
-        break;
-
-      case Indicator::INDICATOR_TYPE_2:
-        ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_2 );
-        break;
-
-      case Indicator::INDICATOR_TYPE_UNKNOWN:
-      default:
-        break;
-    }
-  }
-#endif
-}
-
-void Window::IndicatorClosed( Indicator* indicator )
-{
-  DALI_LOG_TRACE_METHOD( gWindowLogFilter );
-
-  if( mShowRotatedIndicatorOnClose )
-  {
-    Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
-    mIndicator->Open(mNextIndicatorOrientation);
-    mIndicatorOrientation = mNextIndicatorOrientation;
-    SetIndicatorActorRotation();
-    DoShowIndicator(currentOrientation);
-  }
-}
-
-void Window::SetIndicatorActorRotation()
-{
-  DALI_LOG_TRACE_METHOD( gWindowLogFilter );
-  DALI_ASSERT_DEBUG( mIndicator != NULL );
-
-  Dali::Actor actor = mIndicator->GetActor();
-  switch( mIndicatorOrientation )
-  {
-    case Dali::Window::PORTRAIT:
-      actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
-      actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetRotation( Degree(0), Vector3::ZAXIS );
-      break;
-    case Dali::Window::PORTRAIT_INVERSE:
-      actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
-      actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetRotation( Degree(180), Vector3::ZAXIS );
-      break;
-    case Dali::Window::LANDSCAPE:
-      actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
-      actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetRotation( Degree(270), Vector3::ZAXIS );
-      break;
-    case Dali::Window::LANDSCAPE_INVERSE:
-      actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
-      actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetRotation( Degree(90), Vector3::ZAXIS );
-      break;
-  }
-}
-
-void Window::Raise()
-{
-#ifndef WAYLAND
-  ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-  if( x11Window )
-  {
-    Ecore_X_Window win = x11Window->GetXWindow();
-    ecore_x_window_raise(win);
-  }
-#endif
-}
-
-void Window::Lower()
-{
-#ifndef WAYLAND
-  ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-  if( x11Window )
-  {
-    Ecore_X_Window win = x11Window->GetXWindow();
-    ecore_x_window_lower(win);
-  }
-#endif
-}
-
-void Window::Activate()
-{
-#ifndef WAYLAND
-  ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-  if( x11Window )
-  {
-    Ecore_X_Window win = x11Window->GetXWindow();
-    ecore_x_netwm_client_active_request(ecore_x_window_root_get(win), win, 1 /* request type, 1:application, 2:pager */, 0);
-  }
-#endif
-}
-
-Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
-{
-  return mDragAndDropDetector;
-}
-
-void Window::OnStart()
-{
-  DoShowIndicator( mIndicatorOrientation );
-}
-
-void Window::OnPause()
-{
-}
-
-void Window::OnResume()
-{
-  // resume indicator status
-  if( mIndicator != NULL )
-  {
-    // Restore own indicator opacity
-    // Send opacity mode to indicator service when app resumed
-    mIndicator->SetOpacityMode( mIndicatorOpacityMode );
-  }
-}
-
-void Window::OnStop()
-{
-  if( mIndicator )
-  {
-    mIndicator->Close();
-  }
-
-  delete mIndicator;
-  mIndicator = NULL;
-}
-
-void Window::OnDestroy()
-{
-  mAdaptor = NULL;
-}
-
-OrientationPtr Window::GetOrientation()
-{
-  return mOrientation;
-}
-
-void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
-{
-  bool found = false;
-
-  for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
-  {
-    if(mAvailableOrientations[i] == orientation)
-    {
-      found = true;
-      break;
-    }
-  }
-
-  if( ! found )
-  {
-    mAvailableOrientations.push_back(orientation);
-    SetAvailableOrientations( mAvailableOrientations );
-  }
-}
-
-void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
-{
-  for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
-       iter != mAvailableOrientations.end(); ++iter )
-  {
-    if( *iter == orientation )
-    {
-      mAvailableOrientations.erase( iter );
-      break;
-    }
-  }
-  SetAvailableOrientations( mAvailableOrientations );
-}
-
-void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
-{
-  DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
-
-#ifndef WAYLAND
-  mAvailableOrientations = orientations;
-  ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-  if( x11Window )
-  {
-    Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
-    if( ! mWMRotationAppSet )
-    {
-      mWMRotationAppSet = true;
-      ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
-    }
-
-    int rotations[4];
-    for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
-    {
-      rotations[i] = static_cast<int>(mAvailableOrientations[i]);
-    }
-    ecore_x_e_window_rotation_available_rotations_set(ecoreWindow, rotations, mAvailableOrientations.size() );
-
-  }
-#endif
-}
-
-const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
-{
-  return mAvailableOrientations;
-}
-
-void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
-{
-  mPreferredOrientation = orientation;
-
-#ifndef WAYLAND
-  ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-  if( x11Window )
-  {
-    Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
-
-    if( ! mWMRotationAppSet )
-    {
-      mWMRotationAppSet = true;
-      ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
-    }
-
-    ecore_x_e_window_rotation_preferred_rotation_set(ecoreWindow, orientation);
-  }
-#endif
-}
-
-Dali::Window::WindowOrientation Window::GetPreferredOrientation()
-{
-  return mPreferredOrientation;
-}
-
-void Window::RotationDone( int orientation, int width, int height )
-{
-#ifndef WAYLAND
-  // Tell window manager we're done
-  ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
-  if( x11Window )
-  {
-    Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
-    Ecore_X_Window root = ecore_x_window_root_get(ecoreWindow);
-
-    /**
-     * send rotation done message to wm, even if window is already rotated.
-     * that's why wm must be wait for comming rotation done message
-     * after sending rotation request.
-     */
-    ecore_x_e_window_rotation_change_done_send(root, ecoreWindow, orientation, width, height);
-
-    /**
-     * set rotate window property
-     */
-    int angles[2] = { orientation, orientation };
-    ecore_x_window_prop_property_set( ecoreWindow,
-                                     ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
-                                     ECORE_X_ATOM_CARDINAL, 32, &angles, 2 );
-  }
-#endif
-}
-
-
-} // Adaptor
-} // Internal
-} // Dali
diff --git a/adaptors/public-api/adaptor-framework/application-configuration.h b/adaptors/public-api/adaptor-framework/application-configuration.h
new file mode 100644 (file)
index 0000000..fb925ed
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __DALI_APPLICATION_CONFIGURATION_H__
+#define __DALI_APPLICATION_CONFIGURATION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ */
+
+namespace Dali
+{
+namespace Configuration
+{
+enum ContextLoss
+{
+  APPLICATION_HANDLES_CONTEXT_LOSS,  ///< Application will tear down and recreate UI on context loss and context regained signals. Dali doesn't need to retain data.
+  APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS, ///< Application expects Dali to retain data ( increased memory footprint )
+};
+
+} // Configuration
+} // namespace Dali
+
+#endif
index 3f6b27a..642790b 100644 (file)
@@ -88,7 +88,12 @@ Application& Application::operator=(const Application& application)
 
 void Application::MainLoop()
 {
-  Internal::Adaptor::GetImplementation(*this).MainLoop();
+  Internal::Adaptor::GetImplementation(*this).MainLoop(Configuration::APPLICATION_HANDLES_CONTEXT_LOSS);
+}
+
+void Application::MainLoop(Configuration::ContextLoss configuration)
+{
+  Internal::Adaptor::GetImplementation(*this).MainLoop(configuration);
 }
 
 void Application::Lower()
@@ -121,6 +126,11 @@ Window Application::GetWindow()
   return Internal::Adaptor::GetImplementation(*this).GetWindow();
 }
 
+void Application::ReplaceWindow(PositionSize windowPosition, const std::string& name)
+{
+  Internal::Adaptor::GetImplementation(*this).ReplaceWindow(windowPosition, name);
+}
+
 void Application::SetViewMode( ViewMode viewMode )
 {
   Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
index 6c7a2c3..37a3577 100644 (file)
@@ -24,6 +24,7 @@
 #include <dali/public-api/object/base-handle.h>
 #include <dali/public-api/common/view-mode.h>
 
+#include "application-configuration.h"
 #include "style-monitor.h"
 #include "device-layout.h"
 #include "window.h"
@@ -193,11 +194,22 @@ public:
 
 public:
   /**
-   * This starts the application.
+   * This starts the application. Choosing this form of main loop indicates that the default
+   * application configuration of APPLICATION_HANDLES_CONTEXT_LOSS is used. On platforms where
+   * context loss can occur, the application is responsible for tearing down and re-loading UI.
+   * The application should listen to Stage::ContextLostSignal and Stage::ContextRegainedSignal.
    */
   void MainLoop();
 
   /**
+   * This starts the application, and allows the app to choose a different configuration.
+   * If the application plans on using the ReplaceSurface or ReplaceWindow API, then this will
+   * trigger context loss & regain.
+   * The application should listen to Stage::ContextLostSignal and Stage::ContextRegainedSignal.
+   */
+  void MainLoop(Configuration::ContextLoss configuration);
+
+  /**
    * This lowers the application to bottom without actually quitting it
    */
   void Lower();
@@ -236,6 +248,16 @@ public:
    */
   Window GetWindow();
 
+  /**
+   * Replace the current window.
+   * This will force context loss.
+   * If you plan on using this API in your application, then you should configure
+   * it to prevent discard behaviour when handling the Init signal.
+   * @param[in] windowPosition The position and size parameters of the new window
+   * @param[in] name The name of the new window
+   */
+  void ReplaceWindow(PositionSize windowPosition, const std::string& name);
+
 public: // Stereoscopy
 
   /**
@@ -266,7 +288,7 @@ public:  // Signals
 
   /**
    * The user should connect to this signal to determine when they should initialise
-   * their application
+   * their application.
    */
   AppSignalV2& InitSignal();
 
index 6ae56ad..86159b5 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali/public-api/adaptor-framework/accessibility-gesture-handler.h>
 #include <dali/public-api/adaptor-framework/accessibility-manager.h>
 #include <dali/public-api/adaptor-framework/application.h>
+#include <dali/public-api/adaptor-framework/application-configuration.h>
 #include <dali/public-api/adaptor-framework/bitmap-loader.h>
 #include <dali/public-api/adaptor-framework/bitmap-saver.h>
 #include <dali/public-api/adaptor-framework/clipboard.h>
index e71adba..7e0c9b0 100644 (file)
@@ -34,6 +34,7 @@ public_api_adaptor_framework_header_files = \
   $(adaptor_public_api_dir)/adaptor-framework/accessibility-gesture-handler.h \
   $(adaptor_public_api_dir)/adaptor-framework/accessibility-manager.h \
   $(adaptor_public_api_dir)/adaptor-framework/application.h \
+  $(adaptor_public_api_dir)/adaptor-framework/application-configuration.h \
   $(adaptor_public_api_dir)/adaptor-framework/bitmap-loader.h \
   $(adaptor_public_api_dir)/adaptor-framework/bitmap-saver.h \
   $(adaptor_public_api_dir)/adaptor-framework/clipboard-event-notifier.h \
index 539fcd7..6bc1d56 100644 (file)
@@ -204,6 +204,12 @@ Window::~Window()
 {
   delete mEventHandler;
 
+  if( mIndicator )
+  {
+    mIndicator->Close();
+    delete mIndicator;
+  }
+
   if ( mAdaptor )
   {
     mAdaptor->RemoveObserver( *this );
index d007347..cccf568 100644 (file)
@@ -450,29 +450,24 @@ bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNat
 {
   bool contextLost = false;
 
-  //  the surface is bound to the context, so set the context to null
-  MakeContextNull();
-
-  // destroy the surface
-  DestroySurface();
-
-  // If the display has not changed, then we can just create a new surface
+  // If the display connection has not changed, then we can just create a new surface
   if ( display == mEglNativeDisplay )
   {
+    //  the surface is bound to the context, so set the context to null
+    MakeContextNull();
+
+    // destroy the surface
+    DestroySurface();
+
     // create the EGL surface
     CreateSurfaceWindow( window, mColorDepth );
 
     // set the context to be current with the new surface
     MakeContextCurrent();
   }
-  else  // the display has changed, we need to start egl with a new x-connection
+  else  // the display connection has changed, we need to start egl with a new x-connection
   {
-    // Note! this code path is untested
-
-    // this will release all EGL specific resources
-    eglTerminate( mEglDisplay );
-
-    mGlesInitialized = false;
+    TerminateGles();
 
     // let the adaptor know that all resources have been lost
     contextLost = true;
@@ -483,7 +478,7 @@ bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNat
     // create the EGL surface
     CreateSurfaceWindow( window, mColorDepth );
 
-    // create the OpenGL context
+     // create the OpenGL context
     CreateContext();
 
     // Make it current
index 9f7b158..7165cc2 100644 (file)
@@ -335,7 +335,17 @@ Window::~Window()
 {
   delete mEventHandler;
 
-  if ( mAdaptor )
+  if( mIndicator )
+  {
+    mOverlay->Remove( mIndicator->GetActor() );
+    Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
+    Dali::RenderTask indicatorTask = taskList.GetTask(0);
+    mOverlay->GetOverlayRenderTasks().RemoveTask(indicatorTask);
+    mIndicator->Close();
+    delete mIndicator;
+  }
+
+  if( mAdaptor )
   {
     mAdaptor->RemoveObserver( *this );
     mAdaptor->SetDragAndDropDetector( NULL );
index 94a5ae3..5e09dff 100644 (file)
@@ -111,7 +111,7 @@ void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions
   fseek( fp, 0, 0 );
 
   // Create a bitmap object and store a pointer to that object so it is destroyed at the end.
-  Dali::Integration::Bitmap * bitmap = Dali::Integration::Bitmap::New( Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS,  false  );
+  Dali::Integration::Bitmap * bitmap = Dali::Integration::Bitmap::New( Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS,  ResourcePolicy::RETAIN  );
   Dali::Integration::BitmapPtr bitmapPtr( bitmap );
 
 
@@ -139,7 +139,7 @@ void DumpImageBufferToTempFile( std::string filename, std::string targetFilename
   FILE* fp = fopen( filename.c_str() , "rb" );
   AutoCloseFile autoClose( fp );
 
-  Dali::Integration::Bitmap* bitmap = Dali::Integration::Bitmap::New( Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS,  false );
+  Dali::Integration::Bitmap* bitmap = Dali::Integration::Bitmap::New( Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS,  ResourcePolicy::RETAIN );
   Dali::Integration::BitmapPtr bitmapPtr( bitmap );
   Dali::ImageAttributes attributes;
 
index c2680b2..89138eb 100644 (file)
@@ -24,13 +24,15 @@ namespace Dali
 TestApplication::TestApplication( size_t surfaceWidth,
                                   size_t surfaceHeight,
                                   float  horizontalDpi,
-                                  float  verticalDpi)
+                                  float  verticalDpi,
+                                  ResourcePolicy::DataRetention policy)
 : mCore( NULL ),
   mSurfaceWidth( surfaceWidth ),
   mSurfaceHeight( surfaceHeight ),
   mFrame( 0u ),
   mDpi( horizontalDpi, verticalDpi ),
-  mLastVSyncTime(0u)
+  mLastVSyncTime(0u),
+  mDataRetentionPolicy( policy )
 {
   Initialize();
 }
@@ -39,12 +41,14 @@ TestApplication::TestApplication( bool   initialize,
                                   size_t surfaceWidth,
                                   size_t surfaceHeight,
                                   float  horizontalDpi,
-                                  float  verticalDpi )
+                                  float  verticalDpi,
+                                  ResourcePolicy::DataRetention policy)
 : mCore( NULL ),
   mSurfaceWidth( surfaceWidth ),
   mSurfaceHeight( surfaceHeight ),
   mFrame( 0u ),
-  mDpi( horizontalDpi, verticalDpi )
+  mDpi( horizontalDpi, verticalDpi ),
+  mDataRetentionPolicy( policy )
 {
   if ( initialize )
   {
@@ -59,7 +63,8 @@ void TestApplication::Initialize()
     mPlatformAbstraction,
     mGlAbstraction,
     mGlSyncAbstraction,
-    mGestureManager );
+    mGestureManager,
+    mDataRetentionPolicy);
 
   mCore->ContextCreated();
   mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
@@ -190,7 +195,7 @@ bool TestApplication::RenderOnly( )
 
 void TestApplication::ResetContext()
 {
-  mCore->ContextToBeDestroyed();
+  mCore->ContextDestroyed();
   mCore->ContextCreated();
 }
 
index bcc2dd8..c91086e 100644 (file)
@@ -25,6 +25,7 @@
 #include "test-gl-abstraction.h"
 #include "test-render-controller.h"
 #include <dali/public-api/common/dali-common.h>
+#include <dali/integration-api/resource-policies.h>
 
 namespace Dali
 {
@@ -50,13 +51,15 @@ public:
   TestApplication( size_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
                    size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
                    float  horizontalDpi = DEFAULT_HORIZONTAL_DPI,
-                   float  verticalDpi   = DEFAULT_VERTICAL_DPI );
+                   float  verticalDpi   = DEFAULT_VERTICAL_DPI,
+                   ResourcePolicy::DataRetention policy = ResourcePolicy::DALI_DISCARDS_ALL_DATA);
 
   TestApplication( bool   initialize,
                    size_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
                    size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
                    float  horizontalDpi = DEFAULT_HORIZONTAL_DPI,
-                   float  verticalDpi   = DEFAULT_VERTICAL_DPI );
+                   float  verticalDpi   = DEFAULT_VERTICAL_DPI,
+                   ResourcePolicy::DataRetention policy = ResourcePolicy::DALI_DISCARDS_ALL_DATA);
 
   void Initialize();
   virtual ~TestApplication();
@@ -97,6 +100,7 @@ protected:
 
   Vector2 mDpi;
   unsigned int mLastVSyncTime;
+  ResourcePolicy::DataRetention mDataRetentionPolicy;
 };
 
 } // Dali
index ef3eb77..aa1b5b2 100644 (file)
@@ -227,7 +227,7 @@ Integration::GlyphSet* TestPlatformAbstraction::GetGlyphData ( const Integration
 
       if( getBitmap )
       {
-        bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true);
+        bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
         bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
         PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
         memset( pixelBuffer, it->character, 64*64 );
@@ -268,7 +268,7 @@ Integration::GlyphSet* TestPlatformAbstraction::GetCachedGlyphData( const Integr
       characters.insert( it->character );
       Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY,  10.0f,  10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition };
 
-      bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true);
+      bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
       bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
       PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
       memset( pixelBuffer, it->character, 64*64 );
@@ -455,7 +455,7 @@ void TestPlatformAbstraction::GetFileNamesFromDirectory( const std::string& dire
 
 Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const
 {
-  Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true );
+  Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
   image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 );
 
   mTrace.PushCall("GetGlyphImage", "");
index 2d4c38c..54cb154 100644 (file)
@@ -326,7 +326,6 @@ public: // TEST FUNCTIONS
 
   void SetReadMetricsResult( bool success, std::vector<Integration::GlyphMetrics>& glyphMetricsContainer );
 
-
 private:
   mutable TraceCallStack        mTrace;
   size_t                        mSeconds;
index 74d293a..c8825d5 100644 (file)
@@ -269,7 +269,7 @@ bool ConvertStreamToBitmap(const ResourceType& resourceType, std::string path, F
                                    header,
                                    profile ) )
     {
-      bitmap = Bitmap::New(profile, true);
+      bitmap = Bitmap::New(profile, ResourcePolicy::DISCARD );
 
       DALI_LOG_SET_OBJECT_STRING(bitmap, path);
       const BitmapResourceType& resType = static_cast<const BitmapResourceType&>(resourceType);
@@ -331,7 +331,7 @@ bool ConvertStreamToBitmap(const ResourceType& resourceType, std::string path, F
 
             const unsigned newWidth = loadedWidth - 2 * columnsToTrim;
             const unsigned newHeight = loadedHeight - 2 * scanlinesToTrim;
-            BitmapPtr croppedBitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, true );
+            BitmapPtr croppedBitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
             Bitmap::PackedPixelsProfile * packedView = croppedBitmap->GetPackedPixelsProfile();
             DALI_ASSERT_DEBUG( packedView );
             const Pixel::Format pixelFormat = bitmap->GetPixelFormat();
index 09ff13f..3a06871 100644 (file)
@@ -273,7 +273,7 @@ GlyphSet::Character* GetCharacter(FT_Face face, FT_ULong charcode,
       std::vector<unsigned char> underlineAlphaMap(underlineBitmapSize);
       std::fill(underlineAlphaMap.begin(), underlineAlphaMap.end(), 0xff);
 
-      bitmapData = Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, true);
+      bitmapData = Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
       bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, fieldSize, fieldSize);
       GenerateDistanceFieldMap( &(*underlineAlphaMap.begin()), Vector2(underlineBitmapWidth, underlineBitmapHeight),
                                bitmapData->GetBuffer(), Vector2(fieldSize, fieldSize),
@@ -284,7 +284,7 @@ GlyphSet::Character* GetCharacter(FT_Face face, FT_ULong charcode,
     {
       if (0 != (bitmap.width * bitmap.rows))
       {
-        bitmapData = Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, true);
+        bitmapData = Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
         bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, fieldSize, fieldSize);
 
         GenerateDistanceFieldMap(bitmap.buffer, Vector2(bitmap.width, bitmap.rows),
@@ -300,7 +300,7 @@ GlyphSet::Character* GetCharacter(FT_Face face, FT_ULong charcode,
         // However we will still need this code for characters like OGHAM SPACE MARK
         // which will be blank with some fonts, and visible with others.
         // Create a dummy bitmap of size 64,64
-        bitmapData = Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, true);
+        bitmapData = Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
         bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, fieldSize, fieldSize);
         PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
         memset( pixelBuffer, 0x0, fieldSize * fieldSize );
@@ -345,7 +345,7 @@ Integration::BitmapPtr GetGlyphBitmap( FT_Face face, FT_ULong charCode )
     const std::size_t size = ftBitmap.width * ftBitmap.rows;
     if( 0 < size )
     {
-      image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true );
+      image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
       image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::A8, ftBitmap.width, ftBitmap.rows );
 
       memcpy( static_cast<unsigned char*>( image->GetBuffer() ), ftBitmap.buffer, size );
index c79b84e..47edf88 100755 (executable)
@@ -676,7 +676,7 @@ GlyphSet* ResourceLoader::GetCachedGlyphData(const TextResourceType& textRequest
       glyphMetrics.yPosition = requestedCharacters[n].yPosition;
 
       // create a new bitmap, and copy in the data
-      BitmapPtr bitmapData ( Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, true) );
+      BitmapPtr bitmapData ( Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD) );
       DALI_ASSERT_ALWAYS( data.length == DISTANCE_FIELD_SIZE * DISTANCE_FIELD_SIZE );
 
       // assign the data
index b54fe70..3faa9be 100644 (file)
@@ -147,7 +147,7 @@ void ResourceThreadDistanceField::Load(const ResourceRequest& request)
   bool result = false;
   bool file_not_found = false;
 
-  BitmapPtr bitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, true );
+  BitmapPtr bitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
 
   DALI_LOG_SET_OBJECT_STRING(bitmap, request.GetPath());
   BitmapResourceType& resType = static_cast<BitmapResourceType&>(*(request.GetType()));
@@ -169,7 +169,7 @@ void ResourceThreadDistanceField::Load(const ResourceRequest& request)
         if ((bitmap->GetPixelFormat() == Pixel::RGBA8888) || (bitmap->GetPixelFormat() == Pixel::RGB888))
         {
           // create a bitmap, so we can get its buffersize - to avoid a slow copy.
-          BitmapPtr destBitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, true );
+          BitmapPtr destBitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
           destBitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, attributes.GetWidth(), attributes.GetHeight());
 
           uint8_t* srcPixels = bitmap->GetBuffer();
index f82413a..779420b 100644 (file)
@@ -149,7 +149,7 @@ void ResourceThreadText::LoadCharactersFromCache(
       glyphMetrics.yPosition = requestedCharacters[n].yPosition;
 
       // create a new bitmap, and copy in the data
-      BitmapPtr bitmapData ( Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, true) );
+      BitmapPtr bitmapData ( Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD) );
       DALI_ASSERT_ALWAYS( data.length == DISTANCE_FIELD_SIZE );
 
       // assign the data