From: Francisco Santos Date: Tue, 21 Feb 2017 18:31:53 +0000 (+0000) Subject: Removed redundant resource loading code X-Git-Tag: dali_1.2.29~6^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F08%2F113008%2F8;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Removed redundant resource loading code Change-Id: Ib378615988f107271e9d570fe320b1e636900ba5 --- diff --git a/adaptors/base/update-status-logger.cpp b/adaptors/base/update-status-logger.cpp index 8bf9469..b7defb0 100644 --- a/adaptors/base/update-status-logger.cpp +++ b/adaptors/base/update-status-logger.cpp @@ -70,11 +70,6 @@ void UpdateStatusLogger::Log( unsigned int keepUpdatingStatus ) oss += " "; } - if ( keepUpdatingStatus & Integration::KeepUpdating::LOADING_RESOURCES ) - { - oss += " "; - } - if ( keepUpdatingStatus & Integration::KeepUpdating::MONITORING_PERFORMANCE ) { oss += " "; diff --git a/adaptors/common/style-monitor-impl.cpp b/adaptors/common/style-monitor-impl.cpp index ca9ec8f..f85e0b1 100644 --- a/adaptors/common/style-monitor-impl.cpp +++ b/adaptors/common/style-monitor-impl.cpp @@ -77,8 +77,7 @@ Dali::StyleMonitor StyleMonitor::Get() } else { - Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) ); - styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) ); + styleMonitor = Dali::StyleMonitor( new StyleMonitor() ); service.Register( typeid( styleMonitor ), styleMonitor ); } } @@ -86,14 +85,13 @@ Dali::StyleMonitor StyleMonitor::Get() return styleMonitor; } -StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction) -: mPlatformAbstraction(platformAbstraction), - mDefaultFontSize(-1) +StyleMonitor::StyleMonitor() +: mDefaultFontSize(-1) { mFontClient = TextAbstraction::FontClient::Get(); GetSystemDefaultFontFamily( mFontClient, mDefaultFontFamily ); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "StyleMonitor::StyleMonitor::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str() ); - mDefaultFontSize = mPlatformAbstraction.GetDefaultFontSize(); + mDefaultFontSize = mFontClient.GetDefaultFontSize(); } StyleMonitor::~StyleMonitor() @@ -117,7 +115,7 @@ void StyleMonitor::StyleChanged( StyleChange::Type styleChange ) case StyleChange::DEFAULT_FONT_SIZE_CHANGE: { - mDefaultFontSize = mPlatformAbstraction.GetDefaultFontSize(); + mDefaultFontSize = mFontClient.GetDefaultFontSize(); break; } diff --git a/adaptors/common/style-monitor-impl.h b/adaptors/common/style-monitor-impl.h index e279a31..5fffbbe 100644 --- a/adaptors/common/style-monitor-impl.h +++ b/adaptors/common/style-monitor-impl.h @@ -21,7 +21,6 @@ // EXTERNAL INCLUDES #include #include -#include #include // INTERNAL INCLUDES @@ -48,9 +47,8 @@ public: /** * Constructor. - * @param[in] platformAbstraction The platform abstraction. */ - StyleMonitor(Integration::PlatformAbstraction& platformAbstraction); + StyleMonitor(); /** * Retrieve the initialized instance of the StyleMonitor. @@ -124,8 +122,6 @@ private: Dali::StyleMonitor::StyleChangeSignalType mStyleChangeSignal; ///< Emitted when the style changes - Integration::PlatformAbstraction& mPlatformAbstraction; ///< Reference to the PlatformAbstraction (for retrieving defaults) - TextAbstraction::FontClient mFontClient; std::string mDefaultFontFamily; ///< The system default font family std::string mDefaultFontStyle; ///< The default font style diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp index 86b5430..b177e4a 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp @@ -25,10 +25,6 @@ namespace Dali TestPlatformAbstraction::TestPlatformAbstraction() : mTrace(), mIsLoadingResult( false ), - mGetDefaultFontSizeResult( 0 ), - mLoadedResourcesQueue(), - mFailedLoadQueue(), - mResourceRequests(), mSize(), mClosestSize(), mLoadFileResult(), @@ -40,17 +36,6 @@ TestPlatformAbstraction::TestPlatformAbstraction() TestPlatformAbstraction::~TestPlatformAbstraction() { - DiscardRequest(); -} - -void TestPlatformAbstraction::Suspend() -{ - mTrace.PushCall("Suspend", ""); -} - -void TestPlatformAbstraction::Resume() -{ - mTrace.PushCall("Resume", ""); } ImageDimensions TestPlatformAbstraction::GetClosestImageSize( const std::string& filename, @@ -75,16 +60,6 @@ ImageDimensions TestPlatformAbstraction::GetClosestImageSize( Integration::Resou return closestSize; } -void TestPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request) -{ - std::ostringstream out; - out << "Type:" << request.GetType()->id << ", Path: " << request.GetPath() << std::endl ; - - mTrace.PushCall("LoadResource", out.str()); - - mResourceRequests.PushBack( new Integration::ResourceRequest(request) ); -} - Integration::ResourcePointer TestPlatformAbstraction::LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath ) { mTrace.PushCall("LoadResourceSynchronously", ""); @@ -97,59 +72,6 @@ Integration::BitmapPtr TestPlatformAbstraction::DecodeBuffer( const Integration: return mDecodedBitmap; } -void TestPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId) -{ - mTrace.PushCall("CancelLoad", ""); -} - -void TestPlatformAbstraction::GetResources(Integration::ResourceCache& cache) -{ - mTrace.PushCall("GetResources", ""); - - while( !mLoadedResourcesQueue.empty() ) - { - LoadedResource loaded( *mLoadedResourcesQueue.begin() ); - mLoadedResourcesQueue.erase( mLoadedResourcesQueue.begin() ); - cache.LoadResponse( loaded.id, loaded.type, loaded.resource, Integration::RESOURCE_COMPLETELY_LOADED ); - } - - // iterate through the resources which failed to load - while( !mFailedLoadQueue.empty() ) - { - FailedLoad failed( *mFailedLoadQueue.begin() ); - mFailedLoadQueue.erase( mFailedLoadQueue.begin() ); - cache.LoadFailed( failed.id, failed.failure ); - } -} - -bool TestPlatformAbstraction::IsLoading() -{ - mTrace.PushCall("IsLoading", ""); - return mIsLoadingResult; -} - -int TestPlatformAbstraction::GetDefaultFontSize() const -{ - mTrace.PushCall("GetDefaultFontSize", ""); - return mGetDefaultFontSizeResult; -} - -void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical) -{ - mTrace.PushCall("SetDpi", ""); -} - -bool TestPlatformAbstraction::LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const -{ - mTrace.PushCall("LoadFile", ""); - if( mLoadFileResult.loadResult ) - { - buffer = mLoadFileResult.buffer; - } - - return mLoadFileResult.loadResult; -} - bool TestPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const { mTrace.PushCall("LoadShaderBinaryFile", ""); @@ -161,25 +83,12 @@ bool TestPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, return mLoadFileResult.loadResult; } -bool TestPlatformAbstraction::SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const -{ - mTrace.PushCall("SaveFile", ""); - return false; -} - -void TestPlatformAbstraction::JoinLoaderThreads() -{ - mTrace.PushCall("JoinLoaderThreads", ""); -} /** Call this every test */ void TestPlatformAbstraction::Initialize() { mTrace.Reset(); mTrace.Enable(true); - mLoadedResourcesQueue.clear(); - mFailedLoadQueue.clear(); - mResourceRequests.Clear(); mIsLoadingResult=false; mSynchronouslyLoadedResource.Reset(); mDecodedBitmap.Reset(); @@ -189,19 +98,9 @@ bool TestPlatformAbstraction::WasCalled(TestFuncEnum func) { switch(func) { - case SuspendFunc: return mTrace.FindMethod("Suspend"); - case ResumeFunc: return mTrace.FindMethod("Resume"); - case LoadResourceFunc: return mTrace.FindMethod("LoadResource"); case LoadResourceSynchronouslyFunc: return mTrace.FindMethod("LoadResourceSynchronously"); - case LoadFileFunc: return mTrace.FindMethod("LoadFile"); case LoadShaderBinaryFileFunc: return mTrace.FindMethod("LoadShaderBinaryFile"); case SaveShaderBinaryFileFunc: return mTrace.FindMethod("SaveShaderBinaryFile"); - case SaveFileFunc: return mTrace.FindMethod("SaveFile"); - case CancelLoadFunc: return mTrace.FindMethod("CancelLoad"); - case GetResourcesFunc: return mTrace.FindMethod("GetResources"); - case IsLoadingFunc: return mTrace.FindMethod("IsLoading"); - case SetDpiFunc: return mTrace.FindMethod("SetDpi"); - case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads"); } return false; } @@ -213,88 +112,10 @@ void TestPlatformAbstraction::SetIsLoadingResult(bool result) void TestPlatformAbstraction::ClearReadyResources() { - mLoadedResourcesQueue.clear(); - mFailedLoadQueue.clear(); mSynchronouslyLoadedResource.Reset(); mDecodedBitmap.Reset(); } -void TestPlatformAbstraction::SetResourceLoaded(Integration::ResourceId loadedId, - Integration::ResourceTypeId loadedType, - Integration::ResourcePointer loadedResource) -{ - LoadedResource loadedInfo; - loadedInfo.id = loadedId; - loadedInfo.type = loadedType; - loadedInfo.resource = loadedResource; - mLoadedResourcesQueue.push_back( loadedInfo ); -} - -void TestPlatformAbstraction::SetResourceLoadFailed(Integration::ResourceId id, - Integration::ResourceFailure failure) -{ - FailedLoad failedInfo; - failedInfo.id = id; - failedInfo.failure = failure; - mFailedLoadQueue.push_back( failedInfo ); -} - -Integration::ResourceRequest* TestPlatformAbstraction::GetRequest() -{ - Integration::ResourceRequest* request = NULL; - - // Return last request - if( ! mResourceRequests.Empty() ) - { - request = *( mResourceRequests.End() - 1 ); - } - - return request; -} - -const TestPlatformAbstraction::ResourceRequestContainer& TestPlatformAbstraction::GetAllRequests() const -{ - return mResourceRequests; -} - -void TestPlatformAbstraction::SetAllResourceRequestsAsLoaded() -{ - for( ResourceRequestContainer::Iterator iter = mResourceRequests.Begin(), endIter = mResourceRequests.End(); - iter != endIter; ++iter ) - { - Integration::ResourceRequest* request = *iter; - Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD ); - Integration::ResourcePointer resource(bitmap); - bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); - SetResourceLoaded( request->GetId(), request->GetType()->id, resource ); - delete request; - } - mResourceRequests.Clear(); -} - -void TestPlatformAbstraction::SetAllResourceRequestsAsFailed( Integration::ResourceFailure failure ) -{ - for( ResourceRequestContainer::Iterator iter = mResourceRequests.Begin(), endIter = mResourceRequests.End(); - iter != endIter; ++iter ) - { - Integration::ResourceRequest* request = *iter; - SetResourceLoadFailed( (*iter)->GetId(), failure); - delete request; - } - mResourceRequests.Clear(); -} - -void TestPlatformAbstraction::DiscardRequest() -{ - for( ResourceRequestContainer::Iterator iter = mResourceRequests.Begin(), endIter = mResourceRequests.End(); - iter != endIter; ++iter ) - { - Integration::ResourceRequest* request = *iter; - delete request; - } - mResourceRequests.Clear(); -} - void TestPlatformAbstraction::SetClosestImageSize(const Vector2& size) { mClosestSize = size; diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h index 42e2d98..230ed02 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h @@ -40,8 +40,6 @@ class DALI_IMPORT_API TestPlatformAbstraction : public Dali::Integration::Platfo public: - typedef Vector< Integration::ResourceRequest* > ResourceRequestContainer; - /** * Constructor */ @@ -53,16 +51,6 @@ public: virtual ~TestPlatformAbstraction(); /** - * @copydoc PlatformAbstraction::Suspend() - */ - virtual void Suspend(); - - /** - * @copydoc PlatformAbstraction::Resume() - */ - virtual void Resume(); - - /** * @copydoc PlatformAbstraction::GetClosestImageSize() */ virtual ImageDimensions GetClosestImageSize( const std::string& filename, @@ -81,11 +69,6 @@ public: bool orientationCorrection ); /** - * @copydoc PlatformAbstraction::LoadResource() - */ - virtual void LoadResource(const Integration::ResourceRequest& request); - - /** * @copydoc PlatformAbstraction::LoadResourceSynchronously() */ virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath ); @@ -96,70 +79,24 @@ public: virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::ResourceType& resourceType, uint8_t * buffer, size_t size ); /** - * @copydoc PlatformAbstraction::CancelLoad() - */ - virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); - - /** - * @copydoc PlatformAbstraction::GetResources() - */ - virtual void GetResources(Integration::ResourceCache& cache); - - /** - * @copydoc PlatformAbstraction::IsLoading() - */ - virtual bool IsLoading(); - - /** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ - 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; - - /** * @copydoc PlatformAbstraction::LoadShaderBinaryFile() */ virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const; /** - * @copydoc PlatformAbstraction::SaveFile() + * @copydoc PlatformAbstraction::SaveShaderBinaryFile() */ - virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const; - - /** - * @copydoc PlatformAbstraction::SaveShaderBinaryFile() - */ virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; } - virtual void JoinLoaderThreads(); public: // TEST FUNCTIONS // Enumeration of Platform Abstraction methods typedef enum { - SuspendFunc, - ResumeFunc, - LoadResourceFunc, LoadResourceSynchronouslyFunc, - SaveFileFunc, - LoadFileFunc, LoadShaderBinaryFileFunc, - SaveShaderBinaryFileFunc, - CancelLoadFunc, - GetResourcesFunc, - IsLoadingFunc, - SetDpiFunc, - JoinLoaderThreadsFunc, + SaveShaderBinaryFileFunc } TestFuncEnum; /** Call this every test */ @@ -183,63 +120,11 @@ public: // TEST FUNCTIONS void SetIsLoadingResult(bool result); /** - * @brief Sets the value returned by GetDefaultFontSize - * @param[in] result The value to return - */ - void SetGetDefaultFontSizeResult(float result); - - /** * @brief Clears all resource queues */ void ClearReadyResources(); /** - * @brief Sets a particular resource request as loaded. - * @param[in] loadedId The ResourceID of the resource that has been loaded. - * @param[in] loadedType The type of resource that has been loaded. - * @param[in] loadedResource A pointer to the resource that has been loaded. - */ - void SetResourceLoaded(Integration::ResourceId loadedId, - Integration::ResourceTypeId loadedType, - Integration::ResourcePointer loadedResource); - - /** - * @brief Sets a particular resource request as load failure. - * @param[in] id The ID of the failed resource request. - * @param[in] failure The type of failure. - */ - void SetResourceLoadFailed(Integration::ResourceId id, - Integration::ResourceFailure failure); - - /** - * @brief Retrieves the latest resource request - * @return A pointer to the latest resource request. - */ - Integration::ResourceRequest* GetRequest(); - - /** - * @brief Retrieves a reference to a container of all the resource requests. - * @return A reference to a container of all the resource requests. - */ - const ResourceRequestContainer& GetAllRequests() const; - - /** - * @brief Sets all resource requests as loaded. - */ - void SetAllResourceRequestsAsLoaded(); - - /** - * @brief Sets all resource requests as loaded. - * @param[in] failure The failure type - */ - void SetAllResourceRequestsAsFailed( Integration::ResourceFailure failure ); - - /** - * @brief Discards all current resource requests. - */ - void DiscardRequest(); - - /** * @brief Sets the value returned by GetClosestImageSize. * @param[in] size The size that should be returned. */ @@ -277,19 +162,6 @@ private: private: - struct LoadedResource - { - Integration::ResourceId id; - Integration::ResourceTypeId type; - Integration::ResourcePointer resource; - }; - - struct FailedLoad - { - Integration::ResourceId id; - Integration::ResourceFailure failure; - }; - struct LoadFileResult { inline LoadFileResult() @@ -302,15 +174,8 @@ private: Dali::Vector< unsigned char> buffer; }; - typedef std::vector< LoadedResource > LoadedResourceContainer; - typedef std::vector< FailedLoad > FailedLoadContainer; - mutable TraceCallStack mTrace; bool mIsLoadingResult; - int mGetDefaultFontSizeResult; - LoadedResourceContainer mLoadedResourcesQueue; - FailedLoadContainer mFailedLoadQueue; - ResourceRequestContainer mResourceRequests; Vector2 mSize; Vector2 mClosestSize; diff --git a/automated-tests/src/dali-platform-abstraction/CMakeLists.txt b/automated-tests/src/dali-platform-abstraction/CMakeLists.txt index c7542c1..94b7bc3 100644 --- a/automated-tests/src/dali-platform-abstraction/CMakeLists.txt +++ b/automated-tests/src/dali-platform-abstraction/CMakeLists.txt @@ -7,13 +7,9 @@ SET(CAPI_LIB "dali-platform-abstraction") SET(TC_SOURCES utc-image-fitting-modes.cpp - utc-image-loading-cancel-all-loads.cpp - utc-image-loading-cancel-some-loads.cpp - utc-image-loading-load-completion.cpp ) LIST(APPEND TC_SOURCES - resource-collector.cpp ../dali-adaptor/dali-test-suite-utils/mesh-builder.cpp ../dali-adaptor/dali-test-suite-utils/dali-test-suite-utils.cpp ../dali-adaptor/dali-test-suite-utils/test-actor-utils.cpp diff --git a/automated-tests/src/dali-platform-abstraction/resource-collector.cpp b/automated-tests/src/dali-platform-abstraction/resource-collector.cpp deleted file mode 100644 index 799d4c6..0000000 --- a/automated-tests/src/dali-platform-abstraction/resource-collector.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "resource-collector.h" -#include "tizen-platform-abstraction.h" -#include -#include - -namespace Dali -{ -namespace Internal -{ -namespace Platform -{ -using namespace Dali::Integration; - -ResourceCollector::ResourceCollector() : - mGrandTotalCompletions(0), - mGrandTotalNotifications(0) -{ -} - -ResourceCollector::~ResourceCollector() {} - -void ResourceCollector::LoadResponse( Dali::Integration::ResourceId id, Dali::Integration::ResourceTypeId type, Dali::Integration::ResourcePointer resource, Dali::Integration::LoadStatus status ) -{ - ++mGrandTotalNotifications; - if( status == RESOURCE_COMPLETELY_LOADED ) - { - DALI_ASSERT_DEBUG( mCompletionCounts.find(id) == mCompletionCounts.end() && "A resource can only complete once." ); - mCompletionStatuses[id] = true; - ++mCompletionCounts[id]; - ++mSuccessCounts[id]; - mCompletionSequence.push_back( id ); - ++mGrandTotalCompletions; - } -} - -void ResourceCollector::LoadFailed( Dali::Integration::ResourceId id, Dali::Integration::ResourceFailure failure ) -{ - mCompletionStatuses[id] = false; - ++mFailureCounts[id]; - mCompletionSequence.push_back( id ); - ++mGrandTotalCompletions; - ++mGrandTotalNotifications; -} - -void PollForNotification( ResourceCollector& collector, Integration::PlatformAbstraction& abstraction, const unsigned maxPolls ) -{ - // Poll for at least one completed or partially completed load: - const unsigned outstandingNotifications = collector.mGrandTotalNotifications; - for( unsigned poll = 0; poll < maxPolls; ++poll ) - { - abstraction.GetResources( collector ); - if( collector.mGrandTotalNotifications > outstandingNotifications ) - { - break; - } - usleep( 3 ); //< Wait 3 microseconds each time around. - } -} - -} /* namespace Platform */ -} /* namespace Internal */ -} /* namespace Dali */ diff --git a/automated-tests/src/dali-platform-abstraction/resource-collector.h b/automated-tests/src/dali-platform-abstraction/resource-collector.h deleted file mode 100644 index 7a4b2dd..0000000 --- a/automated-tests/src/dali-platform-abstraction/resource-collector.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef __DALI_ADAPTOR_TCT_RESOURCE_COLLECTOR_H_ -#define __DALI_ADAPTOR_TCT_RESOURCE_COLLECTOR_H_ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#include -#include - -#include - -namespace Dali -{ - -namespace Integration -{ -class PlatformAbstraction; -} - -namespace Internal -{ -namespace Platform -{ - /** Stores true for success and false for a failure for each completed - * resource id.*/ - typedef std::map ResourceStatusMap; - /** Stores an integer counter for a resource ID, e.g., to count the number of - * times a load or a fail is reported.*/ - typedef std::map ResourceCounterMap; - /** Used to track the order in which a sequence of requests is completed.*/ - typedef std::vector ResourceSequence; - -/** - * @brief Used for platform testing to record the result of resource requests - * initiated by tests. - */ -class ResourceCollector : public Integration::ResourceCache -{ -public: - - ResourceCollector(); - virtual ~ResourceCollector(); - - virtual void LoadResponse(Dali::Integration::ResourceId id, Dali::Integration::ResourceTypeId type, Dali::Integration::ResourcePointer resource, Dali::Integration::LoadStatus status); - - virtual void LoadFailed(Dali::Integration::ResourceId id, Dali::Integration::ResourceFailure failure); - - // Data: - /** Record of the status of each completed resource. */ - ResourceStatusMap mCompletionStatuses; - /** Record of how many times each resource completed (every value should be 1, - * else we are broken). */ - ResourceCounterMap mCompletionCounts; - /** Record of how many times each resource succeeded (every value should be 0 or - * 1, else we are broken). */ - ResourceCounterMap mSuccessCounts; - /** Record of how many times each resource failed (every value should be 0 or 1, - * else we are broken). - * Only resource IDs that correspond to deliberately unloadable resources - * should have counts other than 0. */ - ResourceCounterMap mFailureCounts; - /** Remember the order of request completions so request priority can be tested. */ - ResourceSequence mCompletionSequence; - /** Count of all successes and failures.*/ - unsigned mGrandTotalCompletions; - /** Count of all successes, failures, loading notifications and partially loaded notifications.*/ - unsigned mGrandTotalNotifications; - -}; - -/** - * Helper to poll the abstraction for notifications assuming loads have been - * issued to it previously and are in-flight. - */ -void PollForNotification( ResourceCollector& collector, Integration::PlatformAbstraction& abstraction, const unsigned maxPolls = 100 ); - -} /* namespace Platform */ -} /* namespace Internal */ -} /* namespace Dali */ - -#endif /* __DALI_ADAPTOR_TCT_RESOURCE_COLLECTOR_H_ */ diff --git a/automated-tests/src/dali-platform-abstraction/utc-image-fitting-modes.cpp b/automated-tests/src/dali-platform-abstraction/utc-image-fitting-modes.cpp index 9da0cbe..477c1d4 100644 --- a/automated-tests/src/dali-platform-abstraction/utc-image-fitting-modes.cpp +++ b/automated-tests/src/dali-platform-abstraction/utc-image-fitting-modes.cpp @@ -19,6 +19,8 @@ #include "platform-abstractions/portable/image-operations.h" +using Dali::Internal::Platform::ApplyAttributesToBitmap; + #define ANSI_BLACK "\x1B[0m" #define ANSI_RED "\x1B[31m" #define ANSI_GREEN "\x1B[32m" diff --git a/automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-all-loads.cpp b/automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-all-loads.cpp deleted file mode 100644 index aa4d8b5..0000000 --- a/automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-all-loads.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "utc-image-loading-common.h" - -void utc_image_loading_cancel_all_loads_startup(void) -{ - utc_dali_loading_startup(); -} - -void utc_image_loading_cancel_all_loads_cleanup(void) -{ - utc_dali_loading_cleanup(); -} - -/** - * @brief Test case for load cancellation. - * - * Load lots of images in batches, cancelling all in a batch after a small delay to - * allow the first of a batch to be launched before cancellation starts. - * Assert that all loads issued are either completed or cancelled. - * - * @note Many loads will succeed despite our cancellations due to the coarse - * granularity of the waits we introduce after loading each batch. That is - * expected. - */ -int UtcDaliCancelAllLoads(void) -{ - tet_printf( "Running load cancel-all test.\n" ); - - DALI_ASSERT_ALWAYS( gAbstraction != 0 ); - - // Start a bunch of loads that should work: - - Dali::Integration::LoadResourcePriority priority = LoadPriorityNormal; - unsigned loadsLaunched = 0; - Dali::Internal::Platform::ResourceCollector resourceSink; - - for( unsigned loadGroup = 0; loadGroup < NUM_CANCELLED_LOAD_GROUPS_TO_ISSUE; ++loadGroup ) - { - // Issue load requests for a batch of images: - for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage ) - { - const ImageParameters & loadParams = gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ]; - const BitmapResourceType bitmapResourceType( loadParams.first, loadParams.second.first, loadParams.second.second.first, loadParams.second.second.second ); - const ResourceId resourceId = loadGroup * NUM_VALID_IMAGES + validImage + 1; - gAbstraction->LoadResource( ResourceRequest( resourceId, bitmapResourceType, VALID_IMAGES[validImage], priority ) ); - loadsLaunched += 1; - } - - // Poll for at least one completed load so we have a good chance of catching an - // in-flight load as we run through the cancellations further below: - PollForNotification( resourceSink, *gAbstraction, 100 ); - - // Cancel all the launched loads in the batch from oldest to newest: - for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage ) - { - const ResourceId resourceId = loadGroup * NUM_VALID_IMAGES + validImage + 1; - gAbstraction->CancelLoad( resourceId, ResourceBitmap ); - } - } - - // Drain the completed loads: - - unsigned lastNotifications = -1; - for( unsigned i = 0; resourceSink.mGrandTotalCompletions < loadsLaunched && resourceSink.mGrandTotalNotifications != lastNotifications; ) - { - lastNotifications = resourceSink.mGrandTotalNotifications; - gAbstraction->GetResources( resourceSink ); - - ++i; - if( i < MAX_NUM_RESOURCE_TRIES && resourceSink.mGrandTotalCompletions < loadsLaunched ) - { - usleep( 1000 * 10 ); - } - else - { - break; - } - } - - // Check the loads completed as expected: - - tet_printf( "Issued Loads: %u, Completed Loads: %u, Successful Loads: %u, Failed Loads: %u \n", loadsLaunched, resourceSink.mGrandTotalCompletions, unsigned(resourceSink.mSuccessCounts.size()), unsigned(resourceSink.mFailureCounts.size()) ); - DALI_TEST_CHECK( loadsLaunched > resourceSink.mGrandTotalCompletions ); - DALI_TEST_CHECK( loadsLaunched > resourceSink.mSuccessCounts.size() ); - DALI_TEST_CHECK( 0 == resourceSink.mFailureCounts.size() ); - - // Check that each success was reported exactly once: - for( ResourceCounterMap::const_iterator it = resourceSink.mSuccessCounts.begin(), end = resourceSink.mSuccessCounts.end(); it != end; ++it ) - { - DALI_TEST_CHECK( it->second == 1u ); - } - - END_TEST; -} diff --git a/automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-some-loads.cpp b/automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-some-loads.cpp deleted file mode 100644 index 3d6ba94..0000000 --- a/automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-some-loads.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include "utc-image-loading-common.h" - -void utc_image_loading_cancel_some_loads_startup(void) -{ - utc_dali_loading_startup(); -} - -void utc_image_loading_cancel_some_loads_cleanup(void) -{ - utc_dali_loading_cleanup(); -} - -/** - * @brief Test case for load cancellation. - * - * Load lots, cancel a subset and be sure the wrong loads are never cancelled - * and that all loads issued are either completed or cancelled. - */ -int UtcDaliCancelSomeLoads(void) -{ - tet_printf( "Running load cancel load subset test.\n" ); - - DALI_ASSERT_ALWAYS( gAbstraction != 0 ); - - // Start a bunch of loads that should work: - - Dali::Integration::LoadResourcePriority priority = LoadPriorityNormal; - unsigned loadsLaunched = 0; - - std::set cancelledLoadSet; - Dali::Internal::Platform::ResourceCollector resourceSink; - - for( unsigned loadGroup = 0; loadGroup < NUM_LOAD_GROUPS_TO_ISSUE; ++loadGroup ) - { - const unsigned preIterationCompletions = resourceSink.mGrandTotalCompletions; - - // Issue load requests for a batch of images: - for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage ) - { - const ImageParameters & loadParams = gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ]; - const BitmapResourceType bitmapResourceType( loadParams.first, loadParams.second.first, loadParams.second.second.first, loadParams.second.second.second ); - const ResourceId resourceId = loadGroup * NUM_VALID_IMAGES + validImage + 1; - gAbstraction->LoadResource( ResourceRequest( resourceId, bitmapResourceType, VALID_IMAGES[validImage], priority ) ); - loadsLaunched += 1; - } - - // Let the first image in the batch start to load so we can try to cancel it in-flight: - usleep( 1 * 1000 ); //< 1 ms is enough to let an image start to load. - ///@Note: The log should show cancellations of many in-flight loads in desktop builds with info-level logging enabled (e.g., "INFO: DALI: : CheckForCancellation: Cancelled in-flight resource (21)."). If it doesn't, the above delay may need to be adjusted. - - // Cancel just two loads (hopefully one in-flight and one queued): - - // Cancel first load, hopefully while it is in-flight: - const ResourceId cancelledInFlight = loadGroup * NUM_VALID_IMAGES + 1; - gAbstraction->CancelLoad( cancelledInFlight, ResourceBitmap ); - cancelledLoadSet.insert( cancelledInFlight ); - - // Cancel second load, that is still queued: - const ResourceId cancelledFromQueue = loadGroup * NUM_VALID_IMAGES + NUM_VALID_IMAGES; - gAbstraction->CancelLoad( cancelledFromQueue, ResourceBitmap ); - cancelledLoadSet.insert( cancelledFromQueue ); - - // Drain a group worth of images so the cancellations hit in-flight loads on the next iteration: - for( unsigned i = 0; i < NUM_VALID_IMAGES * 1000 * 1000 * 10 / (5 * 1000) && resourceSink.mGrandTotalCompletions < preIterationCompletions + NUM_VALID_IMAGES - 2; ++i ) - { - gAbstraction->GetResources( resourceSink ); - usleep( 5 * 1000 ); - } - } - - // Drain any spare completed loads until no new loads complete on an iteration: - unsigned lastNotifications = -1; - for( unsigned i = 0; i < MAX_NUM_RESOURCE_TRIES && resourceSink.mGrandTotalCompletions < loadsLaunched && resourceSink.mGrandTotalNotifications != lastNotifications; ++i ) - { - lastNotifications = resourceSink.mGrandTotalNotifications; - gAbstraction->GetResources( resourceSink ); - usleep( 70 * 1000 ); //< 70 ms should allow at least one medium image to load. You might to increase this to run on a slow device. - gAbstraction->GetResources( resourceSink ); - usleep( 70 * 1000 ); - gAbstraction->GetResources( resourceSink ); - usleep( 70 * 1000 ); - gAbstraction->GetResources( resourceSink ); - } - - // Check the loads completed as expected: - - tet_printf( "Issued Loads: %u, Completed Loads: %u, Successful Loads: %u, Failed Loads: %u \n", loadsLaunched, resourceSink.mGrandTotalCompletions, unsigned(resourceSink.mSuccessCounts.size()), unsigned(resourceSink.mFailureCounts.size()) ); - DALI_TEST_CHECK( loadsLaunched >= resourceSink.mGrandTotalCompletions ); - DALI_TEST_CHECK( loadsLaunched >= resourceSink.mSuccessCounts.size() ); - DALI_TEST_CHECK( 0 == resourceSink.mFailureCounts.size() ); - - // Check that if an image was not loaded, it is one of the ones that was cancelled: - // This is the main point of this test case. - std::vector missingLoads; - for( unsigned resourceId = 1; resourceId <= NUM_LOAD_GROUPS_TO_ISSUE * NUM_VALID_IMAGES; ++resourceId ) - { - // Was the load (not) completed? - if( resourceSink.mCompletionStatuses.find( resourceId ) == resourceSink.mCompletionStatuses.end() ) - { - // Was the load (not) cancelled? - if( cancelledLoadSet.find( resourceId ) == cancelledLoadSet.end() ) - { - // Whoa, the load was not completed and not cancelled either... so where did it go then? - missingLoads.push_back( resourceId ); - tet_printf( "Missing load. ResourceId %u was not completed but was also not cancelled.\n", resourceId ); - ///@note If this fires, you are probably not waiting long enough in the draining loop above (usleep( 70 * 1000 );). - } - } - } - DALI_TEST_CHECK( missingLoads.size() == 0U ); - - // Check that each success was reported exactly once: - for(ResourceCounterMap::const_iterator it = resourceSink.mSuccessCounts.begin(), end = resourceSink.mSuccessCounts.end(); it != end; ++it ) - { - DALI_TEST_CHECK( it->second == 1u ); - } - - END_TEST; -} diff --git a/automated-tests/src/dali-platform-abstraction/utc-image-loading-common.h b/automated-tests/src/dali-platform-abstraction/utc-image-loading-common.h index cc6f713..3cb9cd0 100644 --- a/automated-tests/src/dali-platform-abstraction/utc-image-loading-common.h +++ b/automated-tests/src/dali-platform-abstraction/utc-image-loading-common.h @@ -24,11 +24,9 @@ #include #include #include "tizen-platform-abstraction.h" -#include "resource-collector.h" using namespace Dali; using namespace Dali::Integration; -using namespace Dali::Internal::Platform; namespace { diff --git a/automated-tests/src/dali-platform-abstraction/utc-image-loading-load-completion.cpp b/automated-tests/src/dali-platform-abstraction/utc-image-loading-load-completion.cpp deleted file mode 100644 index dc5ecf0..0000000 --- a/automated-tests/src/dali-platform-abstraction/utc-image-loading-load-completion.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "utc-image-loading-common.h" - -void utc_image_loading_load_completion_startup(void) -{ - utc_dali_loading_startup(); -} - -void utc_image_loading_load_completion_cleanup(void) -{ - utc_dali_loading_cleanup(); -} - -// Positive test case for loading. Load lots and be sure it has succeeded. -int UtcDaliLoadCompletion(void) -{ - tet_printf("Running load completion test \n"); - - DALI_ASSERT_ALWAYS( gAbstraction != 0 ); - - // Start a bunch of loads that should work: - - Dali::Integration::BitmapResourceType bitmapResourceType; - Dali::Integration::LoadResourcePriority priority = Dali::Integration::LoadPriorityNormal; - unsigned loadsLaunched = 0; - - for( unsigned loadGroup = 0; loadGroup < NUM_LOAD_GROUPS_TO_ISSUE; ++loadGroup ) - { - for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage ) - { - Dali::Integration::ResourceRequest request( loadGroup * NUM_VALID_IMAGES + validImage + 1, bitmapResourceType, VALID_IMAGES[validImage], priority ); - gAbstraction->LoadResource( request ); - } - loadsLaunched += NUM_VALID_IMAGES; - } - - // Drain the completed loads: - Dali::Internal::Platform::ResourceCollector resourceSink; - gAbstraction->GetResources( resourceSink ); - usleep( 500 * 1000 ); - gAbstraction->GetResources( resourceSink ); - - const double startDrainTime = GetTimeMilliseconds( *gAbstraction ); - while( resourceSink.mGrandTotalCompletions < loadsLaunched && GetTimeMilliseconds( *gAbstraction ) - startDrainTime < MAX_MILLIS_TO_WAIT_FOR_KNOWN_LOADS ) - { - usleep( 100 * 40 ); - gAbstraction->GetResources( resourceSink ); - } - - // Check the loads completed as expected: - - tet_printf( "Issued Loads: %u, Completed Loads: %u, Successful Loads: %u, Failed Loads: %u \n", loadsLaunched, resourceSink.mGrandTotalCompletions, unsigned(resourceSink.mSuccessCounts.size()), unsigned(resourceSink.mFailureCounts.size()) ); - DALI_TEST_CHECK( loadsLaunched == resourceSink.mGrandTotalCompletions ); - DALI_TEST_CHECK( loadsLaunched == resourceSink.mSuccessCounts.size() ); - DALI_TEST_CHECK( 0 == resourceSink.mFailureCounts.size() ); - - // Check that each success was reported exactly once: - for( ResourceCounterMap::const_iterator it = resourceSink.mSuccessCounts.begin(), end = resourceSink.mSuccessCounts.end(); it != end; ++it ) - { - DALI_TEST_CHECK( it->second == 1u ); - } - - END_TEST; -} diff --git a/platform-abstractions/emscripten/emscripten-callbacks.h b/platform-abstractions/emscripten/emscripten-callbacks.h index 87bb428..43a0457 100644 --- a/platform-abstractions/emscripten/emscripten-callbacks.h +++ b/platform-abstractions/emscripten/emscripten-callbacks.h @@ -20,7 +20,6 @@ // EXTERNAL INCLUDES #include -#include #include // INTERNAL INCLUDES diff --git a/platform-abstractions/emscripten/emscripten-platform-abstraction.cpp b/platform-abstractions/emscripten/emscripten-platform-abstraction.cpp index 00cec12..d744308 100644 --- a/platform-abstractions/emscripten/emscripten-platform-abstraction.cpp +++ b/platform-abstractions/emscripten/emscripten-platform-abstraction.cpp @@ -192,16 +192,6 @@ void EmscriptenPlatformAbstraction::GetTimeMicroseconds(unsigned int &seconds, u microSeconds = (static_cast(current) - seconds*1000.0) * 1000; } -void EmscriptenPlatformAbstraction::Suspend() -{ - DALI_ASSERT_ALWAYS("!Not Implemented"); -} - -void EmscriptenPlatformAbstraction::Resume() -{ - DALI_ASSERT_ALWAYS("!Not Implemented"); -} - ImageDimensions EmscriptenPlatformAbstraction::GetClosestImageSize( const std::string& filename, ImageDimensions size, FittingMode::Type fittingMode, @@ -240,148 +230,16 @@ Integration::ResourcePointer EmscriptenPlatformAbstraction::LoadResourceSynchron ret = bitmapPtr; } break; - case Integration::ResourceNativeImage: - { - } - break; - case Integration::ResourceTargetImage: - { - } - break; } // switch(resourceType->id) return ret; } -void EmscriptenPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request) -{ - std::string path = request.GetPath(); - - Integration::ResourceType *type = request.GetType(); - Integration::ResourceId resourceId = request.GetId(); - Integration::ResourcePointer resourcePtr = request.GetResource(); - - if( type ) - { - switch(type->id) - { - case Integration::ResourceBitmap: - { - Integration::BitmapPtr bitmapPtr = NULL; - - if( NULL == request.GetResource().Get() ) - { - const Integration::BitmapResourceType& bitmapResource( static_cast(*type) ); - - Integration::BitmapPtr bitmapPtr = Dali::Internal::Emscripten::GetImage( bitmapResource.size, - bitmapResource.scalingMode, - bitmapResource.samplingMode, - bitmapResource.orientationCorrection, - path ); - - - - } - else - { - // 2) load it (usually on worker thread) - // DALI_LOG_TRACE_METHOD( mLogFilter ); - // DALI_LOG_INFO(mLogFilter, Debug::Verbose, "%s(%s)\n", __FUNCTION__, request.GetPath().c_str()); - - bitmapPtr = LoadResourceEncodedImage( reinterpret_cast*>( request.GetResource().Get() ) ); - } - - if( bitmapPtr ) - { - mResourceQueue.push( ResourceIdBitmapPair( resourceId, bitmapPtr ) ); - } - - } - break; - case Integration::ResourceNativeImage: - { - printf("EmscriptenPlatformAbstraction::LoadResource ResourceNativeImage\n"); - } - break; - case Integration::ResourceTargetImage: - { - printf("EmscriptenPlatformAbstraction::LoadResource ResourceTargetImage\n"); - } - break; - } // switch(id) - - } // if(type) - -} - -void EmscriptenPlatformAbstraction::SaveResource(const Integration::ResourceRequest& request) -{ - DALI_ASSERT_ALWAYS("!Not Implemented"); -} - Integration::BitmapPtr EmscriptenPlatformAbstraction::DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t bufferSize ) { return Integration::BitmapPtr(); } -void EmscriptenPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId) -{ - DALI_ASSERT_ALWAYS("!Not Implemented"); -} - -void EmscriptenPlatformAbstraction::GetResources(Integration::ResourceCache& cache) -{ - while( !mResourceQueue.empty() ) - { - Integration::ResourceId resourceId = mResourceQueue.front().first; - Integration::BitmapPtr bitmapPtr = mResourceQueue.front().second; - - cache.LoadResponse( resourceId, - Integration::ResourceBitmap, - bitmapPtr, - Integration::RESOURCE_COMPLETELY_LOADED ); - mResourceQueue.pop(); - } -} - -bool EmscriptenPlatformAbstraction::IsLoading() -{ - EM_LOG("EmscriptenPlatformAbstraction::IsLoading"); - return false; -} - -const std::string& EmscriptenPlatformAbstraction::GetDefaultFontFamily() const -{ - EM_LOG("EmscriptenPlatformAbstraction::GetDefaultFontFamily"); - DALI_ASSERT_ALWAYS("!Not Implemented"); - return mGetDefaultFontFamilyResult; -} - -int EmscriptenPlatformAbstraction::GetDefaultFontSize() const -{ - EM_LOG("EmscriptenPlatformAbstraction::GetDefaultFontSize"); - return 12; -} - -void EmscriptenPlatformAbstraction::SetDpi (unsigned int /* dpiHorizontal*/, unsigned int /* dpiVertical */) -{ - -} - - -bool EmscriptenPlatformAbstraction::LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const -{ - EM_LOG("EmscriptenPlatformAbstraction::LoadFile"); - return false; -} - -bool EmscriptenPlatformAbstraction::SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const -{ - EM_LOG("EmscriptenPlatformAbstraction::SaveFile"); - - DALI_ASSERT_ALWAYS("!Unimplemented"); - return false; -} bool EmscriptenPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const { @@ -389,19 +247,6 @@ bool EmscriptenPlatformAbstraction::LoadShaderBinaryFile( const std::string& fil return false; } -bool EmscriptenPlatformAbstraction::SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const -{ - EM_LOG("EmscriptenPlatformAbstraction::SaveShaderBinaryFile"); - - DALI_ASSERT_ALWAYS("!Unimplemented"); - return false; -} - -void EmscriptenPlatformAbstraction::JoinLoaderThreads() -{ - DALI_ASSERT_ALWAYS("!Unimplemented"); -} - void EmscriptenPlatformAbstraction::UpdateDefaultsFromDevice() { DALI_ASSERT_ALWAYS("!Unimplemented"); diff --git a/platform-abstractions/emscripten/emscripten-platform-abstraction.h b/platform-abstractions/emscripten/emscripten-platform-abstraction.h index 2d67e47..97e9a51 100644 --- a/platform-abstractions/emscripten/emscripten-platform-abstraction.h +++ b/platform-abstractions/emscripten/emscripten-platform-abstraction.h @@ -31,6 +31,12 @@ namespace Dali { +namespace Integration +{ + +typedef IntrusivePtr ResourcePointer; +} // namespace Integration + /** * An Dali Platform abstraction using libSDL for Emscripten. * @@ -42,26 +48,6 @@ class DALI_IMPORT_API EmscriptenPlatformAbstraction : public Dali::Integration:: public: - struct Resources - { - bool loaded; - Integration::ResourceId loadedId; - Integration::ResourceTypeId loadedType; - Integration::ResourcePointer loadedResource; - - bool loadFailed; - Integration::ResourceId loadFailedId; - Integration::ResourceFailure loadFailure; - - bool saved; - Integration::ResourceId savedId; - Integration::ResourceTypeId savedType; - - bool saveFailed; - Integration::ResourceId saveFailedId; - Integration::ResourceFailure saveFailure; - }; - struct LoadFileResult { LoadFileResult() @@ -94,16 +80,6 @@ public: void IncrementGetTimeResult(size_t milliseconds); /** - * @copydoc PlatformAbstraction::Suspend() - */ - virtual void Suspend(); - - /** - * @copydoc PlatformAbstraction::Resume() - */ - virtual void Resume(); - - /** * @copydoc PlatformAbstraction::GetClosestImageSize() */ virtual ImageDimensions GetClosestImageSize( const std::string& filename, @@ -121,70 +97,16 @@ public: bool orientationCorrection ); /** - * @copydoc PlatformAbstraction::LoadResource() + * @copydoc PlatformAbstraction::LoadResourceSynchronously() */ - virtual void LoadResource(const Integration::ResourceRequest& request); - virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath ); /** - * @copydoc PlatformAbstraction::SaveResource() - */ - virtual void SaveResource(const Integration::ResourceRequest& request); - - /** * @copydoc PlatformAbstraction::DecodeBuffer() */ virtual Integration::BitmapPtr DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t bufferSize ); /** - * @copydoc PlatformAbstraction::CancelLoad() - */ - virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); - - /** - * @copydoc PlatformAbstraction::GetResources() - */ - virtual void GetResources(Integration::ResourceCache& cache); - - /** - * @copydoc PlatformAbstraction::IsLoading() - */ - virtual bool IsLoading(); - - /** - * @copydoc PlatformAbstraction::GetDefaultFontFamily() - */ - virtual const std::string& GetDefaultFontFamily() const; - - /** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ - virtual int GetDefaultFontSize() const; - - /** - * Sets horizontal and vertical pixels per inch value that is used by the display - * @param[in] dpiHorizontal horizontal dpi value - * @param[in] dpiVertical vertical dpi value - */ - 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; - - /** - * @copydoc PlatformAbstraction::SaveFile() - */ - virtual bool SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const; - - /** - * @copydoc PlatformAbstraction::JoinLoaderThreads() - */ - virtual void JoinLoaderThreads(); - - /** * @copydoc PlatformAbstraction::LoadShaderBinaryFile() */ virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const; @@ -201,7 +123,6 @@ public: private: std::string mGetDefaultFontFamilyResult; - Resources mResources; Vector2 mSize; LoadFileResult mLoadFileResult; diff --git a/platform-abstractions/tizen/file.list b/platform-abstractions/tizen/file.list index c76bcfd..5bb1e1a 100755 --- a/platform-abstractions/tizen/file.list +++ b/platform-abstractions/tizen/file.list @@ -8,9 +8,6 @@ tizen_platform_abstraction_src_files = \ $(tizen_platform_abstraction_src_dir)/resource-loader/resource-requester-base.cpp \ $(tizen_platform_abstraction_src_dir)/resource-loader/resource-bitmap-requester.cpp \ \ - $(tizen_platform_abstraction_src_dir)/resource-loader/resource-thread-base.cpp \ - $(tizen_platform_abstraction_src_dir)/resource-loader/resource-thread-image.cpp \ - \ $(tizen_platform_abstraction_src_dir)/resource-loader/network/file-download.cpp \ $(tizen_platform_abstraction_src_dir)/resource-loader/network/http-utils.cpp \ \ diff --git a/platform-abstractions/tizen/image-loaders/image-loader.h b/platform-abstractions/tizen/image-loaders/image-loader.h index 15e3318..02317b5 100644 --- a/platform-abstractions/tizen/image-loaders/image-loader.h +++ b/platform-abstractions/tizen/image-loaders/image-loader.h @@ -19,7 +19,6 @@ // EXTERNAL INCLUDES #include -#include #include #include @@ -28,6 +27,11 @@ namespace Dali { +namespace Integration +{ +typedef IntrusivePtr ResourcePointer; +} // Integration + namespace TizenPlatform { namespace ImageLoader diff --git a/platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.h b/platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.h index e8ebb96..cc6f774 100644 --- a/platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.h +++ b/platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.h @@ -22,7 +22,6 @@ #if defined(DEBUG_ENABLED) #include -#include namespace Dali diff --git a/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.cpp b/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.cpp index 67da901..ab3e320 100644 --- a/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.cpp +++ b/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.cpp @@ -19,7 +19,6 @@ #include "resource-bitmap-requester.h" // EXTERNAL INCLUDES -#include // INTERNAL INCLUDES #include "network/file-download.h" @@ -41,113 +40,15 @@ enum ResourceScheme }// unnamed namespace ResourceBitmapRequester::ResourceBitmapRequester( ResourceLoader& resourceLoader ) -: ResourceRequesterBase( resourceLoader ), - mThreadImageLocal( NULL ), - mThreadImageRemote( NULL ) +: ResourceRequesterBase( resourceLoader ) { } ResourceBitmapRequester::~ResourceBitmapRequester() { - delete mThreadImageLocal; - delete mThreadImageRemote; } -void ResourceBitmapRequester::Pause() -{ - if( mThreadImageLocal ) - { - mThreadImageLocal->Pause(); - } - if( mThreadImageRemote ) - { - mThreadImageRemote->Pause(); - } -} - -void ResourceBitmapRequester::Resume() -{ - if( mThreadImageLocal ) - { - mThreadImageLocal->Resume(); - } - if( mThreadImageRemote ) - { - mThreadImageRemote->Resume(); - } -} - -void ResourceBitmapRequester::LoadResource( Integration::ResourceRequest& request ) -{ - DALI_ASSERT_DEBUG( (0 != dynamic_cast(request.GetType())) && "Only requsts for bitmap resources can ever be routed to ResourceBitmapRequester.\n"); - BitmapResourceType* resType = static_cast(request.GetType()); - if( !resType ) - { - return; - } - - // Work out what thread to decode / load the image on: - ResourceScheme scheme( FILE_SYSTEM_RESOURCE ); - - // Work out if the resource is in memory, a file, or in a remote server: - ResourceThreadBase::RequestType requestType; - // if resource exists already, then it just needs decoding - if( request.GetResource().Get() ) - { - requestType = ResourceThreadBase::RequestDecode; - } - else - { - const std::string& resourcePath = request.GetPath(); - if( Network::IsHttpUrl( resourcePath) ) - { - requestType = ResourceThreadBase::RequestDownload; - scheme = NETWORK_RESOURCE; - } - else - { - requestType = ResourceThreadBase::RequestLoad; - } - } - - // Dispatch the job to the right thread - // lazily create the thread - if( scheme == FILE_SYSTEM_RESOURCE ) - { - if( !mThreadImageLocal ) - { - mThreadImageLocal = new ResourceThreadImage( mResourceLoader ); - } - mThreadImageLocal->AddRequest( request, requestType ); - } - else - { - if( !mThreadImageRemote ) - { - mThreadImageRemote = new ResourceThreadImage( mResourceLoader ); - } - mThreadImageRemote->AddRequest( request, requestType ); - } -} - -Integration::LoadStatus ResourceBitmapRequester::LoadFurtherResources( Integration::ResourceRequest& request, LoadedResource partialResource ) -{ - // Nothing to do - return RESOURCE_COMPLETELY_LOADED; -} - -void ResourceBitmapRequester::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId) -{ - if( mThreadImageLocal ) - { - mThreadImageLocal->CancelRequest(id); - } - if( mThreadImageRemote ) - { - mThreadImageRemote->CancelRequest(id); - } -} } // TizenPlatform } // Dali diff --git a/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.h b/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.h index 7f59e6b..71f87ed 100644 --- a/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.h +++ b/platform-abstractions/tizen/resource-loader/resource-bitmap-requester.h @@ -19,7 +19,6 @@ */ #include "resource-requester-base.h" -#include "resource-thread-image.h" namespace Dali { @@ -43,34 +42,7 @@ public: */ virtual ~ResourceBitmapRequester(); - /** - * @copydoc ResourceRequester::Pause() - */ - virtual void Pause(); - - /** - * @copydoc ResourceRequester::Resume() - */ - virtual void Resume(); - - /** - * @copydoc ResourceRequester::LoadResource() - */ - virtual void LoadResource( Integration::ResourceRequest& request ); - - /** - * @copydoc ResourceRequester::LoadFurtherResources() - */ - virtual Integration::LoadStatus LoadFurtherResources( Integration::ResourceRequest& request, LoadedResource partialResource ); - - /** - * @copydoc ResourceRequester::CancelLoad() - */ - virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); - private: - ResourceThreadImage* mThreadImageLocal; ///< Image loader thread object to load images in local machine - ResourceThreadImage* mThreadImageRemote; ///< Image loader thread object to download images in remote http server }; } // TizenPlatform diff --git a/platform-abstractions/tizen/resource-loader/resource-loader.cpp b/platform-abstractions/tizen/resource-loader/resource-loader.cpp index 967d2d9..c9ad3cc 100755 --- a/platform-abstractions/tizen/resource-loader/resource-loader.cpp +++ b/platform-abstractions/tizen/resource-loader/resource-loader.cpp @@ -29,7 +29,6 @@ // INTERNAL HEADERS #include #include -#include #include #include #include @@ -47,10 +46,6 @@ namespace TizenPlatform struct ResourceLoader::ResourceLoaderImpl { - typedef std::pair RequestStorePair; - typedef std::map RequestStore; - typedef RequestStore::iterator RequestStoreIter; - typedef std::queue LoadedQueue; typedef std::queue FailedQueue; @@ -63,7 +58,6 @@ struct ResourceLoader::ResourceLoaderImpl FailedQueue mFailedLoads; ///< Failed load request notifications are stored here until fetched by core RequestHandlers mRequestHandlers; - RequestStore mStoredRequests; ///< Used to store load requests until loading is completed ResourceLoaderImpl( ResourceLoader* loader ) { @@ -80,32 +74,6 @@ struct ResourceLoader::ResourceLoaderImpl } } - void Pause() - { - // Pause all the request handlers: - for( RequestHandlersIter it = mRequestHandlers.begin(), end = mRequestHandlers.end(); it != end; ++it ) - { - ResourceRequesterBase * const requester = it->second; - if( requester ) - { - requester->Pause(); - } - } - } - - void Resume() - { - // Wake up all the request handlers: - for( RequestHandlersIter it = mRequestHandlers.begin(), end = mRequestHandlers.end(); it != end; ++it ) - { - ResourceRequesterBase * const requester = it->second; - if( requester ) - { - requester->Resume(); - } - } - } - ResourceRequesterBase* GetRequester(ResourceTypeId typeId) { ResourceRequesterBase* requestHandler = NULL; @@ -118,87 +86,6 @@ struct ResourceLoader::ResourceLoaderImpl return requestHandler; } - void LoadResource(const ResourceRequest& request) - { - // Store resource request for partial loaders. Will get cleaned up after load complete has finished - StoreRequest(request); - - ResourceRequesterBase* requester = GetRequester(request.GetType()->id); - if( requester ) - { - ResourceRequest* storedRequest = GetRequest(request.GetId()); - if( storedRequest != NULL ) - { - requester->LoadResource(*storedRequest); // Pass in stored request - } - } - 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__ ".\n" ); - } - } - - void CancelLoad(ResourceId id, ResourceTypeId typeId) - { - ResourceRequesterBase* requester = GetRequester(typeId); - if( requester ) - { - requester->CancelLoad( id, typeId ); - } - ClearRequest( id ); - } - - LoadStatus LoadFurtherResources( LoadedResource partialResource ) - { - LoadStatus loadStatus = RESOURCE_LOADING; - RequestStoreIter iter = mStoredRequests.find(partialResource.id); - - if( mStoredRequests.end() != iter ) // else cancelled. Ignore response - { - ResourceRequest& request = iter->second; - ResourceRequesterBase* requester = GetRequester(request.GetType()->id); - if( requester ) - { - loadStatus = requester->LoadFurtherResources( request, partialResource ); - } - - DALI_LOG_INFO(gLoaderFilter, Debug::General, "ResourceLoader::LoadFurtherResources( ID:%u complete: %s)\n", request.GetId(), loadStatus==RESOURCE_LOADING?"Loading":loadStatus==RESOURCE_PARTIALLY_LOADED?"PARTIAL":"COMPLETE" ); - } - - if( loadStatus == RESOURCE_COMPLETELY_LOADED ) - { - ClearRequest( partialResource.id ); - } - - return loadStatus; - } - - void GetResources(ResourceCache& cache) - { - // Fill the resource cache - - Mutex::ScopedLock lock( mQueueMutex ); - - // iterate through the successfully loaded resources - while (!mLoadedQueue.empty()) - { - LoadedResource loaded( mLoadedQueue.front() ); - mLoadedQueue.pop(); - ClearRequest( loaded.id ); - cache.LoadResponse( loaded.id, loaded.type, loaded.resource, RESOURCE_COMPLETELY_LOADED ); - } - - // iterate through the resources which failed to load - while (!mFailedLoads.empty()) - { - FailedResource failed(mFailedLoads.front()); - mFailedLoads.pop(); - ClearRequest(failed.id); - cache.LoadFailed(failed.id, failed.failureType); - } - } - void AddLoadedResource(LoadedResource& resource) { // Lock the LoadedQueue to store the loaded resource @@ -215,33 +102,6 @@ struct ResourceLoader::ResourceLoaderImpl mFailedLoads.push(resource); } - void StoreRequest( const ResourceRequest& request ) - { - DALI_LOG_INFO(gLoaderFilter, Debug::Verbose, "ResourceLoader: StoreRequest(id:%u)\n", request.GetId()); - mStoredRequests.insert( RequestStorePair( request.GetId(), request ) ); // copy request as value type - } - - ResourceRequest* GetRequest( ResourceId id ) - { - ResourceRequest* found(NULL); - DALI_LOG_INFO(gLoaderFilter, Debug::Verbose, "ResourceLoader: GetRequest(id:%u)\n", id); - RequestStoreIter iter = mStoredRequests.find( id ); - if( mStoredRequests.end() != iter ) - { - found = &iter->second; - } - return found; - } - - void ClearRequest( ResourceId resourceId ) - { - DALI_LOG_INFO(gLoaderFilter, Debug::Verbose, "ResourceLoader: ClearRequest(id:%u)\n", resourceId); - RequestStoreIter iter = mStoredRequests.find( resourceId ); - if( mStoredRequests.end() != iter ) // Can't assert here - cancel load may cross with load failed - { - mStoredRequests.erase( iter ); - } - } private: @@ -266,26 +126,11 @@ ResourceLoader::~ResourceLoader() delete mImpl; } -void ResourceLoader::Pause() -{ - mImpl->Pause(); -} - -void ResourceLoader::Resume() -{ - mImpl->Resume(); -} - bool ResourceLoader::IsTerminating() { return __sync_fetch_and_or( &mTerminateThread, 0 ); } -void ResourceLoader::GetResources(ResourceCache& cache) -{ - mImpl->GetResources( cache ); -} - /********************************************************************************/ /************************** CALLED FROM LOADER THREADS **********************/ /********************************************************************************/ @@ -304,15 +149,6 @@ void ResourceLoader::AddFailedLoad(FailedResource& resource) /********************* CALLED FROM PLATFORM ABSTRACTION **********************/ /********************************************************************************/ -void ResourceLoader::LoadResource(const ResourceRequest& request) -{ - mImpl->LoadResource(request); -} - -void ResourceLoader::CancelLoad(ResourceId id, ResourceTypeId typeId) -{ - mImpl->CancelLoad(id, typeId); -} bool ResourceLoader::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const { diff --git a/platform-abstractions/tizen/resource-loader/resource-loader.h b/platform-abstractions/tizen/resource-loader/resource-loader.h index 27028ee..41b28be 100644 --- a/platform-abstractions/tizen/resource-loader/resource-loader.h +++ b/platform-abstractions/tizen/resource-loader/resource-loader.h @@ -19,7 +19,6 @@ */ #include -#include #include #include @@ -88,32 +87,6 @@ struct LoadedResource */ struct FailedResource { - FailedResource(Integration::ResourceId resourceId, Integration::ResourceFailure failure): - id(resourceId), - failureType(failure) - { - } - - /// Copy constructor - FailedResource(const FailedResource& failed) - : id(failed.id), - failureType(failed.failureType) - { - } - - /// Assignment operator - FailedResource& operator=(const FailedResource& rhs) - { - if( this != &rhs ) - { - id = rhs.id; - failureType = rhs.failureType; - } - return *this; - } - - Integration::ResourceId id; - Integration::ResourceFailure failureType; }; /** @@ -139,16 +112,6 @@ public: ~ResourceLoader(); /** - * Pause processing of already-queued resource requests. - */ - void Pause(); - - /** - * Continue processing resource requests. - */ - void Resume(); - - /** * Check if the ResourceLoader is terminating * @return true if terminating else false */ @@ -169,21 +132,6 @@ public: // From PlatformAbstraction /** - * @copydoc PlatformAbstraction::LoadResource() - */ - void LoadResource(const Integration::ResourceRequest& request); - - /** - * @copydoc PlatformAbstraction::CancelLoad() - */ - void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); - - /** - * @copydoc PlatformAbstraction::GetResources() - */ - void GetResources(Integration::ResourceCache& cache); - - /** * @copydoc SlpPlatformAbstraction::LoadFile() */ bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; diff --git a/platform-abstractions/tizen/resource-loader/resource-requester-base.h b/platform-abstractions/tizen/resource-loader/resource-requester-base.h index 71ba1d6..713a217 100644 --- a/platform-abstractions/tizen/resource-loader/resource-requester-base.h +++ b/platform-abstractions/tizen/resource-loader/resource-requester-base.h @@ -19,16 +19,9 @@ */ #include -#include -#include namespace Dali { -namespace Integration -{ -class ResourceRequest; -} - namespace TizenPlatform { @@ -49,36 +42,6 @@ public: */ virtual ~ResourceRequesterBase(); - /** - * Pause starting new work on background threads, but keep that work queued. - */ - virtual void Pause() = 0; - - /** - * Resume processing tasks on background threads. - */ - virtual void Resume() = 0; - - /** - * Load a resource. - * @param[in] request The resource request - */ - virtual void LoadResource( Integration::ResourceRequest& request ) = 0; - - /** - * Load more resources (for partial loading) - * @param[in] request The initial load request - * @param[in] partialResource The resources loaded by the last request - * @return LOADING or PARTIALLY_LOADED if more resources to come, COMPLETELY_LOADED if complete - */ - virtual Integration::LoadStatus LoadFurtherResources( Integration::ResourceRequest& request, LoadedResource partialResource ) = 0; - - /** - * Cancal load requests - * @param[in] id The request id of the loading request - * @param[in] typeId The resource type id of the loading request - */ - virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId) = 0; protected: ResourceLoader& mResourceLoader; ///< The resource loader to which to send results diff --git a/platform-abstractions/tizen/resource-loader/resource-thread-base.cpp b/platform-abstractions/tizen/resource-loader/resource-thread-base.cpp deleted file mode 100644 index e5c930e..0000000 --- a/platform-abstractions/tizen/resource-loader/resource-thread-base.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include "resource-thread-base.h" -#include "tizen-logging.h" -#include "atomics.h" - -using namespace Dali::Integration; - -namespace Dali -{ - -// Initial values for the members tracking which resources have been cancelled. -// They start out with different values so that if the first load executed is -// synchronous, it won't be erroneously cancelled. -const Integration::ResourceId NO_REQUEST_IN_FLIGHT = Integration::ResourceId(0) - 1; -const Integration::ResourceId NO_REQUEST_CANCELLED = Integration::ResourceId(0) - 2; - -namespace TizenPlatform -{ - -namespace -{ -const char * const IDLE_PRIORITY_ENVIRONMENT_VARIABLE_NAME = "DALI_RESOURCE_THREAD_IDLE_PRIORITY"; -} // unnamed namespace - -/** Thrown by InterruptionPoint() to abort a request early. */ -class CancelRequestException {}; - -ResourceThreadBase::ResourceThreadBase( ResourceLoader& resourceLoader ) : - mResourceLoader( resourceLoader ), - mThread( 0 ), - mCurrentRequestId( NO_REQUEST_IN_FLIGHT ), - mCancelRequestId( NO_REQUEST_CANCELLED ), - mPaused( false ) -{ -#if defined(DEBUG_ENABLED) - mLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_RESOURCE_THREAD_BASE"); -#endif - - int error = pthread_create( &mThread, NULL, InternalThreadEntryFunc, this ); - DALI_ASSERT_ALWAYS( !error && "Error in pthread_create()" ); -} - -ResourceThreadBase::~ResourceThreadBase() -{ - TerminateThread(); - -#if defined(DEBUG_ENABLED) - delete mLogFilter; -#endif -} - -void ResourceThreadBase::TerminateThread() -{ - if (mThread) - { - // wake thread - mCondition.Notify(); - - // wait for thread to exit - pthread_join( mThread, NULL ); - - mThread = 0; - } -} - -void ResourceThreadBase::AddRequest(const ResourceRequest& request, const RequestType type) -{ - bool wasEmpty = false; - bool wasPaused = false; - - { - // Lock while adding to the request queue - ConditionalWait::ScopedLock lock( mCondition ); - - wasEmpty = mQueue.empty(); - wasPaused = mPaused; - - mQueue.push_back( std::make_pair(request, type) ); - } - - if( wasEmpty && !wasPaused ) - { - // Wake-up the thread - mCondition.Notify(); - } -} - -// Called from outer thread. -void ResourceThreadBase::CancelRequest( const Integration::ResourceId resourceId ) -{ - bool found = false; - DALI_LOG_INFO( mLogFilter, Debug::Verbose, "%s: %u.\n", __FUNCTION__, unsigned(resourceId) ); - - // Eliminate the cancelled request from the request queue if it is in there: - { - // Lock while searching and removing from the request queue: - ConditionalWait::ScopedLock lock( mCondition ); - - for( RequestQueueIter iterator = mQueue.begin(); - iterator != mQueue.end(); - ++iterator ) - { - if( ((*iterator).first).GetId() == resourceId ) - { - iterator = mQueue.erase( iterator ); - found = true; - break; - } - } - } - - // Remember the cancelled id for the worker thread to poll at one of its points - // of interruption: - if( !found ) - { - Dali::Internal::AtomicWriteToCacheableAlignedAddress( &mCancelRequestId, resourceId ); - DALI_LOG_INFO( mLogFilter, Debug::Concise, "%s: Cancelling in-flight resource (%u).\n", __FUNCTION__, unsigned(resourceId) ); - } -} - -// Called from worker thread. -void ResourceThreadBase::InterruptionPoint() const -{ - const Integration::ResourceId cancelled = Dali::Internal::AtomicReadFromCacheableAlignedAddress( &mCancelRequestId ); - const Integration::ResourceId current = mCurrentRequestId; - - if( current == cancelled ) - { - DALI_LOG_INFO( mLogFilter, Debug::Concise, "%s: Cancelled in-flight resource (%u).\n", __FUNCTION__, unsigned(cancelled) ); - throw CancelRequestException(); - } -} - -void* ResourceThreadBase::InternalThreadEntryFunc( void* This ) -{ - ( static_cast( This ) )->ThreadLoop(); - return NULL; -} - -void ResourceThreadBase::Pause() -{ - ConditionalWait::ScopedLock lock( mCondition ); - mPaused = true; -} - -void ResourceThreadBase::Resume() -{ - // Clear the paused flag and if we weren't running already, also wake up the background thread: - bool wasPaused = false; - { - ConditionalWait::ScopedLock lock( mCondition ); - wasPaused = mPaused; - mPaused = false; - } - - // If we were paused, wake up the background thread and give it a - // chance to do some work: - if( wasPaused ) - { - mCondition.Notify(); - } -} - -//----------------- Called from separate thread (mThread) ----------------- - -void ResourceThreadBase::ThreadLoop() -{ - // TODO: Use Environment Options - const char* threadPriorityIdleRequired = std::getenv( IDLE_PRIORITY_ENVIRONMENT_VARIABLE_NAME ); - if( threadPriorityIdleRequired ) - { - // if the parameter exists then set up an idle priority for this thread - struct sched_param sp; - sp.sched_priority = 0; - sched_setscheduler(0, SCHED_IDLE, &sp); - ///@ToDo: change to the corresponding Pthreads call, not this POSIX.1-2001 one with a Linux-specific argument (SCHED_IDLE): int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param);, as specified in the docs for sched_setscheduler(): http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html - } - - InstallLogging(); - - while( !mResourceLoader.IsTerminating() ) - { - try - { - WaitForRequests(); - - if ( !mResourceLoader.IsTerminating() ) - { - ProcessNextRequest(); - } - } - - catch( CancelRequestException& ex ) - { - // No problem: a derived class deliberately threw to abort an in-flight request - // that was cancelled. - DALI_LOG_INFO( mLogFilter, Debug::Concise, "%s: Caught cancellation exception for resource (%u).\n", __FUNCTION__, unsigned(mCurrentRequestId) ); - CancelRequestException* disableUnusedVarWarning = &ex; - ex = *disableUnusedVarWarning; - } - - // Catch all exceptions to avoid killing the process, and log the error: - catch( std::exception& ex ) - { - const char * const what = ex.what(); - DALI_LOG_ERROR( "std::exception caught in resource thread. Aborting request with id %u because of std::exception with reason, \"%s\".\n", unsigned(mCurrentRequestId), what ? what : "null" ); - } - catch( Dali::DaliException& ex ) - { - // Probably a failed assert-always: - DALI_LOG_ERROR( "DaliException caught in resource thread. Aborting request with id %u. Location: \"%s\". Condition: \"%s\".\n", unsigned(mCurrentRequestId), ex.location, ex.condition ); - } - catch( ... ) - { - DALI_LOG_ERROR( "Unknown exception caught in resource thread. Aborting request with id %u.\n", unsigned(mCurrentRequestId) ); - } - } -} - -void ResourceThreadBase::WaitForRequests() -{ - 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 ); - } -} - -void ResourceThreadBase::ProcessNextRequest() -{ - ResourceRequest* request(NULL); - RequestType type(RequestLoad); - - { - // lock the queue and extract the next request - ConditionalWait::ScopedLock lock( mCondition ); - - if (!mQueue.empty()) - { - const RequestInfo & front = mQueue.front(); - request = new ResourceRequest( front.first ); - type = front.second; - mCurrentRequestId = front.first.GetId(); - mQueue.pop_front(); - } - } // unlock the queue - - // process request outside of lock - if ( NULL != request ) - { -#ifdef _CPP11 - std::unique_ptr< ResourceRequest > deleter( request ); -#else - std::auto_ptr< ResourceRequest > deleter( request ); -#endif - switch( type ) - { - case RequestLoad: - { - Load(*request); - } - break; - - case RequestDownload: - { - Download(*request); - } - break; - - case RequestDecode: - { - Decode(*request); - } - break; - } - } -} - -void ResourceThreadBase::InstallLogging() -{ - // resource loading thread will send its logs to TIZEN Platform's LogMessage handler. - Dali::Integration::Log::InstallLogFunction(Dali::TizenPlatform::LogMessage); -} - -void ResourceThreadBase::UninstallLogging() -{ - // uninstall it on resource loading thread. - Dali::Integration::Log::UninstallLogFunction(); -} - -void ResourceThreadBase::Download(const Integration::ResourceRequest& request) -{ - DALI_LOG_TRACE_METHOD(mLogFilter); - DALI_LOG_WARNING("Resource Downloading from a remote server not supported for this type.\n"); - ///! If you need this for a subclassed thread, look to ResourceThreadImage::Download() for an example implementation. -} - -void ResourceThreadBase::Decode(const Integration::ResourceRequest& request) -{ - DALI_LOG_TRACE_METHOD(mLogFilter); - DALI_LOG_WARNING("Resource Decoding from a memory buffer not supported for this type.\n"); - ///! If you need this for a subclassed thread, look to ResourceThreadImage::Decode() for an example implementation. -} - -} // namespace TizenPlatform - -} // namespace Dali diff --git a/platform-abstractions/tizen/resource-loader/resource-thread-base.h b/platform-abstractions/tizen/resource-loader/resource-thread-base.h deleted file mode 100644 index 280785d..0000000 --- a/platform-abstractions/tizen/resource-loader/resource-thread-base.h +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef __DALI_TIZEN_PLATFORM_RESOURCE_THREAD_BASE_H__ -#define __DALI_TIZEN_PLATFORM_RESOURCE_THREAD_BASE_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. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include "resource-loader.h" -#include "resource-loading-client.h" - -namespace Dali -{ - -namespace TizenPlatform -{ - -/** - * Resource loader worker thread - */ -class ResourceThreadBase : public ResourceLoadingClient -{ -public: - // typedefs and enums - - /** Client threads send work to resource threads through Requests, for which - * this type identifies the action to be taken on the resource thread. */ - enum RequestType - { - /** Pull a resource out of the platform's file system. */ - RequestLoad, - /** Pull a resource from the network. */ - RequestDownload, - /** Pull a resource out of a memory buffer. */ - RequestDecode - }; - - typedef std::pair RequestInfo; - typedef std::deque RequestQueue; - typedef RequestQueue::iterator RequestQueueIter; - -public: - // Constructor - ResourceThreadBase(ResourceLoader& resourceLoader); - - // Destructor - virtual ~ResourceThreadBase(); - -protected: - void TerminateThread(); - -public: - /** - * Add a resource request to the back of the queue - * @param[in] request The requested resource/file url and attributes - * @param[in] type Load or save flag - */ - void AddRequest(const Integration::ResourceRequest& request, const RequestType type); - - /** - * Cancel a resource request. Removes the request from the queue. - * @param[in] resourceId ID of the resource to be canceled - */ - void CancelRequest(Integration::ResourceId resourceId); - - /** - * Pause starting new work in the background, but keep that work queued. - */ - void Pause(); - - /** - * Resume processing tasks on background thread. - */ - void Resume(); - - -protected: - /** - * Main control loop for the thread. - * The thread is terminated when this function exits - */ - void ThreadLoop(); - - /** - * Wait for an incoming resource request or termination - */ - void WaitForRequests(); - - /** - * Process the resource request at the head of the queue - */ - void ProcessNextRequest(); - - /** - * Install a logging function in to core for this thread. - */ - void InstallLogging(); - - /** - * Uninstall a logging function. - */ - void UninstallLogging(); - - /** - * Load a resource - * @param[in] request The requested resource/file url and attributes - */ - virtual void Load(const Integration::ResourceRequest& request) = 0; - - /** - * Download a resource - * @param[in] request The requested resource/file url and attributes - */ - virtual void Download(const Integration::ResourceRequest& request); - - /** - * Decode a resource exactly as if it were being loaded but source its data - * from a memory buffer attached directly to the request object. - * @param[in] request The requested resource data and attributes - */ - virtual void Decode(const Integration::ResourceRequest& request); - - /** - * @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; - pthread_t mThread; ///< thread instance - 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 - -private: - - // Undefined - ResourceThreadBase( const ResourceThreadBase& resourceThreadBase ); - - // Undefined - ResourceThreadBase& operator=( const ResourceThreadBase& resourceThreadBase ); - -#if defined(DEBUG_ENABLED) -public: - Integration::Log::Filter* mLogFilter; -#endif -}; // class ResourceThreadBase - -} // namespace TizenPlatform - -} // namespace Dali - -#endif // __DALI_TIZEN_PLATFORM_RESOURCE_THREAD_BASE_H__ diff --git a/platform-abstractions/tizen/resource-loader/resource-thread-image.cpp b/platform-abstractions/tizen/resource-loader/resource-thread-image.cpp deleted file mode 100755 index 02886c0..0000000 --- a/platform-abstractions/tizen/resource-loader/resource-thread-image.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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. - * - */ - -// CLASS HEADER -#include "resource-thread-image.h" - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES -#include "portable/file-closer.h" -#include "image-loaders/image-loader.h" -#include "network/file-download.h" - -using namespace Dali::Integration; - -namespace Dali -{ - -namespace TizenPlatform -{ - -namespace -{ - -// limit maximum image down load size to 50 MB -const size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE = 50 * 1024 * 1024 ; -} - -ResourceThreadImage::ResourceThreadImage(ResourceLoader& resourceLoader) -: ResourceThreadBase(resourceLoader) -{ -} - -ResourceThreadImage::~ResourceThreadImage() -{ -} - -void ResourceThreadImage::Load(const ResourceRequest& request) -{ - DALI_LOG_TRACE_METHOD( mLogFilter ); - DALI_LOG_INFO( mLogFilter, Debug::Verbose, "%s(%s)\n", __FUNCTION__, request.GetPath().c_str() ); - - LoadImageFromLocalFile(request); -} - -void ResourceThreadImage::Download(const ResourceRequest& request) -{ - bool succeeded; - - DALI_LOG_TRACE_METHOD( mLogFilter ); - DALI_LOG_INFO( mLogFilter, Debug::Verbose, "%s(%s)\n", __FUNCTION__, request.GetPath().c_str() ); - - Dali::Vector dataBuffer; - size_t dataSize; - succeeded = DownloadRemoteImageIntoMemory( request, dataBuffer, dataSize ); - if( succeeded ) - { - DecodeImageFromMemory(static_cast(&dataBuffer[0]), dataBuffer.Size(), request); - } -} - -void ResourceThreadImage::Decode(const ResourceRequest& request) -{ - DALI_LOG_TRACE_METHOD( mLogFilter ); - DALI_LOG_INFO(mLogFilter, Debug::Verbose, "%s(%s)\n", __FUNCTION__, request.GetPath().c_str()); - - // Get the blob of binary data that we need to decode: - DALI_ASSERT_DEBUG( request.GetResource() ); - - DALI_ASSERT_DEBUG( 0 != dynamic_cast*>( request.GetResource().Get() ) && "Only blobs of binary data can be decoded." ); - Dali::RefCountedVector* const encodedBlob = reinterpret_cast*>( request.GetResource().Get() ); - - if( 0 != encodedBlob ) - { - const size_t blobSize = encodedBlob->GetVector().Size(); - uint8_t * const blobBytes = &(encodedBlob->GetVector()[0]); - DecodeImageFromMemory(blobBytes, blobSize, request); - } - else - { - FailedResource resource(request.GetId(), FailureUnknown); - mResourceLoader.AddFailedLoad(resource); - } -} - -bool ResourceThreadImage::DownloadRemoteImageIntoMemory(const Integration::ResourceRequest& request, Dali::Vector& dataBuffer, size_t& dataSize) -{ - bool ok = Network::DownloadRemoteFileIntoMemory( request.GetPath(), dataBuffer, dataSize, MAXIMUM_DOWNLOAD_IMAGE_SIZE ); - if( !ok ) - { - FailedResource resource(request.GetId(), FailureUnknown); - mResourceLoader.AddFailedLoad(resource); - } - return ok; -} - -void ResourceThreadImage::LoadImageFromLocalFile(const Integration::ResourceRequest& request) -{ - bool fileNotFound = false; - BitmapPtr bitmap = 0; - bool result = false; - - Dali::Internal::Platform::FileCloser fileCloser( request.GetPath().c_str(), "rb" ); - FILE * const fp = fileCloser.GetFile(); - - if( NULL != fp ) - { - result = ImageLoader::ConvertStreamToBitmap( *request.GetType(), request.GetPath(), fp, *this, bitmap ); - // Last chance to interrupt a cancelled load before it is reported back to clients - // which have already stopped tracking it: - InterruptionPoint(); // Note: This can throw an exception. - if( result && bitmap ) - { - // Construct LoadedResource and ResourcePointer for image data - LoadedResource resource( request.GetId(), request.GetType()->id, ResourcePointer( bitmap.Get() ) ); - // Queue the loaded resource - mResourceLoader.AddLoadedResource( resource ); - } - else - { - DALI_LOG_WARNING( "Unable to decode %s\n", request.GetPath().c_str() ); - } - } - else - { - DALI_LOG_WARNING( "Failed to open file to load \"%s\"\n", request.GetPath().c_str() ); - fileNotFound = true; - } - - if ( !bitmap ) - { - if( fileNotFound ) - { - FailedResource resource(request.GetId(), FailureFileNotFound ); - mResourceLoader.AddFailedLoad(resource); - } - else - { - FailedResource resource(request.GetId(), FailureUnknown); - mResourceLoader.AddFailedLoad(resource); - } - } -} - -void ResourceThreadImage::DecodeImageFromMemory(void* blobBytes, size_t blobSize, const Integration::ResourceRequest& request) -{ - BitmapPtr bitmap = 0; - - DALI_ASSERT_DEBUG( blobSize > 0U ); - DALI_ASSERT_DEBUG( blobBytes != 0U ); - - if( blobBytes != 0 && blobSize > 0U ) - { - // Open a file handle on the memory buffer: - Dali::Internal::Platform::FileCloser fileCloser( blobBytes, blobSize, "rb" ); - FILE * const fp = fileCloser.GetFile(); - if ( NULL != fp ) - { - bool result = ImageLoader::ConvertStreamToBitmap( *request.GetType(), request.GetPath(), fp, StubbedResourceLoadingClient(), bitmap ); - if ( result && bitmap ) - { - // Construct LoadedResource and ResourcePointer for image data - LoadedResource resource( request.GetId(), request.GetType()->id, ResourcePointer( bitmap.Get() ) ); - // Queue the loaded resource - mResourceLoader.AddLoadedResource( resource ); - } - else - { - DALI_LOG_WARNING( "Unable to decode bitmap supplied as in-memory blob.\n" ); - } - } - } - - if (!bitmap) - { - FailedResource resource(request.GetId(), FailureUnknown); - mResourceLoader.AddFailedLoad(resource); - } -} - -} // namespace TizenPlatform - -} // namespace Dali diff --git a/platform-abstractions/tizen/resource-loader/resource-thread-image.h b/platform-abstractions/tizen/resource-loader/resource-thread-image.h deleted file mode 100644 index 6d9a009..0000000 --- a/platform-abstractions/tizen/resource-loader/resource-thread-image.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef __DALI_TIZEN_PLATFORM_RESOURCE_THREAD_IMAGE_H__ -#define __DALI_TIZEN_PLATFORM_RESOURCE_THREAD_IMAGE_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. - * - */ -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include "resource-thread-base.h" - -namespace Dali -{ - -namespace TizenPlatform -{ - -class ResourceThreadImage : public ResourceThreadBase -{ -public: - /** - * Constructor - * @param[in] resourceLoader A reference to the ResourceLoader - */ - ResourceThreadImage( ResourceLoader& resourceLoader ); - - /** - * Destructor - */ - virtual ~ResourceThreadImage(); - - -private: - /** - * @copydoc ResourceThreadBase::Load - */ - virtual void Load(const Integration::ResourceRequest& request); - - /** - * @copydoc ResourceThreadBase::Download - */ - virtual void Download(const Integration::ResourceRequest& request); - - /** - * @copydoc ResourceThreadBase::Decode - */ - virtual void Decode(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. - * @param[out] dataSize The size of the memory buffer. - */ - bool DownloadRemoteImageIntoMemory(const Integration::ResourceRequest& request, Dali::Vector& dataBuffer, size_t& dataSize); - - /** - * Load a requested image from a local file. - * @param[in] request The requested resource/file url and attributes - */ - void LoadImageFromLocalFile(const Integration::ResourceRequest& request); - - /** - * Decode a requested image from a memory buffer. - * @param[in] blobBytes A pointer to the memory buffer containig the requested image data. - * @param[in] blobSize The size of the memory buffer containing the requested image data. - * @param[in] request The requested resource/file url and attributes - */ - void DecodeImageFromMemory(void* blobBytes, size_t blobSize, const Integration::ResourceRequest& request); -}; // class ResourceThreadImage - -} // namespace TizenPlatform - -} // namespace Dali - -#endif // __DALI_TIZEN_PLATFORM_RESOURCE_THREAD_IMAGE_H__ diff --git a/platform-abstractions/tizen/tizen-platform-abstraction.cpp b/platform-abstractions/tizen/tizen-platform-abstraction.cpp index 338f5da..0ca22e4 100644 --- a/platform-abstractions/tizen/tizen-platform-abstraction.cpp +++ b/platform-abstractions/tizen/tizen-platform-abstraction.cpp @@ -54,22 +54,6 @@ TizenPlatformAbstraction::~TizenPlatformAbstraction() delete mResourceLoader; } -void TizenPlatformAbstraction::Suspend() -{ - if (mResourceLoader) - { - mResourceLoader->Pause(); - } -} - -void TizenPlatformAbstraction::Resume() -{ - if (mResourceLoader) - { - mResourceLoader->Resume(); - } -} - int TizenPlatformAbstraction::GetDefaultFontSize() const { int fontSize( -1 ); @@ -99,14 +83,6 @@ ImageDimensions TizenPlatformAbstraction::GetClosestImageSize( Integration::Reso return ImageLoader::GetClosestImageSize( resourceBuffer, size, fittingMode, samplingMode, orientationCorrection ); } -void TizenPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request) -{ - if (mResourceLoader) - { - mResourceLoader->LoadResource(request); - } -} - Integration::ResourcePointer TizenPlatformAbstraction::LoadResourceSynchronously(const Integration::ResourceType& resourceType, const std::string& resourcePath) { return ImageLoader::LoadResourceSynchronously( resourceType, resourcePath ); @@ -131,51 +107,6 @@ Integration::BitmapPtr TizenPlatformAbstraction::DecodeBuffer( const Integration return bitmap; } -void TizenPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId) -{ - if (mResourceLoader) - { - mResourceLoader->CancelLoad(id, typeId); - } -} - -void TizenPlatformAbstraction::GetResources(Integration::ResourceCache& cache) -{ - if (mResourceLoader) - { - mResourceLoader->GetResources(cache); - } -} - -bool TizenPlatformAbstraction::LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const -{ - bool result = false; - - if( mResourceLoader ) - { - result = mResourceLoader->LoadFile( filename, buffer ); - } - - return result; -} - -std::string TizenPlatformAbstraction::LoadFile( const std::string& filename ) -{ - std::string result; - if (mResourceLoader) - { - result = mResourceLoader->LoadFile(filename); - } - - return result; -} - -void TizenPlatformAbstraction::JoinLoaderThreads() -{ - delete mResourceLoader; - mResourceLoader = NULL; -} - bool TizenPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const { bool result = false; diff --git a/platform-abstractions/tizen/tizen-platform-abstraction.h b/platform-abstractions/tizen/tizen-platform-abstraction.h index 949c77f..3e61966 100644 --- a/platform-abstractions/tizen/tizen-platform-abstraction.h +++ b/platform-abstractions/tizen/tizen-platform-abstraction.h @@ -19,7 +19,6 @@ */ #include -#include #include #include @@ -58,16 +57,6 @@ public: // Construction & Destruction public: // PlatformAbstraction overrides /** - * @copydoc PlatformAbstraction::Suspend() - */ - virtual void Suspend(); - - /** - * @copydoc PlatformAbstraction::Resume() - */ - virtual void Resume(); - - /** * @copydoc PlatformAbstraction::GetClosestImageSize() */ virtual ImageDimensions GetClosestImageSize( const std::string& filename, @@ -86,11 +75,6 @@ public: // PlatformAbstraction overrides bool orientationCorrection ); /** - * @copydoc PlatformAbstraction::LoadResource() - */ - virtual void LoadResource(const Integration::ResourceRequest& request); - - /** * @copydoc PlatformAbstraction::LoadResourceSynchronously() */ virtual Integration::ResourcePointer LoadResourceSynchronously(const Integration::ResourceType& resourceType, const std::string& resourcePath); @@ -101,36 +85,11 @@ public: // PlatformAbstraction overrides virtual Integration::BitmapPtr DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t size ); /** - * @copydoc PlatformAbstraction::CancelLoad() - */ - virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); - - /** - * @copydoc PlatformAbstraction::GetResources() - */ - virtual void GetResources(Integration::ResourceCache& cache); - - /** - * @copydoc PlatformAbstraction::JoinLoaderThreads() - */ - virtual void JoinLoaderThreads(); - - /** * @copydoc PlatformAbstraction::GetDefaultFontSize() */ virtual int GetDefaultFontSize() const; /** - * @copydoc PlatformAbstraction::LoadFile() - */ - virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const; - - /** - * @copydoc PlatformAbstraction::LoadFile() - */ - virtual std::string LoadFile( const std::string& filename ); - - /** * @copydoc PlatformAbstraction::LoadShaderBinaryFile() */ virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const; diff --git a/text/dali/devel-api/text-abstraction/font-client.cpp b/text/dali/devel-api/text-abstraction/font-client.cpp index cc00057..3006d47 100644 --- a/text/dali/devel-api/text-abstraction/font-client.cpp +++ b/text/dali/devel-api/text-abstraction/font-client.cpp @@ -75,6 +75,11 @@ void FontClient::GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi GetImplementation(*this).GetDpi( horizontalDpi, verticalDpi ); } +int FontClient::GetDefaultFontSize() +{ + return GetImplementation(*this).GetDefaultFontSize(); +} + void FontClient::ResetSystemDefaults() { GetImplementation(*this).ResetSystemDefaults(); diff --git a/text/dali/devel-api/text-abstraction/font-client.h b/text/dali/devel-api/text-abstraction/font-client.h index 4fa85ca..8b0164e 100644 --- a/text/dali/devel-api/text-abstraction/font-client.h +++ b/text/dali/devel-api/text-abstraction/font-client.h @@ -146,6 +146,15 @@ public: void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi ); /** + * @brief Called by Dali to retrieve the default font size for the platform. + * + * This is an accessibility size, which is mapped to a UI Control specific point-size in stylesheets. + * For example if zero the smallest size, this could potentially map to TextLabel point-size 8. + * @return The default font size. + */ + int GetDefaultFontSize(); + + /** * @brief Called when the user changes the system defaults. * * @post Previously cached system defaults are removed. diff --git a/text/dali/internal/text-abstraction/font-client-impl.cpp b/text/dali/internal/text-abstraction/font-client-impl.cpp index 833dfdc..b850b7f 100644 --- a/text/dali/internal/text-abstraction/font-client-impl.cpp +++ b/text/dali/internal/text-abstraction/font-client-impl.cpp @@ -18,6 +18,11 @@ // CLASS HEADER #include +// EXTERNAL INCLUDES +#ifndef DALI_PROFILE_UBUNTU +#include +#endif + // INTERNAL INCLUDES #include #include @@ -86,6 +91,17 @@ void FontClient::GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi verticalDpi = mDpiVertical; } +int FontClient::GetDefaultFontSize() +{ + int fontSize( -1 ); + +#ifndef DALI_PROFILE_UBUNTU + vconf_get_int( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &fontSize ); +#endif // DALI_PROFILE_UBUNTU + + return fontSize; +} + void FontClient::ResetSystemDefaults() { CreatePlugin(); diff --git a/text/dali/internal/text-abstraction/font-client-impl.h b/text/dali/internal/text-abstraction/font-client-impl.h index f5afa98..3222526 100644 --- a/text/dali/internal/text-abstraction/font-client-impl.h +++ b/text/dali/internal/text-abstraction/font-client-impl.h @@ -66,6 +66,11 @@ public: void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi ); /** + * @copydoc Dali::TextAbstraction::FontClient::GetDefaultFontSize() + */ + int GetDefaultFontSize(); + + /** * @copydoc Dali::TextAbstraction::FontClient::ResetSystemDefaults() */ void ResetSystemDefaults();