Flutter Impeller
proc_table.cc
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 
6 
8 
9 namespace impeller::glvk {
10 
11 ProcTable::ProcTable(const Resolver& resolver) {
12  if (!resolver) {
13  return;
14  }
15 
16  auto error_fn = reinterpret_cast<PFNGLGETERRORPROC>(resolver("glGetError"));
17  if (!error_fn) {
18  VALIDATION_LOG << "Could not resolve " << "glGetError";
19  return;
20  }
21 
22 #define GLVK_PROC(proc_ivar) \
23  if (auto fn_ptr = resolver(proc_ivar.name)) { \
24  proc_ivar.function = \
25  reinterpret_cast<decltype(proc_ivar.function)>(fn_ptr); \
26  proc_ivar.error_fn = error_fn; \
27  } else { \
28  VALIDATION_LOG << "Could not resolve " << proc_ivar.name; \
29  return; \
30  }
31 
33 
34 #undef GLVK_PROC
35 
36  is_valid_ = true;
37 }
38 
39 ProcTable::~ProcTable() = default;
40 
41 bool ProcTable::IsValid() const {
42  return is_valid_;
43 }
44 
45 } // namespace impeller::glvk
std::function< void *(const char *function_name)> Resolver
Definition: proc_table.h:63
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(proc_ivar)
#define VALIDATION_LOG
Definition: validation.h:91