struct weston_output *output, uint32_t msecs);
/* fade animation end */
static void animation_fade_end(struct weston_animation *animation);
+ /* slide animation end */
+static void animation_slide_end(struct weston_animation *animation);
/* zoom animation */
static void animation_zoom(struct weston_animation *animation,
struct weston_output *output, uint32_t msecs);
struct weston_output *output, uint32_t msecs)
{
struct uifw_win_surface *usurf;
- struct weston_surface *es;
- struct weston_view *ev;
+ struct animation_data *animadata;
+ struct weston_layout_SurfaceProperties prop;
int dwidth, dheight;
- int par;
- int x;
- int y;
+ int par, x, y;
usurf = container_of(animation, struct uifw_win_surface, animation.animation);
}
return;
}
- ev = ico_ivi_get_primary_view(usurf);
+ if (animation->frame_counter == 1) {
+ animadata = (struct animation_data *)usurf->animation.animadata;
+ animadata->end_function = animation_slide_end;
+ }
par = usurf->animation.current;
uifw_debug("animation_slide: %08x count=%d %d%% anima=%d state=%d",
usurf->surfaceid, animation->frame_counter, par,
usurf->animation.anima, usurf->animation.state);
- es = usurf->surface;
x = usurf->x;
y = usurf->y;
}
break;
}
-
- uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d)",
- usurf->surfaceid, par, x, y, usurf->x, usurf->y);
- ev->geometry.x = usurf->node_tbl->disp_x + x;
- ev->geometry.y = usurf->node_tbl->disp_y + y;
- if ((ev->output) && (es->buffer_ref.buffer) &&
- (es->width > 0) && (es->height > 0)) {
- weston_view_geometry_dirty(ev);
- weston_surface_damage(es);
+ if ((par < 8) || (par > 92)) {
+ uifw_debug("animation_slide: %08x %d%% %d/%d(target %d/%d) %08x",
+ usurf->surfaceid, par, x, y, usurf->x, usurf->y, (int)usurf->ivisurf);
+ }
+ if (weston_layout_getPropertiesOfSurface(usurf->ivisurf, &prop) == 0) {
+ if (weston_layout_surfaceSetDestinationRectangle(usurf->ivisurf, x, y,
+ prop.destWidth, prop.destHeight) == 0) {
+ weston_layout_commitChanges();
+ }
}
if (par >= 100) {
/* end of animation */
animation_end(usurf, 1);
uifw_trace("animation_slide: End of animation");
}
- else {
- /* continue animation */
- weston_compositor_schedule_repaint(weston_ec);
+}
+
+/*--------------------------------------------------------------------------*/
+/**
+ * @brief animation_slide_end: slide animation end
+ *
+ * @param[in] animation weston animation table
+ * @return none
+ */
+/*--------------------------------------------------------------------------*/
+static void
+animation_slide_end(struct weston_animation *animation)
+{
+ struct uifw_win_surface *usurf;
+
+ usurf = container_of(animation, struct uifw_win_surface, animation.animation);
+ if (usurf) {
+ ico_window_mgr_set_weston_surface(usurf,
+ usurf->animation.pos_x, usurf->animation.pos_y,
+ usurf->animation.pos_width,
+ usurf->animation.pos_height);
}
}
es = usurf->surface;
ev = ico_ivi_get_primary_view(usurf);
ev->alpha = usurf->animation.alpha;
- uifw_debug("animation_swing_end: %08x set alpha=%f",
+ uifw_debug("animation_swing_end: %08x set alpha=%.2f",
usurf->surfaceid, usurf->animation.alpha);
if ((ev->output) && (es->buffer_ref.buffer)) {
weston_surface_damage(es);
if (ev->alpha < 0.0f) ev->alpha = 0.0f;
else if (ev->alpha > 1.0f) ev->alpha = 1.0f;
- if ((par < 5) || (par > 95)) {
+ if ((par < 8) || (par > 92)) {
uifw_debug("animation_fade: %08x count=%d %d%% alpha=%1.2f anima=%d state=%d",
usurf->surfaceid, animation->frame_counter, par,
ev->alpha, usurf->animation.anima, usurf->animation.state);
es = usurf->surface;
ev = ico_ivi_get_primary_view(usurf);
ev->alpha = usurf->animation.alpha;
- uifw_debug("animation_fade_end: %08x set alpha=%f",
+ uifw_debug("animation_fade_end: %08x set alpha=%.2f",
usurf->surfaceid, usurf->animation.alpha);
if ((ev->output) && (es->buffer_ref.buffer) &&
(es->width > 0) && (es->height > 0)) {
return 0;
}
-
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <errno.h>
#include <limits.h>
#include <pixman.h>
#include <wayland-server.h>
+#include <wayland-server.h>
#include <dirent.h>
#include <aul/aul.h>
#include <bundle.h>
#include <weston/weston-layout.h>
/* detail debug log */
-#define UIFW_DETAIL_OUT 0 /* 1=detail debug log/0=no detail log */
+#define UIFW_DETAIL_OUT 1 /* 1=detail debug log/0=no detail log */
#include <weston/weston-layout.h>
+#include <weston/ivi-shell.h>
#include "ico_ivi_common_private.h"
#include "ico_window_mgr_private.h"
#include "ico_window_mgr-server-protocol.h"
/* animation for map check */
struct wl_event_source *wait_mapevent; /* map event send wait timer */
+ char *pixel_readbuf; /* surface pixel image read buffer */
+ int pixel_readsize; /* surface pixel image read buffer size */
struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
struct weston_layout_surface *ivisurf);
/* surface destroy */
static void win_mgr_destroy_surface(struct weston_surface *surface);
- /* window manager surface configure */
-static void win_mgr_surface_configure(struct uifw_win_surface *usurf,
- int x, int y, int width, int height);
+ /* read surface pixel */
+static int win_mgr_takeSurfaceScreenshot(const char *filename,
+ struct uifw_win_surface *usurf,
+ int width, int height);
/* set surface animation */
static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
uint32_t surfaceid, int32_t type,
/* hook for remove surface of ivi-shell */
static void ico_ivi_surfaceRemoveNotification(struct weston_layout_surface *ivisurf,
void *userdata);
- /* hook for configure surface of ivi-shell*/
-static void ico_ivi_surfaceConfigureNotification(struct weston_layout_surface *ivisurf,
- void *userdata);
/* hook for property change of ivi-shell*/
static void ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf,
struct weston_layout_SurfaceProperties *prop,
uifw_error("ico_ivi_get_primary_view: usurf=%08x(%x) surface=%08x has no view",
(int)usurf, usurf->surfaceid, (int)usurf->surface);
}
- else {
- uifw_debug("ico_ivi_get_primary_view: %08x view=%08x view->surf=%08x",
- usurf->surfaceid, (int)ev, (int)ev->surface);
- }
return ev;
}
int x, int y, int width, int height)
{
struct weston_surface *es = usurf->surface;
- struct weston_view *ev;
+ struct weston_layout_SurfaceProperties prop;
int buf_width, buf_height;
if ((es == NULL) || (usurf->ivisurf == NULL)) {
x = ICO_IVI_MAX_COORDINATE+1;
y = ICO_IVI_MAX_COORDINATE+1;
}
- ev = ico_ivi_get_primary_view(usurf);
- if ((ev != NULL) &&
- (((int)ev->geometry.x != x) || ((int)ev->geometry.y != y) ||
- (es->width != width) || (es->height != height))) {
- weston_view_damage_below(ev);
- win_mgr_surface_configure(usurf, x, y, width, height);
+ if (weston_layout_getPropertiesOfSurface(usurf->ivisurf, &prop) == 0) {
+ if ((prop.destX != x) || (prop.destY != y) ||
+ (prop.destWidth != (uint32_t)width) ||
+ (prop.destHeight != (uint32_t)height)) {
+ if (weston_layout_surfaceSetDestinationRectangle(
+ usurf->ivisurf, x, y, width, height) == 0) {
+ weston_layout_commitChanges();
+ }
+ }
}
weston_surface_damage(es);
}
/*--------------------------------------------------------------------------*/
/**
- * @brief ico_ivi_surfaceConfigureNotification: configure ivi-surface
- *
- * @param[in] ivisurf ivi surface
- * @param[in] userdata User Data(Unused)
- * @return none
- */
-/*--------------------------------------------------------------------------*/
-static void
-ico_ivi_surfaceConfigureNotification(struct weston_layout_surface *ivisurf, void *userdata)
-{
- struct weston_view *view;
- struct weston_surface *surface;
- uint32_t id_surface;
-
- id_surface = weston_layout_getIdOfSurface(ivisurf);
- view = weston_layout_get_weston_view(ivisurf);
- if (! view) {
- uifw_trace("ico_ivi_surfaceConfigureNotification: %08x has no view",
- id_surface);
- }
- else {
- surface = view->surface;
- if (! surface) {
- uifw_trace("ico_ivi_surfaceConfigureNotification: %08x has no surface",
- id_surface);
- }
- else {
- uifw_trace("ico_ivi_surfaceConfigureNotification: Configure %08x "
- "x/y=%d/%d w/h=%d/%d",
- id_surface, (int)view->geometry.x, (int)view->geometry.y,
- surface->width, surface->height);
- weston_layout_surfaceSetSourceRectangle(ivisurf,
- 0, 0, surface->width, surface->height);
- weston_layout_surfaceSetDestinationRectangle(ivisurf,
- (uint32_t)view->geometry.x, (uint32_t)view->geometry.y,
- surface->width, surface->height);
- weston_layout_commitChanges();
- }
- }
-}
-
-/*--------------------------------------------------------------------------*/
-/**
* @brief ico_ivi_surfacePropertyNotification: property change ivi-surface
*
* @param[in] ivisurf ivi surface
int retanima;
uint32_t newmask;
struct uifw_win_surface *usurf;
- struct weston_view *ev;
+ struct weston_view *ev;
newmask = ((uint32_t)mask) & (~(IVI_NOTIFICATION_OPACITY|IVI_NOTIFICATION_ORIENTATION|
IVI_NOTIFICATION_PIXELFORMAT));
prop->sourceWidth, prop->sourceHeight);
if ((usurf->client_width == prop->sourceWidth) &&
(usurf->client_height == prop->sourceHeight)) {
- newmask &= (~(IVI_NOTIFICATION_SOURCE_RECT|IVI_NOTIFICATION_DIMENSION));
+ newmask &= (~IVI_NOTIFICATION_SOURCE_RECT);
}
else {
usurf->client_width = prop->sourceWidth;
}
if ((usurf->x == prop->destX) && (usurf->y == prop->destY) &&
(usurf->width == prop->destWidth) && (usurf->height == prop->destHeight)) {
- newmask &= (~(IVI_NOTIFICATION_DEST_RECT|IVI_NOTIFICATION_POSITION));
+ newmask &= (~(IVI_NOTIFICATION_DEST_RECT|
+ IVI_NOTIFICATION_POSITION|IVI_NOTIFICATION_DIMENSION));
}
else {
usurf->x = prop->destX;
usurf->y = prop->destY;
usurf->width = prop->destWidth;
usurf->height = prop->destHeight;
+ if ((usurf->width != usurf->configure_width) ||
+ (usurf->height != usurf->configure_height)) {
+ /* send configure to client(App) */
+ uifw_trace("ico_ivi_surfacePropertyNotification: send configure "
+ "%08x(%d,%d->%d,%d)", usurf->surfaceid,
+ usurf->configure_width, usurf->configure_height,
+ usurf->width, usurf->height);
+ usurf->configure_width = usurf->width;
+ usurf->configure_height = usurf->height;
+
+ struct wl_array surfaces;
+ struct shell_surface;
+ void **shsurf;
+ if (! usurf->shsurf_resource) {
+ /* get shell surface if not get */
+ ivi_shell_get_shell_surfaces(&surfaces);
+ wl_array_for_each(shsurf, &surfaces) {
+ if (shell_surface_get_surface(*shsurf) == usurf->surface) {
+ usurf->shsurf_resource = *((struct wl_resource **)*shsurf);
+ break;
+ }
+ }
+ wl_array_release(&surfaces);
+ }
+ if (usurf->shsurf_resource) {
+ uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x "
+ "resource=%08x",
+ usurf->surfaceid, (int)usurf->shsurf_resource);
+ wl_shell_surface_send_configure(usurf->shsurf_resource,
+ WL_SHELL_SURFACE_RESIZE_RIGHT|
+ WL_SHELL_SURFACE_RESIZE_BOTTOM,
+ usurf->configure_width, usurf->configure_height);
+ }
+ else {
+ uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x "
+ "shell_surface resource not found", usurf->surfaceid);
+ }
+ }
}
}
if (newmask & IVI_NOTIFICATION_VISIBILITY) {
+ if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
+ (win_mgr_hook_animation != NULL)) {
+ /* start animation, save original position of surface */
+ usurf->animation.pos_x = usurf->x;
+ usurf->animation.pos_y = usurf->y;
+ usurf->animation.pos_width = usurf->width;
+ usurf->animation.pos_height = usurf->height;
+ ev = weston_layout_get_weston_view(ivisurf);
+ if (ev) {
+ usurf->animation.alpha = ev->alpha;
+ }
+ else {
+ usurf->animation.alpha = 1.0;
+ }
+ }
if ((usurf->visible == 0) && (prop->visibility)) {
uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 0=>1",
id_surface);
if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
(win_mgr_hook_animation != NULL)) {
/* show with animation */
- usurf->animation.pos_x = usurf->x;
- usurf->animation.pos_y = usurf->y;
- usurf->animation.pos_width = usurf->width;
- usurf->animation.pos_height = usurf->height;
- ev = weston_layout_get_weston_view(ivisurf);
- if (ev) {
- usurf->animation.alpha = ev->alpha;
- }
- else {
- usurf->animation.alpha = 0.9999f;
- }
retanima =
(*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW,
(void *)usurf);
else if ((usurf->visible != 0) && (! prop->visibility)) {
uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 1=>0",
id_surface);
+ usurf->visible = 0;
if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
(win_mgr_hook_animation != NULL)) {
/* hide with animation */
- usurf->animation.pos_x = usurf->x;
- usurf->animation.pos_y = usurf->y;
- usurf->animation.pos_width = usurf->width;
- usurf->animation.pos_height = usurf->height;
- ev = weston_layout_get_weston_view(ivisurf);
- if (ev) {
- usurf->animation.alpha = ev->alpha;
- }
- else {
- usurf->animation.alpha = 0.99999999f;
- }
retanima =
(*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE,
(void *)usurf);
if (newmask) {
/* surface changed, send event to controller */
wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
- uifw_trace("win_mgr_send_event: Send UPDATE_SURFACE(surf=%08x)", id_surface);
+ uifw_trace("win_mgr_send_event: Send UPDATE_SURFACE(surf=%08x) "
+ "v=%d src=%d/%d dest=%d/%d(%d/%d)", id_surface,
+ usurf->visible, usurf->client_width, usurf->client_height,
+ usurf->x, usurf->y, usurf->width, usurf->height);
ico_window_mgr_send_update_surface(mgr->resource, id_surface,
usurf->visible, usurf->client_width,
usurf->client_height, usurf->x, usurf->y,
win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface,
struct wl_client *client, struct weston_layout_surface *ivisurf)
{
+ struct weston_layout_SurfaceProperties prop;
struct uifw_win_surface *usurf;
struct uifw_win_surface *phash;
struct uifw_win_surface *bhash;
/* set default color and shader */
weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
+
/* create UIFW surface management table */
usurf = malloc(sizeof(struct uifw_win_surface));
if (! usurf) {
usurf->surface = surface;
usurf->ivisurf = ivisurf;
usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
+
+ if (weston_layout_getPropertiesOfSurface(ivisurf, &prop) == 0) {
+ usurf->x = prop.destX;
+ usurf->y = prop.destY;
+ usurf->width = prop.destWidth;
+ usurf->height = prop.destHeight;
+ usurf->client_width = prop.sourceWidth;
+ usurf->client_height = prop.sourceHeight;
+ usurf->configure_width = usurf->client_width;
+ usurf->configure_height = usurf->client_height;
+ }
wl_list_init(&usurf->client_link);
wl_list_init(&usurf->animation.animation.link);
wl_list_init(&usurf->surf_map);
/* check all mapped surfaces */
curtime = weston_compositor_get_time();
wl_list_for_each_safe (sm, sm_tmp, &_ico_win_mgr->map_list, map_link) {
+#if 0 /* too many log */
uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x",
(int)sm, sm->usurf->surfaceid);
+#endif
win_mgr_change_mapsurface(sm, 0, curtime);
if (sm->eventque) {
if (sm->interval < wait) {
uint32_t format;
uint32_t dtime;
+#if 0 /* too many log */
uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event);
+#endif
if (event == 0) {
event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
}
if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
sm->initflag = 1;
event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
+#if PERFORMANCE_EVALUATIONS > 0
+ uifw_perf("SWAP_BUFFER appid=%s surface=%08x MAP",
+ sm->usurf->uclient->appid, sm->usurf->surfaceid);
+#endif /*PERFORMANCE_EVALUATIONS*/
}
else if ((width <= 0) || (height <= 0)) {
event = 0;
if ((sm->width != width) || (sm->height != height) ||
(format != sm->format)) {
event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
+#if PERFORMANCE_EVALUATIONS > 0
+ uifw_perf("SWAP_BUFFER appid=%s surface=%08x RESIZE",
+ sm->usurf->uclient->appid, sm->usurf->surfaceid);
+#endif /*PERFORMANCE_EVALUATIONS*/
}
else {
if (es->buffer_ref.buffer->legacy_buffer != sm->curbuf) {
#if PERFORMANCE_EVALUATIONS > 0
- uifw_perf("SWAP_BUFFER appid=%s surface=%08x",
+ uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS",
sm->usurf->uclient->appid, sm->usurf->surfaceid);
#endif /*PERFORMANCE_EVALUATIONS*/
dtime = curtime - sm->lasttime;
else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
#if PERFORMANCE_EVALUATIONS > 0
if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) {
- uifw_perf("SWAP_BUFFER appid=%s surface=%08x",
+ uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS",
sm->usurf->uclient->appid, sm->usurf->surfaceid);
}
#endif /*PERFORMANCE_EVALUATIONS*/
if (event != 0) {
uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d "
- "w/h/s=%d/%d/%d format=%x",
+ "w/h/s=%d/%d/%d format=%x file=<%s>",
event, sm->usurf->surfaceid, sm->type,
- sm->width, sm->height, sm->stride, sm->format);
+ sm->width, sm->height, sm->stride, sm->format, sm->filepath);
sm->lasttime = curtime;
sm->eventque = 0;
if ((event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) &&
- (sm->filepath != NULL)) {
+ (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP) &&
+ (sm->filepath[0] != 0)) {
+#if 1 /* weston_layout_takeSurfaceScreenshot(GENIVI) is slowly */
+ if (win_mgr_takeSurfaceScreenshot(sm->filepath, sm->usurf,
+ sm->width, sm->height) != 0)
+#else /* weston_layout_takeSurfaceScreenshot(GENIVI) is slowly */
if (weston_layout_takeSurfaceScreenshot(sm->filepath,
- sm->usurf->ivisurf) != 0) {
+ sm->usurf->ivisurf) != 0)
+#endif /* weston_layout_takeSurfaceScreenshot(GENIVI) is slowly */
+ {
uifw_warn("win_mgr_change_mapsurface: surface.%08x image read(%s) Error",
sm->usurf->surfaceid, sm->filepath);
event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
}
+ else {
+ uifw_warn("win_mgr_change_mapsurface: surface.%08x image read(%s) OK",
+ sm->usurf->surfaceid, sm->filepath);
+ }
}
ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
sm->usurf->surfaceid, sm->type,
/*--------------------------------------------------------------------------*/
/**
- * @brief win_mgr_surface_configure: UIFW surface configure
- *
- * @param[in] usurf UIFW surface
- * @param[in] x X coordinate on screen
- * @param[in] y Y coordinate on screen
- * @param[in] width surface width
- * @param[in] height surface height
- * @return none
- */
-/*--------------------------------------------------------------------------*/
-static void
-win_mgr_surface_configure(struct uifw_win_surface *usurf,
- int x, int y, int width, int height)
-{
- struct weston_surface *es;
- struct weston_view *ev;
-
- es = usurf->surface;
- if ((es != NULL) && (es->buffer_ref.buffer)) {
- if (usurf->client_width == 0) {
- usurf->client_width = es->width;
- if (usurf->client_width == 0)
- usurf->client_width = ico_ivi_surface_buffer_width(es);
- }
- if (usurf->client_height == 0) {
- usurf->client_height = es->height;
- if (usurf->client_height == 0)
- usurf->client_height = ico_ivi_surface_buffer_height(es);
- }
-
- /* not set geometry width/height */
- ev = ico_ivi_get_primary_view(usurf);
- weston_view_set_position(ev, x, y);
- }
-}
-
-/*--------------------------------------------------------------------------*/
-/**
* @brief win_mgr_destroy_surface: surface destroy
*
* @param[in] surface Weston surface
/*--------------------------------------------------------------------------*/
/**
+ * @brief win_mgr_takeSurfaceScreenshot: take screen image pixel
+ *
+ * @param[in] filename output file path
+ * @param[in] usurf UIFW surface
+ * @param[in] width surface width
+ * @param[in] height surface height
+ * @return result
+ * @retval 0 success
+ * @retval -1 error
+ */
+/*--------------------------------------------------------------------------*/
+static int
+win_mgr_takeSurfaceScreenshot(const char *filename, struct uifw_win_surface *usurf,
+ int width, int height)
+{
+ int datasize;
+ int bufsize;
+ int bitperpixel;
+ int bmphead_size;
+ int fd;
+ int pathlen;
+ int linesize;
+ char *sp, *dp;
+ char *wkbuf = NULL;
+#pragma pack(push, 1)
+ struct _bmphead {
+ short magic;
+ uint32_t fullsize;
+ short res1;
+ short res2;
+ int offset;
+ int headsize;
+ int width;
+ int height;
+ short planes;
+ short bitperpixel;
+ int compress;
+ int datasize;
+ int xp;
+ int yp;
+ int colors;
+ int colors2;
+ } *bmphead;
+#pragma pack(pop)
+
+ uifw_trace("win_mgr_takeSurfaceScreenshot: Enter(%08x) <%s>",
+ usurf->surfaceid, filename);
+
+ if (! _ico_win_mgr->compositor->renderer->read_surface_pixels) {
+ uifw_trace("win_mgr_takeSurfaceScreenshot: Leave(no read_surface_pixels)");
+ return -1;
+ }
+ bitperpixel = PIXMAN_FORMAT_BPP(_ico_win_mgr->compositor->read_format);
+ bmphead_size = ((sizeof(struct _bmphead) + 31) / 32) * 32;
+ datasize = (width * bitperpixel / 8) * height;
+ bufsize = datasize + bmphead_size;
+ if ((_ico_win_mgr->pixel_readbuf != NULL) &&
+ (bufsize > _ico_win_mgr->pixel_readsize)) {
+ free(_ico_win_mgr->pixel_readbuf);
+ _ico_win_mgr->pixel_readbuf = NULL;
+ }
+ if (_ico_win_mgr->pixel_readbuf == NULL) {
+ _ico_win_mgr->pixel_readbuf = malloc(bufsize);
+ if (! _ico_win_mgr->pixel_readbuf) {
+ uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)");
+ return -1;
+ }
+ _ico_win_mgr->pixel_readsize = bufsize;
+ }
+ pathlen = strlen(filename);
+ if ((pathlen >= 4) && (strcmp(&filename[pathlen-4], ".bmp") == 0)) {
+ /* BMP format */
+ wkbuf = malloc(datasize);
+ if (! wkbuf) {
+ uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)");
+ return -1;
+ }
+ }
+ fd = open(filename, O_WRONLY|O_CREAT, 0644);
+ if (fd < 0) {
+ uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> open Error<%d>)",
+ filename, errno);
+ if (wkbuf) free(wkbuf);
+ return -1;
+ }
+
+ uifw_detail("win_mgr_takeSurfaceScreenshot: call read_surface_pixels(%d,%d)",
+ width, height);
+ if ((*(_ico_win_mgr->compositor->
+ renderer->read_surface_pixels))(usurf->surface, PIXMAN_a8r8g8b8,
+ wkbuf ? wkbuf :
+ (_ico_win_mgr->pixel_readbuf + bmphead_size),
+ 0, 0, width, height) != 0) {
+ close(fd);
+ uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(read_surface_pixels Error)");
+ if (wkbuf) free(wkbuf);
+ return -1;
+ }
+ uifw_detail("win_mgr_takeSurfaceScreenshot: end read_surface_pixels");
+
+ if (wkbuf) {
+ /* BMP format */
+ bmphead = (struct _bmphead *)(_ico_win_mgr->pixel_readbuf +
+ (bmphead_size - sizeof(struct _bmphead)));
+ memset(bmphead, 0, sizeof(struct _bmphead));
+ bmphead->magic = 0x4d42;
+ bmphead->fullsize = sizeof(struct _bmphead) + datasize;
+ bmphead->offset = 54;
+ bmphead->headsize = 40;
+ bmphead->width = width;
+ bmphead->height = height;
+ bmphead->planes = 1;
+ bmphead->bitperpixel = bitperpixel;
+ bmphead->compress = 0;
+ bmphead->datasize = datasize;
+ bmphead->xp = 100000;
+ bmphead->yp = 100000;
+
+ /* invert Y */
+ linesize = width * bitperpixel / 8;
+ sp = wkbuf;
+ dp = _ico_win_mgr->pixel_readbuf + bmphead_size + (linesize * (height-1));
+ for (pathlen = 0; pathlen < height; pathlen++) {
+ memcpy(dp, sp, linesize);
+ sp += linesize;
+ dp -= linesize;
+ }
+ free(wkbuf);
+
+ if (write(fd, bmphead, sizeof(struct _bmphead) + datasize) < 0) {
+ uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)",
+ filename, errno);
+ close(fd);
+ if (wkbuf) free(wkbuf);
+ return -1;
+ }
+ }
+ else {
+ /* Binary format */
+ if (write(fd, _ico_win_mgr->pixel_readbuf + bmphead_size, datasize) < 0) {
+ uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)",
+ filename, errno);
+ close(fd);
+ return -1;
+ }
+ }
+ close(fd);
+
+ uifw_trace("win_mgr_takeSurfaceScreenshot: Leave");
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/**
* @brief bind_ico_win_mgr: bind Multi Window Manager from client
*
* @param[in] client client
if (weston_layout_setNotificationRemoveSurface(ico_ivi_surfaceRemoveNotification, NULL) != 0) {
uifw_error("ico_window_mgr: weston_layout_setNotificationRemoveSurface Error");
}
- if (weston_layout_setNotificationConfigureSurface(ico_ivi_surfaceConfigureNotification, NULL) != 0) {
- uifw_error("ico_window_mgr: weston_layout_setNotificationConfigureSurface Error");
- }
uifw_info("ico_window_mgr: Leave(module_init)");
return 0;
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include <linux/joystick.h>
-#include "test-common.h"
#define DEV_TOUCH 0
#define DEV_JS 1
static int mDebug = 0;
static int mRun = 1;
static int mTouch = 1;
+static int mWidth = 1080;
+static int mHeight = 1920;
+static int mConvert = 0;
+
+static void print_log(const char *fmt, ...);
static void
term_signal(const int signo)
}
memset(&uinputDevice, 0, sizeof(uinputDevice));
- strcpy(uinputDevice.name, device);
- uinputDevice.absmax[ABS_X] = 1920;
- uinputDevice.absmax[ABS_Y] = 1080;
+ strncpy(uinputDevice.name, device, UINPUT_MAX_NAME_SIZE-1);
+ uinputDevice.absmax[ABS_X] = mHeight;
+ uinputDevice.absmax[ABS_Y] = mWidth;
/* uinput device configuration */
if (write(uifd, &uinputDevice, sizeof(uinputDevice)) < (int)sizeof(uinputDevice)) {
close(fd);
print_log("%d.event device(%s) is %s", ii+1, devFile, devName);
}
+ usleep(200*1000);
}
static int
gettimeofday(&event.time, NULL);
if (event_key[key].type == SPECIALTYPE_XY) {
event.type = EV_ABS;
- event.code = ABS_X;
+ if (mConvert) event.code = ABS_Y;
+ else event.code = ABS_X;
event.value = convert_value(value, &errp, 0);
if (mDebug) {
- print_log("Send Event ABS_X=%d\t# %d.%03d", event.value,
+ print_log("Send Event ABS_%c=%d\t# %d.%03d", mConvert ? 'Y' : 'X',
+ event.value,
(int)event.time.tv_sec, (int)(event.time.tv_usec/1000));
fflush(stderr);
}
fflush(stderr);
return;
}
- event.code = ABS_Y;
+ if (mConvert) event.code = ABS_X;
+ else event.code = ABS_Y;
if (*errp == ',') {
event.value = convert_value(errp + 1, (char **)0, 0);
}
else {
event.value = 0;
}
+ if (mConvert) {
+ event.value = mHeight - event.value - 1;
+ }
event.time.tv_usec += 200;
if (event.time.tv_usec >= 1000000) {
event.time.tv_sec ++;
event.time.tv_usec -= 1000000;
}
if (mDebug) {
- print_log("Send Event ABS_Y=%d\t# %d.%03d", event.value,
+ print_log("Send Event ABS_%c=%d\t# %d.%03d", mConvert ? 'X' : 'Y',
+ event.value,
(int)event.time.tv_sec, (int)(event.time.tv_usec/1000));
fflush(stderr);
}
}
else {
event.code = event_key[key].code;
- event.value = convert_value(value, (char **)0, 0);
+ if (value[0] == 0) {
+ event.value = event_key[key].value;
+ }
+ else {
+ event.value = convert_value(value, (char **)0, 0);
+ }
}
if (mDebug) {
if ((event.type == EV_ABS) && (event.code == ABS_X)) {
(int)event.time.tv_sec, (int)(event.time.tv_usec/1000));
}
else if ((event.type == EV_KEY) &&
+ (event.code == BTN_TOUCH) && (event.value == 1)) {
+ print_log("Send Event BTN_TOUCH=Down\t# %d.%03d",
+ (int)event.time.tv_sec, (int)(event.time.tv_usec/1000));
+ }
+ else if ((event.type == EV_KEY) &&
+ (event.code == BTN_TOUCH) && (event.value == 0)) {
+ print_log("Send Event BTN_TOUCH=Up\t# %d.%03d",
+ (int)event.time.tv_sec, (int)(event.time.tv_usec/1000));
+ }
+ else if ((event.type == EV_KEY) &&
(event.code == BTN_LEFT) && (event.value == 1)) {
print_log("Send Event BTN_LEFT=Down\t# %d.%03d",
(int)event.time.tv_sec, (int)(event.time.tv_usec/1000));
}
}
+void
+print_log(const char *fmt, ...)
+{
+ va_list ap;
+ char log[128];
+ struct timeval NowTime;
+ extern long timezone;
+ static int sTimeZone = (99*60*60);
+
+ va_start(ap, fmt);
+ vsnprintf(log, sizeof(log)-2, fmt, ap);
+ va_end(ap);
+
+ gettimeofday( &NowTime, (struct timezone *)0 );
+ if( sTimeZone > (24*60*60) ) {
+ tzset();
+ sTimeZone = timezone;
+ }
+ NowTime.tv_sec -= sTimeZone;
+ fprintf(stderr, "[%02d:%02d:%02d.%03d@%d] %s\n", (int)((NowTime.tv_sec/3600) % 24),
+ (int)((NowTime.tv_sec/60) % 60), (int)(NowTime.tv_sec % 60),
+ (int)NowTime.tv_usec/1000, getpid(), log);
+}
+
static void
usage(const char *prog)
{
- fprintf(stderr, "Usage: %s [-device=device] [{-m/-t/-j}] [-mq[=key]] "
- "[-d] [event=value] [event=value] ...\n", prog);
+ fprintf(stderr, "Usage: %s [-device=device] [-w=w] [-h=h] [-c] [{-m/-t/-j/-J}] "
+ "[-mq[=key]] [-d] [event[=value]] [event[=value]] ...\n", prog);
exit(0);
}
char buf[240];
j = 0;
+ mWidth = 1080;
+ mHeight = 1920;
strcpy(buf, "ico_test_device");
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
if (strncasecmp(argv[i], "-device=", 8) == 0) {
strcpy(buf, &argv[i][8]);
}
+ else if (strncasecmp(argv[i], "-w=", 3) == 0) {
+ mWidth = strtol(&argv[i][3], (char **)0, 0);
+ }
+ else if (strncasecmp(argv[i], "-h=", 3) == 0) {
+ mHeight = strtol(&argv[i][3], (char **)0, 0);
+ }
+ else if (strcasecmp(argv[i], "-c") == 0) {
+ mConvert = 1; /* Convert logical to physical */
+ }
else if (strcasecmp(argv[i], "-m") == 0) {
mTouch = 1; /* Simulate mouse */
}
memset(&mqbuf, 0, sizeof(mqbuf));
if (msgrcv(mqid, &mqbuf, sizeof(mqbuf)-sizeof(long), 0, 0) < 0) {
if (errno == EINTR) continue;
- print_log("test-send_event: mq(%d) receive error[%d]",
+ print_log("ico_send_inputevent: mq(%d) receive error[%d]",
mqkey, errno);
fflush(stderr);
break;
send_event(argv[i]);
}
}
+ usleep(300*1000);
exit(0);
}