#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/browser.h"
#include "atom/browser/native_window.h"
+#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "atom/common/event_types.h"
#include "atom/common/native_mate_converters/callback.h"
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
- v8::Local<v8::ArrayBuffer> data = v8::ArrayBuffer::New(isolate(), rgb.get(), size);
- v8::Local<v8::Uint8ClampedArray> uint_data = v8::Uint8ClampedArray::New(data, 0, size);
+ auto data = node::Buffer::New(isolate(), reinterpret_cast<const char*>(rgb.get()), static_cast<size_t>(size));
- Emit("frame-rendered", uint_data, size);
+ Emit("frame-rendered", data, size);
}
void Window::OnWindowClosed() {
rect, base::Bind(&OnCapturePageDone, args->isolate(), callback));
}
-void Window::SetOffscreenRender(bool isOffscreen) {
- window_->SetOffscreenRender(isOffscreen);
+void Window::BeginFrameSubscription() {
+ window_->SetFrameSubscription(true);
+}
+
+void Window::EndFrameSubscription() {
+ window_->SetFrameSubscription(false);
}
void Window::SetProgressBar(double progress) {
&Window::IsVisibleOnAllWorkspaces)
.SetMethod("sendMouseEvent", &Window::SendMouseEvent)
.SetMethod("sendKeyboardEvent", &Window::SendKeyboardEvent)
- .SetMethod("setOffscreenRender", &Window::SetOffscreenRender)
+ .SetMethod("beginFrameSubscription", &Window::BeginFrameSubscription)
+ .SetMethod("endFrameSubscription", &Window::EndFrameSubscription)
#if defined(OS_MACOSX)
.SetMethod("showDefinitionForSelection",
&Window::ShowDefinitionForSelection)
void SendKeyboardEvent(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)
void ShowDefinitionForSelection();
kBGRA_8888_SkColorType);
}
-void NativeWindow::SetOffscreenRender(bool isOffscreen) {
+void NativeWindow::SetFrameSubscription(bool isOffscreen) {
if (!isOffscreen && !offscreen_) return;
const auto view = web_contents()->GetRenderWidgetHostView();
}
void NativeWindow::DidFinishLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url) {
- SetOffscreenRender(offscreen_);
+ SetFrameSubscription(offscreen_);
}
void NativeWindow::RenderViewCreated(
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 SetOffscreenRender(bool isOffscreen);
+ void SetFrameSubscription(bool isOffscreen);
protected:
NativeWindow(brightray::InspectableWebContents* inspectable_web_contents,
* `standard-window` Boolean - Uses the OS X's standard window instead of the
textured window. Defaults to `true`.
* `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
* `javascript` Boolean
* `web-security` Boolean - When setting `false`, it will disable the same-origin
**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,
-when the frame changes.
+Enables offscreen rendering, after this call `frame-rendered` events will be
+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)