Flutter Engine
 
Loading...
Searching...
No Matches
flutter::testing::TestEGLContext Struct Reference

#include <test_gl_context.h>

Public Types

using EGLDisplay = void *
 
using EGLContext = void *
 
using EGLConfig = void *
 

Public Member Functions

 TestEGLContext ()
 
 ~TestEGLContext ()
 

Public Attributes

EGLDisplay display
 
EGLContext onscreen_context
 
EGLContext offscreen_context
 
EGLConfig config
 

Detailed Description

Definition at line 10 of file test_gl_context.h.

Member Typedef Documentation

◆ EGLConfig

Definition at line 17 of file test_gl_context.h.

◆ EGLContext

Definition at line 16 of file test_gl_context.h.

◆ EGLDisplay

Definition at line 15 of file test_gl_context.h.

Constructor & Destructor Documentation

◆ TestEGLContext()

flutter::testing::TestEGLContext::TestEGLContext ( )
explicit

Definition at line 62 of file test_gl_context.cc.

62 {
63 display = CreateSwangleDisplay();
64 FML_CHECK(display != EGL_NO_DISPLAY);
65
66 auto result = ::eglInitialize(display, nullptr, nullptr);
67 FML_CHECK(result == EGL_TRUE) << GetEGLError();
68
69 config = {0};
70
71 EGLint num_config = 0;
72 const EGLint attribute_list[] = {EGL_RED_SIZE,
73 8,
74 EGL_GREEN_SIZE,
75 8,
76 EGL_BLUE_SIZE,
77 8,
78 EGL_ALPHA_SIZE,
79 8,
80 EGL_SURFACE_TYPE,
81 EGL_PBUFFER_BIT,
82 EGL_CONFORMANT,
83 EGL_OPENGL_ES2_BIT,
84 EGL_RENDERABLE_TYPE,
85 EGL_OPENGL_ES2_BIT,
86 EGL_NONE};
87
88 result = ::eglChooseConfig(display, attribute_list, &config, 1, &num_config);
89 FML_CHECK(result == EGL_TRUE) << GetEGLError();
90 FML_CHECK(num_config == 1) << GetEGLError();
91
92 {
93 const EGLint context_attributes[] = {
94 EGL_CONTEXT_CLIENT_VERSION, //
95 2, //
96 EGL_NONE //
97 };
98
100 ::eglCreateContext(display, // display connection
101 config, // config
102 EGL_NO_CONTEXT, // sharegroup
103 context_attributes // context attributes
104 );
105 FML_CHECK(onscreen_context != EGL_NO_CONTEXT) << GetEGLError();
106
108 ::eglCreateContext(display, // display connection
109 config, // config
110 onscreen_context, // sharegroup
111 context_attributes // context attributes
112 );
113 FML_CHECK(offscreen_context != EGL_NO_CONTEXT) << GetEGLError();
114 }
115}
#define FML_CHECK(condition)
Definition logging.h:104
std::string GetEGLError()

References config, display, FML_CHECK, flutter::testing::GetEGLError(), offscreen_context, and onscreen_context.

◆ ~TestEGLContext()

flutter::testing::TestEGLContext::~TestEGLContext ( )

Definition at line 117 of file test_gl_context.cc.

117 {
118 auto result = ::eglDestroyContext(display, onscreen_context);
119 FML_CHECK(result == EGL_TRUE) << GetEGLError();
120
121 result = ::eglDestroyContext(display, offscreen_context);
122 FML_CHECK(result == EGL_TRUE) << GetEGLError();
123
124 result = ::eglTerminate(display);
125 FML_CHECK(result == EGL_TRUE);
126}

References display, FML_CHECK, flutter::testing::GetEGLError(), offscreen_context, and onscreen_context.

Member Data Documentation

◆ config

EGLConfig flutter::testing::TestEGLContext::config

Definition at line 26 of file test_gl_context.h.

Referenced by TestEGLContext().

◆ display

EGLDisplay flutter::testing::TestEGLContext::display

Definition at line 19 of file test_gl_context.h.

Referenced by TestEGLContext(), and ~TestEGLContext().

◆ offscreen_context

EGLContext flutter::testing::TestEGLContext::offscreen_context

Definition at line 21 of file test_gl_context.h.

Referenced by TestEGLContext(), and ~TestEGLContext().

◆ onscreen_context

EGLContext flutter::testing::TestEGLContext::onscreen_context

Definition at line 20 of file test_gl_context.h.

Referenced by TestEGLContext(), and ~TestEGLContext().


The documentation for this struct was generated from the following files: