summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-04-15 12:05:59 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-08-05 15:12:33 +0200
commit8b31b7c33a8f7e35e95e9e8b01eb0fc826787fa9 (patch)
treedb4917d3b938de07269af3affe99b1012aa5bfeb
parent2ebf315591e0554c308d762a5b7c1823649deb1d (diff)
evas: prepare refactoring necessary for snapshot.
-rw-r--r--src/lib/evas/canvas/evas_render.c392
1 files changed, 210 insertions, 182 deletions
diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c
index 80faf6f3c5..c308cb0b8f 100644
--- a/src/lib/evas/canvas/evas_render.c
+++ b/src/lib/evas/canvas/evas_render.c
@@ -2122,6 +2122,202 @@ _cb_always_call(Evas *eo_e, Evas_Callback_Type type, void *event_info)
2122} 2122}
2123 2123
2124static Eina_Bool 2124static Eina_Bool
2125evas_render_updates_internal_loop(Evas *eo_e, Evas_Public_Data *e,
2126 void *surface,
2127 int ux, int uy, int uw, int uh,
2128 int cx, int cy, int cw, int ch,
2129 int fx, int fy,
2130 Eina_Bool alpha,
2131 Eina_Bool make_updates,
2132 Eina_Bool do_async,
2133 Evas_Render_Mode render_mode,
2134 unsigned int *offset)
2135{
2136 Evas_Object *eo_obj;
2137 Evas_Object_Protected_Data *obj;
2138 Render_Updates *ru;
2139 int off_x, off_y;
2140 unsigned int i, j;
2141 Eina_Bool clean_them = EINA_FALSE;
2142
2143 eina_evlog("+render_setup", eo_e, 0.0, NULL);
2144 RD(0, " [--- UPDATE %i %i %ix%i\n", ux, uy, uw, uh);
2145 if (do_async)
2146 {
2147 ru = malloc(sizeof(*ru));
2148 ru->surface = surface;
2149 NEW_RECT(ru->area, ux, uy, uw, uh);
2150 e->render.updates = eina_list_append(e->render.updates, ru);
2151 evas_cache_image_ref(surface);
2152 }
2153 else if (make_updates)
2154 {
2155 Eina_Rectangle *rect;
2156
2157 NEW_RECT(rect, ux, uy, uw, uh);
2158 if (rect)
2159 e->render.updates = eina_list_append(e->render.updates,
2160 rect);
2161 }
2162
2163 off_x = cx - ux;
2164 off_y = cy - uy;
2165 /* build obscuring objects list (in order from bottom to top) */
2166 if (alpha)
2167 {
2168 e->engine.func->context_clip_set(e->engine.data.output,
2169 e->engine.data.context,
2170 ux + off_x, uy + off_y, uw, uh);
2171 }
2172 for (i = 0; i < e->obscuring_objects.count; ++i)
2173 {
2174 obj = (Evas_Object_Protected_Data *)eina_array_data_get
2175 (&e->obscuring_objects, i);
2176 if (evas_object_is_in_output_rect(obj->object, obj, ux - fx, uy - fy, uw, uh))
2177 {
2178 OBJ_ARRAY_PUSH(&e->temporary_objects, obj);
2179
2180 /* reset the background of the area if needed (using cutout and engine alpha flag to help) */
2181 if (alpha)
2182 _evas_render_cutout_add(e, obj, off_x + fx, off_y + fy);
2183 }
2184 }
2185 if (alpha)
2186 {
2187 e->engine.func->context_color_set(e->engine.data.output,
2188 e->engine.data.context,
2189 0, 0, 0, 0);
2190 e->engine.func->context_multiplier_unset
2191 (e->engine.data.output, e->engine.data.context);
2192 e->engine.func->context_render_op_set(e->engine.data.output,
2193 e->engine.data.context,
2194 EVAS_RENDER_COPY);
2195 e->engine.func->rectangle_draw(e->engine.data.output,
2196 e->engine.data.context,
2197 surface,
2198 cx, cy, cw, ch, do_async);
2199 e->engine.func->context_cutout_clear(e->engine.data.output,
2200 e->engine.data.context);
2201 e->engine.func->context_clip_unset(e->engine.data.output,
2202 e->engine.data.context);
2203 }
2204 eina_evlog("-render_setup", eo_e, 0.0, NULL);
2205
2206 eina_evlog("+render_objects", eo_e, 0.0, NULL);
2207 /* render all object that intersect with rect */
2208 for (i = 0; i < e->active_objects.count; ++i)
2209 {
2210 obj = eina_array_data_get(&e->active_objects, i);
2211 eo_obj = obj->object;
2212
2213 /* if it's in our outpout rect and it doesn't clip anything */
2214 RD(0, " OBJ: [%p", obj);
2215 IFRD(0, " '%s'", obj->name);
2216 RD(0, "] '%s' %i %i %ix%i\n", obj->type, obj->cur->geometry.x, obj->cur->geometry.y, obj->cur->geometry.w, obj->cur->geometry.h);
2217 if ((evas_object_is_in_output_rect(eo_obj, obj, ux - fx, uy - fy, uw, uh) ||
2218 (obj->is_smart)) &&
2219 (!obj->clip.clipees) &&
2220 (obj->cur->visible) &&
2221 (!obj->delete_me) &&
2222 (obj->cur->cache.clip.visible) &&
2223 // (!obj->is_smart) &&
2224 ((obj->cur->color.a > 0 || obj->cur->render_op != EVAS_RENDER_BLEND)))
2225 {
2226 int x, y, w, h;
2227
2228 RD(0, " DRAW (vis: %i, a: %i, clipees: %p)\n", obj->cur->visible, obj->cur->color.a, obj->clip.clipees);
2229 if ((e->temporary_objects.count > *offset) &&
2230 (eina_array_data_get(&e->temporary_objects, *offset) == obj))
2231 (*offset)++;
2232 x = cx; y = cy; w = cw; h = ch;
2233 if (((w > 0) && (h > 0)) || (obj->is_smart))
2234 {
2235 Evas_Object_Protected_Data *prev_mask = NULL;
2236 Evas_Object_Protected_Data *mask = NULL;
2237
2238 if (!obj->is_smart)
2239 {
2240 RECTS_CLIP_TO_RECT(x, y, w, h,
2241 obj->cur->cache.clip.x + off_x + fx,
2242 obj->cur->cache.clip.y + off_y + fy,
2243 obj->cur->cache.clip.w,
2244 obj->cur->cache.clip.h);
2245 }
2246
2247 e->engine.func->context_clip_set(e->engine.data.output,
2248 e->engine.data.context,
2249 x, y, w, h);
2250
2251 /* Clipper masks */
2252 if (_evas_render_object_is_mask(obj->cur->clipper))
2253 mask = obj->cur->clipper; // main object clipped by this mask
2254 else if (obj->clip.mask)
2255 mask = obj->clip.mask; // propagated clip
2256 prev_mask = obj->clip.prev_mask;
2257
2258 if (mask)
2259 {
2260 if (mask->mask->redraw || !mask->mask->surface)
2261 evas_render_mask_subrender(obj->layer->evas, mask, prev_mask, 4);
2262
2263 if (mask->mask->surface)
2264 {
2265 e->engine.func->context_clip_image_set
2266 (e->engine.data.output,
2267 e->engine.data.context,
2268 mask->mask->surface,
2269 mask->cur->geometry.x + off_x,
2270 mask->cur->geometry.y + off_y,
2271 e, do_async);
2272 }
2273 }
2274
2275#if 1 /* FIXME: this can slow things down... figure out optimum... coverage */
2276 for (j = *offset; j < e->temporary_objects.count; ++j)
2277 {
2278 Evas_Object_Protected_Data *obj2;
2279
2280 obj2 = (Evas_Object_Protected_Data *)eina_array_data_get
2281 (&e->temporary_objects, j);
2282 _evas_render_cutout_add(e, obj2, off_x + fx, off_y + fy);
2283 }
2284#endif
2285 clean_them |= evas_render_mapped(e, eo_obj, obj, e->engine.data.context,
2286 surface, off_x + fx,
2287 off_y + fy, 0,
2288 cx, cy, cw, ch,
2289 NULL, 4,
2290 EINA_FALSE,
2291 do_async);
2292 e->engine.func->context_cutout_clear(e->engine.data.output,
2293 e->engine.data.context);
2294
2295 if (mask)
2296 {
2297 e->engine.func->context_clip_image_unset
2298 (e->engine.data.output, e->engine.data.context);
2299 }
2300 }
2301 }
2302 }
2303
2304 eina_evlog("-render_objects", eo_e, 0.0, NULL);
2305
2306 eina_evlog("+render_push", eo_e, 0.0, NULL);
2307 e->engine.func->output_redraws_next_update_push(e->engine.data.output,
2308 surface,
2309 ux, uy, uw, uh,
2310 render_mode);
2311 eina_evlog("-render_push", eo_e, 0.0, NULL);
2312
2313 /* free obscuring objects list */
2314 OBJS_ARRAY_CLEAN(&e->temporary_objects);
2315 RD(0, " ---]\n");
2316
2317 return clean_them;
2318}
2319
2320static Eina_Bool
2125evas_render_updates_internal(Evas *eo_e, 2321evas_render_updates_internal(Evas *eo_e,
2126 unsigned char make_updates, 2322 unsigned char make_updates,
2127 unsigned char do_draw, 2323 unsigned char do_draw,
@@ -2133,17 +2329,14 @@ evas_render_updates_internal(Evas *eo_e,
2133 Evas_Object_Protected_Data *obj; 2329 Evas_Object_Protected_Data *obj;
2134 Evas_Public_Data *e; 2330 Evas_Public_Data *e;
2135 Eina_List *ll; 2331 Eina_List *ll;
2136 void *surface;
2137 Eina_Bool clean_them = EINA_FALSE; 2332 Eina_Bool clean_them = EINA_FALSE;
2138 Eina_Bool alpha; 2333 Eina_Bool alpha;
2139 Eina_Rectangle *r; 2334 Eina_Rectangle *r;
2140 int ux, uy, uw, uh; 2335 unsigned int i;
2141 int cx, cy, cw, ch;
2142 unsigned int i, j;
2143 int redraw_all = 0; 2336 int redraw_all = 0;
2144 Eina_Bool haveup = 0; 2337 Evas_Render_Mode render_mode = !do_async ?
2145 Evas_Render_Mode render_mode = EVAS_RENDER_MODE_UNDEF; 2338 EVAS_RENDER_MODE_SYNC :
2146 2339 EVAS_RENDER_MODE_ASYNC_INIT;
2147 Eina_Rectangle clip_rect; 2340 Eina_Rectangle clip_rect;
2148 2341
2149 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 2342 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
@@ -2370,9 +2563,13 @@ evas_render_updates_internal(Evas *eo_e,
2370 eina_evlog("+render_phase6", eo_e, 0.0, NULL); 2563 eina_evlog("+render_phase6", eo_e, 0.0, NULL);
2371 if (do_draw) 2564 if (do_draw)
2372 { 2565 {
2566 void *surface;
2567 int ux, uy, uw, uh;
2568 int cx, cy, cw, ch;
2373 unsigned int offset = 0; 2569 unsigned int offset = 0;
2374 int fx = e->framespace.x; 2570 int fx = e->framespace.x;
2375 int fy = e->framespace.y; 2571 int fy = e->framespace.y;
2572 Eina_Bool haveup = EINA_FALSE;
2376 2573
2377 if (do_async) _evas_render_busy_begin(); 2574 if (do_async) _evas_render_busy_begin();
2378 eina_evlog("+render_surface", eo_e, 0.0, NULL); 2575 eina_evlog("+render_surface", eo_e, 0.0, NULL);
@@ -2382,184 +2579,15 @@ evas_render_updates_internal(Evas *eo_e,
2382 &ux, &uy, &uw, &uh, 2579 &ux, &uy, &uw, &uh,
2383 &cx, &cy, &cw, &ch))) 2580 &cx, &cy, &cw, &ch)))
2384 { 2581 {
2385 int off_x, off_y;
2386 Render_Updates *ru;
2387
2388 eina_evlog("+render_setup", eo_e, 0.0, NULL);
2389 RD(0, " [--- UPDATE %i %i %ix%i\n", ux, uy, uw, uh);
2390 if (do_async)
2391 {
2392 ru = malloc(sizeof(*ru));
2393 ru->surface = surface;
2394 NEW_RECT(ru->area, ux, uy, uw, uh);
2395 e->render.updates = eina_list_append(e->render.updates, ru);
2396 evas_cache_image_ref(surface);
2397 }
2398 else if (make_updates)
2399 {
2400 Eina_Rectangle *rect;
2401
2402 NEW_RECT(rect, ux, uy, uw, uh);
2403 if (rect)
2404 e->render.updates = eina_list_append(e->render.updates,
2405 rect);
2406 }
2407 haveup = EINA_TRUE; 2582 haveup = EINA_TRUE;
2408 off_x = cx - ux;
2409 off_y = cy - uy;
2410 /* build obscuring objects list (in order from bottom to top) */
2411 if (alpha)
2412 {
2413 e->engine.func->context_clip_set(e->engine.data.output,
2414 e->engine.data.context,
2415 ux + off_x, uy + off_y, uw, uh);
2416 }
2417 for (i = 0; i < e->obscuring_objects.count; ++i)
2418 {
2419 obj = (Evas_Object_Protected_Data *)eina_array_data_get
2420 (&e->obscuring_objects, i);
2421 if (evas_object_is_in_output_rect(obj->object, obj, ux - fx, uy - fy, uw, uh))
2422 {
2423 OBJ_ARRAY_PUSH(&e->temporary_objects, obj);
2424
2425 /* reset the background of the area if needed (using cutout and engine alpha flag to help) */
2426 if (alpha)
2427 _evas_render_cutout_add(e, obj, off_x + fx, off_y + fy);
2428 }
2429 }
2430 if (alpha)
2431 {
2432 e->engine.func->context_color_set(e->engine.data.output,
2433 e->engine.data.context,
2434 0, 0, 0, 0);
2435 e->engine.func->context_multiplier_unset
2436 (e->engine.data.output, e->engine.data.context);
2437 e->engine.func->context_render_op_set(e->engine.data.output,
2438 e->engine.data.context,
2439 EVAS_RENDER_COPY);
2440 e->engine.func->rectangle_draw(e->engine.data.output,
2441 e->engine.data.context,
2442 surface,
2443 cx, cy, cw, ch, do_async);
2444 e->engine.func->context_cutout_clear(e->engine.data.output,
2445 e->engine.data.context);
2446 e->engine.func->context_clip_unset(e->engine.data.output,
2447 e->engine.data.context);
2448 }
2449 eina_evlog("-render_setup", eo_e, 0.0, NULL);
2450
2451 eina_evlog("+render_objects", eo_e, 0.0, NULL);
2452 /* render all object that intersect with rect */
2453 for (i = 0; i < e->active_objects.count; ++i)
2454 {
2455 obj = eina_array_data_get(&e->active_objects, i);
2456 eo_obj = obj->object;
2457
2458 /* if it's in our outpout rect and it doesn't clip anything */
2459 RD(0, " OBJ: [%p", obj);
2460 IFRD(obj->name, 0, " '%s'", obj->name);
2461 RD(0, "] '%s' %i %i %ix%i\n", obj->type, obj->cur->geometry.x, obj->cur->geometry.y, obj->cur->geometry.w, obj->cur->geometry.h);
2462 if ((evas_object_is_in_output_rect(eo_obj, obj, ux - fx, uy - fy, uw, uh) ||
2463 (obj->is_smart)) &&
2464 (!obj->clip.clipees) &&
2465 (obj->cur->visible) &&
2466 (!obj->delete_me) &&
2467 (obj->cur->cache.clip.visible) &&
2468// (!obj->is_smart) &&
2469 ((obj->cur->color.a > 0 || obj->cur->render_op != EVAS_RENDER_BLEND)))
2470 {
2471 int x, y, w, h;
2472
2473 RD(0, " DRAW (vis: %i, a: %i, clipees: %p)\n", obj->cur->visible, obj->cur->color.a, obj->clip.clipees);
2474 if ((e->temporary_objects.count > offset) &&
2475 (eina_array_data_get(&e->temporary_objects, offset) == obj))
2476 offset++;
2477 x = cx; y = cy; w = cw; h = ch;
2478 if (((w > 0) && (h > 0)) || (obj->is_smart))
2479 {
2480 Evas_Object_Protected_Data *prev_mask = NULL;
2481 Evas_Object_Protected_Data *mask = NULL;
2482
2483 if (!obj->is_smart)
2484 {
2485 RECTS_CLIP_TO_RECT(x, y, w, h,
2486 obj->cur->cache.clip.x + off_x + fx,
2487 obj->cur->cache.clip.y + off_y + fy,
2488 obj->cur->cache.clip.w,
2489 obj->cur->cache.clip.h);
2490 }
2491
2492 e->engine.func->context_clip_set(e->engine.data.output,
2493 e->engine.data.context,
2494 x, y, w, h);
2495
2496 /* Clipper masks */
2497 if (_evas_render_object_is_mask(obj->cur->clipper))
2498 mask = obj->cur->clipper; // main object clipped by this mask
2499 else if (obj->clip.mask)
2500 mask = obj->clip.mask; // propagated clip
2501 prev_mask = obj->clip.prev_mask;
2502
2503 if (mask)
2504 {
2505 if (mask->mask->redraw || !mask->mask->surface)
2506 evas_render_mask_subrender(obj->layer->evas, mask, prev_mask, 4);
2507
2508 if (mask->mask->surface)
2509 {
2510 e->engine.func->context_clip_image_set
2511 (e->engine.data.output,
2512 e->engine.data.context,
2513 mask->mask->surface,
2514 mask->cur->geometry.x + off_x,
2515 mask->cur->geometry.y + off_y,
2516 e, do_async);
2517 }
2518 }
2519 2583
2520#if 1 /* FIXME: this can slow things down... figure out optimum... coverage */ 2584 clean_them |= evas_render_updates_internal_loop(eo_e, e, surface,
2521 for (j = offset; j < e->temporary_objects.count; ++j)
2522 {
2523 Evas_Object_Protected_Data *obj2;
2524
2525 obj2 = (Evas_Object_Protected_Data *)eina_array_data_get
2526 (&e->temporary_objects, j);
2527 _evas_render_cutout_add(e, obj2, off_x + fx, off_y + fy);
2528 }
2529#endif
2530 clean_them |= evas_render_mapped(e, eo_obj, obj, e->engine.data.context,
2531 surface, off_x + fx,
2532 off_y + fy, 0,
2533 cx, cy, cw, ch,
2534 NULL, 4,
2535 EINA_FALSE,
2536 do_async);
2537 e->engine.func->context_cutout_clear(e->engine.data.output,
2538 e->engine.data.context);
2539
2540 if (mask)
2541 {
2542 e->engine.func->context_clip_image_unset
2543 (e->engine.data.output, e->engine.data.context);
2544 }
2545 }
2546 }
2547 }
2548 eina_evlog("-render_objects", eo_e, 0.0, NULL);
2549
2550 if (!do_async) render_mode = EVAS_RENDER_MODE_SYNC;
2551 else render_mode = EVAS_RENDER_MODE_ASYNC_INIT;
2552
2553 eina_evlog("+render_push", eo_e, 0.0, NULL);
2554 e->engine.func->output_redraws_next_update_push(e->engine.data.output,
2555 surface,
2556 ux, uy, uw, uh, 2585 ux, uy, uw, uh,
2557 render_mode); 2586 cx, cy, cw, ch,
2558 eina_evlog("-render_push", eo_e, 0.0, NULL); 2587 fx, fy, alpha,
2559 2588 make_updates, do_async,
2560 /* free obscuring objects list */ 2589 render_mode,
2561 OBJS_ARRAY_CLEAN(&e->temporary_objects); 2590 &offset);
2562 RD(0, " ---]\n");
2563 } 2591 }
2564 2592
2565 eina_evlog("+render_output_flush", eo_e, 0.0, NULL); 2593 eina_evlog("+render_output_flush", eo_e, 0.0, NULL);