adds docs for osr
This commit is contained in:
parent
e4000850cd
commit
f60d791fa8
6 changed files with 90 additions and 11 deletions
|
@ -1396,8 +1396,8 @@ void WebContents::OnPaint(
|
|||
v8::MaybeLocal<v8::Object> buffer = node::Buffer::New(isolate
|
||||
, (char *)bitmap_pixels, sizeof(bitmap_pixels));
|
||||
|
||||
Emit("paint", damage_rect, bitmap_width, bitmap_height,
|
||||
buffer.ToLocalChecked());
|
||||
const gfx::Size bitmap_size = gfx::Size(bitmap_width, bitmap_height);
|
||||
Emit("paint", damage_rect, buffer.ToLocalChecked(), bitmap_size);
|
||||
}
|
||||
|
||||
void WebContents::StartPainting() {
|
||||
|
|
|
@ -4,17 +4,10 @@
|
|||
|
||||
#include "atom/browser/osr_render_widget_host_view.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
|
||||
#include "ui/events/latency_info.h"
|
||||
|
||||
ui::AcceleratedWidgetMac* atom::OffScreenRenderWidgetHostView::GetAcceleratedWidgetMac()
|
||||
const {
|
||||
|
|
|
@ -189,8 +189,6 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
|||
|
||||
command_line->AppendSwitch(cc::switches::kEnableBeginFrameScheduling);
|
||||
command_line->AppendSwitch(cc::switches::kShowFPSCounter);
|
||||
// command_line->AppendSwitch("disable-gpu");
|
||||
// command_line->AppendSwitch("disable-gpu-compositing");
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -274,6 +274,8 @@ The `webPreferences` option is an object that can have the following properties:
|
|||
* `defaultEncoding` String - Defaults to `ISO-8859-1`.
|
||||
* `backgroundThrottling` Boolean - Whether to throttle animations and timers
|
||||
when the page becomes background. Defaults to `true`.
|
||||
* `offscreen` Boolean - Whether to enable offscreen rendering for the browser
|
||||
window. Defaults to `false`.
|
||||
|
||||
### Instance Events
|
||||
|
||||
|
|
|
@ -174,6 +174,36 @@ 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
|
||||
|
|
|
@ -452,6 +452,41 @@ app.on('ready', () => {
|
|||
|
||||
Emitted when a page's view is repainted.
|
||||
|
||||
#### Event: 'paint'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `dirtyRect` Object
|
||||
* `x` Number - the x coordinate on the bitmap
|
||||
* `y` Number - the y coordinate on the bitmap
|
||||
* `width` Number - the width of the dirty area
|
||||
* `height` Number - the height of the dirty area
|
||||
* `data` Buffer - the bitmap data of the dirty rect
|
||||
* `bitmapSize` Object
|
||||
* `width` Number - the width of the whole bitmap
|
||||
* `height` Number - the height of the whole bitmap
|
||||
|
||||
Emitted when a new frame is generated. Only the dirty area is passed in the
|
||||
buffer.
|
||||
|
||||
```javascript
|
||||
const {BrowserWindow} = require('electron');
|
||||
|
||||
let win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 1500,
|
||||
webPreferences: {
|
||||
offscreen: true
|
||||
}
|
||||
});
|
||||
win.loadURL('http://github.com');
|
||||
|
||||
win.webContents.on('paint', (event, dirty, data) => {
|
||||
updateBitmap(dirty, data);
|
||||
});
|
||||
```
|
||||
|
||||
### Instance Methods
|
||||
|
||||
#### `contents.loadURL(url[, options])`
|
||||
|
@ -1024,6 +1059,27 @@ win.webContents.on('did-finish-load', () => {
|
|||
|
||||
Shows pop-up dictionary that searches the selected word on the page.
|
||||
|
||||
#### `contents.startPainting()`
|
||||
|
||||
If *offscreen rendering* is enabled and not painting, start painting.
|
||||
|
||||
#### `contents.stopPainting()`
|
||||
|
||||
If *offscreen rendering* is enabled and painting, stop painting.
|
||||
|
||||
#### `contents.isPainting()`
|
||||
|
||||
If *offscreen rendering* is enabled returns whether it is currently painting.
|
||||
|
||||
#### `contents.setFrameRate(fps)`
|
||||
|
||||
If *offscreen rendering* is enabled sets the frame rate to the specified number.
|
||||
Only values between 1 and 60 are accepted.
|
||||
|
||||
#### `contents.getFrameRate()`
|
||||
|
||||
If *offscreen rendering* is enabled returns the current frame rate.
|
||||
|
||||
### Instance Properties
|
||||
|
||||
#### `contents.id`
|
||||
|
|
Loading…
Add table
Reference in a new issue