Commit 0f46bbc4 authored by Alexander Alekseev's avatar Alexander Alekseev Committed by Chromium LUCI CQ

[Ash HUD]: Add checkbox for non-overlay HUD mode.

New checkbox moves HUD between overlay and non-overlay containers.

Bug: 1133585
Change-Id: Idab0fc399eb77196797a5ec3db9f404fef99b1c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2612097
Commit-Queue: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840852}
parent f33caabf
......@@ -366,6 +366,14 @@ void ViewTreeHostRootView::SchedulePaintInRect(const gfx::Rect& rect) {
}
}
bool ViewTreeHostRootView::GetIsOverlayCandidate() {
return is_overlay_candidate_;
}
void ViewTreeHostRootView::SetIsOverlayCandidate(bool is_overlay_candidate) {
is_overlay_candidate_ = is_overlay_candidate;
}
void ViewTreeHostRootView::UpdateSurface(const gfx::Rect& damage_rect,
std::unique_ptr<Resource> resource) {
damage_rect_.Union(damage_rect);
......@@ -435,7 +443,7 @@ void ViewTreeHostRootView::SubmitCompositorFrame() {
transferable_resource.size = buffer_size_;
transferable_resource.mailbox_holder = gpu::MailboxHolder(
resource->mailbox, resource->sync_token, GL_TEXTURE_2D);
transferable_resource.is_overlay_candidate = true;
transferable_resource.is_overlay_candidate = is_overlay_candidate_;
gfx::Transform buffer_to_target_transform;
bool rv = rotate_transform_.GetInverse(&buffer_to_target_transform);
......
......@@ -41,6 +41,9 @@ class ViewTreeHostRootView : public views::internal::RootView {
void SchedulePaintInRect(const gfx::Rect& rect);
bool GetIsOverlayCandidate();
void SetIsOverlayCandidate(bool is_overlay_candidate);
private:
struct Resource;
class LayerTreeViewTreeFrameSinkHolder;
......@@ -71,6 +74,9 @@ class ViewTreeHostRootView : public views::internal::RootView {
gfx::Rect damaged_paint_rect_;
bool pending_paint_ = false;
// overlay candidate in submitted frame data.
bool is_overlay_candidate_ = true;
// The resource to be submitted.
std::unique_ptr<Resource> pending_resource_;
......
......@@ -25,6 +25,7 @@
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -44,6 +45,9 @@ constexpr int kHUDViewDefaultHeight =
views::Widget* g_hud_widget = nullptr;
// True if HUD should be initialized as overlay.
bool g_hud_overlay_mode = true;
// ClientView that return HTNOWHERE by default. A child view can receive event
// by setting kHitTestComponentKey property to HTCLIENT.
class HTClientView : public views::ClientView {
......@@ -124,6 +128,8 @@ void HUDDisplayView::Toggle() {
kHUDViewDefaultHeight + 2 * kGridLineWidth);
auto* widget = CreateViewTreeHostWidget(std::move(params));
widget->GetLayer()->SetName("HUDDisplayView");
static_cast<ViewTreeHostRootView*>(widget->GetRootView())
->SetIsOverlayCandidate(g_hud_overlay_mode);
widget->Show();
g_hud_widget = widget;
......@@ -174,7 +180,7 @@ HUDDisplayView::HUDDisplayView() {
data->SetLayoutManager(std::make_unique<views::FillLayout>());
graphs_container_ =
data->AddChildView(std::make_unique<GraphsContainerView>());
settings_view_ = data->AddChildView(std::make_unique<HUDSettingsView>());
settings_view_ = data->AddChildView(std::make_unique<HUDSettingsView>(this));
settings_view_->SetVisible(false);
// CPU display is active by default.
......@@ -191,6 +197,17 @@ void HUDDisplayView::OnSettingsToggle() {
graphs_container_->SetVisible(!settings_view_->GetVisible());
}
bool HUDDisplayView::IsOverlay() {
return static_cast<ViewTreeHostRootView*>(GetWidget()->GetRootView())
->GetIsOverlayCandidate();
}
void HUDDisplayView::ToggleOverlay() {
g_hud_overlay_mode = !g_hud_overlay_mode;
static_cast<ViewTreeHostRootView*>(GetWidget()->GetRootView())
->SetIsOverlayCandidate(g_hud_overlay_mode);
}
int HUDDisplayView::NonClientHitTest(const gfx::Point& point) {
const View* view = GetEventHandlerForPoint(point);
if (!view)
......
......@@ -43,6 +43,12 @@ class HUDDisplayView : public views::View {
// Callback from SettingsButton.
void OnSettingsToggle();
// Returns true if HUD is in overlay mode.
bool IsOverlay();
// Changes HUD overlay flag.
void ToggleOverlay();
private:
HUDHeaderView* header_view_ = nullptr; // not owned
GraphsContainerView* graphs_container_ = nullptr; // not owned
......
......@@ -4,6 +4,7 @@
#include "ash/hud_display/hud_settings_view.h"
#include "ash/hud_display/hud_display.h"
#include "ash/hud_display/hud_properties.h"
#include "ash/shell.h"
#include "base/bind.h"
......@@ -117,8 +118,10 @@ class SettingsCheckbox : public views::Checkbox {
public:
METADATA_HEADER(SettingsCheckbox);
explicit SettingsCheckbox(const base::string16& label)
: views::Checkbox(label, views::Button::PressedCallback()) {}
SettingsCheckbox(const base::string16& label, const base::string16& tooltip)
: views::Checkbox(label, views::Button::PressedCallback()) {
SetTooltipText(tooltip);
}
SettingsCheckbox(const SettingsCheckbox& other) = delete;
SettingsCheckbox operator=(const SettingsCheckbox& other) = delete;
......@@ -337,7 +340,7 @@ void AnimationSpeedControl::Layout() {
BEGIN_METADATA(HUDSettingsView, views::View)
END_METADATA
HUDSettingsView::HUDSettingsView() {
HUDSettingsView::HUDSettingsView(HUDDisplayView* hud_display) {
SetVisible(false);
// We want AnimationSpeedControl to be stretched horizontally so we turn
......@@ -362,10 +365,10 @@ HUDSettingsView::HUDSettingsView() {
auto add_checkbox =
[](HUDSettingsView* self, views::View* container,
const base::string16& text,
const base::string16& text, const base::string16& tooltip,
base::RepeatingCallback<void(views::Checkbox*)> callback) {
views::Checkbox* checkbox =
container->AddChildView(std::make_unique<SettingsCheckbox>(text));
views::Checkbox* checkbox = container->AddChildView(
std::make_unique<SettingsCheckbox>(text, tooltip));
checkbox->SetCallback(
base::BindRepeating(std::move(callback), checkbox));
checkbox->SetEnabledTextColors(kHUDDefaultColor);
......@@ -374,33 +377,58 @@ HUDSettingsView::HUDSettingsView() {
};
checkbox_handlers_.push_back(std::make_unique<HUDCheckboxHandler>(
add_checkbox(this, checkbox_container,
base::ASCIIToUTF16("Tint composited content"),
GetVisDebugHandleClickCallback(
&viz::DebugRendererSettings::tint_composited_content)),
add_checkbox(
this, checkbox_container,
base::ASCIIToUTF16("Tint composited content"),
base::ASCIIToUTF16(
"Equivalent to --tint-composited-content command-line option."),
GetVisDebugHandleClickCallback(
&viz::DebugRendererSettings::tint_composited_content)),
GetVisDebugUpdateStateCallback(
&viz::DebugRendererSettings::tint_composited_content)));
checkbox_handlers_.push_back(std::make_unique<HUDCheckboxHandler>(
add_checkbox(this, checkbox_container,
base::ASCIIToUTF16("Show overdraw feedback"),
GetVisDebugHandleClickCallback(
&viz::DebugRendererSettings::show_overdraw_feedback)),
add_checkbox(
this, checkbox_container,
base::ASCIIToUTF16("Show overdraw feedback"),
base::ASCIIToUTF16(
"Equivalent to --show-overdraw-feedback command-line option."),
GetVisDebugHandleClickCallback(
&viz::DebugRendererSettings::show_overdraw_feedback)),
GetVisDebugUpdateStateCallback(
&viz::DebugRendererSettings::show_overdraw_feedback)));
checkbox_handlers_.push_back(std::make_unique<HUDCheckboxHandler>(
add_checkbox(this, checkbox_container,
base::ASCIIToUTF16("Show aggregated damage"),
GetVisDebugHandleClickCallback(
&viz::DebugRendererSettings::show_aggregated_damage)),
add_checkbox(
this, checkbox_container,
base::ASCIIToUTF16("Show aggregated damage"),
base::ASCIIToUTF16(
"Equivalent to --show-aggregated-damage command-line option."),
GetVisDebugHandleClickCallback(
&viz::DebugRendererSettings::show_aggregated_damage)),
GetVisDebugUpdateStateCallback(
&viz::DebugRendererSettings::show_aggregated_damage)));
checkbox_handlers_.push_back(std::make_unique<HUDCheckboxHandler>(
add_checkbox(this, checkbox_container,
base::ASCIIToUTF16("Show paint rect."),
GetCCDebugHandleClickCallback(
&cc::LayerTreeDebugState::show_paint_rects)),
add_checkbox(
this, checkbox_container, base::ASCIIToUTF16("Show paint rect."),
base::ASCIIToUTF16(
"Equivalent to --ui-show-paint-rects command-line option."),
GetCCDebugHandleClickCallback(
&cc::LayerTreeDebugState::show_paint_rects)),
GetCCDebugUpdateStateCallback(
&cc::LayerTreeDebugState::show_paint_rects)));
checkbox_handlers_.push_back(std::make_unique<HUDCheckboxHandler>(
add_checkbox(this, checkbox_container,
base::ASCIIToUTF16("HUD is overlay."),
base::ASCIIToUTF16("Flips HUD overlay mode flag."),
base::BindRepeating(
[](HUDDisplayView* hud_display, views::Checkbox*) {
hud_display->ToggleOverlay();
},
base::Unretained(hud_display))),
base::BindRepeating(
[](HUDDisplayView* hud_display, views::Checkbox* checkbox) {
checkbox->SetChecked(hud_display->IsOverlay());
},
base::Unretained(hud_display))));
AddChildView(std::make_unique<AnimationSpeedControl>());
}
......
......@@ -15,12 +15,13 @@ namespace ash {
namespace hud_display {
class HUDCheckboxHandler;
class HUDDisplayView;
class HUDSettingsView : public views::View {
public:
METADATA_HEADER(HUDSettingsView);
HUDSettingsView();
explicit HUDSettingsView(HUDDisplayView* hud_display);
~HUDSettingsView() override;
HUDSettingsView(const HUDSettingsView&) = delete;
......
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