Commit 48803a2d authored by Emircan Uysaler's avatar Emircan Uysaler Committed by Commit Bot

Add a threshold for using GpuMemoryBuffer backed frames on Win for WebRTC

Bug: 835752
Change-Id: Ie7664a31c09fff9f77ce614d34b0f61dfb1ed6c1
Reviewed-on: https://chromium-review.googlesource.com/1035903Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Emircan Uysaler <emircan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555390}
parent e8969644
......@@ -12,7 +12,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "cc/blink/web_layer_impl.h"
#include "cc/layers/video_frame_provider_client_impl.h"
#include "cc/layers/video_layer.h"
......@@ -48,10 +47,21 @@ enum class RendererReloadAction {
REMOVE_RENDERER,
NEW_RENDERER
};
} // namespace
namespace content {
#if defined(OS_WIN)
// Since we do not have native GMB support in Windows, using GMBs can cause a
// CPU regression. This is more apparent and can have adverse affects in lower
// resolution content which are defined by these thresholds, see
// https://crbug.com/835752.
// static
const gfx::Size WebMediaPlayerMS::kUseGpuMemoryBufferVideoFramesMinResolution =
gfx::Size(1920, 1080);
#endif // defined(OS_WIN)
// FrameDeliverer is responsible for delivering frames received on
// the IO thread by calling of EnqueueFrame() method of |compositor_|.
//
......@@ -105,11 +115,21 @@ class WebMediaPlayerMS::FrameDeliverer {
return;
}
#if defined(OS_WIN)
const bool skip_creating_gpu_memory_buffer =
frame->visible_rect().width() <
kUseGpuMemoryBufferVideoFramesMinResolution.width() ||
frame->visible_rect().height() <
kUseGpuMemoryBufferVideoFramesMinResolution.height();
#else
const bool skip_creating_gpu_memory_buffer = false;
#endif // defined(OS_WIN)
// If |render_frame_suspended_|, we can keep passing the frames to keep the
// latest frame in compositor up to date. However, creating GMB backed
// frames is unnecessary, because the frames are not going to be shown for
// the time period.
if (render_frame_suspended_) {
if (render_frame_suspended_ || skip_creating_gpu_memory_buffer) {
EnqueueFrame(std::move(frame));
// If there are any existing MaybeCreateHardwareFrame() calls, we do not
// want those frames to be placed after the current one, so just drop
......
......@@ -13,6 +13,7 @@
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "build/build_config.h"
#include "content/common/content_export.h"
#include "media/blink/webmediaplayer_delegate.h"
#include "media/blink/webmediaplayer_util.h"
......@@ -195,6 +196,10 @@ class CONTENT_EXPORT WebMediaPlayerMS
private:
friend class WebMediaPlayerMSTest;
#if defined(OS_WIN)
static const gfx::Size kUseGpuMemoryBufferVideoFramesMinResolution;
#endif // defined(OS_WIN)
void OnFirstFrameReceived(media::VideoRotation video_rotation,
bool is_opaque);
void OnOpacityChanged(bool is_opaque);
......
......@@ -175,6 +175,7 @@ class MockMediaStreamVideoRenderer : public MediaStreamVideoRenderer {
const base::Closure& error_cb,
const MediaStreamVideoRenderer::RepaintCB& repaint_cb)
: started_(false),
standard_size_(kStandardWidth, kStandardHeight),
task_runner_(task_runner),
message_loop_controller_(message_loop_controller),
error_cb_(error_cb),
......@@ -197,6 +198,9 @@ class MockMediaStreamVideoRenderer : public MediaStreamVideoRenderer {
bool Started() { return started_; }
bool Paused() { return paused_; }
void set_standard_size(const gfx::Size& size) { standard_size_ = size; }
const gfx::Size& get_standard_size() { return standard_size_; }
private:
~MockMediaStreamVideoRenderer() override {}
......@@ -209,6 +213,7 @@ class MockMediaStreamVideoRenderer : public MediaStreamVideoRenderer {
bool started_;
bool paused_;
gfx::Size standard_size_;
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
ReusableMessageLoopEvent* const message_loop_controller_;
......@@ -280,11 +285,12 @@ void MockMediaStreamVideoRenderer::QueueFrames(
bool odd_size_frame,
int double_size_index,
media::VideoRotation rotation) {
gfx::Size standard_size = gfx::Size(kStandardWidth, kStandardHeight);
gfx::Size standard_size = standard_size_;
for (size_t i = 0; i < timestamp_or_frame_type.size(); i++) {
const int token = timestamp_or_frame_type[i];
if (static_cast<int>(i) == double_size_index) {
standard_size = gfx::Size(kStandardWidth * 2, kStandardHeight * 2);
standard_size =
gfx::Size(standard_size_.width() * 2, standard_size_.height() * 2);
}
if (token < static_cast<int>(FrameType::MIN_TYPE)) {
CHECK(false) << "Unrecognized frame type: " << token;
......@@ -551,6 +557,11 @@ class WebMediaPlayerMSTest
}
void SetGpuMemoryBufferVideoForTesting() {
#if defined(OS_WIN)
render_factory_->provider()->set_standard_size(
WebMediaPlayerMS::kUseGpuMemoryBufferVideoFramesMinResolution);
#endif // defined(OS_WIN)
player_->SetGpuMemoryBufferVideoForTesting(
new media::MockGpuMemoryBufferVideoFramePool(&frame_ready_cbs_));
}
......@@ -1094,8 +1105,7 @@ TEST_F(WebMediaPlayerMSTest, CreateHardwareFrames) {
blink::WebMediaPlayer::kReadyStateHaveMetadata));
EXPECT_CALL(*this, DoReadyStateChanged(
blink::WebMediaPlayer::kReadyStateHaveEnoughData));
EXPECT_CALL(*this,
CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight)));
EXPECT_CALL(*this, CheckSizeChanged(provider->get_standard_size()));
std::move(frame_ready_cbs_[0]).Run();
message_loop_controller_.RunAndWaitForStatus(
media::PipelineStatus::PIPELINE_OK);
......@@ -1126,8 +1136,7 @@ TEST_F(WebMediaPlayerMSTest, StopsCreatingHardwareFramesWhenHiddenOrClosed) {
blink::WebMediaPlayer::kReadyStateHaveMetadata));
EXPECT_CALL(*this, DoReadyStateChanged(
blink::WebMediaPlayer::kReadyStateHaveEnoughData));
EXPECT_CALL(*this,
CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight)));
EXPECT_CALL(*this, CheckSizeChanged(provider->get_standard_size()));
message_loop_controller_.RunAndWaitForStatus(
media::PipelineStatus::PIPELINE_OK);
ASSERT_EQ(1u, frame_ready_cbs_.size());
......
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