| Flutter Impeller |

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
bool | HasExtension (const std::string &ext) const
bool | HasDebugExtension () const

## Detailed Description

Definition at line 17 of file description_gles.h.

## Constructor & Destructor Documentation

## ◆ DescriptionGLES()

impeller::DescriptionGLES::DescriptionGLES | ( | const ProcTableGLES & | gl | ) |

Definition at line 78 of file description_gles.cc.

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

References impeller::DetermineIfES(), impeller::DetermineVersion(), impeller::GetGLString(), impeller::GetGLStringi(), impeller::Version::IsAtLeast(), and VALIDATION_LOG.

## ◆ ~DescriptionGLES()

impeller::DescriptionGLES::~DescriptionGLES | ( |  | ) |
| default

## Member Function Documentation

## ◆ GetString()

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

Definition at line 124 of file description_gles.cc.

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

References IsValid().

## ◆ HasDebugExtension()

bool impeller::DescriptionGLES::HasDebugExtension | ( |  | ) | const

Definition at line 167 of file description_gles.cc.

167 {
168 return HasExtension("GL_KHR_debug");
169 }

References HasExtension().

## ◆ HasExtension()

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

Definition at line 163 of file description_gles.cc.

163 {
164 return extensions_.find(ext) != extensions_.end();
165 }

Referenced by HasDebugExtension().

## ◆ IsES()

bool impeller::DescriptionGLES::IsES | ( |  | ) | const

Definition at line 159 of file description_gles.cc.

159 {
160 return is_es_;
161 }

Referenced by impeller::CapabilitiesGLES::CapabilitiesGLES().

## ◆ IsValid()

bool impeller::DescriptionGLES::IsValid | ( |  | ) | const

Definition at line 120 of file description_gles.cc.

120 {
121 return is_valid_;
122 }

Referenced by GetString().

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

- impeller/renderer/backend/gles/description_gles.h
- impeller/renderer/backend/gles/description_gles.cc

impeller::GetGLStringi
static std::string GetGLStringi(const ProcTableGLES &gl, GLenum name, int index)
Definition: description_gles.cc:29
impeller::Version::IsAtLeast
constexpr bool IsAtLeast(const Version &other)
Definition: version.h:30
impeller::DescriptionGLES::IsValid
bool IsValid() const
Definition: description_gles.cc:120
impeller::DetermineVersion
static std::optional< Version > DetermineVersion(std::string version)
Definition: description_gles.cc:43
impeller::DetermineIfES
static bool DetermineIfES(const std::string &version)
Definition: description_gles.cc:39
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::GetGLString
static std::string GetGLString(const ProcTableGLES &gl, GLenum name)
Definition: description_gles.cc:21
impeller::DescriptionGLES::HasExtension
bool HasExtension(const std::string &ext) const
Definition: description_gles.cc:163