Change "SLP" to "Tizen"
[platform/core/uifw/dali-adaptor.git] / platform-abstractions / tizen / tizen-platform-abstraction.h
1 #ifndef __DALI_TIZEN_PLATFORM_ABSTRACTION_H__
2 #define __DALI_TIZEN_PLATFORM_ABSTRACTION_H__
3
4 /*
5  * Copyright (c) 2014 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 #include <dali/integration-api/platform-abstraction.h>
22 #include <dali/integration-api/resource-cache.h>
23 #include <dali/public-api/common/dali-common.h>
24
25 #include <ft2build.h>
26 #include FT_FREETYPE_H
27 #include <string>
28
29 namespace Dali
30 {
31
32 /**
33  * Construct a platform abstraction and return it.
34  */
35 Integration::PlatformAbstraction* CreatePlatformAbstraction();
36
37 namespace TizenPlatform
38 {
39
40 class DynamicsFactory;
41 class ResourceLoader;
42
43 /**
44  * Concrete implementation of the platform abstraction class.
45  */
46 class TizenPlatformAbstraction : public Integration::PlatformAbstraction
47 {
48
49 public: // Construction & Destruction
50
51   /**
52    * Constructor
53    */
54   TizenPlatformAbstraction();
55
56   /**
57    * Destructor
58    */
59   virtual ~TizenPlatformAbstraction();
60
61 public: // PlatformAbstraction overrides
62
63   /**
64    * @copydoc PlatformAbstraction::GetTimeMicroseconds()
65    */
66   virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int &microSeconds);
67
68   /**
69    * @copydoc PlatformAbstraction::Suspend()
70    */
71   virtual void Suspend();
72
73   /**
74    * @copydoc PlatformAbstraction::Resume()
75    */
76   virtual void Resume();
77
78   /**
79    * @copydoc PlatformAbstraction::GetClosestImageSize()
80    */
81   virtual void GetClosestImageSize( const std::string& filename,
82                                     const ImageAttributes& attributes,
83                                     Vector2& closestSize );
84
85   /**
86    * @copydoc PlatformAbstraction::GetClosestImageSize()
87    */
88   virtual void GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
89                                     const ImageAttributes& attributes,
90                                     Vector2& closestSize );
91
92   /**
93    * @copydoc PlatformAbstraction::LoadResource()
94    */
95   virtual void LoadResource(const Integration::ResourceRequest& request);
96
97   /**
98    * @copydoc PlatformAbstraction::LoadResourceSynchronously()
99    */
100   virtual Integration::ResourcePointer LoadResourceSynchronously(const Integration::ResourceType& resourceType, const std::string& resourcePath);
101
102   /**
103    * @copydoc PlatformAbstraction::SaveResource()
104    */
105   virtual void SaveResource(const Integration::ResourceRequest& request);
106
107   /**
108    * @copydoc PlatformAbstraction::CancelLoad()
109    */
110   virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
111
112   /**
113    * @copydoc PlatformAbstraction::GetResources()
114    */
115   virtual void GetResources(Integration::ResourceCache& cache);
116
117   /**
118    * @copydoc PlatformAbstraction::IsLoading()
119    */
120   virtual bool IsLoading();
121
122   /**
123    * @copydoc PlatformAbstraction::JoinLoaderThreads()
124    */
125   virtual void JoinLoaderThreads();
126
127   /**
128    *@copydoc PlatformAbstraction::GetDefaultFontFamily()
129    */
130   virtual const std::string& GetDefaultFontFamily() const;
131
132   /**
133    *@copydoc PlatformAbstraction::GetDefaultFontSize()
134    */
135   virtual float GetDefaultFontSize() const;
136
137   /**
138    *@copydoc PlatformAbstraction::GetFontLineHeightFromCapsHeight()
139    */
140   virtual PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const;
141
142   /**
143    * @copydoc PlatformAbstraction::GetGlyphData()
144    */
145   virtual Integration::GlyphSet* GetGlyphData ( const Dali::Integration::TextResourceType& textRequest,
146                                                 const std::string& fontFamily,
147                                                 bool getBitmap) const;
148
149   /**
150    * @copydoc PlatformAbstraction::GetCachedGlyphData()
151    */
152   virtual Integration::GlyphSet* GetCachedGlyphData( const Integration::TextResourceType& textRequest,
153                                                      const std::string& fontFamily ) const;
154
155   /**
156    * @copydoc PlatformAbstraction::GetGlobalMetrics()
157    */
158   virtual void GetGlobalMetrics( const std::string& fontFamily,
159                                  const std::string& fontStyle,
160                                  Integration::GlobalMetrics& globalMetrics ) const;
161
162   /**
163    * @copydoc PlatformAbstraction::SetDpi()
164    */
165   virtual void SetDpi (unsigned int DpiHorizontal, unsigned int DpiVertical);
166
167   /**
168    * @copydoc PlatformAbstraction::GetFontFamilyForChars()
169    */
170   const std::string& GetFontFamilyForChars(const Integration::TextArray& charsRequested) const;
171
172   /**
173    * @copydoc PlatformAbstraction::AllGlyphsSupported()
174    */
175   bool AllGlyphsSupported(const std::string &fontFamily, const std::string& fontStyle, const Integration::TextArray& charsRequested) const;
176
177   /**
178    * @copydoc PlatformAbstraction::ValidateFontFamilyName()
179    */
180   virtual bool ValidateFontFamilyName( const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const;
181
182   /**
183    * @copydoc PlatformAbstraction::GetFontList()
184    */
185   virtual void GetFontList ( Dali::Integration::PlatformAbstraction::FontListMode mode, std::vector<std::string>& fontList ) const;
186
187   /**
188    * @copydoc PlatformAbstraction::LoadFile()
189    */
190   virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const;
191
192   /**
193    * @copydoc PlatformAbstraction::LoadFile()
194    */
195   virtual std::string LoadFile( const std::string& filename );
196
197   /**
198    * @copydoc PlatformAbstraction::SaveFile()
199    */
200   virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const;
201
202   /**
203    * @copydoc PlatformAbstraction::UpdateDefaultsFromDevice();
204    */
205   virtual void UpdateDefaultsFromDevice();
206
207   /**
208    * @copydoc PlatformAbstraction::GetDynamicsFactory();
209    */
210   virtual Integration::DynamicsFactory* GetDynamicsFactory();
211
212   /**
213    * @copydoc PlatformAbstraction::ReadGlobalMetricsFromCacheFile
214    */
215   virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily,
216                                            const std::string& fontStyle,
217                                            Integration::GlobalMetrics& globalMetrics );
218
219   /**
220    * @copydoc PlatformAbstraction::WriteGlobalMetricsToCacheFile
221    */
222   virtual void WriteGlobalMetricsToCache( const std::string& fontFamily,
223                                           const std::string& fontStyle,
224                                           const Integration::GlobalMetrics& globalMetrics );
225
226   /**
227    * @copydoc PlatformAbstraction::ReadMetricsFromCacheFile
228    */
229   virtual bool ReadMetricsFromCache( const std::string& fontFamily,
230                                      const std::string& fontStyle,
231                                      std::vector<Integration::GlyphMetrics>& glyphMetricsContainer );
232
233   /**
234    * @copydoc PlatformAbstraction::WriteMetricsToCacheFile
235    */
236   virtual void WriteMetricsToCache( const std::string& fontFamily,
237                                     const std::string& fontStyle,
238                                     const Integration::GlyphSet& glyphSet );
239
240   /**
241    * @copydoc PlatformAbstraction::GetFileNamesFromDirectory()
242    */
243   virtual void GetFileNamesFromDirectory( const std::string& directoryName,
244                                           std::vector<std::string>& fileNames );
245
246   /**
247    * @copydoc PlatformAbstraction::GetGlyphImage()
248    */
249   virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const;
250
251   /**
252    * @copydoc PlatformAbstraction::LoadShaderBinFile()
253    */
254   virtual bool LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const;
255
256   /**
257    * Sets path for data/resource storage.
258    * @param[in] path data/resource storage path
259    */
260   void SetDataStoragePath( const std::string& path );
261
262 private:
263   ResourceLoader* mResourceLoader;
264   DynamicsFactory* mDynamicsFactory;
265   FT_Library mFreeTypeHandle;       ///< Freetype library
266   std::string mDefaultFontFamily;
267   std::string mDefaultFontStyle;
268   std::string mDefaultThemeFile;
269   std::string mDataStoragePath;
270   float mDefaultFontSize;
271 };
272
273 }  // namespace TizenPlatform
274 }  // namespace Dali
275
276 #endif // __DALI_TIZEN_PLATFORM_ABSTRACTION_H__