diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/bin/edje_cc_out.c | 168 |
1 files changed, 154 insertions, 14 deletions
diff --git a/libraries/edje/src/bin/edje_cc_out.c b/libraries/edje/src/bin/edje_cc_out.c index 5050ad4..b4c541c 100644 --- a/libraries/edje/src/bin/edje_cc_out.c +++ b/libraries/edje/src/bin/edje_cc_out.c | |||
@@ -2,21 +2,30 @@ | |||
2 | # include "config.h" | 2 | # include "config.h" |
3 | #endif | 3 | #endif |
4 | 4 | ||
5 | #ifdef STDC_HEADERS | ||
6 | # include <stdlib.h> | ||
7 | # include <stddef.h> | ||
8 | #else | ||
9 | # ifdef HAVE_STDLIB_H | ||
10 | # include <stdlib.h> | ||
11 | # endif | ||
12 | #endif | ||
5 | #ifdef HAVE_ALLOCA_H | 13 | #ifdef HAVE_ALLOCA_H |
6 | # include <alloca.h> | 14 | # include <alloca.h> |
7 | #elif defined __GNUC__ | 15 | #elif !defined alloca |
8 | # define alloca __builtin_alloca | 16 | # ifdef __GNUC__ |
9 | #elif defined _AIX | 17 | # define alloca __builtin_alloca |
10 | # define alloca __alloca | 18 | # elif defined _AIX |
11 | #elif defined _MSC_VER | 19 | # define alloca __alloca |
12 | # include <malloc.h> | 20 | # elif defined _MSC_VER |
13 | # define alloca _alloca | 21 | # include <malloc.h> |
14 | #else | 22 | # define alloca _alloca |
15 | # include <stddef.h> | 23 | # elif !defined HAVE_ALLOCA |
16 | # ifdef __cplusplus | 24 | # ifdef __cplusplus |
17 | extern "C" | 25 | extern "C" |
18 | # endif | 26 | # endif |
19 | void *alloca (size_t); | 27 | void *alloca (size_t); |
28 | # endif | ||
20 | #endif | 29 | #endif |
21 | 30 | ||
22 | #include <string.h> | 31 | #include <string.h> |
@@ -102,7 +111,7 @@ struct _Code_Lookup | |||
102 | Eina_Bool set; | 111 | Eina_Bool set; |
103 | }; | 112 | }; |
104 | 113 | ||
105 | static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char *ptr, int len)); | 114 | static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char* ptr, int len)); |
106 | 115 | ||
107 | Edje_File *edje_file = NULL; | 116 | Edje_File *edje_file = NULL; |
108 | Eina_List *edje_collections = NULL; | 117 | Eina_List *edje_collections = NULL; |
@@ -500,7 +509,8 @@ data_write_images(Eet_File *ef, int *image_num, int *input_bytes, int *input_raw | |||
500 | { | 509 | { |
501 | img = &edje_file->image_dir->entries[i]; | 510 | img = &edje_file->image_dir->entries[i]; |
502 | 511 | ||
503 | if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) | 512 | if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL |
513 | || img->entry == NULL) | ||
504 | { | 514 | { |
505 | } | 515 | } |
506 | else | 516 | else |
@@ -1550,6 +1560,23 @@ data_queue_image_lookup(char *name, int *dest, Eina_Bool *set) | |||
1550 | } | 1560 | } |
1551 | 1561 | ||
1552 | void | 1562 | void |
1563 | data_queue_image_remove(int *dest, Eina_Bool *set) | ||
1564 | { | ||
1565 | Eina_List *l; | ||
1566 | Image_Lookup *il; | ||
1567 | |||
1568 | EINA_LIST_FOREACH(image_lookups, l, il) | ||
1569 | { | ||
1570 | if (il->dest == dest && il->set == set) | ||
1571 | { | ||
1572 | image_lookups = eina_list_remove_list(image_lookups, l); | ||
1573 | free(il); | ||
1574 | return ; | ||
1575 | } | ||
1576 | } | ||
1577 | } | ||
1578 | |||
1579 | void | ||
1553 | data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set) | 1580 | data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set) |
1554 | { | 1581 | { |
1555 | Eina_List *l; | 1582 | Eina_List *l; |
@@ -1602,14 +1629,64 @@ data_process_lookups(void) | |||
1602 | Program_Lookup *program; | 1629 | Program_Lookup *program; |
1603 | Group_Lookup *group; | 1630 | Group_Lookup *group; |
1604 | Image_Lookup *image; | 1631 | Image_Lookup *image; |
1632 | Eina_List *l2; | ||
1605 | Eina_List *l; | 1633 | Eina_List *l; |
1634 | Eina_Hash *images_in_use; | ||
1606 | void *data; | 1635 | void *data; |
1636 | Eina_Bool is_lua = EINA_FALSE; | ||
1637 | |||
1638 | /* remove all unreferenced Edje_Part_Collection */ | ||
1639 | EINA_LIST_FOREACH_SAFE(edje_collections, l, l2, pc) | ||
1640 | { | ||
1641 | Edje_Part_Collection_Directory_Entry *alias; | ||
1642 | Edje_Part_Collection_Directory_Entry *find; | ||
1643 | Eina_List *l3; | ||
1644 | unsigned int id = 0; | ||
1645 | unsigned int i; | ||
1646 | |||
1647 | find = eina_hash_find(edje_file->collection, pc->part); | ||
1648 | if (find && find->id == pc->id) | ||
1649 | continue ; | ||
1650 | |||
1651 | EINA_LIST_FOREACH(aliases, l3, alias) | ||
1652 | if (alias->id == pc->id) | ||
1653 | continue ; | ||
1654 | |||
1655 | /* This Edje_Part_Collection is not used at all */ | ||
1656 | edje_collections = eina_list_remove_list(edje_collections, l); | ||
1657 | l3 = eina_list_nth_list(codes, pc->id); | ||
1658 | codes = eina_list_remove_list(codes, l3); | ||
1659 | |||
1660 | /* Unref all image used by that group */ | ||
1661 | for (i = 0; i < pc->parts_count; ++i) | ||
1662 | part_description_image_cleanup(pc->parts[i]); | ||
1663 | |||
1664 | /* Correct all id */ | ||
1665 | EINA_LIST_FOREACH(edje_collections, l3, pc) | ||
1666 | { | ||
1667 | Eina_List *l4; | ||
1668 | |||
1669 | /* Some group could be removed from the collection, but still be referenced by alias */ | ||
1670 | find = eina_hash_find(edje_file->collection, pc->part); | ||
1671 | if (pc->id != find->id) find = NULL; | ||
1672 | |||
1673 | /* Update all matching alias */ | ||
1674 | EINA_LIST_FOREACH(aliases, l4, alias) | ||
1675 | if (pc->id == alias->id) | ||
1676 | alias->id = id; | ||
1677 | |||
1678 | pc->id = id++; | ||
1679 | if (find) find->id = pc->id; | ||
1680 | } | ||
1681 | } | ||
1607 | 1682 | ||
1608 | EINA_LIST_FOREACH(edje_collections, l, pc) | 1683 | EINA_LIST_FOREACH(edje_collections, l, pc) |
1609 | { | 1684 | { |
1610 | unsigned int count = 0; | 1685 | unsigned int count = 0; |
1611 | unsigned int i; | 1686 | unsigned int i; |
1612 | 1687 | ||
1688 | if (pc->lua_script_only) | ||
1689 | is_lua = EINA_TRUE; | ||
1613 | #define PROGRAM_ID_SET(Type, Pc, It, Count) \ | 1690 | #define PROGRAM_ID_SET(Type, Pc, It, Count) \ |
1614 | for (It = 0; It < Pc->programs.Type ## _count; ++It) \ | 1691 | for (It = 0; It < Pc->programs.Type ## _count; ++It) \ |
1615 | { \ | 1692 | { \ |
@@ -1738,13 +1815,15 @@ data_process_lookups(void) | |||
1738 | free(group); | 1815 | free(group); |
1739 | } | 1816 | } |
1740 | 1817 | ||
1818 | images_in_use = eina_hash_string_superfast_new(NULL); | ||
1819 | |||
1741 | EINA_LIST_FREE(image_lookups, image) | 1820 | EINA_LIST_FREE(image_lookups, image) |
1742 | { | 1821 | { |
1743 | Edje_Image_Directory_Entry *de; | ||
1744 | Eina_Bool find = EINA_FALSE; | 1822 | Eina_Bool find = EINA_FALSE; |
1745 | 1823 | ||
1746 | if (edje_file->image_dir) | 1824 | if (edje_file->image_dir) |
1747 | { | 1825 | { |
1826 | Edje_Image_Directory_Entry *de; | ||
1748 | unsigned int i; | 1827 | unsigned int i; |
1749 | 1828 | ||
1750 | for (i = 0; i < edje_file->image_dir->entries_count; ++i) | 1829 | for (i = 0; i < edje_file->image_dir->entries_count; ++i) |
@@ -1760,6 +1839,9 @@ data_process_lookups(void) | |||
1760 | *(image->dest) = de->id; | 1839 | *(image->dest) = de->id; |
1761 | *(image->set) = EINA_FALSE; | 1840 | *(image->set) = EINA_FALSE; |
1762 | find = EINA_TRUE; | 1841 | find = EINA_TRUE; |
1842 | |||
1843 | if (!eina_hash_find(images_in_use, image->name)) | ||
1844 | eina_hash_direct_add(images_in_use, de->entry, de); | ||
1763 | break; | 1845 | break; |
1764 | } | 1846 | } |
1765 | } | 1847 | } |
@@ -1774,10 +1856,20 @@ data_process_lookups(void) | |||
1774 | 1856 | ||
1775 | if ((set->name) && (!strcmp(set->name, image->name))) | 1857 | if ((set->name) && (!strcmp(set->name, image->name))) |
1776 | { | 1858 | { |
1859 | Edje_Image_Directory_Set_Entry *child; | ||
1860 | Eina_List *lc; | ||
1861 | |||
1777 | handle_slave_lookup(image_slave_lookups, image->dest, set->id); | 1862 | handle_slave_lookup(image_slave_lookups, image->dest, set->id); |
1778 | *(image->dest) = set->id; | 1863 | *(image->dest) = set->id; |
1779 | *(image->set) = EINA_TRUE; | 1864 | *(image->set) = EINA_TRUE; |
1780 | find = EINA_TRUE; | 1865 | find = EINA_TRUE; |
1866 | |||
1867 | EINA_LIST_FOREACH(set->entries, lc, child) | ||
1868 | if (!eina_hash_find(images_in_use, child->name)) | ||
1869 | eina_hash_direct_add(images_in_use, child->name, child); | ||
1870 | |||
1871 | if (!eina_hash_find(images_in_use, image->name)) | ||
1872 | eina_hash_direct_add(images_in_use, set->name, set); | ||
1781 | break; | 1873 | break; |
1782 | } | 1874 | } |
1783 | } | 1875 | } |
@@ -1795,6 +1887,54 @@ data_process_lookups(void) | |||
1795 | free(image); | 1887 | free(image); |
1796 | } | 1888 | } |
1797 | 1889 | ||
1890 | if (edje_file->image_dir && !is_lua) | ||
1891 | { | ||
1892 | Edje_Image_Directory_Entry *de; | ||
1893 | Edje_Image_Directory_Set *set; | ||
1894 | unsigned int i; | ||
1895 | |||
1896 | for (i = 0; i < edje_file->image_dir->entries_count; ++i) | ||
1897 | { | ||
1898 | de = edje_file->image_dir->entries + i; | ||
1899 | |||
1900 | if (de->entry && eina_hash_find(images_in_use, de->entry)) | ||
1901 | continue ; | ||
1902 | |||
1903 | if (verbose) | ||
1904 | { | ||
1905 | printf("%s: Image '%s' in ressource 'edje/image/%i' will not be included as it is unused.\n", progname, de->entry, de->id); | ||
1906 | } | ||
1907 | else | ||
1908 | { | ||
1909 | INF("Image '%s' in ressource 'edje/image/%i' will not be included as it is unused.", de->entry, de->id); | ||
1910 | } | ||
1911 | |||
1912 | de->entry = NULL; | ||
1913 | } | ||
1914 | |||
1915 | for (i = 0; i < edje_file->image_dir->sets_count; ++i) | ||
1916 | { | ||
1917 | set = edje_file->image_dir->sets + i; | ||
1918 | |||
1919 | if (set->name && eina_hash_find(images_in_use, set->name)) | ||
1920 | continue ; | ||
1921 | |||
1922 | if (verbose) | ||
1923 | { | ||
1924 | printf("%s: Set '%s' will not be included as it is unused.\n", progname, set->name); | ||
1925 | } | ||
1926 | else | ||
1927 | { | ||
1928 | INF("Set '%s' will not be included as it is unused.", set->name); | ||
1929 | } | ||
1930 | |||
1931 | set->name = NULL; | ||
1932 | set->entries = NULL; | ||
1933 | } | ||
1934 | } | ||
1935 | |||
1936 | eina_hash_free(images_in_use); | ||
1937 | |||
1798 | EINA_LIST_FREE(part_slave_lookups, data) | 1938 | EINA_LIST_FREE(part_slave_lookups, data) |
1799 | free(data); | 1939 | free(data); |
1800 | 1940 | ||