Exemplo n.º 1
0
static void
flush_head (ply_renderer_backend_t *backend,
            ply_renderer_head_t    *head)
{
  ply_region_t *updated_region;
  ply_list_t *areas_to_flush;
  ply_list_node_t *node;
  ply_pixel_buffer_t *pixel_buffer;
  char *map_address;

  assert (backend != NULL);

  if (!backend->is_active)
    return;

  ply_terminal_set_mode (backend->terminal, PLY_TERMINAL_MODE_GRAPHICS);
  ply_terminal_set_unbuffered_input (backend->terminal);
  pixel_buffer = head->pixel_buffer;
  updated_region = ply_pixel_buffer_get_updated_areas (pixel_buffer);
  areas_to_flush = ply_region_get_sorted_rectangle_list (updated_region);

  map_address =
    backend->driver_interface->begin_flush (backend->driver,
                                            head->scan_out_buffer_id);

  node = ply_list_get_first_node (areas_to_flush);
  while (node != NULL)
    {
      ply_list_node_t *next_node;
      ply_rectangle_t *area_to_flush;

      area_to_flush = (ply_rectangle_t *) ply_list_node_get_data (node);

      next_node = ply_list_get_next_node (areas_to_flush, node);

      if (reset_scan_out_buffer_if_needed (backend, head))
        ply_trace ("Needed to reset scan out buffer on %ldx%ld renderer head",
                   head->area.width, head->area.height);

      ply_renderer_head_flush_area (head, area_to_flush, map_address);

      node = next_node;
    }

  backend->driver_interface->end_flush (backend->driver,
                                        head->scan_out_buffer_id);

  ply_region_clear (updated_region);
}
Exemplo n.º 2
0
static ply_terminal_open_result_t
ply_terminal_open_device (ply_terminal_t *terminal)
{
    assert (terminal != NULL);
    assert (terminal->name != NULL);
    assert (terminal->fd < 0);
    assert (terminal->fd_watch == NULL);

    terminal->fd = open (terminal->name, O_RDWR | O_NOCTTY | O_NONBLOCK);

    if (terminal->fd < 0) {
        ply_trace ("Unable to open terminal device '%s': %m", terminal->name);

        /* The kernel will apparently return EIO spurriously when opening a tty that's
         * in the process of closing down.  There's more information here:
         *
         * https://bugs.launchpad.net/ubuntu/+source/linux/+bug/554172/comments/245
         *
         * Work around it here.
         */
        if (errno == EIO)
            return PLY_TERMINAL_OPEN_RESULT_INCOMPLETE;

        terminal->number_of_reopen_tries = 0;
        return PLY_TERMINAL_OPEN_RESULT_FAILURE;
    }

    ply_set_fd_as_blocking (terminal->fd);

    terminal->fd_watch = ply_event_loop_watch_fd (terminal->loop, terminal->fd,
                         PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
                         (ply_event_handler_t) on_tty_input,
                         (ply_event_handler_t) on_tty_disconnected,
                         terminal);

    ply_terminal_check_for_vt (terminal);

    if (!ply_terminal_set_unbuffered_input (terminal))
        ply_trace ("terminal '%s' will be line buffered", terminal->name);

    terminal->number_of_reopen_tries = 0;
    return PLY_TERMINAL_OPEN_RESULT_SUCCESS;
}