diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index 6bd0537b9b89..7d840f1a3e23 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -175,36 +175,6 @@ logging level for all code in the source files under a `foo/bar` directory. This switch only works when `--enable-logging` is also passed. -## --disable-gpu - -Disables the use of the GPU in the renderer process. If this is set with the -`--disable-gpu-compositing` switch, *offscreen rendering* will use a software -output device, which has much better overall performance but lacks of WebGL -and 3D CSS support. - -## --disable-gpu-compositing - -Disables the use of the GPU compositing in the renderer process. This should be -set with the `--disable-gpu` switch for *offscreen rendering*. - -``` javascript -const {app, BrowserWindow} = require('electron'); - -app.commandLine.appendSwitch('disable-gpu'); -app.commandLine.appendSwitch('disable-gpu-compositing'); - -let win = new BrowserWindow({ - webPreferences: { - offscreen: true - } -}); -win.loadURL('http://github.com'); - -win.webContents.on('paint', (event, dirty, data) => { - updateBitmap(dirty, data); -}); -``` - [app]: app.md [append-switch]: app.md#appcommandlineappendswitchswitch-value [ready]: app.md#event-ready diff --git a/docs/tutorial/offscreen-rendering.md b/docs/tutorial/offscreen-rendering.md index 53ef2db00736..8edcb573756e 100644 --- a/docs/tutorial/offscreen-rendering.md +++ b/docs/tutorial/offscreen-rendering.md @@ -25,22 +25,17 @@ mode that WebGL and 3D CSS animations are supported. This mode uses a software output device for rendering in the CPU, so the frame generation is much faster, thus this mode is preferred over the GPU accelerated -one. To enable this mode GPU acceleration has to be disabled like this: +one. -``` javascript -const {app} = require('electron') - -app.commandLine.appendSwitch('disable-gpu') -app.commandLine.appendSwitch('disable-gpu-compositing') -``` +To enable this mode GPU acceleration has to be disabled by calling the +[`app.disableHardwareAcceleration()`][disablehardwareacceleration] API. ## Usage ``` javascript const {app, BrowserWindow} = require('electron') -app.commandLine.appendSwitch('disable-gpu') -app.commandLine.appendSwitch('disable-gpu-compositing') +app.disableHardwareAcceleration() let win = new BrowserWindow({ width: 800, @@ -57,3 +52,5 @@ win.webContents.on('paint', (event, dirty, data) => { // updateBitmap(dirty, data) }) ``` + +[disablehardwareacceleration]: ../api/app.md#appdisablehardwareacceleration