Esempio n. 1
0
static void
win_resize_cb(void *data, Evas *e , Evas_Object *obj , void *event_info)
{
	appdata_s *ad = data;

	if(ad->evas_gl_surface)
	{
		cairo_surface_destroy(ad->surface);
		cairo_destroy(ad->cairo);
		cairo_device_destroy(ad->cairo_device);
		evas_gl_surface_destroy(ad->evas_gl, ad->evas_gl_surface);
		ad->evas_gl_surface = NULL;
	}

	evas_object_geometry_get(obj, NULL, NULL, &ad->width, &ad->height);
	evas_object_image_size_set(ad->img, ad->width, ad->height);
	evas_object_resize(ad->img, ad->width, ad->height);
	evas_object_show(ad->img);

	if(!ad->evas_gl_surface)
	{
		Evas_Native_Surface ns;
		ad->evas_gl_surface = evas_gl_surface_create(ad->evas_gl, ad->evas_gl_config, ad->width, ad->height);
		evas_gl_native_surface_get(ad->evas_gl, ad->evas_gl_surface, &ns);
		evas_object_image_native_surface_set(ad->img, &ns);
		evas_object_image_pixels_dirty_set (ad->img, EINA_TRUE);

		ad->cairo_device = (cairo_device_t *)cairo_evas_gl_device_create (ad->evas_gl, ad->evas_gl_context);
		cairo_gl_device_set_thread_aware(ad->cairo_device, 0);
		ad->surface = (cairo_surface_t *)cairo_gl_surface_create_for_evas_gl(ad->cairo_device, ad->evas_gl_surface, ad->evas_gl_config, ad->width, ad->height);
		ad->cairo = cairo_create (ad->surface);
	}
}
Esempio n. 2
0
static void
cairo_evasgl_drawing(appdata_s *ad)
{
	/* Window */
	elm_config_accel_preference_set("opengl");
	ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
	elm_win_autodel_set(ad->win, EINA_TRUE);
	if (elm_win_wm_rotation_supported_get(ad->win))
	{
		int rots[4] = { 0, 90, 180, 270 };
		elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
	}
	evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
	eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
	evas_object_event_callback_add(ad->win, EVAS_CALLBACK_RESIZE, win_resize_cb, ad);
	evas_object_show(ad->win);

	/* Image */
	ad->img = evas_object_image_filled_add(evas_object_evas_get(ad->win));
	evas_object_show(ad->img);

	evas_object_geometry_get(ad->win, NULL, NULL, &ad->width, &ad->height);

	/* Init EVASGL */
	Evas_Native_Surface ns;
	ad->evas_gl = evas_gl_new(evas_object_evas_get(ad->img));
	ad->evas_gl_config = evas_gl_config_new();
	ad->evas_gl_config->color_format = EVAS_GL_RGBA_8888;
	ad->evas_gl_surface = evas_gl_surface_create(ad->evas_gl, ad->evas_gl_config, ad->width, ad->height);
	ad->evas_gl_context = evas_gl_context_create(ad->evas_gl, NULL);
	evas_gl_native_surface_get(ad->evas_gl, ad->evas_gl_surface, &ns);
	evas_object_image_native_surface_set(ad->img, &ns);
	evas_object_image_pixels_get_callback_set(ad->img, cairo_drawing_rt, ad);

	/* cairo & cairo device create with evasgl */
	setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
	ad->cairo_device = (cairo_device_t *)cairo_evas_gl_device_create (ad->evas_gl, ad->evas_gl_context);
	cairo_gl_device_set_thread_aware(ad->cairo_device, 0);
	ad->surface = (cairo_surface_t *)cairo_gl_surface_create_for_evas_gl(ad->cairo_device, ad->evas_gl_surface, ad->evas_gl_config, ad->width, ad->height);
	ad->cairo = cairo_create (ad->surface);
}
bool GraphicsContext3DPrivate::createSurface(PageClientEfl* pageClient, bool renderDirectlyToHostWindow)
{
    // If RenderStyle is RenderOffscreen, we will be rendering to a FBO,
    // so Evas_GL_Surface has a 1x1 dummy surface.
    int width = 1;
    int height = 1;

    // But, in case of RenderDirectlyToHostWindow, we have to render to a render target surface with the same size as our webView.
    if (renderDirectlyToHostWindow) {
        if (!pageClient)
            return false;
        // FIXME: Get geometry of webView and set size of target surface.
    }

    Evas_GL_Config config = {
        EVAS_GL_RGBA_8888,
        EVAS_GL_DEPTH_BIT_8,
        EVAS_GL_STENCIL_NONE, // FIXME: set EVAS_GL_STENCIL_BIT_8 after fixing Evas_GL bug.
        EVAS_GL_OPTIONS_NONE
    };

    // Create a new Evas_GL_Surface object
    m_evasGLSurface = evas_gl_surface_create(m_evasGL, &config, width, height);
    if (!m_evasGLSurface)
        return false;

#if USE(ACCELERATED_COMPOSITING)
    if (renderDirectlyToHostWindow) {
        Evas_Native_Surface nativeSurface;
        // Fill in the Native Surface information from the given Evas GL surface.
        evas_gl_native_surface_get(m_evasGL, m_evasGLSurface, &nativeSurface);

        // FIXME: Create and specially set up a evas_object which act as the render targer surface.
    }
#endif

    return true;
}