summaryrefslogtreecommitdiffstatsci
path: root/src/image.cpp
diff options
context:
space:
mode:
authorsuyambulingamrm <suyambu.rm@samsung.com>2014-05-30 12:39:11 +0530
committersuyambulingamrm <suyambu.rm@samsung.com>2014-05-30 12:39:11 +0530
commit11ce9a1775b62ce2d199a4ab0f4f82b92603b483 (patch)
treed1a85d3926ae50687cdd1e7f0a469502d29a9fb4 /src/image.cpp
parente22eb06986e0511a17e1706d09a46a75458a857b (diff)
Issue #65. Create window for image backend and display the output from image surface.
Diffstat (limited to 'src/image.cpp')
-rw-r--r--src/image.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/image.cpp b/src/image.cpp
index b17b612..4462ecc 100644
--- a/src/image.cpp
+++ b/src/image.cpp
@@ -9,6 +9,7 @@
#include <err.h>
#include <stdlib.h>
+#include "device_config.h"
#include "image.h"
void
@@ -18,6 +19,58 @@ cleanup_state_image (void *data)
free(state);
}
+bool
+createImageWindow(image_state_t *state, const device_config_t& device_config)
+{
+ state->dpy = XOpenDisplay (NULL);
+ if (!state->dpy) {
+ warnx ("fail to open display: %s\n", XDisplayName (0));
+ return false;
+ }
+
+ int screen = DefaultScreen (state->dpy);
+
+ XVisualInfo vi;
+ XSetWindowAttributes attrs;
+
+ XMatchVisualInfo (state->dpy, screen, 32, TrueColor, &vi);
+ attrs.border_pixel = 0;
+ attrs.event_mask = StructureNotifyMask;
+ attrs.colormap = XCreateColormap (state->dpy, DefaultRootWindow (state->dpy),
+ vi.visual, AllocNone);
+ state->window = XCreateWindow (state->dpy, DefaultRootWindow (state->dpy),
+ 0, 0,
+ device_config.width, device_config.height,
+ 0,
+ vi.depth,
+ InputOutput, vi.visual,
+ CWBorderPixel | CWColormap | CWEventMask,
+ &attrs);
+ state->width = device_config.width;
+ state->height = device_config.height;
+ XMapWindow (state->dpy, state->window);
+
+ state->gc = XCreateGC (state->dpy, state->window, 0, NULL);
+ return true;
+}
+
+void
+updateImageWindow(image_state_t* state)
+{
+ XPutImage (state->dpy, state->window, state->gc, &state->image,
+ 0, 0,
+ 0, 0,
+ state->width, state->height);
+ XSync (state->dpy, False);
+}
+void
+destroyImageWindow(image_state_t* state)
+{
+ XFreeGC (state->dpy, state->gc);
+ XDestroyWindow (state->dpy, state->window);
+ XCloseDisplay (state->dpy);
+}
+
/*
Local Variables:
mode:c++