Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Prabir Pradhan | c08b0db | 2022-09-10 00:57:15 +0000 | [diff] [blame] | 17 | #pragma once |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 18 | |
| 19 | #include <stdint.h> |
| 20 | #include <sys/time.h> |
| 21 | #include <vector> |
| 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | /** |
| 26 | * Represents data from a single scan of the touchscreen device. |
| 27 | * Similar in concept to a video frame, but the touch strength is used as |
| 28 | * the values instead. |
| 29 | */ |
| 30 | class TouchVideoFrame { |
| 31 | public: |
Siarhei Vishniakou | fda3aee | 2019-02-15 17:10:53 -0600 | [diff] [blame] | 32 | TouchVideoFrame(uint32_t height, uint32_t width, std::vector<int16_t> data, |
Siarhei Vishniakou | 26cf29d | 2019-02-15 16:48:38 -0600 | [diff] [blame] | 33 | const struct timeval& timestamp); |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 34 | |
Siarhei Vishniakou | 26cf29d | 2019-02-15 16:48:38 -0600 | [diff] [blame] | 35 | bool operator==(const TouchVideoFrame& rhs) const; |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 36 | |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 37 | /** |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 38 | * Height of the frame |
| 39 | */ |
Siarhei Vishniakou | 26cf29d | 2019-02-15 16:48:38 -0600 | [diff] [blame] | 40 | uint32_t getHeight() const; |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 41 | /** |
Siarhei Vishniakou | fda3aee | 2019-02-15 17:10:53 -0600 | [diff] [blame] | 42 | * Width of the frame |
| 43 | */ |
| 44 | uint32_t getWidth() const; |
| 45 | /** |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 46 | * The touch strength data. |
| 47 | * The array is a 2-D row-major matrix, with dimensions (height, width). |
| 48 | * Total size of the array should equal getHeight() * getWidth(). |
| 49 | * Data is allowed to be negative. |
| 50 | */ |
Siarhei Vishniakou | 26cf29d | 2019-02-15 16:48:38 -0600 | [diff] [blame] | 51 | const std::vector<int16_t>& getData() const; |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 52 | /** |
| 53 | * Time at which the heatmap was taken. |
| 54 | */ |
Siarhei Vishniakou | 26cf29d | 2019-02-15 16:48:38 -0600 | [diff] [blame] | 55 | const struct timeval& getTimestamp() const; |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 56 | |
Siarhei Vishniakou | 8154bbd | 2019-02-15 17:21:03 -0600 | [diff] [blame] | 57 | /** |
| 58 | * Rotate the video frame. |
Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 59 | * The rotation value is an enum from ui/Rotation.h |
Siarhei Vishniakou | 8154bbd | 2019-02-15 17:21:03 -0600 | [diff] [blame] | 60 | */ |
| 61 | void rotate(int32_t orientation); |
| 62 | |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 63 | private: |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 64 | uint32_t mHeight; |
Siarhei Vishniakou | fda3aee | 2019-02-15 17:10:53 -0600 | [diff] [blame] | 65 | uint32_t mWidth; |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 66 | std::vector<int16_t> mData; |
| 67 | struct timeval mTimestamp; |
Siarhei Vishniakou | 8154bbd | 2019-02-15 17:21:03 -0600 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Common method for 90 degree and 270 degree rotation |
| 71 | */ |
| 72 | void rotateQuarterTurn(bool clockwise); |
| 73 | void rotate180(); |
Siarhei Vishniakou | 7b7c8f6 | 2018-12-12 16:09:20 -0800 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | } // namespace android |