Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)> Class Template Reference

#include <GrGLFunctions.h>

Public Types

using Fn = R GR_GL_FUNCTION_TYPE(Args...)
 

Public Member Functions

 GrGLFunction ()=default
 
 GrGLFunction (std::nullptr_t)
 
 GrGLFunction (Fn *fn_ptr)
 
template<typename Closure >
 GrGLFunction (Closure closure)
 
R operator() (Args... args) const
 
 operator bool () const
 
void reset ()
 

Detailed Description

template<typename R, typename... Args>
class GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)>

Definition at line 258 of file GrGLFunctions.h.

Member Typedef Documentation

◆ Fn

template<typename R , typename... Args>
using GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)>::Fn = R GR_GL_FUNCTION_TYPE(Args...)

Definition at line 260 of file GrGLFunctions.h.

Constructor & Destructor Documentation

◆ GrGLFunction() [1/4]

template<typename R , typename... Args>
GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)>::GrGLFunction ( )
default

◆ GrGLFunction() [2/4]

template<typename R , typename... Args>
GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)>::GrGLFunction ( std::nullptr_t  )
inline

Definition at line 263 of file GrGLFunctions.h.

263{}

◆ GrGLFunction() [3/4]

template<typename R , typename... Args>
GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)>::GrGLFunction ( Fn fn_ptr)
inline

Definition at line 266 of file GrGLFunctions.h.

266 {
267 static_assert(sizeof(fn_ptr) <= sizeof(fBuf), "fBuf is too small");
268 if (fn_ptr) {
269 memcpy(fBuf, &fn_ptr, sizeof(fn_ptr));
270 fCall = [](const void* buf, Args... args) {
271 return (*(Fn* const *)buf)(std::forward<Args>(args)...);
272 };
273 }
274 }
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ GrGLFunction() [4/4]

template<typename R , typename... Args>
template<typename Closure >
GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)>::GrGLFunction ( Closure  closure)
inline

Definition at line 278 of file GrGLFunctions.h.

278 : GrGLFunction() {
279 static_assert(sizeof(Closure) <= sizeof(fBuf), "fBuf is too small");
280#if defined(__APPLE__) // I am having serious trouble getting these to work with all STLs...
281 static_assert(std::is_trivially_copyable<Closure>::value, "");
282 static_assert(std::is_trivially_destructible<Closure>::value, "");
283#endif
284
285 memcpy(fBuf, &closure, sizeof(closure));
286 fCall = [](const void* buf, Args... args) {
287 auto closure = (const Closure*)buf;
288 return (*closure)(args...);
289 };
290 }
std::function< void()> closure
Definition closure.h:14

Member Function Documentation

◆ operator bool()

template<typename R , typename... Args>
GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)>::operator bool ( ) const
inlineexplicit

Definition at line 297 of file GrGLFunctions.h.

297{ return fCall != nullptr; }

◆ operator()()

template<typename R , typename... Args>
R GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)>::operator() ( Args...  args) const
inline

Definition at line 292 of file GrGLFunctions.h.

292 {
293 SkASSERT(fCall);
294 return fCall(fBuf, std::forward<Args>(args)...);
295 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ reset()

template<typename R , typename... Args>
void GrGLFunction< R GR_GL_FUNCTION_TYPE(Args...)>::reset ( )
inline

Definition at line 299 of file GrGLFunctions.h.

299{ fCall = nullptr; }

The documentation for this class was generated from the following file: