mirror of
https://github.com/electron/electron.git
synced 2026-01-08 23:18:06 -05:00
feat: add app.isHardwareAccelerationEnabled() (#47614)
* feat: add app.isHardwareAccelerationEnabled() * chore: address review feedback
This commit is contained in:
@@ -1140,6 +1140,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 {
|
||||
@@ -1147,6 +1151,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(
|
||||
@@ -1926,6 +1937,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)
|
||||
|
||||
@@ -213,6 +213,7 @@ class App final : public gin::Wrappable<App>,
|
||||
void ReleaseSingleInstanceLock();
|
||||
bool Relaunch(gin::Arguments* args);
|
||||
void DisableHardwareAcceleration(gin_helper::ErrorThrower thrower);
|
||||
bool IsHardwareAccelerationEnabled();
|
||||
void DisableDomainBlockingFor3DAPIs(gin_helper::ErrorThrower thrower);
|
||||
bool IsAccessibilitySupportEnabled();
|
||||
v8::Local<v8::Value> GetAccessibilitySupportFeatures();
|
||||
|
||||
Reference in New Issue
Block a user