2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
23 #include <dali/integration-api/debug.h>
34 namespace ImageLoaderPluginProxy
38 static const char * DEFAULT_OBJECT_NAME( "libdali-image-loader-plugin.so" );
40 static bool mInitializeAttempted = false;
41 static void* mLibHandle = NULL;
42 static CreateImageLoaderPlugin* mCreatePluginFunctionPtr = NULL;
43 static DestroyImageLoaderPlugin* mDestroyImageLoaderPluginPtr = NULL;
44 static Dali::ImageLoaderPlugin* mImageLoaderPlugin = NULL;
48 // Only attempt to load dll once
50 if ( !mInitializeAttempted )
52 mInitializeAttempted = true;
53 mLibHandle = dlopen( DEFAULT_OBJECT_NAME, RTLD_LAZY );
57 DALI_LOG_ERROR( "Cannot load dali image loading plugin library error: %s\n", error );
62 mCreatePluginFunctionPtr = reinterpret_cast<CreateImageLoaderPlugin*>( dlsym( mLibHandle, "CreateImageLoaderPlugin" ) );
64 if( !mCreatePluginFunctionPtr )
66 DALI_LOG_ERROR("Cannot load symbol CreateImageLoaderPlugin(): %s\n", error );
70 mDestroyImageLoaderPluginPtr = reinterpret_cast<DestroyImageLoaderPlugin*>( dlsym( mLibHandle, "DestroyImageLoaderPlugin" ) );
72 if( !mDestroyImageLoaderPluginPtr )
74 DALI_LOG_ERROR("Cannot load symbol DestroyImageLoaderPlugin(): %s\n", error );
79 mImageLoaderPlugin = mCreatePluginFunctionPtr();
81 if( !mImageLoaderPlugin )
83 DALI_LOG_ERROR("Call to function CreateImageLoaderPlugin() failed : %s\n", error );
91 if( mImageLoaderPlugin && mDestroyImageLoaderPluginPtr )
93 mDestroyImageLoaderPluginPtr( mImageLoaderPlugin );
94 mImageLoaderPlugin = NULL;
98 const ImageLoader::BitmapLoader* BitmapLoaderLookup( const std::string& filename )
100 if( mImageLoaderPlugin )
102 const ImageLoader::BitmapLoader* data = mImageLoaderPlugin->BitmapLoaderLookup( filename );
108 } // namespace ImageLoaderPluginProxy
111 } // namespace Adaptor
113 } // namespace Internal