// Not implemented as ConditionalWait is not copyable
ConditionalWait( const ConditionalWait& );
- const ConditionalWait& operator= ( const ConditionalWait& );
+ const ConditionalWait& operator=( const ConditionalWait& );
struct ConditionalWaitImpl;
ConditionalWaitImpl* mImpl;
mCore.Render( renderStatus );
mThreadSynchronization.AddPerformanceMarker( PerformanceInterface::RENDER_END );
+ // Decrement the count of how far update is ahead of render
+ mThreadSynchronization.RenderFinished();
+
// Perform any post-render operations
if ( renderStatus.HasRendered() )
{
{
ConditionalWait::ScopedLock lock( mRenderThreadWaitCondition );
++mUpdateAheadOfRender;
+ DALI_ASSERT_ALWAYS( mUpdateAheadOfRender >= 0 );
+ DALI_ASSERT_ALWAYS( mUpdateAheadOfRender <= mMaximumUpdateCount );
LOG_UPDATE_COUNTER_UPDATE( "updateAheadOfRender(%d)", mUpdateAheadOfRender );
}
mRenderThreadWaitCondition.Notify();
{
mRenderThreadSurfaceReplaced = FALSE;
}
- else
- {
- // decrement update-ahead-of-render
- ConditionalWait::ScopedLock renderLock( mRenderThreadWaitCondition );
- --mUpdateAheadOfRender;
- }
}
// Check if we've had an update, if we haven't then we just wait
}
}
}
- else
- {
- LOG_RENDER( "Just Rendered, now Replacing surface" );
-
- // ... also decrement update-ahead-of-render
- ConditionalWait::ScopedLock renderLock( mRenderThreadWaitCondition );
- --mUpdateAheadOfRender;
- }
// We may have been asked to replace the surface while we were waiting so check again here
if( IsRenderThreadReplacingSurface() )
return IsRenderThreadRunning(); // Call to this function locks so should not be called if we have a scoped-lock
}
+void ThreadSynchronization::RenderFinished()
+{
+ // A frame has been rendered; decrement counter
+ ConditionalWait::ScopedLock renderLock( mRenderThreadWaitCondition );
+ --mUpdateAheadOfRender;
+
+ LOG_RENDER( "mUpdateAheadOfRender %d\n", mUpdateAheadOfRender );
+ DALI_ASSERT_ALWAYS( mUpdateAheadOfRender < mMaximumUpdateCount );
+ DALI_ASSERT_ALWAYS( mUpdateAheadOfRender >= 0 );
+}
+
void ThreadSynchronization::RenderInformSurfaceReplaced()
{
LOG_RENDER_TRACE;
bool RenderReady( RenderRequest*& request );
/**
+ * Called by the render thread after it renders a frame.
+ * Used to notify the update-thread that a frame has been rendered.
+ * @pre Called by render thread only.
+ */
+ void RenderFinished();
+
+ /**
* Called by the Render thread to inform the synchronization class that the surface has been replaced.
*
* @note Should only be called by the Render thread.
}
else
{
+ mIndicatorAnimation.Clear();
+
if( EqualsZero(duration) )
{
mIndicatorAnimation.AnimateTo( Property( mIndicatorImageContainerActor, Dali::Actor::Property::POSITION ), Vector3(0, -mImageHeight, 0), Dali::AlphaFunction::EASE_OUT );
// EXTERNAL INCLUDES
#include <algorithm>
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
void Show()
{
Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) to show the keyboard
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if( imfContext )
{
if( ImfManager::IsAvailable() /* We do not want to create an ImfManager instance*/ )
{
Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if( imfContext )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "IsVisible\n" );
Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if ( imfContext )
{
void EnablePrediction(const bool enable)
{
Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) when enabling prediction
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if ( imfContext )
{
if ( ImfManager::IsAvailable() /* We do not want to create an instance of ImfManger */ )
{
Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if ( imfContext )
{
width = height = xPos = yPos = 0;
Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) as we may need to do some size related setup in the application
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if( imfContext )
{
if ( imfManager )
{
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if ( imfContext )
{
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/dali-vector.h>
// INTERNAL INCLUDES
#include <platform-abstractions/tizen/resource-loader/resource-loader.h>
}
bool EncodeToFormat( const unsigned char* pixelBuffer,
- std::vector< unsigned char >& encodedPixels,
+ Vector< unsigned char >& encodedPixels,
FileFormat formatEncoding,
std::size_t width,
std::size_t height,
const std::size_t height )
{
DALI_ASSERT_DEBUG(pixelBuffer != 0 && filename.size() > 4 && width > 0 && height > 0);
- std::vector< unsigned char > pixbufEncoded;
+ Vector< unsigned char > pixbufEncoded;
const FileFormat format = GetFormatFromFileName( filename );
const bool encodeResult = EncodeToFormat( pixelBuffer, pixbufEncoded, format, width, height, pixelFormat );
if(!encodeResult)
DALI_LOG_ERROR("Encoding pixels failed");
return false;
}
- return TizenPlatform::ResourceLoader::SaveFile( filename, pixbufEncoded );
+ return TizenPlatform::ResourceLoader::SaveFile( filename, pixbufEncoded.Begin(), pixbufEncoded.Count() );
}
} // namespace Dali
return Internal::Adaptor::ImfManager::Get();
}
-ImfContext ImfManager::GetContext()
-{
- return reinterpret_cast<ImfContext>( Internal::Adaptor::ImfManager::GetImplementation(*this).GetContext() );
-}
-
void ImfManager::Activate()
{
Internal::Adaptor::ImfManager::GetImplementation(*this).Activate();
Internal::Adaptor::ImfManager::GetImplementation(*this).SetCursorPosition( SetCursorPosition );
}
-int ImfManager::GetCursorPosition()
+unsigned int ImfManager::GetCursorPosition() const
{
return Internal::Adaptor::ImfManager::GetImplementation(*this).GetCursorPosition();
}
-void ImfManager::SetSurroundingText( std::string text )
+void ImfManager::SetSurroundingText( const std::string& text )
{
Internal::Adaptor::ImfManager::GetImplementation(*this).SetSurroundingText( text );
}
-std::string ImfManager::GetSurroundingText()
+const std::string& ImfManager::GetSurroundingText() const
{
return Internal::Adaptor::ImfManager::GetImplementation(*this).GetSurroundingText();
}
}
}
-// TODO: Temporary patch to hidden ecore dependency. Must fix it.
-typedef void* ImfContext;
-
/**
* @brief The ImfManager class
*
* @brief Default Constructor.
*/
ImfEventData()
- : eventName( VOID ),
- predictiveString(""),
+ : predictiveString(),
+ eventName( VOID ),
cursorOffset( 0 ),
numberOfChars ( 0 )
{
* @param[in] aCursorOffset Start position from the current cursor position to start deleting characters.
* @param[in] aNumberOfChars The number of characters to delete from the cursorOffset.
*/
- ImfEventData(ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset,int aNumberOfChars )
- : eventName(aEventName), predictiveString(aPredictiveString), cursorOffset( aCursorOffset ), numberOfChars( aNumberOfChars )
+ ImfEventData( ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset, int aNumberOfChars )
+ : predictiveString( aPredictiveString ),
+ eventName( aEventName ),
+ cursorOffset( aCursorOffset ),
+ numberOfChars( aNumberOfChars )
{
}
// Data
- ImfEvent eventName; ///< The name of the event from the IMF.
std::string predictiveString; ///< The pre-edit or commit string.
- int cursorOffset; ///< Start position from the current cursor position to start deleting characters.
- int numberOfChars; ///< number of characters to delete from the cursorOffset.
+ ImfEvent eventName; ///< The name of the event from the IMF.
+ int cursorOffset; ///< Start position from the current cursor position to start deleting characters.
+ int numberOfChars; ///< number of characters to delete from the cursorOffset.
};
/**
/**
* @brief Constructor
*/
- ImfCallbackData( )
- : update( false ), cursorPosition( 0 ), preeditResetRequired ( false )
+ ImfCallbackData()
+ : currentText(),
+ cursorPosition( 0 ),
+ update( false ),
+ preeditResetRequired( false )
{
}
* @param[in] aCurrentText current text string
* @param[in] aPreeditResetRequired flag if preedit reset is required.
*/
- ImfCallbackData(bool aUpdate, int aCursorPosition, std::string aCurrentText, bool aPreeditResetRequired )
- : update(aUpdate), cursorPosition(aCursorPosition), currentText( aCurrentText ), preeditResetRequired( aPreeditResetRequired )
+ ImfCallbackData( bool aUpdate, int aCursorPosition, const std::string& aCurrentText, bool aPreeditResetRequired )
+ : currentText( aCurrentText ),
+ cursorPosition( aCursorPosition ),
+ update( aUpdate ),
+ preeditResetRequired( aPreeditResetRequired )
{
}
- bool update; ///< if cursor position needs to be updated
- int cursorPosition; ///< new position of cursor
- std::string currentText; ///< current text string
- bool preeditResetRequired; ///< flag if preedit reset is required.
+ std::string currentText; ///< current text string
+ int cursorPosition; ///< new position of cursor
+ bool update :1; ///< if cursor position needs to be updated
+ bool preeditResetRequired :1; ///< flag if preedit reset is required.
};
typedef Signal< void (ImfManager&) > ImfManagerSignalType; ///< Keyboard actived signal
-
typedef Signal< ImfCallbackData ( ImfManager&, const ImfEventData& ) > ImfEventSignalType; ///< keyboard events
public:
static ImfManager Get();
/**
- * @brief Get the current imf context.
- * @return current imf context.
- */
- ImfContext GetContext();
-
- /**
* @brief Activate the IMF.
*
* It means that the text editing is started at somewhere.
*
* @return current position of cursor
*/
- int GetCursorPosition();
+ unsigned int GetCursorPosition() const;
/**
* @brief Method to store the string required by the IMF, this is used to provide predictive word suggestions.
*
* @param[in] text The text string surrounding the current cursor point.
*/
- void SetSurroundingText( std::string text );
+ void SetSurroundingText( const std::string& text );
/**
* @brief Gets current text string set within the IMF manager, this is used to offer predictive suggestions.
*
* @return current position of cursor
*/
- std::string GetSurroundingText();
+ const std::string& GetSurroundingText() const;
public:
adaptor_integration_x11_api_header_files = \
$(adaptor_integration_api_dir)/x11/ecore-x-types.h \
$(adaptor_integration_api_dir)/x11/ecore-x-render-surface.h \
- $(adaptor_integration_api_dir)/x11/pixmap-render-surface.h
+ $(adaptor_integration_api_dir)/x11/pixmap-render-surface.h \
+ $(adaptor_integration_api_dir)/x11/imf-manager-impl.h
#include <Ecore_X.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/key-event-integ.h>
// INTERNAL INCLUDES
#include <imf-manager.h>
namespace Adaptor
{
-class ImfManager : public Dali::BaseObject
+class DALI_IMPORT_API ImfManager : public Dali::BaseObject
{
public:
typedef Dali::ImfManager::ImfManagerSignalType ImfManagerSignalType;
/**
* @copydoc Dali::ImfManager::PreEditChanged()
*/
- void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+ void PreEditChanged( void* data, Ecore_IMF_Context* imfContext, void* event_info );
/**
* @copydoc Dali::ImfManager::NotifyCursorPosition()
*/
- void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+ void CommitReceived( void* data, Ecore_IMF_Context* imfContext, void* event_info );
/**
* @copydoc Dali::ImfManager::NotifyCursorPosition()
*/
- Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
+ Eina_Bool RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition );
/**
* @copydoc Dali::ImfManager::DeleteSurrounding()
*/
- void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+ void DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info );
// Cursor related
/**
void NotifyCursorPosition();
/**
- * @copydoc Dali::ImfManager::GetCursorPosition()
+ * @copydoc Dali::ImfManager::SetCursorPosition()
*/
- int GetCursorPosition();
+ void SetCursorPosition( unsigned int cursorPosition );
/**
- * @copydoc Dali::ImfManager::SetCursorPosition()
+ * @copydoc Dali::ImfManager::GetCursorPosition()
*/
- void SetCursorPosition( unsigned int cursorPosition );
+ unsigned int GetCursorPosition() const;
/**
* @copydoc Dali::ImfManager::SetSurroundingText()
*/
- void SetSurroundingText( std::string text );
+ void SetSurroundingText( const std::string& text );
/**
* @copydoc Dali::ImfManager::GetSurroundingText()
*/
- std::string GetSurroundingText();
+ const std::string& GetSurroundingText() const;
public: // Signals
bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
- std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
-
ImfManagerSignalType mActivatedSignal;
ImfEventSignalType mEventSignal;
public:
-inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
+DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
{
DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
return static_cast<Internal::Adaptor::ImfManager&>(handle);
}
-inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
+DALI_IMPORT_API inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
{
DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
*/
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 )
+ 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. @since_tizen 2.4
+ APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS, ///< Application expects Dali to retain data ( increased memory footprint ) @since_tizen 2.4
};
} // Configuration
}
/**
* @brief An Application class object should be created by every application
- * that wishes to use Dali. It provides a means for initialising the
+ * that wishes to use Dali.
+ *
+ * It provides a means for initialising the
* resources required by the Dali::Core.
*
* The Application class emits several signals which the user can
{
public:
- typedef Signal< void (Application&) > AppSignalType;
- typedef Signal< void (Application&, void *) > AppControlSignalType;
+ typedef Signal< void (Application&) > AppSignalType; ///< Application lifecycle signal and system signal callback type @since_tizen 2.4
+ typedef Signal< void (Application&, void *) > AppControlSignalType; ///< Application control signal callback type @since_tizen 2.4
/**
* @brief Decides whether a Dali application window is opaque or transparent.
*/
enum WINDOW_MODE
{
- OPAQUE = 0, ///< The window will be opaque
- TRANSPARENT = 1 ///< The window transparency will match the alpha value set in Dali::Stage::SetBackgroundcolor()
+ OPAQUE = 0, ///< The window will be opaque @since_tizen 2.4
+ TRANSPARENT = 1 ///< The window transparency will match the alpha value set in Dali::Stage::SetBackgroundcolor() @since_tizen 2.4
};
public:
public:
/**
- * @brief This starts the application. Choosing this form of main loop indicates that the default
+ * @brief 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.
/**
* @brief 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.
/**
* @brief Retrieves the window used by the Application class.
+ *
* The application writer can use the window to change indicator and orientation
* properties.
* @since_tizen 2.4
/**
* @brief 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.
/**
* @brief This signal is emitted when another application sends a launch request to the application.
+ *
* When the application is launched, this signal is emitted after the main loop of the application starts up.
* The passed parameter describes the launch request and contains the information about why the application is launched.
* @since_tizen 2.4
* @{
*/
+/**
+ * @brief Enumerations for input method.
+ * @since_tizen 2.4
+ */
namespace InputMethod
{
/**
*/
enum ColorDepth
{
- COLOR_DEPTH_DEFAULT, ///< Uses the current X screen default depth (recommended)
- COLOR_DEPTH_8, ///< 8 bits per pixel
- COLOR_DEPTH_16, ///< 16 bits per pixel
- COLOR_DEPTH_24, ///< 24 bits per pixel
- COLOR_DEPTH_32 ///< 32 bits per pixel
+ COLOR_DEPTH_DEFAULT, ///< Uses the current X screen default depth (recommended) @since_tizen 2.4
+ COLOR_DEPTH_8, ///< 8 bits per pixel @since_tizen 2.4
+ COLOR_DEPTH_16, ///< 16 bits per pixel @since_tizen 2.4
+ COLOR_DEPTH_24, ///< 24 bits per pixel @since_tizen 2.4
+ COLOR_DEPTH_32 ///< 32 bits per pixel @since_tizen 2.4
};
/**
* @{
*/
+/**
+ * @brief Style change information.
+ * @since_tizen 2.4
+ */
namespace StyleChange
{
enum Type
{
- DEFAULT_FONT_CHANGE, ///< Denotes that the default font has changed.
- DEFAULT_FONT_SIZE_CHANGE, ///< Denotes that the default font size has changed.
- THEME_CHANGE ///< Denotes that the theme has changed.
+ DEFAULT_FONT_CHANGE, ///< Denotes that the default font has changed. @since_tizen 2.4
+ DEFAULT_FONT_SIZE_CHANGE, ///< Denotes that the default font size has changed. @since_tizen 2.4
+ THEME_CHANGE ///< Denotes that the theme has changed. @since_tizen 2.4
};
} // namespace StyleChange
{
public: // Signal typedefs
- typedef Signal< bool () > TimerSignalType; ///< Timer finished signal callback type
+ typedef Signal< bool () > TimerSignalType; ///< Timer finished signal callback type @since_tizen 2.4
public: // API
~Timer();
/**
- * @brief Downcast an Object handle to Timer handle.
+ * @brief Downcast a handle to Timer handle.
*
* If handle points to a Timer object the downcast produces a valid
* handle. If not the returned handle is left uninitialized.
/**
* @brief Get the interval of timer.
+ *
* @returns Interval in milliseconds.
* @since_tizen 2.4
*/
*/
enum Mode
{
- DEFAULT = 0, ///< Default mode for normal application
- NOTIFICATION, ///< Notification mode
- SCREEN_READER, ///< Screen reader mode
+ DEFAULT = 0, ///< Default mode for normal application @since_tizen 2.4
+ NOTIFICATION, ///< Notification mode @since_tizen 2.4
+ SCREEN_READER, ///< Screen reader mode @since_tizen 2.4
MODE_NUM
};
*/
enum State
{
- UNAVAILABLE = 0, ///< Player is not available
- READY, ///< Player is ready to play
- PLAYING, ///< Player is playing
- PAUSED ///< Player is paused
+ UNAVAILABLE = 0, ///< Player is not available @since_tizen 2.4
+ READY, ///< Player is ready to play @since_tizen 2.4
+ PLAYING, ///< Player is playing @since_tizen 2.4
+ PAUSED ///< Player is paused @since_tizen 2.4
};
public: // Typedefs
/**
* @brief Allows connection TTS state change signal.
- * Note: Only supported by some adaptor types.
* @since_tizen 2.4
* @return A reference to the signal for connection.
+ * @note Only supported by some adaptor types.
*/
Dali::TtsPlayer::StateChangedSignalType& StateChangedSignal();
* @{
*/
-typedef Dali::Rect<int> PositionSize;
+typedef Dali::Rect<int> PositionSize; ///< Type for widow poisition and size. @since_tizen 2.4
namespace Internal DALI_INTERNAL
{
/**
* @brief The window class is used internally for drawing.
*
- * It has an orientation
- * and indicator properties.
+ * A Window has an orientation and indicator properties.
+ * You can get a valid Window handle by calling Dali::Application::GetWindow().
* @since_tizen 2.4
*/
class DALI_IMPORT_API Window : public BaseHandle
{
public:
- typedef Signal< void (bool) > IndicatorSignalType;
+ typedef Signal< void (bool) > IndicatorSignalType; ///< Indicator signal callback type @since_tizen 2.4
public:
*/
enum WindowOrientation
{
- PORTRAIT = 0,
- LANDSCAPE = 90,
- PORTRAIT_INVERSE = 180,
- LANDSCAPE_INVERSE = 270
+ PORTRAIT = 0, ///< Portrait orientation @since_tizen 2.4
+ LANDSCAPE = 90, ///< Landscape orientation @since_tizen 2.4
+ PORTRAIT_INVERSE = 180, ///< Portrait inverse orientation @since_tizen 2.4
+ LANDSCAPE_INVERSE = 270 ///< Landscape inverse orientation @since_tizen 2.4
};
/**
*/
enum IndicatorBgOpacity
{
- OPAQUE = 100, // Fully opaque indicator Bg
- TRANSLUCENT = 50, // Semi translucent indicator Bg
- TRANSPARENT = 0 // Fully transparent indicator Bg
+ OPAQUE = 100, ///< Fully opaque indicator Bg @since_tizen 2.4
+ TRANSLUCENT = 50, ///< Semi translucent indicator Bg @since_tizen 2.4
+ TRANSPARENT = 0 ///< Fully transparent indicator Bg @since_tizen 2.4
};
/**
*/
enum IndicatorVisibleMode
{
- INVISIBLE = 0, // hide indicator
- VISIBLE = 1, // show indicator
- AUTO = 2 // hide in default, will show when necessary
+ INVISIBLE = 0, ///< hide indicator @since_tizen 2.4
+ VISIBLE = 1, ///< show indicator @since_tizen 2.4
+ AUTO = 2 ///< hide in default, will show when necessary @since_tizen 2.4
};
// Methods
/**
* @brief Create an uninitalized handle.
*
- * This can be initialized using Dali::Application::GetWindow() or
- * Dali::Window::New()
+ * This can be initialized using Dali::Window::New()
* @since_tizen 2.4
*/
Window();
*/
enum KeyGrabMode
{
- TOPMOST = 0, ///< Grab a key only when on the top of the grabbing-window stack mode.
- SHARED, ///< Grab a key together with the other client window(s) mode.
- OVERRIDE_EXCLUSIVE, ///< Grab a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode.
- EXCLUSIVE ///< Grab a key exclusively regardless of the grabbing-window's position on the window stack mode.
+ TOPMOST = 0, ///< Grab a key only when on the top of the grabbing-window stack mode. @since_tizen 2.4
+ SHARED, ///< Grab a key together with the other client window(s) mode. @since_tizen 2.4
+ OVERRIDE_EXCLUSIVE, ///< Grab a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode. @since_tizen 2.4
+ EXCLUSIVE ///< Grab a key exclusively regardless of the grabbing-window's position on the window stack mode. @since_tizen 2.4
};
/**
Dali::ImfManager imfManager( ImfManager::Get() );
if ( imfManager )
{
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
}
if ( imfContext )
Dali::ImfManager imfManager( ImfManager::Get() );
if ( imfManager )
{
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
}
if ( imfContext )
{
}
-int ImfManager::GetCursorPosition()
+void ImfManager::SetCursorPosition( unsigned int cursorPosition )
{
- return mIMFCursorPosition;
+ mIMFCursorPosition = static_cast<int>( cursorPosition );
}
-void ImfManager::SetCursorPosition( unsigned int cursorPosition )
+unsigned int ImfManager::GetCursorPosition() const
{
- mIMFCursorPosition = ( int )cursorPosition;
+ return static_cast<unsigned int>( mIMFCursorPosition );
}
-void ImfManager::SetSurroundingText( std::string text )
+void ImfManager::SetSurroundingText( const std::string& text )
{
mSurroundingText = text;
}
-std::string ImfManager::GetSurroundingText()
+const std::string& ImfManager::GetSurroundingText() const
{
return mSurroundingText;
}
void NotifyCursorPosition();
/**
- * @copydoc Dali::ImfManager::GetCursorPosition()
+ * @copydoc Dali::ImfManager::SetCursorPosition()
*/
- int GetCursorPosition();
+ void SetCursorPosition( unsigned int cursorPosition );
/**
- * @copydoc Dali::ImfManager::SetCursorPosition()
+ * @copydoc Dali::ImfManager::GetCursorPosition()
*/
- void SetCursorPosition( unsigned int cursorPosition );
+ unsigned int GetCursorPosition() const;
/**
* @copydoc Dali::ImfManager::SetSurroundingText()
*/
- void SetSurroundingText( std::string text );
+ void SetSurroundingText( const std::string& text );
/**
* @copydoc Dali::ImfManager::GetSurroundingText()
*/
- std::string GetSurroundingText();
+ const std::string& GetSurroundingText() const;
public: // Signals
Dali::ImfManager imfManager( ImfManager::Get() );
if ( imfManager )
{
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
}
if ( imfContext )
Dali::ImfManager imfManager( ImfManager::Get() );
if ( imfManager )
{
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
}
if ( imfContext )
namespace
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_IMF_MANAGER");
#endif
ImfManager::ImfManager( Ecore_X_Window ecoreXwin )
: mIMFContext(),
mIMFCursorPosition( 0 ),
- mSurroundingText(""),
+ mSurroundingText(),
mRestoreAfterFocusLost( false ),
- mIdleCallbackConnected( false ),
- mKeyEvents()
+ mIdleCallbackConnected( false )
{
ecore_imf_init();
CreateContext( ecoreXwin );
* We are still predicting what the user is typing. The latest string is what the IMF module thinks
* the user wants to type.
*/
-void ImfManager::PreEditChanged( void *, Ecore_IMF_Context *imfContext, void *event_info )
+void ImfManager::PreEditChanged( void*, Ecore_IMF_Context* imfContext, void* event_info )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::PreEditChanged\n" );
- char *preEditString( NULL );
+ char* preEditString( NULL );
int cursorPosition( 0 );
- Eina_List *attrs = NULL;
- Eina_List *l = NULL;
+ Eina_List* attrs = NULL;
+ Eina_List* l = NULL;
- Ecore_IMF_Preedit_Attr *attr;
+ Ecore_IMF_Preedit_Attr* attr;
// Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
// the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
if ( attrs )
{
// iterate through the list of attributes getting the type, start and end position.
- for ( l = attrs, (attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ); l; l = eina_list_next(l), ( attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ))
+ for ( l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
{
#ifdef DALI_PROFILE_UBUNTU
if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)
size_t byteIndex = 0;
// iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
- while ( preEditString[byteIndex] != '\0' )
+ const char leadByte = preEditString[byteIndex];
+ while( leadByte != '\0' )
{
// attr->end_index is provided as a byte position not character and we need to know the character position.
- size_t currentSequenceLength = Utf8SequenceLength(preEditString[byteIndex]); // returns number of bytes used to represent character.
+ const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
if ( byteIndex == attr->end_index )
{
cursorPosition = visualCharacterIndex;
if ( Dali::Adaptor::IsAvailable() )
{
- std::string keyString ( preEditString );
- int numberOfChars( 0 );
-
Dali::ImfManager handle( this );
- Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::PREEDIT, keyString, cursorPosition, numberOfChars );
+ Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::PREEDIT, preEditString, cursorPosition, 0 );
Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
if ( callbackData.update )
free( preEditString );
}
-void ImfManager::CommitReceived( void *, Ecore_IMF_Context *imfContext, void *event_info )
+void ImfManager::CommitReceived( void*, Ecore_IMF_Context* imfContext, void* event_info )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CommitReceived\n" );
if ( Dali::Adaptor::IsAvailable() )
{
- const std::string keyString( (char *)event_info );
- const int cursorOffset( 0 );
- const int numberOfChars( 0 );
+ const std::string keyString( static_cast<char*>( event_info ) );
Dali::ImfManager handle( this );
- Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::COMMIT, keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::COMMIT, keyString, 0, 0 );
Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
- if ( callbackData.update )
+ if( callbackData.update )
{
SetCursorPosition( callbackData.cursorPosition );
SetSurroundingText( callbackData.currentText );
* Here the IMF module wishes to know the string we are working with and where within the string the cursor is
* We need to signal the application to tell us this information.
*/
-Eina_Bool ImfManager::RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
+Eina_Bool ImfManager::RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::RetrieveSurrounding\n" );
- std::string keyString ( "" );
- int cursorOffset( 0 );
- int numberOfChars( 0 );
-
- Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::GETSURROUNDING , keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::GETSURROUNDING, std::string(), 0, 0 );
Dali::ImfManager handle( this );
mEventSignal.Emit( handle, imfData );
- if ( text )
+ if( text )
{
- std::string surroundingText( GetSurroundingText() );
-
- if ( !surroundingText.empty() )
- {
- *text = strdup( surroundingText.c_str() );
- }
- else
- {
- *text = strdup( "" );
- }
+ *text = strdup( mSurroundingText.c_str() );
}
- if ( cursorPosition )
+ if( cursorPosition )
{
- *cursorPosition = GetCursorPosition();
+ *cursorPosition = mIMFCursorPosition;
}
-
return EINA_TRUE;
}
* Called when an IMF delete surrounding event is received.
* Here we tell the application that it should delete a certain range.
*/
-void ImfManager::DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
+void ImfManager::DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteSurrounding\n" );
- if ( Dali::Adaptor::IsAvailable() )
+ if( Dali::Adaptor::IsAvailable() )
{
- Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = (Ecore_IMF_Event_Delete_Surrounding*) event_info;
-
- const std::string keyString( "" );
- const int cursorOffset( deleteSurroundingEvent->offset );
- const int numberOfChars( deleteSurroundingEvent->n_chars );
+ Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( event_info );
- Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::DELETESURROUNDING , keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::DELETESURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
Dali::ImfManager handle( this );
mEventSignal.Emit( handle, imfData );
}
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::NotifyCursorPosition\n" );
- if ( mIMFContext )
+ if( mIMFContext )
{
ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
}
}
-int ImfManager::GetCursorPosition()
+void ImfManager::SetCursorPosition( unsigned int cursorPosition )
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
- return mIMFCursorPosition;
+ mIMFCursorPosition = static_cast<int>( cursorPosition );
}
-void ImfManager::SetCursorPosition( unsigned int cursorPosition )
+unsigned int ImfManager::GetCursorPosition() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
- mIMFCursorPosition = ( int )cursorPosition;
+ return static_cast<unsigned int>( mIMFCursorPosition );
}
-void ImfManager::SetSurroundingText( std::string text )
+void ImfManager::SetSurroundingText( const std::string& text )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetSurroundingText\n" );
mSurroundingText = text;
}
-std::string ImfManager::GetSurroundingText()
+const std::string& ImfManager::GetSurroundingText() const
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetSurroundingText\n" );
#include <Ecore_X.h>
#include <algorithm>
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
// Get Focus window
XGetInputFocus(display, &focusWindow, &revert);
- ecore_x_window_prop_property_set(focusWindow,
+ ecore_x_window_prop_property_set( focusWindow,
ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
- ECORE_X_ATOM_CARDINAL, 32, &angle, 1);
+ ECORE_X_ATOM_CARDINAL, 32, &angle, 1 );
XCloseDisplay(display);
}
}
void SetReturnKeyType( const InputMethod::ActionButton type )
{
Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) when setting values
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ Ecore_IMF_Context* imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
if( imfContext )
{
BuildRequires: dali-integration-devel
BuildRequires: pkgconfig(dali-core)
BuildRequires: pkgconfig(dali)
-BuildRequires: boost-devel
+BuildRequires: libxml2-devel
BuildRequires: cmake
BuildRequires: pkgconfig(ecore)
BuildRequires: dali-integration-devel
BuildRequires: pkgconfig(dali-core)
BuildRequires: pkgconfig(dali)
-BuildRequires: boost-devel
+BuildRequires: libxml2-devel
BuildRequires: cmake
$(ELDBUS_LIBS) \
-lgif \
-lpthread \
- -lboost_thread \
-lturbojpeg
if WAYLAND
#ifndef __DALI_ADAPTOR_DOC_H__
#define __DALI_ADAPTOR_DOC_H__
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
/**
* @defgroup dali_adaptor DALi Adaptor
*
- * @brief This module is a platform adaptation layer. It initializes and sets up DALi appropriately.
- * The module provides many platform-related services with its internal module,
+ * @brief DALi Adaptor is a platform adaptation layer.
+ *
+ * It initializes and sets up DALi appropriately and
+ * provides many platform-related services with its internal module,
* platform abstraction. Several signals can be connected to it to keep you informed when
* certain platform-related activities occur.
*
+ * @section dali_adaptor_overview Overview
+ *
+ * DALi Adaptor consists of the following groups of API:
+ *
+ * <table>
+ * <tr>
+ * <th>API Group</th>
+ * <th>Description</th>
+ * </tr>
+ * <tr>
+ * <td>@ref dali_adaptor_framework</td>
+ * <td>Classes for the adaption layer.</td>
+ * </tr>
+ * </table>
+ *
* @ingroup dali
* @{
* @defgroup dali_adaptor_framework Adaptor Framework
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
-Requires: boost-thread
-Requires: boost-chrono
Requires: giflib
BuildRequires: pkgconfig
BuildRequires: gawk
BuildRequires: pkgconfig(sensor)
BuildRequires: pkgconfig(aul)
-BuildRequires: boost-devel
BuildRequires: giflib-devel
BuildRequires: pkgconfig(fontconfig)
BuildRequires: pkgconfig(elementary)
Group: Development/Building
Requires: %{name} = %{version}-%{release}
Requires: %{name}-integration-devel = %{version}-%{release}
-Requires: boost-devel
%description devel
Development components for the DALi Tizen Adaptor - public headers and package configs
}
width = infoHeader.width;
- height = infoHeader.height;
+ height = abs(infoHeader.height);
return true;
}
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
return false;
}
- std::vector<unsigned char> jpegBuffer(0);
+ Vector<unsigned char> jpegBuffer;
try
{
- jpegBuffer.reserve( jpegBufferSize );
+ jpegBuffer.Reserve( jpegBufferSize );
}
catch(...)
{
DALI_LOG_ERROR( "Could not allocate temporary memory to hold JPEG file of size %uMB.\n", jpegBufferSize / 1048576U );
return false;
}
- unsigned char * const jpegBufferPtr = &jpegBuffer[0];
+ unsigned char * const jpegBufferPtr = jpegBuffer.Begin();
// Pull the compressed JPEG image bytes out of a file and into memory:
if( fread( jpegBufferPtr, 1, jpegBufferSize, fp ) != jpegBufferSize )
int ix, iy = 0;
iw = width;
ih = height;
- std::vector<unsigned char> data(width * height * bpp);
- unsigned char *dataPtr = &data[0];
+ Vector<unsigned char> data;
+ data.Reserve(width * height * bpp);
+ unsigned char *dataPtr = data.Begin();
memcpy(dataPtr, buffer, width * height * bpp);
w = ih;
ih = iw;
iw = width;
ih = height;
- std::vector<unsigned char> data(width * height * bpp);
- unsigned char *dataPtr = &data[0];
+ Vector<unsigned char> data;
+ data.Reserve(width * height * bpp);
+ unsigned char *dataPtr = data.Begin();
memcpy(dataPtr, buffer, width * height * bpp);
w = ih;
ih = iw;
return true;
}
-bool EncodeToJpeg( const unsigned char* const pixelBuffer, std::vector< unsigned char >& encodedPixels, const std::size_t width, const std::size_t height, const Pixel::Format pixelFormat, unsigned quality)
+bool EncodeToJpeg( const unsigned char* const pixelBuffer, Vector< unsigned char >& encodedPixels,
+ const std::size_t width, const std::size_t height, const Pixel::Format pixelFormat, unsigned quality )
{
if( !pixelBuffer )
{
// Safely wrap the jpeg codec's buffer in case we are about to throw, then
// save the pixels to a persistent buffer that we own and let our cleaner
// class clean up the buffer as it goes out of scope:
- AutoJpgMem cleaner(dstBuffer);
- encodedPixels.resize(dstBufferSize);
- memcpy(&encodedPixels[0], dstBuffer, dstBufferSize);
+ AutoJpgMem cleaner( dstBuffer );
+ encodedPixels.Reserve( dstBufferSize );
+ memcpy( encodedPixels.Begin(), dstBuffer, dstBufferSize );
}
return true;
}
{
bool widthLessRequired = TJSCALED( postXformImageWidth, factors[i]) < requiredWidth;
bool heightLessRequired = TJSCALED( postXformImageHeight, factors[i]) < requiredHeight;
- switch( fittingMode )
+ // If either scaled dimension is smaller than the desired one, we were done at the last iteration
+ if ( (fittingMode == FittingMode::SCALE_TO_FILL) && (widthLessRequired || heightLessRequired) )
{
- // If either scaled dimension is smaller than the desired one, we were done at the last iteration:
- case FittingMode::SCALE_TO_FILL:
- {
- if ( widthLessRequired || heightLessRequired )
- {
- break;
- }
- }
- // If both dimensions are smaller than the desired one, we were done at the last iteration:
- case FittingMode::SHRINK_TO_FIT:
- {
- if ( widthLessRequired && heightLessRequired )
- {
- break;
- }
- }
- // If the width is smaller than the desired one, we were done at the last iteration:
- case FittingMode::FIT_WIDTH:
- {
- if ( widthLessRequired )
- {
- break;
- }
- }
- // If the width is smaller than the desired one, we were done at the last iteration:
- case FittingMode::FIT_HEIGHT:
- {
- if ( heightLessRequired )
- {
- break;
- }
- }
-
- // This factor stays is within our fitting mode constraint so remember it:
- scaleFactorIndex = i;
+ break;
}
+ // If both dimensions are smaller than the desired one, we were done at the last iteration:
+ if ( (fittingMode == FittingMode::SHRINK_TO_FIT) && ( widthLessRequired && heightLessRequired ) )
+ {
+ break;
+ }
+ // If the width is smaller than the desired one, we were done at the last iteration:
+ if ( fittingMode == FittingMode::FIT_WIDTH && widthLessRequired )
+ {
+ break;
+ }
+ // If the width is smaller than the desired one, we were done at the last iteration:
+ if ( fittingMode == FittingMode::FIT_HEIGHT && heightLessRequired )
+ {
+ break;
+ }
+ // This factor stays is within our fitting mode constraint so remember it:
+ scaleFactorIndex = i;
}
}
#define __DALI_TIZEN_PLATFORM_LOADER_JPEG_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
*/
#include <stdio.h>
-#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/images/pixel.h>
#include "image-encoder.h"
#include "image-loader-input.h"
* @param[in] pixelFormat Input pixel format (must be Pixel::RGB888)
* @param[in] quality JPEG quality on usual 1 to 100 scale.
*/
-bool EncodeToJpeg(const unsigned char* pixelBuffer, std::vector< unsigned char >& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat, unsigned quality = 80);
+bool EncodeToJpeg(const unsigned char* pixelBuffer, Vector< unsigned char >& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat, unsigned quality = 80);
} // namespace TizenPlatform
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
* */
extern "C" void WriteData(png_structp png_ptr, png_bytep data, png_size_t length)
{
- using Dali::TizenPlatform::PngBuffer;
DALI_ASSERT_DEBUG(png_ptr && data);
if(!png_ptr || !data)
{
return;
}
// Make sure we don't try to propagate a C++ exception up the call stack of a pure C library:
- try {
+ try
+ {
// Recover our buffer for writing into:
- PngBuffer* const encoded_img = (PngBuffer*) png_get_io_ptr(png_ptr);
+ Vector<unsigned char>* const encoded_img = static_cast< Vector<unsigned char>* >( png_get_io_ptr(png_ptr) );
if(encoded_img)
{
- const PngBuffer::size_type bufferSize = encoded_img->size();
- encoded_img->resize(encoded_img->size() + length); //< Can throw OOM.
- PngBuffer::value_type* const bufferBack = &((*encoded_img)[bufferSize]);
+ const Vector<unsigned char>::SizeType bufferSize = encoded_img->Count();
+ encoded_img->Reserve( bufferSize + length ); //< Can throw OOM.
+ unsigned char* const bufferBack = encoded_img->Begin() + bufferSize;
memcpy(bufferBack, data, length);
}
else
{
DALI_LOG_ERROR("PNG buffer for write to memory was passed from libpng as null.");
}
- } catch(...)
+ }
+ catch(...)
{
DALI_LOG_ERROR("C++ Exception caught");
}
* 7. If caller asks for no compression, bypass libpng and blat raw data to
* disk, topped and tailed with header/tail blocks.
*/
-bool EncodeToPng( const unsigned char* const pixelBuffer, PngBuffer& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat )
+bool EncodeToPng( const unsigned char* const pixelBuffer, Vector<unsigned char>& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat )
{
// Translate pixel format enum:
int pngPixelFormat = -1;
// Since we are going to write to memory instead of a file, lets provide
// libpng with a custom write function and ask it to pass back our
- // std::vector buffer each time it calls back to flush data to "file":
+ // Vector buffer each time it calls back to flush data to "file":
png_set_write_fn(png_ptr, &encodedPixels, WriteData, FlushData);
// png_set_compression_level( png_ptr, Z_BEST_COMPRESSION);
#define __DALI_TIZEN_PLATFORM_LOADER_PNG_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
*/
#include <cstdio>
-#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/images/pixel.h>
#include "image-encoder.h"
#include "image-loader-input.h"
bool LoadPngHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
/**
- * A bucket of bytes representing a PNG image.
- **/
-typedef std::vector<unsigned char> PngBuffer;
-
-/**
* Encode raw pixel data to PNG format.
* @param[in] pixelBuffer Pointer to raw pixel data to be encoded
* @param[out] encodedPixels Encoded pixel data. Existing contents will be overwritten
* @param[in] height Image height
* @param[in] pixelFormat Input pixel format (must be Pixel::RGB888)
*/
-bool EncodeToPng( const unsigned char* pixelBuffer, PngBuffer& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat );
+bool EncodeToPng( const unsigned char* pixelBuffer, Vector<unsigned char>& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat );
} // namespace TizenPlatform
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
#include "resource-loader.h"
// EXTERNAL HEADERS
-#include <boost/thread.hpp>
#include <iostream>
#include <fstream>
#include <queue>
+#include <cstring>
+#include <dali/devel-api/common/map-wrapper.h>
+#include <dali/devel-api/common/mutex.h>
// INTERNAL HEADERS
#include <dali/integration-api/bitmap.h>
#include "resource-bitmap-requester.h"
#include "debug/resource-loader-debug.h"
-
-/**
- * A macro to expand an argument to a compile time constant string literal.
- * Wrapping the stringify in an outer macro, means that any macro passed as
- * "x" will be expanded before being turned into a string.
- * Use this for example to turn the current line number into a string:
- * puts("The current line number is " DALI_TO_STRING(__LINE__) ".");
- */
-#define DALI_TO_STRING_INNER(x) #x
-#define DALI_TO_STRING(x) DALI_TO_STRING_INNER(x)
-
using namespace Dali::Integration;
-using boost::mutex;
-using boost::unique_lock;
namespace Dali
{
namespace TizenPlatform
{
-namespace
-{
-
-} // unnamed namespace
-
-
struct ResourceLoader::ResourceLoaderImpl
{
typedef std::pair<ResourceId, ResourceRequest> RequestStorePair;
typedef std::map<ResourceTypeId, ResourceRequesterBase*> RequestHandlers;
typedef RequestHandlers::iterator RequestHandlersIter;
- boost::mutex mQueueMutex; ///< used to synchronize access to mLoadedQueue and mFailedQueue
- LoadedQueue mPartiallyLoadedQueue; ///< Partially complete load requests notifications are stored here until fetched by core
+ Dali::Mutex mQueueMutex; ///< used to synchronize access to mLoadedQueue and mFailedQueue
LoadedQueue mLoadedQueue; ///< Completed load requests notifications are stored here until fetched by core
FailedQueue mFailedLoads; ///< Failed load request notifications are stored here until fetched by core
else
{
DALI_LOG_ERROR( "Unknown resource type (%u) with path \"%s\" in load request.\n", request.GetType()->id, request.GetPath().c_str() );
- DALI_ASSERT_DEBUG( 0 == "Unknown resource type in load request at " __FILE__ ", line " DALI_TO_STRING(__LINE__) ".\n" );
+ DALI_ASSERT_DEBUG( 0 == "Unknown resource type in load request at " __FILE__ ".\n" );
}
}
return loadStatus;
}
- bool IsLoading()
- {
- // TODO - not used - remove?
- DALI_ASSERT_DEBUG( 0 == "IsLoading() Is not implemented so don't call it." );
- return true;
- }
-
void GetResources(ResourceCache& cache)
{
// Fill the resource cache
- unique_lock<mutex> lock(mQueueMutex);
-
- // iterate through the partially loaded resources
- while (!mPartiallyLoadedQueue.empty())
- {
- LoadedResource loaded( mPartiallyLoadedQueue.front() );
- mPartiallyLoadedQueue.pop();
- LoadStatus loadStatus = LoadFurtherResources( loaded );
- cache.LoadResponse( loaded.id, loaded.type, loaded.resource, loadStatus );
- }
+ Mutex::ScopedLock lock( mQueueMutex );
// iterate through the successfully loaded resources
while (!mLoadedQueue.empty())
}
}
- void AddPartiallyLoadedResource( LoadedResource& resource)
- {
- // Lock the LoadedQueue to store the loaded resource
- unique_lock<mutex> lock(mQueueMutex);
-
- mPartiallyLoadedQueue.push( resource );
- }
-
void AddLoadedResource(LoadedResource& resource)
{
// Lock the LoadedQueue to store the loaded resource
- unique_lock<mutex> lock(mQueueMutex);
+ Mutex::ScopedLock lock( mQueueMutex );
mLoadedQueue.push( resource );
}
void AddFailedLoad(FailedResource& resource)
{
// Lock the FailedQueue to store the failed resource information
- unique_lock<mutex> lock(mQueueMutex);
+ Mutex::ScopedLock lock( mQueueMutex );
mFailedLoads.push(resource);
}
/************************** CALLED FROM LOADER THREADS **********************/
/********************************************************************************/
-void ResourceLoader::AddPartiallyLoadedResource( LoadedResource& resource)
-{
- mImpl->AddPartiallyLoadedResource( resource );
-}
-
void ResourceLoader::AddLoadedResource(LoadedResource& resource)
{
mImpl->AddLoadedResource( resource );
mImpl->CancelLoad(id, typeId);
}
-bool ResourceLoader::IsLoading()
-{
- return mImpl->IsLoading();
-}
-
-void ResourceLoader::SetDpi(unsigned int dpiHor, unsigned int dpiVer)
-{
- // Unused
-}
-
bool ResourceLoader::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const
{
Dali::Vector<unsigned char> daliVec;
return contents;
}
-bool ResourceLoader::SaveFile(const std::string& filename, std::vector< unsigned char >& buffer)
-{
- return SaveFile( filename, &buffer[0], buffer.size() );
-}
-
bool ResourceLoader::SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes )
{
DALI_LOG_TRACE_METHOD(gLoaderFilter);
};
/**
- * Contains information about a successfully saved resource
- */
-struct SavedResource
-{
- /**
- * Constructor
- * @param[in] savedId The ID of the resource
- * @param[in] savedType The resource type
- */
- SavedResource(Integration::ResourceId savedId,
- Integration::ResourceTypeId savedType)
- : id(savedId),
- type(savedType)
- {
- }
-
- /// Copy constructor
- SavedResource(const LoadedResource& loaded)
- : id(loaded.id),
- type(loaded.type)
- {
- }
-
- /// Assignment operator
- SavedResource& operator=(const SavedResource& rhs)
- {
- if( this != &rhs )
- {
- id = rhs.id;
- type = rhs.type;
- }
- return *this;
- }
-
- Integration::ResourceId id;
- Integration::ResourceTypeId type;
-};
-
-/**
* Contains information about a failed resource load/save request
*/
struct FailedResource
bool IsTerminating();
/**
- * Add a partially loaded resource to the PartiallyLoadedResource queue
- * @param[in] resource The resource's information and data
- */
- void AddPartiallyLoadedResource(LoadedResource& resource);
-
- /**
* Add a completely loaded resource to the LoadedResource queue
* @param[in] resource The resource's information and data
*/
void AddLoadedResource(LoadedResource& resource);
/**
- * Add a successfully saved resource to the SavedResource queue
- * @param[in] resource The resource's information
- */
- void AddSavedResource(SavedResource& resource);
-
- /**
* Add information about a failed resource load to the FailedLoads queue
* @param[in] resource The failed resource's information
*/
void AddFailedLoad(FailedResource& resource);
- /**
- * Add information about a failed resource save to the FailedSaves queue
- * @param[in] resource The failed resource's information
- */
- void AddFailedSave(FailedResource& resource);
-
-
// From PlatformAbstraction
/**
void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
/**
- * @copydoc PlatformAbstraction::IsLoading()
- * @deprecated This is not implemented: always returns true.
- */
- bool IsLoading();
-
- /**
* @copydoc PlatformAbstraction::GetResources()
*/
void GetResources(Integration::ResourceCache& cache);
/**
- * @copydoc PlatformAbstraction::SetDpi()
- */
- void SetDpi(unsigned int dpiHor, unsigned int dpiVer);
-
- /**
* @copydoc SlpPlatformAbstraction::LoadFile()
*/
bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const;
/**
* @copydoc TizenPlatformAbstraction::SaveFile()
*/
- static bool SaveFile( const std::string& filename, std::vector< unsigned char >& buffer );
static bool SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes );
private:
*
*/
+// EXTERNAL INCLUDES
+#include <memory>
#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
#include "resource-thread-base.h"
#include "tizen-logging.h"
#include "atomics.h"
using namespace Dali::Integration;
-using boost::mutex;
-using boost::unique_lock;
namespace Dali
{
namespace TizenPlatform
{
+using Internal::Adaptor::ConditionalWait;
namespace
{
-const char * const IDLE_PRIORITY_ENVIRONMENT_VARIABLE_NAME = "DALI_RESOURCE_THREAD_IDLE_PRIORITY"; ///@Todo Move this to somewhere that other environment variables are declared and document it there.
+const char * const IDLE_PRIORITY_ENVIRONMENT_VARIABLE_NAME = "DALI_RESOURCE_THREAD_IDLE_PRIORITY";
} // unnamed namespace
/** Thrown by InterruptionPoint() to abort a request early. */
ResourceThreadBase::ResourceThreadBase( ResourceLoader& resourceLoader ) :
mResourceLoader( resourceLoader ),
+ mThread( 0 ),
mCurrentRequestId( NO_REQUEST_IN_FLIGHT ),
mCancelRequestId( NO_REQUEST_CANCELLED ),
mPaused( false )
mLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_RESOURCE_THREAD_BASE");
#endif
- mThread = new boost::thread(boost::bind(&ResourceThreadBase::ThreadLoop, this));
+ int error = pthread_create( &mThread, NULL, InternalThreadEntryFunc, this );
+ DALI_ASSERT_ALWAYS( !error && "Error in pthread_create()" );
}
ResourceThreadBase::~ResourceThreadBase()
if (mThread)
{
// wake thread
- mCondition.notify_all();
+ mCondition.Notify();
+
// wait for thread to exit
- mThread->join();
- // delete thread instance
- delete mThread;
- // mark thread terminated
- mThread = NULL;
+ pthread_join( mThread, NULL );
+
+ mThread = 0;
}
}
{
// Lock while adding to the request queue
- unique_lock<mutex> lock( mMutex );
+ ConditionalWait::ScopedLock lock( mCondition );
wasEmpty = mQueue.empty();
wasPaused = mPaused;
if( wasEmpty && !wasPaused )
{
// Wake-up the thread
- mCondition.notify_all();
+ mCondition.Notify();
}
}
// Eliminate the cancelled request from the request queue if it is in there:
{
// Lock while searching and removing from the request queue:
- unique_lock<mutex> lock( mMutex );
+ ConditionalWait::ScopedLock lock( mCondition );
for( RequestQueueIter iterator = mQueue.begin();
iterator != mQueue.end();
}
}
+void* ResourceThreadBase::InternalThreadEntryFunc( void* This )
+{
+ ( static_cast<ResourceThreadBase*>( This ) )->ThreadLoop();
+ return NULL;
+}
+
void ResourceThreadBase::Pause()
{
- unique_lock<mutex> lock( mMutex );
+ ConditionalWait::ScopedLock lock( mCondition );
mPaused = true;
}
// Clear the paused flag and if we weren't running already, also wake up the background thread:
bool wasPaused = false;
{
- unique_lock<mutex> lock( mMutex );
+ ConditionalWait::ScopedLock lock( mCondition );
wasPaused = mPaused;
mPaused = false;
}
// chance to do some work:
if( wasPaused )
{
- mCondition.notify_all();
+ mCondition.Notify();
}
}
void ResourceThreadBase::WaitForRequests()
{
- unique_lock<mutex> lock( mMutex );
+ ConditionalWait::ScopedLock lock( mCondition );
if( mQueue.empty() || mPaused == true )
{
// Waiting for a wake up from resource loader control thread
// This will be to process a new request or terminate
- mCondition.wait(lock);
+ mCondition.Wait( lock );
}
}
{
// lock the queue and extract the next request
- unique_lock<mutex> lock(mMutex);
+ ConditionalWait::ScopedLock lock( mCondition );
if (!mQueue.empty())
{
Decode(*request);
}
break;
-
- case RequestSave:
- {
- Save(*request);
- }
- break;
}
}
}
#define __DALI_TIZEN_PLATFORM_RESOURCE_THREAD_BASE_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
// INTERNAL INCLUDES
#include "resource-loader.h"
#include "resource-loading-client.h"
-#include <dali/integration-api/platform-abstraction.h>
-#include <dali/integration-api/resource-cache.h>
+#include <base/conditional-wait.h>
// EXTERNAL INCLUDES
#include <deque>
-#include <boost/thread.hpp>
namespace Dali
{
/** Pull a resource from the network. */
RequestDownload,
/** Pull a resource out of a memory buffer. */
- RequestDecode,
- /** Push a resource's data out to the file system. */
- RequestSave
+ RequestDecode
};
typedef std::pair<Integration::ResourceRequest, RequestType> RequestInfo;
virtual void Decode(const Integration::ResourceRequest& request);
/**
- * Save a resource
- * @param[in] request The requested resource/file url and attributes
- */
- virtual void Save(const Integration::ResourceRequest& request) = 0;
-
- /**
* @brief Cancels current resource request if it matches the one latched to be cancelled.
*
* @copydoc ResourceLoadingClient::InterruptionPoint
*/
virtual void InterruptionPoint() const;
+private:
+ /**
+ * Helper for the thread calling the entry function
+ * @param[in] This A pointer to the current UpdateThread object
+ */
+ static void* InternalThreadEntryFunc( void* This );
+
protected:
- ResourceLoader& mResourceLoader;
- boost::thread* mThread; ///< thread instance
- boost::condition_variable mCondition; ///< condition variable
- boost::mutex mMutex; ///< used to protect mQueue
- RequestQueue mQueue; ///< Request queue
+ ResourceLoader& mResourceLoader;
+ pthread_t mThread; ///< thread instance
+ Internal::Adaptor::ConditionalWait mCondition; ///< condition variable
+ RequestQueue mQueue; ///< Request queue
private:
- Integration::ResourceId mCurrentRequestId; ///< Current request, set by worker thread
- volatile Integration::ResourceId mCancelRequestId; ///< Request to be cancelled on thread: written by external thread and read by worker.
- bool mPaused; ///< Whether to process work in mQueue
+ Integration::ResourceId mCurrentRequestId; ///< Current request, set by worker thread
+ volatile Integration::ResourceId mCancelRequestId; ///< Request to be cancelled on thread: written by external thread and read by worker.
+ bool mPaused; ///< Whether to process work in mQueue
private:
}
}
-void ResourceThreadImage::Save(const Integration::ResourceRequest& request)
-{
- DALI_LOG_TRACE_METHOD( mLogFilter );
- DALI_ASSERT_DEBUG( request.GetType()->id == ResourceBitmap );
- DALI_LOG_WARNING( "Image saving not supported on background resource threads." );
-}
-
bool ResourceThreadImage::DownloadRemoteImageIntoMemory(const Integration::ResourceRequest& request, Dali::Vector<uint8_t>& dataBuffer, size_t& dataSize)
{
bool ok = Network::DownloadRemoteFileIntoMemory( request.GetPath(), dataBuffer, dataSize, MAXIMUM_DOWNLOAD_IMAGE_SIZE );
virtual void Decode(const Integration::ResourceRequest& request);
/**
- *@copydoc ResourceThreadBase::Save
- */
- virtual void Save(const Integration::ResourceRequest& request);
-
- /**
* Download a requested image into a memory buffer.
* @param[in] request The requested resource/file url and attributes
* @param[out] dataBuffer A memory buffer object to be written with downloaded image data.
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
}
}
-bool TizenPlatformAbstraction::IsLoading()
-{
- if (mResourceLoader)
- {
- return mResourceLoader->IsLoading();
- }
-
- return false;
-}
-
void TizenPlatformAbstraction::GetResources(Integration::ResourceCache& cache)
{
if (mResourceLoader)
}
}
-void TizenPlatformAbstraction::SetDpi(unsigned int dpiHor, unsigned int dpiVer)
-{
- if (mResourceLoader)
- {
- mResourceLoader->SetDpi(dpiHor, dpiVer);
- }
-}
-
bool TizenPlatformAbstraction::LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const
{
bool result = false;
return result;
}
-bool TizenPlatformAbstraction::SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const
-{
- bool result = false;
-
- if( mResourceLoader )
- {
- result = mResourceLoader->SaveFile( filename, buffer, numBytes );
- }
-
- return result;
-}
-
void TizenPlatformAbstraction::JoinLoaderThreads()
{
delete mResourceLoader;
#define __DALI_TIZEN_PLATFORM_ABSTRACTION_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
virtual void GetResources(Integration::ResourceCache& cache);
/**
- * @copydoc PlatformAbstraction::IsLoading()
- */
- virtual bool IsLoading();
-
- /**
* @copydoc PlatformAbstraction::JoinLoaderThreads()
*/
virtual void JoinLoaderThreads();
virtual int GetDefaultFontSize() const;
/**
- * @copydoc PlatformAbstraction::SetDpi()
- */
- virtual void SetDpi (unsigned int DpiHorizontal, unsigned int DpiVertical);
-
- /**
* @copydoc PlatformAbstraction::LoadFile()
*/
virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
virtual std::string LoadFile( const std::string& filename );
/**
- * @copydoc PlatformAbstraction::SaveFile()
- */
- virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const;
-
- /**
* @copydoc PlatformAbstraction::LoadShaderBinaryFile()
*/
virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
bool FontClient::IsScalable( const FontPath& path )
{
- return GetImplementation(*this).IsScalable( path );;
+ return GetImplementation(*this).IsScalable( path );
}
bool FontClient::IsScalable( const FontDescription& fontDescription )