Example #1
0
EGLBoolean
init_haiku(_EGLDriver *drv, _EGLDisplay *dpy)
{
	_eglLog(_EGL_DEBUG,"\nInitializing Haiku EGL\n");
	//_EGLDisplay* egl_dpy;

	printf("Initializing Haiku EGL\n");
	_eglSetLogProc(haiku_log);

	loader_set_logger(_eglLog);

	/*egl_dpy = (_EGLDisplay*) calloc(1, sizeof(_EGLDisplay));
	if (!egl_dpy)
		return _eglError(EGL_BAD_ALLOC, "eglInitialize");

	dpy->DriverData=(void*) egl_dpy;
	if (!dpy->PlatformDisplay) {
		// OPEN DEVICE 
		//dri2_dpy->bwindow = (void*)haiku_create_window();
		//dri2_dpy->own_device = true;
	} else {
		//dri2_dpy->bwindow = (BWindow*)dpy->PlatformDisplay;
	}*/
	
	//dri2_dpy->driver_name = strdup("swrast");
	//if (!dri2_load_driver_swrast(dpy))
	//   goto cleanup_conn;

	/*dri2_dpy->swrast_loader_extension.base.name = __DRI_SWRAST_LOADER;
	dri2_dpy->swrast_loader_extension.base.version = __DRI_SWRAST_LOADER_VERSION;
	dri2_dpy->swrast_loader_extension.getDrawableInfo = swrastGetDrawableInfo;
	dri2_dpy->swrast_loader_extension.putImage = swrastPutImage;
	dri2_dpy->swrast_loader_extension.getImage = swrastGetImage;

	dri2_dpy->extensions[0] = &dri2_dpy->swrast_loader_extension.base;
	dri2_dpy->extensions[1] = NULL;
	dri2_dpy->extensions[2] = NULL;*/

	/*if (dri2_dpy->bwindow) {
		if (!dri2_haiku_add_configs_for_visuals(dri2_dpy, dpy))
			goto cleanup_configs;
	}*/
	_eglLog(_EGL_DEBUG,"Add configs");
    haiku_add_configs_for_visuals(dpy);

	dpy->VersionMajor=1;
	dpy->VersionMinor=4;
   
   //dpy->Extensions.KHR_create_context = true;

	//dri2_dpy->vtbl = &dri2_haiku_display_vtbl;
	_eglLog(_EGL_DEBUG, "Initialization finished");

	return EGL_TRUE;
}
EGLBoolean
dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
{
   struct dri2_egl_display *dri2_dpy;
   const char *err;

   _eglSetLogProc(droid_log);

   dri2_dpy = calloc(1, sizeof(*dri2_dpy));
   if (!dri2_dpy)
      return _eglError(EGL_BAD_ALLOC, "eglInitialize");

   dpy->DriverData = (void *) dri2_dpy;

   dri2_dpy->fd = droid_open_device();
   if (dri2_dpy->fd < 0) {
      err = "DRI2: failed to open device";
      goto cleanup_display;
   }

   dri2_dpy->driver_name = (char *) droid_get_driver_name(dri2_dpy->fd);
   if (dri2_dpy->driver_name == NULL) {
      err = "DRI2: failed to get driver name";
      goto cleanup_device;
   }

   if (!dri2_load_driver(dpy)) {
      err = "DRI2: failed to load driver";
      goto cleanup_device;
   }

   dri2_dpy->dri2_loader_extension.base.name = __DRI_DRI2_LOADER;
   dri2_dpy->dri2_loader_extension.base.version = 3;
   dri2_dpy->dri2_loader_extension.getBuffers = NULL;
   dri2_dpy->dri2_loader_extension.flushFrontBuffer = droid_flush_front_buffer;
   dri2_dpy->dri2_loader_extension.getBuffersWithFormat =
      droid_get_buffers_with_format;

   dri2_dpy->extensions[0] = &dri2_dpy->dri2_loader_extension.base;
   dri2_dpy->extensions[1] = &image_lookup_extension.base;
   dri2_dpy->extensions[2] = &use_invalidate.base;
   dri2_dpy->extensions[3] = NULL;

   if (!dri2_create_screen(dpy)) {
      err = "DRI2: failed to create screen";
      goto cleanup_driver;
   }

   if (!droid_add_configs_for_visuals(drv, dpy)) {
      err = "DRI2: failed to add configs";
      goto cleanup_screen;
   }

   dpy->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
   dpy->Extensions.KHR_image_base = EGL_TRUE;

   /* we're supporting EGL 1.4 */
   dpy->VersionMajor = 1;
   dpy->VersionMinor = 4;

   droid_init_driver_functions(drv);

   return EGL_TRUE;

cleanup_screen:
   dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen);
cleanup_driver:
   dlclose(dri2_dpy->driver);
cleanup_device:
   close(dri2_dpy->fd);
cleanup_display:
   free(dri2_dpy);

   return _eglError(EGL_NOT_INITIALIZED, err);
}
Example #3
0
EGLBoolean
dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
{
   struct dri2_egl_display *dri2_dpy;
   const char *err;

   _eglSetLogProc(droid_log);

   loader_set_logger(_eglLog);

   dri2_dpy = calloc(1, sizeof(*dri2_dpy));
   if (!dri2_dpy)
      return _eglError(EGL_BAD_ALLOC, "eglInitialize");

   dpy->DriverData = (void *) dri2_dpy;

   dri2_dpy->fd = droid_open_device();
   if (dri2_dpy->fd < 0) {
      err = "DRI2: failed to open device";
      goto cleanup_display;
   }

   dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd, 0);
   if (dri2_dpy->driver_name == NULL) {
      err = "DRI2: failed to get driver name";
      goto cleanup_device;
   }

   if (!dri2_load_driver(dpy)) {
      err = "DRI2: failed to load driver";
      goto cleanup_driver_name;
   }

   dri2_dpy->is_render_node = drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER;

   /* render nodes cannot use Gem names, and thus do not support
    * the __DRI_DRI2_LOADER extension */
   if (!dri2_dpy->is_render_node) {
      dri2_dpy->dri2_loader_extension.base.name = __DRI_DRI2_LOADER;
      dri2_dpy->dri2_loader_extension.base.version = 3;
      dri2_dpy->dri2_loader_extension.getBuffers = NULL;
      dri2_dpy->dri2_loader_extension.flushFrontBuffer = droid_flush_front_buffer;
      dri2_dpy->dri2_loader_extension.getBuffersWithFormat =
        droid_get_buffers_with_format;
      dri2_dpy->extensions[0] = &dri2_dpy->dri2_loader_extension.base;
   } else {
      dri2_dpy->extensions[0] = &droid_image_loader_extension.base;
   }
   dri2_dpy->extensions[1] = &use_invalidate.base;
   dri2_dpy->extensions[2] = &image_lookup_extension.base;
   dri2_dpy->extensions[3] = NULL;


   if (!dri2_create_screen(dpy)) {
      err = "DRI2: failed to create screen";
      goto cleanup_driver;
   }

   if (!droid_add_configs_for_visuals(drv, dpy)) {
      err = "DRI2: failed to add configs";
      goto cleanup_screen;
   }

   dpy->Extensions.ANDROID_framebuffer_target = EGL_TRUE;
   dpy->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
   dpy->Extensions.ANDROID_recordable = EGL_TRUE;
   dpy->Extensions.KHR_image_base = EGL_TRUE;

   /* Fill vtbl last to prevent accidentally calling virtual function during
    * initialization.
    */
   dri2_dpy->vtbl = &droid_display_vtbl;

   return EGL_TRUE;

cleanup_screen:
   dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen);
cleanup_driver:
   dlclose(dri2_dpy->driver);
cleanup_driver_name:
   free(dri2_dpy->driver_name);
cleanup_device:
   close(dri2_dpy->fd);
cleanup_display:
   free(dri2_dpy);

   return _eglError(EGL_NOT_INITIALIZED, err);
}