示例#1
0
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;
	int ret = 0;

	display = create_display();
	window = create_window(display, 250, 250);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	/* Initialise damage to full surface, so the padding gets painted */
	wl_surface_damage(window->surface, 0, 0,
			  window->width, window->height);

	redraw(window, NULL, 0);

	while (running && ret != -1)
		ret = wl_display_dispatch(display->display);

	fprintf(stderr, "simple-dmabuf exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
示例#2
0
文件: simple-shm.c 项目: Blei/weston
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;

	display = create_display();
	window = create_window(display, 250, 250);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	redraw(window, NULL, 0);

	while (running)
		wl_display_iterate(display->display, display->mask);

	fprintf(stderr, "simple-shm exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;
	int ret = 0;

	display = create_display();
	window = create_window(display, 250, 250);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	/* Here we retrieve the linux-dmabuf objects, or error */
	wl_display_roundtrip(display->display);

	if (!running)
		return 1;

	redraw(window, NULL, 0);

	while (running && ret != -1)
		ret = wl_display_dispatch(display->display);

	fprintf(stderr, "simple-dmabuf exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
void gui_display(int* results)
{
    create_display(0, 0, height, width);
    for (int r = 0; r < world_size; r++)
        for (int i = 0, x = r * job_width; i < job_width; ++i, ++x)
            for (int j = 0; j < height; ++j)
                draw_point(x, j, results[r * data_size + j * job_width + i]);
    flush();
}
示例#5
0
static gboolean
gst_mir_sink_start (GstBaseSink * bsink)
{
    GstMirSink *sink = (GstMirSink *) bsink;

    GST_DEBUG_OBJECT (sink, "start");

    /* If we start playback again after an EOS, make sure we have a new valid
     * SurfaceTextureClientHybris instance to use and pass to the decoder.
     */
    if (!sink->surface_texture_client && sink->texture_id > 0) {
        GST_DEBUG_OBJECT (sink, "Creating new SurfaceTextureClientHybris instance");
        gst_mir_sink_create_surface_texture (G_OBJECT (bsink));
    }
#if 0
    /* If we are using a texture_id, there's no need to use the Ubuntu
     * Platform API to create an EGLNativeWindowType */
    if (sink->texture_id)
        return TRUE;

    /* Create a new Ubuntu Application API session */
    if (sink->session == NULL)
        sink->session = create_session ();

    if (sink->session == NULL) {
        GST_ELEMENT_ERROR (bsink, RESOURCE, OPEN_READ_WRITE,
                           ("Could not initialize Mir output"),
                           ("Could not start a Mir app session"));
        return FALSE;
    }

    if (sink->display == NULL)
        sink->display = create_display ();

    if (sink->display == NULL) {
        GST_ELEMENT_ERROR (bsink, RESOURCE, OPEN_READ_WRITE,
                           ("Could not initialize Mir output"),
                           ("Could not create a Mir display"));
        return FALSE;
    }

    /* Create an EGLNativeWindowType instance so that a pure playbin
     * scenario will render video */
    if (sink->window == NULL) {
        sink->video_width = sink->display->width;
        sink->video_height = sink->display->height;
        GST_DEBUG_OBJECT (sink, "video_width: %d, video_height: %d",
                          sink->video_width, sink->video_height);
        create_window (sink, sink->display, sink->video_width, sink->video_height);
        sink->surface_texture_client =
            surface_texture_client_create (sink->window->egl_native_window);
    }
#endif

    return TRUE;
}
int
main(int argc, char **argv)
{
	GLenum internal_format = 0;

	EGLDisplay dpy;
	EGLContext ctx;
	bool ok;

	/* Strip common piglit args. */
	piglit_strip_arg(&argc, argv, "-fbo");
	piglit_strip_arg(&argc, argv, "-auto");

	if (argc == 2) {
		if (streq(argv[1], "GL_RGBA")) {
			internal_format = GL_RGBA;
		} else if (streq(argv[1], "GL_DEPTH_COMPONENT24")) {
			internal_format = GL_DEPTH_COMPONENT24;
		}
	}

	if (internal_format == 0)
		usage_error();

	dpy = create_display();
	ctx = create_context(dpy);

	ok = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx);
	if (!ok) {
		piglit_loge("failed to make context current without surface");
		piglit_report_result(PIGLIT_FAIL);
	}

	piglit_dispatch_default_init(PIGLIT_DISPATCH_ES2);

	if (!piglit_is_extension_supported("GL_OES_EGL_image")) {
		piglit_loge("context does not support GL_OES_EGL_image");
		piglit_report_result(PIGLIT_SKIP);
	}

	switch (internal_format) {
	case GL_RGBA:
		test_rgba(dpy, ctx);
		break;
	case GL_DEPTH_COMPONENT24:
		test_depth24(dpy, ctx);
		break;
	default:
		break;
	}

	/* unreachable */
	abort();
}
static gboolean gdm_local_display_factory_sync_seats (GdmLocalDisplayFactory *factory)
{
        GError *error = NULL;
        GVariant *result;
        GVariant *array;
        GVariantIter iter;
        const char *seat;

        result = g_dbus_connection_call_sync (factory->priv->connection,
                                              "org.freedesktop.login1",
                                              "/org/freedesktop/login1",
                                              "org.freedesktop.login1.Manager",
                                              "ListSeats",
                                              NULL,
                                              G_VARIANT_TYPE ("(a(so))"),
                                              G_DBUS_CALL_FLAGS_NONE,
                                              -1,
                                              NULL, &error);

        if (!result) {
                g_warning ("GdmLocalDisplayFactory: Failed to issue method call: %s", error->message);
                g_clear_error (&error);
                return FALSE;
        }

        array = g_variant_get_child_value (result, 0);
        g_variant_iter_init (&iter, array);

        while (g_variant_iter_loop (&iter, "(&so)", &seat, NULL)) {
                gboolean is_initial;
                const char *session_type = NULL;

                if (g_strcmp0 (seat, "seat0") == 0) {
                        is_initial = TRUE;
#ifdef ENABLE_WAYLAND_SUPPORT
                        gboolean wayland_enabled = FALSE;
                        if (gdm_settings_direct_get_boolean (GDM_KEY_WAYLAND_ENABLE, &wayland_enabled)) {
                                if (wayland_enabled) {
                                        session_type = "wayland";
                                }
                        }
#endif
                } else {
                        is_initial = FALSE;
                }

                create_display (factory, seat, session_type, is_initial);
        }

        g_variant_unref (result);
        g_variant_unref (array);
        return TRUE;
}
static void
on_seat_new (GDBusConnection *connection,
             const gchar     *sender_name,
             const gchar     *object_path,
             const gchar     *interface_name,
             const gchar     *signal_name,
             GVariant        *parameters,
             gpointer         user_data)
{
        const char *seat;

        g_variant_get (parameters, "(&s&o)", &seat, NULL);
        create_display (GDM_LOCAL_DISPLAY_FACTORY (user_data), seat, NULL, FALSE);
}
示例#9
0
Display *Framework::create_display(Display::resolution_t resolution)
{
   int w, h;
   int screen_flags = ALLEGRO_FLAGS_EMPTY;
   int display_adapter_to_use = 0;

   switch(resolution)
   {
   case Display::RESOLUTION_XGA:
      w = 1024;
      h = 768;
      break;
   case Display::RESOLUTION_WXGA:
      w = 1280;
      h = 800;
      break;
   case Display::RESOLUTION_WXGA_PLUS:
      w = 1440;
      h = 900;
      break;
   case Display::RESOLUTION_HD_1080:
      w = 1920;
      h = 1080;
      break;
   case Display::RESOLUTION_HD_720:
      w = 1280;
      h = 720;
      break;
   case Display::RESOLUTION_RETINA:
      w = 2880;
      h = 1800;
      break;
   case Display::FULLSCREEN_AUTO:
      {
         ALLEGRO_MONITOR_INFO monitor_info;
         al_get_monitor_info(display_adapter_to_use, &monitor_info);
         w = monitor_info.x2 - monitor_info.x1;
         h = monitor_info.y2 - monitor_info.y1;
         screen_flags = ALLEGRO_FULLSCREEN;
      }
      break;
   default:
      w = 1024;
      h = 768;
      break;
   }

   return create_display(w, h, screen_flags, display_adapter_to_use);
}
示例#10
0
int main(void)
{
        struct sigaction   sigint;
        struct my_display *display;
        struct my_window  *window;

        /* Connect to the display */
        printf("Connecting to display\n");
        display = create_display();
        printf("Connected!\n");

        /* Create a window */
        printf("Creating a window\n");
        window = create_window(display, MIN_WIDTH, MIN_HEIGHT);
        if (!window)
                return 1;
        printf("Window created\n");

        /* Set up singal handler. So SIGINT allows us to cleanly die. */
        sigint.sa_handler = signal_int;
        sigemptyset(&sigint.sa_mask);
        sigint.sa_flags = SA_RESETHAND;
        sigaction(SIGINT, &sigint, NULL);

        printf("Initialising buffers\n");
        /* Initialize */
        wl_surface_damage(window->surface, 0, 0, window->width, window->height);
        /* Draw first screen which allocates buffer(s). */
        draw(window, NULL, 0);
       
        printf("Starting loop\n");
        /* Main loop */
        while (running) {
                if (wl_display_dispatch(display->display) == -1) {
                        running = 0;
                }
        }
        printf("Loop exited\n");
        
        /* Destroy the display */
        printf("Destroying window\n");
        destroy_window(window); window = NULL;
        printf("Disconnecting display\n");
        destroy_display(display); display = NULL;
        printf("Done\n");

        return 0;
}
示例#11
0
static int
x_vdisplay_on_append(x_object *so, x_object *parent)
{
  virtual_display_t *mctl = (virtual_display_t *) so;
  ENTER;

  /* push worker to be run in UI thread */
  TRACE("\n");
//  worker_push(&__x_vdisplay_show, (void *) so);
  create_display(_ENV(so,"sid"), so);
  mctl->frameWidth = 320;
  mctl->frameHeight = 240;
  mctl->frameStride = 320;
  EXIT;
  return 0;
}
int main(int argc, char *argv[])
{
	struct display *d;
	int xd = 79;
	int yd = 23;

	d = create_display(xd + 1, yd + 1);

	draw_rectangle(d, 0, 0, xd, yd);
	draw_line(d, 0, 0, xd, yd); 
	draw_line(d, 0, yd, xd, 0); 
	draw_circle(d, xd / 2, yd / 2, yd / 3);
	show_display(d);

	free_display(d);
	return 0;
}
示例#13
0
bool_t create_lessui(lessui_t *ui) {
  bool_t ok = TRUE;
  if( ui ) {
    ok &= create_cursor(&ui->cursor);
    ok &= create_cursormanager(&ui->cmg);
    ok &= create_cursorrep(&ui->cr);
    ok &= create_display(&ui->display);
    if( ok ) {

      /* toggle_display(&ui->display, DISPLAY_WRAP); */
      /* toggle_display(&ui->display, DISPLAY_ATTRIBUTES); */

    }
    return ok;
  }
  return FALSE;
}
示例#14
0
static char * test_cursor_up_top_first_page()
{
    struct display_t *display;
    struct search_t *search;
    int terminal_line_nb;
    char text[] = "this is the first line\nthis the second line\n";
    const char *pattern = "line";

    display = create_display();
    search = create_search();
    terminal_line_nb = 10;

    parse_text(search, "fake_file", strlen(text), text, pattern);
    move_cursor_up(display, search, terminal_line_nb);
    mu_assert("test_cursor_up_top_first_page failed", display->cursor == 1);
    free_search(search);
    free_display(display);

    return 0;
}
示例#15
0
static gboolean
gdm_local_display_factory_start (GdmDisplayFactory *base_factory)
{
        GdmLocalDisplayFactory *factory = GDM_LOCAL_DISPLAY_FACTORY (base_factory);
        GdmDisplay             *display;

        g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);

#ifdef WITH_SYSTEMD
        if (LOGIND_RUNNING()) {
                gdm_local_display_factory_start_monitor (factory);
                return gdm_local_display_factory_sync_seats (factory);
        }
#endif

        /* On ConsoleKit just create Seat1, and that's it. */
        display = create_display (factory, CK_SEAT1_PATH, NULL, TRUE);

        return display != NULL;
}
示例#16
0
static gboolean
gst_wayland_sink_start (GstBaseSink * bsink)
{
  GstWaylandSink *sink = (GstWaylandSink *) bsink;
  gboolean result = TRUE;

  GST_DEBUG_OBJECT (sink, "start");

  if (!sink->display)
    sink->display = create_display ();

  if (sink->display == NULL) {
    GST_ELEMENT_ERROR (bsink, RESOURCE, OPEN_READ_WRITE,
        ("Could not initialise Wayland output"),
        ("Could not create Wayland display"));
    return FALSE;
  }

  return result;
}
示例#17
0
static void
on_display_status_changed (GdmDisplay             *display,
                           GParamSpec             *arg1,
                           GdmLocalDisplayFactory *factory)
{
        int              status;
        GdmDisplayStore *store;
        int              num;
        char            *seat_id = NULL;
        char            *session_type = NULL;
        gboolean         is_initial = TRUE;
        gboolean         is_local = TRUE;

        num = -1;
        gdm_display_get_x11_display_number (display, &num, NULL);

        store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));

        g_object_get (display,
                      "seat-id", &seat_id,
                      "is-initial", &is_initial,
                      "is-local", &is_local,
                      "session-type", &session_type,
                      NULL);

        status = gdm_display_get_status (display);

        g_debug ("GdmLocalDisplayFactory: display status changed: %d", status);
        switch (status) {
        case GDM_DISPLAY_FINISHED:
                /* remove the display number from factory->priv->used_display_numbers
                   so that it may be reused */
                if (num != -1) {
                        g_hash_table_remove (factory->priv->used_display_numbers, GUINT_TO_POINTER (num));
                }
                gdm_display_store_remove (store, display);

                /* Create a new equivalent display if it was static */
                if (is_local) {
                        /* reset num failures */
                        factory->priv->num_failures = 0;

                        create_display (factory, seat_id, session_type, is_initial);
                }
                break;
        case GDM_DISPLAY_FAILED:
                /* leave the display number in factory->priv->used_display_numbers
                   so that it doesn't get reused */
                gdm_display_store_remove (store, display);

                /* Create a new equivalent display if it was static */
                if (is_local) {

                        factory->priv->num_failures++;

                        if (factory->priv->num_failures > MAX_DISPLAY_FAILURES) {
                                /* oh shit */
                                g_warning ("GdmLocalDisplayFactory: maximum number of X display failures reached: check X server log for errors");
                                /* FIXME: should monitor hardware changes to
                                   try again when seats change */
                        } else {
#ifdef ENABLE_WAYLAND_SUPPORT
                                if (g_strcmp0 (session_type, "wayland") == 0) {
                                        g_free (session_type);
                                        session_type = NULL;
                                }

#endif
                                create_display (factory, seat_id, session_type, is_initial);
                        }
                }
                break;
        case GDM_DISPLAY_UNMANAGED:
                break;
        case GDM_DISPLAY_PREPARED:
                break;
        case GDM_DISPLAY_MANAGED:
                break;
        default:
                g_assert_not_reached ();
                break;
        }

        g_free (seat_id);
        g_free (session_type);
}
示例#18
0
Display *Framework::create_display(int width, int height)
{
   return create_display(width, height, false, -1);
}
示例#19
0
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;
	int i, ret = 0;
	int version = -1;
	int width = 300, height = 200, scale = 1;
	enum wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
	enum window_flags flags = 0;

	for (i = 1; i < argc; ++i) {
		if (strcmp(argv[i], "--help") == 0 ||
		    strcmp(argv[i], "-h") == 0) {
			print_usage(0);
		} else if (sscanf(argv[i], "--version=%d", &version) > 0) {
			if (version < 1 || version > 3) {
				fprintf(stderr, "Unsupported wl_surface version: %d\n",
					version);
				return 1;
			}
			continue;
		} else if (strcmp(argv[i], "--verbose") == 0) {
			print_debug = 1;
			continue;
		} else if (sscanf(argv[i], "--width=%d", &width) > 0) {
			continue;
		} else if (sscanf(argv[i], "--height=%d", &height) > 0) {
			continue;
		} else if (strncmp(argv[i], "--transform=", 12) == 0 &&
			   parse_transform(argv[i] + 12, &transform) > 0) {
			continue;
		} else if (strcmp(argv[i], "--rotating-transform") == 0) {
			flags |= WINDOW_FLAG_ROTATING_TRANSFORM;
			continue;
		} else if (sscanf(argv[i], "--scale=%d", &scale) > 0) {
			continue;
		} else if (strcmp(argv[i], "--use-viewport") == 0) {
			flags |= WINDOW_FLAG_USE_VIEWPORT;
			continue;
		} else {
			printf("Invalid option: %s\n", argv[i]);
			print_usage(255);
		}
	}

	display = create_display(version);

	window = create_window(display, width, height, transform, scale, flags);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	redraw(window, NULL, 0);

	while (running && ret != -1)
		ret = wl_display_dispatch(display->display);

	fprintf(stderr, "simple-shm exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
示例#20
0
int PicBuf_to_UIS(const GEN_PAR * pg, const OUT_PAR * po)
{
	int byte_c, xoff, yoff;
	unsigned long row_c, x1, x2, rw, rh, bpp, zero = 0, two = 2;
	const RowBuf *row;
	const PicBuf *pb;

	float x0f, y0f, x1f, y1f, w, h;
	int c_old, c_new, i;
	unsigned vd_id, wd_id;
	char *target = "sys$workstation";
	static float intens[2] = { 1.0, 0.0 };
	static unsigned atb = 1;

	struct dsc$descriptor_s s_desc;

	if (pg == NULL || po == NULL)
		return ERROR;
	pb = po->picbuf;
	if (pb == NULL)
		return ERROR;

	if (pb->depth > 1) {
		Eprintf
		    ("\nUIS preview does not support colors yet -- sorry\n");
		return ERROR;
	}

	if (!pg->quiet) {
		Eprintf("\nUIS preview follows\n");
		Eprintf("Press <return> to end\n");
	}

	xoff = po->xoff * po->dpi_x / 25.4;
	yoff = po->yoff * po->dpi_y / 25.4;

	if ((!pg->quiet) &&
	    (((pb->nb << 3) + xoff > 1024) || (pb->nr + yoff > 1024))) {
		Eprintf("\n\007WARNING: Picture won't fit!\n");
		Eprintf("Current range: (%d..%d) x (%d..%d) pels\n",
			xoff, (pb->nb << 3) + xoff, yoff, pb->nr + yoff);
		Eprintf("Continue anyway (y/n)?: ");
		if (toupper(getchar()) != 'Y')
			return;
	}

	x0f = y0f = 0.0;	/* No offsets yet       */
	x1f = (float) (pb->nb << 3);
	y1f = (float) pb->nr;
	w = (float) po->width / 10.0;	/* VAX needs cm, not mm */
	h = (float) po->height / 10.0;

	vd_id = uis$create_display(&x0f, &y0f, &x1f, &y1f, &w, &h);
	uis$disable_display_list(&vd_id);
	uis$set_intensities(&vd_id, &zero, &two, intens);

	s_desc.dsc$w_length = strlen(target);
	s_desc.dsc$a_pointer = target;
	s_desc.dsc$b_class = DSC$K_CLASS_S;
	s_desc.dsc$b_dtype = DSC$K_DTYPE_T;
	wd_id = uis$create_window(&vd_id, &s_desc);

	x1 = 0;
	x2 = pb->nc;
	rw = pb->nc;
	rh = 1;
	bpp = 1;

	for (row_c = 0; row_c < pb->nr; row_c++) {	/* for all pixel rows */
/**
 ** Unfortunately, we need a bit reversal in each byte here:
 **/
		row = get_RowBuf(pb, row_c);
		if (row == NULL)
			continue;
		for (byte_c = 0; byte_c < pb->nb; byte_c++) {
			c_old = row->buf[byte_c];

			if (c_old == 0)	/* all white        */
				continue;
			if (c_old == 0xff)	/* all black        */
				continue;

			for (i = 0, c_new = 0;;) {
				if (c_old & 1)
					c_new |= 1;
				if (++i == 8)	/* 8 bits, 7 shifts */
					break;
				c_new <<= 1;
				c_old >>= 1;
			}
			row->buf[byte_c] = c_new;
		}

		uisdc$image(&wd_id, &atb, &x1, &row_c, &x2, &row_c,
			    &rw, &rh, &bpp, row->buf);
	}
	getchar();
	uis$delete_display(&vd_id);
	return 0;
}