static void _surface_context_list_print();
static void _internal_resources_destroy(void *eng_data, EVGL_Resource *rsc);
+// FIXME: This is a hidden option for Webkit-EFL on Tizen.
+// They were setting env vars, which have a global impact on the whole application,
+// including other Evas GL surfaces. Instead, they should request the DR and
+// memory option only on a per-surface basis.
+#define EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE 0x1000
+#define EVAS_GL_OPTIONS_DIRECT_OVERRIDE 0x2000
+
//---------------------------------------------------------------//
// Internal Resources:
sfc->w = w;
sfc->h = h;
+ // Check for Direct rendering override env var.
+ if (!evgl_engine->direct_override)
+ if ((s = getenv("EVAS_GL_DIRECT_OVERRIDE")))
+ {
+ WRN("DIRECT_OVERRIDE flag is set to '%s' for the whole application. "
+ "This should never be done except for debugging purposes.", s);
+ direct_override = atoi(s);
+ if (direct_override == 1)
+ evgl_engine->direct_override = 1;
+ else
+ evgl_engine->direct_override = -1;
+ }
+
+ // Check if Direct Rendering Memory Optimzation flag is on
+ // Creates resources on demand when it fallsback to fbo rendering
+ if (!evgl_engine->direct_mem_opt)
+ if ((s = getenv("EVAS_GL_DIRECT_MEM_OPT")))
+ {
+ WRN("DIRECT_MEMORY_OPTIMIZE flag is set to '%s' for the whole application. "
+ "This should never be done except for debugging purposes.", s);
+ direct_mem_opt = atoi(s);
+ if (direct_mem_opt == 1)
+ evgl_engine->direct_mem_opt = 1;
+ else
+ evgl_engine->direct_mem_opt = -1;
+ }
+
// Set the internal config value
if (!_internal_config_set(sfc, cfg))
{
goto error;
}
+ // Extra options allowed only if DR is set
+ if (sfc->direct_fb_opt)
+ {
+ if (cfg->options_bits & EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE)
+ {
+ DBG("Setting DIRECT_MEMORY_OPTIMIZE bit");
+ sfc->direct_mem_opt = EINA_TRUE;
+ }
+ else if (evgl_engine->direct_mem_opt == 1)
+ sfc->direct_mem_opt = EINA_TRUE;
+
+ if (cfg->options_bits & EVAS_GL_OPTIONS_DIRECT_OVERRIDE)
+ {
+ DBG("Setting DIRECT_OVERRIDE bit");
+ sfc->direct_override = EINA_TRUE;
+ }
+ else if (evgl_engine->direct_override == 1)
+ sfc->direct_override = EINA_TRUE;
+ }
+
// Set the context current with resource context/surface
if (!_internal_resource_make_current(eng_data, NULL))
{
};
// Allocate resources for fallback unless the flag is on
- if (!evgl_engine->direct_mem_opt)
+ if (!sfc->direct_mem_opt)
{
if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 0))
{
evgl_engine->surfaces = eina_list_prepend(evgl_engine->surfaces, sfc);
if (sfc->direct_fb_opt)
- evgl_engine->direct_surfaces = eina_list_prepend(evgl_engine->direct_surfaces, sfc);
+ {
+ eina_hash_add(evgl_engine->direct_surfaces, &sfc->color_buf, sfc);
+ DBG("Added tex %d as direct surface: %p", sfc->color_buf, sfc);
+ }
if (sfc->direct_fb_opt &&
(sfc->depth_fmt || sfc->stencil_fmt || sfc->depth_stencil_fmt))
goto error;
}
+ // What is DR for PBuffer?
+ /*
+ if (sfc->direct_fb_opt)
+ {
+ if (cfg->options_bits & EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE)
+ sfc->direct_mem_opt = EINA_TRUE;
+ if (cfg->options_bits & EVAS_GL_OPTIONS_DIRECT_OVERRIDE)
+ sfc->direct_override = EINA_TRUE;
+ }
+ */
+
// Create internal buffers
if (!_surface_buffers_create(sfc))
{
};
// Allocate resources for fallback unless the flag is on
- if (!evgl_engine->direct_mem_opt)
+ if (!sfc->direct_mem_opt)
{
if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 0))
{
evgl_engine->surfaces = eina_list_remove(evgl_engine->surfaces, sfc);
if (sfc->direct_fb_opt)
- evgl_engine->direct_surfaces = eina_list_remove(evgl_engine->direct_surfaces, sfc);
+ {
+ eina_hash_del(evgl_engine->direct_surfaces, &texid, sfc);
+ DBG("Removed tex %d from the direct surface: %p", texid, sfc);
+ }
+
if (sfc->direct_fb_opt &&
(sfc->depth_fmt || sfc->stencil_fmt || sfc->depth_stencil_fmt))
{
// Allocate or free resources depending on what mode (direct of fbo) it's
// running only if the env var EVAS_GL_DIRECT_MEM_OPT is set.
- if (evgl_engine->direct_mem_opt)
+ if (sfc->direct_mem_opt)
{
if (_evgl_direct_renderable(rsc, sfc))
{
if ((ctx->current_sfc != sfc) || (ctx != sfc->current_ctx))
{
sfc->current_ctx = ctx;
- if ((evgl_engine->direct_mem_opt) && (evgl_engine->direct_override))
+ if ((sfc->direct_mem_opt) && (sfc->direct_fb_opt))
{
DBG("Not creating fallback surfaces even though it should. Use at OWN discretion!");
}
Eina_Bool
evgl_native_surface_direct_opts_get(Evas_Native_Surface *ns,
Eina_Bool *direct_render,
- Eina_Bool *client_side_rotation)
+ Eina_Bool *client_side_rotation,
+ Eina_Bool *direct_override)
{
EVGL_Surface *sfc;
- Eina_List *l;
if (direct_render) *direct_render = EINA_FALSE;
+ if (direct_override) *direct_override = EINA_FALSE;
if (client_side_rotation) *client_side_rotation = EINA_FALSE;
if (!evgl_engine) return EINA_FALSE;
if (ns->data.opengl.framebuffer_id != 0) return EINA_FALSE;
if (ns->data.opengl.texture_id == 0) return EINA_FALSE;
- EINA_LIST_FOREACH(evgl_engine->direct_surfaces, l, sfc)
+ sfc = eina_hash_find(evgl_engine->direct_surfaces, &ns->data.opengl.texture_id);
+ if (!sfc)
{
- if (ns->data.opengl.texture_id == sfc->color_buf)
- {
- if (direct_render) *direct_render = sfc->direct_fb_opt;
- if (client_side_rotation) *client_side_rotation = sfc->client_side_rotation;
- // Note: Maybe we could promote this sfc in the list?
- return EINA_TRUE;
- }
+ DBG("Native surface %p (color_buf %d) was not found.",
+ ns, ns->data.opengl.texture_id);
+ return EINA_FALSE;
+ }
+
+ if (evgl_engine->api_debug_mode)
+ {
+ DBG("Found native surface: texid:%u DR:%d DORR:%d CSR:%d",
+ ns->data.opengl.texture_id, (int) sfc->direct_fb_opt,
+ (int) sfc->direct_override, (int) sfc->client_side_rotation);
}
+ if (direct_render) *direct_render = sfc->direct_fb_opt;
+ if (direct_override) *direct_override = sfc->direct_override;
+ if (client_side_rotation) *client_side_rotation = sfc->client_side_rotation;
return EINA_TRUE;
}
void
evgl_direct_override_get(int *override, int *force_off)
{
- if (override) *override = evgl_engine->direct_override;
+ (void) override;
+ //if (override) *override = evgl_engine->direct_override;
if (force_off) *force_off = evgl_engine->direct_force_off;
}