summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Marchesin <stephane.marchesin@gmail.com>2010-05-03 00:46:31 -0700
committerStephane Marchesin <stephane.marchesin@gmail.com>2010-05-03 00:46:31 -0700
commitffea40ecbbe86ead2699239d504c4d6ecdca4732 (patch)
treeacdebe030d0310857c070c09a973c7e275898f99
parenta3147fea5e0b2da35e0ededd4f28b2253aa5d607 (diff)
First skeleton for a PutImage implementation.
-rw-r--r--draw.c4
-rw-r--r--init.c4
-rw-r--r--render.c3
-rw-r--r--tests/.rect.c.swpbin12288 -> 0 bytes
-rw-r--r--tests/rect.c6
-rw-r--r--xlib_api.c37
6 files changed, 48 insertions, 6 deletions
diff --git a/draw.c b/draw.c
index 6529771..73b41cb 100644
--- a/draw.c
+++ b/draw.c
@@ -27,4 +27,8 @@ void draw_rectangle(GC gc, xenon_rect* r)
damage_add(r);
}
+void draw_image(GC gc, XImage* image, xenon_rect area, int x, int y)
+{
+
+}
diff --git a/init.c b/init.c
index 8d03576..f12f18a 100644
--- a/init.c
+++ b/init.c
@@ -4,14 +4,14 @@
#include "render.h"
#include "damage.h"
-int init_done = 0;
+extern int inhibit_rendering;
void __attribute__ ((constructor)) init()
{
screen.width = 640;
screen.height = 480;
render_init(screen.width, screen.height);
- init_done = 1;
+ inhibit_rendering = 0;
damage_clear();
}
diff --git a/render.c b/render.c
index dada595..0d93a34 100644
--- a/render.c
+++ b/render.c
@@ -35,6 +35,7 @@ typedef struct xenon_libGL
xenon_libGL;
static xenon_libGL libGL;
+int inhibit_rendering = 1;
static void render_init_libs()
{
@@ -105,11 +106,13 @@ void render_init(int w, int h)
void render_update(xenon_rect r)
{
+ inhibit_rendering = 1;
for(int j = r.y ; j < r.y + r.h ; j++)
{
libGL.glRasterPos2i(r.x, r.h - j - 1);
libGL.glDrawPixels(r.w, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels + (r.x + j * screen_rect.w) * 4 );
}
+ inhibit_rendering = 0;
}
diff --git a/tests/.rect.c.swp b/tests/.rect.c.swp
deleted file mode 100644
index 141eb94..0000000
--- a/tests/.rect.c.swp
+++ /dev/null
Binary files differ
diff --git a/tests/rect.c b/tests/rect.c
index db66834..4fb4f0b 100644
--- a/tests/rect.c
+++ b/tests/rect.c
@@ -31,12 +31,14 @@ int main() {
XAllocColor(dis, colormap, &green_col);
XSetForeground(dis, green_gc, green_col.pixel);
- XSelectInput(dis, win, ExposureMask | KeyPressMask | ButtonPressMask);
+ printf("select input\n");
+/* XSelectInput(dis, win, ExposureMask | KeyPressMask | ButtonPressMask);
XDrawRectangle(dis, win, green_gc, 1, 1, 247, 247);
XDrawRectangle(dis, win, green_gc, 50, 50, 148, 148);
+ printf("flush\n");
XFlush(dis);
sleep(5);
- return 0;
+*/ return 0;
}
diff --git a/xlib_api.c b/xlib_api.c
index 2174483..351d058 100644
--- a/xlib_api.c
+++ b/xlib_api.c
@@ -30,8 +30,8 @@ GC XCreateGC(
)
{
// XXX init hack, remove when the renderer is changed to gallium
- extern int init_done;
- if (!init_done)
+ extern int inhibit_rendering;
+ if (inhibit_rendering)
{
void* handle;
handle = dlopen("/usr/lib64/libX11.so.6", RTLD_LAZY);
@@ -193,6 +193,39 @@ Status XParseColor(
printf("parse color ok\n");
}
+int XPutImage(
+ Display* display,
+ Drawable d,
+ GC gc,
+ XImage* image,
+ int src_x,
+ int src_y,
+ int dest_x,
+ int dest_y,
+ unsigned int width,
+ unsigned int height
+)
+{
+ // XXX init hack, remove when the renderer is changed to gallium
+ extern int inhibit_rendering;
+ if (inhibit_rendering)
+ {
+ void* handle;
+ handle = dlopen("/usr/lib64/libX11.so.6", RTLD_LAZY);
+ if (!handle)
+ handle = dlopen("/usr/lib/libX11.so.6", RTLD_LAZY);
+ if (!handle)
+ printf("can't open libX11\n");
+ typedef GC (* XPutImagefunc) (Display*, Drawable, GC, XImage*, int, int, int, int, unsigned, unsigned);
+ XPutImagefunc XPutImagereal = dlsym(handle, "XPutImage");
+ return XPutImagereal(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
+ }
+
+ xenon_rect r = {src_x,src_y,width,height};
+ draw_image(gc, image, r, dest_x, dest_y);
+ printf("put image ok\n");
+}
+
int XSelectInput(
Display* display,
Window w,