Commit ca3939ec authored by Collin Baker's avatar Collin Baker Committed by Chromium LUCI CQ

Move video capture logic behind interface

Adds interface BackgroundThumbnailCapturer for capturing background
tabs. The current video capture logic is moved to implementation
BackgroundThumbnailVideoCapturer.

This will allow experimenting with different capture techniques.

Bug: 1090038
Change-Id: I6204f767be6c8bf42aebf79ca0f9e24606d91f70
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2561466Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834465}
parent a7be590d
...@@ -1242,8 +1242,12 @@ static_library("ui") { ...@@ -1242,8 +1242,12 @@ static_library("ui") {
"task_manager/task_manager_columns.h", "task_manager/task_manager_columns.h",
"task_manager/task_manager_table_model.cc", "task_manager/task_manager_table_model.cc",
"task_manager/task_manager_table_model.h", "task_manager/task_manager_table_model.h",
"thumbnails/background_thumbnail_capturer.h",
"thumbnails/background_thumbnail_video_capturer.cc",
"thumbnails/background_thumbnail_video_capturer.h",
"thumbnails/thumbnail_capture_driver.cc", "thumbnails/thumbnail_capture_driver.cc",
"thumbnails/thumbnail_capture_driver.h", "thumbnails/thumbnail_capture_driver.h",
"thumbnails/thumbnail_capture_info.h",
"thumbnails/thumbnail_image.cc", "thumbnails/thumbnail_image.cc",
"thumbnails/thumbnail_image.h", "thumbnails/thumbnail_image.h",
"thumbnails/thumbnail_readiness_tracker.cc", "thumbnails/thumbnail_readiness_tracker.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_THUMBNAILS_BACKGROUND_THUMBNAIL_CAPTURER_H_
#define CHROME_BROWSER_UI_THUMBNAILS_BACKGROUND_THUMBNAIL_CAPTURER_H_
#include "chrome/browser/ui/thumbnails/thumbnail_capture_info.h"
#include "ui/gfx/geometry/size.h"
// Captures thumbnails from a background tab's contents.
class BackgroundThumbnailCapturer {
public:
BackgroundThumbnailCapturer() = default;
virtual ~BackgroundThumbnailCapturer() = default;
// Begins capture. The tab's renderer must be alive. The subclass will
// determine how captured frames are reported to the client.
virtual void Start(const ThumbnailCaptureInfo& capture_info) = 0;
// Ends capture. After this call, the tab no longer needs to be kept
// alive.
virtual void Stop() = 0;
};
#endif // CHROME_BROWSER_UI_THUMBNAILS_BACKGROUND_THUMBNAIL_CAPTURER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/thumbnails/background_thumbnail_video_capturer.h"
#include <utility>
#include "base/metrics/histogram_macros.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "ui/gfx/skia_util.h"
BackgroundThumbnailVideoCapturer::BackgroundThumbnailVideoCapturer(
content::WebContents* contents,
GotFrameCallback got_frame_callback)
: contents_(contents), got_frame_callback_(std::move(got_frame_callback)) {
DCHECK(contents_);
DCHECK(got_frame_callback_);
}
BackgroundThumbnailVideoCapturer::~BackgroundThumbnailVideoCapturer() = default;
void BackgroundThumbnailVideoCapturer::Start(
const ThumbnailCaptureInfo& capture_info) {
if (video_capturer_)
return;
content::RenderWidgetHostView* const source_view =
contents_->GetMainFrame()->GetRenderViewHost()->GetWidget()->GetView();
if (!source_view)
return;
capture_info_ = capture_info;
start_time_ = base::TimeTicks::Now();
got_first_frame_ = false;
constexpr int kMaxFrameRate = 2;
video_capturer_ = source_view->CreateVideoCapturer();
video_capturer_->SetResolutionConstraints(capture_info_.target_size,
capture_info_.target_size, false);
video_capturer_->SetAutoThrottlingEnabled(false);
video_capturer_->SetMinSizeChangePeriod(base::TimeDelta());
video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB,
gfx::ColorSpace::CreateREC709());
video_capturer_->SetMinCapturePeriod(base::TimeDelta::FromSeconds(1) /
kMaxFrameRate);
video_capturer_->Start(this);
}
void BackgroundThumbnailVideoCapturer::Stop() {
if (!video_capturer_)
return;
video_capturer_->Stop();
video_capturer_.reset();
UMA_HISTOGRAM_MEDIUM_TIMES("Tab.Preview.VideoCaptureDuration",
base::TimeTicks::Now() - start_time_);
start_time_ = base::TimeTicks();
}
void BackgroundThumbnailVideoCapturer::OnFrameCaptured(
base::ReadOnlySharedMemoryRegion data,
::media::mojom::VideoFrameInfoPtr info,
const gfx::Rect& content_rect,
mojo::PendingRemote<::viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks) {
CHECK(video_capturer_);
const base::TimeTicks time_of_call = base::TimeTicks::Now();
mojo::Remote<::viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks_remote(std::move(callbacks));
// Process captured image.
if (!data.IsValid()) {
callbacks_remote->Done();
return;
}
base::ReadOnlySharedMemoryMapping mapping = data.Map();
if (!mapping.IsValid()) {
DLOG(ERROR) << "Shared memory mapping failed.";
return;
}
if (mapping.size() <
media::VideoFrame::AllocationSize(info->pixel_format, info->coded_size)) {
DLOG(ERROR) << "Shared memory size was less than expected.";
return;
}
if (!info->color_space) {
DLOG(ERROR) << "Missing mandatory color space info.";
return;
}
if (!got_first_frame_)
UMA_HISTOGRAM_TIMES("Tab.Preview.TimeToFirstUsableFrameAfterStartCapture",
time_of_call - start_time_);
got_first_frame_ = true;
// The SkBitmap's pixels will be marked as immutable, but the installPixels()
// API requires a non-const pointer. So, cast away the const.
void* const pixels = const_cast<void*>(mapping.memory());
// Call installPixels() with a |releaseProc| that: 1) notifies the capturer
// that this consumer has finished with the frame, and 2) releases the shared
// memory mapping.
struct FramePinner {
// Keeps the shared memory that backs |frame_| mapped.
base::ReadOnlySharedMemoryMapping mapping;
// Prevents FrameSinkVideoCapturer from recycling the shared memory that
// backs |frame_|.
mojo::PendingRemote<viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
releaser;
};
// Subtract back out the scroll bars if we decided there was enough canvas to
// account for them and still have a decent preview image.
const float scale_ratio =
float{content_rect.width()} / float{capture_info_.copy_rect.width()};
const gfx::Insets original_scroll_insets = capture_info_.scrollbar_insets;
const gfx::Insets scroll_insets(
0, 0, std::round(original_scroll_insets.width() * scale_ratio),
std::round(original_scroll_insets.height() * scale_ratio));
gfx::Rect effective_content_rect = content_rect;
effective_content_rect.Inset(scroll_insets);
const gfx::Size bitmap_size(content_rect.right(), content_rect.bottom());
SkBitmap frame;
frame.installPixels(
SkImageInfo::MakeN32(bitmap_size.width(), bitmap_size.height(),
kPremul_SkAlphaType,
info->color_space->ToSkColorSpace()),
pixels,
media::VideoFrame::RowBytes(media::VideoFrame::kARGBPlane,
info->pixel_format, info->coded_size.width()),
[](void* addr, void* context) {
delete static_cast<FramePinner*>(context);
},
new FramePinner{std::move(mapping), callbacks_remote.Unbind()});
frame.setImmutable();
SkBitmap cropped_frame;
if (frame.extractSubset(&cropped_frame,
gfx::RectToSkIRect(effective_content_rect))) {
UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
"Tab.Preview.TimeToStoreAfterFrameReceived",
base::TimeTicks::Now() - time_of_call,
base::TimeDelta::FromMicroseconds(10),
base::TimeDelta::FromMilliseconds(10), 50);
got_frame_callback_.Run(cropped_frame);
}
}
void BackgroundThumbnailVideoCapturer::OnStopped() {}
void BackgroundThumbnailVideoCapturer::OnLog(const std::string& /*message*/) {}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_THUMBNAILS_BACKGROUND_THUMBNAIL_VIDEO_CAPTURER_H_
#define CHROME_BROWSER_UI_THUMBNAILS_BACKGROUND_THUMBNAIL_VIDEO_CAPTURER_H_
#include "base/callback.h"
#include "base/time/time.h"
#include "chrome/browser/ui/thumbnails/background_thumbnail_capturer.h"
#include "components/viz/host/client_frame_sink_video_capturer.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace content {
class WebContents;
} // namespace content
// A thumbnail capturer using viz::ClientFrameSinkVideoCapturer. Gets a
// sequence of frames in the same way as streaming a tab.
class BackgroundThumbnailVideoCapturer
: public BackgroundThumbnailCapturer,
public viz::mojom::FrameSinkVideoConsumer {
public:
using GotFrameCallback = base::RepeatingCallback<void(const SkBitmap&)>;
BackgroundThumbnailVideoCapturer(content::WebContents* contents,
GotFrameCallback got_frame_callback);
~BackgroundThumbnailVideoCapturer() override;
// BackgroundThumbnailCapturer:
void Start(const ThumbnailCaptureInfo& capture_info) override;
void Stop() override;
private:
// viz::mojom::FrameSinkVideoConsumer:
void OnFrameCaptured(
base::ReadOnlySharedMemoryRegion data,
::media::mojom::VideoFrameInfoPtr info,
const gfx::Rect& content_rect,
mojo::PendingRemote<::viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks) override;
void OnStopped() override;
void OnLog(const std::string& /*message*/) override;
content::WebContents* const contents_;
GotFrameCallback got_frame_callback_;
ThumbnailCaptureInfo capture_info_;
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
base::TimeTicks start_time_;
bool got_first_frame_ = false;
};
#endif // CHROME_BROWSER_UI_THUMBNAILS_BACKGROUND_THUMBNAIL_VIDEO_CAPTURER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_THUMBNAILS_THUMBNAIL_CAPTURE_INFO_H_
#define CHROME_BROWSER_UI_THUMBNAILS_THUMBNAIL_CAPTURE_INFO_H_
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
// Describes how a thumbnail bitmap should be generated from a target surface.
// All sizes are in pixels, not DIPs.
struct ThumbnailCaptureInfo {
// The total source size (including scrollbars).
gfx::Size source_size;
// Insets for scrollbars in the source image that should probably be
// ignored for thumbnailing purposes.
gfx::Insets scrollbar_insets;
// Cropping rectangle for the source canvas, in pixels.
gfx::Rect copy_rect;
// Size of the target bitmap in pixels.
gfx::Size target_size;
};
#endif // CHROME_BROWSER_UI_THUMBNAILS_THUMBNAIL_CAPTURE_INFO_H_
...@@ -16,22 +16,18 @@ ...@@ -16,22 +16,18 @@
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/tab_load_tracker.h"
#include "chrome/browser/ui/tabs/tab_style.h" #include "chrome/browser/ui/tabs/tab_style.h"
#include "chrome/browser/ui/thumbnails/background_thumbnail_video_capturer.h"
#include "chrome/browser/ui/thumbnails/thumbnail_capture_driver.h" #include "chrome/browser/ui/thumbnails/thumbnail_capture_driver.h"
#include "chrome/browser/ui/thumbnails/thumbnail_readiness_tracker.h" #include "chrome/browser/ui/thumbnails/thumbnail_readiness_tracker.h"
#include "chrome/browser/ui/thumbnails/thumbnail_scheduler.h" #include "chrome/browser/ui/thumbnails/thumbnail_scheduler.h"
#include "chrome/browser/ui/thumbnails/thumbnail_scheduler_impl.h" #include "chrome/browser/ui/thumbnails/thumbnail_scheduler_impl.h"
#include "components/history/core/common/thumbnail_score.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#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 "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/size_f.h" #include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/scrollbar_size.h" #include "ui/gfx/scrollbar_size.h"
...@@ -212,6 +208,11 @@ class ThumbnailTabHelper::TabStateTracker ...@@ -212,6 +208,11 @@ class ThumbnailTabHelper::TabStateTracker
ThumbnailTabHelper::ThumbnailTabHelper(content::WebContents* contents) ThumbnailTabHelper::ThumbnailTabHelper(content::WebContents* contents)
: state_(std::make_unique<TabStateTracker>(this, contents)), : state_(std::make_unique<TabStateTracker>(this, contents)),
background_capturer_(std::make_unique<BackgroundThumbnailVideoCapturer>(
contents,
base::BindRepeating(&ThumbnailTabHelper::StoreThumbnail,
base::Unretained(this),
CaptureType::kVideoFrame))),
thumbnail_(base::MakeRefCounted<ThumbnailImage>(state_.get())) {} thumbnail_(base::MakeRefCounted<ThumbnailImage>(state_.get())) {}
ThumbnailTabHelper::~ThumbnailTabHelper() { ThumbnailTabHelper::~ThumbnailTabHelper() {
...@@ -282,159 +283,29 @@ void ThumbnailTabHelper::StoreThumbnail(CaptureType type, ...@@ -282,159 +283,29 @@ void ThumbnailTabHelper::StoreThumbnail(CaptureType type,
} }
void ThumbnailTabHelper::StartVideoCapture() { void ThumbnailTabHelper::StartVideoCapture() {
if (video_capturer_)
return;
// This pointer can become null before this method is called - see
// RenderWidgetHost::GetView() for details.
content::RenderWidgetHostView* const source_view = state_->GetView(); content::RenderWidgetHostView* const source_view = state_->GetView();
if (!source_view) if (!source_view)
return; return;
// Get the source size and scale.
const float scale_factor = source_view->GetDeviceScaleFactor(); const float scale_factor = source_view->GetDeviceScaleFactor();
const gfx::Size source_size = source_view->GetViewBounds().size(); const gfx::Size source_size = source_view->GetViewBounds().size();
if (source_size.IsEmpty()) if (source_size.IsEmpty())
return; return;
start_video_capture_time_ = base::TimeTicks::Now(); last_frame_capture_info_ = GetInitialCaptureInfo(
got_first_frame_ = false; source_size, scale_factor, /* include_scrollbars_in_capture */ true);
background_capturer_->Start(last_frame_capture_info_);
// Figure out how large we want the capture target to be.
last_frame_capture_info_ =
GetInitialCaptureInfo(source_size, scale_factor,
/* include_scrollbars_in_capture */ true);
const gfx::Size& target_size = last_frame_capture_info_.target_size;
constexpr int kMaxFrameRate = 2;
video_capturer_ = source_view->CreateVideoCapturer();
video_capturer_->SetResolutionConstraints(target_size, target_size, false);
video_capturer_->SetAutoThrottlingEnabled(false);
video_capturer_->SetMinSizeChangePeriod(base::TimeDelta());
video_capturer_->SetFormat(media::PIXEL_FORMAT_ARGB,
gfx::ColorSpace::CreateREC709());
video_capturer_->SetMinCapturePeriod(base::TimeDelta::FromSeconds(1) /
kMaxFrameRate);
video_capturer_->Start(this);
} }
void ThumbnailTabHelper::StopVideoCapture() { void ThumbnailTabHelper::StopVideoCapture() {
if (!video_capturer_) { background_capturer_->Stop();
DCHECK_EQ(start_video_capture_time_, base::TimeTicks());
return;
}
video_capturer_->Stop();
video_capturer_.reset();
UMA_HISTOGRAM_MEDIUM_TIMES(
"Tab.Preview.VideoCaptureDuration",
base::TimeTicks::Now() - start_video_capture_time_);
start_video_capture_time_ = base::TimeTicks();
} }
void ThumbnailTabHelper::OnFrameCaptured(
base::ReadOnlySharedMemoryRegion data,
::media::mojom::VideoFrameInfoPtr info,
const gfx::Rect& content_rect,
mojo::PendingRemote<::viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks) {
CHECK(video_capturer_);
const base::TimeTicks time_of_call = base::TimeTicks::Now();
mojo::Remote<::viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks_remote(std::move(callbacks));
// Process captured image.
if (!data.IsValid()) {
callbacks_remote->Done();
return;
}
base::ReadOnlySharedMemoryMapping mapping = data.Map();
if (!mapping.IsValid()) {
DLOG(ERROR) << "Shared memory mapping failed.";
return;
}
if (mapping.size() <
media::VideoFrame::AllocationSize(info->pixel_format, info->coded_size)) {
DLOG(ERROR) << "Shared memory size was less than expected.";
return;
}
if (!info->color_space) {
DLOG(ERROR) << "Missing mandatory color space info.";
return;
}
if (!got_first_frame_) {
UMA_HISTOGRAM_TIMES("Tab.Preview.TimeToFirstUsableFrameAfterStartCapture",
time_of_call - start_video_capture_time_);
got_first_frame_ = true;
}
// The SkBitmap's pixels will be marked as immutable, but the installPixels()
// API requires a non-const pointer. So, cast away the const.
void* const pixels = const_cast<void*>(mapping.memory());
// Call installPixels() with a |releaseProc| that: 1) notifies the capturer
// that this consumer has finished with the frame, and 2) releases the shared
// memory mapping.
struct FramePinner {
// Keeps the shared memory that backs |frame_| mapped.
base::ReadOnlySharedMemoryMapping mapping;
// Prevents FrameSinkVideoCapturer from recycling the shared memory that
// backs |frame_|.
mojo::PendingRemote<viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
releaser;
};
// Subtract back out the scroll bars if we decided there was enough canvas to
// account for them and still have a decent preview image.
const float scale_ratio = float{content_rect.width()} /
float{last_frame_capture_info_.copy_rect.width()};
const gfx::Insets original_scroll_insets =
last_frame_capture_info_.scrollbar_insets;
const gfx::Insets scroll_insets(
0, 0, std::round(original_scroll_insets.width() * scale_ratio),
std::round(original_scroll_insets.height() * scale_ratio));
gfx::Rect effective_content_rect = content_rect;
effective_content_rect.Inset(scroll_insets);
const gfx::Size bitmap_size(content_rect.right(), content_rect.bottom());
SkBitmap frame;
frame.installPixels(
SkImageInfo::MakeN32(bitmap_size.width(), bitmap_size.height(),
kPremul_SkAlphaType,
info->color_space->ToSkColorSpace()),
pixels,
media::VideoFrame::RowBytes(media::VideoFrame::kARGBPlane,
info->pixel_format, info->coded_size.width()),
[](void* addr, void* context) {
delete static_cast<FramePinner*>(context);
},
new FramePinner{std::move(mapping), callbacks_remote.Unbind()});
frame.setImmutable();
SkBitmap cropped_frame;
if (frame.extractSubset(&cropped_frame,
gfx::RectToSkIRect(effective_content_rect))) {
UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
"Tab.Preview.TimeToStoreAfterFrameReceived",
base::TimeTicks::Now() - time_of_call,
base::TimeDelta::FromMicroseconds(10),
base::TimeDelta::FromMilliseconds(10), 50);
StoreThumbnail(CaptureType::kVideoFrame, cropped_frame);
}
}
void ThumbnailTabHelper::OnStopped() {}
// static // static
ThumbnailTabHelper::ThumbnailCaptureInfo ThumbnailCaptureInfo ThumbnailTabHelper::GetInitialCaptureInfo(
ThumbnailTabHelper::GetInitialCaptureInfo(const gfx::Size& source_size, const gfx::Size& source_size,
float scale_factor, float scale_factor,
bool include_scrollbars_in_capture) { bool include_scrollbars_in_capture) {
ThumbnailCaptureInfo capture_info; ThumbnailCaptureInfo capture_info;
capture_info.source_size = source_size; capture_info.source_size = source_size;
......
...@@ -11,18 +11,18 @@ ...@@ -11,18 +11,18 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/ui/thumbnails/thumbnail_capture_info.h"
#include "chrome/browser/ui/thumbnails/thumbnail_image.h" #include "chrome/browser/ui/thumbnails/thumbnail_image.h"
#include "components/viz/host/client_frame_sink_video_capturer.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
class BackgroundThumbnailCapturer;
class ThumbnailScheduler; class ThumbnailScheduler;
class ThumbnailTabHelper class ThumbnailTabHelper
: public content::WebContentsUserData<ThumbnailTabHelper>, : public content::WebContentsUserData<ThumbnailTabHelper> {
public viz::mojom::FrameSinkVideoConsumer {
public: public:
~ThumbnailTabHelper() override; ~ThumbnailTabHelper() override;
...@@ -36,23 +36,6 @@ class ThumbnailTabHelper ...@@ -36,23 +36,6 @@ class ThumbnailTabHelper
enum class CaptureType; enum class CaptureType;
static void RecordCaptureType(CaptureType type); static void RecordCaptureType(CaptureType type);
// Describes how a thumbnail bitmap should be generated from a target surface.
// All sizes are in pixels, not DIPs.
struct ThumbnailCaptureInfo {
// The total source size (including scrollbars).
gfx::Size source_size;
// Insets for scrollbars in the source image that should probably be
// ignored for thumbnailing purposes.
gfx::Insets scrollbar_insets;
// Cropping rectangle for the source canvas, in pixels.
gfx::Rect copy_rect;
// Size of the target bitmap in pixels.
gfx::Size target_size;
};
explicit ThumbnailTabHelper(content::WebContents* contents); explicit ThumbnailTabHelper(content::WebContents* contents);
static ThumbnailScheduler& GetScheduler(); static ThumbnailScheduler& GetScheduler();
...@@ -70,14 +53,6 @@ class ThumbnailTabHelper ...@@ -70,14 +53,6 @@ class ThumbnailTabHelper
void StoreThumbnail(CaptureType type, const SkBitmap& bitmap); void StoreThumbnail(CaptureType type, const SkBitmap& bitmap);
// viz::mojom::FrameSinkVideoConsumer: // viz::mojom::FrameSinkVideoConsumer:
void OnFrameCaptured(
base::ReadOnlySharedMemoryRegion data,
::media::mojom::VideoFrameInfoPtr info,
const gfx::Rect& content_rect,
mojo::PendingRemote<::viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks) override;
void OnStopped() override;
void OnLog(const std::string& /*message*/) override {}
// Returns the dimensions of the multipurpose thumbnail that should be // Returns the dimensions of the multipurpose thumbnail that should be
// captured from an entire webpage. Can be cropped or compressed later. // captured from an entire webpage. Can be cropped or compressed later.
...@@ -93,13 +68,11 @@ class ThumbnailTabHelper ...@@ -93,13 +68,11 @@ class ThumbnailTabHelper
// Copy info from the most recent frame we have captured. // Copy info from the most recent frame we have captured.
ThumbnailCaptureInfo last_frame_capture_info_; ThumbnailCaptureInfo last_frame_capture_info_;
// Captures frames from the WebContents while it's hidden. The capturer count
// of the WebContents is incremented/decremented when a capturer is set/unset.
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
// Private implementation of state tracking. // Private implementation of state tracking.
std::unique_ptr<TabStateTracker> state_; std::unique_ptr<TabStateTracker> state_;
std::unique_ptr<BackgroundThumbnailCapturer> background_capturer_;
// Times for computing metrics. // Times for computing metrics.
base::TimeTicks start_video_capture_time_; base::TimeTicks start_video_capture_time_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment