#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/native_mate_converters/blink_converter.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
content::WebContents* web_contents) {
WindowList& window_list = *WindowList::GetInstance();
for (NativeWindow* window : window_list) {
- if (window->web_contents() == web_contents){
+ if (window->web_contents() == web_contents)
return window;
- }
}
return nullptr;
}
void NativeWindow::SetFrameSubscription(bool isOffscreen) {
const auto view = web_contents()->GetRenderWidgetHostView();
-
if (view) {
if (isOffscreen) {
scoped_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber(
new RenderSubscriber(
view->GetVisibleViewportSize(),
- base::Bind(&NativeWindow::OnFrameReceived, base::Unretained(this))
- )
- );
-
+ base::Bind(&NativeWindow::OnFrameReceived, base::Unretained(this))));
view->BeginFrameSubscription(subscriber.Pass());
} else {
view->EndFrameSubscription();
gfx::Rect(size_), size_,
base::TimeDelta());
- *callback = base::Bind(&RenderSubscriber::CallbackMethod, callback_, *storage);
+ *callback =
+ base::Bind(&RenderSubscriber::CallbackMethod, callback_, *storage);
return true;
}
DISALLOW_COPY_AND_ASSIGN(NativeWindow);
};
-//This class provides a way to listen to frame renders and to use the rendered frames for offscreen rendering
+// This class provides a way to listen to frame renders and to use the rendered
+// frames for offscreen rendering
class RenderSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
public:
- RenderSubscriber(gfx::Size size, base::Callback<void(bool, scoped_refptr<media::VideoFrame>)> callback) : size_(size), callback_(callback) {}
+ RenderSubscriber(
+ gfx::Size size,
+ base::Callback<void(bool, scoped_refptr<media::VideoFrame>)> callback)
+ : size_(size), callback_(callback) {}
bool ShouldCaptureFrame(const gfx::Rect& damage_rect,
base::TimeTicks present_time,
base::TimeTicks last_present_time() const { return last_present_time_; }
- static void CallbackMethod(base::Callback<void(bool, scoped_refptr<media::VideoFrame>)> callback,
- scoped_refptr<media::VideoFrame> frame,
- base::TimeTicks present_time,
- bool success) {
+ static void CallbackMethod(
+ base::Callback<void(bool, scoped_refptr<media::VideoFrame>)> callback,
+ scoped_refptr<media::VideoFrame> frame,
+ base::TimeTicks present_time,
+ bool success) {
callback.Run(success, frame);
}