fix: FrameSubscriber should not scale frame down (#17444)
This commit is contained in:
parent
235eea6669
commit
e7c48922e7
2 changed files with 16 additions and 6 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include "content/public/browser/render_widget_host.h"
|
#include "content/public/browser/render_widget_host.h"
|
||||||
#include "content/public/browser/render_widget_host_view.h"
|
#include "content/public/browser/render_widget_host_view.h"
|
||||||
#include "media/capture/mojom/video_capture_types.mojom.h"
|
#include "media/capture/mojom/video_capture_types.mojom.h"
|
||||||
|
#include "ui/gfx/geometry/size_conversions.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
#include "ui/gfx/skbitmap_operations.h"
|
#include "ui/gfx/skbitmap_operations.h"
|
||||||
|
|
||||||
|
@ -43,10 +44,9 @@ void FrameSubscriber::AttachToHost(content::RenderWidgetHost* host) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Create and configure the video capturer.
|
// Create and configure the video capturer.
|
||||||
|
gfx::Size size = GetRenderViewSize();
|
||||||
video_capturer_ = host_->GetView()->CreateVideoCapturer();
|
video_capturer_ = host_->GetView()->CreateVideoCapturer();
|
||||||
video_capturer_->SetResolutionConstraints(
|
video_capturer_->SetResolutionConstraints(size, size, true);
|
||||||
host_->GetView()->GetViewBounds().size(),
|
|
||||||
host_->GetView()->GetViewBounds().size(), true);
|
|
||||||
video_capturer_->SetAutoThrottlingEnabled(false);
|
video_capturer_->SetAutoThrottlingEnabled(false);
|
||||||
video_capturer_->SetMinSizeChangePeriod(base::TimeDelta());
|
video_capturer_->SetMinSizeChangePeriod(base::TimeDelta());
|
||||||
video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB,
|
video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB,
|
||||||
|
@ -87,9 +87,9 @@ void FrameSubscriber::OnFrameCaptured(
|
||||||
::media::mojom::VideoFrameInfoPtr info,
|
::media::mojom::VideoFrameInfoPtr info,
|
||||||
const gfx::Rect& content_rect,
|
const gfx::Rect& content_rect,
|
||||||
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr callbacks) {
|
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr callbacks) {
|
||||||
gfx::Size view_size = host_->GetView()->GetViewBounds().size();
|
gfx::Size size = GetRenderViewSize();
|
||||||
if (view_size != content_rect.size()) {
|
if (size != content_rect.size()) {
|
||||||
video_capturer_->SetResolutionConstraints(view_size, view_size, true);
|
video_capturer_->SetResolutionConstraints(size, size, true);
|
||||||
video_capturer_->RequestRefreshFrame();
|
video_capturer_->RequestRefreshFrame();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,13 @@ void FrameSubscriber::Done(const gfx::Rect& damage, const SkBitmap& frame) {
|
||||||
callback_.Run(gfx::Image::CreateFrom1xBitmap(copy), damage);
|
callback_.Run(gfx::Image::CreateFrom1xBitmap(copy), damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfx::Size FrameSubscriber::GetRenderViewSize() const {
|
||||||
|
content::RenderWidgetHostView* view = host_->GetView();
|
||||||
|
gfx::Size size = view->GetViewBounds().size();
|
||||||
|
return gfx::ToRoundedSize(
|
||||||
|
gfx::ScaleSize(gfx::SizeF(size), view->GetDeviceScaleFactor()));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -54,6 +54,9 @@ class FrameSubscriber : public content::WebContentsObserver,
|
||||||
|
|
||||||
void Done(const gfx::Rect& damage, const SkBitmap& frame);
|
void Done(const gfx::Rect& damage, const SkBitmap& frame);
|
||||||
|
|
||||||
|
// Get the pixel size of render view.
|
||||||
|
gfx::Size GetRenderViewSize() const;
|
||||||
|
|
||||||
FrameCaptureCallback callback_;
|
FrameCaptureCallback callback_;
|
||||||
bool only_dirty_;
|
bool only_dirty_;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue