Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Pablo Marquez Tello | b1db6e1 | 2021-09-01 10:18:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2021 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_SIZE2D_H |
| 25 | #define ARM_COMPUTE_SIZE2D_H |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
| 27 | #include <cstddef> |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 28 | #include <string> |
Isabella Gottardi | 6e464c3 | 2018-01-26 12:32:45 +0000 | [diff] [blame] | 29 | #include <utility> |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | /** Class for specifying the size of an image or rectangle */ |
| 34 | class Size2D |
| 35 | { |
| 36 | public: |
| 37 | /** Default constructor */ |
Isabella Gottardi | 6e464c3 | 2018-01-26 12:32:45 +0000 | [diff] [blame] | 38 | Size2D() = default; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | /** Constructor. Initializes "width" and "height" respectively with "w" and "h" |
| 40 | * |
| 41 | * @param[in] w Width of the image or rectangle |
| 42 | * @param[in] h Height of the image or rectangle |
| 43 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 44 | Size2D(size_t w, size_t h) noexcept : width(w), height(h) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 45 | { |
| 46 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 47 | /** The area of the image or rectangle calculated as (width * height) |
| 48 | * |
| 49 | * @return Area (width * height) |
| 50 | * |
| 51 | */ |
| 52 | size_t area() const |
| 53 | { |
| 54 | return (width * height); |
| 55 | } |
| 56 | |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 57 | bool operator==(const Size2D &other) const |
| 58 | { |
| 59 | return (width == other.width) && (height == other.height); |
| 60 | } |
| 61 | |
| 62 | bool operator!=(const Size2D &other) const |
| 63 | { |
| 64 | return !(*this == other); |
| 65 | } |
| 66 | |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 67 | std::string to_string() const; |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 68 | |
Alex Gilday | 7da29b6 | 2018-03-23 14:16:00 +0000 | [diff] [blame] | 69 | /** Semantic accessor for width as x. |
| 70 | * |
| 71 | * @return x. |
| 72 | */ |
| 73 | size_t x() const |
| 74 | { |
| 75 | return width; |
| 76 | } |
| 77 | |
| 78 | /** Semantic accessor for height as y. |
| 79 | * |
| 80 | * @return y. |
| 81 | */ |
| 82 | size_t y() const |
| 83 | { |
| 84 | return height; |
| 85 | } |
| 86 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 87 | public: |
Isabella Gottardi | 6e464c3 | 2018-01-26 12:32:45 +0000 | [diff] [blame] | 88 | size_t width = {}; /**< Width of the image region or rectangle */ |
| 89 | size_t height = {}; /**< Height of the image region or rectangle */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 90 | }; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 91 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 92 | #endif /*ARM_COMPUTE_SIZE2D_H */ |