~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/drm/drm_rect.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/drm/drm_rect.h (Version linux-6.12-rc7) and /include/drm/drm_rect.h (Version linux-6.6.60)


  1 /*                                                  1 /*
  2  * Copyright (C) 2011-2013 Intel Corporation        2  * Copyright (C) 2011-2013 Intel Corporation
  3  *                                                  3  *
  4  * Permission is hereby granted, free of charg      4  * Permission is hereby granted, free of charge, to any person obtaining a
  5  * copy of this software and associated docume      5  * copy of this software and associated documentation files (the "Software"),
  6  * to deal in the Software without restriction      6  * to deal in the Software without restriction, including without limitation
  7  * the rights to use, copy, modify, merge, pub      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8  * and/or sell copies of the Software, and to       8  * and/or sell copies of the Software, and to permit persons to whom the
  9  * Software is furnished to do so, subject to       9  * Software is furnished to do so, subject to the following conditions:
 10  *                                                 10  *
 11  * The above copyright notice and this permiss     11  * The above copyright notice and this permission notice (including the next
 12  * paragraph) shall be included in all copies      12  * paragraph) shall be included in all copies or substantial portions of the
 13  * Software.                                       13  * Software.
 14  *                                                 14  *
 15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT W     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE W     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINF     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE      18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE O     20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 21  * SOFTWARE.                                       21  * SOFTWARE.
 22  */                                                22  */
 23                                                    23 
 24 #ifndef DRM_RECT_H                                 24 #ifndef DRM_RECT_H
 25 #define DRM_RECT_H                                 25 #define DRM_RECT_H
 26                                                    26 
 27 #include <linux/types.h>                           27 #include <linux/types.h>
 28                                                    28 
 29 /**                                                29 /**
 30  * DOC: rect utils                                 30  * DOC: rect utils
 31  *                                                 31  *
 32  * Utility functions to help manage rectangula     32  * Utility functions to help manage rectangular areas for
 33  * clipping, scaling, etc. calculations.           33  * clipping, scaling, etc. calculations.
 34  */                                                34  */
 35                                                    35 
 36 /**                                                36 /**
 37  * struct drm_rect - two dimensional rectangle     37  * struct drm_rect - two dimensional rectangle
 38  * @x1: horizontal starting coordinate (inclus     38  * @x1: horizontal starting coordinate (inclusive)
 39  * @x2: horizontal ending coordinate (exclusiv     39  * @x2: horizontal ending coordinate (exclusive)
 40  * @y1: vertical starting coordinate (inclusiv     40  * @y1: vertical starting coordinate (inclusive)
 41  * @y2: vertical ending coordinate (exclusive)     41  * @y2: vertical ending coordinate (exclusive)
 42  *                                                 42  *
 43  * Note that this must match the layout of str     43  * Note that this must match the layout of struct drm_mode_rect or the damage
 44  * helpers like drm_atomic_helper_damage_iter_     44  * helpers like drm_atomic_helper_damage_iter_init() break.
 45  */                                                45  */
 46 struct drm_rect {                                  46 struct drm_rect {
 47         int x1, y1, x2, y2;                        47         int x1, y1, x2, y2;
 48 };                                                 48 };
 49                                                    49 
 50 /**                                                50 /**
 51  * DRM_RECT_INIT - initialize a rectangle from     51  * DRM_RECT_INIT - initialize a rectangle from x/y/w/h
 52  * @x: x coordinate                                52  * @x: x coordinate
 53  * @y: y coordinate                                53  * @y: y coordinate
 54  * @w: width                                       54  * @w: width
 55  * @h: height                                      55  * @h: height
 56  *                                                 56  *
 57  * RETURNS:                                        57  * RETURNS:
 58  * A new rectangle of the specified size.          58  * A new rectangle of the specified size.
 59  */                                                59  */
 60 #define DRM_RECT_INIT(x, y, w, h) ((struct drm     60 #define DRM_RECT_INIT(x, y, w, h) ((struct drm_rect){ \
 61                 .x1 = (x), \                       61                 .x1 = (x), \
 62                 .y1 = (y), \                       62                 .y1 = (y), \
 63                 .x2 = (x) + (w), \                 63                 .x2 = (x) + (w), \
 64                 .y2 = (y) + (h) })                 64                 .y2 = (y) + (h) })
 65                                                    65 
 66 /**                                                66 /**
 67  * DRM_RECT_FMT - printf string for &struct dr     67  * DRM_RECT_FMT - printf string for &struct drm_rect
 68  */                                                68  */
 69 #define DRM_RECT_FMT    "%dx%d%+d%+d"              69 #define DRM_RECT_FMT    "%dx%d%+d%+d"
 70 /**                                                70 /**
 71  * DRM_RECT_ARG - printf arguments for &struct     71  * DRM_RECT_ARG - printf arguments for &struct drm_rect
 72  * @r: rectangle struct                            72  * @r: rectangle struct
 73  */                                                73  */
 74 #define DRM_RECT_ARG(r) drm_rect_width(r), drm     74 #define DRM_RECT_ARG(r) drm_rect_width(r), drm_rect_height(r), (r)->x1, (r)->y1
 75                                                    75 
 76 /**                                                76 /**
 77  * DRM_RECT_FP_FMT - printf string for &struct     77  * DRM_RECT_FP_FMT - printf string for &struct drm_rect in 16.16 fixed point
 78  */                                                78  */
 79 #define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%0     79 #define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%06u%+d.%06u"
 80 /**                                                80 /**
 81  * DRM_RECT_FP_ARG - printf arguments for &str     81  * DRM_RECT_FP_ARG - printf arguments for &struct drm_rect in 16.16 fixed point
 82  * @r: rectangle struct                            82  * @r: rectangle struct
 83  *                                                 83  *
 84  * This is useful for e.g. printing plane sour     84  * This is useful for e.g. printing plane source rectangles, which are in 16.16
 85  * fixed point.                                    85  * fixed point.
 86  */                                                86  */
 87 #define DRM_RECT_FP_ARG(r) \                       87 #define DRM_RECT_FP_ARG(r) \
 88                 drm_rect_width(r) >> 16, ((drm     88                 drm_rect_width(r) >> 16, ((drm_rect_width(r) & 0xffff) * 15625) >> 10, \
 89                 drm_rect_height(r) >> 16, ((dr     89                 drm_rect_height(r) >> 16, ((drm_rect_height(r) & 0xffff) * 15625) >> 10, \
 90                 (r)->x1 >> 16, (((r)->x1 & 0xf     90                 (r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \
 91                 (r)->y1 >> 16, (((r)->y1 & 0xf     91                 (r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10
 92                                                    92 
 93 /**                                                93 /**
 94  * drm_rect_init - initialize the rectangle fr     94  * drm_rect_init - initialize the rectangle from x/y/w/h
 95  * @r: rectangle                                   95  * @r: rectangle
 96  * @x: x coordinate                                96  * @x: x coordinate
 97  * @y: y coordinate                                97  * @y: y coordinate
 98  * @width: width                                   98  * @width: width
 99  * @height: height                                 99  * @height: height
100  */                                               100  */
101 static inline void drm_rect_init(struct drm_re    101 static inline void drm_rect_init(struct drm_rect *r, int x, int y,
102                                  int width, in    102                                  int width, int height)
103 {                                                 103 {
104         r->x1 = x;                                104         r->x1 = x;
105         r->y1 = y;                                105         r->y1 = y;
106         r->x2 = x + width;                        106         r->x2 = x + width;
107         r->y2 = y + height;                       107         r->y2 = y + height;
108 }                                                 108 }
109                                                   109 
110 /**                                               110 /**
111  * drm_rect_adjust_size - adjust the size of t    111  * drm_rect_adjust_size - adjust the size of the rectangle
112  * @r: rectangle to be adjusted                   112  * @r: rectangle to be adjusted
113  * @dw: horizontal adjustment                     113  * @dw: horizontal adjustment
114  * @dh: vertical adjustment                       114  * @dh: vertical adjustment
115  *                                                115  *
116  * Change the size of rectangle @r by @dw in t    116  * Change the size of rectangle @r by @dw in the horizontal direction,
117  * and by @dh in the vertical direction, while    117  * and by @dh in the vertical direction, while keeping the center
118  * of @r stationary.                              118  * of @r stationary.
119  *                                                119  *
120  * Positive @dw and @dh increase the size, neg    120  * Positive @dw and @dh increase the size, negative values decrease it.
121  */                                               121  */
122 static inline void drm_rect_adjust_size(struct    122 static inline void drm_rect_adjust_size(struct drm_rect *r, int dw, int dh)
123 {                                                 123 {
124         r->x1 -= dw >> 1;                         124         r->x1 -= dw >> 1;
125         r->y1 -= dh >> 1;                         125         r->y1 -= dh >> 1;
126         r->x2 += (dw + 1) >> 1;                   126         r->x2 += (dw + 1) >> 1;
127         r->y2 += (dh + 1) >> 1;                   127         r->y2 += (dh + 1) >> 1;
128 }                                                 128 }
129                                                   129 
130 /**                                               130 /**
131  * drm_rect_translate - translate the rectangl    131  * drm_rect_translate - translate the rectangle
132  * @r: rectangle to be translated              !! 132  * @r: rectangle to be tranlated
133  * @dx: horizontal translation                    133  * @dx: horizontal translation
134  * @dy: vertical translation                      134  * @dy: vertical translation
135  *                                                135  *
136  * Move rectangle @r by @dx in the horizontal     136  * Move rectangle @r by @dx in the horizontal direction,
137  * and by @dy in the vertical direction.          137  * and by @dy in the vertical direction.
138  */                                               138  */
139 static inline void drm_rect_translate(struct d    139 static inline void drm_rect_translate(struct drm_rect *r, int dx, int dy)
140 {                                                 140 {
141         r->x1 += dx;                              141         r->x1 += dx;
142         r->y1 += dy;                              142         r->y1 += dy;
143         r->x2 += dx;                              143         r->x2 += dx;
144         r->y2 += dy;                              144         r->y2 += dy;
145 }                                                 145 }
146                                                   146 
147 /**                                               147 /**
148  * drm_rect_translate_to - translate the recta    148  * drm_rect_translate_to - translate the rectangle to an absolute position
149  * @r: rectangle to be translated              !! 149  * @r: rectangle to be tranlated
150  * @x: horizontal position                        150  * @x: horizontal position
151  * @y: vertical position                          151  * @y: vertical position
152  *                                                152  *
153  * Move rectangle @r to @x in the horizontal d    153  * Move rectangle @r to @x in the horizontal direction,
154  * and to @y in the vertical direction.           154  * and to @y in the vertical direction.
155  */                                               155  */
156 static inline void drm_rect_translate_to(struc    156 static inline void drm_rect_translate_to(struct drm_rect *r, int x, int y)
157 {                                                 157 {
158         drm_rect_translate(r, x - r->x1, y - r    158         drm_rect_translate(r, x - r->x1, y - r->y1);
159 }                                                 159 }
160                                                   160 
161 /**                                               161 /**
162  * drm_rect_downscale - downscale a rectangle     162  * drm_rect_downscale - downscale a rectangle
163  * @r: rectangle to be downscaled                 163  * @r: rectangle to be downscaled
164  * @horz: horizontal downscale factor             164  * @horz: horizontal downscale factor
165  * @vert: vertical downscale factor               165  * @vert: vertical downscale factor
166  *                                                166  *
167  * Divide the coordinates of rectangle @r by @    167  * Divide the coordinates of rectangle @r by @horz and @vert.
168  */                                               168  */
169 static inline void drm_rect_downscale(struct d    169 static inline void drm_rect_downscale(struct drm_rect *r, int horz, int vert)
170 {                                                 170 {
171         r->x1 /= horz;                            171         r->x1 /= horz;
172         r->y1 /= vert;                            172         r->y1 /= vert;
173         r->x2 /= horz;                            173         r->x2 /= horz;
174         r->y2 /= vert;                            174         r->y2 /= vert;
175 }                                                 175 }
176                                                   176 
177 /**                                               177 /**
178  * drm_rect_width - determine the rectangle wi    178  * drm_rect_width - determine the rectangle width
179  * @r: rectangle whose width is returned          179  * @r: rectangle whose width is returned
180  *                                                180  *
181  * RETURNS:                                       181  * RETURNS:
182  * The width of the rectangle.                    182  * The width of the rectangle.
183  */                                               183  */
184 static inline int drm_rect_width(const struct     184 static inline int drm_rect_width(const struct drm_rect *r)
185 {                                                 185 {
186         return r->x2 - r->x1;                     186         return r->x2 - r->x1;
187 }                                                 187 }
188                                                   188 
189 /**                                               189 /**
190  * drm_rect_height - determine the rectangle h    190  * drm_rect_height - determine the rectangle height
191  * @r: rectangle whose height is returned         191  * @r: rectangle whose height is returned
192  *                                                192  *
193  * RETURNS:                                       193  * RETURNS:
194  * The height of the rectangle.                   194  * The height of the rectangle.
195  */                                               195  */
196 static inline int drm_rect_height(const struct    196 static inline int drm_rect_height(const struct drm_rect *r)
197 {                                                 197 {
198         return r->y2 - r->y1;                     198         return r->y2 - r->y1;
199 }                                                 199 }
200                                                   200 
201 /**                                               201 /**
202  * drm_rect_visible - determine if the rectang    202  * drm_rect_visible - determine if the rectangle is visible
203  * @r: rectangle whose visibility is returned     203  * @r: rectangle whose visibility is returned
204  *                                                204  *
205  * RETURNS:                                       205  * RETURNS:
206  * %true if the rectangle is visible, %false o    206  * %true if the rectangle is visible, %false otherwise.
207  */                                               207  */
208 static inline bool drm_rect_visible(const stru    208 static inline bool drm_rect_visible(const struct drm_rect *r)
209 {                                                 209 {
210         return drm_rect_width(r) > 0 && drm_re    210         return drm_rect_width(r) > 0 && drm_rect_height(r) > 0;
211 }                                                 211 }
212                                                   212 
213 /**                                               213 /**
214  * drm_rect_equals - determine if two rectangl    214  * drm_rect_equals - determine if two rectangles are equal
215  * @r1: first rectangle                           215  * @r1: first rectangle
216  * @r2: second rectangle                          216  * @r2: second rectangle
217  *                                                217  *
218  * RETURNS:                                       218  * RETURNS:
219  * %true if the rectangles are equal, %false o    219  * %true if the rectangles are equal, %false otherwise.
220  */                                               220  */
221 static inline bool drm_rect_equals(const struc    221 static inline bool drm_rect_equals(const struct drm_rect *r1,
222                                    const struc    222                                    const struct drm_rect *r2)
223 {                                                 223 {
224         return r1->x1 == r2->x1 && r1->x2 == r    224         return r1->x1 == r2->x1 && r1->x2 == r2->x2 &&
225                 r1->y1 == r2->y1 && r1->y2 ==     225                 r1->y1 == r2->y1 && r1->y2 == r2->y2;
226 }                                                 226 }
227                                                   227 
228 /**                                               228 /**
229  * drm_rect_fp_to_int - Convert a rect in 16.1    229  * drm_rect_fp_to_int - Convert a rect in 16.16 fixed point form to int form.
230  * @dst: rect to be stored the converted value    230  * @dst: rect to be stored the converted value
231  * @src: rect in 16.16 fixed point form           231  * @src: rect in 16.16 fixed point form
232  */                                               232  */
233 static inline void drm_rect_fp_to_int(struct d    233 static inline void drm_rect_fp_to_int(struct drm_rect *dst,
234                                       const st    234                                       const struct drm_rect *src)
235 {                                                 235 {
236         drm_rect_init(dst, src->x1 >> 16, src-    236         drm_rect_init(dst, src->x1 >> 16, src->y1 >> 16,
237                       drm_rect_width(src) >> 1    237                       drm_rect_width(src) >> 16,
238                       drm_rect_height(src) >>     238                       drm_rect_height(src) >> 16);
239 }                                              << 
240                                                << 
241 /**                                            << 
242  * drm_rect_overlap - Check if two rectangles  << 
243  * @a: first rectangle                         << 
244  * @b: second rectangle                        << 
245  *                                             << 
246  * RETURNS:                                    << 
247  * %true if the rectangles overlap, %false oth << 
248  */                                            << 
249 static inline bool drm_rect_overlap(const stru << 
250                                     const stru << 
251 {                                              << 
252         return (a->x2 > b->x1 && b->x2 > a->x1 << 
253                 a->y2 > b->y1 && b->y2 > a->y1 << 
254 }                                                 239 }
255                                                   240 
256 bool drm_rect_intersect(struct drm_rect *r, co    241 bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip);
257 bool drm_rect_clip_scaled(struct drm_rect *src    242 bool drm_rect_clip_scaled(struct drm_rect *src, struct drm_rect *dst,
258                           const struct drm_rec    243                           const struct drm_rect *clip);
259 int drm_rect_calc_hscale(const struct drm_rect    244 int drm_rect_calc_hscale(const struct drm_rect *src,
260                          const struct drm_rect    245                          const struct drm_rect *dst,
261                          int min_hscale, int m    246                          int min_hscale, int max_hscale);
262 int drm_rect_calc_vscale(const struct drm_rect    247 int drm_rect_calc_vscale(const struct drm_rect *src,
263                          const struct drm_rect    248                          const struct drm_rect *dst,
264                          int min_vscale, int m    249                          int min_vscale, int max_vscale);
265 void drm_rect_debug_print(const char *prefix,     250 void drm_rect_debug_print(const char *prefix,
266                           const struct drm_rec    251                           const struct drm_rect *r, bool fixed_point);
267 void drm_rect_rotate(struct drm_rect *r,          252 void drm_rect_rotate(struct drm_rect *r,
268                      int width, int height,       253                      int width, int height,
269                      unsigned int rotation);      254                      unsigned int rotation);
270 void drm_rect_rotate_inv(struct drm_rect *r,      255 void drm_rect_rotate_inv(struct drm_rect *r,
271                          int width, int height    256                          int width, int height,
272                          unsigned int rotation    257                          unsigned int rotation);
273                                                   258 
274 #endif                                            259 #endif
275                                                   260 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php