|
| 1 | +/* |
| 2 | + * This file is part of the Micro Python project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + * of this software and associated documentation files (the "Software"), to deal |
| 10 | + * in the Software without restriction, including without limitation the rights |
| 11 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + * copies of the Software, and to permit persons to whom the Software is |
| 13 | + * furnished to do so, subject to the following conditions: |
| 14 | + * |
| 15 | + * The above copyright notice and this permission notice shall be included in |
| 16 | + * all copies or substantial portions of the Software. |
| 17 | + * |
| 18 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + * THE SOFTWARE. |
| 25 | + */ |
| 26 | + |
1 | 27 |
|
2 | 28 | #include <string.h>
|
3 | 29 |
|
@@ -249,138 +275,6 @@ void displayio_gc_collect(void) {
|
249 | 275 | }
|
250 | 276 | }
|
251 | 277 |
|
252 |
| -void displayio_area_copy(const displayio_area_t *src, displayio_area_t *dst) { |
253 |
| - dst->x1 = src->x1; |
254 |
| - dst->y1 = src->y1; |
255 |
| - dst->x2 = src->x2; |
256 |
| - dst->y2 = src->y2; |
257 |
| -} |
258 |
| - |
259 |
| -void displayio_area_scale(displayio_area_t *area, uint16_t scale) { |
260 |
| - area->x1 *= scale; |
261 |
| - area->y1 *= scale; |
262 |
| - area->x2 *= scale; |
263 |
| - area->y2 *= scale; |
264 |
| -} |
265 |
| - |
266 |
| -void displayio_area_shift(displayio_area_t *area, int16_t dx, int16_t dy) { |
267 |
| - area->x1 += dx; |
268 |
| - area->y1 += dy; |
269 |
| - area->x2 += dx; |
270 |
| - area->y2 += dy; |
271 |
| -} |
272 |
| - |
273 |
| -bool displayio_area_compute_overlap(const displayio_area_t *a, |
274 |
| - const displayio_area_t *b, |
275 |
| - displayio_area_t *overlap) { |
276 |
| - overlap->x1 = a->x1; |
277 |
| - if (b->x1 > overlap->x1) { |
278 |
| - overlap->x1 = b->x1; |
279 |
| - } |
280 |
| - overlap->x2 = a->x2; |
281 |
| - if (b->x2 < overlap->x2) { |
282 |
| - overlap->x2 = b->x2; |
283 |
| - } |
284 |
| - if (overlap->x1 >= overlap->x2) { |
285 |
| - return false; |
286 |
| - } |
287 |
| - overlap->y1 = a->y1; |
288 |
| - if (b->y1 > overlap->y1) { |
289 |
| - overlap->y1 = b->y1; |
290 |
| - } |
291 |
| - overlap->y2 = a->y2; |
292 |
| - if (b->y2 < overlap->y2) { |
293 |
| - overlap->y2 = b->y2; |
294 |
| - } |
295 |
| - if (overlap->y1 >= overlap->y2) { |
296 |
| - return false; |
297 |
| - } |
298 |
| - return true; |
299 |
| -} |
300 |
| - |
301 |
| -bool displayio_area_empty(const displayio_area_t *a) { |
302 |
| - return (a->x1 == a->x2) || (a->y1 == a->y2); |
303 |
| -} |
304 |
| - |
305 |
| -void displayio_area_canon(displayio_area_t *a) { |
306 |
| - if (a->x1 > a->x2) { |
307 |
| - int16_t t = a->x1; |
308 |
| - a->x1 = a->x2; |
309 |
| - a->x2 = t; |
310 |
| - } |
311 |
| - if (a->y1 > a->y2) { |
312 |
| - int16_t t = a->y1; |
313 |
| - a->y1 = a->y2; |
314 |
| - a->y2 = t; |
315 |
| - } |
316 |
| -} |
317 |
| - |
318 |
| -void displayio_area_union(const displayio_area_t *a, |
319 |
| - const displayio_area_t *b, |
320 |
| - displayio_area_t *u) { |
321 |
| - |
322 |
| - if (displayio_area_empty(a)) { |
323 |
| - displayio_area_copy(b, u); |
324 |
| - return; |
325 |
| - } |
326 |
| - if (displayio_area_empty(b)) { |
327 |
| - displayio_area_copy(a, u); |
328 |
| - return; |
329 |
| - } |
330 |
| - u->x1 = MIN(a->x1, b->x1); |
331 |
| - u->y1 = MIN(a->y1, b->y1); |
332 |
| - u->x2 = MAX(a->x2, b->x2); |
333 |
| - u->y2 = MAX(a->y2, b->y2); |
334 |
| -} |
335 |
| - |
336 |
| -uint16_t displayio_area_width(const displayio_area_t *area) { |
337 |
| - return area->x2 - area->x1; |
338 |
| -} |
339 |
| - |
340 |
| -uint16_t displayio_area_height(const displayio_area_t *area) { |
341 |
| - return area->y2 - area->y1; |
342 |
| -} |
343 |
| - |
344 |
| -uint32_t displayio_area_size(const displayio_area_t *area) { |
345 |
| - return displayio_area_width(area) * displayio_area_height(area); |
346 |
| -} |
347 |
| - |
348 |
| -bool displayio_area_equal(const displayio_area_t *a, const displayio_area_t *b) { |
349 |
| - return a->x1 == b->x1 && |
350 |
| - a->y1 == b->y1 && |
351 |
| - a->x2 == b->x2 && |
352 |
| - a->y2 == b->y2; |
353 |
| -} |
354 |
| - |
355 |
| -// Original and whole must be in the same coordinate space. |
356 |
| -void displayio_area_transform_within(bool mirror_x, bool mirror_y, bool transpose_xy, |
357 |
| - const displayio_area_t *original, |
358 |
| - const displayio_area_t *whole, |
359 |
| - displayio_area_t *transformed) { |
360 |
| - if (mirror_x) { |
361 |
| - transformed->x1 = whole->x1 + (whole->x2 - original->x2); |
362 |
| - transformed->x2 = whole->x2 - (original->x1 - whole->x1); |
363 |
| - } else { |
364 |
| - transformed->x1 = original->x1; |
365 |
| - transformed->x2 = original->x2; |
366 |
| - } |
367 |
| - if (mirror_y) { |
368 |
| - transformed->y1 = whole->y1 + (whole->y2 - original->y2); |
369 |
| - transformed->y2 = whole->y2 - (original->y1 - whole->y1); |
370 |
| - } else { |
371 |
| - transformed->y1 = original->y1; |
372 |
| - transformed->y2 = original->y2; |
373 |
| - } |
374 |
| - if (transpose_xy) { |
375 |
| - int16_t y1 = transformed->y1; |
376 |
| - int16_t y2 = transformed->y2; |
377 |
| - transformed->y1 = whole->y1 + (transformed->x1 - whole->x1); |
378 |
| - transformed->y2 = whole->y1 + (transformed->x2 - whole->x1); |
379 |
| - transformed->x2 = whole->x1 + (y2 - whole->y1); |
380 |
| - transformed->x1 = whole->x1 + (y1 - whole->y1); |
381 |
| - } |
382 |
| -} |
383 |
| - |
384 | 278 | primary_display_t *allocate_display(void) {
|
385 | 279 | for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
|
386 | 280 | mp_const_obj_t display_type = displays[i].display.base.type;
|
|
0 commit comments