Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
impeller::DescriptionGLES Class Reference

#include <description_gles.h>

Public Member Functions

 DescriptionGLES (const ProcTableGLES &gl)
 
 ~DescriptionGLES ()
 
bool IsValid () const
 
bool IsES () const
 
std::string GetString () const
 
Version GetGlVersion () const
 
bool HasExtension (const std::string &ext) const
 
bool HasDebugExtension () const
 Returns whether GLES includes the debug extension.
 
bool IsANGLE () const
 

Detailed Description

Definition at line 18 of file description_gles.h.

Constructor & Destructor Documentation

◆ DescriptionGLES()

impeller::DescriptionGLES::DescriptionGLES ( const ProcTableGLES gl)
explicit

Definition at line 82 of file description_gles.cc.

83 : vendor_(GetGLString(gl, GL_VENDOR)),
84 renderer_(GetGLString(gl, GL_RENDERER)),
85 gl_version_string_(GetGLString(gl, GL_VERSION)),
86 sl_version_string_(GetGLString(gl, GL_SHADING_LANGUAGE_VERSION)) {
87 is_es_ = DetermineIfES(gl_version_string_);
88 is_angle_ = DetermineIfANGLE(gl_version_string_);
89
90 auto gl_version = DetermineVersion(gl_version_string_);
91 if (!gl_version.has_value()) {
92 VALIDATION_LOG << "Could not determine GL version.";
93 return;
94 }
95 gl_version_ = gl_version.value();
96
97 // GL_NUM_EXTENSIONS is only available in OpenGL 3+ and OpenGL ES 3+
98 if (gl_version_.IsAtLeast(Version(3, 0, 0))) {
99 int extension_count = 0;
100 gl.GetIntegerv(GL_NUM_EXTENSIONS, &extension_count);
101 for (auto i = 0; i < extension_count; i++) {
102 extensions_.insert(GetGLStringi(gl, GL_EXTENSIONS, i));
103 }
104 } else {
105 const auto extensions = GetGLString(gl, GL_EXTENSIONS);
106 std::stringstream extensions_stream(extensions);
107 std::string extension;
108 while (std::getline(extensions_stream, extension, ' ')) {
109 extensions_.insert(extension);
110 }
111 }
112
113 auto sl_version = DetermineVersion(sl_version_string_);
114 if (!sl_version.has_value()) {
115 VALIDATION_LOG << "Could not determine SL version.";
116 return;
117 }
118 sl_version_ = sl_version.value();
119
120 is_valid_ = true;
121}
Version
static std::string GetGLString(const ProcTableGLES &gl, GLenum name)
static bool DetermineIfES(const std::string &version)
static bool DetermineIfANGLE(const std::string &version)
static std::optional< Version > DetermineVersion(std::string version)
static std::string GetGLStringi(const ProcTableGLES &gl, GLenum name, int index)
constexpr bool IsAtLeast(const Version &other) const
Definition version.h:31
#define VALIDATION_LOG
Definition validation.h:73

◆ ~DescriptionGLES()

impeller::DescriptionGLES::~DescriptionGLES ( )
default

Member Function Documentation

◆ GetGlVersion()

Version impeller::DescriptionGLES::GetGlVersion ( ) const

Definition at line 164 of file description_gles.cc.

164 {
165 return gl_version_;
166}

◆ GetString()

std::string impeller::DescriptionGLES::GetString ( ) const

Definition at line 129 of file description_gles.cc.

129 {
130 if (!IsValid()) {
131 return "Unknown Renderer.";
132 }
133
134 std::vector<std::pair<std::string, std::string>> items;
135
136 items.emplace_back(std::make_pair("Vendor", vendor_));
137 items.emplace_back(std::make_pair("Renderer", renderer_));
138 items.emplace_back(std::make_pair("GL Version", gl_version_string_));
139 items.emplace_back(
140 std::make_pair("Shading Language Version", sl_version_string_));
141 items.emplace_back(
142 std::make_pair("Extensions", std::to_string(extensions_.size())));
143
144 size_t max_width = 0u;
145 for (const auto& item : items) {
146 max_width = std::max(max_width, item.first.size());
147 }
148
149 std::stringstream stream;
150 stream << "OpenGL Renderer:" << std::endl;
151 for (const auto& item : items) {
152 stream << std::setw(max_width + 1) << item.first << ": " << item.second
153 << std::endl;
154 }
155
156 const auto pad = std::string(max_width + 3, ' ');
157 for (const auto& extension : extensions_) {
158 stream << pad << extension << std::endl;
159 }
160
161 return stream.str();
162}

◆ HasDebugExtension()

bool impeller::DescriptionGLES::HasDebugExtension ( ) const

Returns whether GLES includes the debug extension.

Definition at line 180 of file description_gles.cc.

180 {
181 return HasExtension("GL_KHR_debug");
182}
bool HasExtension(const std::string &ext) const

◆ HasExtension()

bool impeller::DescriptionGLES::HasExtension ( const std::string &  ext) const

Definition at line 176 of file description_gles.cc.

176 {
177 return extensions_.find(ext) != extensions_.end();
178}

◆ IsANGLE()

bool impeller::DescriptionGLES::IsANGLE ( ) const

Definition at line 172 of file description_gles.cc.

172 {
173 return is_angle_;
174}

◆ IsES()

bool impeller::DescriptionGLES::IsES ( ) const

Definition at line 168 of file description_gles.cc.

168 {
169 return is_es_;
170}

◆ IsValid()

bool impeller::DescriptionGLES::IsValid ( ) const

Definition at line 125 of file description_gles.cc.

125 {
126 return is_valid_;
127}

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