EvasGL: Fixed direct rendering not clipping issue

Evas GL direct rendering mode didn't properly take into account
the image object's clipping information and clip the region that
it was directly rendering to. Hence there were issues with the
direct rendering region drawing over the objects that are sitting
on top of it.

Also, cleaned up the direct rendering coordinate computation code
and a nasty dependency with image object that should have been
removed a long time ago.  Basically the evas-gl engine was directly
accessing the image object data structure for its data when it
really should have just passed along necessary information.
This commit is contained in:
Sung W. Park 2013-10-24 17:37:22 +09:00
parent abec2d03b8
commit 7dc102c55f
7 changed files with 231 additions and 185 deletions

View File

@ -1,3 +1,6 @@
2013-10-24 Sung W. Park (sung_)
* EvasGL: Fixed direct rendering mode not clipping to its clip region.
2013-10-18 Youngbok Shin 2013-10-18 Youngbok Shin
* Fixed the textblock format to be drawn according to * Fixed the textblock format to be drawn according to

View File

@ -157,45 +157,23 @@ _evgl_glReleaseShaderCompiler(void)
// returns: objc[4] (nc[4]) tranformed (x, y, width, heigth) in gl coord // returns: objc[4] (nc[4]) tranformed (x, y, width, heigth) in gl coord
// returns: cc[4] cliped coordinate in original coordinate // returns: cc[4] cliped coordinate in original coordinate
static void 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 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]) 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) if (rot == 0)
{ {
// oringinal image object coordinate in gl coordinate // oringinal image object coordinate in gl coordinate
imgc[0] = obj_x; imgc[0] = img_x;
imgc[1] = out_h - obj_y - obj_h; imgc[1] = win_h - img_y - img_h;
imgc[2] = imgc[0] + obj_w; imgc[2] = imgc[0] + img_w;
imgc[3] = imgc[1] + obj_h; imgc[3] = imgc[1] + img_h;
// clip coordinates in gl coordinate // clip coordinates in gl coordinate
cc[0] = clip_x; 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[2] = cc[0] + clip_w;
cc[3] = cc[1] + clip_h; cc[3] = cc[1] + clip_h;
@ -208,20 +186,20 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
else if (rot == 180) else if (rot == 180)
{ {
// oringinal image object coordinate in gl coordinate // oringinal image object coordinate in gl coordinate
imgc[0] = out_w - obj_x - obj_w; imgc[0] = win_w - img_x - img_w;
imgc[1] = obj_y; imgc[1] = img_y;
imgc[2] = imgc[0] + obj_w; imgc[2] = imgc[0] + img_w;
imgc[3] = imgc[1] + obj_h; imgc[3] = imgc[1] + img_h;
// clip coordinates in gl coordinate // 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[1] = clip_y;
cc[2] = cc[0] + clip_w; cc[2] = cc[0] + clip_w;
cc[3] = cc[1] + clip_h; cc[3] = cc[1] + clip_h;
// transformed (x,y,width,height) in gl coordinate // transformed (x,y,width,height) in gl coordinate
objc[0] = imgc[0] + obj_w - x - width; objc[0] = imgc[0] + img_w - x - width;
objc[1] = imgc[1] + obj_h - y - height; objc[1] = imgc[1] + img_h - y - height;
objc[2] = objc[0] + width; objc[2] = objc[0] + width;
objc[3] = objc[1] + height; objc[3] = objc[1] + height;
@ -229,10 +207,10 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
else if (rot == 90) else if (rot == 90)
{ {
// oringinal image object coordinate in gl coordinate // oringinal image object coordinate in gl coordinate
imgc[0] = obj_y; imgc[0] = img_y;
imgc[1] = obj_x; imgc[1] = img_x;
imgc[2] = imgc[0] + obj_h; imgc[2] = imgc[0] + img_h;
imgc[3] = imgc[1] + obj_w; imgc[3] = imgc[1] + img_w;
// clip coordinates in gl coordinate // clip coordinates in gl coordinate
cc[0] = clip_y; cc[0] = clip_y;
@ -241,7 +219,7 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
cc[3] = cc[1] + clip_w; cc[3] = cc[1] + clip_w;
// transformed (x,y,width,height) in gl coordinate // 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[1] = imgc[1] + x;
objc[2] = objc[0] + height; objc[2] = objc[0] + height;
objc[3] = objc[1] + width; objc[3] = objc[1] + width;
@ -249,20 +227,20 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
else if (rot == 270) else if (rot == 270)
{ {
// oringinal image object coordinate in gl coordinate // oringinal image object coordinate in gl coordinate
imgc[0] = out_h - obj_y - obj_h; imgc[0] = win_h - img_y - img_h;
imgc[1] = out_w - obj_x - obj_w; imgc[1] = win_w - img_x - img_w;
imgc[2] = imgc[0] + obj_h; imgc[2] = imgc[0] + img_h;
imgc[3] = imgc[1] + obj_w; imgc[3] = imgc[1] + img_w;
// clip coordinates in gl coordinate // clip coordinates in gl coordinate
cc[0] = out_h - clip_y - clip_h; cc[0] = win_h - clip_y - clip_h;
cc[1] = out_w - clip_x - clip_w; cc[1] = win_w - clip_x - clip_w;
cc[2] = cc[0] + clip_h; cc[2] = cc[0] + clip_h;
cc[3] = cc[1] + clip_w; cc[3] = cc[1] + clip_w;
// transformed (x,y,width,height) in gl coordinate // transformed (x,y,width,height) in gl coordinate
objc[0] = imgc[0] + y; 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[2] = objc[0] + height;
objc[3] = objc[1] + width; objc[3] = objc[1] + width;
} }
@ -297,7 +275,7 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
cc[2] = cc[2]-cc[0]; // width cc[2] = cc[2]-cc[0]; // width
cc[3] = cc[3]-cc[1]; // height 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 static void
@ -305,8 +283,6 @@ _evgl_glClear(GLbitfield mask)
{ {
EVGL_Resource *rsc; EVGL_Resource *rsc;
EVGL_Context *ctx; EVGL_Context *ctx;
Evas_Object *img;
int rot = 0;
int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}; int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
int cc[4] = {0,0,0,0}; int cc[4] = {0,0,0,0};
@ -339,35 +315,33 @@ _evgl_glClear(GLbitfield mask)
ctx->direct_scissor = 1; 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)) if ((ctx->scissor_updated) && (ctx->scissor_enabled))
{ {
compute_gl_coordinates(img, rot, 1, compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
ctx->scissor_coord[0], rsc->direct.rot, 1,
ctx->scissor_coord[1], ctx->scissor_coord[0], ctx->scissor_coord[1],
ctx->scissor_coord[2], ctx->scissor_coord[2], ctx->scissor_coord[3],
ctx->scissor_coord[3], rsc->direct.img.x, rsc->direct.img.y,
rsc->clip, oc, nc, cc); 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);
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]);
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]);
ctx->direct_scissor = 0; ctx->direct_scissor = 0;
} }
else else
{ {
compute_gl_coordinates(img, rot, 0, 0, 0, 0, 0, rsc->clip, oc, nc, cc); compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
rsc->direct.rot, 0,
if (rsc->master_clip) 0, 0, 0, 0,
glScissor(cc[0], cc[1], cc[2], cc[3]); rsc->direct.img.x, rsc->direct.img.y,
else rsc->direct.img.w, rsc->direct.img.h,
glScissor(oc[0], oc[1], oc[2], oc[3]); 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); glClear(mask);
@ -424,7 +398,6 @@ _evgl_glGetIntegerv(GLenum pname, GLint* params)
{ {
EVGL_Resource *rsc; EVGL_Resource *rsc;
EVGL_Context *ctx; EVGL_Context *ctx;
Evas_Object_Protected_Data *img;
if (_evgl_direct_enabled()) if (_evgl_direct_enabled())
{ {
@ -450,8 +423,6 @@ _evgl_glGetIntegerv(GLenum pname, GLint* params)
// Only need to handle it if it's directly rendering to the window // Only need to handle it if it's directly rendering to the window
if (!(rsc->current_ctx->current_fbo)) if (!(rsc->current_ctx->current_fbo))
{ {
img = eo_data_scope_get(rsc->direct_img_obj, EVAS_OBJ_CLASS);
if (pname == GL_SCISSOR_BOX) if (pname == GL_SCISSOR_BOX)
{ {
if (ctx->scissor_updated) if (ctx->scissor_updated)
@ -475,8 +446,8 @@ _evgl_glGetIntegerv(GLenum pname, GLint* params)
{ {
params[0] = 0; params[0] = 0;
params[1] = 0; params[1] = 0;
params[2] = (GLint)img->cur->geometry.w; params[2] = (GLint)rsc->direct.img.w;
params[3] = (GLint)img->cur->geometry.h; params[3] = (GLint)rsc->direct.img.h;
return; return;
} }
} }
@ -490,8 +461,6 @@ _evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum forma
{ {
EVGL_Resource *rsc; EVGL_Resource *rsc;
EVGL_Context *ctx; EVGL_Context *ctx;
Evas_Object *img;
int rot = 0;
int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}; int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
int cc[4] = {0,0,0,0}; int cc[4] = {0,0,0,0};
@ -520,10 +489,14 @@ _evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum forma
if (!(rsc->current_ctx->current_fbo)) if (!(rsc->current_ctx->current_fbo))
{ {
img = rsc->direct_img_obj; compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng); rsc->direct.rot, 1,
x, y, width, height,
compute_gl_coordinates(img, rot, 1, x, y, width, height, rsc->clip, oc, nc, cc); 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); glReadPixels(nc[0], nc[1], nc[2], nc[3], format, type, pixels);
} }
else else
@ -542,8 +515,6 @@ _evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
{ {
EVGL_Resource *rsc; EVGL_Resource *rsc;
EVGL_Context *ctx; EVGL_Context *ctx;
Evas_Object *img;
int rot = 0;
int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}; int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
int cc[4] = {0,0,0,0}; int cc[4] = {0,0,0,0};
@ -575,10 +546,14 @@ _evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
} }
img = rsc->direct_img_obj; compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng); rsc->direct.rot, 1,
x, y, width, height,
compute_gl_coordinates(img, rot, 1, x, y, width, height, rsc->clip, oc, nc, cc); 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 // Keep a copy of the original coordinates
ctx->scissor_coord[0] = x; ctx->scissor_coord[0] = x;
@ -586,13 +561,8 @@ _evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
ctx->scissor_coord[2] = width; ctx->scissor_coord[2] = width;
ctx->scissor_coord[3] = height; 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]);
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]);
ctx->direct_scissor = 0; ctx->direct_scissor = 0;
@ -629,8 +599,6 @@ _evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
{ {
EVGL_Resource *rsc; EVGL_Resource *rsc;
EVGL_Context *ctx; EVGL_Context *ctx;
Evas_Object *img;
int rot = 0;
int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}; int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
int cc[4] = {0,0,0,0}; int cc[4] = {0,0,0,0};
@ -663,40 +631,47 @@ _evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
ctx->direct_scissor = 1; 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)) if ((ctx->scissor_updated) && (ctx->scissor_enabled))
{ {
// Recompute the scissor coordinates // Recompute the scissor coordinates
compute_gl_coordinates(img, rot, 1, compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
ctx->scissor_coord[0], rsc->direct.rot, 1,
ctx->scissor_coord[1], ctx->scissor_coord[0], ctx->scissor_coord[1],
ctx->scissor_coord[2], ctx->scissor_coord[2], ctx->scissor_coord[3],
ctx->scissor_coord[3], rsc->direct.img.x, rsc->direct.img.y,
rsc->clip, oc, nc, cc); 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);
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]);
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]);
ctx->direct_scissor = 0; ctx->direct_scissor = 0;
// Compute the viewport coordinate // 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]); glViewport(nc[0], nc[1], nc[2], nc[3]);
} }
else else
{ {
compute_gl_coordinates(img, rot, 0, x, y, width, height, rsc->clip, oc, nc, cc);
if (rsc->master_clip) compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
glScissor(cc[0], cc[1], cc[2], cc[3]); rsc->direct.rot, 0,
else x, y, width, height,
glScissor(oc[0], oc[1], oc[2], oc[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);
glScissor(cc[0], cc[1], cc[2], cc[3]);
glViewport(nc[0], nc[1], nc[2], nc[3]); glViewport(nc[0], nc[1], nc[2], nc[3]);
} }

View File

@ -114,10 +114,10 @@ _internal_resource_make_current(void *eng_data, EVGL_Context *ctx)
// Set the surface to evas surface if it's there // Set the surface to evas surface if it's there
if (rsc->id == evgl_engine->main_tid) 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) if (rsc->direct.surface)
surface = (void*)rsc->direct_surface; surface = (void*)rsc->direct.surface;
else else
surface = (void*)rsc->surface; surface = (void*)rsc->surface;
@ -1117,7 +1117,7 @@ _evgl_direct_renderable(EVGL_Resource *rsc, EVGL_Surface *sfc)
if (evgl_engine->direct_force_off) return 0; if (evgl_engine->direct_force_off) return 0;
if (rsc->id != evgl_engine->main_tid) return 0; if (rsc->id != evgl_engine->main_tid) return 0;
if (!sfc->direct_fb_opt) return 0; if (!sfc->direct_fb_opt) return 0;
if (!rsc->direct_img_obj) return 0; if (!rsc->direct.enabled) return 0;
return 1; return 1;
} }
@ -1243,7 +1243,7 @@ _evgl_not_in_pixel_get()
(ctx) && (ctx) &&
(ctx->current_sfc) && (ctx->current_sfc) &&
(ctx->current_sfc->direct_fb_opt) && (ctx->current_sfc->direct_fb_opt) &&
(!rsc->direct_img_obj)) (!rsc->direct.enabled))
return 1; return 1;
else else
return 0; return 0;
@ -1740,7 +1740,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
ctx->current_fbo = 0; ctx->current_fbo = 0;
} }
rsc->direct_rendered = 1; rsc->direct.rendered = 1;
} }
else else
{ {
@ -1757,7 +1757,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
if (ctx->current_fbo) if (ctx->current_fbo)
glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo); glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo);
} }
rsc->direct_rendered = 0; rsc->direct.rendered = 0;
} }
ctx->current_sfc = sfc; ctx->current_sfc = sfc;
@ -1820,9 +1820,56 @@ evgl_direct_rendered()
if (!(rsc=_evgl_tls_resource_get())) return 0; 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 void
evgl_direct_img_obj_set(Evas_Object *img, int rot) evgl_direct_img_obj_set(Evas_Object *img, int rot)
{ {
@ -1835,12 +1882,12 @@ evgl_direct_img_obj_set(Evas_Object *img, int rot)
if (rot!=0) if (rot!=0)
{ {
if (evgl_engine->direct_override) if (evgl_engine->direct_override)
rsc->direct_img_obj = img; rsc->direct.img = img;
else else
rsc->direct_img_obj = NULL; rsc->direct.img = NULL;
} }
else else
rsc->direct_img_obj = img; rsc->direct.img = img;
} }
Evas_Object * Evas_Object *
@ -1850,8 +1897,9 @@ evgl_direct_img_obj_get()
if (!(rsc=_evgl_tls_resource_get())) return NULL; if (!(rsc=_evgl_tls_resource_get())) return NULL;
return rsc->direct_img_obj; return rsc->direct.img;
} }
*/
Evas_GL_API * Evas_GL_API *
evgl_api_get() evgl_api_get()
@ -1862,6 +1910,7 @@ evgl_api_get()
} }
/*
void void
evgl_direct_img_clip_set(int c, int x, int y, int w, int h) evgl_direct_img_clip_set(int c, int x, int y, int w, int h)
{ {
@ -1876,6 +1925,7 @@ evgl_direct_img_clip_set(int c, int x, int y, int w, int h)
rsc->clip[3] = h; rsc->clip[3] = h;
} }
*/
void void
evgl_direct_override_get(int *override, int *force_off) evgl_direct_override_get(int *override, int *force_off)

View File

@ -18,24 +18,31 @@ typedef struct _EVGL_Surface_Cap EVGL_Surface_Cap;
typedef struct _EVGL_Surface_Format EVGL_Surface_Format; typedef struct _EVGL_Surface_Format EVGL_Surface_Format;
extern EVGL_Engine *evgl_engine_init(void *eng_data, EVGL_Interface *efunc); EVGL_Engine *evgl_engine_init(void *eng_data, EVGL_Interface *efunc);
extern void evgl_engine_shutdown(void *eng_data); void evgl_engine_shutdown(void *eng_data);
extern void *evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h); void *evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h);
extern int evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc); int evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc);
extern void *evgl_context_create(void *eng_data, EVGL_Context *share_ctx); void *evgl_context_create(void *eng_data, EVGL_Context *share_ctx);
extern int evgl_context_destroy(void *eng_data, EVGL_Context *ctx); int evgl_context_destroy(void *eng_data, EVGL_Context *ctx);
extern int evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx); int evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx);
extern const char *evgl_string_query(int name); const char *evgl_string_query(int name);
extern void *evgl_proc_address_get(const char *name); void *evgl_proc_address_get(const char *name);
extern int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns); int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns);
extern Evas_GL_API *evgl_api_get(); Evas_GL_API *evgl_api_get();
extern int evgl_direct_rendered(); int evgl_direct_rendered();
/*
extern void evgl_direct_img_obj_set(Evas_Object *img, int rot); extern void evgl_direct_img_obj_set(Evas_Object *img, int rot);
extern Evas_Object *evgl_direct_img_obj_get(); extern Evas_Object *evgl_direct_img_obj_get();
*/
extern void evgl_direct_img_clip_set(int c, int x, int y, int w, int h); 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);
extern void evgl_direct_override_get(int *override, int *force_off); void evgl_direct_info_clear();
//extern void evgl_direct_img_clip_set(int c, int x, int y, int w, int h);
void evgl_direct_override_get(int *override, int *force_off);
#endif //_EVAS_GL_CORE_H #endif //_EVAS_GL_CORE_H

View File

@ -209,13 +209,26 @@ struct _EVGL_Resource
EVGL_Context *current_ctx; EVGL_Context *current_ctx;
void *current_eng; void *current_eng;
EVGLNative_Surface direct_surface; struct {
int direct_rendered; EVGLNative_Surface surface;
Evas_Object *direct_img_obj; int rendered;
int get_pixels_set; //Evas_Object *img;
int master_clip; int rot;
int clip[4]; int win_w;
int win_h;
struct {
int x, y, w, h;
} img;
struct {
int x, y, w, h;
} clip;
Eina_Bool enabled : 1;
} direct;
}; };
struct _EVGL_Engine struct _EVGL_Engine

View File

@ -2913,24 +2913,21 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
re->win->gl_context->dc = context; re->win->gl_context->dc = context;
if (re->func.get_pixels) // Set necessary info for direct rendering
{ evgl_direct_info_set(re->win->gl_context->w,
re->win->gl_context->h,
re->win->gl_context->rot,
dst_x, dst_y, dst_w, dst_h,
re->win->gl_context->dc->clip.x,
re->win->gl_context->dc->clip.y,
re->win->gl_context->dc->clip.w,
re->win->gl_context->dc->clip.h);
// Pass the clip info the evas_gl // Call pixel get function
evgl_direct_img_clip_set(1, re->func.get_pixels(re->func.get_pixels_data, re->func.obj);
re->win->gl_context->dc->clip.x,
re->win->gl_context->dc->clip.y,
re->win->gl_context->dc->clip.w,
re->win->gl_context->dc->clip.h);
// Call pixel get function // Clear direct rendering info
evgl_direct_img_obj_set(re->func.obj, re->win->gl_context->rot); evgl_direct_info_clear();
re->func.get_pixels(re->func.get_pixels_data, re->func.obj);
evgl_direct_img_obj_set(NULL, 0);
// Reset clip
evgl_direct_img_clip_set(0, 0, 0, 0, 0);
}
} }
else else
{ {

View File

@ -2018,20 +2018,21 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
re->win->gl_context->dc = context; re->win->gl_context->dc = context;
// Pass the clip info the evas_gl // Set necessary info for direct rendering
evgl_direct_img_clip_set(1, evgl_direct_info_set(re->win->gl_context->w,
re->win->gl_context->dc->clip.x, re->win->gl_context->h,
re->win->gl_context->dc->clip.y, re->win->gl_context->rot,
re->win->gl_context->dc->clip.w, dst_x, dst_y, dst_w, dst_h,
re->win->gl_context->dc->clip.h); re->win->gl_context->dc->clip.x,
re->win->gl_context->dc->clip.y,
re->win->gl_context->dc->clip.w,
re->win->gl_context->dc->clip.h);
// Call pixel get function // Call pixel get function
evgl_direct_img_obj_set(re->func.obj, re->win->gl_context->rot);
re->func.pixels_get(re->func.pixels_data_get, re->func.obj); re->func.pixels_get(re->func.pixels_data_get, re->func.obj);
evgl_direct_img_obj_set(NULL, 0);
// Reset clip // Clear direct rendering info
evgl_direct_img_clip_set(0, 0, 0, 0, 0); evgl_direct_info_clear();
} }
else else
{ {