utc-Dali-ImageAtlas.cpp
utc-Dali-VideoView.cpp
utc-Dali-AsyncImageLoader.cpp
+ utc-Dali-SyncImageLoader.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
#include <dali/dali.h>
#include <dali-toolkit-test-suite-utils.h>
#include <toolkit-event-thread-callback.h>
-#include <dali-toolkit/devel-api/image-loader/async-image-loader.h>
+#include <dali-toolkit/dali-toolkit.h>
using namespace Dali;
using namespace Dali::Toolkit;
END_TEST;
}
+int UtcDaliAsyncImageLoaderDownCastP(void)
+{
+ AsyncImageLoader asyncImageLoader = AsyncImageLoader::New();
+ BaseHandle object(asyncImageLoader);
+
+ AsyncImageLoader asyncImageLoader2 = AsyncImageLoader::DownCast( object );
+
+ DALI_TEST_CHECK( asyncImageLoader2 );
+
+ END_TEST;
+}
+
+int UtcDaliAsyncImageLoaderDownCastN(void)
+{
+ BaseHandle unInitializedObject;
+ AsyncImageLoader asyncImageLoader = AsyncImageLoader::DownCast( unInitializedObject );
+
+ DALI_TEST_CHECK( !asyncImageLoader );
+
+ END_TEST;
+}
+
int UtcDaliAsyncImageLoaderLoadAndLoadedSignal(void)
{
ToolkitTestApplication application;
END_TEST;
}
+// Note: This is not an ideal test, but we cannot guarantee we can call Cancel() before the image has finished loading.
int UtcDaliAsyncImageLoaderCancel(void)
{
ToolkitTestApplication application;
uint32_t id02 = loader.Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) );
uint32_t id03 = loader.Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true );
- // cancel the loading of the second image
- DALI_TEST_CHECK( loader.Cancel( id02 ) );
-
EventThreadCallback* eventTrigger = EventThreadCallback::Get();
CallbackBase* callback = eventTrigger->GetCallback();
- eventTrigger->WaitingForTrigger( 2 );// waiting until first and third images are loaded
+ eventTrigger->WaitingForTrigger( 3 ); // waiting until images are loaded
CallbackBase::Execute( *callback );
- DALI_TEST_CHECK( ! loader.Cancel( id03 ) ); // can not cancel a task that is already implemeted
-
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( loadedSignalVerifier.LoadedImageCount() == 2 );
+ DALI_TEST_CHECK( loadedSignalVerifier.LoadedImageCount() == 3 );
+
+ DALI_TEST_CHECK( !loader.Cancel( id03 ) ); // Cannot cancel a task that is already implemeted
- DALI_TEST_CHECK( loadedSignalVerifier.Verify( id01, 34, 34 ) ); // first image is successfully loaded
- DALI_TEST_CHECK( !loadedSignalVerifier.Verify( id02, 25, 25 ) ); // second image is not loaded
- DALI_TEST_CHECK( loadedSignalVerifier.Verify( id03, 100, 100 ) ); // third image is successfully loaded
+ DALI_TEST_CHECK( loadedSignalVerifier.Verify( id01, 34, 34 ) ); // first image is loaded
+ DALI_TEST_CHECK( loadedSignalVerifier.Verify( id02, 25, 25 ) ); // second image is loaded
+ DALI_TEST_CHECK( loadedSignalVerifier.Verify( id03, 100, 100 ) ); // third image is loaded
END_TEST;
}
-int UtcDaliAsncImageLoaderCancelAll01(void)
+int UtcDaliAsyncImageLoaderCancelAll(void)
{
ToolkitTestApplication application;
END_TEST;
}
-int UtcDaliAsyncImageLoaderCancelAll02(void)
-{
- ToolkitTestApplication application;
-
- AsyncImageLoader loader = AsyncImageLoader::New();
- ImageLoadedSignalVerifier loadedSignalVerifier;
-
- loader.ImageLoadedSignal().Connect( &loadedSignalVerifier, &ImageLoadedSignalVerifier::ImageLoaded );
-
- loader.Load( gImage_34_RGBA, ImageDimensions( 34, 34 ) );
- uint32_t id02 = loader.Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) );
-
- // try to cancel the loading of the first and second image, however the cancellation of the first image is not guaranteed
- loader.CancelAll();
-
- uint32_t id03 = loader.Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true );
- loader.Load( gImage_128_RGB, ImageDimensions( 128, 128 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true );
-
- EventThreadCallback* eventTrigger = EventThreadCallback::Get();
- CallbackBase* callback = eventTrigger->GetCallback();
-
- eventTrigger->WaitingForTrigger( 2 );// waiting until the third images is loaded
-
- CallbackBase::Execute( *callback );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( !loadedSignalVerifier.Verify( id02, 25, 25 ) ); // second image is not loaded
- DALI_TEST_CHECK( loadedSignalVerifier.Verify( id03, 100, 100 ) ); // third image is successfully loaded
-
- END_TEST;
-}
-
-
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <dali/dali.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+
+// Resolution: 50*50, pixel format: RGBA8888
+static const char* gImage_50_RGBA = TEST_RESOURCE_DIR "/icon-delete.png";
+
+// Resolution: 128*128, pixel format: RGB888
+static const char* gImage_128_RGB = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+
+
+void VerifyLoad( PixelData pixelData, uint32_t width, uint32_t height )
+{
+ DALI_TEST_CHECK( pixelData );
+ DALI_TEST_EQUALS<unsigned int>( pixelData.GetWidth(), width, TEST_LOCATION );
+ DALI_TEST_EQUALS<unsigned int>( pixelData.GetHeight(), height, TEST_LOCATION );
+}
+
+} // anonymous namespace
+
+
+int UtcDaliSyncImageLoaderLoad(void)
+{
+ PixelData pixelData = Toolkit::SyncImageLoader::Load( gImage_50_RGBA );
+
+ DALI_TEST_EQUALS<bool>( pixelData, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliSyncImageLoaderLoadWithDimensions(void)
+{
+ PixelData pixelData = Toolkit::SyncImageLoader::Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) );
+
+ VerifyLoad( pixelData, 25u, 25u );
+
+ END_TEST;
+}
+
+int UtcDaliSyncImageLoaderLoadWithAllOptions(void)
+{
+ PixelData pixelData = Toolkit::SyncImageLoader::Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true );
+
+ VerifyLoad( pixelData, 100u, 100u );
+
+ END_TEST;
+}
+
+
develapishadowviewdir = $(develapicontrolsdir)/shadow-view
develapisuperblurviewdir = $(develapicontrolsdir)/super-blur-view
develapifocusmanagerdir = $(develapidir)/focus-manager
-develapiimageloaderdir = $(develapidir)/image-loader
+develapiimageloaderdir = $(develapidir)/image-loader
develapiscriptingdir = $(develapidir)/scripting
develapishadereffectsdir = $(develapidir)/shader-effects
develapitransitioneffectsdir = $(develapidir)/transition-effects
# public api source
publicapidir = $(topleveldir)/public-api
publicapicontrolsdir = $(publicapidir)/controls
+publicapiimageloaderdir = $(publicapidir)/image-loader
publicapiaccessibilitymanagerdir = $(publicapidir)/accessibility-manager
publicapialignmentdir = $(publicapicontrolsdir)/alignment
publicapibuttonsdir = $(publicapicontrolsdir)/buttons
# public api headers
publicapi_HEADERS = $(public_api_header_files)
publicapicontrols_HEADERS = $(public_api_controls_header_files)
+publicapiimageloader_HEADERS = $(public_api_image_loader_header_files)
publicapiaccessibilitymanager_HEADERS = $(public_api_accessibility_manager_header_files)
publicapialignment_HEADERS = $(public_api_alignment_header_files)
publicapibuttons_HEADERS = $(public_api_buttons_header_files)
ALIASES += SINCE_1_2_4="@since 1.2.4"
ALIASES += SINCE_1_2_5="@since 1.2.5"
ALIASES += SINCE_1_2_10="@since 1.2.10"
+ALIASES += SINCE_1_2_14="@since 1.2.14"
ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 1.0"
ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 1.1"
#ALIASES += SINCE_1_2_4="\par Since:\n 3.0, DALi version 1.2.4"
#ALIASES += SINCE_1_2_5="\par Since:\n 3.0, DALi version 1.2.5"
#ALIASES += SINCE_1_2_10="\par Since:\n 3.0, DALi version 1.2.10"
+#ALIASES += SINCE_1_2_14="\par Since:\n 3.0, DALi version 1.2.14"
## DALi has no deprecated API in Tizen 2.4 because it's DALi's first release.
## Thus deprecated APIs in DALi 1.0.xx will be deprecated in Tizen 3.0.
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/public-api/controls/video-view/video-view.h>
+#include <dali-toolkit/public-api/image-loader/async-image-loader.h>
+#include <dali-toolkit/public-api/image-loader/sync-image-loader.h>
+
#include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
$(devel_api_src_dir)/controls/text-controls/text-selection-toolbar.cpp \
$(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \
$(devel_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
- $(devel_api_src_dir)/image-loader/async-image-loader.cpp \
$(devel_api_src_dir)/image-loader/atlas-upload-observer.cpp \
$(devel_api_src_dir)/image-loader/image-atlas.cpp \
$(devel_api_src_dir)/scripting/script.cpp \
$(devel_api_src_dir)/focus-manager/keyinput-focus-manager.h
devel_api_image_loader_header_files = \
- $(devel_api_src_dir)/image-loader/async-image-loader.h \
$(devel_api_src_dir)/image-loader/atlas-upload-observer.h \
$(devel_api_src_dir)/image-loader/image-atlas.h
AsyncImageLoader::AsyncImageLoader()
: mLoadedSignal(),
mLoadThread( new EventThreadCallback( MakeCallback( this, &AsyncImageLoader::ProcessLoadedImage ) ) ),
- mLoadTaskId( 0 ),
+ mLoadTaskId( 0u ),
mIsLoadThreadStarted( false )
{
}
}
uint32_t AsyncImageLoader::Load( const std::string& url,
- ImageDimensions size,
+ ImageDimensions dimensions,
FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
bool orientationCorrection )
mIsLoadThreadStarted = true;
}
- BitmapLoader loader = BitmapLoader::New( url, size, fittingMode, samplingMode, orientationCorrection );
+ BitmapLoader loader = BitmapLoader::New( url, dimensions, fittingMode, samplingMode, orientationCorrection );
mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, loader ) );
-#ifndef DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H__
-#define DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H__
+#ifndef DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H
+#define DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
#include <dali/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/image-loader/async-image-loader.h>
+#include <dali-toolkit/public-api/image-loader/async-image-loader.h>
#include <dali-toolkit/internal/image-loader/image-load-thread.h>
namespace Dali
static IntrusivePtr<AsyncImageLoader> New();
/**
- * @copydoc Toolkit::AsyncImageLoader::Load( const std::string&, ImageDimensions,FittingMode::Type, SamplingMode::Type, bool )
+ * @copydoc Toolkit::AsyncImageLoader::Load( const std::string&, ImageDimensions, FittingMode::Type, SamplingMode::Type, bool )
*/
uint32_t Load( const std::string& url,
- ImageDimensions size,
+ ImageDimensions dimensions,
FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
bool orientationCorrection );
} // namespace Internal
-inline const Internal::AsyncImageLoader& GetImplementation( const Toolkit::AsyncImageLoader& loader )
+inline const Internal::AsyncImageLoader& GetImplementation( const Toolkit::AsyncImageLoader& handle )
{
- DALI_ASSERT_ALWAYS( loader && "AsyncImageLoader handle is empty" );
+ DALI_ASSERT_ALWAYS( handle && "AsyncImageLoader handle is empty" );
- const BaseObject& object = loader.GetBaseObject();
+ const BaseObject& object = handle.GetBaseObject();
return static_cast<const Internal::AsyncImageLoader&>( object );
}
-inline Internal::AsyncImageLoader& GetImplementation( Toolkit::AsyncImageLoader& loader )
+inline Internal::AsyncImageLoader& GetImplementation( Toolkit::AsyncImageLoader& handle )
{
- DALI_ASSERT_ALWAYS( loader && "AsyncImageLoader handle is empty" );
+ DALI_ASSERT_ALWAYS( handle && "AsyncImageLoader handle is empty" );
- BaseObject& object = loader.GetBaseObject();
+ BaseObject& object = handle.GetBaseObject();
return static_cast<Internal::AsyncImageLoader&>( object );
}
} // namespace Dali
-#endif /* DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H__ */
+#endif // DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/image-loader/image-atlas.h>
-#include <dali-toolkit/devel-api/image-loader/async-image-loader.h>
#include <dali-toolkit/internal/image-loader/atlas-packer.h>
+#include <dali-toolkit/public-api/image-loader/async-image-loader.h>
namespace Dali
{
void ImageLoadThread::Run()
{
- while( LoadingTask* task = NextTaskToProcess())
+ while( LoadingTask* task = NextTaskToProcess() )
{
task->loader.Load();
AddCompletedTask( task );
mLoadQueue.PushBack( task );
}
- if( wasEmpty)
+ if( wasEmpty )
{
// wake up the image loading thread
mConditionalWait.Notify();
// Lock while remove task from the queue
ConditionalWait::ScopedLock lock( mConditionalWait );
- for( Vector< LoadingTask* >::Iterator iter = mLoadQueue.Begin(); iter != mLoadQueue.End(); iter++ )
+ for( Vector< LoadingTask* >::Iterator iter = mLoadQueue.Begin(); iter != mLoadQueue.End(); ++iter )
{
if( (*iter)->id == loadingTaskId )
{
// Lock while remove task from the queue
ConditionalWait::ScopedLock lock( mConditionalWait );
- for( Vector< LoadingTask* >::Iterator iter = mLoadQueue.Begin(); iter != mLoadQueue.End(); iter++ )
+ for( Vector< LoadingTask* >::Iterator iter = mLoadQueue.Begin(); iter != mLoadQueue.End(); ++iter )
{
- delete (*iter);
+ delete ( *iter );
}
mLoadQueue.Clear();
}
if( !shader )
{
shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
+ shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
}
}
if( !shader )
{
shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_VARIOUS_WRAP );
+ shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_CUSTOM_WRAP, shader );
}
}
if( !shader )
{
shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_NO_ATLAS );
+ shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER, shader );
}
}
- shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
+
return shader;
}
mImpl->mRenderer = Renderer::New( geometry, shader );
mImpl->mRenderer.SetTextures( textureSet );
+ // Register transform properties
+ mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
+
if( mImpl->mSize != Vector2::ZERO && mParsedImage )
{
AddRasterizationTask( mImpl->mSize );
{
unsigned int width = static_cast<unsigned int>(size.width);
unsigned int height = static_cast<unsigned int>( size.height );
- BufferImage image = BufferImage::New( width, height, Pixel::RGBA8888);
RasterizingTaskPtr newTask = new RasterizingTask( this, mParsedImage, width, height );
mFactoryCache.GetSVGRasterizationThread()->AddTask( newTask );
$(public_api_src_dir)/controls/text-controls/text-label.cpp \
$(public_api_src_dir)/controls/text-controls/text-field.cpp \
$(public_api_src_dir)/controls/video-view/video-view.cpp \
+ $(public_api_src_dir)/image-loader/async-image-loader.cpp \
+ $(public_api_src_dir)/image-loader/sync-image-loader.cpp \
$(public_api_src_dir)/styling/style-manager.cpp \
$(public_api_src_dir)/accessibility-manager/accessibility-manager.cpp \
$(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \
$(public_api_src_dir)/controls/scrollable/item-view/item-view-declarations.h \
$(public_api_src_dir)/controls/scrollable/item-view/item-view.h
+public_api_image_loader_header_files = \
+ $(public_api_src_dir)/image-loader/async-image-loader.h \
+ $(public_api_src_dir)/image-loader/sync-image-loader.h
+
public_api_scrollable_header_files = \
$(public_api_src_dir)/controls/scrollable/scrollable.h
AsyncImageLoader::AsyncImageLoader( Internal::AsyncImageLoader* impl )
: BaseHandle( impl )
-{}
+{
+}
AsyncImageLoader::AsyncImageLoader( const AsyncImageLoader& handle )
: BaseHandle( handle )
AsyncImageLoader& AsyncImageLoader::operator=( const AsyncImageLoader& handle )
{
- BaseHandle::operator=(handle);
+ BaseHandle::operator=( handle );
return *this;
}
+AsyncImageLoader AsyncImageLoader::DownCast( BaseHandle handle )
+{
+ return AsyncImageLoader( dynamic_cast<Dali::Toolkit::Internal::AsyncImageLoader*>( handle.GetObjectPtr() ) );
+}
+
AsyncImageLoader AsyncImageLoader::New()
{
IntrusivePtr<Internal::AsyncImageLoader> internal = Internal::AsyncImageLoader::New();
uint32_t AsyncImageLoader::Load( const std::string& url )
{
- return GetImplementation(*this).Load( url, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true );
+ return GetImplementation( *this ).Load( url, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true );
}
-uint32_t AsyncImageLoader::Load( const std::string& url, ImageDimensions size )
+uint32_t AsyncImageLoader::Load( const std::string& url, ImageDimensions dimensions )
{
- return GetImplementation(*this).Load( url, size, FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true );
+ return GetImplementation( *this ).Load( url, dimensions, FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true );
}
uint32_t AsyncImageLoader::Load( const std::string& url,
- ImageDimensions size,
+ ImageDimensions dimensions,
FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
bool orientationCorrection )
{
- return GetImplementation(*this).Load( url, size, fittingMode, samplingMode, orientationCorrection );
+ return GetImplementation(*this).Load( url, dimensions, fittingMode, samplingMode, orientationCorrection );
}
-bool AsyncImageLoader::Cancel( uint32_t loadingTaskId)
+bool AsyncImageLoader::Cancel( uint32_t loadingTaskId )
{
return GetImplementation(*this).Cancel( loadingTaskId );
}
void AsyncImageLoader::CancelAll()
{
- GetImplementation(*this).CancelAll();
+ GetImplementation( *this ).CancelAll();
}
AsyncImageLoader::ImageLoadedSignalType& AsyncImageLoader::ImageLoadedSignal()
{
- return GetImplementation(*this).ImageLoadedSignal();
+ return GetImplementation( *this ).ImageLoadedSignal();
}
} // namespace Toolkit
-#ifndef __DALI_TOOLKIT_ASYNC_IMAGE_LOADER_H__
-#define __DALI_TOOLKIT_ASYNC_IMAGE_LOADER_H__
+#ifndef DALI_TOOLKIT_ASYNC_IMAGE_LOADER_H
+#define DALI_TOOLKIT_ASYNC_IMAGE_LOADER_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
}
/**
- *@brief The AysncImageLoader is used to load pixel data from the URL asynchronously.
+ * @brief The AsyncImageLoader is used to load pixel data from a URL asynchronously.
*
* The images are loaded in a worker thread to avoid blocking the main event thread.
*
- * Each load call is assigned with an ID, connect to the ImageLoadedSignal and receive the corresponding pixel data by comparing the ID.
+ * To keep track of the loading images, each load call is assigned an ID (which is returned by the Load() call).
+ * To know when the Load has completed, connect to the ImageLoadedSignal.
+ * This signal should be connected before Load is called (in case the signal is emitted immediately).
+ *
+ * Load errors can be detected by checking the PixelData object is valid from within the signal handler.
+
+ * Note: The PixelData object will automatically be destroyed when it leaves its scope.
+ *
+ * Example:
*
- * To make sure the signal is always received, the signal should get connected before invoking the load call.
* @code
* class MyClass : public ConnectionTracker
* {
- * public:
+ * public:
*
- * MyCallback( uint32_t id, PixelData pixelData)
+ * MyCallback( uint32_t loadedTaskId, PixelData pixelData )
* {
- * if(id == mId1)
+ * // First check if the image loaded correctly.
+ * if( pixelData )
* {
- * // use the loaded pixel data from the first image
- * }
- * else if( id == mId2 )
- * {
- * // use the loaded pixel data from the second image
+ * if( loadedTaskId == mId1 )
+ * {
+ * // use the loaded pixel data from the first image
+ * }
+ * else if( loadedTaskId == mId2 )
+ * {
+ * // use the loaded pixel data from the second image
+ * }
* }
* }
*
*
* MyClass myObject;
* AsyncImageLoader imageLoader = AsyncImageLoader::New();
- * // connect the signal here
+ *
+ * // Connect the signal here.
* imageLoader.ImageLoadedSignal().Connect( &myObject, &MyClass::MyCallback );
- * // then invoke the load calls
- * testCallback.mId1 = imageLoader.Load( "first_image_url.jpg" );
- * testCallback.mId2 = imageLoader.Load( "second_image_url.jpg" );
+ *
+ * // Invoke the load calls (must do this after connecting the signal to guarantee callbacks occur).
+ * myObject.mId1 = imageLoader.Load( "first_image_url.jpg" );
+ * myObject.mId2 = imageLoader.Load( "second_image_url.jpg" );
*
* @endcode
*/
{
public:
- /**
- * @brief Type of signal for image loading finished.
- *
- * The signal is emit with the load ID and its corresponding loaded pixel data
- */
- typedef Signal< void( uint32_t, PixelData ) > ImageLoadedSignalType;
+ typedef Signal< void( uint32_t, PixelData ) > ImageLoadedSignalType; ///< Image loaded signal type @SINCE_1_2_14
public:
/**
* @brief Constructor which creates an empty AsyncImageLoader handle.
+ * @SINCE_1_2_14
*
* Use AsyncImageLoader::New() to create an initialised object.
*/
/**
* @brief Destructor
+ * @SINCE_1_2_14
*
* This is non-virtual since derived Handle types must not contain data or virtual methods.
*/
/**
* @brief This copy constructor is required for (smart) pointer semantics.
+ * @SINCE_1_2_14
*
- * @param [in] handle A reference to the copied handle
+ * @param[in] handle A reference to the copied handle
*/
AsyncImageLoader( const AsyncImageLoader& handle );
/**
* @brief This assignment operator is required for (smart) pointer semantics.
+ * @SINCE_1_2_14
*
- * @param [in] handle A reference to the copied handle
+ * @param[in] handle A reference to the copied handle
* @return A reference to this
*/
AsyncImageLoader& operator=( const AsyncImageLoader& handle );
- /*
- * @brief Create a new loader to load the image asynchronously in a worker thread.
- *
- * @return The image loader.
- */
+ /**
+ * @brief Create a new loader to load the image asynchronously in a worker thread.
+ * @SINCE_1_2_14
+ *
+ * @return The image loader.
+ */
static AsyncImageLoader New();
/**
- * @brief Start a image loading task.
+ * @brief Downcast a handle to AsyncImageLoader handle.
+ *
+ * If the handle points to an AsyncImageLoader object the downcast produces
+ * a valid handle. If not, the returned handle is left uninitialized.
+ *
+ * @SINCE_1_2_14
+ * @param[in] handle A handle to an object
+ * @return A handle to a AsyncImageLoader object or an uninitialized handle
+ */
+ static AsyncImageLoader DownCast( BaseHandle handle );
+
+ /**
+ * @brief Start an image loading task.
+ * Note: When using this method, the following defaults will be used:
+ * fittingMode = FittingMode::DEFAULT
+ * samplingMode = SamplingMode::BOX_THEN_LINEAR
+ * orientationCorrection = true
+ *
+ * @SINCE_1_2_14
*
* @param[in] url The URL of the image file to load.
* @return The loading task id.
*/
uint32_t Load( const std::string& url );
- /*
- * @brief Start a image loading task.
+
+ /**
+ * @brief Start an image loading task.
+ * Note: When using this method, the following defaults will be used:
+ * fittingMode = FittingMode::DEFAULT
+ * samplingMode = SamplingMode::BOX_THEN_LINEAR
+ * orientationCorrection = true
+ *
+ * @SINCE_1_2_14
*
* @param[in] url The URL of the image file to load.
- * @param[in] size The width and height to fit the loaded image to.
+ * @param[in] dimensions The width and height to fit the loaded image to.
* @return The loading task id.
*/
- uint32_t Load( const std::string& url, ImageDimensions size );
+ uint32_t Load( const std::string& url, ImageDimensions dimensions );
- /*
- * @brief Start a image loading task.
+ /**
+ * @brief Start an image loading task.
+ * @SINCE_1_2_14
*
* @param[in] url The URL of the image file to load.
- * @param[in] size The width and height to fit the loaded image to.
+ * @param[in] dimensions The width and height to fit the loaded image to.
* @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
* @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
* @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
* @return The loading task id.
*/
uint32_t Load( const std::string& url,
- ImageDimensions size,
+ ImageDimensions dimensions,
FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
bool orientationCorrection );
/**
- * @brief Cancel a image loading task if it is still queuing in the work thread.
+ * @brief Cancel a image loading task if it is still queueing in the work thread.
+ * @SINCE_1_2_14
*
* @param[in] loadingTaskId The task id returned when invoking the load call.
* @return If true, the loading task is removed from the queue, otherwise the loading is already implemented and unable to cancel anymore
*/
- bool Cancel( uint32_t loadingTaskId);
+ bool Cancel( uint32_t loadingTaskId );
/**
* @brief Cancel all the loading tasks in the queue
+ * @SINCE_1_2_14
*/
void CancelAll();
* @code
* void YourCallbackName( uint32_t id, PixelData pixelData );
* @endcode
+ * @SINCE_1_2_14
*
- * @return A signal object to Connect() with.
+ * @return A reference to a signal object to Connect() with.
*/
ImageLoadedSignalType& ImageLoadedSignal();
public: // Not intended for developer use
+ /// @cond internal
+ /**
+ * @brief Allows the creation of a AsyncImageLoader handle from an internal pointer.
+ *
+ * @note Not intended for application developers
+ * @SINCE_1_2_14
+ *
+ * @param[in] impl A pointer to the object.
+ */
explicit DALI_INTERNAL AsyncImageLoader( Internal::AsyncImageLoader* impl );
+ /// @endcond
};
} // namespace Dali
-#endif /* __DALI_TOOLKIT_ASYNC_IMAGE_LOADER_H__ */
+#endif // DALI_TOOLKIT_ASYNC_IMAGE_LOADER_H
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include "sync-image-loader.h"
+#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace SyncImageLoader
+{
+
+
+PixelData Load( const std::string& url )
+{
+ return Load( url, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true );
+}
+
+PixelData Load( const std::string& url, ImageDimensions dimensions )
+{
+ return Load( url, dimensions, FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true );
+}
+
+PixelData Load( const std::string& url,
+ ImageDimensions dimensions,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection )
+{
+ BitmapLoader loader = BitmapLoader::New( url, dimensions, fittingMode, samplingMode, orientationCorrection );
+
+ // Load the image synchronously (block the thread here).
+ loader.Load();
+
+ return loader.GetPixelData();
+}
+
+
+} // namespace SyncImageLoader
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_SYNC_IMAGE_LOADER_H
+#define DALI_TOOLKIT_SYNC_IMAGE_LOADER_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/images/pixel-data.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace SyncImageLoader
+{
+
+/**
+ * @brief The methods in the SyncImageLoader namespace are used to load pixel data from a URL synchronously.
+ *
+ * Example:
+ *
+ * @code
+ * PixelData pixelData = Toolkit::SyncImageLoader::Load( "image_url.jpg" );
+ *
+ * // Check the image was loaded without error.
+ * if( pixelData )
+ * {
+ * // Do work...
+ * }
+ *
+ * @endcode
+ */
+
+/**
+ * @brief Load an image synchronously.
+ * Note: When using this method, the following defaults will be used:
+ * fittingMode = FittingMode::DEFAULT
+ * samplingMode = SamplingMode::BOX_THEN_LINEAR
+ * orientationCorrection = true
+ *
+ * @SINCE_1_2_14
+ *
+ * @param[in] url The URL of the image file to load.
+ * @return A PixelData object containing the image, or an invalid object on failure.
+ */
+PixelData Load( const std::string& url );
+
+/**
+ * @brief Load an image synchronously by specifying the target dimensions.
+ * Note: When using this method, the following defaults will be used:
+ * fittingMode = FittingMode::DEFAULT
+ * samplingMode = SamplingMode::BOX_THEN_LINEAR
+ * orientationCorrection = true
+ *
+ * @SINCE_1_2_14
+ *
+ * @param[in] url The URL of the image file to load.
+ * @param[in] dimensions The width and height to fit the loaded image to.
+ * @return A PixelData object containing the image, or an invalid object on failure.
+ */
+PixelData Load( const std::string& url, ImageDimensions dimensions );
+
+/**
+ * @brief Load an image synchronously by specifying the target dimensions and options.
+ * @SINCE_1_2_14
+ *
+ * @param[in] url The URL of the image file to load.
+ * @param[in] dimensions The width and height to fit the loaded image to.
+ * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
+ * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
+ * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
+ * @return A PixelData object containing the image, or an invalid object on failure.
+ */
+PixelData Load( const std::string& url,
+ ImageDimensions dimensions,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection );
+
+} // namespace SyncImageLoader
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_SYNC_IMAGE_LOADER_H