diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-05-31 07:14:21 +0900 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-05-31 07:14:21 +0900 |
| commit | 8a5ac0ac095d09564aecb340d4bf58bbecfe63c9 (patch) | |
| tree | d9656fef9e2806858dfa31f7b50e96c392267b87 /src/image.cpp | |
| parent | 636f6a31c35d6d1825eabc92b91cedb6c12b4906 (diff) | |
| parent | 11ce9a1775b62ce2d199a4ab0f4f82b92603b483 (diff) | |
Merge pull request #67 from Samsung/Issue_65
Create window for image backend.
ref: https://github.com/Samsung/caskbench/issues/65
Diffstat (limited to 'src/image.cpp')
| -rw-r--r-- | src/image.cpp | 53 |
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++ |