summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-07-24 18:32:07 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:13 +0900
commitdb66f69104914814831b030c78d9e125d7fcf3cf (patch)
tree35b4c5408dbfc91551609447535f2844a770696b /src/bin
parentee74562bf00d7cc7949489c0d9b8e9a0c61fa1a0 (diff)
evas/cserve2: _cserve2_cache_fast_scaling_check()
Adapt function to new Data/Entry model.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/evas/evas_cserve2_cache.c154
1 files changed, 82 insertions, 72 deletions
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index cfb049fa87..b1fc2ee8dd 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -1353,7 +1353,7 @@ cserve2_cache_client_del(Client *client)
1353static Image_Entry * 1353static Image_Entry *
1354_image_entry_new(Client *client, int rid, 1354_image_entry_new(Client *client, int rid,
1355 unsigned int client_file_id, unsigned int client_image_id, 1355 unsigned int client_file_id, unsigned int client_image_id,
1356 Evas_Image_Load_Opts *opts, char *buf) 1356 Evas_Image_Load_Opts *opts, char *buf, size_t buf_size)
1357{ 1357{
1358 Reference *ref, *oldref; 1358 Reference *ref, *oldref;
1359 Image_Entry *ientry; 1359 Image_Entry *ientry;
@@ -1424,15 +1424,19 @@ _image_entry_new(Client *client, int rid,
1424 idata->refcount = 1; 1424 idata->refcount = 1;
1425 idata->id = image_id; 1425 idata->id = image_id;
1426 1426
1427 _image_key_set(idata->file_id, opts, buf, sizeof(buf)); 1427 _image_key_set(idata->file_id, opts, buf, buf_size);
1428 eina_hash_add(image_entries, &image_id, ientry); 1428 eina_hash_add(image_entries, &image_id, ientry);
1429 eina_hash_add(image_ids, buf, (void *)(intptr_t) image_id); 1429 eina_hash_add(image_ids, buf, (void *)(intptr_t) image_id);
1430 1430
1431 oldref = eina_hash_find(client->images.referencing, &client_image_id); 1431 if (client_image_id)
1432 ref = _entry_reference_add(ASENTRY(ientry), client, client_image_id); 1432 {
1433 if (oldref) 1433 oldref = eina_hash_find(client->images.referencing, &client_image_id);
1434 eina_hash_del_by_key(client->images.referencing, &client_image_id); 1434 ref = _entry_reference_add(ASENTRY(ientry), client, client_image_id);
1435 eina_hash_add(client->images.referencing, &client_image_id, ref); 1435 if (oldref)
1436 eina_hash_del_by_key(client->images.referencing, &client_image_id);
1437 eina_hash_add(client->images.referencing, &client_image_id, ref);
1438 }
1439 // else: See _cserve2_cache_fast_scaling_check()
1436 1440
1437 return ientry; 1441 return ientry;
1438} 1442}
@@ -2485,8 +2489,9 @@ static int
2485_cserve2_cache_fast_scaling_check(Client *client, Image_Entry *ientry) 2489_cserve2_cache_fast_scaling_check(Client *client, Image_Entry *ientry)
2486{ 2490{
2487 Eina_Iterator *iter; 2491 Eina_Iterator *iter;
2488 Image_Data *i; 2492 Image_Entry *i;
2489 Image_Entry *original = NULL; 2493 Image_Entry *orig_entry = NULL;
2494 Image_Data *orig_data = NULL;
2490 Evas_Image_Load_Opts unscaled; 2495 Evas_Image_Load_Opts unscaled;
2491 char buf[4096]; 2496 char buf[4096];
2492 unsigned int image_id; 2497 unsigned int image_id;
@@ -2496,42 +2501,41 @@ _cserve2_cache_fast_scaling_check(Client *client, Image_Entry *ientry)
2496 File_Entry *fentry; 2501 File_Entry *fentry;
2497 Image_Data *idata; 2502 Image_Data *idata;
2498 2503
2499 return -1;
2500#if 0
2501 if (!ientry) return -1; 2504 if (!ientry) return -1;
2502
2503 idata = _image_data_find(ENTRYID(ientry)); 2505 idata = _image_data_find(ENTRYID(ientry));
2504 if (!idata) return -1; 2506 if (!idata) return -1;
2505 2507
2506 dst_w = entry->opts.scale_load.dst_w; 2508 dst_w = idata->opts.scale_load.dst_w;
2507 dst_h = entry->opts.scale_load.dst_h; 2509 dst_h = idata->opts.scale_load.dst_h;
2508 2510
2509 // Copy opts w/o scaling 2511 // Copy opts w/o scaling
2510 memset(&unscaled, 0, sizeof(unscaled)); 2512 memset(&unscaled, 0, sizeof(unscaled));
2511 unscaled.dpi = entry->opts.dpi; 2513 unscaled.dpi = idata->opts.dpi;
2512 //unscaled.w = entry->opts.w; 2514 //unscaled.w = idata->opts.w;
2513 //unscaled.h = entry->opts.h; 2515 //unscaled.h = idata->opts.h;
2514 //unscaled.scale_down_by = entry->opts.scale_down_by; 2516 //unscaled.scale_down_by = idata->opts.scale_down_by;
2515 //unscaled.region.x = entry->opts.region.x; 2517 //unscaled.region.x = idata->opts.region.x;
2516 //unscaled.region.y = entry->opts.region.y; 2518 //unscaled.region.y = idata->opts.region.y;
2517 //unscaled.region.w = entry->opts.region.w; 2519 //unscaled.region.w = idata->opts.region.w;
2518 //unscaled.region.h = entry->opts.region.h; 2520 //unscaled.region.h = idata->opts.region.h;
2519 unscaled.scale_load.scale_hint = 0; 2521 unscaled.scale_load.scale_hint = 0;
2520 unscaled.degree = entry->opts.degree; 2522 unscaled.degree = idata->opts.degree;
2521 unscaled.orientation = entry->opts.orientation; 2523 unscaled.orientation = idata->opts.orientation;
2522 unscaled.scale_load.smooth = entry->opts.scale_load.smooth; 2524 unscaled.scale_load.smooth = idata->opts.scale_load.smooth;
2523 2525
2524try_again: 2526try_again:
2525 image_id = _image_opts_id_get(entry->file_id, &unscaled, buf, sizeof(buf)); 2527 image_id = _image_opts_id_get(idata->file_id, &unscaled, buf, sizeof(buf));
2526 if (image_id) 2528 if (image_id)
2527 { 2529 {
2528 original = eina_hash_find(image_entries, &image_id); 2530 orig_data = _image_data_find(image_id);
2529 if (!original) return -1; // Should not happen 2531 orig_entry = _image_entry_find(image_id);
2532 if (!orig_data || !orig_entry) return -1;
2533
2530 DBG("Found original image in hash: %d,%d:%dx%d -> %dx%d shm %p", 2534 DBG("Found original image in hash: %d,%d:%dx%d -> %dx%d shm %p",
2531 original->opts.scale_load.src_x, original->opts.scale_load.src_y, 2535 orig_data->opts.scale_load.src_x, orig_data->opts.scale_load.src_y,
2532 original->opts.scale_load.src_w, original->opts.scale_load.src_h, 2536 orig_data->opts.scale_load.src_w, orig_data->opts.scale_load.src_h,
2533 original->opts.scale_load.dst_w, original->opts.scale_load.dst_h, 2537 orig_data->opts.scale_load.dst_w, orig_data->opts.scale_load.dst_h,
2534 original->shm); 2538 orig_entry->shm);
2535 goto do_scaling; 2539 goto do_scaling;
2536 } 2540 }
2537 2541
@@ -2542,85 +2546,91 @@ try_again:
2542 goto try_again; 2546 goto try_again;
2543 } 2547 }
2544 2548
2545 fentry = _file_entry_find(entry->file_id); 2549 fentry = _file_entry_find(idata->file_id);
2546 iter = eina_list_iterator_new(fentry->images); 2550 iter = eina_list_iterator_new(fentry->images);
2547 //iter = eina_list_iterator_new(entry->file->images);
2548 EINA_ITERATOR_FOREACH(iter, i) 2551 EINA_ITERATOR_FOREACH(iter, i)
2549 { 2552 {
2550 if (i == entry) continue; 2553 Image_Data *id;
2551 if (i->opts.w && i->opts.h && 2554
2552 (!i->opts.scale_load.dst_w && !i->opts.scale_load.dst_h)) 2555 if (i == ientry) continue;
2556 id = _image_data_find(ENTRYID(i));
2557 if (!id) continue;
2558
2559 if (id->opts.w && id->opts.h &&
2560 (!id->opts.scale_load.dst_w &&
2561 !id->opts.scale_load.dst_h))
2553 { 2562 {
2554 DBG("Found image in list: %d,%d:%dx%d -> %dx%d shm %p", 2563 DBG("Found image in list: %d,%d:%dx%d -> %dx%d shm %p",
2555 i->opts.scale_load.src_x, i->opts.scale_load.src_y, 2564 id->opts.scale_load.src_x, id->opts.scale_load.src_y,
2556 i->opts.scale_load.src_w, i->opts.scale_load.src_h, 2565 id->opts.scale_load.src_w, id->opts.scale_load.src_h,
2557 i->opts.scale_load.dst_w, i->opts.scale_load.dst_h, 2566 id->opts.scale_load.dst_w, id->opts.scale_load.dst_h,
2558 i->shm); 2567 i->shm);
2559 if (i->base.request || !i->shm) continue; // Not loaded yet 2568 if (i->base.request || !i->shm) continue; // Not loaded yet
2560 original = i; 2569 orig_entry = i;
2561 break; 2570 break;
2562 } 2571 }
2563 scaled_count++; 2572 scaled_count++;
2564 } 2573 }
2565 eina_iterator_free(iter); 2574 eina_iterator_free(iter);
2566 2575
2567 if (!original) 2576 if (!orig_entry)
2568 { 2577 {
2569 DBG("Found %d scaled images for image %u but none matches", 2578 DBG("Found %d scaled images for image %u but none matches",
2570 scaled_count, entry->base.id); 2579 scaled_count, ENTRYID(ientry));
2571 2580
2581 // FIXME: The value 4 is completely arbitrary. No benchmarks done yet.
2572 if (scaled_count >= 4) 2582 if (scaled_count >= 4)
2573 { 2583 {
2574 DBG("Forcing load of original image now!"); 2584 DBG("Forcing load of original image now!");
2575 2585
2576 original = _image_entry_new(client, 0, entry->file_id, 2586 orig_entry = _image_entry_new(client, 0, idata->file_id,
2577 0, &unscaled); 2587 0, &unscaled, buf, sizeof(buf));
2578 if (!original) return -1; 2588 if (!orig_entry) return -1;
2579 2589 _entry_unused_push(orig_entry);
2580 // NOTE: NOT NEEDED ANYMORE. FIXME
2581 eina_hash_add(image_entries, &image_id, original);
2582 eina_hash_add(image_ids, buf, (void *)(intptr_t)image_id);
2583 _entry_unused_push(original);
2584 2590
2585 fentry = _file_entry_find(original->file_id); 2591 orig_data = _image_data_find(ENTRYID(orig_entry));
2586 fentry->images = eina_list_append(fentry->images, original); 2592 fentry = _file_entry_find(orig_data->file_id);
2593 fentry->images = eina_list_append(fentry->images, orig_entry);
2587 } 2594 }
2588 else 2595 else
2589 return -1; 2596 return -1;
2590 } 2597 }
2591 2598
2592do_scaling: 2599do_scaling:
2593 if (!original) return -1; 2600 if (!orig_entry || !orig_data) return -1;
2594 if (!original->shm && !original->base.request) 2601 if (!orig_entry->shm && !orig_entry->base.request)
2595 { 2602 {
2596 if (original->base.id != image_id) abort(); 2603 if (orig_entry->base.id != image_id)
2597 original->base.request = cserve2_request_add( 2604 {
2605 CRIT("Entry IDs mismatch");
2606 return -1;
2607 }
2608 orig_entry->base.request = cserve2_request_add(
2598 CSERVE2_REQ_IMAGE_LOAD, 2609 CSERVE2_REQ_IMAGE_LOAD,
2599 0, NULL, 0, &_load_funcs, original); 2610 0, NULL, 0, &_load_funcs, orig_entry);
2600 } 2611 }
2601 if (original->base.request || !original->shm) 2612 if (orig_entry->base.request || !orig_entry->shm)
2602 return -1; // Not loaded yet 2613 return -1; // Not loaded yet
2603 2614
2604 if (entry->shm) 2615 if (ientry->shm)
2605 cserve2_shm_unref(entry->shm); 2616 cserve2_shm_unref(ientry->shm);
2606 2617
2607 entry->shm = cserve2_shm_request("img", dst_w * dst_h * 4); 2618 ientry->shm = cserve2_shm_request("img", dst_w * dst_h * 4);
2608 if (!entry->shm) return -1; 2619 if (!ientry->shm) return -1;
2609 2620
2610 if (_scaling_do(entry->shm, entry, original) != 0) 2621 if (_scaling_do(ientry->shm, idata, orig_entry) != 0)
2611 { 2622 {
2612 cserve2_shm_unref(entry->shm); 2623 cserve2_shm_unref(ientry->shm);
2613 entry->shm = NULL; 2624 ientry->shm = NULL;
2614 return -1; 2625 return -1;
2615 } 2626 }
2616 2627
2617 if (original->unused) 2628 if (orig_data->unused)
2618 { 2629 {
2619 image_entries_lru = eina_list_remove(image_entries_lru, original); 2630 image_entries_lru = eina_list_remove(image_entries_lru, orig_entry);
2620 image_entries_lru = eina_list_prepend(image_entries_lru, original); 2631 image_entries_lru = eina_list_prepend(image_entries_lru, orig_entry);
2621 } 2632 }
2622 return 0; 2633 return 0;
2623#endif
2624} 2634}
2625 2635
2626int 2636int
@@ -2683,7 +2693,7 @@ cserve2_cache_image_entry_create(Client *client, int rid,
2683 } 2693 }
2684 2694
2685 ientry = _image_entry_new(client, rid, client_file_id, client_image_id, 2695 ientry = _image_entry_new(client, rid, client_file_id, client_image_id,
2686 opts, buf); 2696 opts, buf, sizeof(buf));
2687 if (!ientry) 2697 if (!ientry)
2688 return -1; 2698 return -1;
2689 2699