X-Git-Url: http://git.mutantstargoat.com?p=winnie;a=blobdiff_plain;f=libwinnie%2Fsrc%2Fgfx.cc;fp=libwinnie%2Fsrc%2Fgfx.cc;h=b72e43bcf1fa67788a349c72366e73a6379aacde;hp=0000000000000000000000000000000000000000;hb=7b5d2df884abb7084d71f17cc29a618c0b6f47ef;hpb=b4c8d68e0357683cec82fb8a9c5a4447155b3192
diff --git a/libwinnie/src/gfx.cc b/libwinnie/src/gfx.cc
new file mode 100644
index 0000000..b72e43b
--- /dev/null
+++ b/libwinnie/src/gfx.cc
@@ -0,0 +1,175 @@
+/*
+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