if (!ctx)
{
- CRIT("\e[1;33m%s\e[m: Current Context NOT SET: GL Call Should NOT Be Called without MakeCurrent!!!", api);
+ CRIT("\e[1;33m%s\e[m: Current Context NOT SET: GL Call Should NOT Be Called without MakeCurrent!!!", api);
}
}
// returns: objc[4] (nc[4]) tranformed (x, y, width, heigth) in gl coord
// returns: cc[4] cliped coordinate in original coordinate
static void
-compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
+compute_gl_coordinates(int win_w, int win_h, int rot, int clip_image,
int x, int y, int width, int height,
- int clip[4],
+ int img_x, int img_y, int img_w, int img_h,
+ int clip_x, int clip_y, int clip_w, int clip_h,
int imgc[4], int objc[4], int cc[4])
{
- Evas_Object_Protected_Data *pd = eo_data_scope_get(obj, EVAS_OBJ_CLASS);
-
- int obj_x, obj_y, obj_w, obj_h;
- int clip_x, clip_y, clip_w, clip_h;
- int out_w, out_h;
-
- // Original Coordinates
- obj_x = pd->cur->geometry.x;
- obj_y = pd->cur->geometry.y;
- obj_w = pd->cur->geometry.w;
- obj_h = pd->cur->geometry.h;
-
- // Clip Region
- clip_x = clip[0];
- clip_y = clip[1];
- clip_w = clip[2];
- clip_h = clip[3];
-
- // Output Window Size
- out_w = pd->layer->evas->output.w;
- out_h = pd->layer->evas->output.h;
-
-
if (rot == 0)
{
// oringinal image object coordinate in gl coordinate
- imgc[0] = obj_x;
- imgc[1] = out_h - obj_y - obj_h;
- imgc[2] = imgc[0] + obj_w;
- imgc[3] = imgc[1] + obj_h;
+ imgc[0] = img_x;
+ imgc[1] = win_h - img_y - img_h;
+ imgc[2] = imgc[0] + img_w;
+ imgc[3] = imgc[1] + img_h;
// clip coordinates in gl coordinate
cc[0] = clip_x;
- cc[1] = out_h - clip_y - clip_h;
+ cc[1] = win_h - clip_y - clip_h;
cc[2] = cc[0] + clip_w;
cc[3] = cc[1] + clip_h;
else if (rot == 180)
{
// oringinal image object coordinate in gl coordinate
- imgc[0] = out_w - obj_x - obj_w;
- imgc[1] = obj_y;
- imgc[2] = imgc[0] + obj_w;
- imgc[3] = imgc[1] + obj_h;
+ imgc[0] = win_w - img_x - img_w;
+ imgc[1] = img_y;
+ imgc[2] = imgc[0] + img_w;
+ imgc[3] = imgc[1] + img_h;
// clip coordinates in gl coordinate
- cc[0] = out_w - clip_x - clip_w;
+ cc[0] = win_w - clip_x - clip_w;
cc[1] = clip_y;
cc[2] = cc[0] + clip_w;
cc[3] = cc[1] + clip_h;
// transformed (x,y,width,height) in gl coordinate
- objc[0] = imgc[0] + obj_w - x - width;
- objc[1] = imgc[1] + obj_h - y - height;
+ objc[0] = imgc[0] + img_w - x - width;
+ objc[1] = imgc[1] + img_h - y - height;
objc[2] = objc[0] + width;
objc[3] = objc[1] + height;
else if (rot == 90)
{
// oringinal image object coordinate in gl coordinate
- imgc[0] = obj_y;
- imgc[1] = obj_x;
- imgc[2] = imgc[0] + obj_h;
- imgc[3] = imgc[1] + obj_w;
+ imgc[0] = img_y;
+ imgc[1] = img_x;
+ imgc[2] = imgc[0] + img_h;
+ imgc[3] = imgc[1] + img_w;
// clip coordinates in gl coordinate
cc[0] = clip_y;
cc[3] = cc[1] + clip_w;
// transformed (x,y,width,height) in gl coordinate
- objc[0] = imgc[0] + obj_h - y - height;
+ objc[0] = imgc[0] + img_h - y - height;
objc[1] = imgc[1] + x;
objc[2] = objc[0] + height;
objc[3] = objc[1] + width;
else if (rot == 270)
{
// oringinal image object coordinate in gl coordinate
- imgc[0] = out_h - obj_y - obj_h;
- imgc[1] = out_w - obj_x - obj_w;
- imgc[2] = imgc[0] + obj_h;
- imgc[3] = imgc[1] + obj_w;
+ imgc[0] = win_h - img_y - img_h;
+ imgc[1] = win_w - img_x - img_w;
+ imgc[2] = imgc[0] + img_h;
+ imgc[3] = imgc[1] + img_w;
// clip coordinates in gl coordinate
- cc[0] = out_h - clip_y - clip_h;
- cc[1] = out_w - clip_x - clip_w;
+ cc[0] = win_h - clip_y - clip_h;
+ cc[1] = win_w - clip_x - clip_w;
cc[2] = cc[0] + clip_h;
cc[3] = cc[1] + clip_w;
// transformed (x,y,width,height) in gl coordinate
objc[0] = imgc[0] + y;
- objc[1] = imgc[1] + obj_w - x - width;
+ objc[1] = imgc[1] + img_w - x - width;
objc[2] = objc[0] + height;
objc[3] = objc[1] + width;
}
cc[2] = cc[2]-cc[0]; // width
cc[3] = cc[3]-cc[1]; // height
- //DBG( "\e[1;32m Img[%d %d %d %d] Original [%d %d %d %d] Transformed[%d %d %d %d] Clip[%d %d %d %d] Clipped[%d %d %d %d] \e[m", obj_x, obj_y, obj_w, obj_h, imgc[0], imgc[1], imgc[2], imgc[3], objc[0], objc[1], objc[2], objc[3], clip[0], clip[1], clip[2], clip[3], cc[0], cc[1], cc[2], cc[3]);
+ //DBG( "\e[1;32m Img[%d %d %d %d] Original [%d %d %d %d] Transformed[%d %d %d %d] Clip[%d %d %d %d] Clipped[%d %d %d %d] \e[m", img_x, img_y, img_w, img_h, imgc[0], imgc[1], imgc[2], imgc[3], objc[0], objc[1], objc[2], objc[3], clip[0], clip[1], clip[2], clip[3], cc[0], cc[1], cc[2], cc[3]);
}
static void
{
EVGL_Resource *rsc;
EVGL_Context *ctx;
- Evas_Object *img;
- int rot = 0;
int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
int cc[4] = {0,0,0,0};
ctx->direct_scissor = 1;
}
- img = rsc->direct_img_obj;
- rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng);
-
if ((ctx->scissor_updated) && (ctx->scissor_enabled))
{
- compute_gl_coordinates(img, rot, 1,
- ctx->scissor_coord[0],
- ctx->scissor_coord[1],
- ctx->scissor_coord[2],
- ctx->scissor_coord[3],
- rsc->clip, oc, nc, cc);
-
- if (rsc->master_clip)
- {
- RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
- glScissor(nc[0], nc[1], nc[2], nc[3]);
- }
- else
- glScissor(nc[0], nc[1], nc[2], nc[3]);
+ compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
+ rsc->direct.rot, 1,
+ ctx->scissor_coord[0], ctx->scissor_coord[1],
+ ctx->scissor_coord[2], ctx->scissor_coord[3],
+ rsc->direct.img.x, rsc->direct.img.y,
+ rsc->direct.img.w, rsc->direct.img.h,
+ rsc->direct.clip.x, rsc->direct.clip.y,
+ rsc->direct.clip.w, rsc->direct.clip.h,
+ oc, nc, cc);
+
+ RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
+ glScissor(nc[0], nc[1], nc[2], nc[3]);
ctx->direct_scissor = 0;
}
else
{
- compute_gl_coordinates(img, rot, 0, 0, 0, 0, 0, rsc->clip, oc, nc, cc);
-
- if (rsc->master_clip)
- glScissor(cc[0], cc[1], cc[2], cc[3]);
- else
- glScissor(oc[0], oc[1], oc[2], oc[3]);
+ compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
+ rsc->direct.rot, 0,
+ 0, 0, 0, 0,
+ rsc->direct.img.x, rsc->direct.img.y,
+ rsc->direct.img.w, rsc->direct.img.h,
+ rsc->direct.clip.x, rsc->direct.clip.y,
+ rsc->direct.clip.w, rsc->direct.clip.h,
+ oc, nc, cc);
+ glScissor(cc[0], cc[1], cc[2], cc[3]);
}
glClear(mask);
{
EVGL_Resource *rsc;
EVGL_Context *ctx;
- Evas_Object_Protected_Data *img;
if (_evgl_direct_enabled())
{
// Only need to handle it if it's directly rendering to the window
if (!(rsc->current_ctx->current_fbo))
{
- img = eo_data_scope_get(rsc->direct_img_obj, EVAS_OBJ_CLASS);
-
if (pname == GL_SCISSOR_BOX)
{
if (ctx->scissor_updated)
{
params[0] = 0;
params[1] = 0;
- params[2] = (GLint)img->cur->geometry.w;
- params[3] = (GLint)img->cur->geometry.h;
+ params[2] = (GLint)rsc->direct.img.w;
+ params[3] = (GLint)rsc->direct.img.h;
return;
}
}
{
EVGL_Resource *rsc;
EVGL_Context *ctx;
- Evas_Object *img;
- int rot = 0;
int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
int cc[4] = {0,0,0,0};
if (!(rsc->current_ctx->current_fbo))
{
- img = rsc->direct_img_obj;
- rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng);
-
- compute_gl_coordinates(img, rot, 1, x, y, width, height, rsc->clip, oc, nc, cc);
+ compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
+ rsc->direct.rot, 1,
+ x, y, width, height,
+ rsc->direct.img.x, rsc->direct.img.y,
+ rsc->direct.img.w, rsc->direct.img.h,
+ rsc->direct.clip.x, rsc->direct.clip.y,
+ rsc->direct.clip.w, rsc->direct.clip.h,
+ oc, nc, cc);
glReadPixels(nc[0], nc[1], nc[2], nc[3], format, type, pixels);
}
else
{
EVGL_Resource *rsc;
EVGL_Context *ctx;
- Evas_Object *img;
- int rot = 0;
int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
int cc[4] = {0,0,0,0};
glDisable(GL_SCISSOR_TEST);
}
- img = rsc->direct_img_obj;
- rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng);
-
- compute_gl_coordinates(img, rot, 1, x, y, width, height, rsc->clip, oc, nc, cc);
+ compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
+ rsc->direct.rot, 1,
+ x, y, width, height,
+ rsc->direct.img.x, rsc->direct.img.y,
+ rsc->direct.img.w, rsc->direct.img.h,
+ rsc->direct.clip.x, rsc->direct.clip.y,
+ rsc->direct.clip.w, rsc->direct.clip.h,
+ oc, nc, cc);
// Keep a copy of the original coordinates
ctx->scissor_coord[0] = x;
ctx->scissor_coord[2] = width;
ctx->scissor_coord[3] = height;
- if (rsc->master_clip)
- {
- RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
- glScissor(nc[0], nc[1], nc[2], nc[3]);
- }
- else
- glScissor(nc[0], nc[1], nc[2], nc[3]);
+ RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
+ glScissor(nc[0], nc[1], nc[2], nc[3]);
ctx->direct_scissor = 0;
{
EVGL_Resource *rsc;
EVGL_Context *ctx;
- Evas_Object *img;
- int rot = 0;
int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
int cc[4] = {0,0,0,0};
ctx->direct_scissor = 1;
}
- img = rsc->direct_img_obj;
- rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng);
-
if ((ctx->scissor_updated) && (ctx->scissor_enabled))
{
// Recompute the scissor coordinates
- compute_gl_coordinates(img, rot, 1,
- ctx->scissor_coord[0],
- ctx->scissor_coord[1],
- ctx->scissor_coord[2],
- ctx->scissor_coord[3],
- rsc->clip, oc, nc, cc);
-
- if (rsc->master_clip)
- {
- RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
- glScissor(nc[0], nc[1], nc[2], nc[3]);
- }
- else
- glScissor(nc[0], nc[1], nc[2], nc[3]);
+ compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
+ rsc->direct.rot, 1,
+ ctx->scissor_coord[0], ctx->scissor_coord[1],
+ ctx->scissor_coord[2], ctx->scissor_coord[3],
+ rsc->direct.img.x, rsc->direct.img.y,
+ rsc->direct.img.w, rsc->direct.img.h,
+ rsc->direct.clip.x, rsc->direct.clip.y,
+ rsc->direct.clip.w, rsc->direct.clip.h,
+ oc, nc, cc);
+
+ RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
+ glScissor(nc[0], nc[1], nc[2], nc[3]);
ctx->direct_scissor = 0;
// Compute the viewport coordinate
- compute_gl_coordinates(img, rot, 0, x, y, width, height, rsc->clip, oc, nc, cc);
+ compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
+ rsc->direct.rot, 0,
+ x, y, width, height,
+ rsc->direct.img.x, rsc->direct.img.y,
+ rsc->direct.img.w, rsc->direct.img.h,
+ rsc->direct.clip.x, rsc->direct.clip.y,
+ rsc->direct.clip.w, rsc->direct.clip.h,
+ oc, nc, cc);
glViewport(nc[0], nc[1], nc[2], nc[3]);
}
else
{
- compute_gl_coordinates(img, rot, 0, x, y, width, height, rsc->clip, oc, nc, cc);
- if (rsc->master_clip)
- glScissor(cc[0], cc[1], cc[2], cc[3]);
- else
- glScissor(oc[0], oc[1], oc[2], oc[3]);
+
+ compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
+ rsc->direct.rot, 0,
+ x, y, width, height,
+ rsc->direct.img.x, rsc->direct.img.y,
+ rsc->direct.img.w, rsc->direct.img.h,
+ rsc->direct.clip.x, rsc->direct.clip.y,
+ rsc->direct.clip.w, rsc->direct.clip.h,
+ oc, nc, cc);
+ glScissor(cc[0], cc[1], cc[2], cc[3]);
glViewport(nc[0], nc[1], nc[2], nc[3]);
}
_evgld_glShaderSource(GLuint shader, GLsizei count, const char* const * string, const GLint* length)
{
EVGL_FUNC_BEGIN();
-#ifdef GL_GLES
+#ifdef GL_GLES
glShaderSource(shader, count, (const GLchar * const *) string, length);
#else
glShaderSource(shader, count, (const GLchar **) string, length);
finish:
EVGL_FUNC_END();
}
-#endif
+#endif
//-------------------------------------------------------------//
ORD(glGetShaderPrecisionFormat);
ORD(glShaderBinary);
ORD(glReleaseShaderCompiler);
-
+
#undef ORD
evgl_api_ext_get(funcs);
// Set the surface to evas surface if it's there
if (rsc->id == evgl_engine->main_tid)
- rsc->direct_surface = evgl_engine->funcs->evas_surface_get(eng_data);
+ rsc->direct.surface = evgl_engine->funcs->evas_surface_get(eng_data);
- if (rsc->direct_surface)
- surface = (void*)rsc->direct_surface;
+ if (rsc->direct.surface)
+ surface = (void*)rsc->direct.surface;
else
surface = (void*)rsc->surface;
if (evgl_engine->direct_force_off) return 0;
if (rsc->id != evgl_engine->main_tid) return 0;
if (!sfc->direct_fb_opt) return 0;
- if (!rsc->direct_img_obj) return 0;
+ if (!rsc->direct.enabled) return 0;
return 1;
}
(ctx) &&
(ctx->current_sfc) &&
(ctx->current_sfc->direct_fb_opt) &&
- (!rsc->direct_img_obj))
+ (!rsc->direct.enabled))
return 1;
else
return 0;
// Terminate engine and all the resources
// - destroy all internal resources
// - free allocated engine struct
-void
+void
evgl_engine_shutdown(void *eng_data)
{
// Check if engine is valid
glBindFramebuffer(GL_FRAMEBUFFER, 0);
ctx->current_fbo = 0;
}
- rsc->direct_rendered = 1;
+ rsc->direct.rendered = 1;
}
else
{
if (ctx->current_fbo)
glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo);
}
- rsc->direct_rendered = 0;
+ rsc->direct.rendered = 0;
}
ctx->current_sfc = sfc;
if (!(rsc=_evgl_tls_resource_get())) return 0;
- return rsc->direct_rendered;
+ return rsc->direct.rendered;
+}
+
+
+
+void
+evgl_direct_info_set(int win_w, int win_h, int rot, int img_x, int img_y, int img_w, int img_h, int clip_x, int clip_y, int clip_w, int clip_h)
+{
+ EVGL_Resource *rsc;
+
+ if (!(rsc=_evgl_tls_resource_get())) return;
+
+ // Normally direct rendering isn't allowed if alpha is on and
+ // rotation is not 0. BUT, if override is on, allow it.
+ if ( (rot==0) ||
+ ((rot!=0) && (evgl_engine->direct_override)) )
+ {
+ rsc->direct.enabled = EINA_TRUE;
+
+ rsc->direct.win_w = win_w;
+ rsc->direct.win_h = win_h;
+ rsc->direct.rot = rot;
+
+ rsc->direct.img.x = img_x;
+ rsc->direct.img.y = img_y;
+ rsc->direct.img.w = img_w;
+ rsc->direct.img.h = img_h;
+
+ rsc->direct.clip.x = clip_x;
+ rsc->direct.clip.y = clip_y;
+ rsc->direct.clip.w = clip_w;
+ rsc->direct.clip.h = clip_h;
+ }
+ else
+ {
+ rsc->direct.enabled = EINA_FALSE;
+ }
+}
+
+void
+evgl_direct_info_clear()
+{
+ EVGL_Resource *rsc;
+
+ if (!(rsc=_evgl_tls_resource_get())) return;
+
+ rsc->direct.enabled = EINA_FALSE;
}
+/*
void
evgl_direct_img_obj_set(Evas_Object *img, int rot)
{
if (rot!=0)
{
if (evgl_engine->direct_override)
- rsc->direct_img_obj = img;
+ rsc->direct.img = img;
else
- rsc->direct_img_obj = NULL;
+ rsc->direct.img = NULL;
}
else
- rsc->direct_img_obj = img;
+ rsc->direct.img = img;
}
Evas_Object *
if (!(rsc=_evgl_tls_resource_get())) return NULL;
- return rsc->direct_img_obj;
+ return rsc->direct.img;
}
+*/
Evas_GL_API *
evgl_api_get()
}
+/*
void
evgl_direct_img_clip_set(int c, int x, int y, int w, int h)
{
rsc->clip[3] = h;
}
+*/
void
evgl_direct_override_get(int *override, int *force_off)