libguac 1.6.0
 
Loading...
Searching...
No Matches
rect.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef GUAC_RECT_H
21#define GUAC_RECT_H
22
23#include "mem.h"
24#include "rect-types.h"
25
55#define GUAC_RECT_MUTABLE_BUFFER(rect, buffer, stride, bpp) ((void*) ( \
56 ((unsigned char*) (buffer)) \
57 + guac_mem_ckd_mul_or_die((rect).top, stride) \
58 + guac_mem_ckd_mul_or_die((rect).left, bpp)))
59
89#define GUAC_RECT_CONST_BUFFER(rect, buffer, stride, bpp) ((const void*) ( \
90 ((const unsigned char*) (buffer)) \
91 + guac_mem_ckd_mul_or_die((rect).top, stride) \
92 + guac_mem_ckd_mul_or_die((rect).left, bpp)))
93
94struct guac_rect {
95
106 int left;
107
118 int top;
119
130 int right;
131
143
144};
145
165void guac_rect_init(guac_rect* rect, int x, int y, int width, int height);
166
180void guac_rect_align(guac_rect* rect, unsigned int bits);
181
192void guac_rect_extend(guac_rect* rect, const guac_rect* min);
193
204void guac_rect_constrain(guac_rect* rect, const guac_rect* max);
205
221void guac_rect_shrink(guac_rect* rect, int max_width, int max_height);
222
235int guac_rect_intersects(const guac_rect* a, const guac_rect* b);
236
247int guac_rect_is_empty(const guac_rect* rect);
248
258int guac_rect_width(const guac_rect* rect);
259
269int guac_rect_height(const guac_rect* rect);
270
271#endif
Provides convenience macros/functions for performing arithmetic on size_t values and for allocating m...
A rectangle defined by its upper-left and lower-right corners.
Definition rect.h:94
int right
The X coordinate of the lower-right corner of this rectangle (exclusive).
Definition rect.h:130
int top
The Y coordinate of the upper-left corner of this rectangle (inclusive).
Definition rect.h:118
int left
The X coordinate of the upper-left corner of this rectangle (inclusive).
Definition rect.h:106
int bottom
The Y coordinate of the lower-right corner of this rectangle (exclusive).
Definition rect.h:142