Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit aea1725

Browse files
committed
Refactor
1 parent 215db1b commit aea1725

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

shell/platform/windows/compositor_opengl.cc

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ struct FramebufferBackingStore {
1717
uint32_t texture_id;
1818
};
1919

20+
// Based off Skia's logic:
21+
// https://github.com/google/skia/blob/4738ed711e03212aceec3cd502a4adb545f38e63/src/gpu/ganesh/gl/GrGLCaps.cpp#L1963-L2116
22+
int GetSupportedTextureFormat(const impeller::DescriptionGLES* description) {
23+
if (description->HasExtension("GL_EXT_texture_format_BGRA8888")) {
24+
return GL_BGRA8_EXT;
25+
} else if (description->HasExtension("GL_APPLE_texture_format_BGRA8888") &&
26+
description->GetGlVersion().IsAtLeast(impeller::Version(3, 0))) {
27+
return GL_BGRA8_EXT;
28+
} else {
29+
return GL_RGBA8;
30+
}
31+
}
32+
2033
} // namespace
2134

2235
CompositorOpenGL::CompositorOpenGL(FlutterWindowsEngine* engine,
@@ -133,18 +146,7 @@ bool CompositorOpenGL::Initialize() {
133146
return false;
134147
}
135148

136-
// Based off Skia's logic:
137-
// https://github.com/google/skia/blob/4738ed711e03212aceec3cd502a4adb545f38e63/src/gpu/ganesh/gl/GrGLCaps.cpp#L1963-L2116
138-
auto description = gl_->GetDescription();
139-
if (description->HasExtension("GL_EXT_texture_format_BGRA8888")) {
140-
format_ = GL_BGRA8_EXT;
141-
} else if (description->HasExtension("GL_APPLE_texture_format_BGRA8888") &&
142-
description->GetGlVersion().IsAtLeast(impeller::Version(3, 0))) {
143-
format_ = GL_BGRA8_EXT;
144-
} else {
145-
format_ = GL_RGBA8;
146-
}
147-
149+
format_ = GetSupportedTextureFormat(gl_->GetDescription());
148150
is_initialized_ = true;
149151
return true;
150152
}

0 commit comments

Comments
 (0)