Move BeginFrameSubscription to WebContents
This commit is contained in:
parent
42863e4700
commit
86f523d3c1
10 changed files with 137 additions and 121 deletions
|
@ -9,8 +9,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "media/base/video_frame.h"
|
||||
#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
|
||||
#include "atom/browser/native_window_observer.h"
|
||||
#include "atom/browser/ui/accelerator_util.h"
|
||||
#include "base/cancelable_callback.h"
|
||||
|
@ -171,9 +169,6 @@ class NativeWindow : public content::WebContentsObserver,
|
|||
gfx::Size GetAspectRatioExtraSize();
|
||||
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
|
||||
|
||||
// Subscribe to the frame updates.
|
||||
void SetFrameSubscription(bool isOffscreen);
|
||||
|
||||
base::WeakPtr<NativeWindow> GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
@ -228,8 +223,6 @@ class NativeWindow : public content::WebContentsObserver,
|
|||
has_dialog_attached_ = has_dialog_attached;
|
||||
}
|
||||
|
||||
void OnFrameReceived(bool result, scoped_refptr<media::VideoFrame> frame);
|
||||
|
||||
protected:
|
||||
NativeWindow(brightray::InspectableWebContents* inspectable_web_contents,
|
||||
const mate::Dictionary& options);
|
||||
|
@ -303,36 +296,6 @@ class NativeWindow : public content::WebContentsObserver,
|
|||
DISALLOW_COPY_AND_ASSIGN(NativeWindow);
|
||||
};
|
||||
|
||||
// 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) {}
|
||||
|
||||
bool ShouldCaptureFrame(const gfx::Rect& damage_rect,
|
||||
base::TimeTicks present_time,
|
||||
scoped_refptr<media::VideoFrame>* storage,
|
||||
DeliverFrameCallback* callback) override;
|
||||
|
||||
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) {
|
||||
callback.Run(success, frame);
|
||||
}
|
||||
|
||||
private:
|
||||
gfx::Size size_;
|
||||
base::Callback<void(bool, scoped_refptr<media::VideoFrame>)> callback_;
|
||||
base::TimeTicks last_present_time_;
|
||||
};
|
||||
|
||||
// This class provides a hook to get a NativeWindow from a WebContents.
|
||||
class NativeWindowRelay :
|
||||
public content::WebContentsUserData<NativeWindowRelay> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue