1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_VIZ_COMMON_DELEGATED_INK_POINT_H_ 6 #define COMPONENTS_VIZ_COMMON_DELEGATED_INK_POINT_H_ 7 8 #include <string> 9 10 #include "base/time/time.h" 11 #include "components/viz/common/viz_common_export.h" 12 #include "mojo/public/cpp/bindings/struct_traits.h" 13 #include "ui/gfx/geometry/point_f.h" 14 15 namespace viz { 16 17 namespace mojom { 18 class DelegatedInkPointDataView; 19 } // namespace mojom 20 21 // This class stores the information required to draw a single point of a 22 // delegated ink trail. When the WebAPI |updateInkTrailStartPoint| is called, 23 // the renderer requests that the browser begin sending these to viz. Viz 24 // will collect them, and then during |DrawAndSwap| will use the 25 // DelegatedInkPoints that have arrived from the browser along with the 26 // DelegatedInkMetadata that the renderer sent to draw a delegated ink trail on 27 // the screen, connected to the end of the already rendered ink stroke. 28 // 29 // Explainer for the feature: 30 // https://github.com/WICG/ink-enhancement/blob/master/README.md 31 class VIZ_COMMON_EXPORT DelegatedInkPoint { 32 public: 33 DelegatedInkPoint() = default; DelegatedInkPoint(const gfx::PointF & pt,base::TimeTicks timestamp)34 DelegatedInkPoint(const gfx::PointF& pt, base::TimeTicks timestamp) 35 : point_(pt), timestamp_(timestamp) {} 36 point()37 const gfx::PointF& point() const { return point_; } timestamp()38 base::TimeTicks timestamp() const { return timestamp_; } 39 std::string ToString() const; 40 41 private: 42 friend struct mojo::StructTraits<mojom::DelegatedInkPointDataView, 43 DelegatedInkPoint>; 44 45 // Location of the input event relative to the root window in device pixels. 46 // Scale is device scale factor at time of input. 47 gfx::PointF point_; 48 49 // Timestamp from the input event. 50 base::TimeTicks timestamp_; 51 }; 52 53 } // namespace viz 54 55 #endif // COMPONENTS_VIZ_COMMON_DELEGATED_INK_POINT_H_ 56