PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
dali-core
dali-toolkit
+ dali-adaptor
)
PKG_CHECK_MODULES(DALI_ADAPTOR REQUIRED
END_TEST;
}
-int UtcDaliImageViewAsyncLoadingWithAltasing(void)
+int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
{
ToolkitTestApplication application;
callStack.Reset();
callStack.Enable(true);
- application.GetPlatform().SetClosestImageSize(Vector2(34, 34));
- BitmapLoader::ResetLatestCreated();
ImageView imageView = ImageView::New( gImage_34_RGBA, ImageDimensions( 34, 34 ) );
// By default, Aysnc loading is used
// loading is not started if the actor is offStage
- BitmapLoader loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( !loader );
Stage::GetCurrent().Add( imageView );
application.SendNotification();
application.Render(16);
application.SendNotification();
- // loading started
- loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( loader );
-
- loader.WaitForLoading();// waiting until the image to be loaded
- DALI_TEST_CHECK( loader.IsLoaded() );
-
+ // loading started, this waits for the loader thread for max 30 seconds
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
application.SendNotification();
#include "async-image-loader-impl.h"
// EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
#include <dali/integration-api/adaptors/adaptor.h>
namespace Dali
mIsLoadThreadStarted = true;
}
- BitmapLoader loader = BitmapLoader::New( url, dimensions, fittingMode, samplingMode, orientationCorrection );
-
- mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, loader ) );
+ mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, url, dimensions, fittingMode, samplingMode, orientationCorrection ) );
return mLoadTaskId;
}
{
while( LoadingTask *next = mLoadThread.NextCompletedTask() )
{
- mLoadedSignal.Emit( next->id, next->loader.GetPixelData() );
+ mLoadedSignal.Emit( next->id, next->pixelData );
delete next;
}
}
// CLASS HEADER
#include "image-load-thread.h"
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/image-loading.h>
+
namespace Dali
{
namespace Internal
{
-LoadingTask::LoadingTask(uint32_t id, BitmapLoader loader )
-: loader( loader ),
- id( id )
+LoadingTask::LoadingTask( uint32_t id, const std::string& url, ImageDimensions dimensions,
+ FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
+: pixelData(),
+ url( url ),
+ id( id ),
+ dimensions( dimensions ),
+ fittingMode( fittingMode ),
+ samplingMode( samplingMode ),
+ orientationCorrection( orientationCorrection )
+{
+}
+
+void LoadingTask::Load()
{
+ pixelData = Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection );
}
+
ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger )
: mTrigger( trigger )
{
{
while( LoadingTask* task = NextTaskToProcess() )
{
- task->loader.Load();
+ task->Load();
AddCompletedTask( task );
}
}
mTrigger->Trigger();
}
-
-
} // namespace Internal
} // namespace Toolkit
// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/images/pixel-data.h>
#include <dali/devel-api/threading/conditional-wait.h>
#include <dali/devel-api/threading/mutex.h>
#include <dali/devel-api/threading/thread.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
#include <dali/devel-api/adaptor-framework/event-thread-callback.h>
+
namespace Dali
{
{
/**
* Constructor.
+ * @param [in] id of the task
+ * @param [in] url The URL of the image file to load.
+ * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
+ * @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.
*/
- LoadingTask( uint32_t id, BitmapLoader loader );
+ LoadingTask( uint32_t id, const std::string& url, ImageDimensions dimensions,
+ FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection );
+
+ /**
+ * Load the image
+ */
+ void Load();
private:
public:
- BitmapLoader loader; ///< The loader used to load the bitmap from URL
- uint32_t id; ///< The id associated with this task.
+ PixelData pixelData; ///< pixelData handle after successfull load
+ std::string url; ///< url of the image to load
+ uint32_t id; ///< The unique id associated with this task.
+ ImageDimensions dimensions; ///< dimensions to load
+ FittingMode::Type fittingMode; ///< fitting options
+ SamplingMode::Type samplingMode; ///< sampling options
+ bool orientationCorrection:1; ///< if orientation correction is needed
+
};
// CLASS HEADER
#include "sync-image-loader.h"
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+#include <dali/devel-api/adaptor-framework/image-loading.h>
namespace Dali
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();
+ return Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection );
}