tizen 2.4 release
[framework/uifw/e17-mod-tizen-comp.git] / src / hwcomp / hwcomp_mobile.c
1 #include "e_mod_comp_shared_types.h"
2 #include "e_mod_comp.h"
3 #include "e_mod_comp_canvas.h"
4 #include "e_mod_comp_atoms.h"
5 #include "e_mod_comp_debug.h"
6
7 #include "hwcomp_debug.h"
8 #include "hwcomp.h"
9 #include <X11/extensions/hwc.h>
10
11 #include "hwcomp_util.h"
12 #include "hwcomp_debug.h"
13 #include "hwcomp_mobile.h"
14
15 #if OPTIMIZED_HWC_MOBILE
16 #define KEYBOARD_MAGNIFIER_WIDTH_PORTRAIT  200
17 #define KEYBOARD_MAGNIFIER_WIDTH_LANDSCAPE  160
18 #endif
19
20 Eina_Bool _hwcomp_mod_mobile_mobile_init(E_Comp *c)
21 {
22    E_CHECK_RETURN(c, EINA_FALSE);
23
24 #ifdef USE_HWC
25    c->hwcomp_funcs.set_drawables = _hwcomp_mod_mobile_update_set_drawables;
26    c->hwcomp_funcs.verify_update_mode = _hwcomp_mod_mobile_verify_update_mode;
27 #endif
28    return EINA_TRUE;
29 }
30
31 #ifdef USE_HWC
32 void
33 _hwcomp_mod_mobile_update_set_drawables(E_Comp_HWComp_Update *hwc_update, Ecore_X_Window win)
34 {
35    E_Comp_HWComp_Drawable *hwc_drawable = NULL;
36    Ecore_X_Drawable *d = NULL;
37    int count = 0, idx = 0;
38    int i;
39
40 #if OPTIMIZED_HWC_MOBILE
41    XRectangle *src_rects = NULL;
42    XRectangle *dst_rects = NULL;
43    int *comp_method = NULL;
44    int zone_x = 0, zone_y = 0, zone_w = 0, zone_h = 0;
45    int zone_rot = 0;
46 #endif
47
48    if (!hwc_update) return;
49
50    for (i = 0; i < hwc_update->num_drawable; i++)
51      {
52         hwc_drawable = hwc_update->hwc_drawable[i];
53         if (hwc_drawable->set_drawable)
54            count++;
55      }
56
57    if (count <= 0) return;
58
59    d = E_NEW(Ecore_X_Drawable, count);
60    if (!d)
61       return;
62
63 #if OPTIMIZED_HWC_MOBILE
64    src_rects = E_NEW(XRectangle, count);
65    if (!src_rects)
66      {
67         E_FREE(d);
68         return;
69      }
70
71    dst_rects = E_NEW(XRectangle, count);
72    if (!dst_rects)
73      {
74         E_FREE(d);
75         E_FREE(src_rects);
76         return;
77      }
78
79    comp_method = E_NEW(int, count);
80    if (!comp_method)
81      {
82         E_FREE(d);
83         E_FREE(src_rects);
84         E_FREE(dst_rects);
85         return;
86      }
87
88    if (hwc_update->hwcomp->canvas && hwc_update->hwcomp->canvas->zone)
89      {
90         zone_x = hwc_update->hwcomp->canvas->zone->x;
91         zone_y = hwc_update->hwcomp->canvas->zone->y;
92         zone_w = hwc_update->hwcomp->canvas->zone->w;
93         zone_h = hwc_update->hwcomp->canvas->zone->h;
94      }
95    else
96      {
97         zone_x = 0;
98         zone_y = 0;
99         zone_w = hwc_update->hwcomp->screen_width;
100         zone_h = hwc_update->hwcomp->screen_height;
101      }
102
103    //check orientation
104    if (hwc_update->hwcomp->canvas && hwc_update->hwcomp->canvas->zone)
105      {
106         zone_rot = e_zone_rotation_get(hwc_update->hwcomp->canvas->zone);
107         _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|SET_DRAWABLES: Zone Rotation[%d]", "HWC:Zone",
108              zone_rot);
109      }
110    else
111      {
112         //if zone is not present then what to do ?
113         if (hwc_update->ime_present)
114           {
115              if (hwc_update->ime_rect.h == hwc_update->hwcomp->screen_height)
116                {
117                   if (hwc_update->ime_rect.x == 0)
118                      zone_rot = 270;
119                   else
120                      zone_rot = 90;
121                }
122           }
123      }
124 #endif
125
126    for (i = 0; i < hwc_update->num_drawable; i++)
127      {
128         hwc_drawable = hwc_update->hwc_drawable[i];
129         if (hwc_drawable->set_drawable)
130           {
131
132 #if OPTIMIZED_HWC_MOBILE
133
134              _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|SET_DRAWABLES: id (%d) , cnt(%d), fu(%d)", "HWC",
135                   i, hwc_drawable->update_count, hwc_drawable->first_update);
136              hwc_drawable->update_count++ ; //for debugging
137
138              if (hwc_update->update_mode == E_HWCOMP_USE_FULLCOMP_MODE)
139                {
140                   src_rects[idx].x = zone_x;
141                   src_rects[idx].y = zone_y;
142                   src_rects[idx].width = zone_w;
143                   src_rects[idx].height = zone_h;
144
145                   hwc_drawable->first_update = 0;
146                }
147              else if (i == 0 && hwc_update->hwcomp->miniapp_present)
148                {
149                   src_rects[idx].x = zone_x;
150                   src_rects[idx].y = zone_y;
151                   src_rects[idx].width = zone_w;
152                   src_rects[idx].height = zone_h;
153
154                   hwc_drawable->first_update = 0;
155                }
156              else if (i == 0 && hwc_update->ime_present && hwc_update->split_launcher_rect_present)
157                {
158                   src_rects[idx].x = zone_x;
159                   src_rects[idx].y = zone_y;
160                   src_rects[idx].width = zone_w;
161                   src_rects[idx].height = zone_h;
162
163                   hwc_drawable->first_update = 0;
164                }
165              else if (i == 0 && hwc_update->ime_present)
166                {
167                   _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|SET_DRAWABLES: kbgeo[%d, %d, %d, %d] zRot[%d]", "HWC:Zone-KB",
168                        hwc_update->ime_rect.x,hwc_update->ime_rect.y, hwc_update->ime_rect.w,
169                        hwc_update->ime_rect.h, zone_rot);
170 #if HWC_ROTATION_PATCH
171                   src_rects[idx].x = zone_x;
172                   src_rects[idx].y = zone_y;
173                   src_rects[idx].width = zone_w;
174                   src_rects[idx].height = zone_h;
175
176                   hwc_drawable->first_update = 0;
177 #else
178                   if (zone_rot == 0 || (zone_rot != 0 && hwc_update->ime_rect.y != 0))
179                     {
180                        if (hwc_drawable->first_update == 0)
181                          {
182                             src_rects[idx].x = zone_x;
183                             src_rects[idx].y = zone_y;
184                             src_rects[idx].width = zone_w;
185                             src_rects[idx].height = zone_h;
186
187                             hwc_drawable->first_update = 1;
188                          }
189                        else
190                          {
191                             src_rects[idx].x = hwc_update->ime_rect.x;
192                             src_rects[idx].y = hwc_update->ime_rect.y - KEYBOARD_MAGNIFIER_WIDTH_PORTRAIT; //includes magnifier
193                             src_rects[idx].width = hwc_update->ime_rect.w;
194                             src_rects[idx].height = hwc_update->ime_rect.h + KEYBOARD_MAGNIFIER_WIDTH_PORTRAIT; //includes magnifier
195                          }
196                     }
197                   else
198                     {
199                        if (hwc_drawable->first_update == 0)
200                          {
201                             src_rects[idx].x = zone_x;
202                             src_rects[idx].y = zone_y;
203                             src_rects[idx].width = zone_w;
204                             src_rects[idx].height = zone_h;
205
206                             hwc_drawable->first_update = 1;
207                          }
208                        else
209                          {
210                             if (zone_rot == 90)
211                               {
212                                  src_rects[idx].x = hwc_update->ime_rect.x - KEYBOARD_MAGNIFIER_WIDTH_LANDSCAPE;
213                               }
214                             else //case (zone_rot == 270), as already zone angle 0 and 90 handled
215                               {
216                                  src_rects[idx].x = hwc_update->ime_rect.x;
217                               }
218                             src_rects[idx].y = hwc_update->ime_rect.y;
219                             src_rects[idx].width = hwc_update->ime_rect.w + KEYBOARD_MAGNIFIER_WIDTH_LANDSCAPE;
220                             src_rects[idx].height = hwc_update->ime_rect.h;
221                          }
222                     }
223 #endif
224                }
225              else if (i == 0 && hwc_update->split_launcher_rect_present)
226                {
227                   src_rects[idx].x = zone_x;
228                   src_rects[idx].y = zone_y;
229                   src_rects[idx].width = zone_w;
230                   src_rects[idx].height = zone_h;
231
232                   hwc_drawable->first_update = 0;
233                }
234              else
235                {
236                   if (hwc_drawable->cw)
237                     {
238                        src_rects[idx].x = hwc_drawable->cw->x;
239                        src_rects[idx].y = hwc_drawable->cw->y;
240                        src_rects[idx].width = hwc_drawable->cw->w;
241                        src_rects[idx].height = hwc_drawable->cw->h;
242                     }
243                   else
244                     {
245                        src_rects[idx].x = zone_x;
246                        src_rects[idx].y = zone_y;
247                        src_rects[idx].width = zone_w;
248                        src_rects[idx].height = zone_h;
249                     }
250                }
251 #endif
252
253              //check for keyboard intersection
254 #if OPTIMIZED_HWC_MOBILE
255              if (hwc_update->ime_present && i != 0 && hwc_drawable->cw &&
256                  E_INTERSECTS(hwc_drawable->cw->x, hwc_drawable->cw->y,
257                               hwc_drawable->cw->w, hwc_drawable->cw->h,
258                               hwc_update->ime_rect.x, hwc_update->ime_rect.y,
259                               hwc_update->ime_rect.w, hwc_update->ime_rect.h)
260                  &&
261                  !E_CONTAINS(hwc_update->ime_rect.x, hwc_update->ime_rect.y,
262                              hwc_update->ime_rect.w, hwc_update->ime_rect.h,
263                              hwc_drawable->cw->x, hwc_drawable->cw->y,
264                              hwc_drawable->cw->w, hwc_drawable->cw->h))
265                {
266                  _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|SET_DRAWABLES:Drawable[%d] size [%d, %d, %d, %d]", "HWC:Reduce", i, hwc_drawable->cw->x, hwc_drawable->cw->y,
267                        hwc_drawable->cw->w, hwc_drawable->cw->h);
268
269                   if (zone_rot == 0 || (zone_rot != 0 && hwc_update->ime_rect.y != 0))
270                     {
271                        src_rects[idx].x = hwc_drawable->cw->x;
272                        src_rects[idx].y = hwc_drawable->cw->y;
273                        src_rects[idx].width = hwc_drawable->cw->w;
274                        src_rects[idx].height = hwc_drawable->cw->h - (hwc_drawable->cw->y +
275                                                                       hwc_drawable->cw->h - hwc_update->ime_rect.y);
276                     }
277                   else
278                     {
279                        if (zone_rot == 90)
280                          {
281                             src_rects[idx].x = hwc_drawable->cw->x;
282                             src_rects[idx].y = hwc_drawable->cw->y;
283                             src_rects[idx].width = hwc_update->ime_rect.x - hwc_drawable->cw->x;
284                             src_rects[idx].height = hwc_drawable->cw->h;
285                          }
286                        else // case (zone_rot == 270) as 0 and 90 zone angle already handled
287                          {
288                             int actualX = src_rects[idx].x;
289                             src_rects[idx].x = hwc_update->ime_rect.x + hwc_update->ime_rect.w;
290                             src_rects[idx].y = hwc_drawable->cw->y;
291                             src_rects[idx].width = hwc_drawable->cw->w - (hwc_update->ime_rect.w - (actualX - hwc_update->ime_rect.x));
292                             src_rects[idx].height = hwc_drawable->cw->h;
293                          }
294                     }
295                }
296
297              memcpy(&dst_rects[idx], &src_rects[idx], sizeof(XRectangle));
298              comp_method[idx] = HWC_COMPOSITE_METHOD_DEFAULT;
299
300              _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|SET_DRAWABLES: id (%d) rect[%d, %d, %d, %d], cnt(%d), fu(%d)", "HWC",
301                   i, dst_rects[i].x, dst_rects[i].y, dst_rects[i].width, dst_rects[i].height, hwc_drawable->update_count, hwc_drawable->first_update);
302 #endif
303
304              d[idx] = hwc_drawable->d;
305              idx++;
306           }
307      }
308
309
310
311    for (i = 0; i < count; i++)
312 #if OPTIMIZED_HWC_MOBILE
313            _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|Sree : total:%d, count(%d) win:0x%08x: rect[%d, %d, %d, %d]", "HWC",
314            count, i + 1, d[i], dst_rects[i].x, dst_rects[i].y, dst_rects[i].width, dst_rects[i].height);
315 #else
316    for (i = 0; i < count; i++)
317            _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|Sree : total:%d, count(%d) win:0x%08x:", "HWC",
318             count, i + 1, d[i]);
319 #endif
320
321
322 #if OPTIMIZED_HWC_MOBILE
323    if (count == 1)
324      {
325         dst_rects[0].x = src_rects[0].x = zone_x;
326         dst_rects[0].y = src_rects[0].y = zone_y;
327         dst_rects[0].width = src_rects[0].width = zone_w;
328         dst_rects[0].height = src_rects[0].height = zone_h;
329         comp_method[0] = HWC_COMPOSITE_METHOD_DEFAULT;
330      }
331    /*TODO: Get Active Crtc */
332    HWCSetDrawables(hwcomp_util_display_get(), 0, win, (Drawable *)d, (XRectangle *)src_rects, (XRectangle *)dst_rects, (int *) comp_method, count);
333 #else
334    // Build Error. when OPTIMIZED_HWC_MOBILE is 0
335    //HWCSetDrawables(hwcomp_util_display_get(), win, (Drawable *)d, count);
336 #endif
337
338    E_FREE(d);
339
340 #if OPTIMIZED_HWC_MOBILE
341    E_FREE(src_rects);
342    E_FREE(dst_rects);
343    E_FREE(comp_method);
344 #endif
345 }
346
347 Eina_Bool
348 _hwcomp_mod_mobile_verify_update_mode(E_Comp_HWComp *hwcomp, E_Comp_HWComp_Update *hwc_update)
349 {
350    E_Comp *c = NULL;
351    E_Comp_Canvas *canvas = NULL;
352    E_Zone *zone = NULL;
353    E_Comp_Layer *ly = NULL;
354    Eina_Bool effect_status = EINA_FALSE, move_status = EINA_FALSE, rotation_status = EINA_FALSE;
355
356    E_Comp_Win *cw;
357    E_Comp_Object *co = NULL, *_co = NULL;
358    Eina_List *l;
359    Eina_Bool check_nocomp = EINA_TRUE;
360    int hybrid_idx = 0;
361    const char *name = NULL;
362
363 #if OPTIMIZED_HWC_MOBILE
364    Eina_Rectangle total_rect = {0,};
365    Eina_Bool miniapp = EINA_FALSE;
366    Eina_Bool keyboard = EINA_FALSE;
367    Eina_Bool magnifier = EINA_FALSE;
368    Eina_Bool clipboard = EINA_FALSE;
369    Eina_Bool split_launcher = EINA_FALSE;
370    Eina_Rectangle clipboard_rect = {0,};
371    Eina_Rectangle zone_rect = {0,};
372 #endif
373
374    c = hwcomp->c;
375    E_CHECK_RETURN(c, 0);
376
377    canvas = hwcomp->canvas;
378    E_CHECK_RETURN(canvas, 0);
379
380    zone = canvas->zone;
381    E_CHECK_RETURN(zone, 0);
382
383 #if OPTIMIZED_HWC_MOBILE
384    zone_rect.x = zone->x;
385    zone_rect.y = zone->y;
386    zone_rect.w = zone->h;
387    zone_rect.h = zone->h;
388 #endif
389
390    /* pre-check full composite condition */
391    ly = e_mod_comp_canvas_layer_get(canvas, "effect");
392    if (ly)
393       effect_status = evas_object_visible_get(ly->layout);
394    ly = e_mod_comp_canvas_layer_get(canvas, "move");
395    if (ly)
396       move_status = evas_object_visible_get(ly->layout);
397    if ((canvas->zone) && (canvas->zone->rot.block_count))
398       rotation_status = EINA_TRUE;
399
400    /*
401     * basically canvas->ee_win always will be set at top layer0
402     * this drawable drawn by GLES
403     */
404    hwc_update->hwc_drawable[0]->cw = NULL;
405    hwc_update->hwc_drawable[0]->d = canvas->ee_win;
406    hwc_update->hwc_drawable[0]->set_drawable = EINA_TRUE;
407
408 #if OPTIMIZED_HWC_MOBILE
409    hwc_update->hwc_drawable[0]->first_update = 0;
410
411 #if DEBUG_HWC
412    hwc_update->hwc_drawable[0]->update_count = 0;  //for debugging
413 #endif
414
415 #endif
416
417    if (hwcomp_util_max_layer_get() == 1)
418       goto full_comp;
419
420    if (hwcomp->force_composite)
421       goto full_comp;
422
423 #if HWC_ROTATION_PATCH
424    if (hwcomp->doing_rotation)
425       goto full_comp;
426 #endif
427
428    /* full composite */
429    if (effect_status == EINA_TRUE)
430       goto full_comp;
431    if (move_status == EINA_TRUE)
432       goto full_comp;
433    if (rotation_status == EINA_TRUE)
434       goto full_comp;
435
436    /*
437     * I have 2 special cases
438     *
439     * CASE 1 : 1 full screen app overlapes full screen
440     *
441     * CASE 2: Some windows are can be set at HW layer
442     *   - If num of windows are bigger than "hwcomp->num_overlays-1" additional algorithm should be used.
443     */
444    EINA_INLIST_REVERSE_FOREACH(c->wins, cw)
445      {
446         EINA_LIST_FOREACH(cw->objs, l, co)
447           {
448              if (!co) continue;
449              if (co->canvas != canvas) continue;
450
451              _co = co;
452              break;
453           }
454
455         if ((_co) && (cw->bd) && (cw->bd->client.win) &&
456             (!cw->shaped) && (!cw->rects) && (cw->hwc.set_drawable))
457           {
458              int abs_x, abs_y, abs_w, abs_h;
459
460              name = hwcomp_util_border_name_get(cw->bd);
461
462 #if OPTIMIZED_HWC_MOBILE
463              abs_x = cw->x;
464              abs_y = cw->y;
465              abs_w = cw->w;
466              abs_h = cw->h;
467 #else
468              ecore_x_window_geometry_get(cw->win, &abs_x, &abs_y, &abs_w, &abs_h);
469 #endif
470
471              if (E_CONTAINS(zone->x, zone->y, zone->w, zone->h, abs_x, abs_y, abs_w, abs_h) || (name && !strcmp(name, "SPLIT_LAUNCHER")))
472                {
473                   /* check nocomp mode with the first cw once */
474                   if (check_nocomp && REGION_EQUAL_TO_ZONE(cw, zone) && cw->use_dri2 && (!cw->argb)
475                       && !cw->hwc.resize_pending)
476                     {
477                        hwc_update->update_mode = E_HWCOMP_USE_NOCOMP_MODE;
478                        hwc_update->num_drawable = 1;
479                        hwc_update->hwc_drawable[0]->cw = cw;
480                        hwc_update->hwc_drawable[0]->d = cw->bd->client.win;
481                        hwc_update->hwc_drawable[0]->set_drawable = EINA_TRUE;
482
483 #if OPTIMIZED_HWC_MOBILE
484                        hwc_update->hwc_drawable[0]->first_update = 0;
485 #if DEBUG_HWC
486                        hwc_update->hwc_drawable[0]->update_count = 0;  //for debugging
487 #endif
488
489 #endif
490                        goto done;
491                     }
492                   else
493                     {
494                        if (check_nocomp) check_nocomp = EINA_FALSE;
495                     }
496
497                   _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|VERIFY_UPDATE:win id:0x%08x name:%s", "HWC:NAME", cw->win, cw->bd->client.icccm.name);
498                   _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|VERIFY_UPDATE:win id:0x%08x class:%s", "HWC:NAME", cw->win, cw->bd->client.icccm.class);
499                   _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|VERIFY_UPDATE:win id:0x%08x title:%s", "HWC:NAME", cw->win, cw->bd->client.icccm.title);
500                   _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|VERIFY_UPDATE:win id:0x%08x iconname:%s", "HWC:NAME", cw->win, cw->bd->client.icccm.icon_name);
501                   /* skip the cw if the cw is not the use_dri2 */
502                   if (!cw->use_dri2 && !cw->argb)
503                      continue;
504
505                   /* skip the cw is the Key Magnifier */
506 #if OPTIMIZED_HWC_MOBILE
507                   if (name && !strcmp(name, "Key Magnifier"))
508                     {
509
510                        magnifier = EINA_TRUE;
511                        hwc_update->keymag_rect.x = cw->x;
512                        hwc_update->keymag_rect.y = cw->y;
513                        hwc_update->keymag_rect.w = cw->w;
514                        hwc_update->keymag_rect.h = cw->h;
515
516                        _hwcomp_dbg_elbf(ELBT_COMP, 0, 0, "%15.15s|KM_RECT rect(%d,%d,%d,%d)", "HWC:RECT", cw->x, cw->y, cw->w, cw->h);
517
518                        continue;
519                     }
520 #else
521                   if (cw->bd->client.icccm.name && !strcmp(cw->bd->client.icccm.name, "Key Magnifier"))
522                      continue;
523 #endif
524
525                   /* skip the cw is the Prediction Window */
526 #if OPTIMIZED_HWC_MOBILE
527                   if (cw->argb && name && !strcmp(name, "Prediction Window"))
528                      continue;
529 #else
530                   if ( cw->argb && (cw->bd->client.icccm.name && !strcmp(cw->bd->client.icccm.name, "Prediction Window")))
531                      continue;
532 #endif
533
534 #if OPTIMIZED_HWC_MOBILE
535                   /* skip the cw is the Key Board / Clipboard */
536                   if (name && !strcmp(name, "Virtual Keyboard"))
537                     {
538                        keyboard = EINA_TRUE;
539                        hwc_update->ime_rect.x = cw->x;
540                        hwc_update->ime_rect.y = cw->y;
541                        hwc_update->ime_rect.w = cw->w;
542                        hwc_update->ime_rect.h = cw->h;
543                        continue;
544                     }
545
546                   if (name && !strcmp(name, "Clipboard History Manager"))
547                     {
548                        clipboard = EINA_TRUE;
549                        clipboard_rect.x = cw->x;
550                        clipboard_rect.y = cw->y;
551                        clipboard_rect.w = cw->w;
552                        clipboard_rect.h = cw->h;
553                        continue;
554                     }
555
556                   if (name && !strcmp(name, "SPLIT_LAUNCHER"))
557                     {
558                        split_launcher = EINA_TRUE;
559                        hwc_update->split_launcher_rect.x = cw->x;
560                        hwc_update->split_launcher_rect.y = cw->y;
561                        hwc_update->split_launcher_rect.w = cw->w;
562                        hwc_update->split_launcher_rect.h = cw->h;
563                        eina_rectangle_intersection(&(hwc_update->split_launcher_rect), &zone_rect);
564                        continue;
565                     }
566
567                   if (STATE_INSET_CHECK(cw) || (!cw->argb && (cw->w < zone->w || cw->h < zone->h)))
568                     {
569                        if (hwcomp_util_check_fullcomp_mode(cw) != EINA_TRUE)
570                          {
571                             e_mod_comp_win_hwcomp_mask_objs_hide(cw);
572                             miniapp = EINA_TRUE;
573                             continue;
574                          }
575                        else
576                           goto full_comp;
577                     }
578 #endif
579                   /* argb */
580                   if (cw->argb)
581                      goto full_comp;
582
583                   if (hybrid_idx < hwc_update->num_overlays-1)
584                     {
585                        hybrid_idx++;
586
587                        /* I think there are some windows which is no full screen */
588                        /* Mini app || Splited window || No magnifier of keypad */
589                        hwc_update->update_mode = E_HWCOMP_USE_HYBRIDCOMP_MODE;
590                        hwc_update->num_drawable = hybrid_idx + 1;
591                        hwc_update->hwc_drawable[hybrid_idx]->cw = cw;
592                        hwc_update->hwc_drawable[hybrid_idx]->d = cw->bd->client.win;
593 #if OPTIMIZED_HWC_MOBILE
594
595 #if DEBUG_HWC
596                        hwc_update->hwc_drawable[hybrid_idx]->update_count = 0;  //for debugging
597 #endif
598
599                        if (hwc_update->keymag_present == EINA_FALSE &&
600                            hwc_update->ime_present == EINA_FALSE)
601                           /* Calculate all rects with union */
602                          {
603                             Eina_Rectangle this_rect;
604                             this_rect.x = cw->x;
605                             this_rect.y = cw->y;
606                             this_rect.w = cw->w;
607                             this_rect.h = cw->h;
608
609                             eina_rectangle_union(&total_rect, &this_rect);
610                          }
611 #endif
612
613                        if ((REGION_EQUAL_TO_ZONE(cw, zone) && (!cw->argb))) break;
614                     }
615                }
616              /* full composite */
617              else if (E_INTERSECTS(zone->x, zone->y, zone->w, zone->h, abs_x, abs_y, abs_w, abs_h))
618                 goto full_comp;
619
620              /* full composite */
621              if (hwcomp_util_check_fullcomp_mode(cw) == EINA_TRUE)
622                 goto full_comp;
623
624           }
625         else if ((_co) && (cw->redirected) && (!cw->bd) &&
626                  (!cw->shaped) && (!cw->rects) && (cw->hwc.set_drawable))
627            goto full_comp;
628      }
629    if (hwc_update->num_drawable == 0)
630      {
631 #if HWC_ROTATION_PATCH
632         goto full_comp;
633 #else
634         return EINA_FALSE;
635 #endif
636      }
637
638 #if OPTIMIZED_HWC_MOBILE
639
640    if (!magnifier && !keyboard && !clipboard
641        && !miniapp && !split_launcher && hwc_update->update_mode == E_HWCOMP_USE_HYBRIDCOMP_MODE
642        && total_rect.x == zone->x && total_rect.y == zone->y
643        && total_rect.w == zone->w && total_rect.h == zone->h)
644      {
645         //update the drawables
646         int idx = 0;
647         for (idx = 0; idx < hwc_update->num_drawable - 1; idx++)
648           {
649              hwc_update->hwc_drawable[idx]->cw = hwc_update->hwc_drawable[idx+1]->cw;
650              hwc_update->hwc_drawable[idx]->d = hwc_update->hwc_drawable[idx+1]->d;
651              hwc_update->hwc_drawable[idx]->set_drawable = EINA_TRUE;
652
653 #if DEBUG_HWC
654              hwc_update->hwc_drawable[idx]->update_count = hwc_update->hwc_drawable[idx+1]->update_count;  //for debugging
655 #endif
656           }
657         hwc_update->num_drawable--;
658      }
659
660 #endif
661
662 done:
663 #if OPTIMIZED_HWC_MOBILE
664    hwc_update->hwcomp->miniapp_present = miniapp;
665    hwc_update->ime_present = keyboard;
666    hwc_update->keymag_present = magnifier;
667    hwc_update->split_launcher_rect_present = split_launcher;
668
669    if (keyboard && clipboard)
670      {
671         if ((hwc_update->ime_rect.w * hwc_update->ime_rect.h) < (clipboard_rect.w * clipboard_rect.h))
672           {
673              hwc_update->ime_rect.x = clipboard_rect.x;
674              hwc_update->ime_rect.y = clipboard_rect.y;
675              hwc_update->ime_rect.w = clipboard_rect.w;
676              hwc_update->ime_rect.h = clipboard_rect.h;
677           }
678      }
679 #endif
680
681    return EINA_TRUE;
682
683 full_comp:
684    hwcomp_util_update_clear(hwc_update);
685
686    hwc_update->update_mode = E_HWCOMP_USE_FULLCOMP_MODE;
687    hwc_update->num_drawable = 1;
688    hwc_update->hwc_drawable[0]->cw = NULL;
689    hwc_update->hwc_drawable[0]->d = canvas->ee_win;
690    hwc_update->hwc_drawable[0]->set_drawable = EINA_TRUE;
691
692    return EINA_TRUE;
693 }
694 #endif /* End of HWC */
695