2016-07-31 20:05:36 +00:00
|
|
|
const {app, BrowserWindow} = require('electron')
|
2016-07-06 18:47:21 +00:00
|
|
|
const path = require('path')
|
2013-07-17 08:21:33 +00:00
|
|
|
|
2016-07-31 20:05:36 +00:00
|
|
|
let mainWindow = null
|
2013-07-17 08:21:33 +00:00
|
|
|
|
2016-07-27 23:58:23 +00:00
|
|
|
app.commandLine.appendSwitch('--disable-gpu');
|
|
|
|
app.commandLine.appendSwitch('--disable-gpu-compositing');
|
|
|
|
|
2013-07-17 08:21:33 +00:00
|
|
|
// Quit when all windows are closed.
|
2016-05-06 23:53:50 +00:00
|
|
|
app.on('window-all-closed', () => {
|
2016-03-24 20:15:04 +00:00
|
|
|
app.quit()
|
|
|
|
})
|
2013-07-17 08:21:33 +00:00
|
|
|
|
2016-05-06 23:53:50 +00:00
|
|
|
exports.load = (appUrl) => {
|
|
|
|
app.on('ready', () => {
|
2016-07-31 20:05:36 +00:00
|
|
|
mainWindow = new BrowserWindow({
|
2016-07-28 10:10:56 +00:00
|
|
|
width: 800,
|
|
|
|
height: 600,
|
|
|
|
autoHideMenuBar: true,
|
|
|
|
backgroundColor: '#FFFFFF',
|
|
|
|
useContentSize: true,
|
|
|
|
webPreferences: {
|
|
|
|
offscreen: true,
|
|
|
|
nodeIntegration: false
|
|
|
|
}
|
|
|
|
})
|
2016-07-31 20:05:36 +00:00
|
|
|
mainWindow.loadURL('file:///Volumes/Elements/dev/electron/spec/fixtures/api/offscreen-rendering.html')
|
|
|
|
mainWindow.focus()
|
2016-07-29 12:50:27 +00:00
|
|
|
|
2016-07-31 20:05:36 +00:00
|
|
|
mainWindow.webContents.on('dom-ready', () => {
|
|
|
|
let ping = true
|
|
|
|
setInterval(() => {
|
|
|
|
if (ping) {
|
|
|
|
mainWindow.webContents.startPainting()
|
|
|
|
} else {
|
|
|
|
mainWindow.webContents.stopPainting()
|
|
|
|
}
|
2016-07-29 12:50:27 +00:00
|
|
|
|
2016-07-31 20:05:36 +00:00
|
|
|
ping = !ping
|
|
|
|
}, 3000)
|
2016-07-28 10:10:56 +00:00
|
|
|
})
|
2016-07-29 12:50:27 +00:00
|
|
|
|
2016-07-31 20:05:36 +00:00
|
|
|
setInterval(() => {
|
|
|
|
console.log(mainWindow.webContents.isPainting())
|
|
|
|
}, 500)
|
2016-07-29 12:50:27 +00:00
|
|
|
|
2016-07-31 20:05:36 +00:00
|
|
|
mainWindow.webContents.on('paint', (e, rect, data) => {
|
|
|
|
console.log('painting', data.length)
|
2016-07-28 10:10:56 +00:00
|
|
|
})
|
2016-03-24 20:15:04 +00:00
|
|
|
})
|
|
|
|
}
|