1 #ifndef __DALI_INTERNAL_PROGRAM_CONTROLLER_H__
2 #define __DALI_INTERNAL_PROGRAM_CONTROLLER_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/devel-api/common/owner-container.h>
23 #include <dali/internal/common/shader-data.h>
24 #include <dali/internal/render/shaders/program.h>
25 #include <dali/internal/render/shaders/program-cache.h>
36 * This class is the owner of GL shader programs
38 class ProgramController : public ProgramCache
43 * Wrapper for a program and its hash code
54 ProgramPair( Program* program, size_t shaderHash )
55 : mProgram( program ), mShaderHash( shaderHash )
59 * Destructor, non-virtual as not a base
67 * Inline getter for the program
70 inline Program* GetProgram()
76 * Inline getter for the hash
79 inline size_t GetHash()
84 private: // Not implemented
85 ProgramPair( const ProgramPair& );
86 ProgramPair& operator=( const ProgramPair& );
95 * @param postProcessDispatcher to send save binary message back to update
97 ProgramController( Integration::GlAbstraction& glAbstraction );
100 * Destructor, non virtual as not a base class
102 ~ProgramController();
107 * Resets the program matrices. Must be called at the beginning of every frame
109 void ResetProgramMatrices();
112 * Notifies the cache that context is (re)created
114 void GlContextCreated();
117 * Notifies cache that context is lost
119 void GlContextDestroyed();
122 * Set the destination for compiler shader binaries so they can be saved.
123 * @note Must be called during initialisation.
125 void SetShaderSaver( ShaderSaver& shaderSaver );
127 private: // From ProgramCache
130 * @copydoc ProgramCache::GetGlAbstraction
132 virtual Integration::GlAbstraction& GetGlAbstraction();
135 * @copydoc ProgramCache::GetProgram
137 virtual Program* GetProgram( size_t shaderHash );
140 * @copydoc ProgramCache::AddProgram
142 virtual void AddProgram( size_t shaderHash, Program* program );
145 * @copydoc ProgramCache::GetCurrentProgram
147 virtual Program* GetCurrentProgram();
150 * @copydoc ProgramCache::SetCurrentProgram
152 virtual void SetCurrentProgram( Program* program );
155 * @copydoc ProgramCache::IsBinarySupported
157 virtual bool IsBinarySupported();
160 * @copydoc ProgramCache::ProgramBinaryFormat
162 virtual GLenum ProgramBinaryFormat();
165 * @copydoc ProgramCache::StoreBinary
167 virtual void StoreBinary( Internal::ShaderDataPtr programData );
169 private: // not implemented as non-copyable
171 ProgramController( const ProgramController& rhs );
172 ProgramController& operator=( const ProgramController& rhs );
176 ShaderSaver* mShaderSaver;
177 Integration::GlAbstraction& mGlAbstraction;
178 Program* mCurrentProgram;
180 typedef OwnerContainer< ProgramPair* > ProgramContainer;
181 typedef ProgramContainer::Iterator ProgramIterator;
182 ProgramContainer mProgramCache;
184 GLint mProgramBinaryFormat;
185 GLint mNumberOfProgramBinaryFormats;
189 } // namespace Internal
193 #endif // __DALI_INTERNAL_PROGRAM_CONTROLLER_H__