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_
|
|
|
|
|
|
|
|
#include "base/callback.h"
|
2016-02-16 02:44:10 +00:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2016-08-26 22:30:02 +00:00
|
|
|
#include "content/public/browser/readback_types.h"
|
2016-02-18 00:15:00 +00:00
|
|
|
#include "content/public/browser/render_widget_host_view.h"
|
2015-09-18 07:57:43 +00:00
|
|
|
#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
|
2016-02-18 00:15:00 +00:00
|
|
|
#include "third_party/skia/include/core/SkBitmap.h"
|
2015-09-18 07:57:43 +00:00
|
|
|
#include "ui/gfx/geometry/size.h"
|
|
|
|
#include "v8/include/v8.h"
|
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
2016-02-16 02:44:10 +00:00
|
|
|
class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
|
2015-09-18 07:57:43 +00:00
|
|
|
public:
|
2016-06-21 00:15:39 +00:00
|
|
|
using FrameCaptureCallback =
|
2016-06-26 02:46:40 +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,
|
2016-02-18 00:15:00 +00:00
|
|
|
content::RenderWidgetHostView* view,
|
2016-06-21 00:15:39 +00:00
|
|
|
const FrameCaptureCallback& callback,
|
2016-06-25 16:23:40 +00:00
|
|
|
bool only_dirty);
|
2015-09-18 07:57:43 +00:00
|
|
|
|
2016-02-16 02:44:10 +00:00
|
|
|
bool ShouldCaptureFrame(const gfx::Rect& damage_rect,
|
|
|
|
base::TimeTicks present_time,
|
|
|
|
scoped_refptr<media::VideoFrame>* storage,
|
|
|
|
DeliverFrameCallback* callback) override;
|
2015-09-18 07:57:43 +00:00
|
|
|
|
|
|
|
private:
|
2016-02-18 00:15:00 +00:00
|
|
|
void OnFrameDelivered(const FrameCaptureCallback& callback,
|
2016-06-26 02:46:40 +00:00
|
|
|
const gfx::Rect& damage_rect,
|
|
|
|
const SkBitmap& bitmap,
|
|
|
|
content::ReadbackResponse response);
|
2015-09-18 07:57:43 +00:00
|
|
|
|
|
|
|
v8::Isolate* isolate_;
|
2016-02-18 00:15:00 +00:00
|
|
|
content::RenderWidgetHostView* view_;
|
2015-09-18 07:57:43 +00:00
|
|
|
FrameCaptureCallback callback_;
|
2016-06-25 16:23:40 +00:00
|
|
|
bool only_dirty_;
|
2016-02-16 02:44:10 +00:00
|
|
|
|
|
|
|
base::WeakPtrFactory<FrameSubscriber> weak_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_
|