Added object sizes to platform abstraction in profiling section
[platform/core/uifw/dali-core.git] / dali / integration-api / shader-data.h
1 #ifndef __DALI_INTEGRATION_SHADER_DATA_H__
2 #define __DALI_INTEGRATION_SHADER_DATA_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // EXTERNAL INCLUDES
21 #include <string>
22
23 // INTERNAL INCLUDES
24 #include <dali/public-api/object/ref-object.h>
25 #include <dali/public-api/common/vector-wrapper.h>
26
27 namespace Dali
28 {
29
30 namespace Integration
31 {
32
33 class ShaderData;
34
35 typedef IntrusivePtr<ShaderData> ShaderDataPtr;
36
37 /**
38  * ShaderData class.
39  * A container for shader source code and compiled binary byte code
40  */
41 class DALI_IMPORT_API ShaderData : public Dali::RefObject
42 {
43 public:
44   /**
45    * Constructor
46    * @param[in] vertexSource   Source code for vertex program
47    * @param[in] fragmentSource Source code for fragment program
48    */
49   ShaderData(const std::string& vertexSource, const std::string& fragmentSource);
50
51 protected:
52   /**
53    * Protected Destructor
54    * A reference counted object may only be deleted by calling Unreference()
55    */
56   virtual ~ShaderData();
57
58 public:
59   /**
60    * Check whether there is a compiled binary available
61    * @return true if this objects contains a compiled binary
62    */
63   bool HasBinary() const;
64
65   /**
66    * Allocate a buffer for the compiled binary bytecode
67    * @param[in] size  The size of the buffer in bytes
68    */
69   void AllocateBuffer(const unsigned int size);
70
71   /**
72    * Set hash value which is created with vertex and fragment shader code
73    * @param [in] shaderHash  hash key created with vertex and fragment shader code
74    */
75   void SetHashValue(size_t shaderHash) { mShaderHash = shaderHash; }
76
77   /**
78    * Get hash value which is created with vertex and fragment shader code
79    * @return shaderHash  hash key created with vertex and fragment shader code
80    */
81   size_t GetHashValue() { return mShaderHash; }
82
83 private:
84   ShaderData(const ShaderData& other);            ///< defined private to prevent use
85   ShaderData& operator= (const ShaderData& rhs);  ///< defined private to prevent use
86
87 public: // Attributes
88   size_t                     mShaderHash;         ///< hash key created with vertex and fragment shader code
89   const std::string          vertexShader;        ///< source code for vertex program
90   const std::string          fragmentShader;      ///< source code for fragment program
91   std::vector<unsigned char> buffer;              ///< buffer containing compiled binary bytecode
92 };
93
94 } // namespace Integration
95
96 } // namespace Dali
97
98 #endif // __DALI_INTEGRATION_SHADER_DATA_H__