Lines Matching refs:surface
95 void gfx_copyrect(gfx_surface* surface, uint x, uint y, uint width, uint height, uint x2, uint y2) { in gfx_copyrect() argument
97 if (x >= surface->width) in gfx_copyrect()
99 if (x2 >= surface->width) in gfx_copyrect()
101 if (y >= surface->height) in gfx_copyrect()
103 if (y2 >= surface->height) in gfx_copyrect()
109 if (x + width > surface->width) in gfx_copyrect()
110 width = surface->width - x; in gfx_copyrect()
111 if (x2 + width > surface->width) in gfx_copyrect()
112 width = surface->width - x2; in gfx_copyrect()
115 if (y + height > surface->height) in gfx_copyrect()
116 height = surface->height - y; in gfx_copyrect()
117 if (y2 + height > surface->height) in gfx_copyrect()
118 height = surface->height - y2; in gfx_copyrect()
120 surface->copyrect(surface, x, y, width, height, x2, y2); in gfx_copyrect()
126 void gfx_fillrect(gfx_surface* surface, uint x, uint y, uint width, uint height, uint color) { in gfx_fillrect() argument
127 LTRACEF("surface %p, x %u y %u w %u h %u c %u\n", surface, x, y, width, height, color); in gfx_fillrect()
129 if (unlikely(x >= surface->width)) in gfx_fillrect()
131 if (y >= surface->height) in gfx_fillrect()
137 if (x + width > surface->width) in gfx_fillrect()
138 width = surface->width - x; in gfx_fillrect()
141 if (y + height > surface->height) in gfx_fillrect()
142 height = surface->height - y; in gfx_fillrect()
144 surface->fillrect(surface, x, y, width, height, color); in gfx_fillrect()
150 void gfx_putpixel(gfx_surface* surface, uint x, uint y, uint color) { in gfx_putpixel() argument
151 if (unlikely(x >= surface->width)) in gfx_putpixel()
153 if (y >= surface->height) in gfx_putpixel()
156 surface->putpixel(surface, x, y, color); in gfx_putpixel()
160 static void putpixel(gfx_surface* surface, uint x, uint y, uint color) { in putpixel() argument
161 T* dest = static_cast<T*>(surface->ptr) + (x + y * surface->stride); in putpixel()
167 *dest = static_cast<T>(surface->translate_color(color)); in putpixel()
172 static void copyrect(gfx_surface* surface, uint x, uint y, uint width, uint height, uint x2, uint y… in copyrect() argument
174 const T* src = static_cast<const T*>(surface->ptr) + (x + y * surface->stride); in copyrect()
175 T* dest = static_cast<T*>(surface->ptr) + (x2 + y2 * surface->stride); in copyrect()
176 uint stride_diff = surface->stride - width; in copyrect()
191 src += height * surface->stride + width; in copyrect()
192 dest += height * surface->stride + width; in copyrect()
208 static void fillrect(gfx_surface* surface, uint x, uint y, uint width, uint height, uint _color) { in fillrect() argument
209 T* dest = static_cast<T*>(surface->ptr) + (x + y * surface->stride); in fillrect()
210 uint stride_diff = surface->stride - width; in fillrect()
216 color = static_cast<T>(surface->translate_color(_color)); in fillrect()
229 void gfx_line(gfx_surface* surface, uint x1, uint y1, uint x2, uint y2, uint color) { in gfx_line() argument
230 if (unlikely(x1 >= surface->width)) in gfx_line()
232 if (unlikely(x2 >= surface->width)) in gfx_line()
235 if (y1 >= surface->height) in gfx_line()
237 if (y2 >= surface->height) in gfx_line()
264 surface->putpixel(surface, px, py, color); in gfx_line()
275 surface->putpixel(surface, px, py, color); in gfx_line()
423 static void putchar(gfx_surface* surface, const struct gfx_font* font, in putchar() argument
425 T* dest = static_cast<T*>(surface->ptr) + (x + y * surface->stride); in putchar()
435 dest += (surface->stride - fw); in putchar()
439 void gfx_putchar(gfx_surface* surface, const struct gfx_font* font, in gfx_putchar() argument
444 if (unlikely(x > (surface->width - font->width))) { in gfx_putchar()
447 if (unlikely(y > (surface->height - font->height))) { in gfx_putchar()
450 if (surface->translate_color) { in gfx_putchar()
451 fg = surface->translate_color(fg); in gfx_putchar()
452 bg = surface->translate_color(bg); in gfx_putchar()
454 surface->putchar(surface, font, ch, x, y, fg, bg); in gfx_putchar()
460 void gfx_flush(gfx_surface* surface) { in gfx_flush() argument
461 if (surface->flags & GFX_FLAG_FLUSH_CPU_CACHE) in gfx_flush()
462 arch_clean_cache_range((addr_t)surface->ptr, surface->len); in gfx_flush()
464 if (surface->flush) in gfx_flush()
465 surface->flush(0, surface->height - 1); in gfx_flush()
471 void gfx_flush_rows(struct gfx_surface* surface, uint start, uint end) { in gfx_flush_rows() argument
478 if (start >= surface->height) in gfx_flush_rows()
480 if (end >= surface->height) in gfx_flush_rows()
481 end = surface->height - 1; in gfx_flush_rows()
483 if (surface->flags & GFX_FLAG_FLUSH_CPU_CACHE) { in gfx_flush_rows()
484 uint32_t runlen = surface->stride * surface->pixelsize; in gfx_flush_rows()
485 arch_clean_cache_range((addr_t)surface->ptr + start * runlen, (end - start + 1) * runlen); in gfx_flush_rows()
488 if (surface->flush) in gfx_flush_rows()
489 surface->flush(start, end); in gfx_flush_rows()
496 gfx_surface* surface = static_cast<gfx_surface*>(calloc(1, sizeof(*surface))); in gfx_create_surface() local
497 if (surface == NULL) in gfx_create_surface()
499 if (gfx_init_surface(surface, ptr, width, height, stride, format, flags)) { in gfx_create_surface()
500 free(surface); in gfx_create_surface()
503 return surface; in gfx_create_surface()
506 int gfx_init_surface(gfx_surface* surface, void* ptr, uint width, uint height, uint stride, gfx_for… in gfx_init_surface() argument
511 surface->flags = flags; in gfx_init_surface()
512 surface->format = format; in gfx_init_surface()
513 surface->width = width; in gfx_init_surface()
514 surface->height = height; in gfx_init_surface()
515 surface->stride = stride; in gfx_init_surface()
516 surface->alpha = MAX_ALPHA; in gfx_init_surface()
521 surface->translate_color = &ARGB8888_to_RGB565; in gfx_init_surface()
522 surface->copyrect = ©rect<uint16_t>; in gfx_init_surface()
523 surface->fillrect = &fillrect<uint16_t>; in gfx_init_surface()
524 surface->putpixel = &putpixel<uint16_t>; in gfx_init_surface()
525 surface->putchar = &putchar<uint16_t>; in gfx_init_surface()
526 surface->pixelsize = 2; in gfx_init_surface()
527 surface->len = (surface->height * surface->stride * surface->pixelsize); in gfx_init_surface()
531 surface->translate_color = NULL; in gfx_init_surface()
532 surface->copyrect = ©rect<uint32_t>; in gfx_init_surface()
533 surface->fillrect = &fillrect<uint32_t>; in gfx_init_surface()
534 surface->putpixel = &putpixel<uint32_t>; in gfx_init_surface()
535 surface->putchar = &putchar<uint32_t>; in gfx_init_surface()
536 surface->pixelsize = 4; in gfx_init_surface()
537 surface->len = (surface->height * surface->stride * surface->pixelsize); in gfx_init_surface()
540 surface->translate_color = &ARGB8888_to_Luma; in gfx_init_surface()
541 surface->copyrect = ©rect<uint8_t>; in gfx_init_surface()
542 surface->fillrect = &fillrect<uint8_t>; in gfx_init_surface()
543 surface->putpixel = &putpixel<uint8_t>; in gfx_init_surface()
544 surface->putchar = &putchar<uint8_t>; in gfx_init_surface()
545 surface->pixelsize = 1; in gfx_init_surface()
546 surface->len = (surface->height * surface->stride * surface->pixelsize); in gfx_init_surface()
549 surface->translate_color = &ARGB8888_to_RGB332; in gfx_init_surface()
550 surface->copyrect = ©rect<uint8_t>; in gfx_init_surface()
551 surface->fillrect = &fillrect<uint8_t>; in gfx_init_surface()
552 surface->putpixel = &putpixel<uint8_t>; in gfx_init_surface()
553 surface->putchar = &putchar<uint8_t>; in gfx_init_surface()
554 surface->pixelsize = 1; in gfx_init_surface()
555 surface->len = (surface->height * surface->stride * surface->pixelsize); in gfx_init_surface()
558 surface->translate_color = &ARGB8888_to_RGB2220; in gfx_init_surface()
559 surface->copyrect = ©rect<uint8_t>; in gfx_init_surface()
560 surface->fillrect = &fillrect<uint8_t>; in gfx_init_surface()
561 surface->putpixel = &putpixel<uint8_t>; in gfx_init_surface()
562 surface->putchar = &putchar<uint8_t>; in gfx_init_surface()
563 surface->pixelsize = 1; in gfx_init_surface()
564 surface->len = (surface->height * surface->stride * surface->pixelsize); in gfx_init_surface()
573 ptr = malloc(surface->len); in gfx_init_surface()
578 surface->flags |= GFX_FLAG_FREE_ON_DESTROY; in gfx_init_surface()
580 surface->ptr = ptr; in gfx_init_surface()
588 gfx_surface* surface = static_cast<gfx_surface*>(calloc(1, sizeof(*surface))); in gfx_create_surface_from_display() local
589 if (surface == NULL) in gfx_create_surface_from_display()
591 if (gfx_init_surface_from_display(surface, info)) { in gfx_create_surface_from_display()
592 free(surface); in gfx_create_surface_from_display()
595 return surface; in gfx_create_surface_from_display()
598 int gfx_init_surface_from_display(gfx_surface* surface, struct display_info* info) { in gfx_init_surface_from_display() argument
615 …r = gfx_init_surface(surface, info->framebuffer, info->width, info->height, info->stride, info->fo… in gfx_init_surface_from_display()
617 surface->flush = info->flush; in gfx_init_surface_from_display()
627 void gfx_surface_destroy(struct gfx_surface* surface) { in gfx_surface_destroy() argument
628 if (surface->flags & GFX_FLAG_FREE_ON_DESTROY) in gfx_surface_destroy()
629 free(surface->ptr); in gfx_surface_destroy()
630 free(surface); in gfx_surface_destroy()
641 gfx_surface* surface = gfx_create_surface_from_display(&info); in gfx_draw_pattern() local
644 for (y = 0; y < surface->height; y++) { in gfx_draw_pattern()
645 for (x = 0; x < surface->width; x++) { in gfx_draw_pattern()
649 scaledx = x * 256 / surface->width; in gfx_draw_pattern()
650 scaledy = y * 256 / surface->height; in gfx_draw_pattern()
652 …gfx_putpixel(surface, x, y, (0xff << 24) | (scaledx * scaledy) << 16 | (scaledx >> 1) << 8 | scale… in gfx_draw_pattern()
656 gfx_flush(surface); in gfx_draw_pattern()
658 gfx_surface_destroy(surface); in gfx_draw_pattern()
669 gfx_surface* surface = gfx_create_surface_from_display(&info); in gfx_draw_pattern_white() local
672 for (y = 0; y < surface->height; y++) { in gfx_draw_pattern_white()
673 for (x = 0; x < surface->width; x++) { in gfx_draw_pattern_white()
674 gfx_putpixel(surface, x, y, 0xFFFFFFFF); in gfx_draw_pattern_white()
678 gfx_flush(surface); in gfx_draw_pattern_white()
680 gfx_surface_destroy(surface); in gfx_draw_pattern_white()
692 static int gfx_draw_rgb_bars(gfx_surface* surface) { in gfx_draw_rgb_bars() argument
695 uint step = surface->height * 100 / 256; in gfx_draw_rgb_bars()
698 for (y = 0; y < surface->height; y++) { in gfx_draw_rgb_bars()
700 for (x = 0; x < surface->width / 3; x++) { in gfx_draw_rgb_bars()
702 gfx_putpixel(surface, x, y, 0xff << 24 | color << 16); in gfx_draw_rgb_bars()
705 for (; x < 2 * (surface->width / 3); x++) { in gfx_draw_rgb_bars()
707 gfx_putpixel(surface, x, y, 0xff << 24 | color << 8); in gfx_draw_rgb_bars()
710 for (; x < surface->width; x++) { in gfx_draw_rgb_bars()
712 gfx_putpixel(surface, x, y, 0xff << 24 | color); in gfx_draw_rgb_bars()
736 gfx_surface* surface = gfx_create_surface_from_display(&info); in cmd_gfx() local
745 gfx_draw_rgb_bars(surface); in cmd_gfx()
756 for (y = 0; y < surface->height; y++) { in cmd_gfx()
757 for (x = 0; x < surface->width; x++) { in cmd_gfx()
759 gfx_putpixel(surface, x, y, fillval); in cmd_gfx()
764 gfx_flush(surface); in cmd_gfx()
766 gfx_surface_destroy(surface); in cmd_gfx()