Skip to content

Commit 6a3b850

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "getPlatformDisplayAngle: Fix std::vector scope error" into main
2 parents 3595275 + 184f274 commit 6a3b850

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

opengl/libs/EGL/egl_display.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_conn
134134

135135
if (cnx->egl.eglGetPlatformDisplay) {
136136
std::vector<EGLAttrib> attrs;
137+
// These must have the same lifetime as |attrs|, because |attrs| contains pointers to these
138+
// variables.
139+
std::vector<const char*> enabled; // ANGLE features to enable
140+
std::vector<const char*> disabled; // ANGLE features to disable
141+
137142
if (attrib_list) {
138143
for (const EGLAttrib* attr = attrib_list; *attr != EGL_NONE; attr += 2) {
139144
attrs.push_back(attr[0]);
@@ -142,9 +147,6 @@ static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_conn
142147
}
143148

144149
if (graphicsenv_flags::feature_overrides()) {
145-
std::vector<const char*> enabled; // ANGLE features to enable
146-
std::vector<const char*> disabled; // ANGLE features to disable
147-
148150
// Get the list of ANGLE features to enable from Global.Settings.
149151
const auto& eglFeatures = GraphicsEnv::getInstance().getAngleEglFeatures();
150152
for (const std::string& eglFeature : eglFeatures) {
@@ -154,25 +156,24 @@ static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_conn
154156
// Get the list of ANGLE features to enable/disable from gpuservice.
155157
GraphicsEnv::getInstance().getAngleFeatureOverrides(enabled, disabled);
156158
if (!enabled.empty()) {
157-
enabled.push_back(0);
159+
enabled.push_back(nullptr);
158160
attrs.push_back(EGL_FEATURE_OVERRIDES_ENABLED_ANGLE);
159161
attrs.push_back(reinterpret_cast<EGLAttrib>(enabled.data()));
160162
}
161163
if (!disabled.empty()) {
162-
disabled.push_back(0);
164+
disabled.push_back(nullptr);
163165
attrs.push_back(EGL_FEATURE_OVERRIDES_DISABLED_ANGLE);
164166
attrs.push_back(reinterpret_cast<EGLAttrib>(disabled.data()));
165167
}
166168
} else {
167169
const auto& eglFeatures = GraphicsEnv::getInstance().getAngleEglFeatures();
168-
std::vector<const char*> features;
169-
if (eglFeatures.size() > 0) {
170+
if (!eglFeatures.empty()) {
170171
for (const std::string& eglFeature : eglFeatures) {
171-
features.push_back(eglFeature.c_str());
172+
enabled.push_back(eglFeature.c_str());
172173
}
173-
features.push_back(0);
174+
enabled.push_back(nullptr);
174175
attrs.push_back(EGL_FEATURE_OVERRIDES_ENABLED_ANGLE);
175-
attrs.push_back(reinterpret_cast<EGLAttrib>(features.data()));
176+
attrs.push_back(reinterpret_cast<EGLAttrib>(enabled.data()));
176177
}
177178
}
178179

0 commit comments

Comments
 (0)