blob: e14fc841a01a39b71fa1218eafe1d20c93725725 [file] [log] [blame]
// Copyright 2017 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.
#include <vector>
#include "ash/components/fast_ink/fast_ink_points.h"
#include "ash/components/fast_ink/fast_ink_view.h"
#include "base/time/time.h"
namespace aura {
class Window;
namespace gfx {
class PointF;
namespace ash {
enum class HighlighterGestureType;
// HighlighterView displays the highlighter palette tool. It draws the
// highlighter stroke which consists of a series of thick lines connecting
// touch points.
class HighlighterView : public fast_ink::FastInkView {
static const SkColor kPenColor;
static const gfx::SizeF kPenTipSize;
HighlighterView(const base::TimeDelta presentation_delay,
aura::Window* container);
~HighlighterView() override;
const fast_ink::FastInkPoints& points() const { return points_; }
bool animating() const { return animation_timer_.get(); }
void AddNewPoint(const gfx::PointF& new_point, const base::TimeTicks& time);
void AddGap();
void Animate(const gfx::PointF& pivot,
HighlighterGestureType gesture_type,
const base::Closure& done);
friend class HighlighterControllerTestApi;
void FadeOut(const gfx::PointF& pivot,
HighlighterGestureType gesture_type,
const base::Closure& done);
void ScheduleUpdateBuffer();
void UpdateBuffer();
void Draw(gfx::Canvas& canvas);
fast_ink::FastInkPoints points_;
fast_ink::FastInkPoints predicted_points_;
const base::TimeDelta presentation_delay_;
std::unique_ptr<base::OneShotTimer> animation_timer_;
gfx::Rect highlighter_damage_rect_;
bool pending_update_buffer_ = false;
base::WeakPtrFactory<HighlighterView> weak_ptr_factory_;
} // namespace ash