Commit 32c5dea9 authored by Ryan Daum's avatar Ryan Daum Committed by Commit Bot

[chromecast] Fullscreen magnficiation for cast.

  * Port of Ash's MagnificationController to cast. First patchset is
    the original source, with changes/removals for cast in patchset 2.
  * Enabled via triple-tap when that is enabled.
  * Two-finger pan & pinch-to-zoom.

Bug: internal b/110532452
Test: manual
Change-Id: Ia346fcc6d4ff70aaa0236f1d976c3b0de13a0f86
Reviewed-on: https://chromium-review.googlesource.com/1170987Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Commit-Queue: Ryan Daum <rdaum@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582308}
parent 47fecb11
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "chromecast/browser/accessibility/accessibility_manager.h" #include "chromecast/browser/accessibility/accessibility_manager.h"
#include "chromecast/graphics/accessibility/focus_ring_controller.h" #include "chromecast/graphics/accessibility/focus_ring_controller.h"
#include "chromecast/graphics/accessibility/partial_magnification_controller.h" #include "chromecast/graphics/accessibility/fullscreen_magnification_controller.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/wm/public/activation_client.h" #include "ui/wm/public/activation_client.h"
...@@ -31,7 +31,7 @@ AccessibilityManager::AccessibilityManager( ...@@ -31,7 +31,7 @@ AccessibilityManager::AccessibilityManager(
&accessibility_sound_proxy_); &accessibility_sound_proxy_);
triple_tap_detector_ = std::make_unique<TripleTapDetector>(root_window, this); triple_tap_detector_ = std::make_unique<TripleTapDetector>(root_window, this);
magnification_controller_ = magnification_controller_ =
std::make_unique<PartialMagnificationController>(root_window); std::make_unique<FullscreenMagnificationController>(root_window);
} }
AccessibilityManager::~AccessibilityManager() {} AccessibilityManager::~AccessibilityManager() {}
......
...@@ -38,6 +38,8 @@ cast_source_set("graphics") { ...@@ -38,6 +38,8 @@ cast_source_set("graphics") {
"accessibility/focus_ring_controller.h", "accessibility/focus_ring_controller.h",
"accessibility/focus_ring_layer.cc", "accessibility/focus_ring_layer.cc",
"accessibility/focus_ring_layer.h", "accessibility/focus_ring_layer.h",
"accessibility/fullscreen_magnification_controller.cc",
"accessibility/fullscreen_magnification_controller.h",
"accessibility/magnification_controller.h", "accessibility/magnification_controller.h",
"accessibility/partial_magnification_controller.cc", "accessibility/partial_magnification_controller.cc",
"accessibility/partial_magnification_controller.h", "accessibility/partial_magnification_controller.h",
......
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_GRAPHICS_ACCESSIBILITY_FULLSCREEN_MAGNIFICATION_CONTROLLER_H_
#define CHROMECAST_GRAPHICS_ACCESSIBILITY_FULLSCREEN_MAGNIFICATION_CONTROLLER_H_
#include "chromecast/graphics/accessibility/magnification_controller.h"
#include "ui/events/event_handler.h"
#include "ui/events/event_rewriter.h"
#include "ui/events/gestures/gesture_provider_aura.h"
#include "ui/events/gestures/gesture_types.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/transform.h"
namespace aura {
class Window;
} // namespace aura
namespace ui {
class GestureProviderAura;
} // namespace ui
namespace chromecast {
class FullscreenMagnificationController : public MagnificationController,
public ui::EventRewriter,
public ui::GestureConsumer {
public:
explicit FullscreenMagnificationController(aura::Window* root_window);
~FullscreenMagnificationController() override;
void SetEnabled(bool enabled) override;
bool IsEnabled() const override;
void SetMagnificationScale(float magnification_scale) override;
private:
class GestureProviderClient;
enum LockedGestureType { NO_GESTURE, ZOOM, SCROLL };
// The current transform to apply to the root window to perform magnification.
gfx::Transform GetMagnifierTransform() const;
// Process pending gestures in |gesture_provider_|. This method returns true
// if the controller needs to cancel existing touches.
bool ProcessGestures();
// Redraws the magnification window with the given origin position in dip and
// the given scale. Returns true if the window is changed; otherwise, false.
bool RedrawDIP(const gfx::PointF& position_in_dip, float scale);
// Overridden from ui::EventRewriter
ui::EventRewriteStatus RewriteEvent(
const ui::Event& event,
std::unique_ptr<ui::Event>* rewritten_event) override;
ui::EventRewriteStatus NextDispatchEvent(
const ui::Event& last_event,
std::unique_ptr<ui::Event>* new_event) override;
aura::Window* root_window_;
bool is_enabled_ = false;
gfx::Transform original_transform_;
// Stores the last touched location. This value is used on zooming to keep
// this location visible.
gfx::Point point_of_interest_in_root_;
// Current scale, origin (left-top) position of the magnification window.
float magnification_scale_;
gfx::PointF magnification_origin_;
float original_magnification_scale_;
gfx::PointF original_magnification_origin_;
// We own our own GestureProvider to detect gestures with screen coordinates
// of touch events. As MagnificationController changes zoom level and moves
// viewport, logical coordinates of touches cannot be used for gesture
// detection as they are changed if the controller reacts to gestures.
std::unique_ptr<ui::GestureProviderAura> gesture_provider_;
std::unique_ptr<GestureProviderClient> gesture_provider_client_;
// We lock the gesture once user performs either scroll or pinch gesture above
// those thresholds.
LockedGestureType locked_gesture_ = NO_GESTURE;
// If true, consumes all touch events.
bool consume_touch_event_ = false;
// Number of touch points on the screen.
int32_t touch_points_ = 0;
// Map for holding ET_TOUCH_PRESS events. Those events are used to dispatch
// ET_TOUCH_CANCELLED events. Events will be removed from this map when press
// events are cancelled, i.e. size of this map can be different from number of
// touches on the screen. Key is pointer id.
std::map<int32_t, std::unique_ptr<ui::TouchEvent>> press_event_map_;
};
} // namespace chromecast
#endif // CHROMECAST_GRAPHICS_ACCESSIBILITY_FULLSCREEN_MAGNIFICATION_CONTROLLER_H_
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