static boolean
android_surface_present(struct native_surface *nsurf,
                        const native_present_control *ctrl)
{
   struct android_surface *asurf = android_surface(nsurf);
   struct android_display *adpy = asurf->adpy;
   boolean ret;

   if (ctrl->swap_interval || ctrl->natt != NATIVE_ATTACHMENT_BACK_LEFT)
      return FALSE;

   /* this happens when eglSwapBuffers is called more than once in a row */
   if (!asurf->buf)
      return TRUE;

   /* we always render to color_res first when it exists */
   if (asurf->color_res) {
      copy_resources(&adpy->base, asurf->color_res, asurf->buf_res);
      if (!ctrl->preserve)
         pipe_resource_reference(&asurf->color_res, NULL);
   }
   else if (ctrl->preserve) {
      struct pipe_resource templ;

      memset(&templ, 0, sizeof(templ));
      templ.target = asurf->buf_res->target;
      templ.format = asurf->buf_res->format;
      templ.bind = PIPE_BIND_RENDER_TARGET;
      templ.width0 = asurf->buf_res->width0;
      templ.height0 = asurf->buf_res->height0;
      templ.depth0 = asurf->buf_res->depth0;
      templ.array_size = asurf->buf_res->array_size;

      asurf->color_res =
         adpy->base.screen->resource_create(adpy->base.screen, &templ);
      if (!asurf->color_res)
         return FALSE;

      /* preserve the contents */
      copy_resources(&adpy->base, asurf->buf_res, asurf->color_res);
   }

   return android_surface_swap_buffers(nsurf);
}
Exemple #2
0
static void do_setup(int argc, char *argv[])
{
	if (!tst_test)
		tst_brk(TBROK, "No tests to run");

	if (!tst_test->test && !tst_test->test_all)
		tst_brk(TBROK, "No test function speficied");

	if (tst_test->test && tst_test->test_all)
		tst_brk(TBROK, "You can define either test() or test_all()");

	if (tst_test->test && !tst_test->tcnt)
		tst_brk(TBROK, "Number of tests (tcnt) must not be > 0");

	if (tst_test->test_all && tst_test->tcnt)
		tst_brk(TBROK, "You can't define tcnt for test_all()");

	if (tst_test->needs_root && geteuid() != 0)
		tst_brk(TCONF, "Test needs to be run as root");

	if (tst_test->min_kver)
		check_kver();

	parse_opts(argc, argv);

	setup_ipc();

	if (needs_tmpdir()) {
		tst_tmpdir();
		tmpdir_created = 1;
	}

	if (tst_test->needs_device) {
		tdev.dev = tst_acquire_device(NULL);
		tdev.fs_type = tst_dev_fs_type();

		if (!tdev.dev)
			tst_brk(TCONF, "Failed to acquire device");

		tst_device = &tdev;
	}

	if (tst_test->resource_files)
		copy_resources();

	main_pid = getpid();

	if (tst_test->setup)
		tst_test->setup();

	if (main_pid != getpid())
		tst_brk(TBROK, "Runaway child in setup()!");
}
Exemple #3
0
static void do_setup(int argc, char *argv[])
{
	if (!tst_test)
		tst_brk(TBROK, "No tests to run");

	if (tst_test->tconf_msg)
		tst_brk(TCONF, "%s", tst_test->tconf_msg);

	assert_test_fn();

	tid = get_tid(argv);

	if (tst_test->sample)
		tst_test = tst_timer_test_setup(tst_test);

	parse_opts(argc, argv);

	if (tst_test->needs_root && geteuid() != 0)
		tst_brk(TCONF, "Test needs to be run as root");

	if (tst_test->min_kver)
		check_kver();

	if (tst_test->format_device)
		tst_test->needs_device = 1;

	if (tst_test->mount_device) {
		tst_test->needs_device = 1;
		tst_test->format_device = 1;
	}

	if (tst_test->all_filesystems)
		tst_test->needs_device = 1;

	setup_ipc();

	if (needs_tmpdir() && !tst_tmpdir_created())
		tst_tmpdir();

	if (tst_test->mntpoint)
		SAFE_MKDIR(tst_test->mntpoint, 0777);

	if ((tst_test->needs_rofs || tst_test->mount_device ||
	     tst_test->all_filesystems) && !tst_test->mntpoint) {
		tst_brk(TBROK, "tst_test->mntpoint must be set!");
	}

	if (tst_test->needs_rofs) {
		/* If we failed to mount read-only tmpfs. Fallback to
		 * using a device with empty read-only filesystem.
		 */
		if (mount(NULL, tst_test->mntpoint, "tmpfs", MS_RDONLY, NULL)) {
			tst_res(TINFO | TERRNO, "Can't mount tmpfs read-only"
				" at %s, setting up a device instead\n",
				tst_test->mntpoint);
			tst_test->mount_device = 1;
			tst_test->needs_device = 1;
			tst_test->format_device = 1;
			tst_test->mnt_flags = MS_RDONLY;
		} else {
			mntpoint_mounted = 1;
		}
	}

	if (tst_test->needs_device && !mntpoint_mounted) {
		tdev.dev = tst_acquire_device_(NULL, tst_test->dev_min_size);

		if (!tdev.dev)
			tst_brk(TCONF, "Failed to acquire device");

		tst_device = &tdev;

		if (tst_test->dev_fs_type)
			tdev.fs_type = tst_test->dev_fs_type;
		else
			tdev.fs_type = tst_dev_fs_type();

		if (!tst_test->all_filesystems)
			prepare_device();
	}

	if (tst_test->resource_files)
		copy_resources();
}