Commit 6220cb63 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

[Surfaces]: Introduce infinite deadline as a DeadlinePolicy choice.

This patch introduces an infinite deadline as a possible DeadlinePolicy
choice. This would be used in the future when a forced surface
synchronization is requested.

R=fsamuel@chromium.org, piman@chromium.org

Bug: 667551
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Iad25d2fd7a8c65e5b53034b448029f463ed717a3
Reviewed-on: https://chromium-review.googlesource.com/996762Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548295}
parent 095215df
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "cc/layers/deadline_policy.h" #include "cc/layers/deadline_policy.h"
#include <limits>
namespace cc { namespace cc {
// static // static
...@@ -19,17 +21,18 @@ DeadlinePolicy DeadlinePolicy::UseDefaultDeadline() { ...@@ -19,17 +21,18 @@ DeadlinePolicy DeadlinePolicy::UseDefaultDeadline() {
// static // static
DeadlinePolicy DeadlinePolicy::UseSpecifiedDeadline( DeadlinePolicy DeadlinePolicy::UseSpecifiedDeadline(
uint32_t deadline_in_frames) { uint32_t deadline_in_frames) {
return DeadlinePolicy(deadline_in_frames); return DeadlinePolicy(Type::kUseSpecifiedDeadline, deadline_in_frames);
} }
DeadlinePolicy::DeadlinePolicy(Type policy_type) // static
: policy_type_(policy_type), deadline_in_frames_(base::nullopt) { DeadlinePolicy DeadlinePolicy::UseInfiniteDeadline() {
DCHECK_NE(Type::kUseSpecifiedDeadline, policy_type_); return DeadlinePolicy(Type::kUseInfiniteDeadline,
std::numeric_limits<uint32_t>::max());
} }
DeadlinePolicy::DeadlinePolicy(uint32_t deadline_in_frames) DeadlinePolicy::DeadlinePolicy(Type policy_type,
: policy_type_(Type::kUseSpecifiedDeadline), base::Optional<uint32_t> deadline_in_frames)
deadline_in_frames_(deadline_in_frames) {} : policy_type_(policy_type), deadline_in_frames_(deadline_in_frames) {}
DeadlinePolicy::DeadlinePolicy(const DeadlinePolicy& other) = default; DeadlinePolicy::DeadlinePolicy(const DeadlinePolicy& other) = default;
......
...@@ -18,7 +18,8 @@ class CC_EXPORT DeadlinePolicy { ...@@ -18,7 +18,8 @@ class CC_EXPORT DeadlinePolicy {
enum Type { enum Type {
kUseExistingDeadline, kUseExistingDeadline,
kUseDefaultDeadline, kUseDefaultDeadline,
kUseSpecifiedDeadline kUseSpecifiedDeadline,
kUseInfiniteDeadline
}; };
static DeadlinePolicy UseExistingDeadline(); static DeadlinePolicy UseExistingDeadline();
...@@ -27,6 +28,8 @@ class CC_EXPORT DeadlinePolicy { ...@@ -27,6 +28,8 @@ class CC_EXPORT DeadlinePolicy {
static DeadlinePolicy UseSpecifiedDeadline(uint32_t deadline_in_frames); static DeadlinePolicy UseSpecifiedDeadline(uint32_t deadline_in_frames);
static DeadlinePolicy UseInfiniteDeadline();
DeadlinePolicy(const DeadlinePolicy& other); DeadlinePolicy(const DeadlinePolicy& other);
DeadlinePolicy& operator=(const DeadlinePolicy& other) = default; DeadlinePolicy& operator=(const DeadlinePolicy& other) = default;
...@@ -39,7 +42,8 @@ class CC_EXPORT DeadlinePolicy { ...@@ -39,7 +42,8 @@ class CC_EXPORT DeadlinePolicy {
base::Optional<uint32_t> deadline_in_frames() const { base::Optional<uint32_t> deadline_in_frames() const {
DCHECK(policy_type_ == Type::kUseDefaultDeadline || DCHECK(policy_type_ == Type::kUseDefaultDeadline ||
policy_type_ == Type::kUseSpecifiedDeadline); policy_type_ == Type::kUseSpecifiedDeadline ||
policy_type_ == Type::kUseInfiniteDeadline);
return deadline_in_frames_; return deadline_in_frames_;
} }
...@@ -55,9 +59,9 @@ class CC_EXPORT DeadlinePolicy { ...@@ -55,9 +59,9 @@ class CC_EXPORT DeadlinePolicy {
} }
private: private:
explicit DeadlinePolicy(Type policy_type); explicit DeadlinePolicy(
Type policy_type,
explicit DeadlinePolicy(uint32_t deadline_in_frames); base::Optional<uint32_t> deadline_in_frames = base::nullopt);
Type policy_type_; Type policy_type_;
base::Optional<uint32_t> deadline_in_frames_; base::Optional<uint32_t> deadline_in_frames_;
......
...@@ -86,6 +86,18 @@ TEST_F(SurfaceLayerTest, UseExistingDeadlineForNewSurfaceLayer) { ...@@ -86,6 +86,18 @@ TEST_F(SurfaceLayerTest, UseExistingDeadlineForNewSurfaceLayer) {
EXPECT_EQ(0u, layer->deadline_in_frames()); EXPECT_EQ(0u, layer->deadline_in_frames());
} }
// This test verifies that if UseInfiniteDeadline() is used on a new
// SurfaceLayer then the deadline will be max number of frames.
TEST_F(SurfaceLayerTest, UseInfiniteDeadlineForNewSurfaceLayer) {
scoped_refptr<SurfaceLayer> layer = SurfaceLayer::Create();
layer_tree_host_->SetRootLayer(layer);
viz::SurfaceId primary_id(
kArbitraryFrameSinkId,
viz::LocalSurfaceId(1, base::UnguessableToken::Create()));
layer->SetPrimarySurfaceId(primary_id, DeadlinePolicy::UseInfiniteDeadline());
EXPECT_EQ(std::numeric_limits<uint32_t>::max(), layer->deadline_in_frames());
}
// This test verifies that SurfaceLayer properties are pushed across to // This test verifies that SurfaceLayer properties are pushed across to
// SurfaceLayerImpl. // SurfaceLayerImpl.
TEST_F(SurfaceLayerTest, PushProperties) { TEST_F(SurfaceLayerTest, PushProperties) {
......
...@@ -302,8 +302,13 @@ void DelegatedFrameHost::WasResized( ...@@ -302,8 +302,13 @@ void DelegatedFrameHost::WasResized(
// On Windows and Linux, we would like to produce new content as soon as // On Windows and Linux, we would like to produce new content as soon as
// possible or the OS will create an additional black gutter. Until we can // possible or the OS will create an additional black gutter. Until we can
// block resize on surface synchronization on these platforms, we will not // block resize on surface synchronization on these platforms, we will not
// block UI on the top-level renderer. // block UI on the top-level renderer. The exception to this is if we're
deadline_policy = cc::DeadlinePolicy::UseSpecifiedDeadline(0u); // using an infinite deadline, in which case we should respect the
// specified deadline and block UI since that's what was requested.
if (deadline_policy.policy_type() !=
cc::DeadlinePolicy::kUseInfiniteDeadline) {
deadline_policy = cc::DeadlinePolicy::UseSpecifiedDeadline(0u);
}
#endif #endif
client_->DelegatedFrameHostGetLayer()->SetShowPrimarySurface( client_->DelegatedFrameHostGetLayer()->SetShowPrimarySurface(
surface_id, current_frame_size_in_dip_, GetGutterColor(), surface_id, current_frame_size_in_dip_, GetGutterColor(),
......
...@@ -148,8 +148,9 @@ void BrowserPlugin::OnSetChildFrameSurface( ...@@ -148,8 +148,9 @@ void BrowserPlugin::OnSetChildFrameSurface(
return; return;
if (!enable_surface_synchronization_) { if (!enable_surface_synchronization_) {
compositing_helper_->SetPrimarySurfaceId(surface_info.id(), compositing_helper_->SetPrimarySurfaceId(
screen_space_rect().size()); surface_info.id(), screen_space_rect().size(),
cc::DeadlinePolicy::UseDefaultDeadline());
} }
compositing_helper_->SetFallbackSurfaceId(surface_info.id(), compositing_helper_->SetFallbackSurfaceId(surface_info.id(),
screen_space_rect().size()); screen_space_rect().size());
...@@ -272,9 +273,11 @@ void BrowserPlugin::WasResized() { ...@@ -272,9 +273,11 @@ void BrowserPlugin::WasResized() {
parent_local_surface_id_allocator_.GenerateId(); parent_local_surface_id_allocator_.GenerateId();
if (enable_surface_synchronization_ && frame_sink_id_.is_valid()) { if (enable_surface_synchronization_ && frame_sink_id_.is_valid()) {
// TODO(vmpstr): When capture_sequence_number is available, the deadline
// should be infinite if the sequence number has changed.
compositing_helper_->SetPrimarySurfaceId( compositing_helper_->SetPrimarySurfaceId(
viz::SurfaceId(frame_sink_id_, GetLocalSurfaceId()), viz::SurfaceId(frame_sink_id_, GetLocalSurfaceId()),
screen_space_rect().size()); screen_space_rect().size(), cc::DeadlinePolicy::UseDefaultDeadline());
} }
bool position_changed = !sent_resize_params_ || bool position_changed = !sent_resize_params_ ||
......
...@@ -72,7 +72,8 @@ void ChildFrameCompositingHelper::ChildFrameGone( ...@@ -72,7 +72,8 @@ void ChildFrameCompositingHelper::ChildFrameGone(
void ChildFrameCompositingHelper::SetPrimarySurfaceId( void ChildFrameCompositingHelper::SetPrimarySurfaceId(
const viz::SurfaceId& surface_id, const viz::SurfaceId& surface_id,
const gfx::Size& frame_size_in_dip) { const gfx::Size& frame_size_in_dip,
const cc::DeadlinePolicy& deadline) {
if (primary_surface_id_ == surface_id) if (primary_surface_id_ == surface_id)
return; return;
...@@ -83,8 +84,7 @@ void ChildFrameCompositingHelper::SetPrimarySurfaceId( ...@@ -83,8 +84,7 @@ void ChildFrameCompositingHelper::SetPrimarySurfaceId(
surface_layer_->SetHitTestable(true); surface_layer_->SetHitTestable(true);
surface_layer_->SetBackgroundColor(SK_ColorTRANSPARENT); surface_layer_->SetBackgroundColor(SK_ColorTRANSPARENT);
surface_layer_->SetPrimarySurfaceId(surface_id, surface_layer_->SetPrimarySurfaceId(surface_id, deadline);
cc::DeadlinePolicy::UseDefaultDeadline());
surface_layer_->SetFallbackSurfaceId(fallback_surface_id_); surface_layer_->SetFallbackSurfaceId(fallback_surface_id_);
std::unique_ptr<cc_blink::WebLayerImpl> layer( std::unique_ptr<cc_blink::WebLayerImpl> layer(
...@@ -111,7 +111,8 @@ void ChildFrameCompositingHelper::SetFallbackSurfaceId( ...@@ -111,7 +111,8 @@ void ChildFrameCompositingHelper::SetFallbackSurfaceId(
fallback_surface_id_ = surface_id; fallback_surface_id_ = surface_id;
if (!surface_layer_) { if (!surface_layer_) {
SetPrimarySurfaceId(surface_id, frame_size_in_dip); SetPrimarySurfaceId(surface_id, frame_size_in_dip,
cc::DeadlinePolicy::UseDefaultDeadline());
return; return;
} }
......
...@@ -36,7 +36,8 @@ class CONTENT_EXPORT ChildFrameCompositingHelper { ...@@ -36,7 +36,8 @@ class CONTENT_EXPORT ChildFrameCompositingHelper {
virtual ~ChildFrameCompositingHelper(); virtual ~ChildFrameCompositingHelper();
void SetPrimarySurfaceId(const viz::SurfaceId& surface_id, void SetPrimarySurfaceId(const viz::SurfaceId& surface_id,
const gfx::Size& frame_size_in_dip); const gfx::Size& frame_size_in_dip,
const cc::DeadlinePolicy& deadline);
void SetFallbackSurfaceId(const viz::SurfaceId& surface_id, void SetFallbackSurfaceId(const viz::SurfaceId& surface_id,
const gfx::Size& frame_size_in_dip); const gfx::Size& frame_size_in_dip);
void UpdateVisibility(bool visible); void UpdateVisibility(bool visible);
......
...@@ -369,8 +369,9 @@ void RenderFrameProxy::SetChildFrameSurface( ...@@ -369,8 +369,9 @@ void RenderFrameProxy::SetChildFrameSurface(
return; return;
if (!enable_surface_synchronization_) { if (!enable_surface_synchronization_) {
compositing_helper_->SetPrimarySurfaceId(surface_info.id(), compositing_helper_->SetPrimarySurfaceId(
local_frame_size()); surface_info.id(), local_frame_size(),
cc::DeadlinePolicy::UseDefaultDeadline());
} }
compositing_helper_->SetFallbackSurfaceId(surface_info.id(), compositing_helper_->SetFallbackSurfaceId(surface_info.id(),
local_frame_size()); local_frame_size());
...@@ -612,8 +613,13 @@ void RenderFrameProxy::WasResized() { ...@@ -612,8 +613,13 @@ void RenderFrameProxy::WasResized() {
local_surface_id_ = parent_local_surface_id_allocator_.GenerateId(); local_surface_id_ = parent_local_surface_id_allocator_.GenerateId();
viz::SurfaceId surface_id(frame_sink_id_, local_surface_id_); viz::SurfaceId surface_id(frame_sink_id_, local_surface_id_);
if (enable_surface_synchronization_) if (enable_surface_synchronization_) {
compositing_helper_->SetPrimarySurfaceId(surface_id, local_frame_size()); // TODO(vmpstr): When capture_sequence_number is available, the deadline
// should be infinite if the sequence number has changed.
compositing_helper_->SetPrimarySurfaceId(
surface_id, local_frame_size(),
cc::DeadlinePolicy::UseDefaultDeadline());
}
bool rect_changed = bool rect_changed =
!sent_resize_params_ || sent_resize_params_->screen_space_rect != !sent_resize_params_ || sent_resize_params_->screen_space_rect !=
......
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