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 static inline uint32_t
20 ao_pattern_expand(uint8_t v, uint8_t rot)
25 v = ao_left(v, 8-rot) | ao_right(v, rot);
27 return (r << 24) | (r << 16) | (r << 8) | (r);
36 ao_pattern(const struct ao_bitmap *dst,
41 const struct ao_pattern *pattern,
48 int16_t x2 = x + width;
49 int16_t y2 = y + height;
51 ao_clip(x, 0, dst->width);
52 ao_clip(x2, 0, dst->width);
53 ao_clip(y, 0, dst->height);
54 ao_clip(y2, 0, dst->height);
56 if (x < x2 && y < y2) {
57 int xrot = (x - pat_x) & 7;
58 int yrot = (y - pat_y) & 7;
62 for (i = 0; i < 8; i++)
63 pat[(i + yrot) & 7] = ao_pattern_expand(pattern->pattern[i], xrot);
64 for (dst_y = y; dst_y < y2; dst_y += 8) {
65 int h = min(y2 - dst_y, 8);
66 for (dst_x = x; dst_x < x2; dst_x += 8) {
67 int w = min(x2 - dst_x, 8);
70 dst->base + dst_y * dst->stride,