Renamed setOffscreenRender to begin/endFrameSubscription because the name was a bit misleading, and replaced the ArrayBuffer creation with a node::Buffer::New call.
This commit is contained in:
parent
1497e7e2ac
commit
ceef06b344
5 changed files with 26 additions and 14 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include "atom/browser/api/atom_api_web_contents.h"
|
#include "atom/browser/api/atom_api_web_contents.h"
|
||||||
#include "atom/browser/browser.h"
|
#include "atom/browser/browser.h"
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
|
#include "atom/common/node_includes.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "atom/common/event_types.h"
|
#include "atom/common/event_types.h"
|
||||||
#include "atom/common/native_mate_converters/callback.h"
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
|
@ -99,10 +100,9 @@ void Window::OnFrameRendered(scoped_ptr<uint8[]> rgb, const int size) {
|
||||||
v8::Locker locker(isolate());
|
v8::Locker locker(isolate());
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
|
|
||||||
v8::Local<v8::ArrayBuffer> data = v8::ArrayBuffer::New(isolate(), rgb.get(), size);
|
auto data = node::Buffer::New(isolate(), reinterpret_cast<const char*>(rgb.get()), static_cast<size_t>(size));
|
||||||
v8::Local<v8::Uint8ClampedArray> uint_data = v8::Uint8ClampedArray::New(data, 0, size);
|
|
||||||
|
|
||||||
Emit("frame-rendered", uint_data, size);
|
Emit("frame-rendered", data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::OnWindowClosed() {
|
void Window::OnWindowClosed() {
|
||||||
|
@ -442,8 +442,12 @@ void Window::CapturePage(mate::Arguments* args) {
|
||||||
rect, base::Bind(&OnCapturePageDone, args->isolate(), callback));
|
rect, base::Bind(&OnCapturePageDone, args->isolate(), callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetOffscreenRender(bool isOffscreen) {
|
void Window::BeginFrameSubscription() {
|
||||||
window_->SetOffscreenRender(isOffscreen);
|
window_->SetFrameSubscription(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::EndFrameSubscription() {
|
||||||
|
window_->SetFrameSubscription(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetProgressBar(double progress) {
|
void Window::SetProgressBar(double progress) {
|
||||||
|
@ -728,7 +732,8 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
&Window::IsVisibleOnAllWorkspaces)
|
&Window::IsVisibleOnAllWorkspaces)
|
||||||
.SetMethod("sendMouseEvent", &Window::SendMouseEvent)
|
.SetMethod("sendMouseEvent", &Window::SendMouseEvent)
|
||||||
.SetMethod("sendKeyboardEvent", &Window::SendKeyboardEvent)
|
.SetMethod("sendKeyboardEvent", &Window::SendKeyboardEvent)
|
||||||
.SetMethod("setOffscreenRender", &Window::SetOffscreenRender)
|
.SetMethod("beginFrameSubscription", &Window::BeginFrameSubscription)
|
||||||
|
.SetMethod("endFrameSubscription", &Window::EndFrameSubscription)
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
.SetMethod("showDefinitionForSelection",
|
.SetMethod("showDefinitionForSelection",
|
||||||
&Window::ShowDefinitionForSelection)
|
&Window::ShowDefinitionForSelection)
|
||||||
|
|
|
@ -141,7 +141,8 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
|
|
||||||
void SendKeyboardEvent(v8::Isolate* isolate, const mate::Dictionary& data);
|
void SendKeyboardEvent(v8::Isolate* isolate, const mate::Dictionary& data);
|
||||||
void SendMouseEvent(v8::Isolate* isolate, const mate::Dictionary& data);
|
void SendMouseEvent(v8::Isolate* isolate, const mate::Dictionary& data);
|
||||||
void SetOffscreenRender(bool isOffscreen);
|
void BeginFrameSubscription();
|
||||||
|
void EndFrameSubscription();
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void ShowDefinitionForSelection();
|
void ShowDefinitionForSelection();
|
||||||
|
|
|
@ -333,7 +333,7 @@ void NativeWindow::CapturePage(const gfx::Rect& rect,
|
||||||
kBGRA_8888_SkColorType);
|
kBGRA_8888_SkColorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetOffscreenRender(bool isOffscreen) {
|
void NativeWindow::SetFrameSubscription(bool isOffscreen) {
|
||||||
if (!isOffscreen && !offscreen_) return;
|
if (!isOffscreen && !offscreen_) return;
|
||||||
|
|
||||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||||
|
@ -637,7 +637,7 @@ void NativeWindow::SendMouseWheelEvent(int modifiers, int x, int y, bool precise
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::DidFinishLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url) {
|
void NativeWindow::DidFinishLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url) {
|
||||||
SetOffscreenRender(offscreen_);
|
SetFrameSubscription(offscreen_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::RenderViewCreated(
|
void NativeWindow::RenderViewCreated(
|
||||||
|
|
|
@ -242,7 +242,7 @@ class NativeWindow : public content::WebContentsObserver,
|
||||||
void SendMouseEvent(blink::WebInputEvent::Type type, int modifiers, blink::WebMouseEvent::Button button, int x, int y, int movementX, int movementY, int clickCount);
|
void SendMouseEvent(blink::WebInputEvent::Type type, int modifiers, blink::WebMouseEvent::Button button, int x, int y, int movementX, int movementY, int clickCount);
|
||||||
void SendMouseWheelEvent(int modifiers, int x, int y, bool clickCount);
|
void SendMouseWheelEvent(int modifiers, int x, int y, bool clickCount);
|
||||||
|
|
||||||
void SetOffscreenRender(bool isOffscreen);
|
void SetFrameSubscription(bool isOffscreen);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NativeWindow(brightray::InspectableWebContents* inspectable_web_contents,
|
NativeWindow(brightray::InspectableWebContents* inspectable_web_contents,
|
||||||
|
|
|
@ -75,7 +75,8 @@ You can also create a window without chrome by using
|
||||||
* `standard-window` Boolean - Uses the OS X's standard window instead of the
|
* `standard-window` Boolean - Uses the OS X's standard window instead of the
|
||||||
textured window. Defaults to `true`.
|
textured window. Defaults to `true`.
|
||||||
* `offscreen-render` Boolean - The frame of the window will be accessible
|
* `offscreen-render` Boolean - The frame of the window will be accessible
|
||||||
through the `frame-rendered` event in a buffer. Defaults to `false`.
|
through the `frame-rendered` event in a buffer (Uint8, BGRA). Defaults to
|
||||||
|
`false`.
|
||||||
* `web-preferences` Object - Settings of web page's features
|
* `web-preferences` Object - Settings of web page's features
|
||||||
* `javascript` Boolean
|
* `javascript` Boolean
|
||||||
* `web-security` Boolean - When setting `false`, it will disable the same-origin
|
* `web-security` Boolean - When setting `false`, it will disable the same-origin
|
||||||
|
@ -732,10 +733,15 @@ Returns whether the window is visible on all workspaces.
|
||||||
|
|
||||||
**Note:** This API always returns false on Windows.
|
**Note:** This API always returns false on Windows.
|
||||||
|
|
||||||
### BrowserWindow.setOffscreenRender(isOffscreen)
|
### BrowserWindow.beginFrameSubscription()
|
||||||
|
|
||||||
Sets the offscreen rendering, if `true` the `frame-rendered` event will fire,
|
Enables offscreen rendering, after this call `frame-rendered` events will be
|
||||||
when the frame changes.
|
fired when the window receives a new frame from the renderer.
|
||||||
|
|
||||||
|
### BrowserWindow.endFrameSubscription()
|
||||||
|
|
||||||
|
Enables offscreen rendering, after this call `frame-rendered` events will
|
||||||
|
no longer be fired if offscreen rendering was enabled before.
|
||||||
|
|
||||||
### BrowserWindow.sendMouseEvent(options)
|
### BrowserWindow.sendMouseEvent(options)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue