/* winnie - an experimental window system Copyright (C) 2013 Eleni Maria Stea This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Author: Eleni Maria Stea */ #include #include "geom.h" #include "gfx.h" void clear_screen(int r, int g, int b) { Rect screen_rect = get_screen_size(); fill_rect(screen_rect, r, g, b); } void fill_rect(const Rect &rect, int r, int g, int b) { Rect drect = rect; Rect screen_rect = get_screen_size(); Rect clipping_rect = get_clipping_rect(); if(drect.x < clipping_rect.x) { drect.width -= clipping_rect.x - drect.x; drect.x = clipping_rect.x; } if(drect.y < clipping_rect.y) { drect.height -= clipping_rect.y - drect.y; drect.y = clipping_rect.y; } if(drect.x + drect.width >= clipping_rect.x + clipping_rect.width) { drect.width = clipping_rect.width + clipping_rect.x - drect.x; } if(drect.y + drect.height >= clipping_rect.y + clipping_rect.height) { drect.height = clipping_rect.height + clipping_rect.y - drect.y; } unsigned char *fb = get_framebuffer() + (drect.x + screen_rect.width * drect.y) * 4; for(int i=0; i= irect.width) { width -= xend - irect.width; } int yend = dest_y + height; if(yend >= irect.height) { height -= yend - irect.height; } if(width <= 0 || height <= 0) { return; } unsigned char *sptr = src_img + (src_rect.y * src_rect.width + src_rect.x) * 4; unsigned char *dptr = dest_img + (dest_y * dest_rect.width + dest_x) * 4; for(int i=0; i= irect.width) { width -= xend - irect.width; } int yend = dest_y + height; if(yend >= irect.height) { height -= yend - irect.height; } if(width <= 0 || height <= 0) { return; } unsigned char *sptr = src_img + (src_rect.y * src_rect.width + src_rect.x) * 4; unsigned char *dptr = dest_img + (dest_y * dest_rect.width + dest_x) * 4; for(int i=0; i