Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / dali / internal / render / shaders / program-cache.h
1 #ifndef __DALI_INTERNAL_PROGRAM_CACHE_H__
2 #define __DALI_INTERNAL_PROGRAM_CACHE_H__
3
4 /*
5  * Copyright (c) 2014 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 // INTERNAL INCLUDES
22 #include <dali/integration-api/gl-abstraction.h> // for GLenum
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 class Program;
31
32 /**
33  * This class is interface for caching Program objects
34  */
35 class ProgramCache
36 {
37 public:
38
39   /**
40    * Constructor
41    */
42   ProgramCache()
43   { }
44
45   /**
46    * Destructor, virtual as this is an interface
47    */
48   virtual ~ProgramCache()
49   { }
50
51 public: // API
52
53   /**
54    * @return GlAbstraction
55    */
56   virtual Integration::GlAbstraction& GetGlAbstraction() = 0;
57
58   /**
59    * Get the program from cache with hash
60    * @param shaderHash to use
61    * @return program
62    */
63   virtual Program* GetProgram( size_t shaderHash ) = 0;
64
65   /**
66    * Add a program to cache
67    * @param shaderHash of the program
68    * @param program to add
69    */
70   virtual void AddProgram( size_t shaderHash, Program* program ) = 0;
71
72   /**
73    * Get currently bound program
74    * @return program that is currently used
75    */
76   virtual Program* GetCurrentProgram() = 0;
77
78   /**
79    * Set the currently bound program
80    * @param program that is used
81    */
82   virtual void SetCurrentProgram( Program* program ) = 0;
83
84   /**
85    * @return true if program binaries are supported
86    */
87   virtual bool IsBinarySupported() = 0;
88
89   /**
90    * @return the binary format to use
91    */
92   virtual GLenum ProgramBinaryFormat() = 0;
93
94   /**
95    * @param programData to store/save
96    */
97   virtual void StoreBinary( Internal::ShaderDataPtr programData ) = 0;
98
99 private: // not implemented as non-copyable
100
101   ProgramCache( const ProgramCache& rhs );
102   ProgramCache& operator=( const ProgramCache& rhs );
103
104 };
105
106
107 } // namespace Internal
108
109 } // namespace Dali
110
111 #endif // __DALI_INTERNAL_PROGRAM_CACHE_H__
112