we can add an image loader through the dali-extension plugin.
To enable it, change to "%define use_image_loader 1" in
dali-extension.spec
Change-Id: Ic553ea5a3bcf681046b92d629e0b7fe3ea3138ae
AC_CONFIG_SUBDIRS(key)
AC_CONFIG_SUBDIRS(video-player)
AC_CONFIG_SUBDIRS(web-engine-chromium)
+AC_CONFIG_SUBDIRS(image-loader)
AC_CONFIG_FILES([
Makefile
--- /dev/null
+#
+# Copyright (c) 2018 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.
+#
+
+# Build the Dali image loader plugin
+
+if USE_IMAGELOADER_EXTENSION
+extension_src_dir = ../../../dali-extension
+
+include ../../../dali-extension/image-loader/file.list
+
+lib_LTLIBRARIES =
+
+lib_LTLIBRARIES += libdali-image-loader-plugin.la
+
+libdali_image_loader_plugin_la_includes =
+
+libdali_image_loader_plugin_la_SOURCES = \
+ $(image_loader_plugin_src_files)
+
+libdali_image_loader_plugin_la_DEPENDENCIES =
+
+libdali_image_loader_plugin_la_CXXFLAGS = \
+ $(DLOG_CFLAGS) \
+ $(DALI_CFLAGS) \
+ -Werror -Wall
+
+libdali_image_loader_plugin_la_CXXFLAGS+= \
+ -I../../../dali-extension/image-loader
+
+libdali_image_loader_plugin_la_LIBADD = \
+ $(DLOG_LIBS) \
+ $(DALI_LIBS)
+
+libdali_image_loader_plugin_la_LDFLAGS = \
+ -rdynamic
+endif
--- /dev/null
+4_define([dali_version],[0.1.0])
+AC_INIT([dali], [dali_version])
+AM_INIT_AUTOMAKE([-Wall foreign])
+
+AC_CONFIG_MACRO_DIR([m4])
+
+AC_PROG_CXX
+AC_PROG_LIBTOOL
+
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+LT_INIT
+
+DALI_EXTENSION_VERSION=dali_version
+AC_SUBST(DALI_EXTENSION_VERSION)
+
+AC_ARG_ENABLE([imageloader-extension],
+ [AC_HELP_STRING([--enable-imageloader-extension],
+ [enables the image loader extension of all the symbols in the library])],
+ [enable_imageloader_extension=yes],
+ [enable_imageloader_extension=no])
+
+AM_CONDITIONAL([USE_IMAGELOADER_EXTENSION], [test x$enable_imageloader_extension = xyes])
+
+PKG_CHECK_MODULES([DALI], [dali-core dali-adaptor dali-toolkit])
+
+devincludepath=${includedir}
+AC_SUBST(devincludepath)
+
+AC_CONFIG_FILES([
+Makefile
+])
+
+AC_OUTPUT
--- /dev/null
+## Implement
+
+You can implement a new type of image loader plugin.
+implement LoadBitmapFromImage and LoadImageHeader in the loader-dummy.cpp file.
+
+ bool LoadImageHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+ {
+ bool success = false;
+ /* Loads the header of a image file and fills in the width and height appropriately. */
+
+ return success;
+ }
+
+ bool LoadBitmapFromImage( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+ {
+ bool success = false;
+ /* Loads the bitmap from an image file. This function checks the header first */
+
+ return success;
+ }
+
+And register your new image loader in tizen-image-loader.cpp
+ 1) add type of new file formats
+ enum FileFormats
+ {
+ // Unknown file format
+ FORMAT_UNKNOWN = -1,
+
+ // formats that use magic bytes
+ FORMAT_DUMMY = 0,
+ FORMAT_TOTAL_COUNT
+ };
+
+ 2) add function of new image loader
+ const Dali::ImageLoader::BitmapLoader BITMAP_LOADER_LOOKUP_TABLE[FORMAT_TOTAL_COUNT] =
+ {
+ { 0x0, 0x0, LoadBitmapFromImage, LoadImageHeader, Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS },
+ };
+
+ 3) add file extensions and formats
+ const FormatExtension FORMAT_EXTENSIONS[] =
+ {
+ { ".dummy", FORMAT_DUMMY }
+ };
+
+## Build
+To use the new Image Loader plugin, You must change the use_image_loader value to 1.
+ packaging/dali-extension.spec
+ # Use Image Loader Plugin
+ %define use_image_loader 1
+
+ When you build the dali-extension, dali-extension-image-loader-plugin.armv7l.rpm file is created.
+
--- /dev/null
+image_loader_plugin_src_files = \
+ $(extension_src_dir)/image-loader/tizen-image-loader.cpp \
+ $(extension_src_dir)/image-loader/loader-dummy.cpp
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// HEADER
+#include "loader-dummy.h"
+
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/images/image.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+namespace Plugin
+{
+
+/**
+ * This code is a dummy code. You can implement it here.
+ */
+
+bool LoadImageHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+{
+ bool success = false;
+ /* Loads the header of a image file and fills in the width and height appropriately. */
+
+ return success;
+}
+
+
+bool LoadBitmapFromImage( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+{
+ bool success = false;
+ /* Loads the bitmap from an image file. This function checks the header first */
+
+ return success;
+}
+
+}
+}
--- /dev/null
+#ifndef DALI_TIZEN_EXTENSION_LOADER_DUMMY_H
+#define DALI_TIZEN_EXTENSION_LOADER_DUMMY_H
+
+/*
+ * Copyright (c) 2018 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 <cstdio>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/images/pixel.h>
+#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+
+namespace Dali
+{
+namespace Devel
+{
+class PixelBuffer;
+}
+
+namespace Plugin
+{
+
+class ResourceLoadingClient;
+
+/**
+ * Loads the bitmap from an image file. This function checks the header first
+ * and if it is not a image file, then it returns straight away.
+ * @param[in] input Information about the input image (including file pointer)
+ * @param[out] bitmap The bitmap class where the decoded image will be stored
+ * @return true if file decoded successfully, false otherwise
+ */
+bool LoadBitmapFromImage( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+
+/**
+ * Loads the header of a image file and fills in the width and height appropriately.
+ * @param[in] fp Pointer to the Image file
+ * @param[in] attributes Describes the dimensions, pixel format and other details for loading the image data
+ * @param[out] width Is set with the width of the image
+ * @param[out] height Is set with the height of the image
+ * @return true if the file's header was read successully, false otherwise
+ */
+bool LoadImageHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height );
+
+} // namespace Plugin
+
+} // namespace Dali
+#endif // DALI_TIZEN_EXTENSION_LOADER_DUMMY_H
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <tizen-image-loader.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/bitmap.h>
+#include "loader-dummy.h"
+
+// The plugin factories
+extern "C" DALI_EXPORT_API Dali::ImageLoaderPlugin* CreateImageLoaderPlugin(void)
+{
+ return new Dali::Plugin::TizenImageLoader;
+}
+
+extern "C" DALI_EXPORT_API void DestroyImageLoaderPlugin( Dali::ImageLoaderPlugin* plugin )
+{
+ if( plugin != NULL )
+ {
+ delete plugin;
+ }
+}
+
+namespace Dali
+{
+namespace Plugin
+{
+namespace
+{
+ /**
+ * Enum for file formats, has to be in sync with BITMAP_LOADER_LOOKUP_TABLE
+ */
+ enum FileFormats
+ {
+ // Unknown file format
+ FORMAT_UNKNOWN = -1,
+
+ // formats that use magic bytes
+ FORMAT_DUMMY = 0,
+ FORMAT_TOTAL_COUNT
+ };
+
+ /**
+ * A lookup table containing all the bitmap loaders with the appropriate information.
+ * Has to be in sync with enum FileFormats
+ */
+ const Dali::ImageLoader::BitmapLoader BITMAP_LOADER_LOOKUP_TABLE[FORMAT_TOTAL_COUNT] =
+ {
+ { 0x0, 0x0, LoadBitmapFromImage, LoadImageHeader, Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS },
+ };
+
+
+ struct FormatExtension
+ {
+ const std::string extension;
+ FileFormats format;
+ };
+
+ const FormatExtension FORMAT_EXTENSIONS[] =
+ {
+ { ".dummy", FORMAT_DUMMY }
+ };
+
+ const unsigned int FORMAT_EXTENSIONS_COUNT = sizeof(FORMAT_EXTENSIONS) / sizeof(FormatExtension);
+
+
+ FileFormats GetFormatHint( const std::string& filename )
+ {
+ FileFormats format = FORMAT_UNKNOWN;
+
+ for ( unsigned int i = 0; i < FORMAT_EXTENSIONS_COUNT; ++i )
+ {
+ unsigned int length = FORMAT_EXTENSIONS[i].extension.size();
+ if ( ( filename.size() > length ) &&
+ ( 0 == filename.compare( filename.size() - length, length, FORMAT_EXTENSIONS[i].extension ) ) )
+ {
+ format = FORMAT_EXTENSIONS[i].format;
+ break;
+ }
+ }
+ return format;
+ }
+
+}
+
+TizenImageLoader::TizenImageLoader()
+{
+}
+
+TizenImageLoader::~TizenImageLoader()
+{
+}
+
+const Dali::ImageLoader::BitmapLoader* TizenImageLoader::BitmapLoaderLookup( const std::string& filename ) const
+{
+ const Dali::ImageLoader::BitmapLoader *lookupPtr = BITMAP_LOADER_LOOKUP_TABLE;
+ FileFormats format = GetFormatHint( filename );
+ if ( format != FORMAT_UNKNOWN )
+ {
+ lookupPtr = BITMAP_LOADER_LOOKUP_TABLE + format;
+ return lookupPtr;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+} // namespace Plugin
+
+} // namespace Dali
+
--- /dev/null
+#ifndef DALI_TIZEN_IMAGE_LOADER_PLUGIN_H
+#define DALI_TIZEN_IMAGE_LOADER_PLUGIN_H
+
+/*
+ * Copyright (c) 2018 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 <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/image-loader-plugin.h>
+
+namespace Dali
+{
+
+namespace Plugin
+{
+
+/**
+ * image loading plugin for image loader.
+ */
+class TizenImageLoader : public Dali::ImageLoaderPlugin
+{
+
+public: // Construction & Destruction
+
+ /**
+ * Constructor
+ */
+ TizenImageLoader();
+
+ /**
+ * Destructor
+ */
+ virtual ~TizenImageLoader();
+
+public: // ImageLoaderPlugin overrides
+
+ /**
+ * @copydoc Dali::Plugin::TizenImageLoader::BitmapLoaderLookup()
+ */
+ virtual const Dali::ImageLoader::BitmapLoader* BitmapLoaderLookup( const std::string& filename ) const;
+
+};
+
+} // namespace Plugin
+
+} // namespace Dali
+
+#endif // DALI_TIZEN_IMAGE_LOADER_PLUGIN_H
Web Engine chromium plugin to support WebView for Dali
##############################
+# Dali Image Loader Plugin
+##############################
+
+%package image-loader-plugin
+Summary: Plugin to image loading for Dali
+Group: System/Libraries
+
+%description image-loader-plugin
+Image Loader plugin to image loading file for Dali
+
+##############################
# Preparation
##############################
%prep
%define dali_data_ro_dir %TZ_SYS_RO_SHARE/dali/
%define dev_include_path %{_includedir}
+# Use Image Loader Plugin
+%define use_image_loader 0
+
##############################
# Build
##############################
%configure --prefix=$PREFIX \
--enable-keyextension
+%if 0%{?use_image_loader}
+%configure \
+ --enable-imageloader-extension
+%endif
make %{?jobs:-j%jobs}
/sbin/ldconfig
exit 0
+%post image-loader-plugin
+/sbin/ldconfig
+exit 0
+
##############################
# Pre Uninstall old package
##############################
/sbin/ldconfig
exit 0
+%postun image-loader-plugin
+/sbin/ldconfig
+exit 0
+
##############################
# Files in Binary Packages
##############################
%defattr(-,root,root,-)
%{_libdir}/libdali-web-engine-chromium-plugin.so*
%license LICENSE
+
+%if 0%{?use_image_loader}
+%files image-loader-plugin
+%manifest dali-extension.manifest
+%defattr(-,root,root,-)
+%{_libdir}/libdali-image-loader-plugin.so*
+%license LICENSE
+%endif