Commit 5fb3f7f8 authored by Mohsen Izadi's avatar Mohsen Izadi Committed by Commit Bot

Limit top/bottom controls data in CompositorFrameMetadata to Android

These fields of CompositorFrameMetadata are not used on other platforms:
 - |top_controls_height|,
 - |top_controls_shown_ratio|,
 - |bottom_controls_height|,
 - |bottom_controls_shown_ratio|.

BUG=859969

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ibe602785bf2214bd371b3ed64964f112e3c7f149
Reviewed-on: https://chromium-review.googlesource.com/1184237Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarThomas Guilbert <tguilbert@chromium.org>
Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Commit-Queue: Mohsen Izadi <mohsen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586340}
parent e684cf41
......@@ -1899,14 +1899,6 @@ viz::CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() {
metadata.page_scale_factor = active_tree_->current_page_scale_factor();
metadata.scrollable_viewport_size = active_tree_->ScrollableViewportSize();
metadata.top_controls_height =
browser_controls_offset_manager_->TopControlsHeight();
metadata.top_controls_shown_ratio =
browser_controls_offset_manager_->TopControlsShownRatio();
metadata.bottom_controls_height =
browser_controls_offset_manager_->BottomControlsHeight();
metadata.bottom_controls_shown_ratio =
browser_controls_offset_manager_->BottomControlsShownRatio();
metadata.root_background_color = active_tree_->background_color();
metadata.content_source_id = active_tree_->content_source_id();
......@@ -1948,6 +1940,15 @@ viz::CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() {
!outer_viewport_scroll_node->user_scrollable_vertical;
}
metadata.top_controls_height =
browser_controls_offset_manager_->TopControlsHeight();
metadata.top_controls_shown_ratio =
browser_controls_offset_manager_->TopControlsShownRatio();
metadata.bottom_controls_height =
browser_controls_offset_manager_->BottomControlsHeight();
metadata.bottom_controls_shown_ratio =
browser_controls_offset_manager_->BottomControlsShownRatio();
active_tree_->GetViewportSelection(&metadata.selection);
#endif
......
......@@ -64,16 +64,6 @@ class VIZ_COMMON_EXPORT CompositorFrameMetadata {
// depending on this anymore.
bool is_resourceless_software_draw_with_scroll_or_animation = false;
// Used to position the Android location top bar and page content, whose
// precise position is computed by the renderer compositor.
float top_controls_height = 0.f;
float top_controls_shown_ratio = 0.f;
// Used to position Android bottom bar, whose position is computed by the
// renderer compositor.
float bottom_controls_height = 0.f;
float bottom_controls_shown_ratio = 0.f;
// This color is usually obtained from the background color of the <body>
// element. It can be used for filling in gutter areas around the frame when
// it's too small to fill the box the parent reserved for it.
......@@ -147,6 +137,16 @@ class VIZ_COMMON_EXPORT CompositorFrameMetadata {
gfx::SizeF root_layer_size;
bool root_overflow_y_hidden = false;
// Used to position the Android location top bar and page content, whose
// precise position is computed by the renderer compositor.
float top_controls_height = 0.f;
float top_controls_shown_ratio = 0.f;
// Used to position Android bottom bar, whose position is computed by the
// renderer compositor.
float bottom_controls_height = 0.f;
float bottom_controls_shown_ratio = 0.f;
// Provides selection region updates relative to the current viewport. If the
// selection is empty or otherwise unused, the bound types will indicate such.
Selection<gfx::SelectionBound> selection;
......
......@@ -13,6 +13,7 @@
#include "base/stl_util.h"
#include "base/time/default_tick_clock.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
#include "components/viz/common/surfaces/local_surface_id.h"
......@@ -497,10 +498,12 @@ void FrameSinkVideoCapturerImpl::MaybeCaptureFrame(
frame_metadata.root_scroll_offset.x());
metadata->SetDouble(VideoFrameMetadata::ROOT_SCROLL_OFFSET_Y,
frame_metadata.root_scroll_offset.y());
#if defined(OS_ANDROID)
metadata->SetDouble(VideoFrameMetadata::TOP_CONTROLS_HEIGHT,
frame_metadata.top_controls_height);
metadata->SetDouble(VideoFrameMetadata::TOP_CONTROLS_SHOWN_RATIO,
frame_metadata.top_controls_shown_ratio);
#endif // defined(OS_ANDROID)
oracle_.RecordCapture(utilization);
const int64_t frame_number = next_capture_frame_number_++;
......
......@@ -172,11 +172,16 @@ void GetMetadataFromFrame(const media::VideoFrame& frame,
media::VideoFrameMetadata::ROOT_SCROLL_OFFSET_X, &root_scroll_offset_x);
success &= frame.metadata()->GetDouble(
media::VideoFrameMetadata::ROOT_SCROLL_OFFSET_Y, &root_scroll_offset_y);
#if defined(OS_ANDROID)
success &= frame.metadata()->GetDouble(
media::VideoFrameMetadata::TOP_CONTROLS_HEIGHT, top_controls_height);
success &= frame.metadata()->GetDouble(
media::VideoFrameMetadata::TOP_CONTROLS_SHOWN_RATIO,
top_controls_shown_ratio);
#else
*top_controls_height = 0.;
*top_controls_shown_ratio = 0.;
#endif // defined(OS_ANDROID)
DCHECK(success);
root_scroll_offset->set_x(root_scroll_offset_x);
......@@ -937,13 +942,19 @@ void PageHandler::InnerSwapCompositorFrame() {
if (snapshot_size.IsEmpty())
return;
double top_controls_height = 0.;
double top_controls_shown_ratio = 0.;
#if defined(OS_ANDROID)
top_controls_height = last_compositor_frame_metadata_.top_controls_height;
top_controls_shown_ratio =
last_compositor_frame_metadata_.top_controls_shown_ratio;
#endif
std::unique_ptr<Page::ScreencastFrameMetadata> page_metadata =
BuildScreencastFrameMetadata(
surface_size, last_compositor_frame_metadata_.device_scale_factor,
last_compositor_frame_metadata_.page_scale_factor,
last_compositor_frame_metadata_.root_scroll_offset,
last_compositor_frame_metadata_.top_controls_height,
last_compositor_frame_metadata_.top_controls_shown_ratio);
top_controls_height, top_controls_shown_ratio);
if (!page_metadata)
return;
......
......@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "media/base/media_export.h"
#include "media/base/video_rotation.h"
......@@ -134,8 +135,10 @@ class MEDIA_EXPORT VideoFrameMetadata {
PAGE_SCALE_FACTOR,
ROOT_SCROLL_OFFSET_X,
ROOT_SCROLL_OFFSET_Y,
#if defined(OS_ANDROID)
TOP_CONTROLS_HEIGHT,
TOP_CONTROLS_SHOWN_RATIO,
#endif
NUM_KEYS
};
......
......@@ -29,10 +29,6 @@ bool StructTraits<viz::mojom::CompositorFrameMetadataDataView,
out->may_contain_video = data.may_contain_video();
out->is_resourceless_software_draw_with_scroll_or_animation =
data.is_resourceless_software_draw_with_scroll_or_animation();
out->top_controls_height = data.top_controls_height();
out->top_controls_shown_ratio = data.top_controls_shown_ratio();
out->bottom_controls_height = data.bottom_controls_height();
out->bottom_controls_shown_ratio = data.bottom_controls_shown_ratio();
out->content_source_id = data.content_source_id();
out->frame_token = data.frame_token();
out->send_frame_token_to_embedder = data.send_frame_token_to_embedder();
......@@ -43,6 +39,10 @@ bool StructTraits<viz::mojom::CompositorFrameMetadataDataView,
#if defined(OS_ANDROID)
out->max_page_scale_factor = data.max_page_scale_factor();
out->root_overflow_y_hidden = data.root_overflow_y_hidden();
out->top_controls_height = data.top_controls_height();
out->top_controls_shown_ratio = data.top_controls_shown_ratio();
out->bottom_controls_height = data.bottom_controls_height();
out->bottom_controls_shown_ratio = data.bottom_controls_shown_ratio();
#endif
return data.ReadLatencyInfo(&out->latency_info) &&
......
......@@ -47,26 +47,6 @@ struct StructTraits<viz::mojom::CompositorFrameMetadataDataView,
return metadata.is_resourceless_software_draw_with_scroll_or_animation;
}
static float top_controls_height(
const viz::CompositorFrameMetadata& metadata) {
return metadata.top_controls_height;
}
static float top_controls_shown_ratio(
const viz::CompositorFrameMetadata& metadata) {
return metadata.top_controls_shown_ratio;
}
static float bottom_controls_height(
const viz::CompositorFrameMetadata& metadata) {
return metadata.bottom_controls_height;
}
static float bottom_controls_shown_ratio(
const viz::CompositorFrameMetadata& metadata) {
return metadata.bottom_controls_shown_ratio;
}
static uint32_t root_background_color(
const viz::CompositorFrameMetadata& metadata) {
return metadata.root_background_color;
......@@ -137,6 +117,26 @@ struct StructTraits<viz::mojom::CompositorFrameMetadataDataView,
return metadata.root_overflow_y_hidden;
}
static float top_controls_height(
const viz::CompositorFrameMetadata& metadata) {
return metadata.top_controls_height;
}
static float top_controls_shown_ratio(
const viz::CompositorFrameMetadata& metadata) {
return metadata.top_controls_shown_ratio;
}
static float bottom_controls_height(
const viz::CompositorFrameMetadata& metadata) {
return metadata.bottom_controls_height;
}
static float bottom_controls_shown_ratio(
const viz::CompositorFrameMetadata& metadata) {
return metadata.bottom_controls_shown_ratio;
}
static const viz::Selection<gfx::SelectionBound>& selection(
const viz::CompositorFrameMetadata& metadata) {
return metadata.selection;
......
......@@ -616,10 +616,6 @@ TEST_F(StructTraitsTest, CompositorFrameMetadata) {
const gfx::SizeF scrollable_viewport_size(1337.7f, 1234.5f);
const bool may_contain_video = true;
const bool is_resourceless_software_draw_with_scroll_or_animation = true;
const float top_bar_height(1234.5f);
const float top_bar_shown_ratio(1.0f);
const float bottom_bar_height(1234.5f);
const float bottom_bar_shown_ratio(1.0f);
const uint32_t root_background_color = 1337;
ui::LatencyInfo latency_info;
latency_info.set_trace_id(5);
......@@ -643,6 +639,10 @@ TEST_F(StructTraitsTest, CompositorFrameMetadata) {
const float max_page_scale_factor = 4.6f;
const gfx::SizeF root_layer_size(1234.5f, 5432.1f);
const bool root_overflow_y_hidden = true;
const float top_bar_height(1234.5f);
const float top_bar_shown_ratio(1.0f);
const float bottom_bar_height(1234.5f);
const float bottom_bar_shown_ratio(1.0f);
Selection<gfx::SelectionBound> selection;
selection.start.SetEdge(gfx::PointF(1234.5f, 67891.f),
gfx::PointF(5432.1f, 1987.6f));
......@@ -662,10 +662,6 @@ TEST_F(StructTraitsTest, CompositorFrameMetadata) {
input.may_contain_video = may_contain_video;
input.is_resourceless_software_draw_with_scroll_or_animation =
is_resourceless_software_draw_with_scroll_or_animation;
input.top_controls_height = top_bar_height;
input.top_controls_shown_ratio = top_bar_shown_ratio;
input.bottom_controls_height = bottom_bar_height;
input.bottom_controls_shown_ratio = bottom_bar_shown_ratio;
input.root_background_color = root_background_color;
input.latency_info = latency_infos;
input.referenced_surfaces = referenced_surfaces;
......@@ -679,6 +675,10 @@ TEST_F(StructTraitsTest, CompositorFrameMetadata) {
input.max_page_scale_factor = max_page_scale_factor;
input.root_layer_size = root_layer_size;
input.root_overflow_y_hidden = root_overflow_y_hidden;
input.top_controls_height = top_bar_height;
input.top_controls_shown_ratio = top_bar_shown_ratio;
input.bottom_controls_height = bottom_bar_height;
input.bottom_controls_shown_ratio = bottom_bar_shown_ratio;
input.selection = selection;
#endif // defined(OS_ANDROID)
......@@ -691,10 +691,6 @@ TEST_F(StructTraitsTest, CompositorFrameMetadata) {
EXPECT_EQ(may_contain_video, output.may_contain_video);
EXPECT_EQ(is_resourceless_software_draw_with_scroll_or_animation,
output.is_resourceless_software_draw_with_scroll_or_animation);
EXPECT_EQ(top_bar_height, output.top_controls_height);
EXPECT_EQ(top_bar_shown_ratio, output.top_controls_shown_ratio);
EXPECT_EQ(bottom_bar_height, output.bottom_controls_height);
EXPECT_EQ(bottom_bar_shown_ratio, output.bottom_controls_shown_ratio);
EXPECT_EQ(root_background_color, output.root_background_color);
EXPECT_EQ(latency_infos.size(), output.latency_info.size());
EXPECT_TRUE(output.latency_info[0].FindLatency(
......@@ -716,6 +712,10 @@ TEST_F(StructTraitsTest, CompositorFrameMetadata) {
EXPECT_EQ(max_page_scale_factor, output.max_page_scale_factor);
EXPECT_EQ(root_layer_size, output.root_layer_size);
EXPECT_EQ(root_overflow_y_hidden, output.root_overflow_y_hidden);
EXPECT_EQ(top_bar_height, output.top_controls_height);
EXPECT_EQ(top_bar_shown_ratio, output.top_controls_shown_ratio);
EXPECT_EQ(bottom_bar_height, output.bottom_controls_height);
EXPECT_EQ(bottom_bar_shown_ratio, output.bottom_controls_shown_ratio);
EXPECT_EQ(selection, output.selection);
#endif // defined(OS_ANDROID)
}
......
......@@ -20,10 +20,6 @@ struct CompositorFrameMetadata {
gfx.mojom.SizeF scrollable_viewport_size;
bool may_contain_video;
bool is_resourceless_software_draw_with_scroll_or_animation;
float top_controls_height;
float top_controls_shown_ratio;
float bottom_controls_height;
float bottom_controls_shown_ratio;
uint32 root_background_color;
array<ui.mojom.LatencyInfo> latency_info;
array<SurfaceRange> referenced_surfaces;
......@@ -46,6 +42,18 @@ struct CompositorFrameMetadata {
[EnableIf=is_android]
bool root_overflow_y_hidden;
[EnableIf=is_android]
float top_controls_height;
[EnableIf=is_android]
float top_controls_shown_ratio;
[EnableIf=is_android]
float bottom_controls_height;
[EnableIf=is_android]
float bottom_controls_shown_ratio;
[EnableIf=is_android]
Selection selection;
};
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