2 * Copyright (c) 2019 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/vector-animation/common/vector-animation-renderer-plugin-proxy.h>
23 #include <dali/integration-api/debug.h>
37 // The default plugin name
38 const char* DEFAULT_OBJECT_NAME( "libdali-vector-animation-renderer-plugin.so" );
42 VectorAnimationRendererPluginProxy::VectorAnimationRendererPluginProxy( const std::string& sharedObjectName )
43 : mSharedObjectName(),
46 mCreateVectorAnimationRendererPtr( NULL ),
49 if( !sharedObjectName.empty() )
51 mSharedObjectName = sharedObjectName;
55 mSharedObjectName = DEFAULT_OBJECT_NAME;
61 VectorAnimationRendererPluginProxy::~VectorAnimationRendererPluginProxy()
68 if( mLibHandle && dlclose( mLibHandle ) )
70 DALI_LOG_ERROR( "Error closing vector animation renderer plugin library: %s\n", dlerror() );
75 void VectorAnimationRendererPluginProxy::Initialize()
77 mLibHandle = dlopen( mSharedObjectName.c_str(), RTLD_LAZY );
79 char* error = dlerror();
80 if( mLibHandle == NULL || error != NULL )
82 DALI_LOG_ERROR( "VectorAnimationRendererPluginProxy::Initialize: dlopen error [%s]\n", error );
87 mCreateVectorAnimationRendererPtr = reinterpret_cast< CreateVectorAnimationRendererFunction >( dlsym( mLibHandle, "CreateVectorAnimationRendererPlugin" ) );
90 if( mCreateVectorAnimationRendererPtr == NULL || error != NULL )
92 DALI_LOG_ERROR( "VectorAnimationRendererPluginProxy::Initialize: Cannot load symbol: %s\n", error );
96 mPlugin = mCreateVectorAnimationRendererPtr();
99 DALI_LOG_ERROR("VectorAnimationRendererPluginProxy::Initialize: Plugin creation failed\n");
104 bool VectorAnimationRendererPluginProxy::Initialize( const std::string& url )
108 return mPlugin->Initialize( url );
113 void VectorAnimationRendererPluginProxy::SetRenderer( Dali::Renderer renderer )
117 mPlugin->SetRenderer( renderer );
121 void VectorAnimationRendererPluginProxy::SetSize( uint32_t width, uint32_t height )
125 mPlugin->SetSize( width, height );
129 bool VectorAnimationRendererPluginProxy::Render( uint32_t frameNumber )
133 return mPlugin->Render( frameNumber );
138 uint32_t VectorAnimationRendererPluginProxy::GetTotalFrameNumber() const
142 return mPlugin->GetTotalFrameNumber();
147 float VectorAnimationRendererPluginProxy::GetFrameRate() const
151 return mPlugin->GetFrameRate();
156 void VectorAnimationRendererPluginProxy::GetDefaultSize( uint32_t& width, uint32_t& height ) const
160 mPlugin->GetDefaultSize( width, height );
164 VectorAnimationRendererPlugin::UploadCompletedSignalType& VectorAnimationRendererPluginProxy::UploadCompletedSignal()
168 return mPlugin->UploadCompletedSignal();
170 return mDefaultSignal;
173 } // namespace Adaptor
175 } // namespace Internal