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>
34 class PostProcessResourceDispatcher;
38 * This class is the owner of GL shader programs
40 class ProgramController : public ProgramCache
45 * Wrapper for a program and its hash code
56 ProgramPair( Program* program, size_t shaderHash )
57 : mProgram( program ), mShaderHash( shaderHash )
61 * Destructor, non-virtual as not a base
69 * Inline getter for the program
72 inline Program* GetProgram()
78 * Inline getter for the hash
81 inline size_t GetHash()
86 private: // Not implemented
87 ProgramPair( const ProgramPair& );
88 ProgramPair& operator=( const ProgramPair& );
97 * @param postProcessDispatcher to send save binary message back to update
99 ProgramController( SceneGraph::PostProcessResourceDispatcher& postProcessDispatcher, Integration::GlAbstraction& glAbstraction );
102 * Destructor, non virtual as not a base class
104 ~ProgramController();
109 * Resets the program matrices. Must be called at the beginning of every frame
111 void ResetProgramMatrices();
114 * Notifies the cache that context is (re)created
116 void GlContextCreated();
119 * Notifies cache that context is lost
121 void GlContextDestroyed();
123 private: // From ProgramCache
126 * @copydoc ProgramCache::GetGlAbstraction
128 virtual Integration::GlAbstraction& GetGlAbstraction();
131 * @copydoc ProgramCache::GetProgram
133 virtual Program* GetProgram( size_t shaderHash );
136 * @copydoc ProgramCache::AddProgram
138 virtual void AddProgram( size_t shaderHash, Program* program );
141 * @copydoc ProgramCache::GetCurrentProgram
143 virtual Program* GetCurrentProgram();
146 * @copydoc ProgramCache::SetCurrentProgram
148 virtual void SetCurrentProgram( Program* program );
151 * @copydoc ProgramCache::IsBinarySupported
153 virtual bool IsBinarySupported();
156 * @copydoc ProgramCache::ProgramBinaryFormat
158 virtual GLenum ProgramBinaryFormat();
161 * @copydoc ProgramCache::StoreBinary
163 virtual void StoreBinary( Integration::ShaderDataPtr programData );
165 private: // not implemented as non-copyable
167 ProgramController( const ProgramController& rhs );
168 ProgramController& operator=( const ProgramController& rhs );
172 SceneGraph::PostProcessResourceDispatcher& mPostProcessDispatcher;
173 Integration::GlAbstraction& mGlAbstraction;
174 Program* mCurrentProgram;
176 typedef OwnerContainer< ProgramPair* > ProgramContainer;
177 typedef ProgramContainer::Iterator ProgramIterator;
178 ProgramContainer mProgramCache;
180 GLint mProgramBinaryFormat;
181 GLint mNumberOfProgramBinaryFormats;
185 } // namespace Internal
189 #endif // __DALI_INTERNAL_PROGRAM_CONTROLLER_H__