Flutter Impeller
proc_table.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_IMPELLER_TOOLKIT_GLVK_PROC_TABLE_H_
6 #define FLUTTER_IMPELLER_TOOLKIT_GLVK_PROC_TABLE_H_
7 
10 
11 namespace impeller::glvk {
12 
13 #define FOR_EACH_GLVK_PROC(PROC) \
14  PROC(ActiveTexture) \
15  PROC(AttachShader) \
16  PROC(BindAttribLocation) \
17  PROC(BindBuffer) \
18  PROC(BindFramebuffer) \
19  PROC(BindTexture) \
20  PROC(BufferData) \
21  PROC(CheckFramebufferStatus) \
22  PROC(Clear) \
23  PROC(ClearColor) \
24  PROC(ColorMask) \
25  PROC(CompileShader) \
26  PROC(CreateProgram) \
27  PROC(CreateShader) \
28  PROC(DeleteBuffers) \
29  PROC(DeleteFramebuffers) \
30  PROC(DeleteProgram) \
31  PROC(DeleteShader) \
32  PROC(DeleteTextures) \
33  PROC(Disable) \
34  PROC(DrawArrays) \
35  PROC(EGLImageTargetTexture2DOES) \
36  PROC(Enable) \
37  PROC(EnableVertexAttribArray) \
38  PROC(Flush) \
39  PROC(FramebufferTexture2D) \
40  PROC(GenBuffers) \
41  PROC(GenFramebuffers) \
42  PROC(GenTextures) \
43  PROC(GetProgramiv) \
44  PROC(GetShaderiv) \
45  PROC(GetUniformLocation) \
46  PROC(LinkProgram) \
47  PROC(ShaderSource) \
48  PROC(TexParameteri) \
49  PROC(Uniform1i) \
50  PROC(UniformMatrix4fv) \
51  PROC(UseProgram) \
52  PROC(VertexAttribPointer) \
53  PROC(Viewport)
54 
55 //------------------------------------------------------------------------------
56 /// @brief A proc. table consisting of methods that are useful when
57 /// interoperating between OpenGL and Vulkan. This is different from
58 /// the OpenGL proc. table since it may contain more interop
59 /// extension related methods.
60 ///
61 class ProcTable {
62  public:
63  using Resolver = std::function<void*(const char* function_name)>;
64 
65  //----------------------------------------------------------------------------
66  /// @brief Create a proc table using a resolver to resolve OpenGL
67  /// methods.
68  ///
69  /// @param[in] resolver The resolver
70  ///
71  explicit ProcTable(const Resolver& resolver);
72 
74 
75  ProcTable(const ProcTable&) = delete;
76 
77  ProcTable& operator=(const ProcTable&) = delete;
78 
79  //----------------------------------------------------------------------------
80  /// @brief Determines if a proc. table is suitable for interop purposes.
81  /// The absence of optional extension methods that have fallbacks
82  /// don't result in an invalid proc. table. But an invalid proc
83  /// table must always be discarded as there can be no error
84  /// recovery.
85  ///
86  /// @return True if valid, False otherwise.
87  ///
88  bool IsValid() const;
89 
90 #define GLVK_PROC(name) GLProc<decltype(gl##name)> name = {"gl" #name, nullptr};
91 
93 
94 #undef GLVK_PROC
95 
96  private:
97  bool is_valid_ = false;
98 };
99 
100 } // namespace impeller::glvk
101 
102 #endif // FLUTTER_IMPELLER_TOOLKIT_GLVK_PROC_TABLE_H_
A proc. table consisting of methods that are useful when interoperating between OpenGL and Vulkan....
Definition: proc_table.h:61
ProcTable & operator=(const ProcTable &)=delete
std::function< void *(const char *function_name)> Resolver
Definition: proc_table.h:63
ProcTable(const ProcTable &)=delete
ProcTable(const Resolver &resolver)
Create a proc table using a resolver to resolve OpenGL methods.
Definition: proc_table.cc:11
bool IsValid() const
Determines if a proc. table is suitable for interop purposes. The absence of optional extension metho...
Definition: proc_table.cc:41
#define GLVK_PROC(name)
Definition: proc_table.h:90