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/internal/common/owner-container.h>
23 #include <dali/internal/render/shaders/program.h>
24 #include <dali/internal/render/shaders/program-cache.h>
35 * This class is the owner of GL shader programs
37 class ProgramController : public ProgramCache
42 * Wrapper for a program and its hash code
53 ProgramPair( Program* program, size_t shaderHash )
54 : mProgram( program ), mShaderHash( shaderHash )
58 * Destructor, non-virtual as not a base
66 * Inline getter for the program
69 inline Program* GetProgram()
75 * Inline getter for the hash
78 inline size_t GetHash()
83 private: // Not implemented
84 ProgramPair( const ProgramPair& );
85 ProgramPair& operator=( const ProgramPair& );
94 * @param postProcessDispatcher to send save binary message back to update
96 ProgramController( Integration::GlAbstraction& glAbstraction );
99 * Destructor, non virtual as not a base class
101 ~ProgramController();
106 * Resets the program matrices. Must be called at the beginning of every frame
108 void ResetProgramMatrices();
111 * Notifies the cache that context is (re)created
113 void GlContextCreated();
116 * Notifies cache that context is lost
118 void GlContextDestroyed();
121 * Set the destination for compiler shader binaries so they can be saved.
122 * @note Must be called during initialisation.
124 void SetShaderSaver( ShaderSaver& shaderSaver );
126 private: // From ProgramCache
129 * @copydoc ProgramCache::GetGlAbstraction
131 virtual Integration::GlAbstraction& GetGlAbstraction();
134 * @copydoc ProgramCache::GetProgram
136 virtual Program* GetProgram( size_t shaderHash );
139 * @copydoc ProgramCache::AddProgram
141 virtual void AddProgram( size_t shaderHash, Program* program );
144 * @copydoc ProgramCache::GetCurrentProgram
146 virtual Program* GetCurrentProgram();
149 * @copydoc ProgramCache::SetCurrentProgram
151 virtual void SetCurrentProgram( Program* program );
154 * @copydoc ProgramCache::IsBinarySupported
156 virtual bool IsBinarySupported();
159 * @copydoc ProgramCache::ProgramBinaryFormat
161 virtual GLenum ProgramBinaryFormat();
164 * @copydoc ProgramCache::StoreBinary
166 virtual void StoreBinary( Internal::ShaderDataPtr programData );
168 private: // not implemented as non-copyable
170 ProgramController( const ProgramController& rhs );
171 ProgramController& operator=( const ProgramController& rhs );
175 ShaderSaver* mShaderSaver;
176 Integration::GlAbstraction& mGlAbstraction;
177 Program* mCurrentProgram;
179 typedef OwnerContainer< ProgramPair* > ProgramContainer;
180 typedef ProgramContainer::Iterator ProgramIterator;
181 ProgramContainer mProgramCache;
183 GLint mProgramBinaryFormat;
184 GLint mNumberOfProgramBinaryFormats;
188 } // namespace Internal
192 #endif // __DALI_INTERNAL_PROGRAM_CONTROLLER_H__