/*
- * 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 <dali/integration-api/bitmap.h>
#include <dali/integration-api/resource-types.h>
+// INTERNAL INCLUDES
#include "resource-loader/resource-loader.h"
-
-#include "tizen-font-configuration-parser.h"
#include "image-loaders/image-loader.h"
+#include "portable/file-closer.h"
namespace Dali
{
namespace TizenPlatform
{
-namespace
-{
-const std::string FONT_CONFIGURATION_FILE( FONT_CONFIGURATION_FILE_PATH ); ///< Default font configuration file
-const unsigned int NANOSECS_TO_MICROSECS( 1000 ); ///< 1000 nanoseconds = 1 microsecond
-}
-
TizenPlatformAbstraction::TizenPlatformAbstraction()
: mResourceLoader(new ResourceLoader),
mDataStoragePath( "" )
delete mResourceLoader;
}
-void TizenPlatformAbstraction::GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds)
-{
- timespec time;
- clock_gettime(CLOCK_MONOTONIC, &time);
- seconds = time.tv_sec;
- microSeconds = time.tv_nsec / NANOSECS_TO_MICROSECS;
-}
-
void TizenPlatformAbstraction::Suspend()
{
if (mResourceLoader)
}
}
-void TizenPlatformAbstraction::GetDefaultFontDescription( std::string& fontFamily, std::string& fontStyle ) const
-{
- FontConfigurationParser::Parse(FONT_CONFIGURATION_FILE, fontFamily, fontStyle);
-}
-
int TizenPlatformAbstraction::GetDefaultFontSize() const
{
int fontSize( -1 );
return ImageLoader::LoadResourceSynchronously( resourceType, resourcePath );
}
-void TizenPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId)
+Integration::BitmapPtr TizenPlatformAbstraction::DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t size )
{
- if (mResourceLoader)
- {
- mResourceLoader->CancelLoad(id, typeId);
- }
-}
+ Integration::BitmapPtr bitmap = 0;
-bool TizenPlatformAbstraction::IsLoading()
-{
- if (mResourceLoader)
+ Dali::Internal::Platform::FileCloser fileCloser( buffer, size, "rb" );
+ FILE * const fp = fileCloser.GetFile();
+ if( fp )
{
- return mResourceLoader->IsLoading();
+ bool result = ImageLoader::ConvertStreamToBitmap( resourceType, "", fp, StubbedResourceLoadingClient(), bitmap );
+ if ( !result || !bitmap )
+ {
+ bitmap.Reset();
+ DALI_LOG_WARNING( "Unable to decode bitmap supplied as in-memory blob.\n" );
+ }
}
- return false;
+ return bitmap;
}
-void TizenPlatformAbstraction::GetResources(Integration::ResourceCache& cache)
+void TizenPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId)
{
if (mResourceLoader)
{
- mResourceLoader->GetResources(cache);
+ mResourceLoader->CancelLoad(id, typeId);
}
}
-void TizenPlatformAbstraction::SetDpi(unsigned int dpiHor, unsigned int dpiVer)
+void TizenPlatformAbstraction::GetResources(Integration::ResourceCache& cache)
{
if (mResourceLoader)
{
- mResourceLoader->SetDpi(dpiHor, dpiVer);
+ mResourceLoader->GetResources(cache);
}
}
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;