2015-09-18 07:57:43 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_API_FRAME_SUBSCRIBER_H_
|
|
|
|
#define ATOM_BROWSER_API_FRAME_SUBSCRIBER_H_
|
|
|
|
|
2018-05-14 15:55:39 +00:00
|
|
|
#include "content/public/browser/web_contents.h"
|
|
|
|
|
2015-09-18 07:57:43 +00:00
|
|
|
#include "base/callback.h"
|
2018-07-13 08:28:23 +00:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2018-05-14 15:55:39 +00:00
|
|
|
#include "components/viz/common/frame_sinks/copy_output_result.h"
|
|
|
|
#include "content/public/browser/web_contents_observer.h"
|
|
|
|
#include "ui/gfx/image/image.h"
|
2015-09-18 07:57:43 +00:00
|
|
|
#include "v8/include/v8.h"
|
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
2018-05-14 15:55:39 +00:00
|
|
|
class WebContents;
|
|
|
|
|
|
|
|
class FrameSubscriber : public content::WebContentsObserver {
|
2015-09-18 07:57:43 +00:00
|
|
|
public:
|
2016-06-21 00:15:39 +00:00
|
|
|
using FrameCaptureCallback =
|
2018-06-19 17:49:44 +00:00
|
|
|
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>;
|
2015-09-18 07:57:43 +00:00
|
|
|
|
|
|
|
FrameSubscriber(v8::Isolate* isolate,
|
2018-05-14 15:55:39 +00:00
|
|
|
content::WebContents* web_contents,
|
2018-05-14 17:09:05 +00:00
|
|
|
const FrameCaptureCallback& callback,
|
|
|
|
bool only_dirty);
|
2018-05-14 15:55:39 +00:00
|
|
|
~FrameSubscriber();
|
2015-09-18 07:57:43 +00:00
|
|
|
|
|
|
|
private:
|
2018-05-14 15:55:39 +00:00
|
|
|
gfx::Rect GetDamageRect();
|
|
|
|
void DidReceiveCompositorFrame() override;
|
|
|
|
void Done(const gfx::Rect& damage, const SkBitmap& frame);
|
2015-09-18 07:57:43 +00:00
|
|
|
|
|
|
|
v8::Isolate* isolate_;
|
|
|
|
FrameCaptureCallback callback_;
|
2018-05-14 17:09:05 +00:00
|
|
|
bool only_dirty_;
|
2016-02-16 02:44:10 +00:00
|
|
|
|
2018-07-13 08:28:23 +00:00
|
|
|
base::WeakPtrFactory<FrameSubscriber> weak_ptr_factory_;
|
|
|
|
|
2015-09-18 07:57:43 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_API_FRAME_SUBSCRIBER_H_
|