c288cd1b0b0afc9cc3980770b160aaab6d11a0b7
[platform/core/uifw/dali-adaptor.git] / dali / internal / legacy / common / tizen-platform-abstraction.h
1 #ifndef DALI_TIZEN_PLATFORM_ABSTRACTION_H
2 #define DALI_TIZEN_PLATFORM_ABSTRACTION_H
3
4 /*
5  * Copyright (c) 2019 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/public-api/adaptor-framework/timer.h>
23 #include <dali/public-api/dali-adaptor-common.h>
24
25
26 // EXTERNAL INCLUDES
27 #include <cstdint>
28 #include <string>
29 #include <dali/integration-api/platform-abstraction.h>
30
31 namespace Dali
32 {
33
34 class CallbackBase;
35
36 namespace TizenPlatform
37 {
38 class ResourceLoader;
39
40 /**
41  * Concrete implementation of the platform abstraction class.
42  */
43 class TizenPlatformAbstraction : public Integration::PlatformAbstraction
44 {
45
46 public: // Construction & Destruction
47
48   /**
49    * Constructor
50    */
51   TizenPlatformAbstraction();
52
53   /**
54    * Destructor
55    */
56   virtual ~TizenPlatformAbstraction();
57
58 public: // PlatformAbstraction overrides
59
60   /**
61    * @copydoc PlatformAbstraction::GetClosestImageSize()
62    */
63   virtual ImageDimensions GetClosestImageSize( const std::string& filename,
64                                                ImageDimensions size,
65                                                FittingMode::Type fittingMode,
66                                                SamplingMode::Type samplingMode,
67                                                bool orientationCorrection );
68
69   /**
70    * @copydoc PlatformAbstraction::GetClosestImageSize()
71    */
72   virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
73                                                ImageDimensions size,
74                                                FittingMode::Type fittingMode,
75                                                SamplingMode::Type samplingMode,
76                                                bool orientationCorrection );
77
78   /**
79    * @copydoc PlatformAbstraction::LoadImageSynchronously()
80    */
81   virtual Integration::ResourcePointer LoadImageSynchronously(const Integration::BitmapResourceType& resource, const std::string& resourcePath);
82
83   /**
84    * @copydoc PlatformAbstraction::DecodeBuffer()
85    */
86   virtual Integration::BitmapPtr DecodeBuffer( const Integration::BitmapResourceType& resource, uint8_t * buffer, size_t size );
87
88   /**
89    * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
90    */
91   virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
92
93   /**
94    * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
95    */
96   virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const;
97
98   /**
99    * @copydoc PlatformAbstraction::StartTimer()
100    */
101   virtual uint32_t StartTimer( uint32_t milliseconds, CallbackBase* callback );
102
103   /**
104    * @copydoc PlatformAbstraction::CancelTimer()
105    */
106   virtual void CancelTimer ( uint32_t timerId );
107
108   /**
109    * Sets path for data/resource storage.
110    * @param[in] path data/resource storage path
111    */
112   void SetDataStoragePath( const std::string& path );
113
114   /**
115    * Clears the timers that have completed
116    */
117   void CleanupTimers();
118
119 private:
120
121   struct TimerCallback;
122
123   /*
124    * Executes callback function and cleans up timer
125    */
126   void RunTimerFunction(TimerCallback& timerPtr);
127
128   TizenPlatformAbstraction( const TizenPlatformAbstraction& ); ///< Undefined
129   TizenPlatformAbstraction& operator=( const TizenPlatformAbstraction& ); ///< Undefined
130
131   std::string mDataStoragePath;
132
133   std::vector<TimerCallback*> mTimerPairsWaiting;
134   std::vector<TimerCallback*> mTimerPairsSpent;
135 };
136
137 /**
138  * Construct a platform abstraction and return it.
139  * @return TizenPlatformAbstraction instance
140  */
141 TizenPlatformAbstraction* CreatePlatformAbstraction();
142
143 /**
144  * Save a file to disk
145  * @param filename to create
146  * @param buffer to store
147  * @param numBytes to store
148  * @return true if successful, false otherwise
149  */
150 bool SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes );
151
152 }  // namespace TizenPlatform
153
154 }  // namespace Dali
155
156 #endif // DALI_TIZEN_PLATFORM_ABSTRACTION_H