Merge "Use existing callback ID for recurring callbacks" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / gl-extensions.h
1 #ifndef DALI_INTERNAL_GL_EXTENSION_H
2 #define DALI_INTERNAL_GL_EXTENSION_H
3
4 /*
5  * Copyright (c) 2019 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
23 #include <GLES3/gl3.h>
24 #include <GLES2/gl2.h>
25 #include <GLES2/gl2ext.h>
26
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 namespace Adaptor
35 {
36
37 /**
38  * GlExtensions class provides GL extensions support
39  */
40 class GlExtensions
41 {
42 public:
43
44   /**
45    * Constructor
46    */
47   GlExtensions();
48
49   /**
50    * Destructor
51    */
52   ~GlExtensions();
53
54
55 public:
56
57   /**
58    * If the GL extension is available this function discards specified data in attachments
59    * from being copied from the target to improve performance.
60    *
61    * Usage: GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT };
62    *        DiscardFrameBufferEXT(GL_FRAMEBUFFER, 2, attachments);
63    *
64    * @param target is usually GL_FRAMEBUFFER
65    * @param numAttachments is the count of attachments
66    * @param attachments is a pointer to the attachments
67    */
68   void DiscardFrameBuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);
69
70   /**
71    * GLES extension
72    * Returns the program object's executable bytecode.
73    * @param[in] program       The program object's name/id
74    * @param[in] bufSize       The maximum number of bytes that may be written into binary
75    * @param[out] length       The actual number of bytes written into binary
76    * @param[out] binaryFormat The format of the program binary
77    * @param[out] binary       The actual program bytecode
78    */
79   void GetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
80
81   /**
82    * GLES extension
83    * Loads a program object with a program binary previously returned from GetProgramBinaryOES
84    * @param[in] program       The program object's name/id
85    * @param[in] binaryFormat  The format of the program binary
86    * @param[in] binary        The program bytecode
87    * @param[in] length        The number of bytes in binary
88    */
89   void ProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
90
91   /**
92    * KHR extension
93    * Specify a boundary between passes when using advanced blend equations.
94    */
95   bool BlendBarrierKHR ();
96
97 private:
98
99   /**
100    * Lazy Initialize extensions on first use
101    */
102   void Initialize();
103
104 #ifdef GL_EXT_discard_framebuffer
105   PFNGLDISCARDFRAMEBUFFEREXTPROC mGlDiscardFramebuffer;
106 #endif
107
108 #ifdef GL_OES_get_program_binary
109   PFNGLGETPROGRAMBINARYOESPROC mGlGetProgramBinaryOES;
110   PFNGLPROGRAMBINARYOESPROC mGlProgramBinaryOES;
111 #endif
112
113 #ifdef GL_KHR_blend_equation_advanced
114   PFNGLBLENDBARRIERKHRPROC mBlendBarrierKHR;
115 #endif
116
117   bool mInitialized;
118
119 };
120
121 } // namespace Adaptor
122
123 } // namespace Internal
124
125 } // namespace Dali
126
127 #endif /* DALI_INTERNAL_GL_EXTENSION_H */