summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Marchesin <stephane.marchesin@gmail.com>2010-04-24 18:09:17 -0700
committerStephane Marchesin <stephane.marchesin@gmail.com>2010-04-24 18:09:17 -0700
commit661eb5a9126e608b8e5cea3e6105728da3edd015 (patch)
treee5e6814fb6986ec6ad9db27175ae5cb54e2cf238
parent24f654343c555424cb4313a863d02fe6ce819499 (diff)
More work on draw/damage.
-rw-r--r--CMakeLists.txt4
-rw-r--r--damage.c18
-rw-r--r--damage.h5
-rw-r--r--draw.c23
-rw-r--r--draw.h21
-rw-r--r--render.c3
-rw-r--r--render.h7
-rw-r--r--xlib_api.c3
8 files changed, 74 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 530950f..ac0f5e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.4)
link_libraries(dl)
-set(CMAKE_C_FLAGS "-Wall -march=native -O2")
-add_library (X11 SHARED display.c drawable.c init.c render.c screen.c window.c xlib_api.c)
+set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wtype-limits -Wuninitialized -Wmissing-field-initializers -Wmissing-parameter-type -march=native -O2 --std=gnu99")
+add_library (X11 SHARED damage.c display.c draw.c drawable.c init.c render.c screen.c window.c xlib_api.c)
diff --git a/damage.c b/damage.c
new file mode 100644
index 0000000..8d27c06
--- /dev/null
+++ b/damage.c
@@ -0,0 +1,18 @@
+#include "draw.h"
+
+static xenon_rect current_rect;
+
+void damage_add(xenon_rect* region)
+{
+ xenon_rect new = current_rect;
+}
+
+void damage_clear()
+{
+}
+
+xenon_rect current_damage()
+{
+ return current_rect;
+}
+
diff --git a/damage.h b/damage.h
new file mode 100644
index 0000000..8d6f66a
--- /dev/null
+++ b/damage.h
@@ -0,0 +1,5 @@
+#include "draw.h"
+
+void damage_add(xenon_rect* region);
+void damage_clear();
+xenon_rect current_damage();
diff --git a/draw.c b/draw.c
new file mode 100644
index 0000000..cf2ba5e
--- /dev/null
+++ b/draw.c
@@ -0,0 +1,23 @@
+#include "xenon.h"
+#include "draw.h"
+#include "damage.h"
+
+unsigned char* pixels;
+xenon_rect screen_rect;
+
+void draw_rectangle(GC gc, xenon_rect* r)
+{
+ for(int i = r->x ; i < r->x + r->w ; i++)
+ {
+ pixelrgba(i, r->y) = 0xffffffff;
+ pixelrgba(i, r->y + r->h) = 0xffffffff;
+ }
+ for(int j = r->y ; j < r->y + r->h ; j++)
+ {
+ pixelrgba(r->x, j) = 0xffffffff;
+ pixelrgba(r->x + r->w, j) = 0xffffffff;
+ }
+ damage_add(r);
+}
+
+
diff --git a/draw.h b/draw.h
new file mode 100644
index 0000000..5122f0c
--- /dev/null
+++ b/draw.h
@@ -0,0 +1,21 @@
+#ifndef _draw_h_
+#define _draw_h_
+
+#define pixelr(x,y) pixels[(screen_rect.w * y + x)*4 + 0]
+#define pixelg(x,y) pixels[(screen_rect.w * y + x)*4 + 1]
+#define pixelb(x,y) pixels[(screen_rect.w * y + x)*4 + 2]
+#define pixela(x,y) pixels[(screen_rect.w * y + x)*4 + 3]
+
+#define pixelrgba(x,y) ((unsigned*)pixels)[(screen_rect.w * y + x)]
+
+typedef struct xenon_rect
+{
+ int x, y;
+ int w, h;
+}
+xenon_rect;
+extern unsigned char* pixels;
+extern xenon_rect screen_rect;
+
+#endif
+
diff --git a/render.c b/render.c
index 8388f30..b977eee 100644
--- a/render.c
+++ b/render.c
@@ -2,10 +2,9 @@
#include <dlfcn.h>
#include "xenon.h"
#include "render.h"
+#include "draw.h"
#include <GL/glx.h>
-unsigned char* pixels;
-static xenon_rect screen_rect;
typedef struct xenon_libX11
{
diff --git a/render.h b/render.h
index 9a924de..05e35db 100644
--- a/render.h
+++ b/render.h
@@ -1,10 +1,5 @@
-typedef struct xenon_rect
-{
- int x, y;
- int w, h;
-}
-xenon_rect;
+#include "draw.h"
extern void render_init(int w, int h);
extern void render_update(xenon_rect r);
diff --git a/xlib_api.c b/xlib_api.c
index 1d52181..5d1f66b 100644
--- a/xlib_api.c
+++ b/xlib_api.c
@@ -2,6 +2,7 @@
#include "xenon.h"
#include "window.h"
#include "display.h"
+#include "draw.h"
Status XAllocColor(
Display* display,
@@ -84,6 +85,8 @@ int XDrawRectangle(
unsigned int height
)
{
+ xenon_rect r = {x,y,width,height};
+ draw_rectangle(gc, &r);
printf("draw rectangle ok\n");
}