Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::PlaygroundImplGLES Class Referencefinal

#include <playground_impl_gles.h>

Inheritance diagram for impeller::PlaygroundImplGLES:
impeller::PlaygroundImpl

Classes

class  ReactorWorker
 

Public Member Functions

 PlaygroundImplGLES (PlaygroundSwitches switches)
 
 ~PlaygroundImplGLES ()
 
fml::Status SetCapabilities (const std::shared_ptr< Capabilities > &capabilities) override
 
- Public Member Functions inherited from impeller::PlaygroundImpl
virtual ~PlaygroundImpl ()
 
Vector2 GetContentScale () const
 
virtual Playground::VKProcAddressResolver CreateVKProcAddressResolver () const
 
virtual void SetGPUDisabled (bool disabled) const
 

Additional Inherited Members

- Public Types inherited from impeller::PlaygroundImpl
using WindowHandle = void *
 
- Static Public Member Functions inherited from impeller::PlaygroundImpl
static std::unique_ptr< PlaygroundImplCreate (PlaygroundBackend backend, PlaygroundSwitches switches)
 
- Protected Member Functions inherited from impeller::PlaygroundImpl
 PlaygroundImpl (PlaygroundSwitches switches)
 
- Protected Attributes inherited from impeller::PlaygroundImpl
const PlaygroundSwitches switches_
 

Detailed Description

Definition at line 12 of file playground_impl_gles.h.

Constructor & Destructor Documentation

◆ PlaygroundImplGLES()

impeller::PlaygroundImplGLES::PlaygroundImplGLES ( PlaygroundSwitches  switches)
explicit

Definition at line 73 of file playground_impl_gles.cc.

74 : PlaygroundImpl(switches),
75 handle_(nullptr, &DestroyWindowHandle),
76 worker_(std::shared_ptr<ReactorWorker>(new ReactorWorker())),
77 use_angle_(switches.use_angle) {
78 if (use_angle_) {
79#if IMPELLER_PLAYGROUND_SUPPORTS_ANGLE
80 angle_glesv2_ = dlopen("libGLESv2.dylib", RTLD_LAZY);
81#endif
82 FML_CHECK(angle_glesv2_ != nullptr);
83 }
84
85 ::glfwDefaultWindowHints();
86
87#if FML_OS_MACOSX
88 FML_CHECK(use_angle_) << "Must use Angle on macOS for OpenGL ES.";
89 ::glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
90#endif // FML_OS_MACOSX
91#if FML_OS_LINUX
92 // Use EGL even on X11 then the client can select the GLES implementation
93 // by defining __EGL_VENDOR_LIBRARY_FILENAMES
94 ::glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
95#endif
96 ::glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
97 ::glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
98 ::glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
99 ::glfwWindowHint(GLFW_RED_BITS, 8);
100 ::glfwWindowHint(GLFW_GREEN_BITS, 8);
101 ::glfwWindowHint(GLFW_BLUE_BITS, 8);
102 ::glfwWindowHint(GLFW_ALPHA_BITS, 8);
103 ::glfwWindowHint(GLFW_DEPTH_BITS, 32); // 32 bit depth buffer
104 ::glfwWindowHint(GLFW_STENCIL_BITS, 8); // 8 bit stencil buffer
105 ::glfwWindowHint(GLFW_SAMPLES, 4); // 4xMSAA
106
107 ::glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
108#ifndef NDEBUG
109 ::glfwWindowHint(GLFW_CONTEXT_DEBUG, GLFW_TRUE);
110#endif
111
112 auto window = ::glfwCreateWindow(1, 1, "Test", nullptr, nullptr);
113
114 ::glfwMakeContextCurrent(window);
115 worker_->SetReactionsAllowedOnCurrentThread(true);
116
117 handle_.reset(window);
118
119 auto gl = std::make_unique<ProcTableGLES>(CreateGLProcAddressResolver());
120 if (!gl->IsValid()) {
121 FML_LOG(ERROR) << "Proc table when creating a playground was invalid.";
122 return;
123 }
124
125 if (gl->GetDescription()->HasDebugExtension()) {
126 gl->DebugMessageCallbackKHR(
127 +[](GLenum /* source */, GLenum message_type, GLuint /* message_id */,
128 GLenum /* severity */, GLsizei /* length */, const GLchar* message,
129 const void* /* user_param */) {
130 switch (message_type) {
131 case GL_DEBUG_TYPE_ERROR_KHR:
132 FML_LOG(ERROR) << "GL Error: " << message;
133 return;
134 default:
135 return;
136 }
137 },
138 nullptr);
139
140#ifndef NDEBUG
141 gl->Enable(GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR);
142#endif
143 }
144 bool is_gles3 = gl->GetDescription()->GetGlVersion().IsAtLeast(Version(3));
145 auto context_gles =
146 ContextGLES::Create(switches_.flags, std::move(gl),
147 ShaderLibraryMappingsForPlayground(is_gles3), true);
148 if (!context_gles) {
149 FML_LOG(ERROR) << "Could not create context.";
150 return;
151 }
152
153 auto worker_id = context_gles->AddReactorWorker(worker_);
154 if (!worker_id.has_value()) {
155 FML_LOG(ERROR) << "Could not add reactor worker.";
156 return;
157 }
158 context_ = std::move(context_gles);
159}
static std::shared_ptr< ContextGLES > Create(const Flags &flags, std::unique_ptr< ProcTableGLES > gl, const std::vector< std::shared_ptr< fml::Mapping > > &shader_libraries, bool enable_gpu_tracing)
PlaygroundImpl(PlaygroundSwitches switches)
const PlaygroundSwitches switches_
GLFWwindow * window
Definition main.cc:60
const char * message
#define GLFW_TRUE
#define GLFW_FALSE
#define FML_LOG(severity)
Definition logging.h:101
#define FML_CHECK(condition)
Definition logging.h:104
static std::vector< std::shared_ptr< fml::Mapping > > ShaderLibraryMappingsForPlayground()

References impeller::ContextGLES::Create(), impeller::PlaygroundSwitches::flags, FML_CHECK, FML_LOG, GLFW_FALSE, GLFW_TRUE, message, impeller::ShaderLibraryMappingsForPlayground(), impeller::PlaygroundImpl::switches_, and window.

◆ ~PlaygroundImplGLES()

impeller::PlaygroundImplGLES::~PlaygroundImplGLES ( )
default

Member Function Documentation

◆ SetCapabilities()

fml::Status impeller::PlaygroundImplGLES::SetCapabilities ( const std::shared_ptr< Capabilities > &  capabilities)
overridevirtual

Implements impeller::PlaygroundImpl.

Definition at line 257 of file playground_impl_gles.cc.

258 {
259 return fml::Status(
261 "PlaygroundImplGLES doesn't support setting the capabilities.");
262}

References fml::kUnimplemented.


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