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