1 #ifndef __DALI_INTEGRATION_SHADER_DATA_H__
2 #define __DALI_INTEGRATION_SHADER_DATA_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
24 #include <dali/public-api/object/ref-object.h>
25 #include <dali/public-api/common/vector-wrapper.h>
35 typedef IntrusivePtr<ShaderData> ShaderDataPtr;
39 * A container for shader source code and compiled binary byte code
41 class DALI_IMPORT_API ShaderData : public Dali::RefObject
46 * @param[in] vertexSource Source code for vertex program
47 * @param[in] fragmentSource Source code for fragment program
49 ShaderData(const std::string& vertexSource, const std::string& fragmentSource);
53 * Protected Destructor
54 * A reference counted object may only be deleted by calling Unreference()
56 virtual ~ShaderData();
60 * Check whether there is a compiled binary available
61 * @return true if this objects contains a compiled binary
63 bool HasBinary() const;
66 * Allocate a buffer for the compiled binary bytecode
67 * @param[in] size The size of the buffer in bytes
69 void AllocateBuffer(const unsigned int size);
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
75 void SetHashValue(size_t shaderHash) { mShaderHash = shaderHash; }
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
81 size_t GetHashValue() { return mShaderHash; }
84 ShaderData(const ShaderData& other); ///< defined private to prevent use
85 ShaderData& operator= (const ShaderData& rhs); ///< defined private to prevent use
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
94 } // namespace Integration
98 #endif // __DALI_INTEGRATION_SHADER_DATA_H__