From 02cfe30df9fce5e8465d6f502782d7013cabb9ca Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 6 Jun 2016 20:19:55 +0900 Subject: [PATCH] Add app.disableHardwareAcceleration() API --- atom/browser/api/atom_api_app.cc | 13 ++++++++++++- atom/browser/api/atom_api_app.h | 2 +- docs/api/app.md | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 5d4aafca6999..87f960a87824 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -447,6 +447,15 @@ bool App::Relaunch(mate::Arguments* js_args) { return relauncher::RelaunchApp(argv); } +void App::DisableHardwareAcceleration(mate::Arguments* args) { + if (Browser::Get()->is_ready()) { + args->ThrowError("app.disableHardwareAcceleration() can only be called " + "before app is ready"); + return; + } + content::GpuDataManager::GetInstance()->DisableHardwareAcceleration(); +} + #if defined(USE_NSS_CERTS) void App::ImportCertificate( const base::DictionaryValue& options, @@ -528,7 +537,9 @@ void App::BuildPrototype( #endif .SetMethod("makeSingleInstance", &App::MakeSingleInstance) .SetMethod("releaseSingleInstance", &App::ReleaseSingleInstance) - .SetMethod("relaunch", &App::Relaunch); + .SetMethod("relaunch", &App::Relaunch) + .SetMethod("disableHardwareAcceleration", + &App::DisableHardwareAcceleration); } } // namespace api diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index e2bcb4583dda..ba274deb9ccd 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -111,7 +111,7 @@ class App : public AtomBrowserClient::Delegate, const ProcessSingleton::NotificationCallback& callback); void ReleaseSingleInstance(); bool Relaunch(mate::Arguments* args); - + void DisableHardwareAcceleration(mate::Arguments* args); #if defined(USE_NSS_CERTS) void ImportCertificate(const base::DictionaryValue& options, const net::CompletionCallback& callback); diff --git a/docs/api/app.md b/docs/api/app.md index becd6039c757..1f72dba2ca0b 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -561,6 +561,12 @@ Imports the certificate in pkcs12 format into the platform certificate store. `callback` is called with the `result` of import operation, a value of `0` indicates success while any other value indicates failure according to chromium [net_error_list](https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h). +### `app.disableHardwareAcceleration()` + +Disables hardware acceleration for current app. + +This method can only be called before app is ready. + ### `app.commandLine.appendSwitch(switch[, value])` Append a switch (with optional `value`) to Chromium's command line.