From 1bd9dce134ee73fc69759704e00ca86587da9054 Mon Sep 17 00:00:00 2001 From: taeyoon Date: Thu, 26 Feb 2015 18:57:26 +0900 Subject: [PATCH] Resource management modification - Moving shaderbin directory information from dali-core to dali-adaptor - Addition of shaderbin handling. - Addition of enable_shaderbincache ENABLE (default is ENABLE) Change-Id: I89ba27280fc1186245453fa6642bc8678d43a124 --- adaptors/common/adaptor-impl.cpp | 4 ++ adaptors/common/adaptor-impl.h | 6 +++ adaptors/tizen/adaptor-impl-tizen.cpp | 47 ++++++++++++++++++++ adaptors/tizen/file.list | 1 + adaptors/ubuntu/adaptor-impl-ubuntu.cpp | 39 +++++++++++++++++ adaptors/ubuntu/file.list | 1 + .../test-platform-abstraction.cpp | 15 +++++++ .../test-platform-abstraction.h | 7 +++ build/tizen/adaptor/Makefile.am | 5 ++- build/tizen/configure.ac | 10 +++++ packaging/dali-adaptor-mobile.spec | 16 ++++--- packaging/dali-adaptor-tv.spec | 5 +-- packaging/dali-adaptor-wearable.spec | 5 +-- packaging/dali-adaptor.spec | 22 +++++----- .../slp/slp-platform-abstraction.cpp | 50 ++++++++++++++++++++-- .../slp/slp-platform-abstraction.h | 16 ++++++- 16 files changed, 217 insertions(+), 32 deletions(-) create mode 100644 adaptors/tizen/adaptor-impl-tizen.cpp create mode 100644 adaptors/ubuntu/adaptor-impl-ubuntu.cpp diff --git a/adaptors/common/adaptor-impl.cpp b/adaptors/common/adaptor-impl.cpp index f614faa..cd87f18 100644 --- a/adaptors/common/adaptor-impl.cpp +++ b/adaptors/common/adaptor-impl.cpp @@ -224,6 +224,10 @@ void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration) mPlatformAbstraction = new SlpPlatform::SlpPlatformAbstraction; + std::string path; + GetDataStoragePath( path ); + mPlatformAbstraction->SetDataStoragePath( path ); + ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA; if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ) { diff --git a/adaptors/common/adaptor-impl.h b/adaptors/common/adaptor-impl.h index ad7d100..1e5c2ac 100644 --- a/adaptors/common/adaptor-impl.h +++ b/adaptors/common/adaptor-impl.h @@ -457,6 +457,12 @@ private: */ void ProcessCoreEventsFromIdle(); + /** + * Gets path for data/resource storage. + * @param[out] path Path for data/resource storage + */ + void GetDataStoragePath(std::string& path); + private: /** diff --git a/adaptors/tizen/adaptor-impl-tizen.cpp b/adaptors/tizen/adaptor-impl-tizen.cpp new file mode 100644 index 0000000..89dcdfe --- /dev/null +++ b/adaptors/tizen/adaptor-impl-tizen.cpp @@ -0,0 +1,47 @@ +/* + * 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. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#ifdef OVER_TIZEN_SDK_2_2 +#include +#endif + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +void Adaptor::GetDataStoragePath( std::string& path) +{ + path = ""; +#ifdef OVER_TIZEN_SDK_2_2 + path = app_get_data_path(); +#endif +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/adaptors/tizen/file.list b/adaptors/tizen/file.list index 3e0609f..7ab1a0e 100644 --- a/adaptors/tizen/file.list +++ b/adaptors/tizen/file.list @@ -2,6 +2,7 @@ adaptor_tizen_internal_src_files = \ $(adaptor_tizen_dir)/accessibility-manager-impl-tizen.cpp \ + $(adaptor_tizen_dir)/adaptor-impl-tizen.cpp \ $(adaptor_tizen_dir)/framework-tizen.cpp \ $(adaptor_tizen_dir)/vsync-monitor-tizen.cpp \ $(adaptor_tizen_dir)/tilt-sensor-impl-tizen.cpp \ diff --git a/adaptors/ubuntu/adaptor-impl-ubuntu.cpp b/adaptors/ubuntu/adaptor-impl-ubuntu.cpp new file mode 100644 index 0000000..118816e --- /dev/null +++ b/adaptors/ubuntu/adaptor-impl-ubuntu.cpp @@ -0,0 +1,39 @@ +/* + * 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. + * + */ + +// CLASS HEADER +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +void Adaptor::GetDataStoragePath( std::string& path) +{ + path = DALI_SHADERBIN_DIR; +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/adaptors/ubuntu/file.list b/adaptors/ubuntu/file.list index d8c6357..0ff86ba 100644 --- a/adaptors/ubuntu/file.list +++ b/adaptors/ubuntu/file.list @@ -2,6 +2,7 @@ adaptor_ubuntu_internal_src_files = \ $(adaptor_ubuntu_dir)/accessibility-manager-impl-ubuntu.cpp \ + $(adaptor_ubuntu_dir)/adaptor-impl-ubuntu.cpp \ $(adaptor_ubuntu_dir)/framework-ubuntu.cpp \ $(adaptor_ubuntu_dir)/vsync-monitor-ubuntu.cpp \ $(adaptor_ubuntu_dir)/tilt-sensor-impl-ubuntu.cpp \ 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 aa1b5b2..5ab4b7d 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 @@ -370,6 +370,20 @@ bool TestPlatformAbstraction::LoadFile( const std::string& filename, std::vector } /** + * @copydoc PlatformAbstraction::LoadShaderBinFile() + */ +bool TestPlatformAbstraction::LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const +{ + mTrace.PushCall("LoadShaderBinFile", ""); + if( mLoadFileResult.loadResult ) + { + buffer = mLoadFileResult.buffer; + } + + return mLoadFileResult.loadResult; +} + +/** * @copydoc PlatformAbstraction::SaveFile() */ bool TestPlatformAbstraction::SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const @@ -498,6 +512,7 @@ bool TestPlatformAbstraction::WasCalled(TestFuncEnum func) case LoadResourceFunc: return mTrace.FindMethod("LoadResource"); case SaveResourceFunc: return mTrace.FindMethod("SaveResource"); case LoadFileFunc: return mTrace.FindMethod("LoadFile"); + case LoadShaderBinFileFunc: return mTrace.FindMethod("LoadShaderBinFile"); case SaveFileFunc: return mTrace.FindMethod("SaveFile"); case CancelLoadFunc: return mTrace.FindMethod("CancelLoad"); case GetResourcesFunc: return mTrace.FindMethod("GetResources"); 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 54cb154..070af04 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 @@ -208,6 +208,12 @@ public: virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; /** + * @copydoc PlatformAbstraction::LoadShaderBinFile() + */ + virtual bool LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer +) const; + + /** * @copydoc PlatformAbstraction::SaveFile() */ virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const; @@ -251,6 +257,7 @@ public: // TEST FUNCTIONS SaveResourceFunc, SaveFileFunc, LoadFileFunc, + LoadShaderBinFileFunc, CancelLoadFunc, GetResourcesFunc, IsLoadingFunc, diff --git a/build/tizen/adaptor/Makefile.am b/build/tizen/adaptor/Makefile.am index bce2054..d547c40 100644 --- a/build/tizen/adaptor/Makefile.am +++ b/build/tizen/adaptor/Makefile.am @@ -198,13 +198,14 @@ endif daliDefaultFontCacheDir = ${dataReadOnlyDir}/glyphcache/ daliUserFontCacheDir = ${dataReadWriteDir}/glyphcache/ daliDefaultThemeDir = ${dataReadWriteDir}/theme/ -daliUserShaderCacheDir = ${dataReadWriteDir}/core/shaderbin/ +daliShaderbinCacheDir = ${dataReadOnlyDir}/core/shaderbin/ libdali_adaptor_la_CXXFLAGS = \ -DDALI_DATA_RW_DIR="\"${daliReadWriteDir}\"" \ -DDALI_DATA_RO_DIR="\"${daliReadOnlyDir}\"" \ -DDALI_DEFAULT_FONT_CACHE_DIR="\"${daliDefaultFontCacheDir}\"" \ -DDALI_USER_FONT_CACHE_DIR="\"${daliUserFontCacheDir}\"" \ + -DDALI_SHADERBIN_DIR="\"${daliShaderbinCacheDir}\"" \ -DDALI_DEFAULT_THEME_DIR="\"${daliDefaultThemeDir}\"" \ -DFONT_PRELOADED_PATH="\"${fontPreloadedPath}\"" \ -DFONT_DOWNLOADED_PATH="\"${fontDownloadedPath}\"" \ @@ -323,7 +324,7 @@ tizenadaptordaliheaderdir = $(devincludepath)/dali tizenadaptordaliheader_HEADERS = $(adaptor_dali_header_file) install-data-local: - $(MKDIR_P) ${DESTDIR}/${daliUserFontCacheDir} ${DESTDIR}/${daliUserShaderCacheDir} + $(MKDIR_P) ${DESTDIR}/${daliUserFontCacheDir} ${DESTDIR}/${daliShaderbinCacheDir} # Install resource log analyzer script bin_SCRIPTS = ../../../adaptors/scripts/dalireslog.sh diff --git a/build/tizen/configure.ac b/build/tizen/configure.ac index 6aec94b..61ba696 100644 --- a/build/tizen/configure.ac +++ b/build/tizen/configure.ac @@ -91,6 +91,12 @@ AC_ARG_ENABLE([debug], [enable_debug=$enableval], [enable_debug=no]) +AC_ARG_ENABLE(shaderbincache, + [AC_HELP_STRING([--enable-shaderbincache], + [enables shader binary cache])], + [enable_shaderbincache=$enableval], + [enable_shaderbincache=DISABLE]) + if test "x$enable_debug" = "xyes"; then DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DDEBUG_ENABLED" fi @@ -99,6 +105,10 @@ if test "x$enable_debug" = "xno" -a "x$enable_exportall" = "xno"; then DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -fvisibility=hidden -DHIDE_DALI_INTERNALS" fi +if test "x$enable_shaderbincache" = "xENABLE"; then + DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DSHADERBIN_CACHE_ENABLED" +fi + AC_ARG_ENABLE([assimp], [AC_HELP_STRING([--enable-assimp], [Enable assimp plugin, overriding platform defaults])], diff --git a/packaging/dali-adaptor-mobile.spec b/packaging/dali-adaptor-mobile.spec index d965c6a..230a432 100644 --- a/packaging/dali-adaptor-mobile.spec +++ b/packaging/dali-adaptor-mobile.spec @@ -13,6 +13,10 @@ Source0: %{name}-%{version}.tar.gz %define dali_bullet_plugin 1 %define dali_assimp_plugin 1 +%if 0%{?over_tizen_2_2} +%define shaderbincache_flag ENABLE +%endif + Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig Requires: boost-thread @@ -102,7 +106,7 @@ Dynamics plugin to wrap the libBulletDynamics libraries %define dali_data_rw_dir /opt/usr/share/dali/ %define dali_data_ro_dir /usr/share/dali/ %define user_font_cache_dir %{dali_data_rw_dir}/glyphcache/ -%define user_shader_cache_dir %{dali_data_rw_dir}/core/shaderbin/ +%define user_shader_cache_dir %{dali_data_ro_dir}/core/shaderbin/ %define font_preloaded_path /usr/share/fonts/ %define font_downloaded_path /opt/share/fonts/ %define font_application_path /usr/share/app_fonts/ @@ -124,8 +128,9 @@ LDFLAGS+=" -Wl,--rpath=%{_libdir} -Wl,--as-needed -Wl,--gc-sections -Wl,-Bsymbol CXXFLAGS+=" -D_ARCH_ARM_ -lgcc" %endif -%if 0%{?TIZEN_SDK_2_3} -CXXFLAGS+=" -DTIZEN_SDK_2_3" +%if 0%{?over_tizen_2_2} +CFLAGS+=" -DOVER_TIZEN_SDK_2_2" +CXXFLAGS+=" -DOVER_TIZEN_SDK_2_2" %endif libtoolize --force @@ -138,7 +143,7 @@ FONT_DOWNLOADED_PATH="%{font_downloaded_path}" ; export FONT_DOWNLOADED_PATH FONT_APPLICATION_PATH="%{font_application_path}" ; export FONT_APPLICATION_PATH FONT_CONFIGURATION_FILE="%{font_configuration_file}" ; export FONT_CONFIGURATION_FILE -%configure --with-jpeg-turbo --enable-gles=20 --enable-profile=%{dali_profile} \ +%configure --with-jpeg-turbo --enable-gles=20 --enable-shaderbincache=%{shaderbincache_flag} --enable-profile=%{dali_profile} \ %if 0%{?dali_feedback_plugin} --enable-feedback \ %endif @@ -176,7 +181,6 @@ cp -af %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{ %pre rm -f %{user_font_cache_dir}/* -rm -f %{user_shader_cache_dir}/* exit 0 ############################## @@ -185,7 +189,6 @@ exit 0 %post /sbin/ldconfig chown 5000:5000 %{user_font_cache_dir} -chown 5000:5000 %{user_shader_cache_dir} exit 0 %if 0%{?dali_feedback_plugin} @@ -205,7 +208,6 @@ exit 0 ############################## %preun rm -f %{user_font_cache_dir}/* -rm -f %{user_shader_cache_dir}/* exit 0 ############################## diff --git a/packaging/dali-adaptor-tv.spec b/packaging/dali-adaptor-tv.spec index 03a68c1..785e8afd 100644 --- a/packaging/dali-adaptor-tv.spec +++ b/packaging/dali-adaptor-tv.spec @@ -99,7 +99,7 @@ Dynamics plugin to wrap the libBulletDynamics libraries %define dali_data_rw_dir /usr/share/dali/ %define dali_data_ro_dir /usr/share/dali/ %define user_font_cache_dir %{dali_data_rw_dir}/glyphcache/ -%define user_shader_cache_dir %{dali_data_rw_dir}/core/shaderbin/ +%define user_shader_cache_dir %{dali_data_ro_dir}/core/shaderbin/ %define font_preloaded_path /usr/share/fonts/ %define font_downloaded_path /opt/share/fonts/ %define font_application_path /usr/share/app_fonts/ @@ -169,7 +169,6 @@ cp -af %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{ %pre rm -f %{user_font_cache_dir}/* -rm -f %{user_shader_cache_dir}/* exit 0 ############################## @@ -178,7 +177,6 @@ exit 0 %post /sbin/ldconfig chown 5000:5000 %{user_font_cache_dir} -chown 5000:5000 %{user_shader_cache_dir} exit 0 %if 0%{?dali_feedback_plugin} @@ -198,7 +196,6 @@ exit 0 ############################## %preun rm -f %{user_font_cache_dir}/* -rm -f %{user_shader_cache_dir}/* exit 0 ############################## diff --git a/packaging/dali-adaptor-wearable.spec b/packaging/dali-adaptor-wearable.spec index 33819b6..99c549f 100644 --- a/packaging/dali-adaptor-wearable.spec +++ b/packaging/dali-adaptor-wearable.spec @@ -88,7 +88,7 @@ Feedback plugin to play haptic and audio feedback for Dali %define dali_data_rw_dir /opt/usr/share/dali/ %define dali_data_ro_dir /usr/share/dali/ %define user_font_cache_dir %{dali_data_rw_dir}/glyphcache/ -%define user_shader_cache_dir %{dali_data_rw_dir}/core/shaderbin/ +%define user_shader_cache_dir %{dali_data_ro_dir}/core/shaderbin/ %define font_preloaded_path /usr/share/fonts/ %define font_downloaded_path /opt/share/fonts/ %define font_application_path /usr/share/app_fonts/ @@ -155,7 +155,6 @@ cp -af %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{ %pre rm -f %{user_font_cache_dir}/* -rm -f %{user_shader_cache_dir}/* exit 0 ############################## @@ -164,7 +163,6 @@ exit 0 %post /sbin/ldconfig chown 5000:5000 %{user_font_cache_dir} -chown 5000:5000 %{user_shader_cache_dir} exit 0 %if 0%{?dali_feedback_plugin} @@ -178,7 +176,6 @@ exit 0 ############################## %preun rm -f %{user_font_cache_dir}/* -rm -f %{user_shader_cache_dir}/* exit 0 ############################## diff --git a/packaging/dali-adaptor.spec b/packaging/dali-adaptor.spec index 4bdf5bd..f28e051 100755 --- a/packaging/dali-adaptor.spec +++ b/packaging/dali-adaptor.spec @@ -15,29 +15,34 @@ Source0: %{name}-%{version}.tar.gz %define dali_bullet_plugin 0 %define dali_assimp_plugin 0 %define over_tizen_2_2 0 +%define shaderbincache_flag DISABLE +%endif -%else if "%{profile}" == "tv" +%if "%{profile}" == "tv" %define dali_profile TV %define dali_feedback_plugin 0 %define dali_bullet_plugin 0 %define dali_assimp_plugin 0 %define over_tizen_2_2 1 +%define shaderbincache_flag ENABLE +%endif -%else if "%{profile}" == "wearable" +%if "%{profile}" == "wearable" %define dali_profile WEARABLE %define dali_feedback_plugin 0 %define dali_bullet_plugin 0 %define dali_assimp_plugin 0 %define over_tizen_2_2 0 +%define shaderbincache_flag DISABLE +%endif -%else -## profile == common +%if "%{profile}" == "common" %define dali_profile COMMON %define dali_feedback_plugin 0 %define dali_bullet_plugin 0 %define dali_assimp_plugin 0 %define over_tizen_2_2 0 - +%define shaderbincache_flag DISABLE %endif Requires(post): /sbin/ldconfig @@ -137,7 +142,7 @@ Dynamics plugin to wrap the libBulletDynamics libraries %define dali_data_rw_dir /usr/share/dali/ %define dali_data_ro_dir /usr/share/dali/ %define user_font_cache_dir %{dali_data_rw_dir}/glyphcache/ -%define user_shader_cache_dir %{dali_data_rw_dir}/core/shaderbin/ +%define user_shader_cache_dir %{dali_data_ro_dir}/core/shaderbin/ %define font_preloaded_path /usr/share/fonts/ %define font_downloaded_path /opt/share/fonts/ %define font_application_path /usr/share/app_fonts/ @@ -174,7 +179,7 @@ libtoolize --force cd %{_builddir}/%{name}-%{version}/build/tizen && autoreconf --install cd %{_builddir}/%{name}-%{version}/build/tizen && CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS DALI_DATA_RW_DIR="%{dali_data_rw_dir}" DALI_DATA_RO_DIR="%{dali_data_ro_dir}" FONT_PRELOADED_PATH="%{font_preloaded_path}" FONT_DOWNLOADED_PATH="%{font_downloaded_path}" FONT_APPLICATION_PATH="%{font_application_path}" FONT_CONFIGURATION_FILE="%{font_configuration_file}" -%configure --prefix=$PREFIX --with-jpeg-turbo --enable-gles=20 --enable-profile=%{dali_profile} \ +%configure --prefix=$PREFIX --with-jpeg-turbo --enable-gles=20 --enable-shaderbincache=%{shaderbincache_flag} --enable-profile=%{dali_profile} \ %if 0%{?dali_feedback_plugin} --enable-feedback \ %endif @@ -212,7 +217,6 @@ cp -af %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{ %pre rm -f %{user_font_cache_dir}/* -rm -f %{user_shader_cache_dir}/* exit 0 ############################## @@ -221,7 +225,6 @@ exit 0 %post /sbin/ldconfig chown 5000:5000 %{user_font_cache_dir} -chown 5000:5000 %{user_shader_cache_dir} exit 0 %if 0%{?dali_feedback_plugin} @@ -241,7 +244,6 @@ exit 0 ############################## %preun rm -f %{user_font_cache_dir}/* -rm -f %{user_shader_cache_dir}/* exit 0 ############################## diff --git a/platform-abstractions/slp/slp-platform-abstraction.cpp b/platform-abstractions/slp/slp-platform-abstraction.cpp index 188aced..799139f 100644 --- a/platform-abstractions/slp/slp-platform-abstraction.cpp +++ b/platform-abstractions/slp/slp-platform-abstraction.cpp @@ -66,8 +66,9 @@ const float FONT_SIZE_TABLE[5] = SlpPlatformAbstraction::SlpPlatformAbstraction() : mResourceLoader(new ResourceLoader), - mDefaultFontSize(FONT_SIZE_TABLE[1]), - mDynamicsFactory(NULL) + mDynamicsFactory(NULL), + mDataStoragePath( "" ), + mDefaultFontSize(FONT_SIZE_TABLE[1]) { int error = FT_Init_FreeType(&mFreeTypeHandle); DALI_ASSERT_ALWAYS( error == 0 && "Freetype initialization failed" ); @@ -204,7 +205,20 @@ void SlpPlatformAbstraction::SaveResource(const Integration::ResourceRequest& re { if (mResourceLoader) { - mResourceLoader->SaveResource(request); + if( request.GetType()->id == Integration::ResourceShader ) + { +#ifdef SHADERBIN_CACHE_ENABLED + std::string path = mDataStoragePath; + path += request.GetPath(); + + Integration::ResourceRequest newRequest( request.GetId(), *request.GetType(), path, request.GetResource() ); + mResourceLoader->SaveResource(newRequest); +#endif + } + else + { + mResourceLoader->SaveResource(request); + } } } @@ -427,6 +441,36 @@ Integration::BitmapPtr SlpPlatformAbstraction::GetGlyphImage( const std::string& return glyphImage; } +bool SlpPlatformAbstraction::LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const +{ + bool result = false; + +#ifdef SHADERBIN_CACHE_ENABLED + std::string path; + + if( mResourceLoader ) + { + path = DALI_SHADERBIN_DIR; + path += filename; + result = mResourceLoader->LoadFile( path, buffer ); + } + + if( mResourceLoader && result == false ) + { + path = mDataStoragePath; + path += filename; + result = mResourceLoader->LoadFile( path, buffer ); + } +#endif + + return result; +} + +void SlpPlatformAbstraction::SetDataStoragePath( const std::string& path ) +{ + mDataStoragePath = path; +} + } // namespace SlpPlatform } // namespace Dali diff --git a/platform-abstractions/slp/slp-platform-abstraction.h b/platform-abstractions/slp/slp-platform-abstraction.h index e32f979..5201a0f 100644 --- a/platform-abstractions/slp/slp-platform-abstraction.h +++ b/platform-abstractions/slp/slp-platform-abstraction.h @@ -248,14 +248,26 @@ public: // PlatformAbstraction overrides */ virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const; + /** + * @copydoc PlatformAbstraction::LoadShaderBinFile() + */ + virtual bool LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; + + /** + * Sets path for data/resource storage. + * @param[in] path data/resource storage path + */ + void SetDataStoragePath( const std::string& path ); + private: ResourceLoader* mResourceLoader; + DynamicsFactory* mDynamicsFactory; FT_Library mFreeTypeHandle; ///< Freetype library std::string mDefaultFontFamily; std::string mDefaultFontStyle; - float mDefaultFontSize; std::string mDefaultThemeFile; - DynamicsFactory* mDynamicsFactory; + std::string mDataStoragePath; + float mDefaultFontSize; }; } // namespace SlpPlatform -- 2.7.4