f2334039ad1371f8efae20fcddf163719cb0440e
[platform/core/uifw/dali-adaptor.git] / dali / internal / vector-image / common / vector-image-renderer-plugin-proxy.h
1 #ifndef DALI_INTERNAL_VECTOR_IMAGE_RENDERER_PLUGIN_PROXY_H
2 #define DALI_INTERNAL_VECTOR_IMAGE_RENDERER_PLUGIN_PROXY_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/vector-image-renderer-plugin.h>
23 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
24 #include <memory>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace Adaptor
33 {
34
35 /**
36  * Proxy class to dynamically load, use and unload vector image renderer plugin.
37  */
38 class VectorImageRendererPluginProxy
39 {
40 public:
41
42   /**
43    * @brief Constructor
44    */
45   VectorImageRendererPluginProxy( std::string sharedObjectName );
46
47   /**
48    * @brief Destructor
49    */
50   ~VectorImageRendererPluginProxy();
51
52   /**
53    * @copydoc Dali::VectorImageRendererPlugin::Initialize()
54    */
55   bool Initialize();
56
57   /**
58    * @copydoc Dali::VectorImageRendererPlugin::SetBuffer()
59    */
60   void SetBuffer( Dali::Devel::PixelBuffer &buffer );
61
62   /**
63    * @copydoc Dali::VectorImageRendererPlugin::Render()
64    */
65   bool Render(float scale);
66
67   /**
68    * @copydoc Dali::VectorImageRendererPlugin::Load()
69    */
70   bool Load( const std::string& url );
71
72   /**
73    * @copydoc Dali::VectorImageRendererPlugin::Load()
74    */
75   bool Load( const char *data, uint32_t size );
76
77   /**
78    * @copydoc Dali::VectorImageRendererPlugin::GetDefaultSize()
79    */
80   void GetDefaultSize( uint32_t& width, uint32_t& height ) const;
81
82   // Not copyable or movable
83   VectorImageRendererPluginProxy( const VectorImageRendererPluginProxy& ) = delete; ///< Deleted copy constructor
84   VectorImageRendererPluginProxy( VectorImageRendererPluginProxy&& ) = delete; ///< Deleted move constructor
85   VectorImageRendererPluginProxy& operator=( const VectorImageRendererPluginProxy& ) = delete; ///< Deleted copy assignment operator
86   VectorImageRendererPluginProxy& operator=( VectorImageRendererPluginProxy&& ) = delete; ///< Deleted move assignment operator
87
88 private:
89
90   /**
91    * Dynamically loads the plugin.
92    */
93   void InitializePlugin();
94
95 private:
96
97   using CreateVectorImageRendererFunction = Dali::VectorImageRendererPlugin* (*)();
98
99   std::string                        mSharedObjectName;   ///< Shared object name
100   void*                              mLibHandle;          ///< Handle for the loaded library
101   Dali::VectorImageRendererPlugin*   mPlugin;             ///< Plugin handle
102
103   CreateVectorImageRendererFunction  mCreateVectorImageRendererPtr;   ///< Function pointer called in adaptor to create a plugin instance
104
105 };
106
107 } // namespace Adaptor
108
109 } // namespace Internal
110
111 } // namespace Dali
112
113 #endif // DALI_INTERNAL_VECTOR_IMAGE_RENDERER_PLUGIN_PROXY_H