Revert "[Tizen] Fix build errors in adaptor-uv by ecore wayland"
[platform/core/uifw/dali-adaptor.git] / platform-abstractions / emscripten / emscripten-platform-abstraction.h
1 #ifndef __DALI_EMSCRIPTEN_PLATFORM_ABSTRACTION_H__
2 #define __DALI_EMSCRIPTEN_PLATFORM_ABSTRACTION_H__
3
4 /*
5  * Copyright (c) 2016 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 // EXTERNAL INCLUDES
22 #include <set>
23 #include <stdint.h>
24 #include <cstring>
25 #include <queue>
26
27 // INTERNAL INCLUDES
28 #include <dali/integration-api/platform-abstraction.h>
29 #include <dali/integration-api/bitmap.h>
30
31 namespace Dali
32 {
33
34 namespace Integration
35 {
36
37 typedef IntrusivePtr<Dali::RefObject> ResourcePointer;
38 } // namespace Integration
39
40 /**
41  * An Dali Platform abstraction using libSDL for Emscripten.
42  *
43  * Emscripten already wraps the SDL API so we can use this API to create windows/canvas in the browser
44  *
45  */
46 class DALI_IMPORT_API EmscriptenPlatformAbstraction : public Dali::Integration::PlatformAbstraction
47 {
48
49 public:
50
51   struct LoadFileResult
52   {
53     LoadFileResult()
54     : loadResult(false)
55     {
56
57     }
58
59     bool loadResult;
60     std::vector< unsigned char> buffer;
61   };
62
63
64   /**
65    * Constructor
66    */
67   EmscriptenPlatformAbstraction();
68
69
70   /**
71    * Destructor
72    */
73   virtual ~EmscriptenPlatformAbstraction();
74
75   /**
76    * @copydoc PlatformAbstraction::GetTimeMicroseconds()
77    */
78   virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int &microSeconds);
79
80   void IncrementGetTimeResult(size_t milliseconds);
81
82   /**
83    * @copydoc PlatformAbstraction::GetClosestImageSize()
84    */
85   virtual ImageDimensions GetClosestImageSize( const std::string& filename,
86                                                ImageDimensions size,
87                                                FittingMode::Type fittingMode,
88                                                SamplingMode::Type samplingMode,
89                                                bool orientationCorrection );
90   /**
91    * @copydoc PlatformAbstraction::GetClosestImageSize()
92    */
93   virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
94                                                ImageDimensions size,
95                                                FittingMode::Type fittingMode,
96                                                SamplingMode::Type samplingMode,
97                                                bool orientationCorrection );
98
99   /**
100    * @copydoc PlatformAbstraction::LoadResourceSynchronously()
101    */
102   virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
103
104   /**
105    * @copydoc PlatformAbstraction::DecodeBuffer()
106    */
107   virtual Integration::BitmapPtr DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t bufferSize );
108
109   /**
110    * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
111    */
112   virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
113
114   /**
115    * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
116    */
117   virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const;
118
119   /**
120    * @copydoc PlatformAbstraction::UpdateDefaultsFromDevice()
121    */
122   virtual void UpdateDefaultsFromDevice();
123
124 private:
125   std::string                   mGetDefaultFontFamilyResult;
126   Vector2                       mSize;
127
128   LoadFileResult                mLoadFileResult;
129
130   typedef std::pair< Integration::ResourceId, Integration::BitmapPtr > ResourceIdBitmapPair;
131   std::queue<ResourceIdBitmapPair> mResourceQueue;
132
133 };
134
135 } // Dali
136
137 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */