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