Beispiel #1
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym, enum wl_keyboard_key_state state,
	    void *data)
{
	struct resizor *resizor = data;
	struct rectangle allocation;

	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
		return;

	window_get_allocation(resizor->window, &allocation);
	resizor->width.current = allocation.width;
	if (spring_done(&resizor->width))
		resizor->width.target = allocation.width;
	resizor->height.current = allocation.height;
	if (spring_done(&resizor->height))
		resizor->height.target = allocation.height;

	switch (sym) {
	case XKB_KEY_Up:
		if (allocation.height < 400)
			break;

		resizor->height.target = allocation.height - 200;
		break;

	case XKB_KEY_Down:
		if (allocation.height > 1000)
			break;

		resizor->height.target = allocation.height + 200;
		break;

	case XKB_KEY_Left:
		if (allocation.width < 400)
			break;

		resizor->width.target = allocation.width - 200;
		break;

	case XKB_KEY_Right:
		if (allocation.width > 1000)
			break;

		resizor->width.target = allocation.width + 200;
		break;

	case XKB_KEY_Escape:
		display_exit(resizor->display);
		break;
	}

	if (!resizor->frame_callback)
		frame_callback(resizor, NULL, 0);
}
Beispiel #2
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym, uint32_t state, void *data)
{
	struct resizor *resizor = data;

	if (state == 0)
		return;

	switch (sym) {
	case XK_Down:
		resizor->height.target = 400;
		frame_callback(resizor, 0);
		break;
	case XK_Up:
		resizor->height.target = 200;
		frame_callback(resizor, 0);
		break;
	}
}
Beispiel #3
0
void destroyr_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	switch (id)
	{
	case TIMER_DESTROYR_DIAL:
		dial_callback(ptr, param);
		break;
	case TIMER_DESTROYR_FRAME:
		frame_callback(ptr, param);
		break;
	default:
		assert_always(FALSE, "Unknown id in destroyr_state::device_timer");
	}
}
Beispiel #4
0
int decode_nal(void * dec, unsigned char const * nal, size_t nalsz)
{
    ISVCDecoder* decoder_ = (ISVCDecoder*)dec;
    uint8_t* data[3];
    SBufferInfo bufInfo;
    memset (data, 0, sizeof (data));
    memset (&bufInfo, 0, sizeof (SBufferInfo));
    if (nalsz <= 0) {
        int32_t iEndOfStreamFlag = 1;
        decoder_->SetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
        nalsz = 0;
        nal = NULL;
    }


    DECODING_STATE rv = decoder_->DecodeFrame2 (nal, (int) nalsz, data, &bufInfo);
    if (rv == 0 && bufInfo.iBufferStatus) {
        EM_ASM_({
            frame_callback($0, $1, $2, $3, $4, $5, $6);
        },
static struct nested_client *
nested_client_create(int width, int height)
{
  static const EGLint context_attribs[] = {
    EGL_CONTEXT_CLIENT_VERSION, 2,
    EGL_NONE
  };

  static const EGLint config_attribs[] = {
    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
    EGL_RED_SIZE, 1,
    EGL_GREEN_SIZE, 1,
    EGL_BLUE_SIZE, 1,
    EGL_ALPHA_SIZE, 1,
    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
    EGL_NONE
  };

  EGLint major, minor, n;
  EGLBoolean ret;

  struct nested_client *client;

  client = malloc(sizeof *client);
  if (client == NULL)
    return NULL;

  client->width  = width;
  client->height = height;

  client->display = wl_display_connect(NULL);

  client->registry = wl_display_get_registry(client->display);
  wl_registry_add_listener(client->registry,
                           &registry_listener, client);

  /* get globals */
  wl_display_roundtrip(client->display);

  client->egl_display = eglGetDisplay(client->display);
  if (client->egl_display == NULL)
    return NULL;

  ret = eglInitialize(client->egl_display, &major, &minor);
  if (!ret)
    return NULL;
  ret = eglBindAPI(EGL_OPENGL_ES_API);
  if (!ret)
    return NULL;

  ret = eglChooseConfig(client->egl_display, config_attribs,
                        &client->egl_config, 1, &n);
  if (!ret || n != 1)
    return NULL;

  client->egl_context = eglCreateContext(client->egl_display,
                                         client->egl_config,
                                         EGL_NO_CONTEXT,
                                         context_attribs);
  if (!client->egl_context)
    return NULL;

  client->surface = wl_compositor_create_surface(client->compositor);

  client->native = wl_egl_window_create(client->surface,
                                        client->width, client->height);


  client->egl_surface =
    eglCreateWindowSurface(client->egl_display,
                           client->egl_config,
                           client->native, NULL);

  eglMakeCurrent(client->egl_display, client->egl_surface,
                 client->egl_surface, client->egl_context);

  wl_egl_window_resize(client->native,
                       client->width, client->height, 0, 0);

  frame_callback(client, NULL, 0);

  return client;
}