Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address some feedback
  • Loading branch information
loic-sharma committed Dec 13, 2023
commit fcf036508ce037aec7c8b7c4aa4db1ca9fe4c5e8
8 changes: 4 additions & 4 deletions shell/platform/windows/compositor_opengl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ bool CompositorOpenGL::Initialize() {
return false;
}

auto gl = std::make_unique<impeller::ProcTableGLES>(resolver_);
if (!gl->IsValid()) {
gl_ = std::make_unique<impeller::ProcTableGLES>(resolver_);
if (!gl_->IsValid()) {
gl_.reset();
return false;
}

// Based off Skia's logic:
// https://github.com/google/skia/blob/4738ed711e03212aceec3cd502a4adb545f38e63/src/gpu/ganesh/gl/GrGLCaps.cpp#L1963-L2116
auto description = gl->GetDescription();
auto description = gl_->GetDescription();
if (description->HasExtension("GL_EXT_texture_format_BGRA8888")) {
format_ = GL_BGRA8_EXT;
} else if (description->HasExtension("GL_APPLE_texture_format_BGRA8888") &&
Expand All @@ -139,7 +140,6 @@ bool CompositorOpenGL::Initialize() {
format_ = GL_RGBA8;
}

gl_ = std::move(gl);
is_initialized_ = true;
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions shell/platform/windows/compositor_opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class CompositorOpenGL : public Compositor {
bool is_initialized_ = false;

// Function used to resolve GLES functions.
impeller::ProcTableGLES::Resolver resolver_;
impeller::ProcTableGLES::Resolver resolver_ = nullptr;

// Table of resolved GLES functions. Null until the compositor is initialized.
std::unique_ptr<impeller::ProcTableGLES> gl_;
std::unique_ptr<impeller::ProcTableGLES> gl_ = nullptr;

// The OpenGL texture target format for backing stores. Invalid value until
// the compositor is initialized.
uint32_t format_;
uint32_t format_ = 0;

// Initialize the compositor. This must run on the raster thread.
bool Initialize();
Expand Down
12 changes: 7 additions & 5 deletions shell/platform/windows/compositor_opengl_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const unsigned char* MockGetString(GLenum name) {
switch (name) {
case GL_VERSION:
case GL_SHADING_LANGUAGE_VERSION:
return (unsigned char*)"3.0";
return reinterpret_cast<const unsigned char*>("3.0");
default:
return (unsigned char*)"";
return reinterpret_cast<const unsigned char*>("");
}
}

Expand All @@ -43,11 +43,13 @@ GLenum MockGetError() {
void DoNothing() {}

const impeller::ProcTableGLES::Resolver kMockResolver = [](const char* name) {
if (strcmp(name, "glGetString") == 0) {
std::string function_name{name};

if (function_name == "glGetString") {
return reinterpret_cast<void*>(&MockGetString);
} else if (strcmp(name, "glGetIntegerv") == 0) {
} else if (function_name == "glGetIntegerv") {
return reinterpret_cast<void*>(&MockGetIntegerv);
} else if (strcmp(name, "glGetError") == 0) {
} else if (function_name == "glGetError") {
return reinterpret_cast<void*>(&MockGetError);
} else {
return reinterpret_cast<void*>(&DoNothing);
Expand Down