summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorSung W. Park <dunamis.park@samsung.com>2013-10-24 17:37:22 +0900
committerSung W. Park <dunamis.park@samsung.com>2013-10-24 17:42:21 +0900
commit7dc102c55f6de2a9952cf79ffa69b50ab66df4c1 (patch)
tree990be0bac6c5dc11ac4431fc6b71cd09c51cff08 /src/modules
parentabec2d03b88657873a864dbd0bb0731442b4384f (diff)
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.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api.c231
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.c76
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.h39
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core_private.h25
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c33
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_engine.c21
6 files changed, 234 insertions, 191 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api.c b/src/modules/evas/engines/gl_common/evas_gl_api.c
index 968f7e10b3..6b93548524 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api.c
@@ -20,7 +20,7 @@ void _make_current_check(const char* api)
20 20
21 if (!ctx) 21 if (!ctx)
22 { 22 {
23 CRIT("\e[1;33m%s\e[m: Current Context NOT SET: GL Call Should NOT Be Called without MakeCurrent!!!", api); 23 CRIT("\e[1;33m%s\e[m: Current Context NOT SET: GL Call Should NOT Be Called without MakeCurrent!!!", api);
24 } 24 }
25} 25}
26 26
@@ -157,45 +157,23 @@ _evgl_glReleaseShaderCompiler(void)
157// returns: objc[4] (nc[4]) tranformed (x, y, width, heigth) in gl coord 157// returns: objc[4] (nc[4]) tranformed (x, y, width, heigth) in gl coord
158// returns: cc[4] cliped coordinate in original coordinate 158// returns: cc[4] cliped coordinate in original coordinate
159static void 159static void
160compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image, 160compute_gl_coordinates(int win_w, int win_h, int rot, int clip_image,
161 int x, int y, int width, int height, 161 int x, int y, int width, int height,
162 int clip[4], 162 int img_x, int img_y, int img_w, int img_h,
163 int clip_x, int clip_y, int clip_w, int clip_h,
163 int imgc[4], int objc[4], int cc[4]) 164 int imgc[4], int objc[4], int cc[4])
164{ 165{
165 Evas_Object_Protected_Data *pd = eo_data_scope_get(obj, EVAS_OBJ_CLASS);
166
167 int obj_x, obj_y, obj_w, obj_h;
168 int clip_x, clip_y, clip_w, clip_h;
169 int out_w, out_h;
170
171 // Original Coordinates
172 obj_x = pd->cur->geometry.x;
173 obj_y = pd->cur->geometry.y;
174 obj_w = pd->cur->geometry.w;
175 obj_h = pd->cur->geometry.h;
176
177 // Clip Region
178 clip_x = clip[0];
179 clip_y = clip[1];
180 clip_w = clip[2];
181 clip_h = clip[3];
182
183 // Output Window Size
184 out_w = pd->layer->evas->output.w;
185 out_h = pd->layer->evas->output.h;
186
187
188 if (rot == 0) 166 if (rot == 0)
189 { 167 {
190 // oringinal image object coordinate in gl coordinate 168 // oringinal image object coordinate in gl coordinate
191 imgc[0] = obj_x; 169 imgc[0] = img_x;
192 imgc[1] = out_h - obj_y - obj_h; 170 imgc[1] = win_h - img_y - img_h;
193 imgc[2] = imgc[0] + obj_w; 171 imgc[2] = imgc[0] + img_w;
194 imgc[3] = imgc[1] + obj_h; 172 imgc[3] = imgc[1] + img_h;
195 173
196 // clip coordinates in gl coordinate 174 // clip coordinates in gl coordinate
197 cc[0] = clip_x; 175 cc[0] = clip_x;
198 cc[1] = out_h - clip_y - clip_h; 176 cc[1] = win_h - clip_y - clip_h;
199 cc[2] = cc[0] + clip_w; 177 cc[2] = cc[0] + clip_w;
200 cc[3] = cc[1] + clip_h; 178 cc[3] = cc[1] + clip_h;
201 179
@@ -208,20 +186,20 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
208 else if (rot == 180) 186 else if (rot == 180)
209 { 187 {
210 // oringinal image object coordinate in gl coordinate 188 // oringinal image object coordinate in gl coordinate
211 imgc[0] = out_w - obj_x - obj_w; 189 imgc[0] = win_w - img_x - img_w;
212 imgc[1] = obj_y; 190 imgc[1] = img_y;
213 imgc[2] = imgc[0] + obj_w; 191 imgc[2] = imgc[0] + img_w;
214 imgc[3] = imgc[1] + obj_h; 192 imgc[3] = imgc[1] + img_h;
215 193
216 // clip coordinates in gl coordinate 194 // clip coordinates in gl coordinate
217 cc[0] = out_w - clip_x - clip_w; 195 cc[0] = win_w - clip_x - clip_w;
218 cc[1] = clip_y; 196 cc[1] = clip_y;
219 cc[2] = cc[0] + clip_w; 197 cc[2] = cc[0] + clip_w;
220 cc[3] = cc[1] + clip_h; 198 cc[3] = cc[1] + clip_h;
221 199
222 // transformed (x,y,width,height) in gl coordinate 200 // transformed (x,y,width,height) in gl coordinate
223 objc[0] = imgc[0] + obj_w - x - width; 201 objc[0] = imgc[0] + img_w - x - width;
224 objc[1] = imgc[1] + obj_h - y - height; 202 objc[1] = imgc[1] + img_h - y - height;
225 objc[2] = objc[0] + width; 203 objc[2] = objc[0] + width;
226 objc[3] = objc[1] + height; 204 objc[3] = objc[1] + height;
227 205
@@ -229,10 +207,10 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
229 else if (rot == 90) 207 else if (rot == 90)
230 { 208 {
231 // oringinal image object coordinate in gl coordinate 209 // oringinal image object coordinate in gl coordinate
232 imgc[0] = obj_y; 210 imgc[0] = img_y;
233 imgc[1] = obj_x; 211 imgc[1] = img_x;
234 imgc[2] = imgc[0] + obj_h; 212 imgc[2] = imgc[0] + img_h;
235 imgc[3] = imgc[1] + obj_w; 213 imgc[3] = imgc[1] + img_w;
236 214
237 // clip coordinates in gl coordinate 215 // clip coordinates in gl coordinate
238 cc[0] = clip_y; 216 cc[0] = clip_y;
@@ -241,7 +219,7 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
241 cc[3] = cc[1] + clip_w; 219 cc[3] = cc[1] + clip_w;
242 220
243 // transformed (x,y,width,height) in gl coordinate 221 // transformed (x,y,width,height) in gl coordinate
244 objc[0] = imgc[0] + obj_h - y - height; 222 objc[0] = imgc[0] + img_h - y - height;
245 objc[1] = imgc[1] + x; 223 objc[1] = imgc[1] + x;
246 objc[2] = objc[0] + height; 224 objc[2] = objc[0] + height;
247 objc[3] = objc[1] + width; 225 objc[3] = objc[1] + width;
@@ -249,20 +227,20 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
249 else if (rot == 270) 227 else if (rot == 270)
250 { 228 {
251 // oringinal image object coordinate in gl coordinate 229 // oringinal image object coordinate in gl coordinate
252 imgc[0] = out_h - obj_y - obj_h; 230 imgc[0] = win_h - img_y - img_h;
253 imgc[1] = out_w - obj_x - obj_w; 231 imgc[1] = win_w - img_x - img_w;
254 imgc[2] = imgc[0] + obj_h; 232 imgc[2] = imgc[0] + img_h;
255 imgc[3] = imgc[1] + obj_w; 233 imgc[3] = imgc[1] + img_w;
256 234
257 // clip coordinates in gl coordinate 235 // clip coordinates in gl coordinate
258 cc[0] = out_h - clip_y - clip_h; 236 cc[0] = win_h - clip_y - clip_h;
259 cc[1] = out_w - clip_x - clip_w; 237 cc[1] = win_w - clip_x - clip_w;
260 cc[2] = cc[0] + clip_h; 238 cc[2] = cc[0] + clip_h;
261 cc[3] = cc[1] + clip_w; 239 cc[3] = cc[1] + clip_w;
262 240
263 // transformed (x,y,width,height) in gl coordinate 241 // transformed (x,y,width,height) in gl coordinate
264 objc[0] = imgc[0] + y; 242 objc[0] = imgc[0] + y;
265 objc[1] = imgc[1] + obj_w - x - width; 243 objc[1] = imgc[1] + img_w - x - width;
266 objc[2] = objc[0] + height; 244 objc[2] = objc[0] + height;
267 objc[3] = objc[1] + width; 245 objc[3] = objc[1] + width;
268 } 246 }
@@ -297,7 +275,7 @@ compute_gl_coordinates(Evas_Object *obj, int rot, int clip_image,
297 cc[2] = cc[2]-cc[0]; // width 275 cc[2] = cc[2]-cc[0]; // width
298 cc[3] = cc[3]-cc[1]; // height 276 cc[3] = cc[3]-cc[1]; // height
299 277
300 //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]); 278 //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]);
301} 279}
302 280
303static void 281static void
@@ -305,8 +283,6 @@ _evgl_glClear(GLbitfield mask)
305{ 283{
306 EVGL_Resource *rsc; 284 EVGL_Resource *rsc;
307 EVGL_Context *ctx; 285 EVGL_Context *ctx;
308 Evas_Object *img;
309 int rot = 0;
310 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}; 286 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
311 int cc[4] = {0,0,0,0}; 287 int cc[4] = {0,0,0,0};
312 288
@@ -339,35 +315,33 @@ _evgl_glClear(GLbitfield mask)
339 ctx->direct_scissor = 1; 315 ctx->direct_scissor = 1;
340 } 316 }
341 317
342 img = rsc->direct_img_obj;
343 rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng);
344
345 if ((ctx->scissor_updated) && (ctx->scissor_enabled)) 318 if ((ctx->scissor_updated) && (ctx->scissor_enabled))
346 { 319 {
347 compute_gl_coordinates(img, rot, 1, 320 compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
348 ctx->scissor_coord[0], 321 rsc->direct.rot, 1,
349 ctx->scissor_coord[1], 322 ctx->scissor_coord[0], ctx->scissor_coord[1],
350 ctx->scissor_coord[2], 323 ctx->scissor_coord[2], ctx->scissor_coord[3],
351 ctx->scissor_coord[3], 324 rsc->direct.img.x, rsc->direct.img.y,
352 rsc->clip, oc, nc, cc); 325 rsc->direct.img.w, rsc->direct.img.h,
353 326 rsc->direct.clip.x, rsc->direct.clip.y,
354 if (rsc->master_clip) 327 rsc->direct.clip.w, rsc->direct.clip.h,
355 { 328 oc, nc, cc);
356 RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]); 329
357 glScissor(nc[0], nc[1], nc[2], nc[3]); 330 RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
358 } 331 glScissor(nc[0], nc[1], nc[2], nc[3]);
359 else
360 glScissor(nc[0], nc[1], nc[2], nc[3]);
361 ctx->direct_scissor = 0; 332 ctx->direct_scissor = 0;
362 } 333 }
363 else 334 else
364 { 335 {
365 compute_gl_coordinates(img, rot, 0, 0, 0, 0, 0, rsc->clip, oc, nc, cc); 336 compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
366 337 rsc->direct.rot, 0,
367 if (rsc->master_clip) 338 0, 0, 0, 0,
368 glScissor(cc[0], cc[1], cc[2], cc[3]); 339 rsc->direct.img.x, rsc->direct.img.y,
369 else 340 rsc->direct.img.w, rsc->direct.img.h,
370 glScissor(oc[0], oc[1], oc[2], oc[3]); 341 rsc->direct.clip.x, rsc->direct.clip.y,
342 rsc->direct.clip.w, rsc->direct.clip.h,
343 oc, nc, cc);
344 glScissor(cc[0], cc[1], cc[2], cc[3]);
371 } 345 }
372 346
373 glClear(mask); 347 glClear(mask);
@@ -424,7 +398,6 @@ _evgl_glGetIntegerv(GLenum pname, GLint* params)
424{ 398{
425 EVGL_Resource *rsc; 399 EVGL_Resource *rsc;
426 EVGL_Context *ctx; 400 EVGL_Context *ctx;
427 Evas_Object_Protected_Data *img;
428 401
429 if (_evgl_direct_enabled()) 402 if (_evgl_direct_enabled())
430 { 403 {
@@ -450,8 +423,6 @@ _evgl_glGetIntegerv(GLenum pname, GLint* params)
450 // Only need to handle it if it's directly rendering to the window 423 // Only need to handle it if it's directly rendering to the window
451 if (!(rsc->current_ctx->current_fbo)) 424 if (!(rsc->current_ctx->current_fbo))
452 { 425 {
453 img = eo_data_scope_get(rsc->direct_img_obj, EVAS_OBJ_CLASS);
454
455 if (pname == GL_SCISSOR_BOX) 426 if (pname == GL_SCISSOR_BOX)
456 { 427 {
457 if (ctx->scissor_updated) 428 if (ctx->scissor_updated)
@@ -475,8 +446,8 @@ _evgl_glGetIntegerv(GLenum pname, GLint* params)
475 { 446 {
476 params[0] = 0; 447 params[0] = 0;
477 params[1] = 0; 448 params[1] = 0;
478 params[2] = (GLint)img->cur->geometry.w; 449 params[2] = (GLint)rsc->direct.img.w;
479 params[3] = (GLint)img->cur->geometry.h; 450 params[3] = (GLint)rsc->direct.img.h;
480 return; 451 return;
481 } 452 }
482 } 453 }
@@ -490,8 +461,6 @@ _evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum forma
490{ 461{
491 EVGL_Resource *rsc; 462 EVGL_Resource *rsc;
492 EVGL_Context *ctx; 463 EVGL_Context *ctx;
493 Evas_Object *img;
494 int rot = 0;
495 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}; 464 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
496 int cc[4] = {0,0,0,0}; 465 int cc[4] = {0,0,0,0};
497 466
@@ -520,10 +489,14 @@ _evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum forma
520 489
521 if (!(rsc->current_ctx->current_fbo)) 490 if (!(rsc->current_ctx->current_fbo))
522 { 491 {
523 img = rsc->direct_img_obj; 492 compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
524 rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng); 493 rsc->direct.rot, 1,
525 494 x, y, width, height,
526 compute_gl_coordinates(img, rot, 1, x, y, width, height, rsc->clip, oc, nc, cc); 495 rsc->direct.img.x, rsc->direct.img.y,
496 rsc->direct.img.w, rsc->direct.img.h,
497 rsc->direct.clip.x, rsc->direct.clip.y,
498 rsc->direct.clip.w, rsc->direct.clip.h,
499 oc, nc, cc);
527 glReadPixels(nc[0], nc[1], nc[2], nc[3], format, type, pixels); 500 glReadPixels(nc[0], nc[1], nc[2], nc[3], format, type, pixels);
528 } 501 }
529 else 502 else
@@ -542,8 +515,6 @@ _evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
542{ 515{
543 EVGL_Resource *rsc; 516 EVGL_Resource *rsc;
544 EVGL_Context *ctx; 517 EVGL_Context *ctx;
545 Evas_Object *img;
546 int rot = 0;
547 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}; 518 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
548 int cc[4] = {0,0,0,0}; 519 int cc[4] = {0,0,0,0};
549 520
@@ -575,10 +546,14 @@ _evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
575 glDisable(GL_SCISSOR_TEST); 546 glDisable(GL_SCISSOR_TEST);
576 } 547 }
577 548
578 img = rsc->direct_img_obj; 549 compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
579 rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng); 550 rsc->direct.rot, 1,
580 551 x, y, width, height,
581 compute_gl_coordinates(img, rot, 1, x, y, width, height, rsc->clip, oc, nc, cc); 552 rsc->direct.img.x, rsc->direct.img.y,
553 rsc->direct.img.w, rsc->direct.img.h,
554 rsc->direct.clip.x, rsc->direct.clip.y,
555 rsc->direct.clip.w, rsc->direct.clip.h,
556 oc, nc, cc);
582 557
583 // Keep a copy of the original coordinates 558 // Keep a copy of the original coordinates
584 ctx->scissor_coord[0] = x; 559 ctx->scissor_coord[0] = x;
@@ -586,13 +561,8 @@ _evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
586 ctx->scissor_coord[2] = width; 561 ctx->scissor_coord[2] = width;
587 ctx->scissor_coord[3] = height; 562 ctx->scissor_coord[3] = height;
588 563
589 if (rsc->master_clip) 564 RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
590 { 565 glScissor(nc[0], nc[1], nc[2], nc[3]);
591 RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
592 glScissor(nc[0], nc[1], nc[2], nc[3]);
593 }
594 else
595 glScissor(nc[0], nc[1], nc[2], nc[3]);
596 566
597 ctx->direct_scissor = 0; 567 ctx->direct_scissor = 0;
598 568
@@ -629,8 +599,6 @@ _evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
629{ 599{
630 EVGL_Resource *rsc; 600 EVGL_Resource *rsc;
631 EVGL_Context *ctx; 601 EVGL_Context *ctx;
632 Evas_Object *img;
633 int rot = 0;
634 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}; 602 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0};
635 int cc[4] = {0,0,0,0}; 603 int cc[4] = {0,0,0,0};
636 604
@@ -663,40 +631,47 @@ _evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
663 ctx->direct_scissor = 1; 631 ctx->direct_scissor = 1;
664 } 632 }
665 633
666 img = rsc->direct_img_obj;
667 rot = evgl_engine->funcs->rotation_angle_get(rsc->current_eng);
668
669 if ((ctx->scissor_updated) && (ctx->scissor_enabled)) 634 if ((ctx->scissor_updated) && (ctx->scissor_enabled))
670 { 635 {
671 // Recompute the scissor coordinates 636 // Recompute the scissor coordinates
672 compute_gl_coordinates(img, rot, 1, 637 compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
673 ctx->scissor_coord[0], 638 rsc->direct.rot, 1,
674 ctx->scissor_coord[1], 639 ctx->scissor_coord[0], ctx->scissor_coord[1],
675 ctx->scissor_coord[2], 640 ctx->scissor_coord[2], ctx->scissor_coord[3],
676 ctx->scissor_coord[3], 641 rsc->direct.img.x, rsc->direct.img.y,
677 rsc->clip, oc, nc, cc); 642 rsc->direct.img.w, rsc->direct.img.h,
678 643 rsc->direct.clip.x, rsc->direct.clip.y,
679 if (rsc->master_clip) 644 rsc->direct.clip.w, rsc->direct.clip.h,
680 { 645 oc, nc, cc);
681 RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]); 646
682 glScissor(nc[0], nc[1], nc[2], nc[3]); 647 RECTS_CLIP_TO_RECT(nc[0], nc[1], nc[2], nc[3], cc[0], cc[1], cc[2], cc[3]);
683 } 648 glScissor(nc[0], nc[1], nc[2], nc[3]);
684 else
685 glScissor(nc[0], nc[1], nc[2], nc[3]);
686 649
687 ctx->direct_scissor = 0; 650 ctx->direct_scissor = 0;
688 651
689 // Compute the viewport coordinate 652 // Compute the viewport coordinate
690 compute_gl_coordinates(img, rot, 0, x, y, width, height, rsc->clip, oc, nc, cc); 653 compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
654 rsc->direct.rot, 0,
655 x, y, width, height,
656 rsc->direct.img.x, rsc->direct.img.y,
657 rsc->direct.img.w, rsc->direct.img.h,
658 rsc->direct.clip.x, rsc->direct.clip.y,
659 rsc->direct.clip.w, rsc->direct.clip.h,
660 oc, nc, cc);
691 glViewport(nc[0], nc[1], nc[2], nc[3]); 661 glViewport(nc[0], nc[1], nc[2], nc[3]);
692 } 662 }
693 else 663 else
694 { 664 {
695 compute_gl_coordinates(img, rot, 0, x, y, width, height, rsc->clip, oc, nc, cc); 665
696 if (rsc->master_clip) 666 compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
697 glScissor(cc[0], cc[1], cc[2], cc[3]); 667 rsc->direct.rot, 0,
698 else 668 x, y, width, height,
699 glScissor(oc[0], oc[1], oc[2], oc[3]); 669 rsc->direct.img.x, rsc->direct.img.y,
670 rsc->direct.img.w, rsc->direct.img.h,
671 rsc->direct.clip.x, rsc->direct.clip.y,
672 rsc->direct.clip.w, rsc->direct.clip.h,
673 oc, nc, cc);
674 glScissor(cc[0], cc[1], cc[2], cc[3]);
700 675
701 glViewport(nc[0], nc[1], nc[2], nc[3]); 676 glViewport(nc[0], nc[1], nc[2], nc[3]);
702 } 677 }
@@ -1627,7 +1602,7 @@ void
1627_evgld_glShaderSource(GLuint shader, GLsizei count, const char* const * string, const GLint* length) 1602_evgld_glShaderSource(GLuint shader, GLsizei count, const char* const * string, const GLint* length)
1628{ 1603{
1629 EVGL_FUNC_BEGIN(); 1604 EVGL_FUNC_BEGIN();
1630#ifdef GL_GLES 1605#ifdef GL_GLES
1631 glShaderSource(shader, count, (const GLchar * const *) string, length); 1606 glShaderSource(shader, count, (const GLchar * const *) string, length);
1632#else 1607#else
1633 glShaderSource(shader, count, (const GLchar **) string, length); 1608 glShaderSource(shader, count, (const GLchar **) string, length);
@@ -2273,7 +2248,7 @@ _evgld_glShaderSource(GLuint shader, GLsizei count, const char* const* string, c
2273finish: 2248finish:
2274 EVGL_FUNC_END(); 2249 EVGL_FUNC_END();
2275} 2250}
2276#endif 2251#endif
2277 2252
2278//-------------------------------------------------------------// 2253//-------------------------------------------------------------//
2279 2254
@@ -2524,7 +2499,7 @@ _normal_gl_api_get(Evas_GL_API *funcs)
2524 ORD(glGetShaderPrecisionFormat); 2499 ORD(glGetShaderPrecisionFormat);
2525 ORD(glShaderBinary); 2500 ORD(glShaderBinary);
2526 ORD(glReleaseShaderCompiler); 2501 ORD(glReleaseShaderCompiler);
2527 2502
2528#undef ORD 2503#undef ORD
2529 2504
2530 evgl_api_ext_get(funcs); 2505 evgl_api_ext_get(funcs);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c
index c711a26756..a065bd4652 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -114,10 +114,10 @@ _internal_resource_make_current(void *eng_data, EVGL_Context *ctx)
114 114
115 // Set the surface to evas surface if it's there 115 // Set the surface to evas surface if it's there
116 if (rsc->id == evgl_engine->main_tid) 116 if (rsc->id == evgl_engine->main_tid)
117 rsc->direct_surface = evgl_engine->funcs->evas_surface_get(eng_data); 117 rsc->direct.surface = evgl_engine->funcs->evas_surface_get(eng_data);
118 118
119 if (rsc->direct_surface) 119 if (rsc->direct.surface)
120 surface = (void*)rsc->direct_surface; 120 surface = (void*)rsc->direct.surface;
121 else 121 else
122 surface = (void*)rsc->surface; 122 surface = (void*)rsc->surface;
123 123
@@ -1117,7 +1117,7 @@ _evgl_direct_renderable(EVGL_Resource *rsc, EVGL_Surface *sfc)
1117 if (evgl_engine->direct_force_off) return 0; 1117 if (evgl_engine->direct_force_off) return 0;
1118 if (rsc->id != evgl_engine->main_tid) return 0; 1118 if (rsc->id != evgl_engine->main_tid) return 0;
1119 if (!sfc->direct_fb_opt) return 0; 1119 if (!sfc->direct_fb_opt) return 0;
1120 if (!rsc->direct_img_obj) return 0; 1120 if (!rsc->direct.enabled) return 0;
1121 1121
1122 return 1; 1122 return 1;
1123} 1123}
@@ -1243,7 +1243,7 @@ _evgl_not_in_pixel_get()
1243 (ctx) && 1243 (ctx) &&
1244 (ctx->current_sfc) && 1244 (ctx->current_sfc) &&
1245 (ctx->current_sfc->direct_fb_opt) && 1245 (ctx->current_sfc->direct_fb_opt) &&
1246 (!rsc->direct_img_obj)) 1246 (!rsc->direct.enabled))
1247 return 1; 1247 return 1;
1248 else 1248 else
1249 return 0; 1249 return 0;
@@ -1384,7 +1384,7 @@ error:
1384// Terminate engine and all the resources 1384// Terminate engine and all the resources
1385// - destroy all internal resources 1385// - destroy all internal resources
1386// - free allocated engine struct 1386// - free allocated engine struct
1387void 1387void
1388evgl_engine_shutdown(void *eng_data) 1388evgl_engine_shutdown(void *eng_data)
1389{ 1389{
1390 // Check if engine is valid 1390 // Check if engine is valid
@@ -1740,7 +1740,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
1740 glBindFramebuffer(GL_FRAMEBUFFER, 0); 1740 glBindFramebuffer(GL_FRAMEBUFFER, 0);
1741 ctx->current_fbo = 0; 1741 ctx->current_fbo = 0;
1742 } 1742 }
1743 rsc->direct_rendered = 1; 1743 rsc->direct.rendered = 1;
1744 } 1744 }
1745 else 1745 else
1746 { 1746 {
@@ -1757,7 +1757,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
1757 if (ctx->current_fbo) 1757 if (ctx->current_fbo)
1758 glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo); 1758 glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo);
1759 } 1759 }
1760 rsc->direct_rendered = 0; 1760 rsc->direct.rendered = 0;
1761 } 1761 }
1762 1762
1763 ctx->current_sfc = sfc; 1763 ctx->current_sfc = sfc;
@@ -1820,9 +1820,56 @@ evgl_direct_rendered()
1820 1820
1821 if (!(rsc=_evgl_tls_resource_get())) return 0; 1821 if (!(rsc=_evgl_tls_resource_get())) return 0;
1822 1822
1823 return rsc->direct_rendered; 1823 return rsc->direct.rendered;
1824}
1825
1826
1827
1828void
1829evgl_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)
1830{
1831 EVGL_Resource *rsc;
1832
1833 if (!(rsc=_evgl_tls_resource_get())) return;
1834
1835 // Normally direct rendering isn't allowed if alpha is on and
1836 // rotation is not 0. BUT, if override is on, allow it.
1837 if ( (rot==0) ||
1838 ((rot!=0) && (evgl_engine->direct_override)) )
1839 {
1840 rsc->direct.enabled = EINA_TRUE;
1841
1842 rsc->direct.win_w = win_w;
1843 rsc->direct.win_h = win_h;
1844 rsc->direct.rot = rot;
1845
1846 rsc->direct.img.x = img_x;
1847 rsc->direct.img.y = img_y;
1848 rsc->direct.img.w = img_w;
1849 rsc->direct.img.h = img_h;
1850
1851 rsc->direct.clip.x = clip_x;
1852 rsc->direct.clip.y = clip_y;
1853 rsc->direct.clip.w = clip_w;
1854 rsc->direct.clip.h = clip_h;
1855 }
1856 else
1857 {
1858 rsc->direct.enabled = EINA_FALSE;
1859 }
1860}
1861
1862void
1863evgl_direct_info_clear()
1864{
1865 EVGL_Resource *rsc;
1866
1867 if (!(rsc=_evgl_tls_resource_get())) return;
1868
1869 rsc->direct.enabled = EINA_FALSE;
1824} 1870}
1825 1871
1872/*
1826void 1873void
1827evgl_direct_img_obj_set(Evas_Object *img, int rot) 1874evgl_direct_img_obj_set(Evas_Object *img, int rot)
1828{ 1875{
@@ -1835,12 +1882,12 @@ evgl_direct_img_obj_set(Evas_Object *img, int rot)
1835 if (rot!=0) 1882 if (rot!=0)
1836 { 1883 {
1837 if (evgl_engine->direct_override) 1884 if (evgl_engine->direct_override)
1838 rsc->direct_img_obj = img; 1885 rsc->direct.img = img;
1839 else 1886 else
1840 rsc->direct_img_obj = NULL; 1887 rsc->direct.img = NULL;
1841 } 1888 }
1842 else 1889 else
1843 rsc->direct_img_obj = img; 1890 rsc->direct.img = img;
1844} 1891}
1845 1892
1846Evas_Object * 1893Evas_Object *
@@ -1850,8 +1897,9 @@ evgl_direct_img_obj_get()
1850 1897
1851 if (!(rsc=_evgl_tls_resource_get())) return NULL; 1898 if (!(rsc=_evgl_tls_resource_get())) return NULL;
1852 1899
1853 return rsc->direct_img_obj; 1900 return rsc->direct.img;
1854} 1901}
1902*/
1855 1903
1856Evas_GL_API * 1904Evas_GL_API *
1857evgl_api_get() 1905evgl_api_get()
@@ -1862,6 +1910,7 @@ evgl_api_get()
1862} 1910}
1863 1911
1864 1912
1913/*
1865void 1914void
1866evgl_direct_img_clip_set(int c, int x, int y, int w, int h) 1915evgl_direct_img_clip_set(int c, int x, int y, int w, int h)
1867{ 1916{
@@ -1876,6 +1925,7 @@ evgl_direct_img_clip_set(int c, int x, int y, int w, int h)
1876 rsc->clip[3] = h; 1925 rsc->clip[3] = h;
1877 1926
1878} 1927}
1928*/
1879 1929
1880void 1930void
1881evgl_direct_override_get(int *override, int *force_off) 1931evgl_direct_override_get(int *override, int *force_off)
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.h b/src/modules/evas/engines/gl_common/evas_gl_core.h
index edcb52c3d6..bbd5b24af9 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.h
@@ -18,24 +18,31 @@ typedef struct _EVGL_Surface_Cap EVGL_Surface_Cap;
18typedef struct _EVGL_Surface_Format EVGL_Surface_Format; 18typedef struct _EVGL_Surface_Format EVGL_Surface_Format;
19 19
20 20
21extern EVGL_Engine *evgl_engine_init(void *eng_data, EVGL_Interface *efunc); 21EVGL_Engine *evgl_engine_init(void *eng_data, EVGL_Interface *efunc);
22extern void evgl_engine_shutdown(void *eng_data); 22void evgl_engine_shutdown(void *eng_data);
23 23
24extern void *evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h); 24void *evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h);
25extern int evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc); 25int evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc);
26extern void *evgl_context_create(void *eng_data, EVGL_Context *share_ctx); 26void *evgl_context_create(void *eng_data, EVGL_Context *share_ctx);
27extern int evgl_context_destroy(void *eng_data, EVGL_Context *ctx); 27int evgl_context_destroy(void *eng_data, EVGL_Context *ctx);
28extern int evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx); 28int evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx);
29 29
30extern const char *evgl_string_query(int name); 30const char *evgl_string_query(int name);
31extern void *evgl_proc_address_get(const char *name); 31void *evgl_proc_address_get(const char *name);
32extern int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns); 32int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns);
33extern Evas_GL_API *evgl_api_get(); 33Evas_GL_API *evgl_api_get();
34extern int evgl_direct_rendered(); 34int evgl_direct_rendered();
35
36
37/*
35extern void evgl_direct_img_obj_set(Evas_Object *img, int rot); 38extern void evgl_direct_img_obj_set(Evas_Object *img, int rot);
36extern Evas_Object *evgl_direct_img_obj_get(); 39extern Evas_Object *evgl_direct_img_obj_get();
40*/
41
42void 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);
43void evgl_direct_info_clear();
37 44
38extern void evgl_direct_img_clip_set(int c, int x, int y, int w, int h); 45//extern void evgl_direct_img_clip_set(int c, int x, int y, int w, int h);
39extern void evgl_direct_override_get(int *override, int *force_off); 46void evgl_direct_override_get(int *override, int *force_off);
40 47
41#endif //_EVAS_GL_CORE_H 48#endif //_EVAS_GL_CORE_H
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core_private.h b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
index 5c617b6c69..37e8cc5127 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
@@ -209,13 +209,26 @@ struct _EVGL_Resource
209 EVGL_Context *current_ctx; 209 EVGL_Context *current_ctx;
210 void *current_eng; 210 void *current_eng;
211 211
212 EVGLNative_Surface direct_surface; 212 struct {
213 int direct_rendered; 213 EVGLNative_Surface surface;
214 Evas_Object *direct_img_obj; 214 int rendered;
215 int get_pixels_set; 215 //Evas_Object *img;
216 216
217 int master_clip; 217 int rot;
218 int clip[4]; 218 int win_w;
219 int win_h;
220
221 struct {
222 int x, y, w, h;
223 } img;
224
225 struct {
226 int x, y, w, h;
227 } clip;
228
229 Eina_Bool enabled : 1;
230
231 } direct;
219}; 232};
220 233
221struct _EVGL_Engine 234struct _EVGL_Engine
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index f1a41e5a3a..b708bf8fef 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -2913,24 +2913,21 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
2913 2913
2914 re->win->gl_context->dc = context; 2914 re->win->gl_context->dc = context;
2915 2915
2916 if (re->func.get_pixels) 2916 // Set necessary info for direct rendering
2917 { 2917 evgl_direct_info_set(re->win->gl_context->w,
2918 2918 re->win->gl_context->h,
2919 // Pass the clip info the evas_gl 2919 re->win->gl_context->rot,
2920 evgl_direct_img_clip_set(1, 2920 dst_x, dst_y, dst_w, dst_h,
2921 re->win->gl_context->dc->clip.x, 2921 re->win->gl_context->dc->clip.x,
2922 re->win->gl_context->dc->clip.y, 2922 re->win->gl_context->dc->clip.y,
2923 re->win->gl_context->dc->clip.w, 2923 re->win->gl_context->dc->clip.w,
2924 re->win->gl_context->dc->clip.h); 2924 re->win->gl_context->dc->clip.h);
2925 2925
2926 // Call pixel get function 2926 // Call pixel get function
2927 evgl_direct_img_obj_set(re->func.obj, re->win->gl_context->rot); 2927 re->func.get_pixels(re->func.get_pixels_data, re->func.obj);
2928 re->func.get_pixels(re->func.get_pixels_data, re->func.obj); 2928
2929 evgl_direct_img_obj_set(NULL, 0); 2929 // Clear direct rendering info
2930 2930 evgl_direct_info_clear();
2931 // Reset clip
2932 evgl_direct_img_clip_set(0, 0, 0, 0, 0);
2933 }
2934 } 2931 }
2935 else 2932 else
2936 { 2933 {
diff --git a/src/modules/evas/engines/wayland_egl/evas_engine.c b/src/modules/evas/engines/wayland_egl/evas_engine.c
index a370825b2f..f5acf968e7 100644
--- a/src/modules/evas/engines/wayland_egl/evas_engine.c
+++ b/src/modules/evas/engines/wayland_egl/evas_engine.c
@@ -2018,20 +2018,21 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
2018 2018
2019 re->win->gl_context->dc = context; 2019 re->win->gl_context->dc = context;
2020 2020
2021 // Pass the clip info the evas_gl 2021 // Set necessary info for direct rendering
2022 evgl_direct_img_clip_set(1, 2022 evgl_direct_info_set(re->win->gl_context->w,
2023 re->win->gl_context->dc->clip.x, 2023 re->win->gl_context->h,
2024 re->win->gl_context->dc->clip.y, 2024 re->win->gl_context->rot,
2025 re->win->gl_context->dc->clip.w, 2025 dst_x, dst_y, dst_w, dst_h,
2026 re->win->gl_context->dc->clip.h); 2026 re->win->gl_context->dc->clip.x,
2027 re->win->gl_context->dc->clip.y,
2028 re->win->gl_context->dc->clip.w,
2029 re->win->gl_context->dc->clip.h);
2027 2030
2028 // Call pixel get function 2031 // Call pixel get function
2029 evgl_direct_img_obj_set(re->func.obj, re->win->gl_context->rot);
2030 re->func.pixels_get(re->func.pixels_data_get, re->func.obj); 2032 re->func.pixels_get(re->func.pixels_data_get, re->func.obj);
2031 evgl_direct_img_obj_set(NULL, 0);
2032 2033
2033 // Reset clip 2034 // Clear direct rendering info
2034 evgl_direct_img_clip_set(0, 0, 0, 0, 0); 2035 evgl_direct_info_clear();
2035 } 2036 }
2036 else 2037 else
2037 { 2038 {