summaryrefslogtreecommitdiffstatsci
path: root/src/cairo-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/cairo-image.cpp
parente22eb06986e0511a17e1706d09a46a75458a857b (diff)
Issue #65. Create window for image backend and display the output from image surface.
Diffstat (limited to 'src/cairo-image.cpp')
-rw-r--r--src/cairo-image.cpp38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/cairo-image.cpp b/src/cairo-image.cpp
index 5db97fe..1d6d918 100644
--- a/src/cairo-image.cpp
+++ b/src/cairo-image.cpp
@@ -12,28 +12,42 @@
#include "forward.h"
#include "image.h"
-#include "device_config.h"
static image_state_t *state;
+cairo_surface_t *cairo_surface;
+
+static int
+convert_cairo_surface_to_ximage (cairo_surface_t *surface)
+{
+ unsigned char *data = cairo_image_surface_get_data (surface);
+ state->image.width = cairo_image_surface_get_width (surface);
+ state->image.height = cairo_image_surface_get_height (surface);
+ state->image.format = ZPixmap;
+ state->image.data = (char*)data;
+ state->image.bitmap_unit = 4 * 8;
+ state->image.byte_order = LSBFirst;
+ state->image.bitmap_bit_order = LSBFirst;
+ state->image.bitmap_pad = 4 * 8;
+ state->image.depth = 32;
+ state->image.bytes_per_line = state->image.width * 4;
+ state->image.bits_per_pixel = 4 * 8;
+ Status status = XInitImage (&state->image);
+ return status;
+}
cairo_surface_t *
create_cairo_surface_image (const device_config_t& config)
{
- cairo_surface_t *cairo_surface;
-
state = (image_state_t*) malloc (sizeof (image_state_t));
if (!state) {
warnx ("Out of memory\n");
return NULL;
}
- /*
- state->dpy = XOpenDisplay (NULL);
- if (state->dpy == NULL) {
- warnx ("Failed to open display: %s\n", XDisplayName (0));
- return NULL;
- }
- */
+ if (!createImageWindow(state, config)) {
+ cleanup_state_image(state);
+ return NULL;
+ }
cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
config.width,
@@ -45,12 +59,16 @@ create_cairo_surface_image (const device_config_t& config)
void
destroy_cairo_image(void)
{
+ destroyImageWindow(state);
cleanup_state_image(state);
}
void
update_cairo_image(void)
{
+ if (convert_cairo_surface_to_ximage (cairo_surface)) {
+ updateImageWindow(state);
+ }
}
/*