Dali 3D User Interface Engine
shader-data.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_SHADER_DATA_H__
2 #define __DALI_INTERNAL_SHADER_DATA_H__
3 
4 /*
5  * Copyright (c) 2015 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 <string>
23 
24 // INTERNAL INCLUDES
27 #include <dali/devel-api/rendering/shader.h> // ShaderHints
28 
29 namespace Dali
30 {
31 
32 namespace Internal
33 {
34 
35 class ShaderData;
37 
43 {
44 public:
45 
51  ShaderData(const std::string& vertexSource, const std::string& fragmentSource, const Dali::Shader::ShaderHints hints)
52  : mShaderHash( -1 ),
53  mVertexShader(vertexSource),
54  mFragmentShader(fragmentSource),
55  mHints(hints)
56  { }
57 
58 protected:
63  virtual ~ShaderData()
64  {
65  // vector releases its data
66  }
67 
68 public: // API
69 
74  void SetHashValue(size_t shaderHash)
75  {
76  DALI_ASSERT_DEBUG( shaderHash != size_t(-1) );
77  mShaderHash = shaderHash;
78  }
79 
84  size_t GetHashValue() const
85  {
86  DALI_ASSERT_DEBUG( mShaderHash != size_t(-1) );
87  return mShaderHash;
88  }
89 
93  const char* GetVertexShader() const
94  {
95  return mVertexShader.c_str();
96  }
97 
101  const char* GetFragmentShader() const
102  {
103  return mFragmentShader.c_str();
104  }
105 
110  {
111  return mHints;
112  }
117  bool HasBinary() const
118  {
119  return 0 != mBuffer.Size();
120  }
121 
126  void AllocateBuffer( size_t size )
127  {
128  mBuffer.Resize( size );
129  }
130 
135  size_t GetBufferSize() const
136  {
137  return mBuffer.Size();
138  }
139 
144  unsigned char* GetBufferData()
145  {
146  DALI_ASSERT_DEBUG( mBuffer.Size() > 0 );
147  return &mBuffer[0];
148  }
149 
155  {
156  return mBuffer;
157  }
158 
159 private: // Not implemented
160 
161  ShaderData(const ShaderData& other);
162  ShaderData& operator= (const ShaderData& rhs);
163 
164 private: // Data
165 
166  size_t mShaderHash;
167  std::string mVertexShader;
168  std::string mFragmentShader;
171 };
172 
173 } // namespace Integration
174 
175 } // namespace Dali
176 
177 #endif // __DALI_INTERNAL_SHADER_DATA_H__
Dali Docs Home
Read more about Dali