feat: add app.isHardwareAccelerationEnabled() (#48679)

* feat: add app.isHardwareAccelerationEnabled()

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: address review feedback

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2025-11-13 10:30:30 -05:00 committed by GitHub
commit dc5681ed79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 0 deletions

View file

@ -1134,6 +1134,10 @@ void App::DisableHardwareAcceleration(gin_helper::ErrorThrower thrower) {
"before app is ready");
return;
}
// If the GpuDataManager is already initialized, disable hardware
// acceleration immediately. Otherwise, set a flag to disable it in
// OnPreCreateThreads().
if (content::GpuDataManager::Initialized()) {
content::GpuDataManager::GetInstance()->DisableHardwareAcceleration();
} else {
@ -1141,6 +1145,13 @@ void App::DisableHardwareAcceleration(gin_helper::ErrorThrower thrower) {
}
}
bool App::IsHardwareAccelerationEnabled() {
if (content::GpuDataManager::Initialized())
return content::GpuDataManager::GetInstance()
->HardwareAccelerationEnabled();
return !disable_hw_acceleration_;
}
void App::DisableDomainBlockingFor3DAPIs(gin_helper::ErrorThrower thrower) {
if (Browser::Get()->is_ready()) {
thrower.ThrowError(
@ -1908,6 +1919,8 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
&App::SetAccessibilitySupportEnabled)
.SetMethod("disableHardwareAcceleration",
&App::DisableHardwareAcceleration)
.SetMethod("isHardwareAccelerationEnabled",
&App::IsHardwareAccelerationEnabled)
.SetMethod("disableDomainBlockingFor3DAPIs",
&App::DisableDomainBlockingFor3DAPIs)
.SetMethod("getFileIcon", &App::GetFileIcon)