2 * Copyright © 2016 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
17 #include "ao_draw_int.h"
19 #define bound(val,max,other) do { \
25 other -= (val - max); \
30 #define bound2(a, max_a, b, max_b) do { \
36 ao_copy(const struct ao_bitmap *dst,
41 const struct ao_bitmap *src,
46 int16_t dst_x2 = dst_x + width, dst_y2 = dst_y + height;
47 int16_t src_x2 = src_x + width, src_y2 = src_y + height;
49 uint8_t upsidedown = 0;
51 bound2(dst_x, dst->width, src_x, src->width);
52 bound2(dst_x2, dst->width, src_x2, src->width);
53 bound2(dst_y, dst->height, src_y, src->height);
54 bound2(dst_y2, dst->height, src_y2, src->height);
57 reverse = (dst_x > src_x);
58 upsidedown = (dst_y > src_y);
61 if (dst_x < dst_x2 && dst_y < dst_y2) {
62 ao_blt(src->base + src_y * src->stride,
65 dst->base + dst_y * dst->stride,