Re: [E-devel] Evas cserve2

2013-10-28 Thread ChunEon Park
Also it will be useful when you post it to the phabricator article.
https://phab.enlightenment.org/phame/post/all/
 

-Regards, Hermet- 

-Original Message-
From: Jean-Philippe Andréj...@videolan.org 
To: Enlightenment developer listenlightenment-devel@lists.sourceforge.net; 
Cc: 
Sent: 2013-10-24 (목) 10:45:31
Subject: [E-devel] Evas cserve2

Dear EFL developers,


TL;DR I'd like to merge my work on cserve2 into EFL master soon. This is a
commit-flood warning mail.


I hope the lucky of you folks who attended EFL dev day 2013 had fun there.
Also I hope this was a productive event and you got the opportunity to
discuss various EFL-related topics.

Amongst those, I trust Cedric made an awesome presentation about cserve2,
and introduced the work I've put on top of what had already been done :-)

Now is about time to merge this work into the master branch, as it's
reached a state where it is (almost?) fast  stable enough to be used to
run E18.

For those who forgot or could not attend, let me summarize what this is all
about:

Evas cserve2 is a caching mechanism for Evas images and font (glyphs) that
is based on a client-server model. A program, evas_cserve2, runs as a
server on the system, waits for commands on a UNIX socket, and loads image
files, image data and font data in memory. The memory is then shared and
exposed in virtual files in /dev/shm and all applications can access it.
This means multiple apps will reuse the exact same resources in memory, and
won't need to duplicate common elements such as font glyphs and theme image
data.

When I first started working on cserve2, it was in an experimentally
working state. That is, it worked pretty well in some situations, but there
were huge performance bottlenecks, that made it impractical to use in
production.

One of the main bottlenecks was the massive amount of IPC involved in just
opening  loading an image. (Example: client A sends a message to cserve2
to OPEN an image, then waits for cserve2 to answer. cserve2 sends a message
to its slave to OPEN that image, receives a message from the slave when
it's done, sends a message back to the client A, ... So far the data itself
is still not even loaded, and client A will have to request the data in a
second message to cserve2...) In particular, most scaling was done on the
server and not on the client side, which means that lots of scaled images
could be cached even when used only once.

So, I worked on reducing unnecessary IPC and optimizing data loading, in
two ways:
- Reuse the scalecache logic for scaled images (cache only images that
would otherwise hit the scalecache, scale on the fly all the rest)
- Implement a shared indexing system, where cserve2 exposes its internal
cache structure to all the clients. The clients can then scan the indexes
(also stored in /dev/shm), bypass part of the heavy IPC and directly open
the data. This works very well for images as they will not change at all
after being fully loaded.

In terms of stability, I've also improved the following:
- Support the GL engine (very basic support right now)
- Support some exotic stuff (eg. animated Gif)
- Allow cserve2 to crash without affecting clients (as long as the system
restarts the server)


The overall objective of cserve2 is to reduce memory usage at the system
level, as applications will share more resources. Also, we can integrate in
the future with E, so that the required resources are loaded ASAP when an
app starts (predict what an app needs before even it has requested them).
So there is a potential performance increase as well, on slower devices at
least.

I've been actually using it for a couple days and it's surprisingly quite
stable ^^.
I will fix bugs as they come [1].


The source code is available in my dev branch (rebased on top of master):
https://git.enlightenment.org/core/efl.git/log/?h=devs/jpeg/cserve2

It's a LOT of commits, so out of question that I push them without previous
notice  discussion :-)
As usual, if there's any bug left, blame Cedric.


Best regards,


[1] I know (only) one bug right now, but sh, don't tell...

-- 
Jean-Philippe André
(jpeg)
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, 

Re: [E-devel] Eolian meta-data parsing

2013-10-28 Thread daniel.za...@samsung.com
Yo,

On 10/28/2013 04:02 AM, Carsten Haitzler (The Rasterman) wrote:
 On Tue, 22 Oct 2013 08:43:14 +0200 Raoul Hecky raoul.he...@gmail.com said:

 I'm also more for json, it allows other tools to parse the files and
 you don't need to learn a new syntax...
 except syntax is pretty moot... it's like saying hey - i can understand
 finnish because they use the same punctuation as english!.

 json is merely the punctuation. the rest is custom vocabulary to eolian.

 if we use json we will end up with doing things like:

 method_name_here_in_quotes: {
return: unsigned long,
params: [
  { type: const char *, var: string }
  { type: unsigned int, var: value }
]
 }

 vs a much easier to read and write (for someone doing C - our audience):

 unsigned long
 method_name_here_in_quotes(const char *string,
 unsigned int value);

 one of them looks like something a developer can read, write and maintain. the
 other looks like it is a database dump. in  json pretty much everything will
 just become strings that you have to eternally quote all the time because a
 type can have a space (unsigned long, const char *, etc.).

 the point of eoilian is to cut down work and boilerplate and make it easy to
 just simply declare in shorthand the obvious classes, inheritance and methods
 that will then GENERATE the C code so you don't have to write mountains of the
 boilerplate.

 both c style and json formats are extensible. arguments that the json is
 instantly understood and the c style is not are bogus - because the work is in
 the vocabulary (which has to be learned in either case), and the c style is
 closer to being directly what we already write just minus some namespacing
 preamble. the json looks alien.
Of course, both are extensible. The problem is the price. When we 
generated the .eo files from the Eo classes, we encountered some issues 
(read-only properties, comments specific, virtual pure) that I will not 
re-explain here. They can be solved in both cases, but in C, it will 
seem more like patches in the language (at least, imo).

 remember daniels example was just covering properties which much more cloesely
 resemble data structures ala json - try actually define real methods with it.
You will have to give an example because most of the EFL functions look 
like that. And if you really want to describe complex functions, like 
something that returns a list of objects, you will have to specify the 
element type (i.e Eo *) for the bindings and it will no more seem like a 
C style (but more like that some C++ template).
 not to mention the c style will indent, format and hilight like c - with
 comments (the description fields) nicely colorized, but to a json syntax
 hilighter its a sea of generic strings all the same color.
Well, for this point, I have the solution :). We can create a simple 
application (that will be used as plug-in in some next century IDE) that 
will show you the eo file colorized, how the C/C++/JS... code will look 
like and so on.

 c style will be more compact, easier to read, write, format, hilight and
 maintain. json is a shortcut bit of trendiness that we will suffer from for
 years. the COST of doing the c style is the parser. that i do understand is
 something undesirable to make, but consider the cost of forcing the verbosity 
 of
 json in when the point is to nuke the verbosity.
I really don't know how the language will evolve (not just the JSON but 
the C one too) and which one is the best for our cause (well, that's why 
I began this discussion;-)). And of course, my preference is for JSON 
(easy parsing and readability really acceptable, at least imo).

 --
 Raoul Hecky


 2013/10/21 Jose Souza zehortig...@profusion.mobi:
 json++


 On Mon, Oct 21, 2013 at 5:38 PM, Davide Andreoli
 d...@gurumeditation.itwrote:

 Json +1 also for me, It is more clear that is a descriptive thing and not
 real code.
 It is also more easily parsable by other tools/languages


 2013/10/21 Gustavo Sverzut Barbieri barbi...@gmail.com

 JSon +1

 On Mon, Oct 21, 2013 at 3:29 PM, daniel.za...@samsung.com
 daniel.za...@samsung.com wrote:
 Hi all,

 I would like to discuss about a project that we are beginning just now.
 I presented it on EFL dev. day yesterday but I would like to share it
 here since it will imply all the EFL developers (yes, you) one day or
 another.

 It is called Eolian and was first aimed to facilitate addition of new
 Eo
 functions by auto-generating code. Then we noted that we can
 automatically generate language bindings too but it is not the goal of
 this discussion.

 The idea is that each Eo class is represented into a .eo file. These
 files are manually modified to add new functions, comments,
 callbacks...
 and parsed and the generation phase updates the C/H files.

 They contain descriptions of inherited classes, properties, methods,
 base classes implemented functions and callbacks.

 We thought about two formats:
 - a C-like format:
 

Re: [E-devel] enventor release. (Tom, Read this)

2013-10-28 Thread ChunEon Park
ok, that will be the first but last request.
 

-Regards, Hermet- 

-Original Message-
From: Steven@este...@enlightenment.org 
To: Enlightenment developer listenlightenment-devel@lists.sourceforge.net; 
Cc: 
Sent: 2013-10-24 (목) 10:16:58
Subject: Re: [E-devel] enventor release. (Tom, Read this)

On Thu, Oct 24, 2013 at 1:46 AM, Daniel Juyung Seo seojuyung2@gmail.comwrote:

 On Thu, Oct 24, 2013 at 8:31 AM, Bertrand Jacquin beber@meleeweb.net
 wrote:

  On 2013-10-23 12:24, ChunEon Park wrote:
   As far as our plan, efl 1.8 will be released in the next month.
   I'm getting to release enventor 0.1 also along with the efl 1.8.
  
   So, I gonna put the enventor under the tools repository at this point
   If nobody object to me.
  
   Tom or Daniel, could you please migrate the enventor from my private
   repo to tools?
 
  Done. I made a copy of your repo, so you're free to remove your personal
  repo.
 
  http://git.enlightenment.org/tools/enventor.git/
 

 Cool Beber!
 Thanks for your job.


reminder : it's not his job ;)

Many thx  to him !



 Daniel Juyung Seo (SeoZ)


 
  --
  Beber
 
 
 
 --
  October Webinars: Code for Performance
  Free Intel webinars can help you accelerate application performance.
  Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
  from
  the latest Intel processors and coprocessors. See abstracts and register
 
 
 http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
  ___
  enlightenment-devel mailing list
  enlightenment-devel@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
 

 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
 from
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [RFC] configure options for maintainers

2013-10-28 Thread The Rasterman
On Mon, 28 Oct 2013 14:45:38 +0900 Cedric BAIL cedric.b...@free.fr said:

 On Mon, Oct 28, 2013 at 11:49 AM, Carsten Haitzler ras...@rasterman.com
 wrote:
  On Sat, 12 Oct 2013 11:43:33 +0900 Jérôme Pinot ngc...@gmail.com said:
 
  great.. but how do you EXTRACT this info then from the lib? :) it's a lib..
  it can't execute on its own... and printfing such strings on every fn call
  is just anti-social :)
 
 I would have said :
  #define EFL_BUILD_DISTRO MyDistro
  #define EFL_BUILD_VENDOR Main Tainer f...@bar.org
  #define EFL_BUILD_VERSION 42

ummm... ok - and so then we have tyo rely on application executables
specifically finding these and printfing them or stuffing them into dialogs?

  Hi,
 
  During the Enlightenment French League^W^W dinner, we had this idea of
  having a configure option for the EFL to setup a string identifying the
  compiler/maintainer/distribution of the build. Several projects use this
  kind of string, for instance TexLive, LibreOffice or POV-Ray. It can be
  use to find quickly the maintainer, to generate automatic bug reports
  and most important, blame someone else (not you, no, really).
 
  There are several way to accomplish this during configuration:
 
  POV-Ray uses the COMPILED_BY=Main Tainer f...@bar.org environment
  variable
 
  TexLive uses --with-banner-add=Tex Live 2013/MyDistro Main Tainer
  f...@bar.org
 
  LibreOffice uses several options:
  --with-distro=MyDistro
  --with-vendor=Main Tainer f...@bar.org
  --with-build-version=42
 
  It seems to me that the LibreOffice options are better.
 
  What do you think about this?
 
  --
  Jérôme Pinot
  http://ngc891.blogdns.net/
 
 
  --
  - Codito, ergo sum - I code, therefore I am --
  The Rasterman (Carsten Haitzler)ras...@rasterman.com
 
 
  --
  October Webinars: Code for Performance
  Free Intel webinars can help you accelerate application performance.
  Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
  from the latest Intel processors and coprocessors. See abstracts and
  register 
  http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
  ___ enlightenment-devel mailing
  list enlightenment-devel@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
 
 
 
 -- 
 Cedric BAIL
 
 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


-- 
- Codito, ergo sum - I code, therefore I am --
The Rasterman (Carsten Haitzler)ras...@rasterman.com


--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[EGIT] [core/efl] master 02/77: evas/cserve2: Prepare usage of shared strings

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=781c2e26e545586378c07339154c50a500b14b99

commit 781c2e26e545586378c07339154c50a500b14b99
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Jul 18 17:54:06 2013 +0900

evas/cserve2: Prepare usage of shared strings

+ Add macros to fake usage of future cserve2 strings functions
+ Rename all File_Entry to fe
+ Other costmetic changes
---
 src/bin/evas/evas_cserve2_cache.c | 363 ++
 1 file changed, 207 insertions(+), 156 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index b9283da..374be45 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -14,6 +14,18 @@
 
 #include Evas_Loader.h
 
+// For testing purposes only.
+#define EXPERIMENTAL_SHARED_INDEX 0
+#if EXPERIMENTAL_SHARED_INDEX
+typedef int string_t;
+#else
+#define cserve2_shared_string_get(str) (str)
+#define cserve2_shared_string_del(str) (eina_stringshare_del(str))
+#define cserve2_shared_string_add(str) (eina_stringshare_add(str))
+#define cserve2_shared_string_ref(str) (eina_stringshare_ref(str))
+typedef Eina_Stringshare* string_t;
+#endif
+
 typedef struct _Entry Entry;
 typedef struct _Reference Reference;
 typedef struct _File_Data File_Data;
@@ -45,13 +57,13 @@ struct _Entry {
 
 struct _File_Data {
Entry base;
-   char *path;
-   char *key;
+   string_t path;
+   string_t key;
+   string_t loader_data;
int w, h;
int frame_count;
int loop_count;
int loop_hint;
-   const char *loader_data;
File_Watch *watcher;
Eina_List *images;
Eina_Bool alpha : 1;
@@ -71,9 +83,9 @@ struct _Image_Data {
 };
 
 struct _Font_Source {
-   const char *key;
-   const char *name;
-   const char *file;
+   string_t key;
+   string_t name;
+   string_t file;
int references;
void *ft;
 };
@@ -225,18 +237,18 @@ _entry_load_reused(Entry *e)
 }
 
 static Msg_Opened *
-_image_opened_msg_create(File_Data *entry, int *size)
+_image_opened_msg_create(File_Data *fe, int *size)
 {
Msg_Opened *msg;
 
msg = calloc(1, sizeof(*msg));
msg-base.type = CSERVE2_OPENED;
-   msg-image.w = entry-w;
-   msg-image.h = entry-h;
-   msg-image.frame_count = entry-frame_count;
-   msg-image.loop_count = entry-loop_count;
-   msg-image.loop_hint = entry-loop_hint;
-   msg-image.alpha = entry-alpha;
+   msg-image.w = fe-w;
+   msg-image.h = fe-h;
+   msg-image.frame_count = fe-frame_count;
+   msg-image.loop_count = fe-loop_count;
+   msg-image.loop_hint = fe-loop_hint;
+   msg-image.alpha = fe-alpha;
 
*size = sizeof(*msg);
 
@@ -244,15 +256,15 @@ _image_opened_msg_create(File_Data *entry, int *size)
 }
 
 static void
-_image_opened_send(Client *client, File_Data *entry, unsigned int rid)
+_image_opened_send(Client *client, File_Data *fe, unsigned int rid)
 {
 int size;
 Msg_Opened *msg;
 
-DBG(Sending OPENED reply for entry: %d and RID: %d., entry-base.id, 
rid);
+DBG(Sending OPENED reply for entry: %d and RID: %d., fe-base.id, rid);
 // clear the struct with possible paddings, since it is not aligned.
 
-msg = _image_opened_msg_create(entry, size);
+msg = _image_opened_msg_create(fe, size);
 msg-base.rid = rid;
 
 cserve2_client_send(client, size, sizeof(size));
@@ -323,32 +335,34 @@ _font_loaded_send(Client *client, unsigned int rid)
 }
 
 static void *
-_open_request_build(File_Data *f, int *bufsize)
+_open_request_build(File_Data *fe, int *bufsize)
 {
+   const char *loader_data;
char *buf;
int size, pathlen, keylen, loaderlen;
Slave_Msg_Image_Open msg;
 
-   pathlen = strlen(f-path) + 1;
-   keylen = strlen(f-key) + 1;
+   pathlen = strlen(cserve2_shared_string_get(fe-path)) + 1;
+   keylen = strlen(cserve2_shared_string_get(fe-key)) + 1;
 
memset(msg, 0, sizeof(msg));
-   msg.has_loader_data = !!f-loader_data;
-   loaderlen = msg.has_loader_data ? (strlen(f-loader_data) + 1) : 0;
+   loader_data = cserve2_shared_string_get(fe-loader_data);
+   msg.has_loader_data = !!loader_data;
+   loaderlen = msg.has_loader_data ? (strlen(loader_data) + 1) : 0;
 
size = sizeof(msg) + pathlen + keylen + loaderlen;
buf = malloc(size);
if (!buf) return NULL;
 
memcpy(buf, msg, sizeof(msg));
-   memcpy(buf + sizeof(msg), f-path, pathlen);
-   memcpy(buf + sizeof(msg) + pathlen, f-key, keylen);
+   memcpy(buf + sizeof(msg), cserve2_shared_string_get(fe-path), pathlen);
+   memcpy(buf + sizeof(msg) + pathlen, cserve2_shared_string_get(fe-key), 
keylen);
if (msg.has_loader_data)
- memcpy(buf + sizeof(msg) + pathlen + keylen, f-loader_data, loaderlen);
+ memcpy(buf + sizeof(msg) + pathlen + keylen, loader_data, loaderlen);
 
*bufsize = size;
 
-   _entry_load_start(f-base);
+   _entry_load_start(fe-base);
 
return buf;
 }
@@ -360,26 +374,26 @@ _request_free(void *msg, void *data EINA_UNUSED)
 }
 
 static Msg_Opened *

[EGIT] [core/efl] master 07/77: evas/cserve2: Use Shared_Array storage for File_Data

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=acae35b4d1cb2a8aa602cc9c1e6de468997de059

commit acae35b4d1cb2a8aa602cc9c1e6de468997de059
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Jul 22 16:28:42 2013 +0900

evas/cserve2: Use Shared_Array storage for File_Data

File_Entry and File_Data are now two different types,
one being stored in the shared array, the other one
is only a reference counting entry.
---
 src/bin/evas/evas_cserve2_cache.c | 457 +-
 src/bin/evas/evas_cserve2_index.c |   5 +-
 2 files changed, 310 insertions(+), 152 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 6075200..d3926e2 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -14,20 +14,15 @@
 
 #include Evas_Loader.h
 
-// For testing purposes only.
-#define EXPERIMENTAL_SHARED_INDEX 0
-#if EXPERIMENTAL_SHARED_INDEX
 typedef int string_t;
-#else
-#define cserve2_shared_string_get(str) (str)
-#define cserve2_shared_string_del(str) (eina_stringshare_del(str))
-#define cserve2_shared_string_add(str) (eina_stringshare_add(str))
-#define cserve2_shared_string_ref(str) (eina_stringshare_ref(str))
-typedef Eina_Stringshare* string_t;
-#endif
+#define ENTRY Entry base
+#define ASENTRY(a) ((a-base))
+#define SHMOBJECT unsigned int id; unsigned int refcount
 
 typedef struct _Entry Entry;
+typedef struct _Shm_Object Shm_Object;
 typedef struct _Reference Reference;
+typedef struct _File_Entry File_Entry;
 typedef struct _File_Data File_Data;
 typedef struct _Image_Data Image_Data;
 typedef struct _File_Watch File_Watch;
@@ -55,8 +50,19 @@ struct _Entry {
 #endif
 };
 
+struct _Shm_Object
+{
+   SHMOBJECT;
+};
+
+struct _File_Entry {
+   ENTRY;
+   File_Watch *watcher;
+   Eina_List *images;
+};
+
 struct _File_Data {
-   Entry base;
+   SHMOBJECT;
string_t path;
string_t key;
string_t loader_data;
@@ -64,8 +70,6 @@ struct _File_Data {
int frame_count;
int loop_count;
int loop_hint;
-   File_Watch *watcher;
-   Eina_List *images;
Eina_Bool alpha : 1;
Eina_Bool invalid : 1;
 };
@@ -74,7 +78,6 @@ struct _File_Data {
 struct _Image_Data {
Entry base;
unsigned int file_id;
-   File_Data *file;
Evas_Image_Load_Opts opts;
Shm_Handle *shm;
Eina_Bool alpha_sparse : 1;
@@ -172,6 +175,8 @@ struct _File_Watch {
 };
 
 static unsigned int _entry_id = 0;
+static Shared_Array *_file_data_array = NULL;
+
 static Eina_Hash *file_ids = NULL; // maps path + key -- file_id
 static Eina_Hash *file_entries = NULL; // maps file_id -- entry
 
@@ -235,6 +240,54 @@ _entry_load_reused(Entry *e)
 #endif
 }
 
+
+static int
+_shm_object_id_find_cb(const void *data1, const void *data2)
+{
+   const Shm_Object *obj;
+   unsigned int key;
+
+   if (data1 == data2) return 0;
+   if (!data1) return 1;
+   if (!data2) return -1;
+
+   obj = data1;
+   key = *((unsigned int *) data2);
+   if (obj-id == key) return 0;
+   if (obj-id  key)
+ return -1;
+   else
+ return +1;
+}
+
+static inline File_Data *
+_file_data_find(unsigned int file_id)
+{
+   File_Data *fd;
+
+   fd = cserve2_shared_array_item_data_find(_file_data_array, file_id,
+_shm_object_id_find_cb);
+   if (fd  !fd-refcount)
+ {
+ERR(Can not access object %u with refcount 0, file_id);
+return NULL;
+ }
+   return fd;
+}
+
+static inline File_Entry *
+_file_entry_find(unsigned int entry_id)
+{
+   Entry *e;
+
+   e = (Entry *) eina_hash_find(file_entries, entry_id);
+   if (!e || e-type != CSERVE2_IMAGE_FILE)
+ return NULL;
+
+   return (File_Entry *) e;
+}
+
+
 static Msg_Opened *
 _image_opened_msg_create(File_Data *fd, int *size)
 {
@@ -260,7 +313,7 @@ _image_opened_send(Client *client, File_Data *fd, unsigned 
int rid)
 int size;
 Msg_Opened *msg;
 
-DBG(Sending OPENED reply for entry: %d and RID: %d., fd-base.id, rid);
+DBG(Sending OPENED reply for entry: %d and RID: %d., fd-id, rid);
 // clear the struct with possible paddings, since it is not aligned.
 
 msg = _image_opened_msg_create(fd, size);
@@ -334,12 +387,20 @@ _font_loaded_send(Client *client, unsigned int rid)
 }
 
 static void *
-_open_request_build(File_Data *fd, int *bufsize)
+_open_request_build(Entry *entry, int *bufsize)
 {
const char *loader_data;
char *buf;
int size, pathlen, keylen, loaderlen;
Slave_Msg_Image_Open msg;
+   File_Data *fd;
+
+   fd = _file_data_find(entry-id);
+   if (!fd)
+ {
+ERR(Could not find file data for entry %u, entry-id);
+return NULL;
+ }
 
pathlen = strlen(cserve2_shared_string_get(fd-path)) + 1;
keylen = strlen(cserve2_shared_string_get(fd-key)) + 1;
@@ -361,7 +422,7 @@ _open_request_build(File_Data *fd, int *bufsize)
 
*bufsize = size;
 
-   _entry_load_start(fd-base);
+   _entry_load_start(entry);
 

[EGIT] [core/efl] master 01/77: evas/cserve2: Add CRIT() macro

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=afde0c892be2f0f472ca465c746a0dedf2e9d41e

commit afde0c892be2f0f472ca465c746a0dedf2e9d41e
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Jul 18 19:18:24 2013 +0900

evas/cserve2: Add CRIT() macro

For easy debugging
---
 src/bin/evas/evas_cserve2.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index cc1a748..158e3e2 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -4,6 +4,10 @@
 #include Eina.h
 #include evas_cs2.h
 
+#ifdef CRIT
+#undef CRIT
+#endif
+#define CRIT(...) EINA_LOG_DOM_CRIT(_evas_cserve2_bin_log_dom, __VA_ARGS__)
 #ifdef ERR
 #undef ERR
 #endif

-- 




[EGIT] [core/efl] master 05/77: evas/cserve2: Use unique id counter

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=12deed8073c0946b261b11e2dd611ff3693a8c3a

commit 12deed8073c0946b261b11e2dd611ff3693a8c3a
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Jul 22 15:27:53 2013 +0900

evas/cserve2: Use unique id counter

Merge file id and image id into a single entry id.
---
 src/bin/evas/evas_cserve2_cache.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 374be45..5c14e7e 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -171,8 +171,7 @@ struct _File_Watch {
Eina_List *entries;
 };
 
-static unsigned int _file_id = 0; // id unique number
-static unsigned int _image_id = 0; // id unique number
+static unsigned int _entry_id = 0;
 static Eina_Hash *file_ids = NULL; // maps path + key -- file_id
 static Eina_Hash *file_entries = NULL; // maps file_id -- entry
 
@@ -2099,9 +2098,9 @@ cserve2_cache_file_open(Client *client, unsigned int 
client_file_id,
 return 0;
  }
 
-   file_id = _file_id++;
+   file_id = ++_entry_id;
while ((file_id == 0) || (eina_hash_find(file_entries, file_id)))
- file_id = _file_id++;
+ file_id = ++_entry_id;
 
DBG(Creating new entry with file_id: %u for file \%s:%s\,
file_id, path, key);
@@ -2243,9 +2242,9 @@ try_again:
  0, unscaled);
  if (!original) return -1;
 
- image_id = _image_id++;
+ image_id = ++_entry_id;
  while ((image_id == 0) || (eina_hash_find(image_entries, 
image_id)))
-   image_id = _image_id++;
+   image_id = ++_entry_id;
  DBG(Creating new image_id: %d, image_id);
 
  original-base.id = image_id;
@@ -2348,9 +2347,9 @@ cserve2_cache_image_entry_create(Client *client, int rid,
 return 0;
  }
 
-   image_id = _image_id++;
+   image_id = ++_entry_id;
while ((image_id == 0) || (eina_hash_find(image_entries, image_id)))
- image_id = _image_id++;
+ image_id = ++_entry_id;
 
entry-base.id = image_id;
eina_hash_add(image_entries, image_id, entry);

-- 




[EGIT] [core/efl] master 03/77: evas/cserve2: Add functions to resize shm files

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=deb8776de5b46e280371fc0db894db96287cf681

commit deb8776de5b46e280371fc0db894db96287cf681
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Jul 18 19:21:58 2013 +0900

evas/cserve2: Add functions to resize shm files

- cserve2_shm_segment_request()
Creates a new shm segment (Shm_Handle) from an existing file,
without changing the current mmap.

- cserve2_shm_resize()
Grows the file and remaps in memory (new virtual address).

- cserve2_shm_id_get()
Returns the shm creation ID.
---
 src/bin/evas/evas_cserve2.h |   3 ++
 src/bin/evas/evas_cserve2_shm.c | 104 +++-
 2 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 158e3e2..e7e53f3 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -264,8 +264,11 @@ void cserve2_message_handler(int fd, Fd_Flags flags, void 
*data);
 void cserve2_shm_init();
 void cserve2_shm_shutdown();
 Shm_Handle *cserve2_shm_request(const char *infix, size_t size);
+Shm_Handle *cserve2_shm_segment_request(Shm_Handle *shm, size_t size);
+Shm_Handle *cserve2_shm_resize(Shm_Handle *shm, size_t newsize);
 void cserve2_shm_unref(Shm_Handle *shm);
 const char *cserve2_shm_name_get(const Shm_Handle *shm);
+int cserve2_shm_id_get(const Shm_Handle *shm);
 off_t cserve2_shm_map_offset_get(const Shm_Handle *shm);
 off_t cserve2_shm_offset_get(const Shm_Handle *shm);
 size_t cserve2_shm_map_size_get(const Shm_Handle *shm);
diff --git a/src/bin/evas/evas_cserve2_shm.c b/src/bin/evas/evas_cserve2_shm.c
index 7dcf05d..2df0bb5 100644
--- a/src/bin/evas/evas_cserve2_shm.c
+++ b/src/bin/evas/evas_cserve2_shm.c
@@ -28,6 +28,7 @@ struct _Shm_Handle
size_t map_size;
size_t image_size;
int refcount;
+   int shmid;
void *data;
 };
 
@@ -77,7 +78,7 @@ cserve2_shm_request(const char *infix, size_t size)
 
do {
 snprintf(shmname, sizeof(shmname), /evas-shm-%x-%s-%08x,
- (int) getuid(), infix, id++);
+ (int) getuid(), infix, ++id);
 fd = shm_open(shmname, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
 if (fd == -1  errno != EEXIST)
   {
@@ -110,6 +111,100 @@ cserve2_shm_request(const char *infix, size_t size)
 
shm-image_size = size;
shm-map_size = map_size;
+   shm-shmid = id;
+
+   return shm;
+}
+
+Shm_Handle *
+cserve2_shm_segment_request(Shm_Handle *shm, size_t size)
+{
+   Shm_Handle *segment;
+   size_t map_size;
+   Shm_Mapping *map = shm-mapping;
+   int fd;
+
+   segment = calloc(1, sizeof (Shm_Handle));
+   if (!segment) return NULL;
+
+   fd = shm_open(map-name, O_RDWR, S_IRUSR | S_IWUSR);
+   if (!fd)
+ {
+ERR(Could not reopen shm handle: %m);
+free(segment);
+return NULL;
+ }
+
+   map_size  = cserve2_shm_size_normalize(size);
+   map_size += map-length;
+
+   if (ftruncate(fd, map_size) == -1)
+ {
+ERR(Could not set the size of the shm: %m);
+close(fd);
+free(segment);
+return NULL;
+ }
+   close(fd);
+
+   segment-mapping= map;
+   segment-map_offset = map-length;
+   segment-map_size   = map_size - map-length;
+   segment-image_size = size;
+   segment-image_offset = segment-map_offset;
+   map-length = map_size;
+   map-segments = eina_inlist_append(map-segments, EINA_INLIST_GET(segment));
+
+   return segment;
+}
+
+Shm_Handle *
+cserve2_shm_resize(Shm_Handle *shm, size_t newsize)
+{
+   size_t map_size;
+   int fd;
+
+   if (!shm)
+ return NULL;
+
+   if (shm-map_offset || shm-image_offset)
+ {
+CRIT(Can not resize shm with non-zero offset);
+return NULL;
+ }
+
+   if (eina_inlist_count(shm-mapping-segments)  1)
+ {
+CRIT(Can not resize shm with more than one segment);
+return NULL;
+ }
+
+   fd = shm_open(shm-mapping-name, O_RDWR, S_IRUSR | S_IWUSR);
+   if (!fd)
+ {
+ERR(Could not reopen shm handle: %m);
+return NULL;
+ }
+
+   map_size  = cserve2_shm_size_normalize(newsize);
+   if (ftruncate(fd, map_size))
+ {
+ERR(Could not set the size of the shm: %m);
+close(fd);
+return NULL;
+ }
+
+   if (shm-data)
+ {
+munmap(shm-data, shm-image_size);
+shm-data = mmap(NULL, shm-image_size, PROT_WRITE, MAP_SHARED,
+ fd, shm-image_offset);
+ }
+   close(fd);
+
+   shm-map_size = map_size;
+   shm-image_size = newsize;
+   shm-mapping-length = map_size;
 
return shm;
 }
@@ -139,6 +234,12 @@ cserve2_shm_name_get(const Shm_Handle *shm)
return shm-mapping-name;
 }
 
+int
+cserve2_shm_id_get(const Shm_Handle *shm)
+{
+   return shm-shmid;
+}
+
 off_t
 cserve2_shm_map_offset_get(const Shm_Handle *shm)
 {
@@ -220,6 +321,7 @@ _cserve2_shm_cleanup()
 else
   DBG(cserve2 cleanup: 

[EGIT] [core/efl] master 06/77: evas/cserve2: Rename File_Data pointers to fd

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c57a319df3fec9272fa46fb3da84d69b8d26f144

commit c57a319df3fec9272fa46fb3da84d69b8d26f144
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Jul 19 13:58:56 2013 +0900

evas/cserve2: Rename File_Data pointers to fd

The name fe is also used by Font_Entry, slightly confusing
---
 src/bin/evas/evas_cserve2_cache.c | 210 +++---
 1 file changed, 105 insertions(+), 105 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 5c14e7e..6075200 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -236,18 +236,18 @@ _entry_load_reused(Entry *e)
 }
 
 static Msg_Opened *
-_image_opened_msg_create(File_Data *fe, int *size)
+_image_opened_msg_create(File_Data *fd, int *size)
 {
Msg_Opened *msg;
 
msg = calloc(1, sizeof(*msg));
msg-base.type = CSERVE2_OPENED;
-   msg-image.w = fe-w;
-   msg-image.h = fe-h;
-   msg-image.frame_count = fe-frame_count;
-   msg-image.loop_count = fe-loop_count;
-   msg-image.loop_hint = fe-loop_hint;
-   msg-image.alpha = fe-alpha;
+   msg-image.w = fd-w;
+   msg-image.h = fd-h;
+   msg-image.frame_count = fd-frame_count;
+   msg-image.loop_count = fd-loop_count;
+   msg-image.loop_hint = fd-loop_hint;
+   msg-image.alpha = fd-alpha;
 
*size = sizeof(*msg);
 
@@ -255,15 +255,15 @@ _image_opened_msg_create(File_Data *fe, int *size)
 }
 
 static void
-_image_opened_send(Client *client, File_Data *fe, unsigned int rid)
+_image_opened_send(Client *client, File_Data *fd, unsigned int rid)
 {
 int size;
 Msg_Opened *msg;
 
-DBG(Sending OPENED reply for entry: %d and RID: %d., fe-base.id, rid);
+DBG(Sending OPENED reply for entry: %d and RID: %d., fd-base.id, rid);
 // clear the struct with possible paddings, since it is not aligned.
 
-msg = _image_opened_msg_create(fe, size);
+msg = _image_opened_msg_create(fd, size);
 msg-base.rid = rid;
 
 cserve2_client_send(client, size, sizeof(size));
@@ -334,18 +334,18 @@ _font_loaded_send(Client *client, unsigned int rid)
 }
 
 static void *
-_open_request_build(File_Data *fe, int *bufsize)
+_open_request_build(File_Data *fd, int *bufsize)
 {
const char *loader_data;
char *buf;
int size, pathlen, keylen, loaderlen;
Slave_Msg_Image_Open msg;
 
-   pathlen = strlen(cserve2_shared_string_get(fe-path)) + 1;
-   keylen = strlen(cserve2_shared_string_get(fe-key)) + 1;
+   pathlen = strlen(cserve2_shared_string_get(fd-path)) + 1;
+   keylen = strlen(cserve2_shared_string_get(fd-key)) + 1;
 
memset(msg, 0, sizeof(msg));
-   loader_data = cserve2_shared_string_get(fe-loader_data);
+   loader_data = cserve2_shared_string_get(fd-loader_data);
msg.has_loader_data = !!loader_data;
loaderlen = msg.has_loader_data ? (strlen(loader_data) + 1) : 0;
 
@@ -354,14 +354,14 @@ _open_request_build(File_Data *fe, int *bufsize)
if (!buf) return NULL;
 
memcpy(buf, msg, sizeof(msg));
-   memcpy(buf + sizeof(msg), cserve2_shared_string_get(fe-path), pathlen);
-   memcpy(buf + sizeof(msg) + pathlen, cserve2_shared_string_get(fe-key), 
keylen);
+   memcpy(buf + sizeof(msg), cserve2_shared_string_get(fd-path), pathlen);
+   memcpy(buf + sizeof(msg) + pathlen, cserve2_shared_string_get(fd-key), 
keylen);
if (msg.has_loader_data)
  memcpy(buf + sizeof(msg) + pathlen + keylen, loader_data, loaderlen);
 
*bufsize = size;
 
-   _entry_load_start(fe-base);
+   _entry_load_start(fd-base);
 
return buf;
 }
@@ -373,26 +373,26 @@ _request_free(void *msg, void *data EINA_UNUSED)
 }
 
 static Msg_Opened *
-_open_request_response(File_Data *fe, Slave_Msg_Image_Opened *resp, int *size)
+_open_request_response(File_Data *fd, Slave_Msg_Image_Opened *resp, int *size)
 {
-   _entry_load_finish(fe-base);
+   _entry_load_finish(fd-base);
 
-   fe-base.request = NULL;
+   fd-base.request = NULL;
 
-   fe-w = resp-w;
-   fe-h = resp-h;
-   fe-frame_count = resp-frame_count;
-   fe-loop_count = resp-loop_count;
-   fe-loop_hint = resp-loop_hint;
-   fe-alpha = resp-alpha;
+   fd-w = resp-w;
+   fd-h = resp-h;
+   fd-frame_count = resp-frame_count;
+   fd-loop_count = resp-loop_count;
+   fd-loop_hint = resp-loop_hint;
+   fd-alpha = resp-alpha;
if (resp-has_loader_data)
  {
 const char *ldata =
   (const char *)resp + sizeof(Slave_Msg_Image_Opened);
-fe-loader_data = cserve2_shared_string_add(ldata);
+fd-loader_data = cserve2_shared_string_add(ldata);
  }
 
-   return _image_opened_msg_create(fe, size);
+   return _image_opened_msg_create(fd, size);
 }
 
 static void
@@ -647,14 +647,14 @@ _image_entry_size_get(Image_Data *e)
 }
 
 static void
-_file_id_free(File_Data *fe)
+_file_id_free(File_Data *fd)
 {
char buf[4096];
 
DBG(Removing entry file id: %d, file: \%s:%s\,
-   fe-base.id, 

[EGIT] [core/efl] master 04/77: evas/cserve2: Implement shared index and buffers

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=07fb7172d57c0bb9151d1510b1d091ff77e36b7a

commit 07fb7172d57c0bb9151d1510b1d091ff77e36b7a
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Jul 18 19:39:33 2013 +0900

evas/cserve2: Implement shared index and buffers

Only import the C file for now.
Implement the following features:

- Shared Arrays
Store arrays of elements of fixed size in shm.

- Shared Mempool
Store random sized buffers in shm.
These buffers are indexed in a Shared Array and are
referred to using their index only.

- Shared Strings
Store strings in a shm in a way similar to Eina_Stringshare
(except strings are referred to using an int index).

- Include evas_cserve2_index.c to the compilation.
- Declare shared index functions in header file.
- Call init() and shutdown() on the shared index subsystem.
- Add find and foreach functions
---
 src/Makefile_Evas.am  |   1 +
 src/bin/evas/evas_cserve2.h   |  43 ++
 src/bin/evas/evas_cserve2_index.c | 878 ++
 src/bin/evas/evas_cserve2_main.c  |  14 +-
 4 files changed, 925 insertions(+), 11 deletions(-)

diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 29bea4b..de3636b 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -1013,6 +1013,7 @@ bin/evas/evas_cserve2_requests.c \
 bin/evas/evas_cserve2_fonts.c \
 bin/evas/evas_cserve2_scale.c \
 bin/evas/evas_cserve2_main_loop_linux.c \
+bin/evas/evas_cserve2_index.c \
 lib/evas/cserve2/evas_cs2_utils.h \
 lib/evas/cserve2/evas_cs2_utils.c
 
diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index e7e53f3..b6bdff3 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -316,4 +316,47 @@ void *cserve2_font_slave_cb(Slave_Thread_Data *sd, 
Slave_Command *cmd, const voi
 void cserve2_font_source_ft_free(void *fontsource);
 void cserve2_font_ft_free(void *fontinfo);
 
+// Shared buffers  indexes
+void cserve2_shared_index_init(void);
+void cserve2_shared_index_shutdown(void);
+
+typedef struct _Shared_Array Shared_Array;
+typedef struct _Shared_Mempool Shared_Mempool;
+typedef Eina_Bool (* Shared_Array_Repack_Skip_Cb) (Shared_Array *, const void 
*);
+
+// Shared arrays (arrays of fixed size object)
+Shared_Array *cserve2_shared_array_new(int tag, int elemsize, int initcount);
+const char *cserve2_shared_array_name_get(Shared_Array *sa);
+void cserve2_shared_array_del(Shared_Array *sa);
+int cserve2_shared_array_size_get(Shared_Array *sa);
+int cserve2_shared_array_count_get(Shared_Array *sa);
+int cserve2_shared_array_item_size_get(Shared_Array *sa);
+int cserve2_shared_array_generation_id_get(Shared_Array *sa);
+int cserve2_shared_array_size_set(Shared_Array *sa, int newcount);
+int cserve2_shared_array_item_new(Shared_Array *sa);
+void *cserve2_shared_array_item_data_get(Shared_Array *sa, int elemid);
+Shared_Array *cserve2_shared_array_repack(Shared_Array *sa,
+  Shared_Array_Repack_Skip_Cb skip,
+  Eina_Compare_Cb cmp);
+int cserve2_shared_array_item_find(Shared_Array *sa, void *data,
+   Eina_Compare_Cb cmp);
+void *cserve2_shared_array_item_data_find(Shared_Array *sa, void *data,
+  Eina_Compare_Cb cmp);
+int cserve2_shared_array_foreach(Shared_Array *sa, Eina_Each_Cb cb, void 
*data);
+
+// Shared buffers and memory pools
+Shared_Mempool *cserve2_shared_mempool_new(int initsize);
+void cserve2_shared_mempool_del(Shared_Mempool *sm);
+int cserve2_shared_mempool_buffer_new(Shared_Mempool *sm, int size);
+int cserve2_shared_mempool_buffer_ref(Shared_Mempool *sm, int bufferid);
+void cserve2_shared_mempool_buffer_del(Shared_Mempool *sm, int bufferid);
+void *cserve2_shared_mempool_buffer_get(Shared_Mempool *sm, int bufferid);
+
+
+// Shared strings
+int cserve2_shared_string_add(const char *str);
+int cserve2_shared_string_ref(int id);
+void cserve2_shared_string_del(int id);
+const char *cserve2_shared_string_get(int id);
+
 #endif /* _EVAS_CSERVE2_H */
diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
new file mode 100644
index 000..2579104
--- /dev/null
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -0,0 +1,878 @@
+/* Shared index for cserve2.
+ * EXPERIMENTAL WORK.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include config.h
+#endif
+
+#include evas_cserve2.h
+#include evas_cs2_utils.h
+
+#include stdint.h
+
+typedef struct _Data_Shm Data_Shm;
+typedef struct _Index_Entry Index_Entry;
+typedef struct _Block Block;
+typedef struct _Shared_Array_Header Shared_Array_Header;
+typedef struct _Shared_Index Shared_Index;
+
+static int _instances = 0;
+
+// Static memory pool used for storing strings
+static Shared_Mempool *_string_mempool = NULL;
+
+// Map const char* -- buffer id 

[EGIT] [core/efl] master 08/77: evas/cserve2: Repack File_Data shared array

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=d0e647fee3b5ebe6e5c2905a4053a51283f27014

commit d0e647fee3b5ebe6e5c2905a4053a51283f27014
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Jul 23 19:30:54 2013 +0900

evas/cserve2: Repack File_Data shared array
---
 src/bin/evas/evas_cserve2.h   |  6 ++--
 src/bin/evas/evas_cserve2_cache.c | 65 +++
 src/bin/evas/evas_cserve2_index.c |  6 ++--
 3 files changed, 60 insertions(+), 17 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index b6bdff3..361d08a 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -322,7 +322,9 @@ void cserve2_shared_index_shutdown(void);
 
 typedef struct _Shared_Array Shared_Array;
 typedef struct _Shared_Mempool Shared_Mempool;
-typedef Eina_Bool (* Shared_Array_Repack_Skip_Cb) (Shared_Array *, const void 
*);
+typedef Eina_Bool (* Shared_Array_Repack_Skip_Cb) (Shared_Array *sa,
+   const void *elem,
+   void *user_data);
 
 // Shared arrays (arrays of fixed size object)
 Shared_Array *cserve2_shared_array_new(int tag, int elemsize, int initcount);
@@ -337,7 +339,7 @@ int cserve2_shared_array_item_new(Shared_Array *sa);
 void *cserve2_shared_array_item_data_get(Shared_Array *sa, int elemid);
 Shared_Array *cserve2_shared_array_repack(Shared_Array *sa,
   Shared_Array_Repack_Skip_Cb skip,
-  Eina_Compare_Cb cmp);
+  Eina_Compare_Cb cmp, void 
*user_data);
 int cserve2_shared_array_item_find(Shared_Array *sa, void *data,
Eina_Compare_Cb cmp);
 void *cserve2_shared_array_item_data_find(Shared_Array *sa, void *data,
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index d3926e2..8624c08 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -175,6 +175,8 @@ struct _File_Watch {
 };
 
 static unsigned int _entry_id = 0;
+static unsigned int _freed_entry_count = 0;
+
 static Shared_Array *_file_data_array = NULL;
 
 static Eina_Hash *file_ids = NULL; // maps path + key -- file_id
@@ -242,7 +244,7 @@ _entry_load_reused(Entry *e)
 
 
 static int
-_shm_object_id_find_cb(const void *data1, const void *data2)
+_shm_object_id_cmp_cb(const void *data1, const void *data2)
 {
const Shm_Object *obj;
unsigned int key;
@@ -266,12 +268,14 @@ _file_data_find(unsigned int file_id)
File_Data *fd;
 
fd = cserve2_shared_array_item_data_find(_file_data_array, file_id,
-_shm_object_id_find_cb);
+_shm_object_id_cmp_cb);
if (fd  !fd-refcount)
  {
 ERR(Can not access object %u with refcount 0, file_id);
 return NULL;
  }
+   else if (!fd)
+ ERR(Could not find file %u, file_id);
return fd;
 }
 
@@ -287,6 +291,45 @@ _file_entry_find(unsigned int entry_id)
return (File_Entry *) e;
 }
 
+static Eina_Bool
+_repack_skip_cb(Shared_Array *sa EINA_UNUSED, const void *elem,
+void *user_data EINA_UNUSED)
+{
+   const File_Data *fd = elem;
+   return (!fd-refcount);
+}
+
+static void
+_repack()
+{
+   Shared_Array *sa;
+   int count;
+
+   count = cserve2_shared_array_size_get(_file_data_array);
+   if (count = 0) return;
+
+   // Repack when we have 10% fragmentation over the whole shm buffer
+   if (_freed_entry_count  100 ||
+   ((_freed_entry_count * 100) / count = 10))
+ {
+DBG(Repacking file data array: %s,
+cserve2_shared_array_name_get(_file_data_array));
+
+sa = cserve2_shared_array_repack(_file_data_array,
+ _repack_skip_cb,
+ _shm_object_id_cmp_cb, NULL);
+if (!sa)
+  {
+ ERR(Failed to repack array. Keeping previous references!);
+ return;
+  }
+
+cserve2_shared_array_del(_file_data_array);
+_freed_entry_count = 0;
+_file_data_array = sa;
+ }
+}
+
 
 static Msg_Opened *
 _image_opened_msg_create(File_Data *fd, int *size)
@@ -845,8 +888,11 @@ _hash_file_entry_free(void *data)
 
fd = _file_data_find(ASENTRY(fentry)-id);
_file_id_free(fd);
-   _file_entry_free(fentry);
_file_data_free(fd);
+   _file_entry_free(fentry);
+
+   _freed_entry_count++;
+   _repack();
 }
 
 static void
@@ -1097,12 +1143,8 @@ _entry_reference_del(Entry *entry, Reference *ref)
 
 if (fd)
   {
- if (fd-invalid)
-   {
-  _file_entry_free(fentry);
-  _file_data_free(fd);
-   }
- else if (!fentry-images)
+ // FIXME: Check difference with master (2 cases vs. 

[EGIT] [core/efl] master 10/77: evas/cserve2: Store Image_Data in shared array

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=64e7d48296a7f21245203ea9bada0be90dbf360a

commit 64e7d48296a7f21245203ea9bada0be90dbf360a
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Jul 24 14:34:35 2013 +0900

evas/cserve2: Store Image_Data in shared array

Split image entries into Image_Data and Image_Entry.
Store, find and use Image_Data descriptors from shared array.
Fix some wrong hash table usages.
---
 src/bin/evas/evas_cserve2.h   |   2 +-
 src/bin/evas/evas_cserve2_cache.c | 678 ++
 src/bin/evas/evas_cserve2_index.c |  18 +-
 3 files changed, 412 insertions(+), 286 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 361d08a..1e1a055 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -288,7 +288,7 @@ void cserve2_cache_client_new(Client *client);
 void cserve2_cache_client_del(Client *client);
 int cserve2_cache_file_open(Client *client, unsigned int client_file_id, const 
char *path, const char *key, unsigned int rid);
 void cserve2_cache_file_close(Client *client, unsigned int client_file_id);
-int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int 
file_id, unsigned int image_id, Evas_Image_Load_Opts *opts);
+int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int 
client_file_id, unsigned int image_id, Evas_Image_Load_Opts *opts);
 void cserve2_rgba_image_scale_do(void *src_data, void *dst_data, int src_x, 
int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, 
int alpha, int smooth);
 void cserve2_cache_image_load(Client *client, unsigned int client_image_id, 
unsigned int rid);
 void cserve2_cache_image_preload(Client *client, unsigned int client_image_id, 
unsigned int rid);
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 8624c08..b8a55c9 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -17,6 +17,7 @@
 typedef int string_t;
 #define ENTRY Entry base
 #define ASENTRY(a) ((a-base))
+#define ENTRYID(a) ((a)-base.id)
 #define SHMOBJECT unsigned int id; unsigned int refcount
 
 typedef struct _Entry Entry;
@@ -24,6 +25,7 @@ typedef struct _Shm_Object Shm_Object;
 typedef struct _Reference Reference;
 typedef struct _File_Entry File_Entry;
 typedef struct _File_Data File_Data;
+typedef struct _Image_Entry Image_Entry;
 typedef struct _Image_Data Image_Data;
 typedef struct _File_Watch File_Watch;
 
@@ -74,12 +76,17 @@ struct _File_Data {
Eina_Bool invalid : 1;
 };
 
-// Default values for load options commented below
+
+struct _Image_Entry {
+   ENTRY;
+   Shm_Handle *shm;
+};
+
 struct _Image_Data {
-   Entry base;
+   SHMOBJECT;
unsigned int file_id;
+   string_t shm_id;
Evas_Image_Load_Opts opts;
-   Shm_Handle *shm;
Eina_Bool alpha_sparse : 1;
Eina_Bool unused : 1;
Eina_Bool doload : 1;
@@ -178,6 +185,7 @@ static unsigned int _entry_id = 0;
 static unsigned int _freed_entry_count = 0;
 
 static Shared_Array *_file_data_array = NULL;
+static Shared_Array *_image_data_array = NULL;
 
 static Eina_Hash *file_ids = NULL; // maps path + key -- file_id
 static Eina_Hash *file_entries = NULL; // maps file_id -- entry
@@ -262,7 +270,7 @@ _shm_object_id_cmp_cb(const void *data1, const void *data2)
  return +1;
 }
 
-static inline File_Data *
+static File_Data *
 _file_data_find(unsigned int file_id)
 {
File_Data *fd;
@@ -276,10 +284,11 @@ _file_data_find(unsigned int file_id)
  }
else if (!fd)
  ERR(Could not find file %u, file_id);
+
return fd;
 }
 
-static inline File_Entry *
+static File_Entry *
 _file_entry_find(unsigned int entry_id)
 {
Entry *e;
@@ -291,6 +300,36 @@ _file_entry_find(unsigned int entry_id)
return (File_Entry *) e;
 }
 
+static Image_Data *
+_image_data_find(unsigned int image_id)
+{
+   Image_Data *idata;
+
+   idata = cserve2_shared_array_item_data_find(_image_data_array, image_id,
+   _shm_object_id_cmp_cb);
+   if (idata  !idata-refcount)
+ {
+ERR(Can not access object %u with refcount 0, image_id);
+return NULL;
+ }
+   else if (!idata)
+ ERR(Could not find image %u, image_id);
+
+   return idata;
+}
+
+static Image_Entry *
+_image_entry_find(unsigned int entry_id)
+{
+   Entry *e;
+
+   e = (Entry *) eina_hash_find(image_entries, entry_id);
+   if (!e || e-type != CSERVE2_IMAGE_DATA)
+ return NULL;
+
+   return (Image_Entry *) e;
+}
+
 static Eina_Bool
 _repack_skip_cb(Shared_Array *sa EINA_UNUSED, const void *elem,
 void *user_data EINA_UNUSED)
@@ -369,10 +408,10 @@ _image_opened_send(Client *client, File_Data *fd, 
unsigned int rid)
 }
 
 static Msg_Loaded *
-_image_loaded_msg_create(Image_Data *entry, int *size)
+_image_loaded_msg_create(Image_Entry *ientry, Image_Data *idata, int *size)
 {

[EGIT] [core/efl] master 09/77: evas/cserve2: binary search in Shared_Array

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=315c2fd161b1a552c5589bae6f7a488ffea1d318

commit 315c2fd161b1a552c5589bae6f7a488ffea1d318
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Jul 24 10:59:51 2013 +0900

evas/cserve2: binary search in Shared_Array
---
 src/bin/evas/evas_cserve2_index.c | 35 +--
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
index fd95aa5..dd335d8 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -38,9 +38,9 @@ struct _Shared_Array_Header
int32_t count;
int32_t generation_id;
int32_t emptyidx;
+   int32_t sortedidx;
int32_t _reserved1;
int32_t _reserved2;
-   int32_t _reserved3;
 };
 
 struct _Shared_Array
@@ -280,8 +280,9 @@ cserve2_shared_array_new(int tag, int elemsize, int 
initcount)
sa-header-elemsize = elemsize;
sa-header-generation_id = 1;
sa-header-emptyidx = 0;
+   sa-header-sortedidx = 0;
sa-header-tag = tag;
-   memset(sa-header-_reserved1, 0, sizeof(int32_t) * 3);
+   memset(sa-header-_reserved1, 0, sizeof(int32_t) * 2);
 
return sa;
 }
@@ -449,6 +450,7 @@ cserve2_shared_array_repack(Shared_Array *sa,
 
// Finalize  return
sa2-header-emptyidx = newcount;
+   sa2-header-sortedidx = newcount;
sa2-header-tag = sa-header-tag;
return sa2;
 }
@@ -462,12 +464,33 @@ cserve2_shared_array_item_find(Shared_Array *sa, void 
*data,
 
if (!sa || !cmp) return -1;
 
-   // TODO: Fast search in the sorted zone
-
-   ptr = sa-ds-data + sizeof(Shared_Array_Header);
+   // Binary search
+   if (sa-header-sortedidx  0)
+ {
+int low = 0;
+int high = sa-header-sortedidx;
+int prev = -1;
+int r;
+k = high / 2;
+while (prev != k)
+  {
+ ptr = cserve2_shared_array_item_data_get(sa, k);
+ r = cmp(ptr, data);
+ if (!r)
+   return k;
+ else if (r  0)
+   high = k;
+ else
+   low = k;
+ prev = k;
+ k = low + (high - low) / 2;
+  }
+ }
 
// Linear search O(n)
-   for (k = 0; k  sa-header-emptyidx; k++)
+   k = sa-header-sortedidx;
+   ptr = sa-ds-data + sizeof(Shared_Array_Header) + k * sa-header-elemsize;
+   for (; k  sa-header-emptyidx; k++)
  {
 if (!cmp(ptr, data))
   return k;

-- 




[EGIT] [core/efl] master 13/77: evas/cserve2: Fix image load premultiplication

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c0bb73c775787ae1221efacc8d5d7a01a28320af

commit c0bb73c775787ae1221efacc8d5d7a01a28320af
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Jul 25 12:31:45 2013 +0900

evas/cserve2: Fix image load premultiplication

There was a color problem in elementary_test since elm
sets premul to 0 while expedite sets it to 1 during image load.
---
 src/bin/evas/evas_cserve2_slave.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/evas/evas_cserve2_slave.c 
b/src/bin/evas/evas_cserve2_slave.c
index a5a407b..5f9bc32 100644
--- a/src/bin/evas/evas_cserve2_slave.c
+++ b/src/bin/evas/evas_cserve2_slave.c
@@ -459,7 +459,7 @@ image_load(const char *file, const char *key, const char 
*shmfile,
result-w = property.w;
result-h = property.h;
 
-   if (property.alpha)
+   if (property.alpha  property.premul)
  {
 result-alpha_sparse = evas_cserve2_image_premul_data((unsigned int *) 
map,
   result-w * 
result-h);

-- 




[EGIT] [core/efl] master 12/77: evas/cserve2: _cserve2_cache_fast_scaling_check()

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=db66f69104914814831b030c78d9e125d7fcf3cf

commit db66f69104914814831b030c78d9e125d7fcf3cf
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Jul 24 18:32:07 2013 +0900

evas/cserve2: _cserve2_cache_fast_scaling_check()

Adapt function to new Data/Entry model.
---
 src/bin/evas/evas_cserve2_cache.c | 154 --
 1 file changed, 82 insertions(+), 72 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index cfb049f..b1fc2ee 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)
 static Image_Entry *
 _image_entry_new(Client *client, int rid,
  unsigned int client_file_id, unsigned int client_image_id,
- Evas_Image_Load_Opts *opts, char *buf)
+ Evas_Image_Load_Opts *opts, char *buf, size_t buf_size)
 {
Reference *ref, *oldref;
Image_Entry *ientry;
@@ -1424,15 +1424,19 @@ _image_entry_new(Client *client, int rid,
idata-refcount = 1;
idata-id = image_id;
 
-   _image_key_set(idata-file_id, opts, buf, sizeof(buf));
+   _image_key_set(idata-file_id, opts, buf, buf_size);
eina_hash_add(image_entries, image_id, ientry);
eina_hash_add(image_ids, buf, (void *)(intptr_t) image_id);
 
-   oldref = eina_hash_find(client-images.referencing, client_image_id);
-   ref = _entry_reference_add(ASENTRY(ientry), client, client_image_id);
-   if (oldref)
- eina_hash_del_by_key(client-images.referencing, client_image_id);
-   eina_hash_add(client-images.referencing, client_image_id, ref);
+   if (client_image_id)
+ {
+oldref = eina_hash_find(client-images.referencing, client_image_id);
+ref = _entry_reference_add(ASENTRY(ientry), client, client_image_id);
+if (oldref)
+  eina_hash_del_by_key(client-images.referencing, client_image_id);
+eina_hash_add(client-images.referencing, client_image_id, ref);
+ }
+   // else: See _cserve2_cache_fast_scaling_check()
 
return ientry;
 }
@@ -2485,8 +2489,9 @@ static int
 _cserve2_cache_fast_scaling_check(Client *client, Image_Entry *ientry)
 {
Eina_Iterator *iter;
-   Image_Data *i;
-   Image_Entry *original = NULL;
+   Image_Entry *i;
+   Image_Entry *orig_entry = NULL;
+   Image_Data *orig_data = NULL;
Evas_Image_Load_Opts unscaled;
char buf[4096];
unsigned int image_id;
@@ -2496,42 +2501,41 @@ _cserve2_cache_fast_scaling_check(Client *client, 
Image_Entry *ientry)
File_Entry *fentry;
Image_Data *idata;
 
-   return -1;
-#if 0
if (!ientry) return -1;
-
idata = _image_data_find(ENTRYID(ientry));
if (!idata) return -1;
 
-   dst_w = entry-opts.scale_load.dst_w;
-   dst_h = entry-opts.scale_load.dst_h;
+   dst_w = idata-opts.scale_load.dst_w;
+   dst_h = idata-opts.scale_load.dst_h;
 
// Copy opts w/o scaling
memset(unscaled, 0, sizeof(unscaled));
-   unscaled.dpi = entry-opts.dpi;
-   //unscaled.w = entry-opts.w;
-   //unscaled.h = entry-opts.h;
-   //unscaled.scale_down_by = entry-opts.scale_down_by;
-   //unscaled.region.x = entry-opts.region.x;
-   //unscaled.region.y = entry-opts.region.y;
-   //unscaled.region.w = entry-opts.region.w;
-   //unscaled.region.h = entry-opts.region.h;
+   unscaled.dpi = idata-opts.dpi;
+   //unscaled.w = idata-opts.w;
+   //unscaled.h = idata-opts.h;
+   //unscaled.scale_down_by = idata-opts.scale_down_by;
+   //unscaled.region.x = idata-opts.region.x;
+   //unscaled.region.y = idata-opts.region.y;
+   //unscaled.region.w = idata-opts.region.w;
+   //unscaled.region.h = idata-opts.region.h;
unscaled.scale_load.scale_hint = 0;
-   unscaled.degree = entry-opts.degree;
-   unscaled.orientation = entry-opts.orientation;
-   unscaled.scale_load.smooth = entry-opts.scale_load.smooth;
+   unscaled.degree = idata-opts.degree;
+   unscaled.orientation = idata-opts.orientation;
+   unscaled.scale_load.smooth = idata-opts.scale_load.smooth;
 
 try_again:
-   image_id = _image_opts_id_get(entry-file_id, unscaled, buf, sizeof(buf));
+   image_id = _image_opts_id_get(idata-file_id, unscaled, buf, sizeof(buf));
if (image_id)
  {
-original = eina_hash_find(image_entries, image_id);
-if (!original) return -1; // Should not happen
+orig_data = _image_data_find(image_id);
+orig_entry = _image_entry_find(image_id);
+if (!orig_data || !orig_entry) return -1;
+
 DBG(Found original image in hash: %d,%d:%dx%d - %dx%d shm %p,
-original-opts.scale_load.src_x, 
original-opts.scale_load.src_y,
-original-opts.scale_load.src_w, 
original-opts.scale_load.src_h,
-original-opts.scale_load.dst_w, 
original-opts.scale_load.dst_h,
-original-shm);
+orig_data-opts.scale_load.src_x, 

[EGIT] [core/efl] master 33/77: evas/cserve2: Remap string entries when size changed

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a14e69e5733457f2b8e09caadb24271522cbe82b

commit a14e69e5733457f2b8e09caadb24271522cbe82b
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Aug 23 14:52:11 2013 +0900

evas/cserve2: Remap string entries when size changed

Lots of files can't be found by the client when the strings table
changed, because it was not remapped properly.
---
 src/lib/evas/cserve2/evas_cs2_client.c | 146 -
 1 file changed, 91 insertions(+), 55 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 9bcf966..7746e1d 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1661,58 +1661,11 @@ evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, 
unsigned int idx, Font_Hint_F
 
 static Eina_Bool _shared_index_remap_check(Shared_Index *si, int elemsize);
 
-// Returns the number of correctly opened index arrays
-static int
-_server_index_list_set(Msg_Base *data, int size)
+static Eina_Bool
+_string_index_refresh(void)
 {
-   Msg_Index_List *msg = (Msg_Index_List *) data;
-   unsigned sz;
-
-   // TODO #1: Check populate rule.
-   // TODO #2: Protect memory for read-only access.
-   // TODO #3: Optimize file reopen/remap (esp. strings table)
-
-   if (size != sizeof(*msg) || msg-base.type != CSERVE2_INDEX_LIST)
- {
-CRIT(Invalid message! type: %d, size: %d (expected %d),
- msg-base.type, size, (int) sizeof(*msg));
-return -1;
- }
-
-   if (_index.generation_id == msg-generation_id)
- {
-ERR(New index generation_id is the same as before: %d,
-_index.generation_id);
- }
-
-   _index.generation_id = msg-generation_id;
-
-   // 1. Strings (indexes and entries)
-
-   if (_index.strings_entries.data
-strncmp(_index.strings_entries.path, msg-strings_entries_path,
-  SHARED_BUFFER_PATH_MAX) != 0)
- {
-DBG(Updating string entries shm to: '%s', msg-strings_entries_path);
-eina_file_map_free(_index.strings_entries.f, 
_index.strings_entries.data);
-eina_file_close(_index.strings_entries.f);
-_index.strings_entries.f = NULL;
-_index.strings_entries.data = NULL;
- }
-
-   if (_index.strings_index.data
-strncmp(_index.strings_index.path, msg-strings_index_path,
-  SHARED_BUFFER_PATH_MAX) != 0)
- {
-DBG(Updating string indexes shm to: '%s', msg-strings_index_path);
-eina_file_map_free(_index.strings_index.f, _index.strings_index.data);
-eina_file_close(_index.strings_index.f);
-_index.strings_index.f = NULL;
-_index.strings_index.data = NULL;
- }
-
-   eina_strlcpy(_index.strings_entries.path, msg-strings_entries_path, 
SHARED_BUFFER_PATH_MAX);
-   eina_strlcpy(_index.strings_index.path, msg-strings_index_path, 
SHARED_BUFFER_PATH_MAX);
+   size_t sz;
+   Eina_Bool ret = EINA_FALSE;
 
if (!_index.strings_entries.data
 _index.strings_entries.path[0]
@@ -1729,8 +1682,13 @@ _server_index_list_set(Msg_Base *data, int size)
  eina_file_close(_index.strings_entries.f);
  _index.strings_entries.f = NULL;
  _index.strings_entries.data = NULL;
+ ret = EINA_FALSE;
+  }
+else
+  {
+ DBG(Mapped string entries from %s, _index.strings_entries.path);
+ ret = EINA_TRUE;
   }
-else DBG(Mapped string entries from %s, _index.strings_entries.path);
  }
 
if (_index.strings_entries.data 
@@ -1752,6 +1710,7 @@ _server_index_list_set(Msg_Base *data, int size)
   _index.strings_index.count, 
_index.strings_index.header-count);
   _index.strings_index.count = 
_index.strings_index.header-count;
}
+ ret = EINA_TRUE;
   }
 else
   {
@@ -1762,20 +1721,79 @@ _server_index_list_set(Msg_Base *data, int size)
  _index.strings_index.f = NULL;
  _index.strings_entries.f = NULL;
  _index.strings_entries.data = NULL;
+ ret = EINA_FALSE;
   }
  }
 
_shared_index_remap_check(_index.strings_index, sizeof(Index_Entry));
if (_index.strings_entries.data)
  {
-if (eina_file_refresh(_index.strings_entries.f))
+if (eina_file_refresh(_index.strings_entries.f)
+|| (_index.strings_entries.size != (int) 
eina_file_size_get(_index.strings_entries.f)))
   {
  eina_file_map_free(_index.strings_entries.f, 
_index.strings_entries.data);
  _index.strings_entries.data = 
eina_file_map_all(_index.strings_entries.f, EINA_FILE_RANDOM);
  _index.strings_entries.size = 
eina_file_size_get(_index.strings_entries.f);
+ return EINA_TRUE;
   }
  }
 
+   return ret;
+}
+
+// 

[EGIT] [core/efl] master 17/77: evas/cserve2: Scan shared indexes in client side

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=f5d0f0aec37fae9e974ce1b5b2e518863297ba3f

commit f5d0f0aec37fae9e974ce1b5b2e518863297ba3f
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Jul 31 20:29:41 2013 +0900

evas/cserve2: Scan shared indexes in client side

Read Image descriptors from the shared arrays

But, accessing the shared index can be a bit expensive, so
try to read from the socket before scanning the index,
without blocking.
---
 src/lib/evas/cache2/evas_cache2.c   |  21 +-
 src/lib/evas/cache2/evas_cache2.h   |   1 +
 src/lib/evas/cserve2/evas_cs2.h |   1 +
 src/lib/evas/cserve2/evas_cs2_client.c  | 577 ++--
 src/lib/evas/cserve2/evas_cs2_private.h |  36 +-
 5 files changed, 359 insertions(+), 277 deletions(-)

diff --git a/src/lib/evas/cache2/evas_cache2.c 
b/src/lib/evas/cache2/evas_cache2.c
index 81fd78c..77585ab 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -549,8 +549,10 @@ evas_cache2_shutdown(Evas_Cache2 *cache)
free(cache);
 }
 
-static void
-_create_hash_key(char *hkey, const char *path, size_t pathlen, const char 
*key, size_t keylen, Evas_Image_Load_Opts *lo)
+EAPI void
+evas_cache2_image_cache_key_create(char *hkey, const char *path, size_t 
pathlen,
+   const char *key, size_t keylen,
+   const Evas_Image_Load_Opts *lo)
 {
const char *ckey = (null);
size_t size;
@@ -561,6 +563,7 @@ _create_hash_key(char *hkey, const char *path, size_t 
pathlen, const char *key,
memcpy(hkey + size, //://, 5);
size += 5;
if (key) ckey = key;
+   else keylen = 6;
memcpy(hkey + size, ckey, keylen);
size += keylen;
if (lo)
@@ -634,7 +637,8 @@ _create_hash_key(char *hkey, const char *path, size_t 
pathlen, const char *key,
 }
 
 EAPI Image_Entry *
-evas_cache2_image_open(Evas_Cache2 *cache, const char *path, const char *key, 
Evas_Image_Load_Opts *lo, int *error)
+evas_cache2_image_open(Evas_Cache2 *cache, const char *path, const char *key,
+   Evas_Image_Load_Opts *lo, int *error)
 {
size_tsize;
size_tpathlen;
@@ -659,7 +663,7 @@ evas_cache2_image_open(Evas_Cache2 *cache, const char 
*path, const char *key, Ev
size = pathlen + keylen + HKEY_LOAD_OPTS_STR_LEN;
hkey = alloca(sizeof(char) * size);
 
-   _create_hash_key(hkey, path, pathlen, key, keylen, lo);
+   evas_cache2_image_cache_key_create(hkey, path, pathlen, key, keylen, lo);
DBG(Looking at the hash for key '%s', hkey);
 
/* use local var to copy default load options to the image entry */
@@ -816,7 +820,8 @@ _scaled_image_find(Image_Entry *im, int src_x, int src_y, 
int src_w, int src_h,
if (!smooth)
  {
 lo.scale_load.smooth = 1;
-_create_hash_key(hkey, im-file, pathlen, im-key, keylen, lo);
+evas_cache2_image_cache_key_create(hkey, im-file, pathlen,
+   im-key, keylen, lo);
 
 ret = eina_hash_find(im-cache2-activ, hkey);
 if (ret) goto found;
@@ -827,7 +832,8 @@ _scaled_image_find(Image_Entry *im, int src_x, int src_y, 
int src_w, int src_h,
 lo.scale_load.smooth = smooth;
  }
 
-   _create_hash_key(hkey, im-file, pathlen, im-key, keylen, lo);
+   evas_cache2_image_cache_key_create(hkey, im-file, pathlen,
+  im-key, keylen, lo);
 
ret = eina_hash_find(im-cache2-activ, hkey);
if (ret) goto found;
@@ -896,7 +902,8 @@ evas_cache2_image_scale_load(Image_Entry *im,
lo.scale_load.smooth = smooth;
lo.scale_load.scale_hint = im-scale_hint;
 
-   _create_hash_key(hkey, im-file, pathlen, im-key, keylen, lo);
+   evas_cache2_image_cache_key_create(hkey, im-file, pathlen,
+  im-key, keylen, lo);
 
ret = _evas_cache_image_entry_new(im-cache2, hkey, NULL, im-file, im-key,
  lo, error);
diff --git a/src/lib/evas/cache2/evas_cache2.h 
b/src/lib/evas/cache2/evas_cache2.h
index f6ba8f8..6f8e588 100644
--- a/src/lib/evas/cache2/evas_cache2.h
+++ b/src/lib/evas/cache2/evas_cache2.h
@@ -66,6 +66,7 @@ EAPI void evas_cache2_image_close(Image_Entry *im);
 EAPI int evas_cache2_image_load_data(Image_Entry *ie);
 EAPI void evas_cache2_image_unload_data(Image_Entry *im);
 EAPI void evas_cache2_image_preload_data(Image_Entry *im, const void *target);
+EAPI void evas_cache2_image_cache_key_create(char *hkey, const char *path, 
size_t pathlen, const char *key, size_t keylen, const Evas_Image_Load_Opts *lo);
 
 EAPI DATA32 * evas_cache2_image_pixels(Image_Entry *im);
 EAPI Image_Entry * evas_cache2_image_writable(Image_Entry *im);
diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h
index 7cb6e08..19bf806 100644
--- a/src/lib/evas/cserve2/evas_cs2.h
+++ 

[EGIT] [core/efl] master 16/77: evas/cserve2: Add _shared_index_remap_check()

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=08648ab2a5033da4f6c835c049238074802fb232

commit 08648ab2a5033da4f6c835c049238074802fb232
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Jul 31 19:31:50 2013 +0900

evas/cserve2: Add _shared_index_remap_check()

Check consistency of index header and remap if necessary.
---
 src/lib/evas/cserve2/evas_cs2_client.c  | 126 +---
 src/lib/evas/cserve2/evas_cs2_private.h |   9 ++-
 2 files changed, 108 insertions(+), 27 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 73d0936..d7cd814 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1945,6 +1945,105 @@ _shared_image_entry_image_data_match(Image_Entry *ie, 
const Image_Data *id)
return EINA_FALSE;
 }
 
+#define SHARED_INDEX_CHECK(si, typ) \
+   if (!_shared_index_remap_check((si), sizeof(typ))) return NULL
+
+static Eina_Bool
+_shared_index_remap_check(Shared_Index *si, int elemsize)
+{
+   size_t filesize;
+   Eina_Bool refresh = EINA_FALSE;
+
+   // Note: all checks are unlikely to be true.
+
+   if (!si || elemsize = 0) return EINA_FALSE;
+   if (si-generation_id != _index.generation_id)
+ {
+DBG(Generation ID changed.);
+if (si-f  si-data)
+  {
+ if (eina_file_refresh(si-f))
+   {
+  DBG(Remapping index.);
+  eina_file_map_free(si-f, si-data);
+  si-data = NULL;
+   }
+  }
+else if (si-f)
+  {
+ eina_file_close(si-f);
+ si-f = NULL;
+  }
+si-generation_id = _index.generation_id;
+ }
+   if (!si-f)
+ {
+si-data = NULL; // If that was not NULL, the address was invalid.
+si-f = eina_file_open(si-path, EINA_TRUE);
+if (!si-f)
+  {
+ ERR(Could not open index '%s', si-path);
+ return EINA_FALSE;
+  }
+ }
+   if (!si-data)
+ {
+filesize = eina_file_size_get(si-f);
+if (filesize  sizeof(Shared_Array_Header))
+  {
+ ERR(Index is invalid. Got file size %d, (int) filesize);
+ eina_file_close(si-f);
+ si-f = NULL;
+ return EINA_FALSE;
+  }
+si-data = eina_file_map_all(si-f, EINA_FILE_RANDOM);
+if (!si-data)
+  {
+ ERR(Could not mmap index '%s', si-path);
+ eina_file_close(si-f);
+ si-f = NULL;
+ return EINA_FALSE;
+  }
+refresh = EINA_TRUE;
+ }
+
+   if (elemsize != si-header-elemsize)
+ {
+ERR(Index is invalid. Expected element size %d, got %d.,
+elemsize, si-header-elemsize);
+return EINA_FALSE;
+ }
+
+   if (si-count != si-header-count)
+ {
+// generation_id should have been incremented. Maybe we are hitting
+// a race condition here, when cserve2 grows an index.
+WRN(Reported index count differs from known count: %d vs %d,
+si-header-count, si-count);
+filesize = eina_file_size_get(si-f);
+si-count = (filesize - sizeof(Shared_Array_Header)) / elemsize;
+if (si-count  si-header-count)
+  {
+ WRN(Index reports %d elements, but file can contain only %d,
+ si-header-count, si-count);
+ si-count = si-header-count;
+  }
+refresh = EINA_TRUE;
+ }
+
+   if (!si-entries_by_hkey)
+ refresh = EINA_TRUE;
+
+   if (refresh)
+ {
+if (si-entries_by_hkey) eina_hash_free_buckets(si-entries_by_hkey);
+else si-entries_by_hkey = eina_hash_string_small_new(NULL);
+si-last_entry_in_hash = 0;
+ }
+
+   return EINA_TRUE;
+}
+
 static const Image_Data *
 _shared_image_entry_image_data_find(Image_Entry *ie)
 {
@@ -1973,32 +2072,7 @@ _shared_image_entry_image_data_find(Image_Entry *ie)
 file_id = fdata-id;
  }
 
-   // FIXME. Factorize and simplify.
-   if (_index.images.count != _index.images.header-count)
- {
-size_t sz;
-WRN(Image entries array has been resized from %d to %d. Remapping.,
-_index.images.count, _index.images.header-count);
-eina_file_map_free(_index.images.f, (void *) _index.images.header);
-eina_file_close(_index.images.f);
-_index.images.f = eina_file_open(_index.images.path, EINA_TRUE);
-sz = eina_file_size_get(_index.images.f);
-_index.images.header = eina_file_map_new(_index.images.f, 
EINA_FILE_RANDOM,
- 0, sz); 
//eina_file_map_all(_index.images.f, EINA_FILE_RANDOM);
-_index.images.count = _index.images.header-count;
-if (_index.images.count * sizeof(Image_Data) + 
sizeof(Shared_Array_Header)  sz)
-  CRIT(New mapping might be too 

[EGIT] [core/efl] master 65/77: evas/cserve2: Fix CList usage

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=2cd0b316f156efef4891dff9b1aba23ae50f1ff5

commit 2cd0b316f156efef4891dff9b1aba23ae50f1ff5
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Oct 2 15:05:44 2013 +0900

evas/cserve2: Fix CList usage

In some error cases, the list could become a cycle.
Foreach would then loop forever!
---
 src/lib/evas/cserve2/evas_cs2_client.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index fa29fab..cf3e1b7 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1541,7 +1541,11 @@ _font_entry_glyph_map_rebuild_check(Font_Entry *fe, 
Font_Hint_Flags hints)
  gl = fash_gl_find(fe-fash[hints], gd-index);
  if (gl  gl-base.bitmap.buffer) continue;
 
- if (!gl) gl = calloc(1, sizeof(*gl));
+ if (!gl)
+   {
+  gl = calloc(1, sizeof(*gl));
+  eina_clist_element_init(gl-map_entry);
+   }
  gl-map = fe-map;
  gl-offset = gd-offset;
  gl-size = gd-size;
@@ -1555,7 +1559,8 @@ _font_entry_glyph_map_rebuild_check(Font_Entry *fe, 
Font_Hint_Flags hints)
  gl-idx = gd-index;
  gl-rid = 0;
 
- eina_clist_add_head(fe-map-glyphs, gl-map_entry);
+ if (!eina_clist_element_is_linked(gl-map_entry))
+   eina_clist_add_head(fe-map-glyphs, gl-map_entry);
  fash_gl_add(fe-fash[hints], gd-index, gl);
  cnt++;
   }
@@ -1676,8 +1681,12 @@ _glyph_request_cb(void *data, const void *msg, int size)
 
  if (gl-offset + glsize  (size_t) fe-map-mempool.size)
{
-  ERR(Glyph is out of the buffer. Set buffer to NULL.);
-  gl-base.bitmap.buffer = NULL;
+  WRN(Glyph offset out of the buffer. Refreshing map.);
+  if (!_glyph_map_remap_check(fe-map))
+{
+   ERR(Failed to remap glyph mempool!);
+   gl-base.bitmap.buffer = NULL;
+}
}
 
  eina_clist_add_head(fe-map-glyphs, gl-map_entry);
@@ -2017,7 +2026,7 @@ _server_index_list_set(Msg_Base *data, int size)
 
if (_index.generation_id == msg-generation_id)
  {
-ERR(New index generation_id is the same as before: %d,
+WRN(New index generation_id is the same as before: %d,
 _index.generation_id);
  }
 

-- 




[EGIT] [core/efl] master 40/77: evas/cserve2: Fix crashes in E17/cserve2

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=45456f8cf0a35bc997f2edd435ff34ec9f6abb81

commit 45456f8cf0a35bc997f2edd435ff34ec9f6abb81
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Aug 26 17:32:09 2013 +0900

evas/cserve2: Fix crashes in E17/cserve2

When remapping the glyph data buffer, we need to reposition
the glyph pointers as well.
---
 src/lib/evas/cserve2/evas_cs2_client.c | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index cc5458a..4a00521 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1365,6 +1365,8 @@ _glyph_map_remap_check(Glyph_Map *map)
if (eina_file_refresh(map-mempool.f)
|| (eina_file_size_get(map-mempool.f) != (size_t) map-mempool.size))
  {
+CS_Glyph_Out *gl;
+
 WRN(Glyph pool has been resized.);
 eina_file_map_free(map-mempool.f, map-mempool.data);
 map-mempool.data = eina_file_map_all(map-mempool.f, 
EINA_FILE_RANDOM);
@@ -1373,6 +1375,17 @@ _glyph_map_remap_check(Glyph_Map *map)
 else
   map-mempool.size = 0;
 changed = EINA_TRUE;
+
+// Remap loaded glyphs
+EINA_CLIST_FOR_EACH_ENTRY(gl, map-fe-map-glyphs,
+  CS_Glyph_Out, map_entry)
+  {
+ if (map-mempool.data)
+   gl-base.bitmap.buffer = (unsigned char *)
+ map-mempool.data + gl-offset;
+ else
+   gl-base.bitmap.buffer = NULL;
+  }
  }
 
map-index.generation_id = _index.generation_id;
@@ -2050,6 +2063,7 @@ _shared_image_entry_file_data_find(Image_Entry *ie)
 if (!fd-id) break;
 if (!fd-refcount) continue;
 
+key = _shared_string_get(fd-key);
 file = _shared_string_get(fd-path);
 if (!file)
   {
@@ -2058,7 +2072,11 @@ _shared_image_entry_file_data_find(Image_Entry *ie)
  add_to_hash = EINA_FALSE;
  continue;
   }
-key = _shared_string_get(fd-key);
+
+// Note: The strings base pointer may change if the index grows
+if ((key  _index.strings_entries.data) ||
+(key  _index.strings_entries.data + _index.strings_entries.size))
+  key = _shared_string_get(fd-key);
 
 _shared_file_data_hkey_get(fd_hkey, file, key, PATH_MAX);
 
@@ -2385,6 +2403,12 @@ _shared_image_entry_image_data_find(Image_Entry *ie)
   add_to_hash = EINA_FALSE;
   continue;
}
+
+ // Note: The strings base pointer may change if the index grows
+ if ((key  _index.strings_entries.data) ||
+ (key  _index.strings_entries.data + 
_index.strings_entries.size))
+   key = _shared_string_get(fd-key);
+
  keylen = key ? strlen(key) : 0;
  filelen = strlen(file);
 

-- 




[EGIT] [core/efl] master 51/77: evas/cserve2: Reduce debug logs (s/INF/DBG)

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8aa4a58d5b9092f8343c7e9bddf8f35738b93206

commit 8aa4a58d5b9092f8343c7e9bddf8f35738b93206
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Sep 3 11:27:27 2013 +0900

evas/cserve2: Reduce debug logs (s/INF/DBG)
---
 src/lib/evas/cserve2/evas_cs2_client.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index e32dc1d..59ca540 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -940,7 +940,7 @@ evas_cserve2_image_load_wait(Image_Entry *ie)
fd = _shared_image_entry_file_data_find(ie);
if (fd  fd-valid)
  {
-INF(Bypassing socket wait (open_rid %d), ie-open_rid);
+DBG(Bypassing socket wait (open_rid %d), ie-open_rid);
 ie-w = fd-w;
 ie-h = fd-h;
 ie-flags.alpha = fd-alpha;
@@ -1003,7 +1003,7 @@ evas_cserve2_image_load_data_wait(Image_Entry *ie)
 
 shmpath = _shared_string_get(idata-shm_id);
 if (!shmpath) goto load_wait;
-INF(Bypassing image load socket wait. Image found: %d in %s,
+DBG(Bypassing image load socket wait. Image found: %d in %s,
 idata-id, shmpath);
 
 dentry-shm.mmap_offset = 0;
@@ -1286,7 +1286,7 @@ evas_cserve2_font_load_wait(Font_Entry *fe)
fd = _shared_font_entry_data_find(fe);
if (fd)
  {
-INF(Bypassing socket wait (rid %d), fe-rid);
+DBG(Bypassing socket wait (rid %d), fe-rid);
 fe-failed = EINA_FALSE;
 fe-rid = 0;
 return CSERVE2_NONE;

-- 




[EGIT] [core/efl] master 26/77: evas/cserve2: Client-side scanning of Font Entries

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=df31807329ca500eb579d538abe9f21208426934

commit df31807329ca500eb579d538abe9f21208426934
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Aug 20 13:09:02 2013 +0900

evas/cserve2: Client-side scanning of Font Entries
---
 src/lib/evas/cserve2/evas_cs2_client.c  | 38 +
 src/lib/evas/cserve2/evas_cs2_private.h |  6 +++---
 2 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 47ede9b..5721d0b 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -54,6 +54,7 @@ static const File_Data *_shared_file_data_get_by_id(unsigned 
int id);
 static const Shm_Object *_shared_index_item_get_by_id(Shared_Index *si, int 
elemsize, unsigned int id);
 static const File_Data *_shared_image_entry_file_data_find(Image_Entry *ie);
 static const Image_Data *_shared_image_entry_image_data_find(Image_Entry *ie);
+static const Font_Data *_shared_font_entry_data_find(Font_Entry *fe);
 
 #ifndef UNIX_PATH_MAX
 #define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)-sun_path)
@@ -1171,6 +1172,8 @@ _font_entry_free(Font_Entry *fe)
  if (fe-fash[i])
fash_gl_free(fe-fash[i]);
 
+   eina_hash_del_by_key(_index.fonts.entries_by_hkey, fe-hkey);
+   free(fe-hkey);
eina_stringshare_del(fe-source);
eina_stringshare_del(fe-name);
eina_hash_foreach(fe-glyphs_maps, _glyphs_maps_foreach_free, NULL);
@@ -1235,7 +1238,8 @@ _font_load_server_send(Font_Entry *fe, Message_Type type)
 }
 
 Font_Entry *
-evas_cserve2_font_load(const char *source, const char *name, int size, int 
dpi, Font_Rend_Flags wanted_rend)
+evas_cserve2_font_load(const char *source, const char *name, int size, int dpi,
+   Font_Rend_Flags wanted_rend)
 {
Font_Entry *fe;
 
@@ -1260,12 +1264,36 @@ evas_cserve2_font_load(const char *source, const char 
*name, int size, int dpi,
eina_clist_init(fe-glyphs_queue);
eina_clist_init(fe-glyphs_used);
 
+   if (asprintf(fe-hkey, %s:%s/%u:%u:%u, fe-name, fe-source,
+fe-size, fe-dpi, (unsigned int) fe-wanted_rend) == -1)
+ fe-hkey = NULL;
+
return fe;
 }
 
 int
 evas_cserve2_font_load_wait(Font_Entry *fe)
 {
+#if USE_SHARED_INDEX
+   const Font_Data *fd;
+   Eina_Bool failed;
+   unsigned int rid, rrid;
+
+   rid = fe-rid;
+   rrid = _server_dispatch(failed);
+   if ((rid == rrid)  !fe-failed)
+ return CSERVE2_NONE;
+
+   fd = _shared_font_entry_data_find(fe);
+   if (fd)
+ {
+INF(Bypassing socket wait (rid %d), fe-rid);
+fe-failed = EINA_FALSE;
+fe-rid = 0;
+return CSERVE2_NONE;
+ }
+#endif
+
if (!_server_dispatch_until(fe-rid))
  return CSERVE2_GENERIC;
 
@@ -1762,7 +1790,9 @@ _server_index_list_set(Msg_Base *data, int size)
 
 
// 4. Font indexes
-   // TODO
+
+   eina_strlcpy(_index.fonts.path, msg-fonts_index_path, 
SHARED_BUFFER_PATH_MAX);
+   _shared_index_remap_check(_index.fonts, sizeof(Font_Data));
 
return 0;
 }
@@ -1826,7 +1856,7 @@ _shared_image_entry_file_data_find(Image_Entry *ie)
if (!_index.strings_index.header || !_index.strings_entries.data)
  return NULL;
 
-   if (!_index.files.header || !_index.files.entries.fdata)
+   if (!_index.files.header || !_index.files.entries.filedata)
  return NULL;
 
// Direct access
@@ -1851,7 +1881,7 @@ _shared_image_entry_file_data_find(Image_Entry *ie)
 const File_Data *fd;
 char fd_hkey[PATH_MAX];
 
-fd = (_index.files.entries.fdata[k]);
+fd = (_index.files.entries.filedata[k]);
 if (!fd-id) break;
 if (!fd-refcount) continue;
 
diff --git a/src/lib/evas/cserve2/evas_cs2_private.h 
b/src/lib/evas/cserve2/evas_cs2_private.h
index d1c5366..b1719e8 100644
--- a/src/lib/evas/cserve2/evas_cs2_private.h
+++ b/src/lib/evas/cserve2/evas_cs2_private.h
@@ -41,8 +41,8 @@ struct _Shared_Index
   const char *p; // Random access
   const Index_Entry *index; // TODO for strings
   const Image_Data *idata;
-  const File_Data *fdata;
-  // TODO Fonts
+  const File_Data *filedata;
+  const Font_Data *fontdata;
} entries;
int count;
Eina_Hash *entries_by_hkey;
@@ -64,7 +64,7 @@ struct _Index_Table
Shared_Index strings_index;
Shared_Index files;
Shared_Index images;
-   Shared_Index fonts; // TODO
+   Shared_Index fonts;
 };
 
 int evas_cserve2_init(void);

-- 




[EGIT] [core/efl] master 30/77: evas/cserve2: Add glyph shm names to Font_Data

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=bc7b337fc065dc922a039897e22f570a26fbf4be

commit bc7b337fc065dc922a039897e22f570a26fbf4be
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Aug 22 14:55:07 2013 +0900

evas/cserve2: Add glyph shm names to Font_Data
---
 src/bin/evas/evas_cserve2_cache.c | 8 
 src/lib/evas/cserve2/evas_cs2.h   | 1 +
 2 files changed, 9 insertions(+)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 9a9b82e..a1cda8c 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -1974,10 +1974,13 @@ _glyphs_load_request_response(Glyphs_Request *req,
Shared_Mempool *mempool = msg-mempool;
unsigned int j;
string_t shm_id = 0;
+   Font_Data *fd;
 
if (!msg-nglyphs)
  return _glyphs_loaded_msg_create(req, size);
 
+   fd = _font_data_find(fe-font_data_id);
+
DBG(Font memory usage [begin]: %d / %d, font_mem_usage, max_font_usage);
 
if (!mempool)
@@ -1995,6 +1998,8 @@ _glyphs_load_request_response(Glyphs_Request *req,
_generation_id,
sizeof(Glyph_Data), 0);
 font_mem_usage += cserve2_shared_array_map_size_get(fe-glyph_datas);
+fd-glyph_index_shm = cserve2_shared_string_add(
+ cserve2_shared_array_name_get(fe-glyph_datas));
  }
 
shm_id = 
cserve2_shared_string_add(cserve2_shared_mempool_name_get(mempool));
@@ -2058,6 +2063,9 @@ _glyphs_load_request_response(Glyphs_Request *req,
 #endif
 
fe-mempool = mempool;
+   if (!fd-mempool_shm)
+ fd-mempool_shm = cserve2_shared_string_add(
+  cserve2_shared_mempool_name_get(mempool));
 
DBG(Font memory usage [end]: %d / %d, font_mem_usage, max_font_usage);
_font_lru_flush();
diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h
index 2d3ad05..87633f0 100644
--- a/src/lib/evas/cserve2/evas_cs2.h
+++ b/src/lib/evas/cserve2/evas_cs2.h
@@ -351,6 +351,7 @@ struct _Font_Data {
string_t name;
string_t file;
string_t glyph_index_shm;
+   string_t mempool_shm;
uint32_t rend_flags;
uint32_t size;
uint32_t dpi;

-- 




[EGIT] [core/efl] master 74/77: evas/cserve2: Use Eina_Refcount instead of int

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4c44b5a553290f0e35675974da59b1205e06e850

commit 4c44b5a553290f0e35675974da59b1205e06e850
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Oct 11 14:47:07 2013 +0900

evas/cserve2: Use Eina_Refcount instead of int

Use the refcount macros instead of manually handling
integers. Not sure if it really helps since the refcounting
in cs2 client is a bit special :)
---
 src/lib/evas/cserve2/evas_cs2_client.c  | 76 ++---
 src/lib/evas/cserve2/evas_cs2_private.h |  2 +-
 2 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index df3573f..520c400 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -44,7 +44,7 @@ static const Evas_Image_Load_Opts empty_lo = {
 struct _File_Entry {
unsigned int file_id;
unsigned int server_file_id;
-   unsigned int refcount;
+   EINA_REFCOUNT;
Eina_Stringshare *hkey;
 };
 
@@ -980,14 +980,16 @@ _image_open_server_send(Image_Entry *ie)
 
 fentry-file_id = ++_file_id;
 fentry-hkey = eina_stringshare_add(hkey);
+EINA_REFCOUNT_INIT(fentry);
 eina_hash_direct_add(_file_entries, fentry-hkey, fentry);
  }
-   fentry-refcount++;
+   else
+ EINA_REFCOUNT_REF(fentry);
 
dentry = calloc(1, sizeof(*dentry));
if (!dentry)
  {
-if (!(--fentry-refcount))
+EINA_REFCOUNT_UNREF(fentry)
   eina_hash_del(_file_entries, fentry-hkey, fentry);
 return 0;
  }
@@ -1008,7 +1010,7 @@ _image_open_server_send(Image_Entry *ie)
buf = malloc(size);
if (!buf)
  {
-if (!(--fentry-refcount))
+EINA_REFCOUNT_UNREF(fentry)
   eina_hash_del(_file_entries, fentry-hkey, fentry);
 free(dentry);
 return 0;
@@ -1023,7 +1025,7 @@ _image_open_server_send(Image_Entry *ie)
  {
 ERR(Couldn't send message to server.);
 free(dentry);
-if (!(--fentry-refcount))
+EINA_REFCOUNT_UNREF(fentry)
   eina_hash_del(_file_entries, fentry-hkey, fentry);
 return 0;
  }
@@ -1131,7 +1133,7 @@ _image_close_server_send(Image_Entry *ie)
msg-base.type = CSERVE2_CLOSE;
msg-file_id = fentry-file_id;
 
-   if (!(--fentry-refcount))
+   EINA_REFCOUNT_UNREF(fentry)
  eina_hash_del(_file_entries, fentry-hkey, fentry);
ie-data1 = NULL;
 
@@ -1422,8 +1424,8 @@ struct _CS_Glyph_Out
unsigned int size;
unsigned int hint;
Eina_Bool used;
-   int refcount;
int pending_ref;
+   EINA_REFCOUNT;
 };
 
 static void
@@ -1684,13 +1686,12 @@ _glyph_map_remap_check(Glyph_Map *map, const char 
*idxpath, const char *datapath
 eina_strlcpy(map-index.path, idxpath, SHARED_BUFFER_PATH_MAX);
 
 // Reopen mempool
-if (map-mempool.refcount  0)
+if (EINA_REFCOUNT_GET(map-mempool)  0)
   {
  oldbuf = calloc(1, sizeof(Glyph_Map));
  oldbuf-f = map-mempool.f;
  oldbuf-data = map-mempool.data;
  oldbuf-size = map-mempool.size;
- oldbuf-refcount = map-mempool.refcount;
  eina_strlcpy(oldbuf-path, map-mempool.path, 
SHARED_BUFFER_PATH_MAX);
  map-mempool_lru = eina_list_append(map-mempool_lru, oldbuf);
   }
@@ -1704,18 +1705,21 @@ _glyph_map_remap_check(Glyph_Map *map, const char 
*idxpath, const char *datapath
 map-mempool.f = eina_file_open(datapath, EINA_TRUE);
 map-mempool.data = eina_file_map_all(map-mempool.f, 
EINA_FILE_RANDOM);
 map-mempool.size = eina_file_size_get(map-mempool.f);
-map-mempool.refcount = 0;
+EINA_REFCOUNT_GET(map-mempool) = 0;
 
 EINA_CLIST_FOR_EACH_ENTRY_SAFE(gl, cursor, map-glyphs,
CS_Glyph_Out, map_entry)
   {
- if (!gl-refcount)
+ if (!EINA_REFCOUNT_GET(gl))
{
   gl-sb = NULL;
   gl-base.bitmap.buffer = NULL;
}
  else
-   gl-sb = oldbuf;
+   {
+  gl-sb = oldbuf;
+  EINA_REFCOUNT_REF(gl-sb);
+   }
   }
 
 if (!eina_clist_count(map-glyphs))
@@ -1738,13 +1742,12 @@ _glyph_map_remap_check(Glyph_Map *map, const char 
*idxpath, const char *datapath
 // after some glyphs have been requested but not all for the current
 // draw.
 
-if (map-mempool.refcount  0)
+if (EINA_REFCOUNT_GET(map-mempool)  0)
   {
  oldbuf = calloc(1, sizeof(Glyph_Map));
  oldbuf-f = eina_file_dup(map-mempool.f);
  oldbuf-data = map-mempool.data;
  oldbuf-size = map-mempool.size;
- //oldbuf-refcount = map-mempool.refcount;
  eina_strlcpy(oldbuf-path, 

[EGIT] [core/efl] master 37/77: evas/cserve2: Use only one Glyph_Map per font

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=22009a3f644094816e2ae649dd3ad48b04825a5f

commit 22009a3f644094816e2ae649dd3ad48b04825a5f
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Aug 26 15:31:52 2013 +0900

evas/cserve2: Use only one Glyph_Map per font

In the new cs2 model, only one shared buffer is allocated
for a font, and it resizes on demand.
---
 src/lib/evas/cserve2/evas_cs2_client.c | 105 ++---
 1 file changed, 59 insertions(+), 46 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 16e1ebb..d6cedcc 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -55,6 +55,7 @@ static const Shm_Object 
*_shared_index_item_get_by_id(Shared_Index *si, int elem
 static const File_Data *_shared_image_entry_file_data_find(Image_Entry *ie);
 static const Image_Data *_shared_image_entry_image_data_find(Image_Entry *ie);
 static const Font_Data *_shared_font_entry_data_find(Font_Entry *fe);
+static Eina_Bool _shared_index_remap_check(Shared_Index *si, int elemsize);
 
 #ifndef UNIX_PATH_MAX
 #define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)-sun_path)
@@ -1100,7 +1101,7 @@ struct _Font_Entry
 
unsigned int rid; // open
 
-   Eina_Hash *glyphs_maps;
+   Glyph_Map *map;
Fash_Glyph2 *fash[3]; // one per hinting value
 
Eina_Clist glyphs_queue;
@@ -1114,10 +1115,8 @@ struct _Font_Entry
 struct _Glyph_Map
 {
Font_Entry *fe;
-   const char *name;
-   unsigned int size;
-   Eina_File *map;
-   unsigned char *data;
+   Shared_Index index;
+   Shared_Buffer mempool;
Eina_Clist glyphs;
 };
 
@@ -1135,12 +1134,15 @@ struct _CS_Glyph_Out
 };
 
 static void
-_glyphs_map_free(Glyph_Map *m)
+_glyphs_map_free(Glyph_Map *map)
 {
-   eina_file_map_free(m-map, m-data);
-   eina_file_close(m-map);
-   eina_stringshare_del(m-name);
-   free(m);
+   if (!map) return;
+   eina_file_map_free(map-mempool.f, map-mempool.data);
+   eina_file_close(map-mempool.f);
+   eina_file_map_free(map-index.f, map-index.data);
+   eina_file_close(map-index.f);
+   map-fe-map = NULL;
+   free(map);
 }
 
 static void
@@ -1150,28 +1152,14 @@ _glyph_out_free(void *gl)
 
if (glout-map)
  {
-// FIXME: Invalid write of size 8 here (64 bit machine)
 eina_clist_remove(glout-map_entry);
 if (eina_clist_empty(glout-map-glyphs))
-  {
- eina_hash_del(glout-map-fe-glyphs_maps, glout-map-name,
-   NULL);
- _glyphs_map_free(glout-map);
-  }
+  _glyphs_map_free(glout-map);
  }
 
free(glout);
 }
 
-static Eina_Bool
-_glyphs_maps_foreach_free(const Eina_Hash *hash EINA_UNUSED, const void *key 
EINA_UNUSED, void *data, void *fdata EINA_UNUSED)
-{
-   Glyph_Map *m = data;
-
-   _glyphs_map_free(m);
-   return EINA_TRUE;
-}
-
 static void
 _font_entry_free(Font_Entry *fe)
 {
@@ -1185,8 +1173,7 @@ _font_entry_free(Font_Entry *fe)
free(fe-hkey);
eina_stringshare_del(fe-source);
eina_stringshare_del(fe-name);
-   eina_hash_foreach(fe-glyphs_maps, _glyphs_maps_foreach_free, NULL);
-   eina_hash_free(fe-glyphs_maps);
+   _glyphs_map_free(fe-map);
free(fe);
 }
 
@@ -1269,7 +1256,6 @@ evas_cserve2_font_load(const char *source, const char 
*name, int size, int dpi,
 return NULL;
  }
 
-   fe-glyphs_maps = eina_hash_stringshared_new(NULL);
eina_clist_init(fe-glyphs_queue);
eina_clist_init(fe-glyphs_used);
 
@@ -1339,6 +1325,33 @@ typedef struct
unsigned int rid;
 } Glyph_Request_Data;
 
+static Glyph_Map *
+_glyph_map_open(Font_Entry *fe, const char *indexpath, const char *datapath)
+{
+   Glyph_Map *map;
+
+   if (!fe) return NULL;
+   if (fe-map) return fe-map;
+
+   map = calloc(1, sizeof(*map));
+   if (!map) return NULL;
+
+   map-fe = fe;
+   eina_clist_init(map-glyphs);
+   eina_strlcpy(map-index.path, indexpath, SHARED_BUFFER_PATH_MAX);
+   eina_strlcpy(map-mempool.path, datapath, SHARED_BUFFER_PATH_MAX);
+
+   map-index.generation_id = _index.generation_id;
+   _shared_index_remap_check(map-index, sizeof(Glyph_Data));
+
+   map-mempool.f = eina_file_open(map-mempool.path, EINA_TRUE);
+   map-mempool.size = eina_file_size_get(map-mempool.f);
+   map-mempool.data = eina_file_map_all(map-mempool.f, EINA_FILE_RANDOM);
+
+   fe-map = map;
+   return map;
+}
+
 static void
 _glyph_request_cb(void *data, const void *msg, int size)
 {
@@ -1349,7 +1362,6 @@ _glyph_request_cb(void *data, const void *msg, int size)
int i, nglyphs;
int namelen;
const char *name;
-   Glyph_Map *map;
int pos;
 
if (resp-base.type == CSERVE2_ERROR)
@@ -1372,25 +1384,27 @@ _glyph_request_cb(void *data, const void *msg, int size)
pos += namelen + sizeof(int);
if (pos  size) goto end;
 
-   name = eina_stringshare_add_length(buf, namelen);
+   name = buf; //eina_stringshare_add_length(buf, 

[EGIT] [core/efl] master 23/77: evas/cserve2: Store glyphs in shared arrays

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7ebda2d123ec53bad84dc7eabc08530477d50e80

commit 7ebda2d123ec53bad84dc7eabc08530477d50e80
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Aug 7 18:48:00 2013 +0900

evas/cserve2: Store glyphs in shared arrays

Also, change the internal structure of glyph listing:
 - Use lists instead of inlists

Switch to use Glyph_Data instead of Glyph_Entry
---
 src/bin/evas/evas_cserve2_cache.c  | 175 -
 src/lib/evas/cserve2/evas_cs2.h|  25 +++--
 src/lib/evas/cserve2/evas_cs2_client.c |   3 +
 3 files changed, 129 insertions(+), 74 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 3a66988..efe90be 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -75,7 +75,7 @@ struct _Font_Entry {
void *ft;
Fash_Glyph2 *glyphs;
unsigned int nglyphs;
-   Eina_Inlist *caches;
+   Eina_List *caches;
Font_Cache *last_cache;
Eina_Bool unused : 1;
 #ifdef DEBUG_LOAD_TIME
@@ -90,27 +90,18 @@ struct _Font_Entry {
 };
 
 struct _Font_Cache {
-   EINA_INLIST;
Font_Entry *fe;
Shm_Handle *shm;
unsigned int usage;
int inuse;
-   Eina_Inlist *glyphs;
+   Shared_Array *glyphs; // Contains gldata_id only
unsigned int nglyphs;
 };
 
 struct _Glyph_Entry {
-   EINA_INLIST;
+   unsigned int gldata_id;
Font_Entry *fe;
Font_Cache *fc;
-   unsigned int index;
-   unsigned int offset;
-   unsigned int size;
-   unsigned int rows;
-   unsigned int width;
-   unsigned int pitch;
-   unsigned int num_grays;
-   unsigned int pixel_mode;
 };
 
 struct _Glyphs_Request {
@@ -148,11 +139,13 @@ struct _File_Watch {
 };
 
 static unsigned int _entry_id = 0;
+static unsigned int _glyph_id = 0;
 static unsigned int _freed_file_entry_count = 0;
 static unsigned int _freed_image_entry_count = 0;
 
 static Shared_Array *_file_data_array = NULL;
 static Shared_Array *_image_data_array = NULL;
+static Shared_Array *_glyph_data_array = NULL;
 
 static Eina_Hash *file_ids = NULL; // maps path + key -- file_id
 static Eina_Hash *file_entries = NULL; // maps file_id -- entry
@@ -303,6 +296,22 @@ _image_entry_find(unsigned int entry_id)
return (Image_Entry *) e;
 }
 
+static Glyph_Data *
+_glyph_data_find(unsigned int glyph_id)
+{
+   Glyph_Data *gldata;
+
+   gldata = cserve2_shared_array_item_data_find(_glyph_data_array, glyph_id,
+_shm_object_id_cmp_cb);
+   if (!gldata)
+ {
+ERR(Could not find glyph %u, glyph_id);
+return NULL;
+ }
+
+   return gldata;
+}
+
 static Eina_Bool
 _repack_skip_cb(Shared_Array *sa EINA_UNUSED, const void *elem,
 void *user_data EINA_UNUSED)
@@ -1061,6 +1070,12 @@ static void
 _glyph_free_cb(void *data)
 {
Glyph_Entry *gl = data;
+   Glyph_Data *gldata;
+
+   if (!gl) return;
+   gldata = _glyph_data_find(gl-gldata_id);
+   cserve2_shared_string_del(gldata-shm_id);
+   gldata-refcount--;
free(gl);
 }
 
@@ -1096,18 +,22 @@ _font_shm_size_get(Font_Cache *fc)
 static void
 _font_shm_free(Font_Cache *fc)
 {
+   Glyph_Data *gd;
Font_Entry *fe = fc-fe;
-   fe-caches = eina_inlist_remove(fe-caches, EINA_INLIST_GET(fc));
+   unsigned int k;
+
+   fe-caches = eina_list_remove(fe-caches, fc);
if (fc == fe-last_cache)
  fe-last_cache = NULL;
 
-   while (fc-glyphs)
+   for (k = 0; k  fc-nglyphs; k++)
  {
-Glyph_Entry *gl = EINA_INLIST_CONTAINER_GET(fc-glyphs, Glyph_Entry);
-fc-glyphs = eina_inlist_remove(fc-glyphs, fc-glyphs);
-fash_gl_del(fe-glyphs, gl-index);
+int *gldata_id = cserve2_shared_array_item_data_get(fc-glyphs, k);
+gd = _glyph_data_find(*gldata_id);
+fash_gl_del(fe-glyphs, gd-index);
  }
 
+   cserve2_shared_array_del(fc-glyphs);
cserve2_shm_unref(fc-shm);
free(fc);
 
@@ -1161,6 +1180,7 @@ cserve2_cache_init(void)
 
_file_data_array = cserve2_shared_array_new(1, sizeof(File_Data), 0);
_image_data_array = cserve2_shared_array_new(1, sizeof(Image_Data), 0);
+   _glyph_data_array = cserve2_shared_array_new(1, sizeof(Glyph_Data), 0);
 }
 
 void
@@ -1182,6 +1202,7 @@ cserve2_cache_shutdown(void)
 
cserve2_shared_array_del(_file_data_array);
cserve2_shared_array_del(_image_data_array);
+   cserve2_shared_array_del(_glyph_data_array);
 }
 
 static Reference *
@@ -1716,7 +1737,7 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int 
*resp_size)
 size += sizeof(int);
 // nglyphs * (index + offset + size + rows + width + pitch +
 //num_grays + pixel_mode)
-size += eina_list_count(iter-glyphs) * 8 * sizeof(int);
+size += eina_list_count(iter-glyphs) * 9 * sizeof(int);
  }
 
resp = malloc(size);
@@ -1743,21 +1764,27 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int 
*resp_size)
 
 

[EGIT] [core/efl] master 14/77: evas/cserve2: Prepare shared indexes in clients

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=47be3a2b819ed6319a65018195b31b622b547aab

commit 47be3a2b819ed6319a65018195b31b622b547aab
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Jul 29 13:08:36 2013 +0900

evas/cserve2: Prepare shared indexes in clients

- Move required struct definitions to common evas_cs2.h

- Open/close shm and map arrays to memory
Pretty stupid for now as it will close  reopen the shm files
even when unchanged.

- Check shm size and array header consistency

- Implement message send

- Send messages from server when calling repack()
---
 src/bin/evas/evas_cserve2.h |   1 +
 src/bin/evas/evas_cserve2_cache.c   |  49 +++-
 src/bin/evas/evas_cserve2_index.c   |  13 ---
 src/bin/evas/evas_cserve2_main.c|  29 +++
 src/lib/evas/cserve2/evas_cs2.h |  68 +++-
 src/lib/evas/cserve2/evas_cs2_client.c  | 137 
 src/lib/evas/cserve2/evas_cs2_private.h |  23 ++
 7 files changed, 267 insertions(+), 53 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 1e1a055..c91e822 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -233,6 +233,7 @@ void cserve2_client_del(Client *client);
 void cserve2_client_deliver(Client *client);
 void cserve2_client_error_send(Client *client, unsigned int rid, int 
error_code);
 ssize_t cserve2_client_send(Client *client, const void *data, size_t size);
+void cserve2_index_list_send(const char *files_index_path, const char 
*images_index_path, const char *fonts_index_path);
 
 Eina_Bool cserve2_fd_watch_add(int fd, Fd_Flags flags, Fd_Watch_Cb cb, const 
void *data);
 Eina_Bool cserve2_fd_watch_del(int fd);
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index b1fc2ee..777d35c 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -14,19 +14,14 @@
 
 #include Evas_Loader.h
 
-typedef int string_t;
 #define ENTRY Entry base
 #define ASENTRY(a) ((a-base))
 #define ENTRYID(a) ((a)-base.id)
-#define SHMOBJECT unsigned int id; unsigned int refcount
 
 typedef struct _Entry Entry;
-typedef struct _Shm_Object Shm_Object;
 typedef struct _Reference Reference;
 typedef struct _File_Entry File_Entry;
-typedef struct _File_Data File_Data;
 typedef struct _Image_Entry Image_Entry;
-typedef struct _Image_Data Image_Data;
 typedef struct _File_Watch File_Watch;
 
 typedef struct _Font_Source Font_Source;
@@ -52,46 +47,17 @@ struct _Entry {
 #endif
 };
 
-struct _Shm_Object
-{
-   SHMOBJECT;
-};
-
 struct _File_Entry {
ENTRY;
File_Watch *watcher;
Eina_List *images;
 };
 
-struct _File_Data {
-   SHMOBJECT;
-   string_t path;
-   string_t key;
-   string_t loader_data;
-   int w, h;
-   int frame_count;
-   int loop_count;
-   int loop_hint;
-   Eina_Bool alpha : 1;
-   Eina_Bool invalid : 1;
-};
-
-
 struct _Image_Entry {
ENTRY;
Shm_Handle *shm;
 };
 
-struct _Image_Data {
-   SHMOBJECT;
-   unsigned int file_id;
-   string_t shm_id;
-   Evas_Image_Load_Opts opts;
-   Eina_Bool alpha_sparse : 1;
-   Eina_Bool unused : 1;
-   Eina_Bool doload : 1;
-};
-
 struct _Font_Source {
string_t key;
string_t name;
@@ -350,12 +316,11 @@ _repack()
Shared_Array *sa;
int count;
 
-   count = cserve2_shared_array_size_get(_file_data_array);
-   if (count = 0) return;
-
// Repack when we have 10% fragmentation over the whole shm buffer
-   if (_freed_entry_count  100 ||
-   ((_freed_entry_count * 100) / count = 10))
+
+   count = cserve2_shared_array_size_get(_file_data_array);
+   if ((count  0)  (_freed_entry_count  100 ||
+   ((_freed_entry_count * 100) / count = 10)))
  {
 DBG(Repacking file data array: %s,
 cserve2_shared_array_name_get(_file_data_array));
@@ -373,6 +338,12 @@ _repack()
 _freed_entry_count = 0;
 _file_data_array = sa;
  }
+
+   // FIXME TODO: Repack image data array as well
+
+   cserve2_index_list_send(cserve2_shared_array_name_get(_file_data_array),
+   cserve2_shared_array_name_get(_image_data_array),
+   NULL);
 }
 
 
diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
index debaedc..329ceeb 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -14,7 +14,6 @@
 typedef struct _Data_Shm Data_Shm;
 typedef struct _Index_Entry Index_Entry;
 typedef struct _Block Block;
-typedef struct _Shared_Array_Header Shared_Array_Header;
 typedef struct _Shared_Index Shared_Index;
 
 static int _instances = 0;
@@ -31,18 +30,6 @@ struct _Data_Shm
char *data;
 };
 
-struct _Shared_Array_Header
-{
-   int32_t tag;
-   int32_t elemsize;
-   int32_t count;
-   int32_t generation_id;
-   int32_t emptyidx;
-   int32_t sortedidx;
-   

[EGIT] [core/efl] master 45/77: evas/cserve2: Small performance fixes

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=50be9145a1d6706ae0aaa5a81211e214d37422fd

commit 50be9145a1d6706ae0aaa5a81211e214d37422fd
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Aug 27 15:35:22 2013 +0900

evas/cserve2: Small performance fixes
---
 src/bin/evas/evas_cserve2_index.c  | 6 +-
 src/bin/evas/evas_cserve2_slaves.c | 2 +-
 src/lib/evas/cserve2/evas_cs2_client.c | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
index 2c4d9dc..ce5b93a 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -550,11 +550,15 @@ _shared_index_entry_get_by_id(Shared_Index *si, unsigned 
int id)
 obj = (Index_Entry *) (base + (elemsize * id));
 if (obj-id == id)
   return obj;
+if (obj-id  id)
+  low = id + 1;
+else
+  high = id;
  }
 
// Binary search
start_high = high;
-   while(high != low)
+   while(high  low)
  {
 cur = low + ((high - low) / 2);
 obj = (Index_Entry *) (base + (elemsize * cur));
diff --git a/src/bin/evas/evas_cserve2_slaves.c 
b/src/bin/evas/evas_cserve2_slaves.c
index 3bbf39d..a1fc7f5 100644
--- a/src/bin/evas/evas_cserve2_slaves.c
+++ b/src/bin/evas/evas_cserve2_slaves.c
@@ -128,7 +128,7 @@ _slave_proc_dead_cb(int pid, int status EINA_UNUSED)
 {
Slave_Proc *s;
 
-   DBG(Child dead with pid '%d'., pid);
+   INF(Child dead with pid '%d'., pid);
s = _slave_proc_find(pid);
if (!s)
  {
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 4a00521..01bd8b7 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1447,13 +1447,15 @@ _font_entry_glyph_map_rebuild_check(Font_Entry *fe, 
Font_Hint_Flags hints)
fe-map-mempool.data + gl-offset;
  gl-base.bitmap.num_grays = gd-num_grays;
  gl-base.bitmap.pixel_mode = gd-pixel_mode;
+ gl-idx = gd-index;
  gl-rid = 0;
 
  eina_clist_add_head(fe-map-glyphs, gl-map_entry);
  fash_gl_add(fe-fash[hints], gd-index, gl);
  cnt++;
   }
-DBG(Added %d glyphs to the font hash (out of %d scanned), cnt, tot);
+if (cnt)
+  DBG(Added %d glyphs to the font hash (out of %d scanned), cnt, 
tot);
  }
 
return cnt;

-- 




[EGIT] [core/efl] master 15/77: evas/cserve2: Share paths of index tables with clients

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=88ef4131a0df0735ebef19306285b4bea608cbab

commit 88ef4131a0df0735ebef19306285b4bea608cbab
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Jul 29 15:41:23 2013 +0900

evas/cserve2: Share paths of index tables with clients

- Send paths to all connected clients
- Send paths upon connection from a new client

- Client side:
 - Fast find opened images
 - Fast find loaded images
 - Optimize load by skipping socket wait

Also, remap indexes when needed (file size changed)
When index file grows, the clients are not notified, so they
must constantly check that their mapping matches the current array
size.
---
 src/bin/evas/evas_cserve2.h |   4 +-
 src/bin/evas/evas_cserve2_cache.c   |  74 +++-
 src/bin/evas/evas_cserve2_index.c   |  35 +-
 src/bin/evas/evas_cserve2_main.c|  31 +-
 src/lib/evas/cserve2/evas_cs2.h |  12 +
 src/lib/evas/cserve2/evas_cs2_client.c  | 616 ++--
 src/lib/evas/cserve2/evas_cs2_private.h |  55 +--
 7 files changed, 654 insertions(+), 173 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index c91e822..f4a1d8d 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -233,7 +233,7 @@ void cserve2_client_del(Client *client);
 void cserve2_client_deliver(Client *client);
 void cserve2_client_error_send(Client *client, unsigned int rid, int 
error_code);
 ssize_t cserve2_client_send(Client *client, const void *data, size_t size);
-void cserve2_index_list_send(const char *files_index_path, const char 
*images_index_path, const char *fonts_index_path);
+void cserve2_index_list_send(const char *strings_index_path, const char 
*strings_entries_path, const char *files_index_path, const char 
*images_index_path, const char *fonts_index_path, Client *client);
 
 Eina_Bool cserve2_fd_watch_add(int fd, Fd_Flags flags, Fd_Watch_Cb cb, const 
void *data);
 Eina_Bool cserve2_fd_watch_del(int fd);
@@ -357,6 +357,8 @@ void *cserve2_shared_mempool_buffer_get(Shared_Mempool *sm, 
int bufferid);
 
 
 // Shared strings
+const char *cserve2_shared_strings_table_name_get();
+const char *cserve2_shared_strings_index_name_get();
 int cserve2_shared_string_add(const char *str);
 int cserve2_shared_string_ref(int id);
 void cserve2_shared_string_del(int id);
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 777d35c..5bbe014 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -148,7 +148,8 @@ struct _File_Watch {
 };
 
 static unsigned int _entry_id = 0;
-static unsigned int _freed_entry_count = 0;
+static unsigned int _freed_file_entry_count = 0;
+static unsigned int _freed_image_entry_count = 0;
 
 static Shared_Array *_file_data_array = NULL;
 static Shared_Array *_image_data_array = NULL;
@@ -315,12 +316,13 @@ _repack()
 {
Shared_Array *sa;
int count;
+   Eina_Bool updated = EINA_FALSE;
 
// Repack when we have 10% fragmentation over the whole shm buffer
 
count = cserve2_shared_array_size_get(_file_data_array);
-   if ((count  0)  (_freed_entry_count  100 ||
-   ((_freed_entry_count * 100) / count = 10)))
+   if ((count  0)  (_freed_file_entry_count  100 ||
+   ((_freed_file_entry_count * 100) / count = 10)))
  {
 DBG(Repacking file data array: %s,
 cserve2_shared_array_name_get(_file_data_array));
@@ -331,19 +333,46 @@ _repack()
 if (!sa)
   {
  ERR(Failed to repack array. Keeping previous references!);
- return;
+ goto skip_files;
   }
 
 cserve2_shared_array_del(_file_data_array);
-_freed_entry_count = 0;
+_freed_file_entry_count = 0;
 _file_data_array = sa;
+updated = EINA_TRUE;
  }
+skip_files:
 
-   // FIXME TODO: Repack image data array as well
+   count = cserve2_shared_array_size_get(_image_data_array);
+   if ((count  0)  (_freed_image_entry_count  100 ||
+   ((_freed_image_entry_count * 100) / count = 10)))
+ {
+DBG(Repacking image data array: %s,
+cserve2_shared_array_name_get(_image_data_array));
 
-   cserve2_index_list_send(cserve2_shared_array_name_get(_file_data_array),
-   cserve2_shared_array_name_get(_image_data_array),
-   NULL);
+sa = cserve2_shared_array_repack(_image_data_array,
+ _repack_skip_cb,
+ _shm_object_id_cmp_cb, NULL);
+if (!sa)
+  {
+ ERR(Failed to repack array. Keeping previous references!);
+ goto skip_images;
+  }
+
+cserve2_shared_array_del(_image_data_array);
+_freed_image_entry_count = 0;
+

[EGIT] [core/efl] master 32/77: evas/cserve2: Optimize shared strings

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=743e2047636ee7deb8dca87afd8651aa0c83bffb

commit 743e2047636ee7deb8dca87afd8651aa0c83bffb
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Aug 22 16:53:51 2013 +0900

evas/cserve2: Optimize shared strings

Shared string indexes are not repacked, since they live in a
memory pool (where the indexes can be reused).
So, the index in the table is equal to their ID. Add initial
test to check if the item at index n has the ID n.
---
 src/bin/evas/evas_cserve2_index.c  | 8 
 src/bin/evas/evas_cserve2_shm_debug.c  | 8 
 src/lib/evas/cserve2/evas_cs2_client.c | 8 
 3 files changed, 24 insertions(+)

diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
index 699ef95..816a686 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -544,6 +544,14 @@ _shared_index_entry_get_by_id(Shared_Index *si, unsigned 
int id)
base = si-sa-ds-data + sizeof(Shared_Array_Header);
elemsize = si-sa-header-elemsize;
 
+   // Direct access, works for non-repacked arrays
+   if ((int) id  high)
+ {
+obj = (Index_Entry *) (base + (elemsize * id));
+if (obj-id == id)
+  return obj;
+ }
+
// Binary search
start_high = high;
while(high != low)
diff --git a/src/bin/evas/evas_cserve2_shm_debug.c 
b/src/bin/evas/evas_cserve2_shm_debug.c
index e17e5d2..bde62bd 100644
--- a/src/bin/evas/evas_cserve2_shm_debug.c
+++ b/src/bin/evas/evas_cserve2_shm_debug.c
@@ -286,6 +286,14 @@ _shared_index_item_get_by_id(Shm_File *si, int elemsize, 
unsigned int id)
 
base = si-data  + sizeof(Shared_Array_Header);
 
+   // Direct access, works for non-repacked arrays
+   if ((int) id  high)
+ {
+obj = (Shm_Object *) (base + (elemsize * id));
+if (obj-id == id)
+  return obj;
+ }
+
// Binary search
start_high = high;
while(high != low)
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 5721d0b..9bcf966 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1929,6 +1929,14 @@ _shared_index_item_get_by_id(Shared_Index *si, int 
elemsize, unsigned int id)
 
base = si-data  + sizeof(Shared_Array_Header);
 
+   // Direct access, works for non-repacked arrays
+   if ((int) id  high)
+ {
+obj = (Shm_Object *) (base + (elemsize * id));
+if (obj-id == id)
+  return obj;
+ }
+
// Binary search
start_high = high;
while(high != low)

-- 




[EGIT] [core/efl] master 66/77: evas/cserve2: Implement support for GL engine

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3889feca24ad3dba2aead16261a6b8dde0687b57

commit 3889feca24ad3dba2aead16261a6b8dde0687b57
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Oct 2 15:07:25 2013 +0900

evas/cserve2: Implement support for GL engine

Simply call the appropriate cache2 functions when possible
and check for usage of cache2 whenever an evas_cache_ function
is called.

This effectively adds cserve2 image (data) load support for the
GL engines. Fonts were already working out-of-the-box.
---
 src/modules/evas/engines/gl_common/evas_gl_image.c | 147 ++---
 1 file changed, 132 insertions(+), 15 deletions(-)

diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c 
b/src/modules/evas/engines/gl_common/evas_gl_image.c
index 2317790..36b40aa 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -1,5 +1,9 @@
 #include evas_gl_private.h
 
+#ifdef EVAS_CSERVE2
+#include evas_cs2_private.h
+#endif
+
 void
 evas_gl_common_image_alloc_ensure(Evas_GL_Image *im)
 {
@@ -16,7 +20,15 @@ evas_gl_common_image_all_unload(Evas_Engine_GL_Context *gc)
 
EINA_LIST_FOREACH(gc-shared-images, l, im)
  {
-if (im-im) evas_cache_image_unload_data(im-im-cache_entry);
+if (im-im)
+  {
+#ifdef EVAS_CSERVE2
+ if (evas_cache2_image_cached(im-im-cache_entry))
+   evas_cache2_image_unload_data(im-im-cache_entry);
+ else
+#endif
+   evas_cache_image_unload_data(im-im-cache_entry);
+  }
 if (im-tex)
   {
  if (!im-tex-pt-dyn.img)
@@ -141,7 +153,12 @@ _evas_gl_common_image(Evas_Engine_GL_Context *gc, 
RGBA_Image *im_im, Evas_Image_
im = calloc(1, sizeof(Evas_GL_Image));
if (!im)
  {
-evas_cache_image_drop((im_im-cache_entry));
+#ifdef EVAS_CSERVE2
+if (evas_cache2_image_cached(im_im-cache_entry))
+  evas_cache2_image_close((im_im-cache_entry));
+else
+#endif
+  evas_cache_image_drop((im_im-cache_entry));
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
return NULL;
  }
@@ -163,6 +180,26 @@ evas_gl_common_image_load(Evas_Engine_GL_Context *gc, 
const char *file, const ch
 {
RGBA_Image *im_im;
 
+#ifdef EVAS_CSERVE2
+   if (evas_cserve2_use_get())
+ {
+im_im = (RGBA_Image *) evas_cache2_image_open
+  (evas_common_image_cache2_get(), file, key, lo, error);
+if (im_im)
+  {
+ *error = evas_cache2_image_open_wait(im_im-cache_entry);
+ if ((*error != EVAS_LOAD_ERROR_NONE)
+  im_im-cache_entry.animated.animated)
+   {
+  evas_cache2_image_close(im_im-cache_entry);
+  im_im = NULL;
+   }
+ else
+   return _evas_gl_common_image(gc, im_im, lo, error);
+  }
+ }
+#endif
+
im_im = evas_common_load_image_from_file(file, key, lo, error);
if (!im_im) return NULL;
 
@@ -174,6 +211,26 @@ evas_gl_common_image_mmap(Evas_Engine_GL_Context *gc, 
Eina_File *f, const char *
 {
RGBA_Image *im_im;
 
+#ifdef EVAS_CSERVE2
+   if (evas_cserve2_use_get()  !eina_file_virtual(f))
+ {
+im_im = (RGBA_Image *) evas_cache2_image_open
+  (evas_common_image_cache2_get(), eina_file_filename_get(f), key, lo, 
error);
+if (im_im)
+  {
+ *error = evas_cache2_image_open_wait(im_im-cache_entry);
+ if ((*error != EVAS_LOAD_ERROR_NONE)
+  im_im-cache_entry.animated.animated)
+   {
+  evas_cache2_image_close(im_im-cache_entry);
+  im_im = NULL;
+   }
+ else
+   return _evas_gl_common_image(gc, im_im, lo, error);
+  }
+ }
+#endif
+
im_im = evas_common_load_image_from_mmap(f, key, lo, error);
if (!im_im) return NULL;
 
@@ -341,7 +398,12 @@ evas_gl_common_image_alpha_set(Evas_GL_Image *im, int 
alpha)
im-alpha = alpha;
if (!im-im) return im;
evas_gl_common_image_alloc_ensure(im);
-   evas_cache_image_load_data(im-im-cache_entry);
+#ifdef EVAS_CSERVE2
+   if (evas_cache2_image_cached(im-im-cache_entry))
+ evas_cache2_image_load_data(im-im-cache_entry);
+   else
+#endif
+ evas_cache_image_load_data(im-im-cache_entry);
im-im-cache_entry.flags.alpha = alpha ? 1 : 0;
 
if (im-tex) evas_gl_common_texture_free(im-tex, EINA_TRUE);
@@ -376,7 +438,12 @@ evas_gl_common_image_native_enable(Evas_GL_Image *im)
  }
if (im-im)
  {
-evas_cache_image_drop(im-im-cache_entry);
+#ifdef EVAS_CSERVE2
+if (evas_cache2_image_cached(im-im-cache_entry))
+  evas_cache2_image_close(im-im-cache_entry);
+else
+#endif
+  evas_cache_image_drop(im-im-cache_entry);
 im-im = NULL;
  }
if 

[EGIT] [core/efl] master 72/77: evas/cserve2: catch only SIGINT from cserve2

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=745b4d4acc64432b5b531054b94592bee6d55340

commit 745b4d4acc64432b5b531054b94592bee6d55340
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Oct 11 12:07:43 2013 +0900

evas/cserve2: catch only SIGINT from cserve2

SIGTERM and SIGQUIT don't need to be caught.
the proper signal to ask cserve2 to exit cleanly is SIGINT.

enlightenment_start (or systemd) should be responsible for
restarting in case of crash / unexpected termination.

cserve2 will not restart if killed with signal SIGINT,
as it will then exit with return code 0 (normal)
---
 src/bin/evas/evas_cserve2_main_loop_linux.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_main_loop_linux.c 
b/src/bin/evas/evas_cserve2_main_loop_linux.c
index 18b4662..7f17618 100644
--- a/src/bin/evas/evas_cserve2_main_loop_linux.c
+++ b/src/bin/evas/evas_cserve2_main_loop_linux.c
@@ -131,8 +131,6 @@ _signalfd_handler(int fd, Fd_Flags flags EINA_UNUSED, void 
*data EINA_UNUSED)
  _signal_handle_child(sinfo);
  break;
case SIGINT:
-   case SIGTERM:
-   case SIGQUIT:
  _signal_handle_exit(sinfo);
  break;
case SIGUSR1:
@@ -161,10 +159,8 @@ _signalfd_setup(void)
 
sigemptyset(mask);
sigaddset(mask, SIGCHLD);
-   sigaddset(mask, SIGTERM);
-   sigaddset(mask, SIGQUIT);
-   sigaddset(mask, SIGUSR1);
-   sigaddset(mask, SIGUSR2);
+   sigaddset(mask, SIGUSR1); // ignored
+   sigaddset(mask, SIGUSR2); // ignored
 
if (sigprocmask(SIG_BLOCK, mask, NULL) == -1)
  {

-- 




[EGIT] [core/efl] master 24/77: evas/cserve2: Add mempool_buffer_offset_get() api

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c7515f3300157419c42d8a9d224c46babebae37c

commit c7515f3300157419c42d8a9d224c46babebae37c
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Aug 14 13:57:41 2013 +0900

evas/cserve2: Add mempool_buffer_offset_get() api
---
 src/bin/evas/evas_cserve2_index.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
index ecafa31..ccb4903 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -821,6 +821,22 @@ cserve2_shared_mempool_buffer_get(Shared_Mempool *sm, int 
bufferid)
return data;
 }
 
+int
+cserve2_shared_mempool_buffer_offset_get(Shared_Mempool *sm, int bufferid)
+{
+   Index_Entry *ie;
+
+   if (!sm) return -1;
+   ie = _shared_index_entry_get_by_id(sm-index, bufferid);
+   if (!ie || ie-refcount = 0)
+ {
+CRIT(Tried to access invalid buffer or with refcount 0);
+return -1;
+ }
+
+   return ie-offset;
+}
+
 
 // Shared strings
 

-- 




[EGIT] [core/efl] master 27/77: evas/cserve2: Fix cserve2_usage tool

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=1e4ee656a0c44cbf915e124aa59c50fdde9f0973

commit 1e4ee656a0c44cbf915e124aa59c50fdde9f0973
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Aug 20 18:26:02 2013 +0900

evas/cserve2: Fix cserve2_usage tool

Also, print shared arrays usage as it is sent as first message
upon connection to the server.

Add fonts to LRU and flush LRU as needed.
Seems to work okay. Could probably be finetuned a bit.
---
 src/bin/evas/evas_cserve2.h   |   1 +
 src/bin/evas/evas_cserve2_cache.c | 495 +-
 src/bin/evas/evas_cserve2_debug.c | 136 +--
 src/bin/evas/evas_cserve2_index.c |  10 +-
 src/bin/evas/evas_cserve2_usage.c |  85 +--
 src/lib/evas/cserve2/evas_cs2.h   |  19 +-
 6 files changed, 255 insertions(+), 491 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 88f4370..badd33c 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -352,6 +352,7 @@ const char *cserve2_shared_array_name_get(Shared_Array *sa);
 void cserve2_shared_array_del(Shared_Array *sa);
 int cserve2_shared_array_size_get(Shared_Array *sa);
 int cserve2_shared_array_count_get(Shared_Array *sa);
+int cserve2_shared_array_map_size_get(Shared_Array *sa);
 int cserve2_shared_array_item_size_get(Shared_Array *sa);
 int cserve2_shared_array_generation_id_get(Shared_Array *sa);
 int cserve2_shared_array_size_set(Shared_Array *sa, int newcount);
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 7c7932e..86fb804 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -1080,12 +1080,34 @@ _font_entry_key_hash(const Font_Entry *key, int 
key_length EINA_UNUSED)
return hash;
 }
 
+static int
+_font_entry_memory_usage_get(Font_Entry *fe)
+{
+   int size;
+
+   if (!fe) return 0;
+   if (!fe-mempool  !fe-glyph_datas)
+ return 0;
+
+   size = cserve2_shared_mempool_size_get(fe-mempool);
+   size += cserve2_shared_array_map_size_get(fe-glyph_datas);
+   size += fe-nglyphs * sizeof(Glyph_Entry);
+
+   return size;
+}
+
 static void
 _font_entry_free(Font_Entry *fe)
 {
Font_Data *fd;
+   int size;
 
if (!fe) return;
+   size = _font_entry_memory_usage_get(fe);
+
+   DBG(Font memory usage down: %d - %d / %d, font_mem_usage,
+   font_mem_usage - size, max_font_usage);
+   font_mem_usage -= size;
 
fd = _font_data_find(fe-font_data_id);
if (fd)
@@ -1098,6 +1120,7 @@ _font_entry_free(Font_Entry *fe)
 
fash_gl_free(fe-glyph_entries);
cserve2_shared_array_del(fe-glyph_datas);
+   cserve2_shared_mempool_del(fe-mempool);
cserve2_font_ft_free(fe-ft);
fe-src-refcount--;
if (fe-src-refcount = 0)
@@ -1141,79 +1164,49 @@ _font_source_free(Font_Source *fs)
free(fs);
 }
 
-#if 0
 static void
-_font_shm_promote(Font_Cache *fc)
+_font_lru_update(Font_Entry *fe)
 {
Eina_List *l;
-   l = eina_list_data_find_list(font_shm_lru, fc);
-   font_shm_lru = eina_list_demote_list(font_shm_lru, l);
-}
-
-static int
-_font_shm_size_get(Font_Cache *fc)
-{
-   int size;
-
-   size = sizeof(*fc) + cserve2_shm_size_get(fc-shm);
-
-   return size;
-}
-
-static void
-_font_shm_free(Font_Cache *fc)
-{
-   Glyph_Data *gd;
-   Font_Entry *fe = fc-fe;
-   unsigned int k;
-
-   fe-caches = eina_list_remove(fe-caches, fc);
-   if (fc == fe-last_cache)
- fe-last_cache = NULL;
-
-   for (k = 0; k  fc-nglyphs; k++)
+   l = eina_list_data_find_list(font_shm_lru, fe);
+   if (l)
  {
-int *gldata_id = cserve2_shared_array_item_data_get(fc-glyphs, k);
-gd = _glyph_data_find(*gldata_id);
-fash_gl_del(fe-glyphs, gd-index);
+if (fe-unused)
+  font_shm_lru = eina_list_promote_list(font_shm_lru, l);
+else
+  font_shm_lru = eina_list_demote_list(font_shm_lru, l);
  }
-
-   cserve2_shared_array_del(fc-glyphs);
-   cserve2_shm_unref(fc-shm);
-   free(fc);
-
-   if (!fe-caches)
- eina_hash_del_by_key(font_entries, fe);
+   else
+ font_shm_lru = eina_list_append(font_shm_lru, fe);
 }
 
 static void
-_font_shm_lru_flush(void)
+_font_lru_flush(void)
 {
Eina_List *l, *l_next;
 
l = font_shm_lru;
l_next = eina_list_next(l);
 
+   DBG(Font memory usage [begin]: %d / %d, font_mem_usage, max_font_usage);
+
while (l  font_mem_usage  max_font_usage)
  {
-int size;
-Font_Cache *fc;
+Font_Entry *fe;
 
-fc = eina_list_data_get(l);
-if (fc-fe-unused  fc-inuse == 0)
+fe = eina_list_data_get(l);
+if (fe-unused)
   {
  font_shm_lru = eina_list_remove_list(font_shm_lru, l);
- size = _font_shm_size_get(fc);
- size += fc-nglyphs * sizeof(Glyph_Entry);
- _font_shm_free(fc);
- font_mem_usage -= size;
+ eina_hash_del_by_key(font_entries, fe);
  

[EGIT] [core/efl] master 52/77: evas/cserve2: Reuse file entries when possible

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=31a5bfb46427265cd0537c0e61146a4960b7f557

commit 31a5bfb46427265cd0537c0e61146a4960b7f557
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Sep 3 15:24:27 2013 +0900

evas/cserve2: Reuse file entries when possible

For some reason, a new File_Entry was created whenever
a new image is loaded, even if that file was already
opened by the client.
---
 src/lib/evas/cserve2/evas_cs2_client.c | 56 --
 1 file changed, 47 insertions(+), 9 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 59ca540..852ae08 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -26,6 +26,8 @@ typedef void (*Op_Callback)(void *data, const void *msg, int 
size);
 struct _File_Entry {
unsigned int file_id;
unsigned int server_file_id;
+   unsigned int refcount;
+   Eina_Stringshare *hkey;
 };
 
 struct _Client_Request {
@@ -46,6 +48,7 @@ static unsigned int _file_id = 0;
 static unsigned int _data_id = 0;
 
 static Eina_List *_requests = NULL;
+static Eina_Hash *_file_entries = NULL;
 
 // Shared index table
 static Index_Table _index;
@@ -82,6 +85,15 @@ _memory_zero_cmp(void *data, size_t len)
 }
 
 static void
+_file_entry_free(void *data)
+{
+   File_Entry *fentry = data;
+   if (!fentry) return;
+   eina_stringshare_del(fentry-hkey);
+   free(fentry);
+}
+
+static void
 _socket_path_set(char *path)
 {
char *env;
@@ -304,6 +316,7 @@ evas_cserve2_init(void)
 return 0;
  }
 
+   _file_entries = 
eina_hash_string_superfast_new(EINA_FREE_CB(_file_entry_free));
return cserve2_init;
 }
 
@@ -313,6 +326,12 @@ evas_cserve2_shutdown(void)
const char zeros[sizeof(Msg_Index_List)] = {0};
Msg_Index_List *empty = (Msg_Index_List *) zeros;
 
+   if (cserve2_init = 0)
+ {
+CRIT(cserve2 is already shutdown);
+return -1;
+ }
+
if ((--cserve2_init)  0)
  return cserve2_init;
 
@@ -321,6 +340,9 @@ evas_cserve2_shutdown(void)
_server_index_list_set((Msg_Base *) empty, sizeof(Msg_Index_List));
_server_disconnect();
 
+   eina_hash_free(_file_entries);
+   _file_entries = NULL;
+
return cserve2_init;
 }
 
@@ -674,6 +696,7 @@ _image_open_server_send(Image_Entry *ie, const char *file, 
const char *key,
int size;
char *buf;
char filebuf[PATH_MAX];
+   char *file_hkey;
Msg_Open msg_open;
File_Entry *fentry;
Data_Entry *dentry;
@@ -696,23 +719,35 @@ _image_open_server_send(Image_Entry *ie, const char 
*file, const char *key,
flen++;
 
if (!key) key = ;
+   klen = strlen(key) + 1;
 
-   fentry = calloc(1, sizeof(*fentry));
+   file_hkey = alloca(flen + klen);
+   memcpy(file_hkey, file, flen);
+   file_hkey[flen - 1] = ':';
+   memcpy(file_hkey + flen, key, klen);
+   fentry = eina_hash_find(_file_entries, file_hkey);
if (!fentry)
- return 0;
+ {
+fentry = calloc(1, sizeof(*fentry));
+if (!fentry)
+  return 0;
+
+fentry-file_id = ++_file_id;
+fentry-hkey = eina_stringshare_add(file_hkey);
+eina_hash_direct_add(_file_entries, fentry-hkey, fentry);
+ }
+   fentry-refcount++;
 
dentry = calloc(1, sizeof(*dentry));
if (!dentry)
  {
-free(fentry);
+if (!(--fentry-refcount))
+  eina_hash_del(_file_entries, fentry-hkey, fentry);
 return 0;
  }
 
memset(msg_open, 0, sizeof(msg_open));
 
-   fentry-file_id = ++_file_id;
-   klen = strlen(key) + 1;
-
msg_open.base.rid = _next_rid();
msg_open.base.type = CSERVE2_OPEN;
msg_open.file_id = fentry-file_id;
@@ -727,7 +762,8 @@ _image_open_server_send(Image_Entry *ie, const char *file, 
const char *key,
buf = malloc(size);
if (!buf)
  {
-free(fentry);
+if (!(--fentry-refcount))
+  eina_hash_del(_file_entries, fentry-hkey, fentry);
 free(dentry);
 return 0;
  }
@@ -741,8 +777,9 @@ _image_open_server_send(Image_Entry *ie, const char *file, 
const char *key,
  {
 ERR(Couldn't send message to server.);
 free(buf);
-free(fentry);
 free(dentry);
+if (!(--fentry-refcount))
+  eina_hash_del(_file_entries, fentry-hkey, fentry);
 return 0;
  }
 
@@ -848,7 +885,8 @@ _image_close_server_send(Image_Entry *ie)
msg.base.type = CSERVE2_CLOSE;
msg.file_id = fentry-file_id;
 
-   free(fentry);
+   if (!(--fentry-refcount))
+ eina_hash_del(_file_entries, fentry-hkey, fentry);
ie-data1 = NULL;
 
if (!_server_send(msg, sizeof(msg), NULL, NULL))

-- 




[EGIT] [core/efl] master 46/77: evas/cserve2: Fix segfault in cserve2 slave

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=94f0e1b3e1be60dc751c4f8a51191402e79cc951

commit 94f0e1b3e1be60dc751c4f8a51191402e79cc951
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Aug 27 16:03:28 2013 +0900

evas/cserve2: Fix segfault in cserve2 slave

Slaves always crash when loading SVG images.
The svg module was simply not a dynamic module.
---
 src/bin/evas/evas_cserve2_slave.c  | 2 +-
 src/bin/evas/evas_cserve2_slaves.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_slave.c 
b/src/bin/evas/evas_cserve2_slave.c
index 5f9bc32..da6099b 100644
--- a/src/bin/evas/evas_cserve2_slave.c
+++ b/src/bin/evas/evas_cserve2_slave.c
@@ -364,7 +364,7 @@ try_extension:
if (loader)
  {
 module = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_LOADER, loader);
-if (_image_file_header(fd, skey, load_opts, result, module))
+if (module  _image_file_header(fd, skey, load_opts, result, module))
   goto success;
 loader = NULL;
 module = NULL;
diff --git a/src/bin/evas/evas_cserve2_slaves.c 
b/src/bin/evas/evas_cserve2_slaves.c
index a1fc7f5..82f3e2b 100644
--- a/src/bin/evas/evas_cserve2_slaves.c
+++ b/src/bin/evas/evas_cserve2_slaves.c
@@ -128,7 +128,8 @@ _slave_proc_dead_cb(int pid, int status EINA_UNUSED)
 {
Slave_Proc *s;
 
-   INF(Child dead with pid '%d'., pid);
+   INF(Child dead with pid '%d': signal %d,
+   pid, WIFSIGNALED(status) ? WTERMSIG(status) : 0);
s = _slave_proc_find(pid);
if (!s)
  {

-- 




[EGIT] [core/efl] master 39/77: evas/cserve2: Scan glyphs and add to fash

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=ca44473f184c95b88a2dadc02e85bb0806236c05

commit ca44473f184c95b88a2dadc02e85bb0806236c05
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Aug 26 16:48:49 2013 +0900

evas/cserve2: Scan glyphs and add to fash

This will save (just) a few socket waits.
---
 src/lib/evas/cserve2/evas_cs2_client.c  | 88 +++--
 src/lib/evas/cserve2/evas_cs2_private.h |  3 +-
 2 files changed, 86 insertions(+), 5 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 0b036e0..cc5458a 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1356,9 +1356,12 @@ _glyph_map_open(Font_Entry *fe, const char *indexpath, 
const char *datapath)
return map;
 }
 
-static void
+static Eina_Bool
 _glyph_map_remap_check(Glyph_Map *map)
 {
+   Eina_Bool changed = EINA_FALSE;
+   int oldcount;
+
if (eina_file_refresh(map-mempool.f)
|| (eina_file_size_get(map-mempool.f) != (size_t) map-mempool.size))
  {
@@ -1369,7 +1372,78 @@ _glyph_map_remap_check(Glyph_Map *map)
   map-mempool.size = eina_file_size_get(map-mempool.f);
 else
   map-mempool.size = 0;
+changed = EINA_TRUE;
+ }
+
+   map-index.generation_id = _index.generation_id;
+   oldcount = map-index.count;
+   _shared_index_remap_check(map-index, sizeof(Glyph_Data));
+   changed |= (oldcount != map-index.count);
+
+   return changed;
+}
+
+static int
+_font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints)
+{
+   Eina_Bool changed = EINA_FALSE;
+   int cnt = 0;
+
+   if (!fe-map)
+ {
+const Font_Data *fd;
+const char *idxpath, *datapath;
+
+fd = _shared_font_entry_data_find(fe);
+if (!fd) return -1;
+
+idxpath = _shared_string_get(fd-glyph_index_shm);
+datapath = _shared_string_get(fd-mempool_shm);
+if (!idxpath || !datapath) return -1;
+
+fe-map =_glyph_map_open(fe, idxpath, datapath);
+changed = EINA_TRUE;
+ }
+
+   changed |= _glyph_map_remap_check(fe-map);
+   if (changed  fe-map  fe-map-index.data  fe-map-mempool.data)
+ {
+CS_Glyph_Out *gl;
+const Glyph_Data *gd;
+int k, tot = 0;
+
+DBG(Rebuilding font hash based on shared index...);
+for (k = 0; k  fe-map-index.count; k++)
+  {
+ gd = (fe-map-index.entries.gldata[k]);
+ if (!gd-id) break;
+ if (!gd-refcount) continue;
+
+ tot++;
+ gl = fash_gl_find(fe-fash[hints], gd-index);
+ if (gl  gl-base.bitmap.buffer) continue;
+
+ if (!gl) gl = calloc(1, sizeof(*gl));
+ gl-map = fe-map;
+ gl-offset = gd-offset;
+ gl-size = gd-size;
+ gl-base.bitmap.rows = gd-rows;
+ gl-base.bitmap.width = gd-width;
+ gl-base.bitmap.pitch = gd-pitch;
+ gl-base.bitmap.buffer = (unsigned char *)
+   fe-map-mempool.data + gl-offset;
+ gl-base.bitmap.num_grays = gd-num_grays;
+ gl-base.bitmap.pixel_mode = gd-pixel_mode;
+ gl-rid = 0;
+
+ eina_clist_add_head(fe-map-glyphs, gl-map_entry);
+ fash_gl_add(fe-fash[hints], gd-index, gl);
+ cnt++;
+  }
+DBG(Added %d glyphs to the font hash (out of %d scanned), cnt, tot);
  }
+
+   return cnt;
 }
 
 static void
@@ -1668,7 +1742,8 @@ evas_cserve2_font_glyph_used(Font_Entry *fe, unsigned int 
idx, Font_Hint_Flags h
 }
 
 RGBA_Font_Glyph_Out *
-evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, unsigned int idx, 
Font_Hint_Flags hints)
+evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, unsigned int idx,
+   Font_Hint_Flags hints)
 {
Fash_Glyph2 *fash;
CS_Glyph_Out *out;
@@ -1687,7 +1762,7 @@ evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, 
unsigned int idx, Font_Hint_F
if (!fash)
  {
 // this should not happen really, so let the user know he fucked up
-ERR(%s was called with a hinting value that was not requested!, 
__FUNCTION__);
+ERR(was called with a hinting value that was not requested!);
 return NULL;
  }
 
@@ -1696,9 +1771,14 @@ evas_cserve2_font_glyph_bitmap_get(Font_Entry *fe, 
unsigned int idx, Font_Hint_F
  {
 // again, if we are asking for a bitmap we were supposed to already
 // have requested the glyph, it must be there
-ERR(%s was called with a glyph index that was not requested!, 
__FUNCTION__);
+ERR(was called with a glyph index that was not requested!);
 return NULL;
  }
+
+#if USE_SHARED_INDEX
+   _font_entry_glyph_map_rebuild_check(fe, hints);
+#endif
+
if (out-rid)
  _server_dispatch_until(out-rid);
 
diff --git 

[EGIT] [core/efl] master 41/77: evas/cserve2: Rename _evas_cache_ to _evas_cache2_

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7bf4394198cb6803613200f055c09d32a7256853

commit 7bf4394198cb6803613200f055c09d32a7256853
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Aug 26 19:59:24 2013 +0900

evas/cserve2: Rename _evas_cache_ to _evas_cache2_
---
 src/lib/evas/cache2/evas_cache2.c | 134 +++---
 1 file changed, 67 insertions(+), 67 deletions(-)

diff --git a/src/lib/evas/cache2/evas_cache2.c 
b/src/lib/evas/cache2/evas_cache2.c
index 77585ab..1a033b5 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -33,23 +33,23 @@
 // Default LRU size. If 0, all scaled images will be dropped instantly.
 #define DEFAULT_CACHE_LRU_SIZE (4*1024*1024)
 
-static void _evas_cache_image_dirty_add(Image_Entry *im);
-static void _evas_cache_image_dirty_del(Image_Entry *im);
-static void _evas_cache_image_activ_add(Image_Entry *im);
-static void _evas_cache_image_activ_del(Image_Entry *im);
-static void _evas_cache_image_lru_add(Image_Entry *im);
-static void _evas_cache_image_lru_del(Image_Entry *im);
+static void _evas_cache2_image_dirty_add(Image_Entry *im);
+static void _evas_cache2_image_dirty_del(Image_Entry *im);
+static void _evas_cache2_image_activ_add(Image_Entry *im);
+static void _evas_cache2_image_activ_del(Image_Entry *im);
+static void _evas_cache2_image_lru_add(Image_Entry *im);
+static void _evas_cache2_image_lru_del(Image_Entry *im);
 static void _evas_cache2_image_entry_preload_remove(Image_Entry *ie, const 
void *target);
-// static void _evas_cache_image_lru_nodata_add(Image_Entry *im);
-// static void _evas_cache_image_lru_nodata_del(Image_Entry *im);
+// static void _evas_cache2_image_lru_nodata_add(Image_Entry *im);
+// static void _evas_cache2_image_lru_nodata_del(Image_Entry *im);
 
 static void
-_evas_cache_image_dirty_add(Image_Entry *im)
+_evas_cache2_image_dirty_add(Image_Entry *im)
 {
if (im-flags.dirty) return;
-   _evas_cache_image_activ_del(im);
-   _evas_cache_image_lru_del(im);
-   // _evas_cache_image_lru_nodata_del(im);
+   _evas_cache2_image_activ_del(im);
+   _evas_cache2_image_lru_del(im);
+   // _evas_cache2_image_lru_nodata_del(im);
im-flags.dirty = 1;
im-flags.cached = 1;
im-cache2-dirty = eina_inlist_prepend(im-cache2-dirty, 
EINA_INLIST_GET(im));
@@ -61,7 +61,7 @@ _evas_cache_image_dirty_add(Image_Entry *im)
 }
 
 static void
-_evas_cache_image_dirty_del(Image_Entry *im)
+_evas_cache2_image_dirty_del(Image_Entry *im)
 {
if (!im-flags.dirty) return;
if (!im-cache2) return;
@@ -71,12 +71,12 @@ _evas_cache_image_dirty_del(Image_Entry *im)
 }
 
 static void
-_evas_cache_image_activ_add(Image_Entry *im)
+_evas_cache2_image_activ_add(Image_Entry *im)
 {
if (im-flags.activ) return;
-   _evas_cache_image_dirty_del(im);
-   _evas_cache_image_lru_del(im);
-   // _evas_cache_image_lru_nodata_del(im);
+   _evas_cache2_image_dirty_del(im);
+   _evas_cache2_image_lru_del(im);
+   // _evas_cache2_image_lru_nodata_del(im);
if (!im-cache_key) return;
im-flags.activ = 1;
im-flags.cached = 1;
@@ -84,7 +84,7 @@ _evas_cache_image_activ_add(Image_Entry *im)
 }
 
 static void
-_evas_cache_image_activ_del(Image_Entry *im)
+_evas_cache2_image_activ_del(Image_Entry *im)
 {
if (!im-flags.activ) return;
if (!im-cache_key) return;
@@ -94,12 +94,12 @@ _evas_cache_image_activ_del(Image_Entry *im)
 }
 
 static void
-_evas_cache_image_lru_add(Image_Entry *im)
+_evas_cache2_image_lru_add(Image_Entry *im)
 {
if (im-flags.lru) return;
-   _evas_cache_image_dirty_del(im);
-   _evas_cache_image_activ_del(im);
-   // _evas_cache_image_lru_nodata_del(im); 
+   _evas_cache2_image_dirty_del(im);
+   _evas_cache2_image_activ_del(im);
+   // _evas_cache2_image_lru_nodata_del(im);
if (!im-cache_key) return;
im-flags.lru = 1;
im-flags.cached = 1;
@@ -109,7 +109,7 @@ _evas_cache_image_lru_add(Image_Entry *im)
 }
 
 static void
-_evas_cache_image_lru_del(Image_Entry *im)
+_evas_cache2_image_lru_del(Image_Entry *im)
 {
if (!im-flags.lru) return;
if (!im-cache_key) return;
@@ -122,19 +122,19 @@ _evas_cache_image_lru_del(Image_Entry *im)
 
 /*
 static void
-_evas_cache_image_lru_nodata_add(Image_Entry *im)
+_evas_cache2_image_lru_nodata_add(Image_Entry *im)
 {
if (im-flags.lru_nodata) return;
-   _evas_cache_image_dirty_del(im);
-   _evas_cache_image_activ_del(im);
-   _evas_cache_image_lru_del(im);
+   _evas_cache2_image_dirty_del(im);
+   _evas_cache2_image_activ_del(im);
+   _evas_cache2_image_lru_del(im);
im-flags.lru = 1;
im-flags.cached = 1;
im-cache2-lru_nodata = eina_inlist_prepend(im-cache2-lru_nodata, 
EINA_INLIST_GET(im));
 }
 
 static void
-_evas_cache_image_lru_nodata_del(Image_Entry *im)
+_evas_cache2_image_lru_nodata_del(Image_Entry *im)
 {
if (!im-flags.lru_nodata) return;
im-flags.lru = 0;
@@ -177,7 +177,7 @@ _timestamp_build(Image_Timestamp *tstamp, struct stat *st)
 }
 

[EGIT] [core/efl] master 60/77: evas/cserve2: Fix scaling options

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c5ecf6e5d1f0c43cce569898cb477825b3c88b58

commit c5ecf6e5d1f0c43cce569898cb477825b3c88b58
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Sep 24 18:46:17 2013 +0900

evas/cserve2: Fix scaling options

Be more careful when selecting the original image for scaling.
Most load opts must remain the same, only smooth can be toyed with.
Also, fix alpha when scaling.
---
 src/bin/evas/evas_cserve2_cache.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index d0589dd..87ea2d2 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -842,6 +842,7 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *idata, 
Image_Entry *original)
0, 0,
idata-opts.scale_load.dst_w, idata-opts.scale_load.dst_h);
 
+   idata-alpha = orig_idata-alpha;
cserve2_rgba_image_scale_do(
 src_data, orig_idata-w, orig_idata-h,
 dst_data,
@@ -2721,10 +2722,10 @@ try_again:
 goto do_scaling;
  }
 
-   if (first_attempt)
+   if (first_attempt  unscaled.scale_load.smooth)
  {
 first_attempt = EINA_FALSE;
-memset(unscaled, 0, sizeof(unscaled));
+unscaled.scale_load.smooth = 0;
 goto try_again;
  }
 

-- 




[EGIT] [core/efl] master 63/77: evas/cserve2: Fix scaling error (server side)

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=74080fba226410257084df7cde9cb02f96ed37b6

commit 74080fba226410257084df7cde9cb02f96ed37b6
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Sep 30 18:46:49 2013 +0900

evas/cserve2: Fix scaling error (server side)

This causes crashes in the client also...
---
 src/bin/evas/evas_cserve2_cache.c | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 87ea2d2..2a358f7 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -2669,7 +2669,8 @@ cserve2_cache_file_close(Client *client, unsigned int 
client_file_id)
 }
 
 static int
-_cserve2_cache_fast_scaling_check(Client *client, Image_Entry *ientry)
+_cserve2_cache_fast_scaling_check(Client *client, Image_Entry *ientry,
+  int client_file_id)
 {
Eina_Iterator *iter;
Image_Entry *i;
@@ -2694,13 +2695,13 @@ _cserve2_cache_fast_scaling_check(Client *client, 
Image_Entry *ientry)
// Copy opts w/o scaling
memset(unscaled, 0, sizeof(unscaled));
unscaled.dpi = idata-opts.dpi;
-   //unscaled.w = idata-opts.w;
-   //unscaled.h = idata-opts.h;
-   //unscaled.scale_down_by = idata-opts.scale_down_by;
-   //unscaled.region.x = idata-opts.region.x;
-   //unscaled.region.y = idata-opts.region.y;
-   //unscaled.region.w = idata-opts.region.w;
-   //unscaled.region.h = idata-opts.region.h;
+   unscaled.w = idata-opts.w;
+   unscaled.h = idata-opts.h;
+   unscaled.scale_down_by = idata-opts.scale_down_by;
+   unscaled.region.x = idata-opts.region.x;
+   unscaled.region.y = idata-opts.region.y;
+   unscaled.region.w = idata-opts.region.w;
+   unscaled.region.h = idata-opts.region.h;
unscaled.scale_load.scale_hint = 0;
unscaled.degree = idata-opts.degree;
unscaled.orientation = idata-opts.orientation;
@@ -2762,18 +2763,20 @@ try_again:
 scaled_count, ENTRYID(ientry));
 
 // FIXME: The value 4 is completely arbitrary. No benchmarks done yet.
-if (scaled_count = 4)
+if (scaled_count = 4  (unused_mem_usage  max_unused_mem_usage))
   {
  DBG(Forcing load of original image now!);
 
- orig_entry = _image_entry_new(client, 0, idata-file_id,
+ orig_entry = _image_entry_new(client, 0, client_file_id,
0, unscaled, buf, sizeof(buf));
  if (!orig_entry) return -1;
- _entry_unused_push(orig_entry);
 
  orig_data = _image_data_find(ENTRYID(orig_entry));
+ orig_data-unused = EINA_TRUE;
  fentry = _file_entry_find(orig_data-file_id);
  fentry-images = eina_list_append(fentry-images, orig_entry);
+ // TODO: Check validity of this call. Leak VS immediate delete?
+ //_entry_unused_push(orig_entry);
   }
 else
   return -1;
@@ -2885,7 +2888,7 @@ cserve2_cache_image_entry_create(Client *client, int rid,
 
if (opts  opts-scale_load.dst_w  opts-scale_load.dst_h)
  {
-if (!_cserve2_cache_fast_scaling_check(client, ientry))
+if (!_cserve2_cache_fast_scaling_check(client, ientry, client_file_id))
   return 0;
  }
 

-- 




[EGIT] [core/efl] master 76/77: evas/cserve2: Merge Glyph_Data and mempool index

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=15130078156d849f942fb00c4f37bd708bad0c7b

commit 15130078156d849f942fb00c4f37bd708bad0c7b
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Oct 11 17:18:42 2013 +0900

evas/cserve2: Merge Glyph_Data and mempool index

Glyphs were previously using 3 shared buffers, now reduce to 2:
- Memory pool (mempool) containing the glyph drawable data
- Index table (Shared_Index / array) containing only the
  indexes of the buffers in the mempool
- Glyph_Data table (array) containing the glyphs descriptors
  AS WELL as the buffer indexes.

So, we just merge the two index tables into one by using directly
objects of type Glyph_Data for the referencing of the mempool
buffers.
---
 src/bin/evas/evas_cserve2.h|   3 +-
 src/bin/evas/evas_cserve2_cache.c  | 111 +
 src/bin/evas/evas_cserve2_fonts.c  |  11 +++-
 src/bin/evas/evas_cserve2_index.c  |  26 ++--
 src/bin/evas/evas_cserve2_shm_debug.c  |   7 +--
 src/lib/evas/cserve2/evas_cs2.h|   9 ++-
 src/lib/evas/cserve2/evas_cs2_client.c |   4 +-
 7 files changed, 96 insertions(+), 75 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 219bb0d..e49bfc4 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -381,7 +381,7 @@ void *cserve2_shared_array_item_data_find(Shared_Array *sa, 
void *data,
 int cserve2_shared_array_foreach(Shared_Array *sa, Eina_Each_Cb cb, void 
*data);
 
 // Shared buffers and memory pools
-Shared_Mempool *cserve2_shared_mempool_new(int indextag, int generation_id, 
int initsize);
+Shared_Mempool *cserve2_shared_mempool_new(int indextag, int index_elemsize, 
int generation_id, int initsize);
 void cserve2_shared_mempool_del(Shared_Mempool *sm);
 int cserve2_shared_mempool_buffer_new(Shared_Mempool *sm, int size);
 int cserve2_shared_mempool_buffer_ref(Shared_Mempool *sm, int bufferid);
@@ -392,6 +392,7 @@ size_t cserve2_shared_mempool_size_get(Shared_Mempool *sm);
 const char *cserve2_shared_mempool_name_get(Shared_Mempool *sm);
 int cserve2_shared_mempool_generation_id_get(Shared_Mempool *sm);
 int cserve2_shared_mempool_generation_id_set(Shared_Mempool *sm, int 
generation_id);
+Shared_Array *cserve2_shared_mempool_index_get(Shared_Mempool *sm);
 
 // Shared strings
 const char *cserve2_shared_strings_table_name_get();
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 15ce2c3..9f92543 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -90,7 +90,6 @@ struct _Font_Entry {
Font_Source *src;
void *ft; // Font_Info
Fash_Glyph2 *glyph_entries[3]; // Fast access to the Glyph_Entry objects
-   Shared_Array *glyph_datas; // Contains the Glyph_Data objects
unsigned int nglyphs;
Eina_Bool unused : 1;
Shared_Mempool *mempool; // Contains the rendered glyphs
@@ -139,7 +138,6 @@ struct _File_Watch {
 
 static unsigned int _generation_id = 0;
 static unsigned int _entry_id = 0;
-static unsigned int _glyph_id = 0;
 static unsigned int _font_data_id = 0;
 static unsigned int _freed_file_entry_count = 0;
 static unsigned int _freed_image_entry_count = 0;
@@ -318,10 +316,12 @@ _font_data_find(unsigned int fs_id)
 }
 
 static Glyph_Data *
-_glyph_data_find(Shared_Array *sa, unsigned int glyph_id)
+_glyph_data_find(Shared_Mempool *sm, unsigned int glyph_id)
 {
Glyph_Data *gldata;
+   Shared_Array *sa;
 
+   sa = cserve2_shared_mempool_index_get(sm);
gldata = cserve2_shared_array_item_data_find(sa, glyph_id,
 _shm_object_id_cmp_cb);
if (!gldata)
@@ -1214,14 +1214,13 @@ _font_entry_key_hash(const Font_Entry *key, int 
key_length EINA_UNUSED)
 static int
 _font_entry_memory_usage_get(Font_Entry *fe)
 {
-   int size;
+   int size = sizeof(Font_Entry);
 
if (!fe) return 0;
-   if (!fe-mempool  !fe-glyph_datas)
- return 0;
+   if (!fe-mempool)
+ return size;
 
-   size = cserve2_shared_mempool_size_get(fe-mempool);
-   size += cserve2_shared_array_map_size_get(fe-glyph_datas);
+   size += cserve2_shared_mempool_size_get(fe-mempool);
size += fe-nglyphs * sizeof(Glyph_Entry);
 
return size;
@@ -1251,7 +1250,6 @@ _font_entry_free(Font_Entry *fe)
 
for (k = 0; k  3; k++)
  fash_gl_free(fe-glyph_entries[k]);
-   cserve2_shared_array_del(fe-glyph_datas);
cserve2_shared_mempool_del(fe-mempool);
cserve2_font_ft_free(fe-ft);
fe-src-refcount--;
@@ -1274,10 +1272,10 @@ _glyph_free_cb(void *data)
 
if (!gl || !gl-fe) return;
 
-   gldata = _glyph_data_find(gl-fe-glyph_datas, gl-gldata_id);
+   gldata = _glyph_data_find(gl-fe-mempool, gl-gldata_id);
if (gldata)
  {
-cserve2_shared_string_del(gldata-shm_id);
+cserve2_shared_string_del(gldata-mempool_id);
 gldata-refcount--;
  

[EGIT] [core/efl] master 77/77: Evas/cserve2: Merge branch 'devs/jpeg/cserve2'

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7338164468370056e35c206a47ca3fe1b1b61f38

commit 7338164468370056e35c206a47ca3fe1b1b61f38
Merge: 9f690ba 1513007
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Oct 28 15:50:57 2013 +0900

Evas/cserve2: Merge branch 'devs/jpeg/cserve2'

Improve stability, performance and overall support of
evas cserve2.

In particular:
- Implement shared indexes and memory pools to share cserve's
  internal state with all clients. Apps can then scan these
  indexes and avoid waiting for socket responses when loading
  resources.
- Implement crash resiliency in evas. If cserve2 crashes, apps
  can safely reconnect and continue working as if nothing
  happened.
- Implement support for the GL engine (very basic support so
  far, just works).
- Improve performance by reusing the scalecache logic.

 src/Makefile_Evas.am   |   13 +-
 src/bin/evas/evas_cserve2.h|  140 +-
 src/bin/evas/evas_cserve2_cache.c  | 2508 
 src/bin/evas/evas_cserve2_debug.c  |  185 +-
 src/bin/evas/evas_cserve2_fonts.c  |  157 +-
 src/bin/evas/evas_cserve2_index.c  | 1084 +
 src/bin/evas/evas_cserve2_main.c   |  111 +-
 src/bin/evas/evas_cserve2_main_loop_linux.c|   12 +-
 src/bin/evas/evas_cserve2_messages.c   |3 -
 src/bin/evas/evas_cserve2_requests.c   |   32 +
 src/bin/evas/evas_cserve2_scale.c  |6 +-
 src/bin/evas/evas_cserve2_shm.c|  118 +-
 src/bin/evas/evas_cserve2_shm_debug.c  |  811 +++
 src/bin/evas/evas_cserve2_slave.c  |   49 +-
 src/bin/evas/evas_cserve2_slaves.c |3 +-
 src/bin/evas/evas_cserve2_usage.c  |   85 +-
 src/lib/evas/cache2/evas_cache2.c  |  179 +-
 src/lib/evas/cache2/evas_cache2.h  |2 +
 src/lib/evas/canvas/evas_main.c|   11 +-
 src/lib/evas/canvas/evas_object_image.c|   56 +-
 src/lib/evas/canvas/evas_object_inform.c   |2 +
 src/lib/evas/canvas/evas_render.c  |2 +-
 src/lib/evas/common/evas_font_draw.c   |   53 +-
 src/lib/evas/common/evas_font_main.c   |   13 +-
 src/lib/evas/common/evas_image_load.c  |   35 +-
 src/lib/evas/common/evas_image_scalecache.c|   22 +-
 src/lib/evas/cserve2/evas_cs2.h|  158 +-
 src/lib/evas/cserve2/evas_cs2_client.c | 2054 ++--
 src/lib/evas/cserve2/evas_cs2_image_data.c |9 +
 src/lib/evas/cserve2/evas_cs2_private.h|   59 +-
 src/lib/evas/cserve2/evas_cs2_utils.c  |2 +
 src/modules/evas/engines/gl_common/evas_gl_image.c |  147 +-
 .../evas/engines/software_generic/evas_engine.c|   92 +-
 33 files changed, 6436 insertions(+), 1777 deletions(-)

-- 




[EGIT] [core/efl] master 28/77: evas/cserve2: Add proper tags to shm arrays

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4f5c48236f4152964868914ad106c1cb928bc41e

commit 4f5c48236f4152964868914ad106c1cb928bc41e
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Aug 21 13:51:15 2013 +0900

evas/cserve2: Add proper tags to shm arrays

Use tags such as INDX, FONT, IMAG, FILE.
These can help debugging and for robustness, as they will
be visible in the memory dump.

Update generation_id after repack as well
---
 src/bin/evas/evas_cserve2.h   | 11 ---
 src/bin/evas/evas_cserve2_cache.c | 59 +++--
 src/bin/evas/evas_cserve2_fonts.c |  3 +-
 src/bin/evas/evas_cserve2_index.c | 62 +--
 src/bin/evas/evas_cserve2_main.c  |  4 ++-
 src/lib/evas/cserve2/evas_cs2.h   |  9 +-
 6 files changed, 111 insertions(+), 37 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index badd33c..c0a703a 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -254,7 +254,7 @@ void cserve2_client_del(Client *client);
 void cserve2_client_deliver(Client *client);
 void cserve2_client_error_send(Client *client, unsigned int rid, int 
error_code);
 ssize_t cserve2_client_send(Client *client, const void *data, size_t size);
-void cserve2_index_list_send(const char *strings_index_path, const char 
*strings_entries_path, const char *files_index_path, const char 
*images_index_path, const char *fonts_index_path, Client *client);
+void cserve2_index_list_send(int generation_id, const char 
*strings_index_path, const char *strings_entries_path, const char 
*files_index_path, const char *images_index_path, const char *fonts_index_path, 
Client *client);
 
 Eina_Bool cserve2_fd_watch_add(int fd, Fd_Flags flags, Fd_Watch_Cb cb, const 
void *data);
 Eina_Bool cserve2_fd_watch_del(int fd);
@@ -347,7 +347,7 @@ typedef Eina_Bool (* Shared_Array_Repack_Skip_Cb) 
(Shared_Array *sa,
void *user_data);
 
 // Shared arrays (arrays of fixed size object)
-Shared_Array *cserve2_shared_array_new(int tag, int elemsize, int initcount);
+Shared_Array *cserve2_shared_array_new(int tag, int generation_id, int 
elemsize, int initcount);
 const char *cserve2_shared_array_name_get(Shared_Array *sa);
 void cserve2_shared_array_del(Shared_Array *sa);
 int cserve2_shared_array_size_get(Shared_Array *sa);
@@ -355,10 +355,11 @@ int cserve2_shared_array_count_get(Shared_Array *sa);
 int cserve2_shared_array_map_size_get(Shared_Array *sa);
 int cserve2_shared_array_item_size_get(Shared_Array *sa);
 int cserve2_shared_array_generation_id_get(Shared_Array *sa);
+int cserve2_shared_array_generation_id_set(Shared_Array *sa, int 
generation_id);
 int cserve2_shared_array_size_set(Shared_Array *sa, int newcount);
 int cserve2_shared_array_item_new(Shared_Array *sa);
 void *cserve2_shared_array_item_data_get(Shared_Array *sa, int elemid);
-Shared_Array *cserve2_shared_array_repack(Shared_Array *sa,
+Shared_Array *cserve2_shared_array_repack(Shared_Array *sa, int generation_id,
   Shared_Array_Repack_Skip_Cb skip,
   Eina_Compare_Cb cmp, void 
*user_data);
 int cserve2_shared_array_item_find(Shared_Array *sa, void *data,
@@ -368,7 +369,7 @@ void *cserve2_shared_array_item_data_find(Shared_Array *sa, 
void *data,
 int cserve2_shared_array_foreach(Shared_Array *sa, Eina_Each_Cb cb, void 
*data);
 
 // Shared buffers and memory pools
-Shared_Mempool *cserve2_shared_mempool_new(int initsize);
+Shared_Mempool *cserve2_shared_mempool_new(int indextag, int generation_id, 
int initsize);
 void cserve2_shared_mempool_del(Shared_Mempool *sm);
 int cserve2_shared_mempool_buffer_new(Shared_Mempool *sm, int size);
 int cserve2_shared_mempool_buffer_ref(Shared_Mempool *sm, int bufferid);
@@ -377,6 +378,8 @@ void *cserve2_shared_mempool_buffer_get(Shared_Mempool *sm, 
int bufferid);
 int cserve2_shared_mempool_buffer_offset_get(Shared_Mempool *sm, int bufferid);
 size_t cserve2_shared_mempool_size_get(Shared_Mempool *sm);
 const char *cserve2_shared_mempool_name_get(Shared_Mempool *sm);
+int cserve2_shared_mempool_generation_id_get(Shared_Mempool *sm);
+int cserve2_shared_mempool_generation_id_set(Shared_Mempool *sm, int 
generation_id);
 
 // Shared strings
 const char *cserve2_shared_strings_table_name_get();
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 86fb804..9a9b82e 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -121,6 +121,7 @@ struct _File_Watch {
Eina_List *entries;
 };
 
+static unsigned int _generation_id = 0;
 static unsigned int _entry_id = 0;
 static unsigned int _glyph_id = 0;
 static unsigned int _font_data_id = 0;
@@ -341,7 +342,9 @@ _repack()
 DBG(Repacking file data array: %s,
 

[EGIT] [core/efl] master 19/77: evas/cserve2: Fix race condition on font load / socket fail

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=f5fee255de5a2e9f33c2d2f5b87b9ba02fd65922

commit f5fee255de5a2e9f33c2d2f5b87b9ba02fd65922
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Aug 2 15:16:24 2013 +0900

evas/cserve2: Fix race condition on font load / socket fail

If the client exits while the server is loading fonts,
the font entry objects are accessed after being freed.

Note: This is not a proper fix. The race condition should still
be fixed, but delaying client deletion a bit might help for a while...
---
 src/bin/evas/evas_cserve2_messages.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_messages.c 
b/src/bin/evas/evas_cserve2_messages.c
index e5cb1b7..168bd72 100644
--- a/src/bin/evas/evas_cserve2_messages.c
+++ b/src/bin/evas/evas_cserve2_messages.c
@@ -172,9 +172,6 @@ cserve2_client_send(Client *client, const void *data, 
size_t size)
 // so we must close the connection to the client and remove
 // its references inside our cache.
 WRN(Error on socket with client %d: %s, client-id, strerror(errno));
-if (client-msg.reading)
-  _client_msg_free(client);
-cserve2_client_del(client);
 return sent;
  }
if (sent  0)

-- 




[EGIT] [core/efl] master 21/77: evas/cserve2: Optimize cserve2_shared_string_del()

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9d731364c1268fd824d4dc697a21fe6357908c37

commit 9d731364c1268fd824d4dc697a21fe6357908c37
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Aug 6 14:52:12 2013 +0900

evas/cserve2: Optimize cserve2_shared_string_del()

eina_hash_del_by_data is very expensive, so let's delete by key
since we can get the original data.
---
 src/bin/evas/evas_cserve2_cache.c |  1 -
 src/bin/evas/evas_cserve2_index.c | 27 +--
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 5bbe014..1a025a8 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -1588,7 +1588,6 @@ _font_load_request_response(Font_Entry *fe, 
Slave_Msg_Font_Loaded *msg, int *siz
 
if (fe-base.request) fe-base.request = NULL;
 
-   /* could be a function, but it's too basic and only used here */
resp = calloc(1, sizeof(*resp));
resp-base.type = CSERVE2_FONT_LOADED;
*size = sizeof(*resp);
diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
index 66b50a4..ecafa31 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -765,18 +765,19 @@ cserve2_shared_mempool_buffer_ref(Shared_Mempool *sm, int 
bufferid)
return ie-id;
 }
 
-static Eina_Bool
+static const void *
 _shared_mempool_buffer_del(Shared_Mempool *sm, int bufferid)
 {
Index_Entry *ie;
+   const char *data;
 
-   if (!sm || !bufferid) return EINA_FALSE;
+   if (!sm || !bufferid) return NULL;
 
ie = _shared_index_entry_get_by_id(sm-index, bufferid);
if (!ie || ie-refcount = 0)
  {
 CRIT(Tried to delete invalid buffer or with refcount 0);
-return EINA_FALSE;
+return NULL;
  }
 
ie-refcount--;
@@ -789,10 +790,11 @@ _shared_mempool_buffer_del(Shared_Mempool *sm, int 
bufferid)
 sm-empty_blocks = (Block *) eina_rbtree_inline_insert(
  EINA_RBTREE_GET(sm-empty_blocks), EINA_RBTREE_GET(newblk),
  EINA_RBTREE_CMP_NODE_CB(_block_rbtree_cmp), NULL);
-return EINA_TRUE;
+data = sm-ds-data + ie-offset;
+return data;
  }
 
-   return EINA_FALSE;
+   return NULL;
 }
 
 void
@@ -856,7 +858,7 @@ cserve2_shared_string_add(const char *str)
 ie = _shared_index_entry_get_by_id(_string_mempool-index, id);
 if (!ie || ie-refcount = 0)
   {
- CRIT(String found in hash but not in mempool!);
+ ERR(String found in hash but not in mempool!);
  eina_hash_del(_string_entries, str, (void *) (intptr_t) id);
  goto new_entry;
   }
@@ -874,9 +876,9 @@ new_entry:
 return -1;
  }
 
-   eina_hash_add(_string_entries, str, (void *) (intptr_t) ie-id);
data = _string_mempool-ds-data + ie-offset;
memcpy(data, str, len);
+   eina_hash_add(_string_entries, data, (void *) (intptr_t) ie-id);
return ie-id;
 }
 
@@ -890,11 +892,16 @@ cserve2_shared_string_ref(int id)
 void
 cserve2_shared_string_del(int id)
 {
+   const char *data;
+
if (!id) return;
-   if (_shared_mempool_buffer_del(_string_mempool, id))
+   if ((data = _shared_mempool_buffer_del(_string_mempool, id)) != NULL)
  {
-if (!eina_hash_del_by_data(_string_entries, (void *) (intptr_t) id))
-  CRIT(Invalid free);
+if (!eina_hash_del_by_key(_string_entries, data))
+  {
+ if (!eina_hash_del_by_data(_string_entries, (void *) (intptr_t) 
id))
+   CRIT(Invalid free);
+  }
  }
 }
 

-- 




[EGIT] [core/efl] master 56/77: evas/cserve2: Fix images indexing (File_Entry stuff)

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0d506a7b7369aad8376336497e755092cbe8cb40

commit 0d506a7b7369aad8376336497e755092cbe8cb40
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Sep 6 11:53:28 2013 +0900

evas/cserve2: Fix images indexing (File_Entry stuff)

High-level problem:
cserve2 does not support load_opts properly when opening an image.
As a result, when (pre)loading a JPEG file with specific load
options (eg. w, h, region and orientation), the image buffer might
have the wrong dimensions.

So, we need to use load_opts when computing file hash key.
And, pass these load options to the loader slave,
and use them while OPENING the image. This will set
properly the geometry.

Fixes test Preload and Prescale in elementary_test.
---
 src/bin/evas/evas_cserve2.h|  17 +++-
 src/bin/evas/evas_cserve2_cache.c  | 146 +
 src/bin/evas/evas_cserve2_main.c   |  12 ++-
 src/bin/evas/evas_cserve2_shm_debug.c  |  52 +++-
 src/bin/evas/evas_cserve2_slave.c  |  34 +---
 src/lib/evas/cserve2/evas_cs2.h|  13 ++-
 src/lib/evas/cserve2/evas_cs2_client.c |  80 ++
 7 files changed, 282 insertions(+), 72 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 3b0ec15..b1b6d68 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -5,7 +5,7 @@
 #include evas_cs2.h
 
 #ifndef CSERVE2_LOG_LEVEL
-#define CSERVE2_LOG_LEVEL 2
+#define CSERVE2_LOG_LEVEL 4
 #endif
 
 #ifdef CRIT
@@ -103,8 +103,17 @@ typedef enum {
 } Slave_Command;
 
 struct _Slave_Msg_Image_Open {
-   Eina_Bool has_loader_data : 1;
-   // Optionally followed by:
+   struct {
+  struct {
+ unsigned int x, y, w, h;
+  } region;
+  double   dpi;
+  unsigned int w, h;
+  int  scale_down_by;
+  Eina_Boolorientation;
+   } lo;
+   // const char path[];
+   // const char key[];
// const char loader[];
 };
 
@@ -308,7 +317,7 @@ void cserve2_cache_init(void);
 void cserve2_cache_shutdown(void);
 void cserve2_cache_client_new(Client *client);
 void cserve2_cache_client_del(Client *client);
-int cserve2_cache_file_open(Client *client, unsigned int client_file_id, const 
char *path, const char *key, unsigned int rid);
+int cserve2_cache_file_open(Client *client, unsigned int client_file_id, const 
char *path, const char *key, unsigned int rid, Evas_Image_Load_Opts *lo);
 void cserve2_cache_file_close(Client *client, unsigned int client_file_id);
 int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int 
client_file_id, unsigned int image_id, Evas_Image_Load_Opts *opts);
 void cserve2_rgba_image_scale_do(void *src_data, void *dst_data, int src_x, 
int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, 
int alpha, int smooth);
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 30f4cf5..5361c13 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -27,6 +27,22 @@ typedef struct _File_Watch File_Watch;
 typedef struct _Font_Source Font_Source;
 typedef struct _Font_Entry Font_Entry;
 
+static const Evas_Image_Load_Opts empty_lo = {
+  { 0, 0, 0, 0 },
+  {
+0, 0, 0, 0,
+0, 0,
+0,
+0
+  },
+  0.0,
+  0, 0,
+  0,
+  0,
+
+  EINA_FALSE
+};
+
 typedef enum {
CSERVE2_IMAGE_FILE,
CSERVE2_IMAGE_DATA,
@@ -550,11 +566,12 @@ _font_loaded_send(Client *client, unsigned int rid)
 static void *
 _open_request_build(Entry *entry, int *bufsize)
 {
+   Slave_Msg_Image_Open msg = { { { 0,0,0,0}, 0,0,0,0,0, } };
const char *loader_data, *key, *path;
-   char *buf;
-   int size, pathlen, keylen, loaderlen;
-   Slave_Msg_Image_Open msg;
+   void *buf;
+   size_t pathlen, keylen, loaderlen;
File_Data *fd;
+   Eina_Binbuf *bb;
 
if (!entry || entry-type != CSERVE2_IMAGE_FILE)
  return NULL;
@@ -568,30 +585,33 @@ _open_request_build(Entry *entry, int *bufsize)
 
path = cserve2_shared_string_get(fd-path);
key = cserve2_shared_string_get(fd-key);
+   loader_data = cserve2_shared_string_get(fd-loader_data);
if (!path) path = ;
if (!key) key = ;
+   if (!loader_data) loader_data = ;
pathlen = strlen(path) + 1;
keylen = strlen(key) + 1;
-
-   memset(msg, 0, sizeof(msg));
-   loader_data = cserve2_shared_string_get(fd-loader_data);
-   msg.has_loader_data = !!loader_data;
-   loaderlen = msg.has_loader_data ? (strlen(loader_data) + 1) : 0;
-
-   size = sizeof(msg) + pathlen + keylen + loaderlen;
-   buf = malloc(size);
-   if (!buf) return NULL;
-
-   memcpy(buf, msg, sizeof(msg));
-   memcpy(buf + sizeof(msg), path, pathlen);
-   memcpy(buf + sizeof(msg) + pathlen, key, keylen);
-   if (msg.has_loader_data)
- memcpy(buf + sizeof(msg) + pathlen + keylen, loader_data, loaderlen);
-
-   *bufsize = size;
-
-   

Re: [E-devel] Evas cserve2

2013-10-28 Thread Jean-Philippe André
Hello there!

The commit is there:
https://git.enlightenment.org/core/efl.git/commit/?id=7338164468370056e35c206a47ca3fe1b1b61f38

It's a merge of 77 commits from my public branch, rebased (fast-forward)
onto master.
Sorry about the [EGIT] mail flood, I thought --no-ff would prevent that
from happening...

Should any breakage happen (build, runtime, anything), please let me know
soon :)

If the build is broken for you and you are in a hurry, please use git
revert 1 
7338164https://git.enlightenment.org/core/efl.git/commit/?id=7338164468370056e35c206a47ca3fe1b1b61f38
to revert this merge on your local branch.

Have a great day,

JP


2013/10/28 ChunEon Park her...@naver.com

 Also it will be useful when you post it to the phabricator article.
 https://phab.enlightenment.org/phame/post/all/

 
 -Regards, Hermet-

 -Original Message-
 From: Jean-Philippe Andréj...@videolan.org
 To: Enlightenment developer list
 enlightenment-devel@lists.sourceforge.net;
 Cc:
 Sent: 2013-10-24 (목) 10:45:31
 Subject: [E-devel] Evas cserve2

 Dear EFL developers,


 TL;DR I'd like to merge my work on cserve2 into EFL master soon. This is a
 commit-flood warning mail.


 I hope the lucky of you folks who attended EFL dev day 2013 had fun there.
 Also I hope this was a productive event and you got the opportunity to
 discuss various EFL-related topics.

 Amongst those, I trust Cedric made an awesome presentation about cserve2,
 and introduced the work I've put on top of what had already been done :-)

 Now is about time to merge this work into the master branch, as it's
 reached a state where it is (almost?) fast  stable enough to be used to
 run E18.

 For those who forgot or could not attend, let me summarize what this is all
 about:

 Evas cserve2 is a caching mechanism for Evas images and font (glyphs) that
 is based on a client-server model. A program, evas_cserve2, runs as a
 server on the system, waits for commands on a UNIX socket, and loads image
 files, image data and font data in memory. The memory is then shared and
 exposed in virtual files in /dev/shm and all applications can access it.
 This means multiple apps will reuse the exact same resources in memory, and
 won't need to duplicate common elements such as font glyphs and theme image
 data.

 When I first started working on cserve2, it was in an experimentally
 working state. That is, it worked pretty well in some situations, but there
 were huge performance bottlenecks, that made it impractical to use in
 production.

 One of the main bottlenecks was the massive amount of IPC involved in just
 opening  loading an image. (Example: client A sends a message to cserve2
 to OPEN an image, then waits for cserve2 to answer. cserve2 sends a message
 to its slave to OPEN that image, receives a message from the slave when
 it's done, sends a message back to the client A, ... So far the data itself
 is still not even loaded, and client A will have to request the data in a
 second message to cserve2...) In particular, most scaling was done on the
 server and not on the client side, which means that lots of scaled images
 could be cached even when used only once.

 So, I worked on reducing unnecessary IPC and optimizing data loading, in
 two ways:
 - Reuse the scalecache logic for scaled images (cache only images that
 would otherwise hit the scalecache, scale on the fly all the rest)
 - Implement a shared indexing system, where cserve2 exposes its internal
 cache structure to all the clients. The clients can then scan the indexes
 (also stored in /dev/shm), bypass part of the heavy IPC and directly open
 the data. This works very well for images as they will not change at all
 after being fully loaded.

 In terms of stability, I've also improved the following:
 - Support the GL engine (very basic support right now)
 - Support some exotic stuff (eg. animated Gif)
 - Allow cserve2 to crash without affecting clients (as long as the system
 restarts the server)


 The overall objective of cserve2 is to reduce memory usage at the system
 level, as applications will share more resources. Also, we can integrate in
 the future with E, so that the required resources are loaded ASAP when an
 app starts (predict what an app needs before even it has requested them).
 So there is a potential performance increase as well, on slower devices at
 least.

 I've been actually using it for a couple days and it's surprisingly quite
 stable ^^.
 I will fix bugs as they come [1].


 The source code is available in my dev branch (rebased on top of master):
 https://git.enlightenment.org/core/efl.git/log/?h=devs/jpeg/cserve2

 It's a LOT of commits, so out of question that I push them without previous
 notice  discussion :-)
 As usual, if there's any bug left, blame Cedric.


 Best regards,


 [1] I know (only) one bug right now, but sh, don't tell...

 --
 Jean-Philippe André
 (jpeg)

 

[EGIT] [core/efl] master 31/77: evas/cserve2: Add SHM debug tool (CLI)

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=71fdd0d3426868dff7f8a9df785f5ef1a20a4c87

commit 71fdd0d3426868dff7f8a9df785f5ef1a20a4c87
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Aug 22 10:43:53 2013 +0900

evas/cserve2: Add SHM debug tool (CLI)

Prints out the content or the shared index.
Does not need any socket connection to the server, read-only.
---
 src/Makefile_Evas.am  |  12 +-
 src/bin/evas/evas_cserve2_shm_debug.c | 759 ++
 2 files changed, 770 insertions(+), 1 deletion(-)

diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index de3636b..7a52016 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -999,7 +999,8 @@ bin/evas/dummy_slave
 bin_PROGRAMS += \
 bin/evas/evas_cserve2_client \
 bin/evas/evas_cserve2_usage \
-bin/evas/evas_cserve2_debug
+bin/evas/evas_cserve2_debug \
+bin/evas/evas_cserve2_shm_debug
 
 bin_evas_evas_cserve2_SOURCES = \
 bin/evas/evas_cserve2.h \
@@ -1056,6 +1057,15 @@ bin_evas_evas_cserve2_debug_CPPFLAGS = 
-I$(top_builddir)/src/lib/efl \
 bin_evas_evas_cserve2_debug_LDADD = @USE_EINA_LIBS@
 bin_evas_evas_cserve2_debug_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
 
+bin_evas_evas_cserve2_shm_debug_SOURCES = \
+bin/evas/evas_cserve2_shm_debug.c
+bin_evas_evas_cserve2_shm_debug_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
+-I$(top_srcdir)/src/lib/evas \
+-I$(top_srcdir)/src/lib/evas/cserve2 \
+@EINA_CFLAGS@
+bin_evas_evas_cserve2_shm_debug_LDADD = @USE_EINA_LIBS@
+bin_evas_evas_cserve2_shm_debug_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
+
 bin_evas_evas_cserve2_slave_SOURCES = \
 bin/evas/evas_cserve2_slave.c \
 bin/evas/evas_cserve2_utils.c \
diff --git a/src/bin/evas/evas_cserve2_shm_debug.c 
b/src/bin/evas/evas_cserve2_shm_debug.c
new file mode 100644
index 000..e17e5d2
--- /dev/null
+++ b/src/bin/evas/evas_cserve2_shm_debug.c
@@ -0,0 +1,759 @@
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include unistd.h
+#include sys/ioctl.h
+
+#include Eina.h
+#include evas_cs2.h
+
+#define SHM_FOLDER /dev/shm
+static int _evas_cserve2_shm_debug_log_dom = -1;
+
+#define ERR(...) EINA_LOG_DOM_ERR(_evas_cserve2_shm_debug_log_dom, __VA_ARGS__)
+#define DBG(...) EINA_LOG_DOM_DBG(_evas_cserve2_shm_debug_log_dom, __VA_ARGS__)
+#define WRN(...) EINA_LOG_DOM_WARN(_evas_cserve2_shm_debug_log_dom, 
__VA_ARGS__)
+#define INF(...) EINA_LOG_DOM_INFO(_evas_cserve2_shm_debug_log_dom, 
__VA_ARGS__)
+
+typedef struct _Shm_File Shm_File;
+struct _Shm_File
+{
+   Eina_File *f;
+   char *data;
+   size_t size;
+   int tag;
+
+   Eina_Bool strings;
+   Shared_Array_Header *header;
+};
+
+Shm_File *sf_strindex = NULL;
+Shm_File *sf_strpool = NULL;
+Shm_File *sf_fonts = NULL;
+Shm_File *sf_files = NULL;
+Shm_File *sf_images = NULL;
+
+static int _termsize = 0;
+
+static void
+nprintf(int n, const char *fmt, ...)
+{
+   char buf[n+1];
+   va_list arg;
+   int len;
+
+   va_start(arg, fmt);
+   if (!n)
+ vprintf(fmt, arg);
+   else
+ {
+len = vsnprintf(buf, n+1, fmt, arg);
+buf[n] = 0;
+fputs(buf, stdout);
+if ((len  0)  (buf[len-1] != '\n'))
+  fputc('\n', stdout);
+ }
+   va_end(arg);
+}
+
+#define printf(...) nprintf(_termsize, __VA_ARGS__)
+
+static Shm_File *
+_shm_file_open(const char *path)
+{
+   Shm_File *sf;
+   Eina_File *f;
+   char *data;
+
+   f = eina_file_open(path, EINA_TRUE);
+   if (!f)
+ {
+ERR(Could not open file %s: [%d] %m, path, errno);
+return NULL;
+ }
+
+   data = eina_file_map_all(f, EINA_FILE_RANDOM);
+   if (!data)
+ {
+ERR(Could not map the file %s, path);
+eina_file_close(f);
+return NULL;
+ }
+
+   sf = calloc(1, sizeof(*sf));
+   sf-data = data;
+   sf-f = f;
+   sf-size = eina_file_size_get(f);
+
+   DBG(Successfully opened %s, path);
+   return sf;
+}
+
+static void
+_shm_file_close(Shm_File *sf)
+{
+   if (!sf) return;
+   eina_file_map_free(sf-f, sf-data);
+   eina_file_close(sf-f);
+   free(sf);
+}
+
+static Eina_Bool
+_shm_file_probe(Shm_File *sf)
+{
+   if (!sf || !sf-data)
+ return EINA_FALSE;
+
+   if (sf-size  sizeof(Shared_Array_Header))
+ {
+sf-header = NULL;
+return EINA_TRUE;
+ }
+
+   sf-header = (Shared_Array_Header *) sf-data;
+   switch (sf-header-tag)
+ {
+  case STRING_INDEX_ARRAY_TAG:
+DBG(Found string index: %s, eina_file_filename_get(sf-f));
+if (sf-header-elemsize != sizeof(Index_Entry))
+  {
+ ERR(String index looks invalid: elemsize %d,
+ sf-header-elemsize);
+ return EINA_FALSE;
+  }
+sf-tag = STRING_INDEX_ARRAY_TAG;
+sf_strindex = sf;
+break;
+
+  case STRING_MEMPOOL_FAKETAG:
+DBG(Found string mempool: %s, eina_file_filename_get(sf-f));
+sf-strings = EINA_TRUE;
+sf-tag = STRING_MEMPOOL_FAKETAG;
+sf-header = NULL;
+

[EGIT] [core/efl] master 20/77: evas/cserve2: Add binary search in server side

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e95bd7755eada7a123cd3e8c560dbe72a297c837

commit e95bd7755eada7a123cd3e8c560dbe72a297c837
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Aug 2 15:27:20 2013 +0900

evas/cserve2: Add binary search in server side
---
 src/bin/evas/evas_cserve2_index.c | 60 +--
 1 file changed, 45 insertions(+), 15 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
index 6563872..66b50a4 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -509,21 +509,51 @@ _shared_index_entry_new(Shared_Index *si)
 }
 
 static Index_Entry *
-_shared_index_entry_find(Shared_Index *si, int id)
+_shared_index_entry_get_by_id(Shared_Index *si, unsigned int id)
 {
-   int k, count;
+   Index_Entry *obj;
+   const char *base;
+   int low = 0, high, start_high, elemsize;
+   int cur;
 
-   if (!si) return NULL;
-   count = cserve2_shared_array_count_get(si-sa);
+   if (!si || !si-sa || !id)
+ return NULL;
+
+   // FIXME: HACK (consider all arrays always sorted by id)
+   high = si-sa-header-emptyidx; // Should be si-sa-header-sortedidx
+
+   if (high  si-sa-header-count)
+ high = si-sa-header-count;
+
+   base = si-sa-ds-data + sizeof(Shared_Array_Header);
+   elemsize = si-sa-header-elemsize;
+
+   // Binary search
+   start_high = high;
+   while(high != low)
+ {
+cur = low + ((high - low) / 2);
+obj = (Index_Entry *) (base + (elemsize * cur));
+if (!obj)
+  return NULL;
+if (obj-id == id)
+  return obj;
+if (obj-id  id)
+  low = cur + 1;
+else
+  high = cur;
+ }
 
-   // FIXME: Linear search O(n)
-   for (k = 0; k  count; k++)
+   // Linear search
+   for (cur = start_high; cur  si-sa-header-count; cur++)
  {
-Index_Entry *ie;
-ie = cserve2_shared_array_item_data_get(si-sa, k);
-if (!ie) break;
-if (ie-id == id)
-  return ie;
+obj = (Index_Entry *) (base + (elemsize * cur));
+if (!obj)
+  return NULL;
+if (!obj-id)
+  return NULL;
+if (obj-id == id)
+  return obj;
  }
 
return NULL;
@@ -709,7 +739,7 @@ cserve2_shared_mempool_buffer_ref(Shared_Mempool *sm, int 
bufferid)
Index_Entry *ie;
 
if (!sm) return -1;
-   ie = _shared_index_entry_find(sm-index, bufferid);
+   ie = _shared_index_entry_get_by_id(sm-index, bufferid);
if (!ie) return -1;
 
if (!ie-refcount)
@@ -742,7 +772,7 @@ _shared_mempool_buffer_del(Shared_Mempool *sm, int bufferid)
 
if (!sm || !bufferid) return EINA_FALSE;
 
-   ie = _shared_index_entry_find(sm-index, bufferid);
+   ie = _shared_index_entry_get_by_id(sm-index, bufferid);
if (!ie || ie-refcount = 0)
  {
 CRIT(Tried to delete invalid buffer or with refcount 0);
@@ -778,7 +808,7 @@ cserve2_shared_mempool_buffer_get(Shared_Mempool *sm, int 
bufferid)
char *data;
 
if (!sm) return NULL;
-   ie = _shared_index_entry_find(sm-index, bufferid);
+   ie = _shared_index_entry_get_by_id(sm-index, bufferid);
if (!ie || ie-refcount = 0)
  {
 CRIT(Tried to access invalid buffer or with refcount 0);
@@ -823,7 +853,7 @@ cserve2_shared_string_add(const char *str)
id = (int) (intptr_t) eina_hash_find(_string_entries, str);
if (id  0)
  {
-ie = _shared_index_entry_find(_string_mempool-index, id);
+ie = _shared_index_entry_get_by_id(_string_mempool-index, id);
 if (!ie || ie-refcount = 0)
   {
  CRIT(String found in hash but not in mempool!);

-- 




[EGIT] [core/efl] master 44/77: evas/cserve2: Modify usage of EVAS_CSERVE2 env

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=1a324754fd886cbb03c09e7cba81d5ad36938143

commit 1a324754fd886cbb03c09e7cba81d5ad36938143
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Aug 27 12:47:51 2013 +0900

evas/cserve2: Modify usage of EVAS_CSERVE2 env

Check the value of EVAS_CSERVE2 instead of just checking
if it is defined in the environment. So we can set to 0
to disable.
---
 src/lib/evas/canvas/evas_main.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index bf23273..101b82f 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -55,7 +55,11 @@ evas_init(void)
if (!evas_async_events_init())
  goto shutdown_module;
 #ifdef EVAS_CSERVE2
-   if (getenv(EVAS_CSERVE2)) evas_cserve2_init();
+   {
+  const char *env;
+  env = getenv(EVAS_CSERVE2);
+  if (env  atoi(env)) evas_cserve2_init();
+   }
 #endif
_evas_preload_thread_init();
 
@@ -96,7 +100,7 @@ evas_shutdown(void)
   EINA_LOG_STATE_SHUTDOWN);
 
 #ifdef EVAS_CSERVE2
-   if (getenv(EVAS_CSERVE2))
+   if (evas_cserve2_use_get())
  evas_cserve2_shutdown();
 #endif
 

-- 




[EGIT] [core/efl] master 57/77: evas/cserve2: Add cache hit count on image data

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=fc73405c40653a5fc0166690e3657ffd87069efc

commit fc73405c40653a5fc0166690e3657ffd87069efc
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Sep 9 13:57:45 2013 +0900

evas/cserve2: Add cache hit count on image data
---
 src/lib/evas/cache2/evas_cache2.c  | 5 -
 src/lib/evas/cserve2/evas_cs2_image_data.c | 9 +
 src/lib/evas/cserve2/evas_cs2_private.h| 2 ++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/lib/evas/cache2/evas_cache2.c 
b/src/lib/evas/cache2/evas_cache2.c
index 0444741..fc7982d 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -982,7 +982,10 @@ evas_cache2_image_load_data(Image_Entry *ie)
int error = EVAS_LOAD_ERROR_NONE;
 
if ((ie-flags.loaded)  (!ie-animated.animated))
- return error;
+ {
+evas_cserve2_image_hit(ie);
+return EVAS_LOAD_ERROR_NONE;
+ }
 
ie-flags.in_progress = EINA_TRUE;
 
diff --git a/src/lib/evas/cserve2/evas_cs2_image_data.c 
b/src/lib/evas/cserve2/evas_cs2_image_data.c
index a5e49da..845107e 100644
--- a/src/lib/evas/cserve2/evas_cs2_image_data.c
+++ b/src/lib/evas/cserve2/evas_cs2_image_data.c
@@ -20,4 +20,13 @@ evas_cserve2_image_data_get(Image_Entry *ie)
return dentry-shm.data;
 }
 
+unsigned int
+evas_cserve2_image_hit(Image_Entry *ie)
+{
+   Data_Entry *dentry = ie-data2;
+
+   if (!dentry) return 0;
+   return ++dentry-hit_count;
+}
+
 #endif
diff --git a/src/lib/evas/cserve2/evas_cs2_private.h 
b/src/lib/evas/cserve2/evas_cs2_private.h
index 8d12e69..c0ed575 100644
--- a/src/lib/evas/cserve2/evas_cs2_private.h
+++ b/src/lib/evas/cserve2/evas_cs2_private.h
@@ -14,6 +14,7 @@ typedef struct _Shared_Buffer Shared_Buffer;
 struct _Data_Entry
 {
unsigned int image_id;
+   unsigned int hit_count;
void (*preloaded_cb)(void *, Eina_Bool);
struct {
   const char *path;
@@ -81,6 +82,7 @@ Eina_Bool evas_cserve2_image_preload(Image_Entry *ie, void 
(*preloaded_cb)(void
 void evas_cserve2_dispatch(void);
 
 void *evas_cserve2_image_data_get(Image_Entry *ie);
+unsigned int evas_cserve2_image_hit(Image_Entry *ie);
 
 Font_Entry *evas_cserve2_font_load(const char *source, const char *name, int 
size, int dpi, Font_Rend_Flags wanted_rend);
 EAPI int evas_cserve2_font_load_wait(Font_Entry *fe);

-- 




[EGIT] [core/efl] master 75/77: evas/cserve2: Add debug and reduce number of GLYPHS_USED messages

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7b62d77cf5441b89c17ff082204a6908259bd4c3

commit 7b62d77cf5441b89c17ff082204a6908259bd4c3
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Oct 11 15:36:11 2013 +0900

evas/cserve2: Add debug and reduce number of GLYPHS_USED messages

One socket message was sent per each glyph used ... which means
a LOT of messages when text is being redrawn.

Reduce this flow of messages by triggering send() only when
50+ items are being used.
Btw, USED is a bit useless as there is no UNUSED equivalent.

Also, slightly improve debug logs.
---
 src/bin/evas/evas_cserve2_main.c   |  8 ++--
 src/lib/evas/cserve2/evas_cs2_client.c | 74 +-
 2 files changed, 50 insertions(+), 32 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_main.c b/src/bin/evas/evas_cserve2_main.c
index bd54cbf..1e8fd18 100644
--- a/src/bin/evas/evas_cserve2_main.c
+++ b/src/bin/evas/evas_cserve2_main.c
@@ -234,8 +234,8 @@ _cserve2_client_font_glyphs_request(Client *client)
 
if (msg-base.type == CSERVE2_FONT_GLYPHS_LOAD)
  {
-INF(Received CSERVE2_FONT_GLYPHS_LOAD command: RID=%d,
-msg-base.rid);
+INF(Received CSERVE2_FONT_GLYPHS_LOAD command: RID=%d (%d glyphs),
+msg-base.rid, msg-nglyphs);
 cserve2_cache_font_glyphs_load(client, source, fontpath,
msg-hint, msg-rend_flags, msg-size,
msg-dpi, glyphs, msg-nglyphs,
@@ -243,8 +243,8 @@ _cserve2_client_font_glyphs_request(Client *client)
  }
else
  {
-INF(Received CSERVE2_FONT_GLYPHS_USED command: RID=%d,
-msg-base.rid);
+INF(Received CSERVE2_FONT_GLYPHS_USED command: RID=%d (%d glyphs),
+msg-base.rid, msg-nglyphs);
 cserve2_cache_font_glyphs_used(client, source, fontpath,
msg-hint, msg-rend_flags, msg-size,
msg-dpi, glyphs, msg-nglyphs,
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 520c400..c052c27 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -364,45 +364,58 @@ on_error:
 }
 
 static Eina_Bool
-_server_send(void *buf, int size, Op_Callback cb, void *data)
+_request_answer_required(int type, Eina_Bool *valid)
 {
-   Msg_Base *msg;
-   if (!_server_safe_send(socketfd, size, sizeof(size)))
- {
-ERR(Couldn't send message size to server.);
-goto on_error;
- }
-   if (!_server_safe_send(socketfd, buf, size))
- {
-ERR(Couldn't send message body to server.);
-goto on_error;
- }
-
-   msg = buf;
-   switch (msg-type)
+   switch (type)
  {
   case CSERVE2_OPEN:
   case CSERVE2_LOAD:
   case CSERVE2_PRELOAD:
   case CSERVE2_FONT_LOAD:
   case CSERVE2_FONT_GLYPHS_LOAD:
-_request_answer_add(msg, size, cb, data);
-break;
+if (valid) *valid = EINA_TRUE;
+return EINA_TRUE;
   case CSERVE2_CLOSE:
   case CSERVE2_UNLOAD:
   case CSERVE2_FONT_UNLOAD:
   case CSERVE2_FONT_GLYPHS_USED:
-free(msg);
-break;
+if (valid) *valid = EINA_TRUE;
+return EINA_FALSE;
   default:
-ERR(Invalid message type %d, msg-type);
-free(msg);
+ERR(Invalid message type %d, type);
+if (valid) *valid = EINA_FALSE;
 return EINA_FALSE;
  }
+}
 
-   return EINA_TRUE;
+static Eina_Bool
+_server_send(void *buf, int size, Op_Callback cb, void *data)
+{
+   Msg_Base *msg = buf;
+   int type = msg-type;
+   Eina_Bool valid = EINA_TRUE;
+
+   if (!_server_safe_send(socketfd, size, sizeof(size)))
+ {
+ERR(Couldn't send message size to server.);
+goto on_error;
+ }
+   if (!_server_safe_send(socketfd, buf, size))
+ {
+ERR(Couldn't send message body to server.);
+goto on_error;
+ }
+
+   if (_request_answer_required(type, valid))
+ _request_answer_add(msg, size, cb, data);
+   else
+ free(msg);
+
+   return valid;
 
 on_error:
+   if (!_request_answer_required(type, NULL))
+ return EINA_FALSE;
ERR(Socket error: %d %m, errno);
switch (errno)
  {
@@ -532,6 +545,7 @@ _server_dispatch(Eina_Bool *failed)
Eina_List *l, *l_next;
Client_Request *cr;
Msg_Base *msg;
+   Eina_Bool found;
 
msg = _server_read(size);
if (!msg)
@@ -560,6 +574,7 @@ _server_dispatch(Eina_Bool *failed)
 if (cr-msg-rid != msg-rid) // dispatch this answer
   continue;
 
+found = EINA_TRUE;
 if (cr-cb)
   remove = cr-cb(cr-data, msg, size);
 if (remove)
@@ -571,8 +586,10 @@ _server_dispatch(Eina_Bool *failed)
  }
 
rid = msg-rid;
-   free(msg);
+   if (!found)
+ WRN(Got unexpected response %d for 

[EGIT] [core/efl] master 69/77: evas/cserve2: Add PID to shm filenames

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=660ad6e4a414c42364ab555f6f77354a97d04610

commit 660ad6e4a414c42364ab555f6f77354a97d04610
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Oct 8 17:06:33 2013 +0900

evas/cserve2: Add PID to shm filenames

This will help identify new memory pools in case cserve2
restarts and reloads the same glyphs for instance.
---
 src/bin/evas/evas_cserve2_shm.c   | 6 +++---
 src/bin/evas/evas_cserve2_shm_debug.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_shm.c b/src/bin/evas/evas_cserve2_shm.c
index 2df0bb5..2045cdd 100644
--- a/src/bin/evas/evas_cserve2_shm.c
+++ b/src/bin/evas/evas_cserve2_shm.c
@@ -77,8 +77,8 @@ cserve2_shm_request(const char *infix, size_t size)
  }
 
do {
-snprintf(shmname, sizeof(shmname), /evas-shm-%x-%s-%08x,
- (int) getuid(), infix, ++id);
+snprintf(shmname, sizeof(shmname), /evas-shm-%05d-%05d-%s-%08x,
+ (int) getuid(), (int) getpid(), infix, ++id);
 fd = shm_open(shmname, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
 if (fd == -1  errno != EEXIST)
   {
@@ -304,7 +304,7 @@ _cserve2_shm_cleanup()
const Eina_File_Direct_Info *f_info;
char pattern[NAME_MAX];
 
-   sprintf(pattern, evas-shm-%x-, (int) getuid());
+   sprintf(pattern, evas-shm-%05d-, (int) getuid());
iter = eina_file_direct_ls(/dev/shm);
EINA_ITERATOR_FOREACH(iter, f_info)
  {
diff --git a/src/bin/evas/evas_cserve2_shm_debug.c 
b/src/bin/evas/evas_cserve2_shm_debug.c
index 12ee29d..8535af4 100644
--- a/src/bin/evas/evas_cserve2_shm_debug.c
+++ b/src/bin/evas/evas_cserve2_shm_debug.c
@@ -179,7 +179,7 @@ _shm_files_list(const char *folder)
const Eina_File_Direct_Info *f_info;
char pattern[64];
 
-   sprintf(pattern, /evas-shm-%x-, (int) getuid());
+   sprintf(pattern, /evas-shm-%05d-, (int) getuid());
iter = eina_file_direct_ls(folder);
EINA_ITERATOR_FOREACH(iter, f_info)
  {
@@ -191,7 +191,7 @@ _shm_files_list(const char *folder)
  lst = eina_list_append(lst, strdup(shmname));
   }
 else
-  DBG(cserve2 cleanup: ignoring %s, f_info-path);
+  DBG(cserve2 scan: ignoring %s, f_info-path);
  }
eina_iterator_free(iter);
 

-- 




[EGIT] [core/efl] master 38/77: evas/cserve2: Remap glyph mempool if resized

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=d5ac5a8df37a6627b24455fb9364a007d6279872

commit d5ac5a8df37a6627b24455fb9364a007d6279872
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Aug 26 15:40:54 2013 +0900

evas/cserve2: Remap glyph mempool if resized
---
 src/lib/evas/cserve2/evas_cs2_client.c | 34 +++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index d6cedcc..0b036e0 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -1141,6 +1141,7 @@ _glyphs_map_free(Glyph_Map *map)
eina_file_close(map-mempool.f);
eina_file_map_free(map-index.f, map-index.data);
eina_file_close(map-index.f);
+   eina_hash_free(map-index.entries_by_hkey);
map-fe-map = NULL;
free(map);
 }
@@ -1338,11 +1339,14 @@ _glyph_map_open(Font_Entry *fe, const char *indexpath, 
const char *datapath)
 
map-fe = fe;
eina_clist_init(map-glyphs);
-   eina_strlcpy(map-index.path, indexpath, SHARED_BUFFER_PATH_MAX);
eina_strlcpy(map-mempool.path, datapath, SHARED_BUFFER_PATH_MAX);
 
-   map-index.generation_id = _index.generation_id;
-   _shared_index_remap_check(map-index, sizeof(Glyph_Data));
+   if (indexpath)
+ {
+eina_strlcpy(map-index.path, indexpath, SHARED_BUFFER_PATH_MAX);
+map-index.generation_id = _index.generation_id;
+_shared_index_remap_check(map-index, sizeof(Glyph_Data));
+ }
 
map-mempool.f = eina_file_open(map-mempool.path, EINA_TRUE);
map-mempool.size = eina_file_size_get(map-mempool.f);
@@ -1353,6 +1357,22 @@ _glyph_map_open(Font_Entry *fe, const char *indexpath, 
const char *datapath)
 }
 
 static void
+_glyph_map_remap_check(Glyph_Map *map)
+{
+   if (eina_file_refresh(map-mempool.f)
+   || (eina_file_size_get(map-mempool.f) != (size_t) map-mempool.size))
+ {
+WRN(Glyph pool has been resized.);
+eina_file_map_free(map-mempool.f, map-mempool.data);
+map-mempool.data = eina_file_map_all(map-mempool.f, 
EINA_FILE_RANDOM);
+if (map-mempool.data)
+  map-mempool.size = eina_file_size_get(map-mempool.f);
+else
+  map-mempool.size = 0;
+ }
+}
+
+static void
 _glyph_request_cb(void *data, const void *msg, int size)
 {
const Msg_Font_Glyphs_Loaded *resp = msg;
@@ -1405,6 +1425,8 @@ _glyph_request_cb(void *data, const void *msg, int size)
   datapath = name;
 fe-map = _glyph_map_open(fe, idxpath, datapath);
  }
+   else
+ _glyph_map_remap_check(fe-map);
 
for (i = 0; i  nglyphs; i++)
  {
@@ -1451,6 +1473,12 @@ _glyph_request_cb(void *data, const void *msg, int size)
  gl-base.bitmap.pixel_mode = pixel_mode;
  gl-rid = 0;
 
+ if (gl-offset + glsize  (size_t) fe-map-mempool.size)
+   {
+  ERR(Glyph is out of the buffer. Set buffer to NULL.);
+  gl-base.bitmap.buffer = NULL;
+   }
+
  eina_clist_add_head(fe-map-glyphs, gl-map_entry);
   }
  }

-- 




[EGIT] [core/efl] master 49/77: evas/cserve2: Fix font hinting

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=808c20f9896d4a92f15a653dd23d7e9088ab84d6

commit 808c20f9896d4a92f15a653dd23d7e9088ab84d6
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Sep 2 16:17:05 2013 +0900

evas/cserve2: Fix font hinting

cserve2 was not handling font hints properly in the server side
Add some consistency checks and separate glyphs per hinting value
---
 src/bin/evas/evas_cserve2_cache.c  | 51 ++
 src/bin/evas/evas_cserve2_debug.c  |  4 +--
 src/bin/evas/evas_cserve2_shm_debug.c  |  9 +++---
 src/lib/evas/cserve2/evas_cs2.h|  1 +
 src/lib/evas/cserve2/evas_cs2_client.c | 12 ++--
 5 files changed, 57 insertions(+), 20 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index b71ce01..40cd55d 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -73,7 +73,7 @@ struct _Font_Entry {
unsigned int font_data_id;
Font_Source *src;
void *ft; // Font_Info
-   Fash_Glyph2 *glyph_entries; // Fast access to the Glyph_Entry objects
+   Fash_Glyph2 *glyph_entries[3]; // Fast access to the Glyph_Entry objects
Shared_Array *glyph_datas; // Contains the Glyph_Data objects
unsigned int nglyphs;
Eina_Bool unused : 1;
@@ -1130,7 +1130,7 @@ static void
 _font_entry_free(Font_Entry *fe)
 {
Font_Data *fd;
-   int size;
+   int size, k;
 
if (!fe) return;
size = _font_entry_memory_usage_get(fe);
@@ -1148,7 +1148,8 @@ _font_entry_free(Font_Entry *fe)
 cserve2_shared_string_del(fd-name);
  }
 
-   fash_gl_free(fe-glyph_entries);
+   for (k = 0; k  3; k++)
+ fash_gl_free(fe-glyph_entries[k]);
cserve2_shared_array_del(fe-glyph_datas);
cserve2_shared_mempool_del(fe-mempool);
cserve2_font_ft_free(fe-ft);
@@ -1720,16 +1721,23 @@ static Slave_Request_Funcs _font_load_funcs = {
 static Eina_Bool
 _glyphs_request_check(Glyphs_Request *req, Eina_Bool report_load)
 {
-   unsigned int i;
+   unsigned int i, hint;
Font_Entry *fe = req-fe;
 
req-answer = malloc(sizeof(*req-answer) * req-nglyphs);
req-nanswer = 0;
 
+   hint = req-hint;
+   if (hint  2)
+ {
+WRN(Invalid font hint requested. Defaulting to 0.);
+hint = 0;
+ }
+
for (i = req-current; i  req-nglyphs; i++)
  {
 Glyph_Entry *ge;
-ge = fash_gl_find(fe-glyph_entries, req-glyphs[i]);
+ge = fash_gl_find(fe-glyph_entries[hint], req-glyphs[i]);
 if (ge)
   {
  req-answer[req-nanswer++] = ge;
@@ -1767,7 +1775,7 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int 
*resp_size)
size = sizeof(Msg_Font_Glyphs_Loaded);
size += sizeof(int) * 2;
size += shmname_size;
-   size += req-nanswer * 9 * sizeof(int);
+   size += req-nanswer * 10 * sizeof(int);
 
response = malloc(size);
if (!response) return NULL;
@@ -1813,6 +1821,8 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int 
*resp_size)
 buf += sizeof(int);
 memcpy(buf, gldata-pixel_mode, sizeof(int));
 buf += sizeof(int);
+memcpy(buf, gldata-hint, sizeof(int));
+buf += sizeof(int);
  }
 
*resp_size = size;
@@ -1915,7 +1925,7 @@ _glyphs_request_free(Glyphs_Request *req)
 static void
 _glyphs_load_request_prepare(Glyphs_Request *req)
 {
-   unsigned int i, max;
+   unsigned int i, max, hint;
req-nrender = 0;
Font_Entry *fe = req-fe;
 
@@ -1925,6 +1935,13 @@ _glyphs_load_request_prepare(Glyphs_Request *req)
 return;
  }
 
+   hint = req-hint;
+   if (hint  2)
+ {
+WRN(Invalid font hint requested. Defaulting to 0.);
+hint = 0;
+ }
+
// Won't render more than this number of glyphs
max = req-nglyphs - req-nanswer;
req-render = malloc(sizeof(*req-render) * max);
@@ -1932,7 +1949,7 @@ _glyphs_load_request_prepare(Glyphs_Request *req)
for (i = req-current; i  req-nglyphs; i++)
  {
 Glyph_Entry *ge;
-ge = fash_gl_find(fe-glyph_entries, req-glyphs[i]);
+ge = fash_gl_find(fe-glyph_entries[hint], req-glyphs[i]);
 if (ge)
   {
  req-answer[req-nanswer++] = ge;
@@ -1987,13 +2004,20 @@ _glyphs_load_request_response(Glyphs_Request *req,
 {
Font_Entry *fe = req-fe;
Shared_Mempool *mempool = msg-mempool;
-   unsigned int j;
+   unsigned int j, hint;
string_t shm_id = 0;
Font_Data *fd;
 
if (!msg-nglyphs)
  return _glyphs_loaded_msg_create(req, size);
 
+   hint = req-hint;
+   if (hint  2)
+ {
+WRN(Invalid font hint requested. Defaulting to 0.);
+hint = 0;
+ }
+
fd = _font_data_find(fe-font_data_id);
 
DBG(Font memory usage [begin]: %d / %d, font_mem_usage, max_font_usage);
@@ -2022,7 +2046,7 @@ _glyphs_load_request_response(Glyphs_Request *req,
  {
 Glyph_Entry *gl;
 
-gl = fash_gl_find(fe-glyph_entries, 

[EGIT] [core/efl] master 25/77: evas/cserve2: Store Glyph_Data in shared mempools

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=467b1b17395cf712ee4ec1ac4a3cef710370ed6d

commit 467b1b17395cf712ee4ec1ac4a3cef710370ed6d
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Aug 19 12:22:19 2013 +0900

evas/cserve2: Store Glyph_Data in shared mempools

- Create one Glyph_Data array per Font_Entry
- Copy Font_Source descriptors in shared array
- Copy font entries in shared index
- Send font index path over socket
- Merge Font_Source and Font_Data in shared memory
- Send font index path on client connect
- Repack font index after free
- Pass font shm name to clients
---
 src/bin/evas/evas_cserve2.h|  27 +-
 src/bin/evas/evas_cserve2_cache.c  | 530 +++--
 src/bin/evas/evas_cserve2_fonts.c  | 118 +++-
 src/bin/evas/evas_cserve2_index.c  |  14 +
 src/bin/evas/evas_cserve2_main.c   |   4 +
 src/lib/evas/cserve2/evas_cs2.h|  13 +-
 src/lib/evas/cserve2/evas_cs2_client.c | 218 +-
 7 files changed, 598 insertions(+), 326 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 02ee966..88f4370 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -62,6 +62,8 @@ extern Eina_Prefix *_evas_cserve2_pfx;
 typedef struct _Slave Slave;
 typedef struct _Slave_Thread_Data Slave_Thread_Data;
 typedef struct _Shm_Handle Shm_Handle;
+typedef struct _Shared_Array Shared_Array;
+typedef struct _Shared_Mempool Shared_Mempool;
 
 typedef enum {
FD_READ = 1,
@@ -172,14 +174,13 @@ struct _Slave_Msg_Font_Glyphs_Load {
   unsigned int *glyphs;
} glyphs;
struct {
-  Shm_Handle *shm;
-  unsigned int usage;
-  unsigned int nglyphs;
+  Shared_Mempool *mempool;
} cache;
 };
 
 struct _Slave_Msg_Glyph {
unsigned int index;
+   unsigned int buffer_id;
unsigned int offset;
unsigned int size;
unsigned int rows;
@@ -191,21 +192,13 @@ struct _Slave_Msg_Glyph {
 
 typedef struct _Slave_Msg_Glyph Slave_Msg_Glyph;
 
-struct _Slave_Msg_Font_Cache {
-   unsigned int nglyphs;
-   Slave_Msg_Glyph *glyphs;
-   Shm_Handle *shm;
-   unsigned int usage;
-};
-
-typedef struct _Slave_Msg_Font_Cache Slave_Msg_Font_Cache;
-
 struct _Slave_Msg_Font_Glyphs_Loaded {
-   unsigned int ncaches;
+   Shared_Mempool *mempool;
unsigned int gl_load_time;
unsigned int gl_render_time;
unsigned int gl_slave_time;
-   Slave_Msg_Font_Cache **caches;
+   Slave_Msg_Glyph *glyphs;
+   unsigned int nglyphs;
 };
 
 typedef struct _Slave_Msg_Font_Load Slave_Msg_Font_Load;
@@ -349,8 +342,6 @@ void cserve2_font_ft_free(void *fontinfo);
 void cserve2_shared_index_init(void);
 void cserve2_shared_index_shutdown(void);
 
-typedef struct _Shared_Array Shared_Array;
-typedef struct _Shared_Mempool Shared_Mempool;
 typedef Eina_Bool (* Shared_Array_Repack_Skip_Cb) (Shared_Array *sa,
const void *elem,
void *user_data);
@@ -382,7 +373,9 @@ int cserve2_shared_mempool_buffer_new(Shared_Mempool *sm, 
int size);
 int cserve2_shared_mempool_buffer_ref(Shared_Mempool *sm, int bufferid);
 void cserve2_shared_mempool_buffer_del(Shared_Mempool *sm, int bufferid);
 void *cserve2_shared_mempool_buffer_get(Shared_Mempool *sm, int bufferid);
-
+int cserve2_shared_mempool_buffer_offset_get(Shared_Mempool *sm, int bufferid);
+size_t cserve2_shared_mempool_size_get(Shared_Mempool *sm);
+const char *cserve2_shared_mempool_name_get(Shared_Mempool *sm);
 
 // Shared strings
 const char *cserve2_shared_strings_table_name_get();
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index efe90be..7c7932e 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -26,7 +26,6 @@ typedef struct _File_Watch File_Watch;
 
 typedef struct _Font_Source Font_Source;
 typedef struct _Font_Entry Font_Entry;
-typedef struct _Font_Cache Font_Cache;
 
 typedef enum {
CSERVE2_IMAGE_FILE,
@@ -62,22 +61,23 @@ struct _Font_Source {
string_t key;
string_t name;
string_t file;
-   int references;
-   void *ft;
+   int refcount;
+   void *ft; // Font_Source_Info
 };
 
 struct _Font_Entry {
-   Entry base;
+   ENTRY;
unsigned int rend_flags;
unsigned int size;
unsigned int dpi;
+   unsigned int font_data_id;
Font_Source *src;
-   void *ft;
-   Fash_Glyph2 *glyphs;
+   void *ft; // Font_Info
+   Fash_Glyph2 *glyph_entries; // Fast access to the Glyph_Entry objects
+   Shared_Array *glyph_datas; // Contains the Glyph_Data objects
unsigned int nglyphs;
-   Eina_List *caches;
-   Font_Cache *last_cache;
Eina_Bool unused : 1;
+   Shared_Mempool *mempool; // Contains the rendered glyphs
 #ifdef DEBUG_LOAD_TIME
struct timeval rstart; // start of the glyphs load request
struct timeval rfinish; // finish of the glyphs load 

[EGIT] [core/efl] master 34/77: evas/cserve2: Add valid flag on Image_Data and File_Data

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9d2400af8bfedbd74954d185ef1c24190798bb8e

commit 9d2400af8bfedbd74954d185ef1c24190798bb8e
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Aug 23 15:10:03 2013 +0900

evas/cserve2: Add valid flag on Image_Data and File_Data

Images and Files can be discovered by the client scanner before they
are valid (aka. loaded or opened). We want clients to ignore all
shared objects that are not ready yet, as they are in an undefined
state (values and memory might be invalid).
---
 src/bin/evas/evas_cserve2_cache.c  |  6 +-
 src/lib/evas/cserve2/evas_cs2.h|  2 ++
 src/lib/evas/cserve2/evas_cs2_client.c | 21 ++---
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index a1cda8c..88cd2c9 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -618,6 +618,7 @@ _open_request_response(Entry *entry, Slave_Msg_Image_Opened 
*resp, int *size)
 fd-loader_data = cserve2_shared_string_add(ldata);
  }
 
+   fd-valid = EINA_TRUE;
return _image_opened_msg_create(fd, size);
 }
 
@@ -831,6 +832,7 @@ _load_request_response(Image_Entry *ientry,
idata = _image_data_find(ENTRYID(ientry));
if (!idata) return NULL;
 
+   idata-valid = EINA_TRUE;
_entry_load_finish(ASENTRY(ientry));
ASENTRY(ientry)-request = NULL;
 
@@ -1529,6 +1531,7 @@ _image_entry_new(Client *client, int rid,
 idata-opts.degree = opts-degree;
 idata-opts.orientation = opts-orientation;
  }
+   idata-valid = EINA_FALSE;
idata-file_id = ref-entry-id;
idata-refcount = 1;
idata-id = image_id;
@@ -2463,10 +2466,11 @@ cserve2_cache_file_open(Client *client, unsigned int 
client_file_id,
 ERR(Could not create new file entry!);
 return -1;
  }
-   fd-id = file_id; // FIXME: write last (?)
+   fd-valid = EINA_FALSE;
fd-refcount = 1;
fd-path = cserve2_shared_string_add(path);
fd-key = cserve2_shared_string_add(key);
+   fd-id = file_id;
 
fentry = calloc(1, sizeof(File_Entry));
ASENTRY(fentry)-type = CSERVE2_IMAGE_FILE;
diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h
index 87633f0..bcba89a 100644
--- a/src/lib/evas/cserve2/evas_cs2.h
+++ b/src/lib/evas/cserve2/evas_cs2.h
@@ -332,6 +332,7 @@ struct _File_Data {
int loop_hint;
Eina_Bool alpha : 1;
Eina_Bool invalid : 1;
+   Eina_Bool valid : 1;
 };
 
 #define IMAGE_DATA_ARRAY_TAG ('I' | 'M'  8 | 'A'  16 | 'G'  24)
@@ -343,6 +344,7 @@ struct _Image_Data {
Eina_Bool alpha_sparse : 1;
Eina_Bool unused : 1;
Eina_Bool doload : 1;
+   Eina_Bool valid : 1;
 };
 
 #define FONT_DATA_ARRAY_TAG ('F' | 'O'  8 | 'N'  16 | 'T'  24)
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 7746e1d..b378b79 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -440,6 +440,10 @@ _image_opened_cb(void *data, const void *msg_received, int 
size)
 * -- jpeg
 */
//DBG(Received OPENED for RID: %d [open_rid: %d], answer-rid, 
ie-open_rid);
+
+   if (ie-server_id  !ie-open_rid)
+ return;
+
if (answer-rid != ie-open_rid)
  {
 WRN(Message rid (%d) differs from expected rid (open_rid: %d), 
answer-rid, ie-open_rid);
@@ -536,6 +540,10 @@ _image_loaded_cb(void *data, const void *msg_received, int 
size)
Image_Entry *ie = data;
 
//DBG(Received LOADED for RID: %d [load_rid: %d], answer-rid, 
ie-load_rid);
+
+   if (!ie-load_rid)
+ return;
+
if (answer-rid != ie-load_rid)
  {
 WRN(Message rid (%d) differs from expected rid (load_rid: %d), 
answer-rid, ie-load_rid);
@@ -926,7 +934,7 @@ evas_cserve2_image_load_wait(Image_Entry *ie)
 
 #if USE_SHARED_INDEX
fd = _shared_image_entry_file_data_find(ie);
-   if (fd)
+   if (fd  fd-valid)
  {
 INF(Bypassing socket wait (open_rid %d), ie-open_rid);
 ie-w = fd-w;
@@ -935,6 +943,7 @@ evas_cserve2_image_load_wait(Image_Entry *ie)
 ie-animated.loop_hint = fd-loop_hint;
 ie-animated.loop_count = fd-loop_count;
 ie-animated.frame_count = fd-frame_count;
+ie-server_id = fd-id;
 ie-open_rid = 0;
 return CSERVE2_NONE;
  }
@@ -981,7 +990,7 @@ evas_cserve2_image_load_data_wait(Image_Entry *ie)
 
 #if USE_SHARED_INDEX
idata = _shared_image_entry_image_data_find(ie);
-   if (idata)
+   if (idata  idata-valid)
  {
 // FIXME: Ugly copy  paste from _loaded_handle
 Data_Entry *dentry = ie-data2;
@@ -2196,7 +2205,7 @@ _shared_image_entry_image_data_find(Image_Entry *ie)
  eina_hash_find(_index.images.entries_by_hkey, ie-cache_key);
if (idata)
  {
-ERR(Image found in shared index (by cache_key).);
+DBG(Image found in shared index (by 

[EGIT] [core/efl] master 54/77: evas/cserve2: Fallback to normal cache for animated gifs

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=97d9fab7042f213498268dfc58636b823380245c

commit 97d9fab7042f213498268dfc58636b823380245c
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Sep 4 16:14:37 2013 +0900

evas/cserve2: Fallback to normal cache for animated gifs

Pass around animated flag for images that can be animated.
Fallback to local cache if the image is animated.
Implementing support for animated images in cserve2 does
not seem to make a lot of sense considering each frame must
be requested independently in real time,... and to be honest
there doesn't seem to be any valid use case anyway :)
---
 src/bin/evas/evas_cserve2_cache.c  |  2 ++
 src/bin/evas/evas_cserve2_shm_debug.c  |  3 ++-
 src/lib/evas/cache2/evas_cache2.c  |  3 +++
 src/lib/evas/cserve2/evas_cs2.h|  2 ++
 src/lib/evas/cserve2/evas_cs2_client.c |  9 +++-
 .../evas/engines/software_generic/evas_engine.c| 24 +++---
 6 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 40cd55d..83923d4 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -444,6 +444,7 @@ _image_opened_msg_create(File_Data *fd, int *size)
msg-image.loop_count = fd-loop_count;
msg-image.loop_hint = fd-loop_hint;
msg-image.alpha = fd-alpha;
+   msg-image.animated = fd-animated;
 
*size = sizeof(*msg);
 
@@ -615,6 +616,7 @@ _open_request_response(Entry *entry, Slave_Msg_Image_Opened 
*resp, int *size)
 
fd-w = resp-w;
fd-h = resp-h;
+   fd-animated = resp-animated;
fd-frame_count = resp-frame_count;
fd-loop_count = resp-loop_count;
fd-loop_hint = resp-loop_hint;
diff --git a/src/bin/evas/evas_cserve2_shm_debug.c 
b/src/bin/evas/evas_cserve2_shm_debug.c
index 426fd67..49bae20 100644
--- a/src/bin/evas/evas_cserve2_shm_debug.c
+++ b/src/bin/evas/evas_cserve2_shm_debug.c
@@ -519,7 +519,8 @@ _images_all_print_full(void)
  printf(  Loader:%s\n,
 _shared_string_get(fd-loader_data));
  printf(  Geometry:  %dx%d\n, fd-w, fd-h);
- printf(  Animation: frames: %d, loop: %d, hint: 
%d\n,
+ printf(  Animation: anim: %s, frames: %d, loop: %d, 
hint: %d\n,
+fd-animated ? YES : NO,
 fd-frame_count, fd-loop_count, fd-loop_hint);
  printf(  Alpha: %s\n, fd-alpha ? YES : NO);
  printf(  Invalid:   %s\n, fd-invalid ? YES : 
NO);
diff --git a/src/lib/evas/cache2/evas_cache2.c 
b/src/lib/evas/cache2/evas_cache2.c
index 4b51b32..0444741 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -873,6 +873,9 @@ evas_cache2_image_scale_load(Image_Entry *im,
int  error = EVAS_LOAD_ERROR_NONE;
Image_Entry  *ret;
 
+   if (!im-cache2)
+ return im;
+
if (!smooth  im-scale_hint != EVAS_IMAGE_SCALE_HINT_STATIC)
  goto parent_out;
 
diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h
index a47c384..835ed31 100644
--- a/src/lib/evas/cserve2/evas_cs2.h
+++ b/src/lib/evas/cserve2/evas_cs2.h
@@ -73,6 +73,7 @@ struct _Msg_Opened {
   int loop_count;
   int loop_hint; /* include Evas.h? Copy the enum around? */
   Eina_Bool alpha : 1;
+  Eina_Bool animated : 1;
} image;
 };
 
@@ -333,6 +334,7 @@ struct _File_Data {
Eina_Bool alpha : 1;
Eina_Bool invalid : 1;
Eina_Bool valid : 1;
+   Eina_Bool animated : 1;
 };
 
 #define IMAGE_DATA_ARRAY_TAG ('I' | 'M'  8 | 'A'  16 | 'G'  24)
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 852ae08..566bd06 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -505,6 +505,7 @@ _image_opened_cb(void *data, const void *msg_received, int 
size)
ie-animated.loop_hint = msg-image.loop_hint;
ie-animated.loop_count = msg-image.loop_count;
ie-animated.frame_count = msg-image.frame_count;
+   ie-animated.animated = msg-image.animated;
 }
 
 static void
@@ -985,9 +986,9 @@ evas_cserve2_image_load_wait(Image_Entry *ie)
 ie-animated.loop_hint = fd-loop_hint;
 ie-animated.loop_count = fd-loop_count;
 ie-animated.frame_count = fd-frame_count;
+ie-animated.animated = fd-animated;
 ie-server_id = fd-id;
 ie-open_rid = 0;
-return CSERVE2_NONE;
  }
 #endif
 
@@ -999,6 +1000,12 @@ evas_cserve2_image_load_wait(Image_Entry *ie)
   return CSERVE2_GENERIC;
  }
 
+   if (ie-animated.animated)
+ {
+WRN(This image is animated. cserve2 does not support animations);
+return CSERVE2_GENERIC;
+ }
+
return 

[EGIT] [core/efl] master 53/77: evas: Fix potential crash after image preload

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=bfe3fe27df9384642d8f3b277ec694c9d42fc0c9

commit bfe3fe27df9384642d8f3b277ec694c9d42fc0c9
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Sep 3 15:53:08 2013 +0900

evas: Fix potential crash after image preload

E17 crashed when running under cserve2.
Not sure about this commit. Also what about the other functions.
---
 src/lib/evas/canvas/evas_object_inform.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lib/evas/canvas/evas_object_inform.c 
b/src/lib/evas/canvas/evas_object_inform.c
index c4aa8e1..28ff355 100644
--- a/src/lib/evas/canvas/evas_object_inform.c
+++ b/src/lib/evas/canvas/evas_object_inform.c
@@ -66,6 +66,8 @@ void
 evas_object_inform_call_image_preloaded(Evas_Object *eo_obj)
 {
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
+   EINA_SAFETY_ON_NULL_RETURN(obj);
+
if (!_evas_object_image_preloading_get(eo_obj)) return;
_evas_object_image_preloading_check(eo_obj);
_evas_object_image_preloading_set(eo_obj, 0);

-- 




[EGIT] [core/efl] master 18/77: evas/cserve2: Fix Eina_File leak at shutdown

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a230e41409b21c05fab6a47ea2a5510ac848d9d1

commit a230e41409b21c05fab6a47ea2a5510ac848d9d1
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Aug 1 18:39:38 2013 +0900

evas/cserve2: Fix Eina_File leak at shutdown

cserve2_shutdown was not called
---
 src/lib/evas/canvas/evas_main.c|  5 +
 src/lib/evas/cserve2/evas_cs2_client.c | 20 ++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index f755fcc..bf23273 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -95,6 +95,11 @@ evas_shutdown(void)
   EINA_LOG_STATE_START,
   EINA_LOG_STATE_SHUTDOWN);
 
+#ifdef EVAS_CSERVE2
+   if (getenv(EVAS_CSERVE2))
+ evas_cserve2_shutdown();
+#endif
+
eina_cow_del(evas_object_proxy_cow);
eina_cow_del(evas_object_map_cow);
eina_cow_del(evas_object_state_cow);
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 5b8e463..6e65158 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -308,12 +308,14 @@ int
 evas_cserve2_shutdown(void)
 {
const char zeros[sizeof(Msg_Index_List)] = {0};
+   Msg_Index_List *empty = (Msg_Index_List *) zeros;
 
if ((--cserve2_init)  0)
  return cserve2_init;
 
DBG(Disconnecting from cserve2.);
-   _server_index_list_set((Msg_Base *) zeros, sizeof(Msg_Index_List));
+   empty-base.type = CSERVE2_INDEX_LIST;
+   _server_index_list_set((Msg_Base *) empty, sizeof(Msg_Index_List));
_server_disconnect();
 
return cserve2_init;
@@ -1948,7 +1950,21 @@ _shared_index_remap_check(Shared_Index *si, int elemsize)
 
// Note: all checks are unlikely to be true.
 
-   if (!si || elemsize = 0) return EINA_FALSE;
+   if (!si || elemsize = 0)
+ return EINA_FALSE;
+
+   if (!si-path[0])
+ {
+if (si-f)
+  {
+ DBG(Closing index map);
+ eina_file_map_free(si-f, si-data);
+ eina_file_close(si-f);
+ eina_hash_free(si-entries_by_hkey);
+ memset(si, 0, sizeof(*si));
+  }
+return EINA_FALSE;
+ }
 
if (si-generation_id != _index.generation_id)
  {

-- 




[EGIT] [core/efl] master 64/77: evas/cserve2: Fix reload of image without load_opts

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6f485d2a125be78388ffa95d88b041b20b8724ec

commit 6f485d2a125be78388ffa95d88b041b20b8724ec
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Oct 1 11:59:40 2013 +0900

evas/cserve2: Fix reload of image without load_opts

Problem: Images opened without load_opts are reopened
multiple times.
Solution: Use empty load opts when looking for the key.
---
 src/bin/evas/evas_cserve2.h   |  2 +-
 src/bin/evas/evas_cserve2_cache.c | 15 ---
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 158eefd..a90dc07 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -320,7 +320,7 @@ void cserve2_cache_client_new(Client *client);
 void cserve2_cache_client_del(Client *client);
 int cserve2_cache_file_open(Client *client, unsigned int client_file_id, const 
char *path, const char *key, unsigned int rid, Evas_Image_Load_Opts *lo);
 void cserve2_cache_file_close(Client *client, unsigned int client_file_id);
-int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int 
client_file_id, unsigned int image_id, Evas_Image_Load_Opts *opts);
+int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int 
client_file_id, unsigned int image_id, const Evas_Image_Load_Opts *opts);
 void cserve2_rgba_image_scale_do(void *src_data, int src_full_w, int 
src_full_h, void *dst_data, int src_x, int src_y, int src_w, int src_h, int 
dst_x, int dst_y, int dst_w, int dst_h, int alpha, int smooth);
 void cserve2_cache_image_load(Client *client, unsigned int client_image_id, 
unsigned int rid);
 void cserve2_cache_image_preload(Client *client, unsigned int client_image_id, 
unsigned int rid);
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 2a358f7..8b4e565 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -932,10 +932,8 @@ static void
 _image_key_set(unsigned int file_id, const Evas_Image_Load_Opts *opts,
char *buf, int size)
 {
-   const char empty[sizeof(Evas_Image_Load_Opts)] = {0};
-
if (!opts)
- opts = (Evas_Image_Load_Opts *) empty;
+ opts = empty_lo;
 
snprintf(buf, size,
 %u:%0.3f:%dx%d:%d:%d,%d+%dx%d:!([%d,%d:%dx%d]-[%dx%d:%d]):%d:%d,
@@ -950,7 +948,7 @@ _image_key_set(unsigned int file_id, const 
Evas_Image_Load_Opts *opts,
 }
 
 static unsigned int
-_image_opts_id_get(unsigned int file_id, Evas_Image_Load_Opts *opts,
+_image_opts_id_get(unsigned int file_id, const Evas_Image_Load_Opts *opts,
char *buf, int size)
 {
uintptr_t image_id;
@@ -1580,7 +1578,7 @@ cserve2_cache_client_del(Client *client)
 static Image_Entry *
 _image_entry_new(Client *client, int rid,
  unsigned int client_file_id, unsigned int client_image_id,
- Evas_Image_Load_Opts *opts, char *buf, size_t buf_size)
+ const Evas_Image_Load_Opts *opts, char *buf, size_t buf_size)
 {
Reference *ref, *oldref;
Image_Entry *ientry;
@@ -2823,7 +2821,7 @@ int
 cserve2_cache_image_entry_create(Client *client, int rid,
  unsigned int client_file_id,
  unsigned int client_image_id,
- Evas_Image_Load_Opts *opts)
+ const Evas_Image_Load_Opts *opts)
 {
Image_Data *idata;
Image_Entry *ientry;
@@ -2832,9 +2830,12 @@ cserve2_cache_image_entry_create(Client *client, int rid,
unsigned int image_id = 0;
char buf[4096];
 
+   if (!opts)
+ opts = empty_lo;
+
// search whether the image is already loaded by another client
ref = eina_hash_find(client-files.referencing, client_file_id);
-   if (ref  opts)
+   if (ref)
  image_id = _image_opts_id_get(ref-entry-id, opts, buf, sizeof(buf));
 
if (image_id)

-- 




[EGIT] [core/efl] master 67/77: evas/cserve2: Reconnect to cserve2 in case of server crash

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e74cac57e412bcd71f2cc58ba46d326aef0996c4

commit e74cac57e412bcd71f2cc58ba46d326aef0996c4
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Oct 2 20:23:14 2013 +0900

evas/cserve2: Reconnect to cserve2 in case of server crash

Try to reconnect to cserve2 if the socket connection was lost.
Resend some messages if necessary.

Images reload seems to be working.
Actually, the images don't change over time, so the clients just
keep the previous references to their images.

FONT RELOAD IS NOT WORKING:
- Crashes
- Invalid glyph data
- Infinite loop in _glyph_map_remap_check()

Root cause:
When new glyphs are requested from the server, they are added to
the mempool. So it is necessary to remap the font.
Unfortunately, in case of server reboot, we did not keep the mempool
so the old glyphs that were not requested again will not be valid.
---
 src/bin/evas/evas_cserve2_cache.c   |  10 +-
 src/lib/evas/cache2/evas_cache2.c   |   4 +-
 src/lib/evas/common/evas_font_draw.c|   7 +-
 src/lib/evas/common/evas_font_main.c|  10 +-
 src/lib/evas/cserve2/evas_cs2.h |   1 +
 src/lib/evas/cserve2/evas_cs2_client.c  | 454 +---
 src/lib/evas/cserve2/evas_cs2_private.h |   1 -
 7 files changed, 379 insertions(+), 108 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 8b4e565..5ec597b 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -2769,6 +2769,7 @@ try_again:
0, unscaled, buf, sizeof(buf));
  if (!orig_entry) return -1;
 
+ image_id = orig_entry-base.id;
  orig_data = _image_data_find(ENTRYID(orig_entry));
  orig_data-unused = EINA_TRUE;
  fentry = _file_entry_find(orig_data-file_id);
@@ -2914,12 +2915,17 @@ cserve2_cache_image_load(Client *client, unsigned int 
client_image_id, unsigned
  {
 ERR(Can't load: client %d has no image id %d,
 client-id, client_image_id);
+cserve2_client_error_send(client, rid, CSERVE2_NOT_LOADED);
 return;
  }
 
ientry = (Image_Entry *) ref-entry;
idata = _image_data_find(ENTRYID(ientry));
-   if (!idata) return;
+   if (!idata)
+ {
+cserve2_client_error_send(client, rid, CSERVE2_INVALID_CACHE);
+return;
+ }
 
fd = _file_data_find(idata-file_id);
if (!fd || fd-invalid)
@@ -3120,6 +3126,7 @@ cserve2_cache_font_glyphs_load(Client *client, const char 
*source,
if (!req)
  {
 free(glyphs);
+cserve2_client_error_send(client, rid, CSERVE2_NOT_LOADED);
 return -1;
  }
 
@@ -3153,6 +3160,7 @@ cserve2_cache_font_glyphs_used(Client *client, const char 
*source,
if (!req)
  {
 free(glyphs);
+cserve2_client_error_send(client, rid, CSERVE2_NOT_LOADED);
 return 0;
  }
 
diff --git a/src/lib/evas/cache2/evas_cache2.c 
b/src/lib/evas/cache2/evas_cache2.c
index a9ed8ca..e1a9d01 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -997,10 +997,10 @@ evas_cache2_image_load_data(Image_Entry *ie)
 error = evas_cserve2_image_load_data_wait(ie);
 
 RGBA_Image *im = (RGBA_Image *)ie;
-DBG(try cserve2 image data '%s' '%s' loaded!,
-ie-file, ie-key ? ie-key : );
 if ((error == CSERVE2_NONE)  im-image.data)
   {
+ DBG(try cserve2 image data '%s' '%s' loaded!,
+ ie-file, ie-key ? ie-key : );
  error = EVAS_LOAD_ERROR_NONE;
   }
 else
diff --git a/src/lib/evas/common/evas_font_draw.c 
b/src/lib/evas/common/evas_font_draw.c
index 5b8423d..2b82035 100644
--- a/src/lib/evas/common/evas_font_draw.c
+++ b/src/lib/evas/common/evas_font_draw.c
@@ -304,7 +304,12 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
 
 fg = evas_common_font_int_cache_glyph_get(fi, idx);
 if (!fg) continue;
-if (!fg-glyph_out) evas_common_font_int_cache_glyph_render(fg);
+if (!fg-glyph_out)
+  if (!evas_common_font_int_cache_glyph_render(fg))
+{
+   fg = NULL;
+   goto error;
+}

glyph = eina_inarray_grow(glyphs, 1);
if (!glyph) goto error;
diff --git a/src/lib/evas/common/evas_font_main.c 
b/src/lib/evas/common/evas_font_main.c
index 32c7e37..769114a 100644
--- a/src/lib/evas/common/evas_font_main.c
+++ b/src/lib/evas/common/evas_font_main.c
@@ -548,8 +548,14 @@ evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph 
*fg)
 fg-glyph_out = evas_cserve2_font_glyph_bitmap_get(fi-cs2_handler,
fg-index,
  

[EGIT] [core/efl] master 59/77: evas/cserve2: Add alpha flag to Image_data

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=25d71f823668ecb1865c61f306890fee654b9d32

commit 25d71f823668ecb1865c61f306890fee654b9d32
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Sep 24 18:18:53 2013 +0900

evas/cserve2: Add alpha flag to Image_data
---
 src/bin/evas/evas_cserve2.h   |  1 +
 src/bin/evas/evas_cserve2_cache.c | 14 +++---
 src/bin/evas/evas_cserve2_slave.c |  1 +
 src/lib/evas/cserve2/evas_cs2.h   |  2 ++
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index 2a3a40e..158eefd 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -146,6 +146,7 @@ struct _Slave_Msg_Image_Load {
 
 struct _Slave_Msg_Image_Loaded {
int w, h;
+   Eina_Bool alpha : 1;
Eina_Bool alpha_sparse : 1;
 };
 
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index e86643d..d0589dd 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -508,6 +508,7 @@ _image_loaded_msg_create(Image_Entry *ientry, Image_Data 
*idata, int *size)
msg-alpha_sparse = idata-alpha_sparse;
msg-image.w = idata-w;
msg-image.h = idata-h;
+   msg-alpha = idata-alpha;
 
if (idata-shm_id)
  {
@@ -806,18 +807,8 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *idata, 
Image_Entry *original)
 {
char *scale_map, *orig_map;
void *src_data, *dst_data;
-   File_Data *fd;
Image_Data *orig_idata;
 
-#warning FIXME Remove this call, add alpha flag to Image_Data
-   fd = _file_data_find(idata-file_id);
-   if (!fd)
- {
-ERR(Could not find file data %u for image %u,
-idata-file_id, idata-id);
-return -1;
- }
-
orig_idata = _image_data_find(original-base.id);
if (!orig_idata)
  {
@@ -858,7 +849,7 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *idata, 
Image_Entry *original)
 idata-opts.scale_load.src_w, idata-opts.scale_load.src_h,
 0, 0,
 idata-opts.scale_load.dst_w, idata-opts.scale_load.dst_h,
-fd-alpha, idata-opts.scale_load.smooth);
+idata-alpha, idata-opts.scale_load.smooth);
 
cserve2_shm_unmap(original-shm);
cserve2_shm_unmap(scale_shm);
@@ -906,6 +897,7 @@ _load_request_response(Image_Entry *ientry,
_entry_load_finish(ASENTRY(ientry));
ASENTRY(ientry)-request = NULL;
 
+   idata-alpha = resp-alpha;
idata-alpha_sparse = resp-alpha_sparse;
if (!idata-doload)
  DBG(Entry %d loaded by speculative preload., idata-id);
diff --git a/src/bin/evas/evas_cserve2_slave.c 
b/src/bin/evas/evas_cserve2_slave.c
index 963a1db..43fc3a5 100644
--- a/src/bin/evas/evas_cserve2_slave.c
+++ b/src/bin/evas/evas_cserve2_slave.c
@@ -456,6 +456,7 @@ image_load(const char *file, const char *key, const char 
*shmfile,
 
result-w = property.w;
result-h = property.h;
+   result-alpha = property.alpha;
 
if (property.alpha  property.premul)
  {
diff --git a/src/lib/evas/cserve2/evas_cs2.h b/src/lib/evas/cserve2/evas_cs2.h
index 5378790..7dcd441 100644
--- a/src/lib/evas/cserve2/evas_cs2.h
+++ b/src/lib/evas/cserve2/evas_cs2.h
@@ -93,6 +93,7 @@ struct _Msg_Loaded {
struct {
   unsigned int w, h; // Real dimensions of this image. May differ from 
Msg_Opened::image::{w,h} after scaling.
} image;
+   Eina_Bool alpha : 1;
Eina_Bool alpha_sparse : 1;
 };
 
@@ -358,6 +359,7 @@ struct _Image_Data {
string_t shm_id;
Evas_Image_Load_Opts opts;
uint32_t w, h;
+   Eina_Bool alpha : 1;
Eina_Bool alpha_sparse : 1;
Eina_Bool unused : 1;
Eina_Bool doload : 1;

-- 




[EGIT] [core/efl] master 61/77: evas/cserve2: Fix invalid file referencing in client

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=f18b71d5155e50ae1f494abe11813ac292e53e1d

commit f18b71d5155e50ae1f494abe11813ac292e53e1d
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Sep 25 18:57:04 2013 +0900

evas/cserve2: Fix invalid file referencing in client

Fixes elementary_test Bg Image:
 - Various load_opts (jpeg geometry) where not handled properly
   by the client.
---
 src/bin/evas/evas_cserve2_slave.c  | 12 -
 src/lib/evas/cserve2/evas_cs2_client.c | 97 +-
 2 files changed, 58 insertions(+), 51 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_slave.c 
b/src/bin/evas/evas_cserve2_slave.c
index 43fc3a5..7aeac6b 100644
--- a/src/bin/evas/evas_cserve2_slave.c
+++ b/src/bin/evas/evas_cserve2_slave.c
@@ -434,8 +434,8 @@ image_load(const char *file, const char *key, const char 
*shmfile,
  }
 
memset(property, 0, sizeof (property));
-   property.w = params-w;
-   property.h = params-h;
+   property.w = params-opts.w; // Should we rather use params-w ?
+   property.h = params-opts.h;
 
skey = eina_stringshare_add(key);
loader_data = _image_file_open(fd, skey, opts, module, property, 
animated, funcs);
@@ -446,6 +446,14 @@ image_load(const char *file, const char *key, const char 
*shmfile,
 goto done;
  }
 
+   if (params-shm.mmap_size  (int) (property.w * property.h * 4))
+ {
+printf(LOAD failed at %s:%d: shm map is too small (%d) for this image 
(%ux%u)\n,
+   __FUNCTION__, __LINE__,
+   params-shm.mmap_size, property.w , property.h);
+goto done;
+ }
+
ok = funcs-file_data(loader_data, property, map, error);
if (!ok || (error != EVAS_LOAD_ERROR_NONE))
  {
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index e6f43a7..fa29fab 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -705,15 +705,56 @@ _build_absolute_path(const char *path, char buf[], int 
size)
return len;
 }
 
+// NOTE: Copy  paste from evas_cserve2_cache.c (TODO: Merge into common file)
+static Eina_Bool
+_evas_image_load_opts_empty(Evas_Image_Load_Opts *lo)
+{
+   if (!lo) return EINA_TRUE;
+
+   return ((lo-scale_down_by == 0)
+(lo-dpi == 0.0)
+(lo-w == 0)  (lo-h == 0)
+(lo-region.x == 0)  (lo-region.y == 0)
+(lo-region.w == 0)  (lo-region.h == 0)
+(lo-orientation == 0));
+}
+
+static void
+_file_hkey_get(char *buf, size_t sz, const char *path, const char *key,
+   Evas_Image_Load_Opts *lo)
+{
+   // Same as _evas_cache_image_loadopts_append() but not optimized :)
+   if (lo  _evas_image_load_opts_empty(lo))
+ lo = NULL;
+
+   if (!lo)
+ snprintf(buf, sz, %s:%s, path, key);
+   else
+ {
+if (lo-orientation)
+  {
+ snprintf(buf, sz, %s:%s//@/%d/%f/%dx%d/%d+%d.%dx%d,
+  path, key, lo-scale_down_by, lo-dpi, lo-w, lo-h,
+  lo-region.x, lo-region.y, lo-region.w, lo-region.h);
+  }
+else
+  {
+ snprintf(buf, sz, %s:%s//@/%d/%f/%dx%d/%d+%d.%dx%d/o,
+  path, key, lo-scale_down_by, lo-dpi, lo-w, lo-h,
+  lo-region.x, lo-region.y, lo-region.w, lo-region.h);
+  }
+ }
+}
+
 static unsigned int
 _image_open_server_send(Image_Entry *ie, const char *file, const char *key,
 Evas_Image_Load_Opts *opts)
 {
int flen, klen;
-   int size;
+   int size, hkey_len;
char *buf;
char filebuf[PATH_MAX];
-   char *file_hkey;
+   char *hkey;
Msg_Open msg_open;
File_Entry *fentry;
Data_Entry *dentry;
@@ -738,11 +779,10 @@ _image_open_server_send(Image_Entry *ie, const char 
*file, const char *key,
if (!key) key = ;
klen = strlen(key) + 1;
 
-   file_hkey = alloca(flen + klen);
-   memcpy(file_hkey, file, flen);
-   file_hkey[flen - 1] = ':';
-   memcpy(file_hkey + flen, key, klen);
-   fentry = eina_hash_find(_file_entries, file_hkey);
+   hkey_len = flen + klen + 1024;
+   hkey = alloca(hkey_len);
+   _file_hkey_get(hkey, hkey_len, filebuf, key, opts);
+   fentry = eina_hash_find(_file_entries, hkey);
if (!fentry)
  {
 fentry = calloc(1, sizeof(*fentry));
@@ -750,7 +790,7 @@ _image_open_server_send(Image_Entry *ie, const char *file, 
const char *key,
   return 0;
 
 fentry-file_id = ++_file_id;
-fentry-hkey = eina_stringshare_add(file_hkey);
+fentry-hkey = eina_stringshare_add(hkey);
 eina_hash_direct_add(_file_entries, fentry-hkey, fentry);
  }
fentry-refcount++;
@@ -2069,47 +2109,6 @@ _shared_string_get(int id)
do { if (!_shared_index_remap_check((si), sizeof(typ))) { \
CRIT(Failed to remap index); return NULL; } } while (0)
 
-
-static Eina_Bool
-_evas_image_load_opts_empty(Evas_Image_Load_Opts 

[EGIT] [core/efl] master 35/77: evas/cserve2: Fix lag with invalid font glyphs

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8b39c443fe711fd311d1fabc6273b023bd242694

commit 8b39c443fe711fd311d1fabc6273b023bd242694
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Aug 23 18:01:22 2013 +0900

evas/cserve2: Fix lag with invalid font glyphs
---
 src/bin/evas/evas_cserve2_fonts.c | 11 +--
 src/bin/evas/evas_cserve2_main.c  | 18 +-
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_fonts.c 
b/src/bin/evas/evas_cserve2_fonts.c
index ed0698c..b9da989 100644
--- a/src/bin/evas/evas_cserve2_fonts.c
+++ b/src/bin/evas/evas_cserve2_fonts.c
@@ -335,7 +335,7 @@ _font_slave_glyph_render(Font_Info *fi, 
Slave_Msg_Font_Glyphs_Loaded *response,
if (!glyphsize)
  {
 FT_Done_Glyph(glyph);
-return EINA_FALSE;
+goto on_error;
  }
 
buffer_id = cserve2_shared_mempool_buffer_new(response-mempool, glyphsize);
@@ -343,7 +343,7 @@ _font_slave_glyph_render(Font_Info *fi, 
Slave_Msg_Font_Glyphs_Loaded *response,
if (!data)
  {
 FT_Done_Glyph(glyph);
-return EINA_FALSE;
+goto on_error;
  }
memcpy(data, bglyph-bitmap.buffer, glyphsize);
 
@@ -363,6 +363,13 @@ _font_slave_glyph_render(Font_Info *fi, 
Slave_Msg_Font_Glyphs_Loaded *response,
FT_Done_Glyph(glyph);
 
return EINA_TRUE;
+
+on_error:
+   // Create invalid entry for this index.
+   memset(response-glyphs[response-nglyphs], 0, sizeof(Slave_Msg_Glyph));
+   response-glyphs[response-nglyphs].index = idx;
+   response-nglyphs++;
+   return EINA_FALSE;
 }
 
 static void
diff --git a/src/bin/evas/evas_cserve2_main.c b/src/bin/evas/evas_cserve2_main.c
index 1509a9c..fa70fec 100644
--- a/src/bin/evas/evas_cserve2_main.c
+++ b/src/bin/evas/evas_cserve2_main.c
@@ -24,15 +24,15 @@ cserve2_client_error_send(Client *client, unsigned int rid, 
int error_code)
int size;
Msg_Error msg;
 
-// clear the struct with possible paddings, since it is not aligned.
-memset(msg, 0, sizeof(msg));
-msg.base.rid = rid;
-msg.base.type = CSERVE2_ERROR;
-msg.error = error_code;
-
-size = sizeof(msg);
-cserve2_client_send(client, size, sizeof(size));
-cserve2_client_send(client, msg, sizeof(msg));
+   // clear the struct with possible paddings, since it is not aligned.
+   memset(msg, 0, sizeof(msg));
+   msg.base.rid = rid;
+   msg.base.type = CSERVE2_ERROR;
+   msg.error = error_code;
+
+   size = sizeof(msg);
+   cserve2_client_send(client, size, sizeof(size));
+   cserve2_client_send(client, msg, sizeof(msg));
 }
 
 void

-- 




Re: [E-devel] [RFC] configure options for maintainers

2013-10-28 Thread Cedric BAIL
On Mon, Oct 28, 2013 at 4:27 PM, Carsten Haitzler ras...@rasterman.com wrote:
 On Mon, 28 Oct 2013 14:45:38 +0900 Cedric BAIL cedric.b...@free.fr said:
 On Mon, Oct 28, 2013 at 11:49 AM, Carsten Haitzler ras...@rasterman.com
 wrote:
  On Sat, 12 Oct 2013 11:43:33 +0900 Jérôme Pinot ngc...@gmail.com said:
 
  great.. but how do you EXTRACT this info then from the lib? :) it's a lib..
  it can't execute on its own... and printfing such strings on every fn call
  is just anti-social :)

 I would have said :
  #define EFL_BUILD_DISTRO MyDistro
  #define EFL_BUILD_VENDOR Main Tainer f...@bar.org
  #define EFL_BUILD_VERSION 42

 ummm... ok - and so then we have tyo rely on application executables
 specifically finding these and printfing them or stuffing them into dialogs?

We could put those variable also in the pkg-config, but I was inclined
on using that in our .e-crashdump.txt infra. So plain C code there.

  Hi,
 
  During the Enlightenment French League^W^W dinner, we had this idea of
  having a configure option for the EFL to setup a string identifying the
  compiler/maintainer/distribution of the build. Several projects use this
  kind of string, for instance TexLive, LibreOffice or POV-Ray. It can be
  use to find quickly the maintainer, to generate automatic bug reports
  and most important, blame someone else (not you, no, really).
 
  There are several way to accomplish this during configuration:
 
  POV-Ray uses the COMPILED_BY=Main Tainer f...@bar.org environment
  variable
 
  TexLive uses --with-banner-add=Tex Live 2013/MyDistro Main Tainer
  f...@bar.org
 
  LibreOffice uses several options:
  --with-distro=MyDistro
  --with-vendor=Main Tainer f...@bar.org
  --with-build-version=42
 
  It seems to me that the LibreOffice options are better.
 
  What do you think about this?
 
  --
  Jérôme Pinot
  http://ngc891.blogdns.net/
 
 
  --
  - Codito, ergo sum - I code, therefore I am --
  The Rasterman (Carsten Haitzler)ras...@rasterman.com
 
 
  --
  October Webinars: Code for Performance
  Free Intel webinars can help you accelerate application performance.
  Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
  from the latest Intel processors and coprocessors. See abstracts and
  register 
  http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
  ___ enlightenment-devel mailing
  list enlightenment-devel@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/enlightenment-devel



 --
 Cedric BAIL

 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


 --
 - Codito, ergo sum - I code, therefore I am --
 The Rasterman (Carsten Haitzler)ras...@rasterman.com


 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/enlightenment-devel



-- 
Cedric BAIL

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[EGIT] [core/efl] master 11/77: evas/cserve2: Simplify error logs

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=ee74562bf00d7cc7949489c0d9b8e9a0c61fa1a0

commit ee74562bf00d7cc7949489c0d9b8e9a0c61fa1a0
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Jul 24 18:17:52 2013 +0900

evas/cserve2: Simplify error logs
---
 src/bin/evas/evas_cserve2_cache.c | 42 ---
 1 file changed, 17 insertions(+), 25 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index b8a55c9..cfb049f 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -295,7 +295,10 @@ _file_entry_find(unsigned int entry_id)
 
e = (Entry *) eina_hash_find(file_entries, entry_id);
if (!e || e-type != CSERVE2_IMAGE_FILE)
- return NULL;
+ {
+ERR(Could not find file entry %u, entry_id);
+return NULL;
+ }
 
return (File_Entry *) e;
 }
@@ -325,7 +328,10 @@ _image_entry_find(unsigned int entry_id)
 
e = (Entry *) eina_hash_find(image_entries, entry_id);
if (!e || e-type != CSERVE2_IMAGE_DATA)
- return NULL;
+ {
+ERR(Could not find image entry %u, entry_id);
+return NULL;
+ }
 
return (Image_Entry *) e;
 }
@@ -595,11 +601,7 @@ _load_request_build(Image_Entry *ientry, int *bufsize)
Image_Data *idata;
 
idata = _image_data_find(ENTRYID(ientry));
-   if (!idata || !idata-refcount)
- {
-ERR(Image data not found for entry %u, ENTRYID(ientry));
-return NULL;
- }
+   if (!idata) return NULL;
 
fd = _file_data_find(idata-file_id);
if (!fd)
@@ -762,11 +764,7 @@ _load_request_response(Image_Entry *ientry,
Image_Data *idata;
 
idata = _image_data_find(ENTRYID(ientry));
-   if (!idata)
- {
-ERR(Image data %u not found, ENTRYID(ientry));
-return NULL;
- }
+   if (!idata) return NULL;
 
_entry_load_finish(ASENTRY(ientry));
ASENTRY(ientry)-request = NULL;
@@ -1195,6 +1193,7 @@ _entry_unused_push(Image_Entry *ientry)
int size;
 
idata = _image_data_find(ENTRYID(ientry));
+   if (!idata) return;
 
size = _image_entry_size_get(ientry);
if ((size  max_unused_mem_usage) || !(idata-doload))
@@ -1453,11 +1452,7 @@ _file_changed_cb(const char *path EINA_UNUSED, Eina_Bool 
deleted EINA_UNUSED, vo
 
 fd-invalid = EINA_TRUE;
 fentry = _file_entry_find(fd-id);
-if (!fentry)
-  {
- ERR(Could not find file entry for id %u, fd-id);
- continue;
-  }
+if (!fentry) continue;
 
 fentry-watcher = NULL;
 
@@ -1478,7 +1473,6 @@ _file_changed_cb(const char *path EINA_UNUSED, Eina_Bool 
deleted EINA_UNUSED, vo
   if (idata-unused)
 _image_entry_free(ie);
}
- else ERR(Image data %u not found, ENTRYID(ie));
   }
 
 _file_id_free(fd);
@@ -2095,6 +2089,7 @@ _image_data_entry_stats_cb(const Eina_Hash *hash 
EINA_UNUSED, const void *key EI
File_Data *fd;
 
idata = _image_data_find(ENTRYID(ientry));
+   if (!idata) return EINA_TRUE;
 
// accounting numbers
msg-images.images_loaded++;
@@ -2501,11 +2496,12 @@ _cserve2_cache_fast_scaling_check(Client *client, 
Image_Entry *ientry)
File_Entry *fentry;
Image_Data *idata;
 
-#warning NOT IMPLEMENTED. PLEASE REIMLPEMENT.
return -1;
 #if 0
+   if (!ientry) return -1;
 
-   if (!ientry || !idata) return -1;
+   idata = _image_data_find(ENTRYID(ientry));
+   if (!idata) return -1;
 
dst_w = entry-opts.scale_load.dst_w;
dst_h = entry-opts.scale_load.dst_h;
@@ -2726,11 +2722,7 @@ cserve2_cache_image_load(Client *client, unsigned int 
client_image_id, unsigned
 
ientry = (Image_Entry *) ref-entry;
idata = _image_data_find(ENTRYID(ientry));
-   if (!idata)
- {
-ERR(Image data not found for entry %u, ENTRYID(ientry));
-return;
- }
+   if (!idata) return;
 
fd = _file_data_find(idata-file_id);
if (!fd || fd-invalid)

-- 




[EGIT] [core/efl] master 48/77: evas/cserve2: Reset pointers to NULL after close

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a7b3f7efd3bf7291109131db7fb694c8eef72248

commit a7b3f7efd3bf7291109131db7fb694c8eef72248
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Sep 2 10:10:02 2013 +0900

evas/cserve2: Reset pointers to NULL after close
---
 src/lib/evas/cserve2/evas_cs2_client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index af5eff8..1538b49 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -2201,6 +2201,8 @@ _shared_index_remap_check(Shared_Index *si, int elemsize)
  eina_file_map_free(si-f, si-data);
  eina_file_close(si-f);
  eina_hash_free(si-entries_by_hkey);
+ si-f = NULL;
+ si-data = NULL;
  memset(si, 0, sizeof(*si));
   }
 return EINA_FALSE;

-- 




[EGIT] [core/efl] master 47/77: evas/cserve2: Add TIMEOUT macro for cs2 client

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e06111493493c7dcf2730f3f4a59f62ea68e7c09

commit e06111493493c7dcf2730f3f4a59f62ea68e7c09
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Aug 29 16:46:25 2013 +0900

evas/cserve2: Add TIMEOUT macro for cs2 client

This will help debugging as we can disable the timeout on demand.
---
 src/lib/evas/cserve2/evas_cs2_client.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 01bd8b7..af5eff8 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -17,6 +17,7 @@
 
 #ifdef EVAS_CSERVE2
 
+#define TIMEOUT 1000
 #define USE_SHARED_INDEX 1
 #define SHARED_INDEX_ADD_TO_HASH 1
 #define HKEY_LOAD_OPTS_STR_LEN 215
@@ -395,6 +396,7 @@ _server_dispatch_until(unsigned int rid)
  {
 rrid = _server_dispatch(failed);
 if (rrid == rid) break;
+#if TIMEOUT
 else if (failed)
   {
  int sel;
@@ -402,8 +404,8 @@ _server_dispatch_until(unsigned int rid)
  //DBG(Waiting for request %d..., rid);
  FD_ZERO(rfds);
  FD_SET(socketfd, rfds);
- tv.tv_sec = 1;
- tv.tv_usec = 0;
+ tv.tv_sec = TIMEOUT / 1000;
+ tv.tv_usec = TIMEOUT * 1000;
  sel = select(socketfd + 1, rfds, NULL, NULL, tv);
  if (sel == -1)
{
@@ -425,6 +427,7 @@ _server_dispatch_until(unsigned int rid)
   return EINA_FALSE;
}
   }
+#endif
  }
return EINA_TRUE;
 }

-- 




[EGIT] [core/efl] master 22/77: evas/cserve2: Add compile-time log level flag for cserve2

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=28a5c6f587992b5cf5506129c86cdde95253d525

commit 28a5c6f587992b5cf5506129c86cdde95253d525
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Wed Aug 7 15:45:35 2013 +0900

evas/cserve2: Add compile-time log level flag for cserve2

DBG and INF messages pollute the logs and performance reports
from valgrind, let's disable them at build-time for better
benchmarking.

Fix other compilation warnings and clean code a bit
---
 src/bin/evas/evas_cserve2.h |  34 +-
 src/bin/evas/evas_cserve2_cache.c   | 160 ++--
 src/bin/evas/evas_cserve2_main_loop_linux.c |   4 +-
 3 files changed, 113 insertions(+), 85 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index f4a1d8d..02ee966 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -4,26 +4,54 @@
 #include Eina.h
 #include evas_cs2.h
 
+#ifndef CSERVE2_LOG_LEVEL
+#define CSERVE2_LOG_LEVEL 2
+#endif
+
 #ifdef CRIT
 #undef CRIT
 #endif
+#if CSERVE2_LOG_LEVEL = 0
 #define CRIT(...) EINA_LOG_DOM_CRIT(_evas_cserve2_bin_log_dom, __VA_ARGS__)
+#else
+#define CRIT(...) do {} while(0)
+#endif
+
 #ifdef ERR
 #undef ERR
 #endif
+#if CSERVE2_LOG_LEVEL = 1
 #define ERR(...) EINA_LOG_DOM_ERR(_evas_cserve2_bin_log_dom, __VA_ARGS__)
-#ifdef DBG
-#undef DBG
+#else
+#define ERR(...) do {} while(0)
 #endif
-#define DBG(...) EINA_LOG_DOM_DBG(_evas_cserve2_bin_log_dom, __VA_ARGS__)
+
 #ifdef WRN
 #undef WRN
 #endif
+#if CSERVE2_LOG_LEVEL = 2
 #define WRN(...) EINA_LOG_DOM_WARN(_evas_cserve2_bin_log_dom, __VA_ARGS__)
+#else
+#define WRN(...) do {} while(0)
+#endif
+
 #ifdef INF
 #undef INF
 #endif
+#if CSERVE2_LOG_LEVEL = 3
 #define INF(...) EINA_LOG_DOM_INFO(_evas_cserve2_bin_log_dom, __VA_ARGS__)
+#else
+#define INF(...) do {} while(0)
+#endif
+
+#ifdef DBG
+#undef DBG
+#endif
+#if CSERVE2_LOG_LEVEL = 4
+#define DBG(...) EINA_LOG_DOM_DBG(_evas_cserve2_bin_log_dom, __VA_ARGS__)
+#else
+#define DBG(...) do {} while(0)
+#endif
 
 #define DEBUG_LOAD_TIME 1
 
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 1a025a8..3a66988 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -1691,7 +1691,6 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int 
*resp_size)
Eina_List *ll, *answers = NULL;
const char *shmname;
unsigned int shmsize;
-   unsigned int intsize;
char *resp, *buf;
Glyphs_Group *iter;
 
@@ -1706,20 +1705,18 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int 
*resp_size)
// ncaches * sizeof(cache) + nglyphs1 * sizeof(glyph) +
//   nglyphs2 * sizeof(glyph)...
 
-   intsize = sizeof(unsigned int);
-
EINA_LIST_FOREACH(answers, ll, iter)
  {
 shmname = cserve2_shm_name_get(iter-fc-shm);
 shmsize = eina_stringshare_strlen(shmname) + 1;
 // shm namelen + name
-size += intsize + shmsize;
+size += sizeof(int) + shmsize;
 
 // nglyphs
-size += intsize;
+size += sizeof(int);
 // nglyphs * (index + offset + size + rows + width + pitch +
 //num_grays + pixel_mode)
-size += eina_list_count(iter-glyphs) * 8 * intsize;
+size += eina_list_count(iter-glyphs) * 8 * sizeof(int);
  }
 
resp = malloc(size);
@@ -1733,35 +1730,35 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int 
*resp_size)
 
 shmname = cserve2_shm_name_get(iter-fc-shm);
 shmsize = eina_stringshare_strlen(shmname) + 1;
-memcpy(buf, shmsize, intsize);
-buf += intsize;
+memcpy(buf, shmsize, sizeof(int));
+buf += sizeof(int);
 memcpy(buf, shmname, shmsize);
 buf += shmsize;
 
 nglyphs = eina_list_count(iter-glyphs);
-memcpy(buf, nglyphs, intsize);
-buf += intsize;
+memcpy(buf, nglyphs, sizeof(int));
+buf += sizeof(int);
 
 iter-fc-inuse -= eina_list_count(iter-glyphs);
 
 EINA_LIST_FREE(iter-glyphs, gl)
   {
- memcpy(buf, gl-index, intsize);
- buf += intsize;
- memcpy(buf, gl-offset, intsize);
- buf += intsize;
- memcpy(buf, gl-size, intsize);
- buf += intsize;
- memcpy(buf, gl-rows, intsize);
- buf += intsize;
- memcpy(buf, gl-width, intsize);
- buf += intsize;
- memcpy(buf, gl-pitch, intsize);
- buf += intsize;
- memcpy(buf, gl-num_grays, intsize);
- buf += intsize;
- memcpy(buf, gl-pixel_mode, intsize);
- buf += intsize;
+ memcpy(buf, gl-index, sizeof(int));
+ buf += sizeof(int);
+ memcpy(buf, gl-offset, sizeof(int));
+ buf += sizeof(int);
+ memcpy(buf, gl-size, sizeof(int));
+ buf += 

[EGIT] [core/efl] master 71/77: evas/cserve2: Reduce repacking and resizing of SHM

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=cd702b3785059f99d362045429280a6a9dbc64ff

commit cd702b3785059f99d362045429280a6a9dbc64ff
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Oct 10 17:15:21 2013 +0900

evas/cserve2: Reduce repacking and resizing of SHM

These operations have tons of side effects and it's a lot
easier to just avoid doing them. Now, repacking will always
need to happen as applications will add/delete strings and
items, but the less frequent, the better :)

Also, align most arrays  mempools to 32K instead of the
default page size (4K). This will also reduce resizes.
---
 src/bin/evas/evas_cserve2.h   |  2 +-
 src/bin/evas/evas_cserve2_cache.c |  8 
 src/bin/evas/evas_cserve2_fonts.c | 22 ++
 src/bin/evas/evas_cserve2_index.c | 15 ++-
 src/bin/evas/evas_cserve2_shm.c   | 14 +-
 5 files changed, 26 insertions(+), 35 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index a90dc07..219bb0d 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -307,7 +307,7 @@ size_t cserve2_shm_map_size_get(const Shm_Handle *shm);
 size_t cserve2_shm_size_get(const Shm_Handle *shm);
 void *cserve2_shm_map(Shm_Handle *shm);
 void cserve2_shm_unmap(Shm_Handle *shm);
-size_t cserve2_shm_size_normalize(size_t size);
+size_t cserve2_shm_size_normalize(size_t size, size_t align);
 
 void cserve2_command_run(Client *client, Message_Type type);
 
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index dc2939b..15ce2c3 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -171,6 +171,7 @@ static int max_font_usage = 10 * 4 * 1024; /* in kbytes */
 static int font_mem_usage = 0;
 
 #define MAX_PREEMPTIVE_LOAD_SIZE (320*320*4)
+#define ARRAY_REPACK_TRIGGER_PERCENT 25 // repack when array conains 25% holes
 
 #ifdef DEBUG_LOAD_TIME
 static int
@@ -354,7 +355,7 @@ _repack()
 
count = cserve2_shared_array_size_get(_file_data_array);
if ((count  0)  (_freed_file_entry_count  100 ||
-   ((_freed_file_entry_count * 100) / count = 10)))
+ ((_freed_file_entry_count * 100) / count = 
ARRAY_REPACK_TRIGGER_PERCENT)))
  {
 DBG(Repacking file data array: %s,
 cserve2_shared_array_name_get(_file_data_array));
@@ -379,7 +380,7 @@ skip_files:
 
count = cserve2_shared_array_size_get(_image_data_array);
if ((count  0)  (_freed_image_entry_count  100 ||
-   ((_freed_image_entry_count * 100) / count = 10)))
+ ((_freed_image_entry_count * 100) / count = 
ARRAY_REPACK_TRIGGER_PERCENT)))
  {
 DBG(Repacking image data array: %s,
 cserve2_shared_array_name_get(_image_data_array));
@@ -405,7 +406,7 @@ skip_images:
 
count = cserve2_shared_array_size_get(_font_data_array);
if ((count  0)  (_freed_font_entry_count  100 ||
-   ((_freed_font_entry_count * 100) / count = 10)))
+ ((_freed_font_entry_count * 100) / count = 
ARRAY_REPACK_TRIGGER_PERCENT)))
  {
 DBG(Repacking font data array: %s,
 cserve2_shared_array_name_get(_font_data_array));
@@ -1145,7 +1146,6 @@ _file_data_free(File_Data *fd)
 cserve2_shared_string_del(fd-key);
 cserve2_shared_string_del(fd-path);
 cserve2_shared_string_del(fd-loader_data);
-memset((char *) fd + sizeof(fd-id), 0, sizeof(*fd) - sizeof(fd-id));
  }
 }
 
diff --git a/src/bin/evas/evas_cserve2_fonts.c 
b/src/bin/evas/evas_cserve2_fonts.c
index b9da989..51b87fe 100644
--- a/src/bin/evas/evas_cserve2_fonts.c
+++ b/src/bin/evas/evas_cserve2_fonts.c
@@ -26,7 +26,7 @@
 #define _EVAS_FONT_SLANT_TAN 0.221694663
 
 #define CHECK_CHARS 
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
-#define MIN_GLYPHS 50
+#define MIN_GLYPHS 100 // 26*2 + a nice margin :)
 #define MAX_CACHE_SIZE 1 * 1024 * 1024 // 1MB
 
 #define EVAS_FONT_ROUND_26_6_TO_INT(x) \
@@ -406,24 +406,6 @@ end:
 }
 
 static unsigned int
-_font_slave_int_shm_prev_calculate(unsigned int size, unsigned int nglyphs)
-{
-   unsigned int average;
-   unsigned int newsize;
-
-   if (!nglyphs) return cserve2_shm_size_normalize(1);
-   average = size / nglyphs;
-
-   newsize = MIN_GLYPHS * average;
-   newsize = cserve2_shm_size_normalize(newsize);
-
-   if (newsize  MAX_CACHE_SIZE)
- return MAX_CACHE_SIZE;
-
-   return newsize;
-}
-
-static unsigned int
 _font_slave_int_shm_calculate(Font_Info *fi, unsigned int hint)
 {
const char *c;
@@ -441,7 +423,7 @@ _font_slave_int_shm_calculate(Font_Info *fi, unsigned int 
hint)
average = size / i; // average glyph size
size = MIN_GLYPHS * average;
 
-   size = cserve2_shm_size_normalize(size);
+   size = cserve2_shm_size_normalize(size, 0);
 
if (size  MAX_CACHE_SIZE)
  return MAX_CACHE_SIZE; // Assumes no glyph 

[EGIT] [core/efl] master 42/77: evas/cserve2: Fix NULL vs. empty string

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=74d399ab8188cbec655c5833f77977b49d4bcae5

commit 74d399ab8188cbec655c5833f77977b49d4bcae5
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Aug 27 09:56:50 2013 +0900

evas/cserve2: Fix NULL vs. empty string

Server side: Some strings were NULL, some other were empty.
Client side was looking for NULL, but the shared index contained
empty key.
---
 src/bin/evas/evas_cserve2_cache.c | 32 
 src/bin/evas/evas_cserve2_index.c | 10 +-
 src/bin/evas/evas_cserve2_main.c  |  7 ---
 3 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index bc89150..f351dd7 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -197,7 +197,6 @@ _entry_load_reused(Entry *e)
 #endif
 }
 
-
 static int
 _shm_object_id_cmp_cb(const void *data1, const void *data2)
 {
@@ -545,7 +544,7 @@ _font_loaded_send(Client *client, unsigned int rid)
 static void *
 _open_request_build(Entry *entry, int *bufsize)
 {
-   const char *loader_data;
+   const char *loader_data, *key, *path;
char *buf;
int size, pathlen, keylen, loaderlen;
Slave_Msg_Image_Open msg;
@@ -561,8 +560,12 @@ _open_request_build(Entry *entry, int *bufsize)
 return NULL;
  }
 
-   pathlen = strlen(cserve2_shared_string_get(fd-path)) + 1;
-   keylen = strlen(cserve2_shared_string_get(fd-key)) + 1;
+   path = cserve2_shared_string_get(fd-path);
+   key = cserve2_shared_string_get(fd-key);
+   if (!path) path = ;
+   if (!key) key = ;
+   pathlen = strlen(path) + 1;
+   keylen = strlen(key) + 1;
 
memset(msg, 0, sizeof(msg));
loader_data = cserve2_shared_string_get(fd-loader_data);
@@ -574,8 +577,8 @@ _open_request_build(Entry *entry, int *bufsize)
if (!buf) return NULL;
 
memcpy(buf, msg, sizeof(msg));
-   memcpy(buf + sizeof(msg), cserve2_shared_string_get(fd-path), pathlen);
-   memcpy(buf + sizeof(msg) + pathlen, cserve2_shared_string_get(fd-key), 
keylen);
+   memcpy(buf + sizeof(msg), path, pathlen);
+   memcpy(buf + sizeof(msg) + pathlen, key, keylen);
if (msg.has_loader_data)
  memcpy(buf + sizeof(msg) + pathlen + keylen, loader_data, loaderlen);
 
@@ -661,7 +664,7 @@ static void *
 _load_request_build(Image_Entry *ientry, int *bufsize)
 {
char *buf, *ptr;
-   const char *shmpath, *loader_data;
+   const char *shmpath, *loader_data, *path, *key;
int size;
int shmlen, filelen, keylen, loaderlen;
Slave_Msg_Image_Load msg;
@@ -686,8 +689,12 @@ _load_request_build(Image_Entry *ientry, int *bufsize)
 
shmpath = cserve2_shm_name_get(ientry-shm);
shmlen = strlen(shmpath) + 1;
-   filelen = strlen(cserve2_shared_string_get(fd-path)) + 1;
-   keylen = strlen(cserve2_shared_string_get(fd-key)) + 1;
+   path = cserve2_shared_string_get(fd-path);
+   key = cserve2_shared_string_get(fd-key);
+   if (!path) path = ;
+   if (!key) key = ;
+   filelen = strlen(path) + 1;
+   keylen = strlen(key) + 1;
loader_data = cserve2_shared_string_get(fd-loader_data);
if (loader_data)
  loaderlen = strlen(loader_data) + 1;
@@ -724,11 +731,12 @@ _load_request_build(Image_Entry *ientry, int *bufsize)
 
memcpy(ptr, shmpath, shmlen);
ptr += shmlen;
-   memcpy(ptr, cserve2_shared_string_get(fd-path), filelen);
+   memcpy(ptr, path, filelen);
ptr += filelen;
-   memcpy(ptr, cserve2_shared_string_get(fd-key), keylen);
+   memcpy(ptr, key, keylen);
ptr += keylen;
-   if (loaderlen  0) memcpy(ptr, cserve2_shared_string_get(fd-loader_data), 
loaderlen);
+   if (loaderlen  0)
+ memcpy(ptr, loader_data, loaderlen);
 
*bufsize = size;
 
diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
index 816a686..fdff6b5 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -921,7 +921,7 @@ cserve2_shared_string_add(const char *str)
char *data;
int len, id;
 
-   if (!str) return -1;
+   if (!str) return 0;
 
// Find in known strings
id = (int) (intptr_t) eina_hash_find(_string_entries, str);
@@ -945,7 +945,7 @@ new_entry:
if (!ie)
  {
 ERR(Could not store new string in shm);
-return -1;
+return 0;
  }
 
data = _string_mempool-ds-data + ie-offset;
@@ -957,7 +957,7 @@ new_entry:
 int
 cserve2_shared_string_ref(int id)
 {
-   if (!id) return 0;
+   if (id = 0) return 0;
return cserve2_shared_mempool_buffer_ref(_string_mempool, id);
 }
 
@@ -966,7 +966,7 @@ cserve2_shared_string_del(int id)
 {
const char *data;
 
-   if (!id) return;
+   if (id = 0) return;
if ((data = _shared_mempool_buffer_del(_string_mempool, id)) != NULL)
  {
 if (!eina_hash_del_by_key(_string_entries, data))
@@ -980,7 +980,7 @@ cserve2_shared_string_del(int id)
 const char *
 cserve2_shared_string_get(int id)
 {
-   if (!id) 

[EGIT] [core/efl] master 43/77: evas/cserve2: Repack strings index when too fragmented

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=877532e0009b864a95da045b9d123d27d70e3b9b

commit 877532e0009b864a95da045b9d123d27d70e3b9b
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Tue Aug 27 11:14:21 2013 +0900

evas/cserve2: Repack strings index when too fragmented
---
 src/bin/evas/evas_cserve2.h   |  1 +
 src/bin/evas/evas_cserve2_cache.c |  7 +--
 src/bin/evas/evas_cserve2_index.c | 38 ++
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index c0a703a..fda088f 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -388,5 +388,6 @@ int cserve2_shared_string_add(const char *str);
 int cserve2_shared_string_ref(int id);
 void cserve2_shared_string_del(int id);
 const char *cserve2_shared_string_get(int id);
+int cserve2_shared_strings_repack(Shared_Array_Repack_Skip_Cb skip, 
Eina_Compare_Cb cmp);
 
 #endif /* _EVAS_CSERVE2_H */
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index f351dd7..b71ce01 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -318,8 +318,8 @@ static Eina_Bool
 _repack_skip_cb(Shared_Array *sa EINA_UNUSED, const void *elem,
 void *user_data EINA_UNUSED)
 {
-   const File_Data *fd = elem;
-   return (!fd-refcount);
+   const Shm_Object *obj = elem;
+   return (!obj-refcount);
 }
 
 static void
@@ -411,6 +411,9 @@ skip_images:
  }
 skip_fonts:
 
+   if (cserve2_shared_strings_repack(_repack_skip_cb, _shm_object_id_cmp_cb) 
== 1)
+ updated = EINA_TRUE;
+
if (updated)
  {
 // TODO: Update strings table generation_id?
diff --git a/src/bin/evas/evas_cserve2_index.c 
b/src/bin/evas/evas_cserve2_index.c
index fdff6b5..2c4d9dc 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -896,6 +896,8 @@ cserve2_shared_mempool_generation_id_set(Shared_Mempool 
*sm, int generation_id)
 
 // Shared strings
 
+static int _shared_strings_unref_items = 0;
+
 const char *
 cserve2_shared_strings_table_name_get()
 {
@@ -957,7 +959,12 @@ new_entry:
 int
 cserve2_shared_string_ref(int id)
 {
+   Index_Entry *ie;
if (id = 0) return 0;
+   ie = _shared_index_entry_get_by_id(_string_mempool-index, id);
+   if (!ie) return 0;
+   if (!ie-refcount)
+ _string_mempool--;
return cserve2_shared_mempool_buffer_ref(_string_mempool, id);
 }
 
@@ -975,6 +982,7 @@ cserve2_shared_string_del(int id)
CRIT(Invalid free);
   }
  }
+   _shared_strings_unref_items++;
 }
 
 const char *
@@ -984,6 +992,35 @@ cserve2_shared_string_get(int id)
return cserve2_shared_mempool_buffer_get(_string_mempool, id);
 }
 
+int
+cserve2_shared_strings_repack(Shared_Array_Repack_Skip_Cb skip,
+  Eina_Compare_Cb cmp)
+{
+   int count;
+
+   if (!_string_mempool-index) return -1;
+   count = _string_mempool-index-lastid;
+   if (!count) return -1;
+   if (_shared_strings_unref_items * 100 / count = 25
+_shared_strings_unref_items  100)
+ {
+Shared_Array *sa;
+int genid;
+
+genid = _string_mempool-index-sa-header-generation_id + 1;
+sa = cserve2_shared_array_repack(_string_mempool-index-sa, genid,
+ skip, cmp, NULL);
+if (!sa) return -1;
+
+cserve2_shared_array_del(_string_mempool-index-sa);
+_string_mempool-index-sa = sa;
+_shared_strings_unref_items = 0;
+return 1;
+ }
+
+   return 0;
+}
+
 
 
 // Init/destroy
@@ -1002,6 +1039,7 @@ cserve2_shared_index_init(void)
 
 memcpy(faketag, ifaketag, sizeof(int));
 cserve2_shared_string_add(faketag);
+_shared_strings_unref_items = 0;
  }
_instances++;
 }

-- 




[EGIT] [core/efl] master 68/77: evas/cserve2: Fix refcount for glyphs glyph buffers

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6b6e33e262387380af4507e94a123a352ac6ee1c

commit 6b6e33e262387380af4507e94a123a352ac6ee1c
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Oct 7 15:59:13 2013 +0900

evas/cserve2: Fix refcount for glyphs  glyph buffers

Maybe a little overkill on the iterations (ref/unref),
but at least we can really track down which glyphs are
currently being used.
---
 src/lib/evas/common/evas_font_draw.c|  50 +++-
 src/lib/evas/cserve2/evas_cs2_client.c  | 198 +++-
 src/lib/evas/cserve2/evas_cs2_private.h |   2 +
 3 files changed, 194 insertions(+), 56 deletions(-)

diff --git a/src/lib/evas/common/evas_font_draw.c 
b/src/lib/evas/common/evas_font_draw.c
index 2b82035..02f681c 100644
--- a/src/lib/evas/common/evas_font_draw.c
+++ b/src/lib/evas/common/evas_font_draw.c
@@ -7,6 +7,10 @@
 
 #include evas_font_ot.h
 
+#ifdef EVAS_CSERVE2
+#include ../cserve2/evas_cs2_private.h
+#endif
+
 struct _Evas_Glyph
 {
RGBA_Font_Glyph *fg;
@@ -227,6 +231,19 @@ evas_common_font_rgba_draw(RGBA_Image *dst, 
RGBA_Draw_Context *dc, int x, int y,
 void
 evas_common_font_glyphs_ref(Evas_Glyph_Array *array)
 {
+#ifdef EVAS_CSERVE2
+   if (evas_cserve2_use_get()  !array-refcount)
+ {
+Eina_Iterator *iter;
+Evas_Glyph *glyph;
+
+iter = eina_inarray_iterator_new(array-array);
+EINA_ITERATOR_FOREACH(iter, glyph)
+  evas_cserve2_font_glyph_ref(glyph-fg-glyph_out, EINA_TRUE);
+eina_iterator_free(iter);
+ }
+#endif
+
array-refcount++;
 }
 
@@ -235,6 +252,19 @@ evas_common_font_glyphs_unref(Evas_Glyph_Array *array)
 {
if (--array-refcount) return;
 
+#ifdef EVAS_CSERVE2
+   if (evas_cserve2_use_get())
+ {
+Eina_Iterator *iter;
+Evas_Glyph *glyph;
+
+iter = eina_inarray_iterator_new(array-array);
+EINA_ITERATOR_FOREACH(iter, glyph)
+  evas_cserve2_font_glyph_ref(glyph-fg-glyph_out, EINA_FALSE);
+eina_iterator_free(iter);
+ }
+#endif
+
eina_inarray_free(array-array);
evas_common_font_int_unref(array-fi);
free(array);
@@ -274,6 +304,18 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
if (text_props-len  unit) unit = text_props-len;
if (text_props-glyphs  text_props-glyphs-refcount == 1)
  {
+#ifdef EVAS_CSERVE2
+if (evas_cserve2_use_get())
+  {
+ Eina_Iterator *iter;
+ Evas_Glyph *glyph;
+
+ iter = eina_inarray_iterator_new(text_props-glyphs-array);
+ EINA_ITERATOR_FOREACH(iter, glyph)
+   evas_cserve2_font_glyph_ref(glyph-fg-glyph_out, EINA_FALSE);
+ eina_iterator_free(iter);
+  }
+#endif
 glyphs = text_props-glyphs-array;
 glyphs-len = 0;
 reused_glyphs = EINA_TRUE;
@@ -318,6 +360,11 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
 glyph-idx = idx;
 glyph-coord.x = EVAS_FONT_WALK_PEN_X + EVAS_FONT_WALK_X_OFF + 
EVAS_FONT_WALK_X_BEAR;
 glyph-coord.y = EVAS_FONT_WALK_PEN_Y + EVAS_FONT_WALK_Y_OFF + 
EVAS_FONT_WALK_Y_BEAR;
+
+#ifdef EVAS_CSERVE2
+if (reused_glyphs  evas_cserve2_use_get())
+  evas_cserve2_font_glyph_ref(glyph-fg-glyph_out, EINA_TRUE);
+#endif
  }
EVAS_FONT_WALK_TEXT_END();
 
@@ -327,10 +374,11 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
 
 text_props-glyphs = malloc(sizeof(*text_props-glyphs));
 if (!text_props-glyphs) goto error;
-text_props-glyphs-refcount = 1;
+text_props-glyphs-refcount = 0;
 text_props-glyphs-array = glyphs;
 text_props-glyphs-fi = fi;
 fi-references++;
+evas_common_font_glyphs_ref(text_props-glyphs);
  }
 
/* check if there's a request queue in fi, if so ask cserve2 to render
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index a1ca4d3..64e335a 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -262,6 +262,7 @@ _request_resend(unsigned int rid)
Client_Request *cr;
Eina_Bool found = EINA_FALSE;
 
+   DBG(Re-sending %d requests..., eina_list_count(_requests));
EINA_LIST_FOREACH(_requests, l, cr)
  {
 if (rid)
@@ -337,9 +338,13 @@ _server_reconnect()
if (!_server_dispatch_until(SPECIAL_RID_INDEX_LIST))
  goto on_error;
 
-#warning TODO: Reopen all files, images, fonts...
+   /* NOTE: (TODO?)
+* Either we reopen all images  fonts now
+* Or we wait until new data is required again to request cserve2 to load
+* it for us. Not sure which approch is the best now.
+* So, for the moment, we'll just wait until the client needs new data.
+*/
 
-   DBG(Re-sending %d requests..., eina_list_count(_requests));
if (!_request_resend(0))
  goto on_error;
 
@@ -768,7 +773,7 @@ _image_loaded_cb(void 

[EGIT] [core/efl] master 55/77: evas/cserve2: Drop pre-emptive load of large images

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=85cd382725ab877a62d935d9fb37368d4b868f59

commit 85cd382725ab877a62d935d9fb37368d4b868f59
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Sep 5 17:44:10 2013 +0900

evas/cserve2: Drop pre-emptive load of large images

When the image is too large, let's not preload it unless
specifically requested by the application.

Value 320x320 is completely arbitrary.
---
 src/bin/evas/evas_cserve2.h   |  2 ++
 src/bin/evas/evas_cserve2_cache.c | 21 +
 src/bin/evas/evas_cserve2_requests.c  | 32 
 src/bin/evas/evas_cserve2_shm_debug.c |  7 ---
 4 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index fda088f..3b0ec15 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -331,6 +331,8 @@ void cserve2_request_cancel(Slave_Request *req, Client 
*client, Error_Type err);
 void cserve2_request_cancel_all(Slave_Request *req, Error_Type err);
 void cserve2_requests_init(void);
 void cserve2_requests_shutdown(void);
+void cserve2_request_dependents_drop(Slave_Request *req, Slave_Request_Type 
type);
+void cserve2_entry_request_drop(void *data, Slave_Request_Type type);
 
 void cserve2_font_init(void);
 void cserve2_font_shutdown(void);
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 83923d4..30f4cf5 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -154,6 +154,8 @@ static int unused_mem_usage = 0;
 static int max_font_usage = 10 * 4 * 1024; /* in kbytes */
 static int font_mem_usage = 0;
 
+#define MAX_PREEMPTIVE_LOAD_SIZE (320*320*4)
+
 #ifdef DEBUG_LOAD_TIME
 static int
 _timeval_sub(const struct timeval *tv2, const struct timeval *tv1)
@@ -603,8 +605,10 @@ static Msg_Opened *
 _open_request_response(Entry *entry, Slave_Msg_Image_Opened *resp, int *size)
 {
File_Data *fd;
+   Slave_Request *req;
 
_entry_load_finish(entry);
+   req = entry-request;
entry-request = NULL;
 
fd = _file_data_find(entry-id);
@@ -629,9 +633,26 @@ _open_request_response(Entry *entry, 
Slave_Msg_Image_Opened *resp, int *size)
  }
 
fd-valid = EINA_TRUE;
+
+   // If the image is too large, cancel pre-emptive load.
+   if (fd-w * fd-h * 4 = MAX_PREEMPTIVE_LOAD_SIZE)
+ {
+DBG(Not pre-loading this image );
+cserve2_request_dependents_drop(req, CSERVE2_REQ_IMAGE_SPEC_LOAD);
+ }
+
return _image_opened_msg_create(fd, size);
 }
 
+void
+cserve2_entry_request_drop(void *data, Slave_Request_Type type EINA_UNUSED)
+{
+   Entry *e = data;
+
+   if (!e) return;
+   e-request = NULL;
+}
+
 static void
 _request_failed(Entry *e, Error_Type type EINA_UNUSED)
 {
diff --git a/src/bin/evas/evas_cserve2_requests.c 
b/src/bin/evas/evas_cserve2_requests.c
index ab63db8..9a8eb2f 100644
--- a/src/bin/evas/evas_cserve2_requests.c
+++ b/src/bin/evas/evas_cserve2_requests.c
@@ -289,6 +289,38 @@ cserve2_request_cancel_all(Slave_Request *req, Error_Type 
err)
 }
 
 void
+cserve2_request_dependents_drop(Slave_Request *req, Slave_Request_Type type)
+{
+   Slave_Request *dep;
+   Eina_List *l, *l_next;
+
+   if (type != CSERVE2_REQ_IMAGE_SPEC_LOAD)
+ {
+CRIT(Only CSERVE2_REQ_IMAGE_SPEC_LOAD is supported.);
+return;
+ }
+
+   EINA_LIST_FOREACH_SAFE(req-dependents, l, l_next, dep)
+ {
+if (dep-type == type)
+  {
+ req-dependents = eina_list_remove_list(req-dependents, l);
+
+ if (dep-processing)
+   dep-cancelled = EINA_TRUE;
+ else
+   {
+  cserve2_entry_request_drop(dep-data, type);
+  requests[type].waiting = eina_inlist_remove(
+   requests[type].waiting, EINA_INLIST_GET(dep));
+  dep-funcs-msg_free(dep-msg, dep-data);
+  free(dep);
+   }
+  }
+ }
+}
+
+void
 cserve2_requests_init(void)
 {
DBG(Initializing requests.);
diff --git a/src/bin/evas/evas_cserve2_shm_debug.c 
b/src/bin/evas/evas_cserve2_shm_debug.c
index 49bae20..8828646 100644
--- a/src/bin/evas/evas_cserve2_shm_debug.c
+++ b/src/bin/evas/evas_cserve2_shm_debug.c
@@ -467,13 +467,14 @@ _images_all_print_full(void)
 printf(Refcount%d\n, id-refcount);
 printf(Sparse alpha%s\n
Unused: %s\n
-   Load requested: %s\n,
+   Load requested: %s\n
+   Valid:  %s\n,
id-alpha_sparse ? YES : NO,
id-unused ? YES : NO,
-   id-doload ? YES : NO);
+   id-doload ? YES : NO,
+   id-valid ? YES : NO);
 printf(Shm Path:   '%s'\n,
id-shm_id ? _shared_string_get(id-shm_id) : );
-
 printf(LoadOpts: width  

[EGIT] [core/efl] master 73/77: evas/cserve2: prevent unwanted remap of strings table

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=ffa27c70825161606a06cda017d2a82c50cfb34f

commit ffa27c70825161606a06cda017d2a82c50cfb34f
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Fri Oct 11 14:31:18 2013 +0900

evas/cserve2: prevent unwanted remap of strings table

In the client, string_get() can cause a remapping of the
strings index  mempool. This means that all pointers to
string data are invalid past that call.

Solution: add a safe_get() function that prevents remap
during search. It might prove faster also, but will
return NULL more often.
---
 src/lib/evas/cserve2/evas_cs2_client.c | 63 +++---
 1 file changed, 36 insertions(+), 27 deletions(-)

diff --git a/src/lib/evas/cserve2/evas_cs2_client.c 
b/src/lib/evas/cserve2/evas_cs2_client.c
index 6fc1a4a..df3573f 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -74,9 +74,11 @@ static Eina_Hash *_file_entries = NULL;
 // Shared index table
 static Index_Table _index;
 static const char *_shared_string_get(int id);
+static const char *_shared_string_safe_get(int id); // Do not allow remap 
during search
+static Eina_Bool _string_index_refresh(void);
 static int _server_index_list_set(Msg_Base *data, int size);
 static const File_Data *_shared_file_data_get_by_id(unsigned int id);
-static const Shm_Object *_shared_index_item_get_by_id(Shared_Index *si, int 
elemsize, unsigned int id);
+static const Shm_Object *_shared_index_item_get_by_id(Shared_Index *si, int 
elemsize, unsigned int id, Eina_Bool safe);
 static const File_Data *_shared_image_entry_file_data_find(Image_Entry *ie);
 static const Image_Data *_shared_image_entry_image_data_find(Image_Entry *ie);
 static const Font_Data *_shared_font_entry_data_find(Font_Entry *fe);
@@ -1788,6 +1790,7 @@ _font_entry_glyph_map_rebuild_check(Font_Entry *fe, 
Font_Hint_Flags hints)
int cnt = 0;
const char *idxpath = NULL, *datapath = NULL;
 
+   _string_index_refresh();
if (!fe-map)
  {
 const Font_Data *fd;
@@ -1795,8 +1798,8 @@ _font_entry_glyph_map_rebuild_check(Font_Entry *fe, 
Font_Hint_Flags hints)
 fd = _shared_font_entry_data_find(fe);
 if (!fd) return -1;
 
-idxpath = _shared_string_get(fd-glyph_index_shm);
-datapath = _shared_string_get(fd-mempool_shm);
+idxpath = _shared_string_safe_get(fd-glyph_index_shm);
+datapath = _shared_string_safe_get(fd-mempool_shm);
 if (!idxpath || !datapath) return -1;
 
 fe-map =_glyph_map_open(fe, idxpath, datapath);
@@ -2527,7 +2530,7 @@ _server_index_list_set(Msg_Base *data, int size)
 
 // FIXME: (almost) copy  paste from evas_cserve2_cache.c
 static const char *
-_shared_string_get(int id)
+_shared_string_internal_get(int id, Eina_Bool safe)
 {
Index_Entry *ie;
 
@@ -2538,19 +2541,20 @@ _shared_string_get(int id)
  }
 
ie = (Index_Entry *)
- _shared_index_item_get_by_id(_index.strings_index, sizeof(*ie), id);
+ _shared_index_item_get_by_id(_index.strings_index, sizeof(*ie), id, 
safe);
if (!ie) return NULL;
if (ie-offset  0) return NULL;
if (!ie-refcount) return NULL;
if (ie-offset + ie-length  _index.strings_entries.size)
  {
+if (safe) return NULL;
 if (eina_file_refresh(_index.strings_entries.f)
 || (_index.strings_entries.size != (int) 
eina_file_size_get(_index.strings_entries.f)))
   {
  DBG(String entries size has changed from %d to %d,
  _index.strings_entries.size, (int) 
eina_file_size_get(_index.strings_entries.f));
  if (_string_index_refresh())
-   return _shared_string_get(id);
+   return _shared_string_internal_get(id, EINA_FALSE);
   }
 return NULL;
  }
@@ -2558,6 +2562,18 @@ _shared_string_get(int id)
return _index.strings_entries.data + ie-offset;
 }
 
+static const char *
+_shared_string_safe_get(int id)
+{
+   return _shared_string_internal_get(id, EINA_TRUE);
+}
+
+static const char *
+_shared_string_get(int id)
+{
+   return _shared_string_internal_get(id, EINA_FALSE);
+}
+
 #define SHARED_INDEX_CHECK(si, typ) \
do { if (!_shared_index_remap_check((si), sizeof(typ))) { \
CRIT(Failed to remap index); return NULL; } } while (0)
@@ -2597,6 +2613,7 @@ _shared_image_entry_file_data_find(Image_Entry *ie)
  return fdata;
 
// Scan shared index
+   _string_index_refresh();
for (k = _index.files.last_entry_in_hash;
 k  _index.files.count  k  _index.files.header-emptyidx; k++)
  {
@@ -2609,8 +2626,8 @@ _shared_image_entry_file_data_find(Image_Entry *ie)
 if (!fd-id) break;
 if (!fd-refcount) continue;
 
-key = _shared_string_get(fd-key);
-file = _shared_string_get(fd-path);
+key = _shared_string_safe_get(fd-key);
+file = 

[EGIT] [core/efl] master 70/77: evas/cserve2: Fix font reloading after cserve2 restart.

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c8e6f9e5f9d20d67b49a0355b1b42b1ba8689291

commit c8e6f9e5f9d20d67b49a0355b1b42b1ba8689291
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Thu Oct 10 09:26:42 2013 +0900

evas/cserve2: Fix font reloading after cserve2 restart.

Well it LOOKS like it's working properly.
Clients can safely keep running after cserve2 crashed and
restarted.
---
 src/bin/evas/evas_cserve2_cache.c  |  25 ++-
 src/lib/evas/common/evas_font_draw.c   |  24 ++-
 src/lib/evas/common/evas_font_main.c   |   3 +
 src/lib/evas/cserve2/evas_cs2_client.c | 316 ++---
 src/lib/evas/cserve2/evas_cs2_utils.c  |   2 +
 5 files changed, 238 insertions(+), 132 deletions(-)

diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 5ec597b..dc2939b 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -1865,17 +1865,20 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int 
*resp_size)
 {
Msg_Font_Glyphs_Loaded *msg;
unsigned int size;
-   const char *shmname;
-   unsigned int shmname_size;
+   const char *shmname, *idxname;
+   unsigned int shmname_size, idxname_size;
unsigned int k;
char *response, *buf;
 
shmname = cserve2_shared_mempool_name_get(req-fe-mempool);
shmname_size = strlen(shmname) + 1;
 
+   idxname = cserve2_shared_array_name_get(req-fe-glyph_datas);
+   idxname_size = strlen(idxname) + 1;
+
size = sizeof(Msg_Font_Glyphs_Loaded);
-   size += sizeof(int) * 2;
-   size += shmname_size;
+   size += sizeof(int) * 3;
+   size += shmname_size + idxname_size;
size += req-nanswer * 10 * sizeof(int);
 
response = malloc(size);
@@ -1888,6 +1891,10 @@ _glyphs_loaded_msg_create(Glyphs_Request *req, int 
*resp_size)
buf += sizeof(int);
memcpy(buf, shmname, shmname_size);
buf += shmname_size;
+   memcpy(buf, idxname_size, sizeof(int));
+   buf += sizeof(int);
+   memcpy(buf, idxname, idxname_size);
+   buf += idxname_size;
memcpy(buf, req-nanswer, sizeof(int));
buf += sizeof(int);
 
@@ -2123,15 +2130,7 @@ _glyphs_load_request_response(Glyphs_Request *req,
 
DBG(Font memory usage [begin]: %d / %d, font_mem_usage, max_font_usage);
 
-   if (!mempool)
- {
-mempool = cserve2_shared_mempool_new(GLYPH_DATA_ARRAY_TAG,
- _generation_id, 0);
-font_mem_usage += cserve2_shared_mempool_size_get(mempool);
- }
-   else
- cserve2_shared_mempool_generation_id_set(mempool, _generation_id);
-
+   cserve2_shared_mempool_generation_id_set(mempool, _generation_id);
if (!fe-glyph_datas)
  {
 fe-glyph_datas = cserve2_shared_array_new(GLYPH_INDEX_ARRAY_TAG,
diff --git a/src/lib/evas/common/evas_font_draw.c 
b/src/lib/evas/common/evas_font_draw.c
index 02f681c..3a999ff 100644
--- a/src/lib/evas/common/evas_font_draw.c
+++ b/src/lib/evas/common/evas_font_draw.c
@@ -346,12 +346,16 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
 
 fg = evas_common_font_int_cache_glyph_get(fi, idx);
 if (!fg) continue;
-if (!fg-glyph_out)
-  if (!evas_common_font_int_cache_glyph_render(fg))
-{
-   fg = NULL;
-   goto error;
-}
+if (!evas_common_font_int_cache_glyph_render(fg))
+  {
+ fg = NULL;
+ goto error;
+  }
+
+#ifdef EVAS_CSERVE2
+if (evas_cserve2_use_get())
+  evas_cserve2_font_glyph_ref(fg-glyph_out, EINA_TRUE);
+#endif

glyph = eina_inarray_grow(glyphs, 1);
if (!glyph) goto error;
@@ -360,11 +364,6 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
 glyph-idx = idx;
 glyph-coord.x = EVAS_FONT_WALK_PEN_X + EVAS_FONT_WALK_X_OFF + 
EVAS_FONT_WALK_X_BEAR;
 glyph-coord.y = EVAS_FONT_WALK_PEN_Y + EVAS_FONT_WALK_Y_OFF + 
EVAS_FONT_WALK_Y_BEAR;
-
-#ifdef EVAS_CSERVE2
-if (reused_glyphs  evas_cserve2_use_get())
-  evas_cserve2_font_glyph_ref(glyph-fg-glyph_out, EINA_TRUE);
-#endif
  }
EVAS_FONT_WALK_TEXT_END();
 
@@ -374,11 +373,10 @@ evas_common_font_draw_prepare(Evas_Text_Props *text_props)
 
 text_props-glyphs = malloc(sizeof(*text_props-glyphs));
 if (!text_props-glyphs) goto error;
-text_props-glyphs-refcount = 0;
+text_props-glyphs-refcount = 1;
 text_props-glyphs-array = glyphs;
 text_props-glyphs-fi = fi;
 fi-references++;
-evas_common_font_glyphs_ref(text_props-glyphs);
  }
 
/* check if there's a request queue in fi, if so ask cserve2 to render
diff --git a/src/lib/evas/common/evas_font_main.c 
b/src/lib/evas/common/evas_font_main.c
index 769114a..8bc9e68 100644
--- a/src/lib/evas/common/evas_font_main.c
+++ b/src/lib/evas/common/evas_font_main.c
@@ -560,6 +560,9 @@ 

[EGIT] [core/efl] master 58/77: evas/cserve2: Use scalecache with cserve2

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=1e82480c9a074163ec6788a8a60ead403f7b0658

commit 1e82480c9a074163ec6788a8a60ead403f7b0658
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Sep 23 17:51:06 2013 +0900

evas/cserve2: Use scalecache with cserve2

Let's reuse the logic from scalecache and call cserve2
functions when the scalecache should be used.
So, now, cserve2 server will not scale any image... This is
too computationally intensive for the server's main thread.

This is not optimal but makes a hell of a lot more sense for
the moment. (since cserve2 manages the SHM segments)
---
 src/bin/evas/evas_cserve2.h|  2 +-
 src/bin/evas/evas_cserve2_cache.c  | 24 --
 src/bin/evas/evas_cserve2_scale.c  |  6 +--
 src/lib/evas/cache2/evas_cache2.c  |  3 +-
 src/lib/evas/canvas/evas_object_image.c| 56 --
 src/lib/evas/common/evas_image_scalecache.c| 20 
 src/lib/evas/cserve2/evas_cs2.h|  4 ++
 .../evas/engines/software_generic/evas_engine.c| 54 -
 8 files changed, 68 insertions(+), 101 deletions(-)

diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index b1b6d68..2a3a40e 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -320,7 +320,7 @@ void cserve2_cache_client_del(Client *client);
 int cserve2_cache_file_open(Client *client, unsigned int client_file_id, const 
char *path, const char *key, unsigned int rid, Evas_Image_Load_Opts *lo);
 void cserve2_cache_file_close(Client *client, unsigned int client_file_id);
 int cserve2_cache_image_entry_create(Client *client, int rid, unsigned int 
client_file_id, unsigned int image_id, Evas_Image_Load_Opts *opts);
-void cserve2_rgba_image_scale_do(void *src_data, void *dst_data, int src_x, 
int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, 
int alpha, int smooth);
+void cserve2_rgba_image_scale_do(void *src_data, int src_full_w, int 
src_full_h, void *dst_data, int src_x, int src_y, int src_w, int src_h, int 
dst_x, int dst_y, int dst_w, int dst_h, int alpha, int smooth);
 void cserve2_cache_image_load(Client *client, unsigned int client_image_id, 
unsigned int rid);
 void cserve2_cache_image_preload(Client *client, unsigned int client_image_id, 
unsigned int rid);
 void cserve2_cache_image_unload(Client *client, unsigned int client_image_id);
diff --git a/src/bin/evas/evas_cserve2_cache.c 
b/src/bin/evas/evas_cserve2_cache.c
index 5361c13..e86643d 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -506,6 +506,8 @@ _image_loaded_msg_create(Image_Entry *ientry, Image_Data 
*idata, int *size)
msg-shm.mmap_size = cserve2_shm_map_size_get(ientry-shm);
msg-shm.image_size = cserve2_shm_size_get(ientry-shm);
msg-alpha_sparse = idata-alpha_sparse;
+   msg-image.w = idata-w;
+   msg-image.h = idata-h;
 
if (idata-shm_id)
  {
@@ -805,7 +807,9 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *idata, 
Image_Entry *original)
char *scale_map, *orig_map;
void *src_data, *dst_data;
File_Data *fd;
+   Image_Data *orig_idata;
 
+#warning FIXME Remove this call, add alpha flag to Image_Data
fd = _file_data_find(idata-file_id);
if (!fd)
  {
@@ -814,6 +818,13 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *idata, 
Image_Entry *original)
 return -1;
  }
 
+   orig_idata = _image_data_find(original-base.id);
+   if (!orig_idata)
+ {
+ERR(Could not find image %u, original-base.id);
+return -1;
+ }
+
scale_map = cserve2_shm_map(scale_shm);
if (scale_map == MAP_FAILED)
  {
@@ -833,14 +844,16 @@ _scaling_do(Shm_Handle *scale_shm, Image_Data *idata, 
Image_Entry *original)
src_data = orig_map + cserve2_shm_map_offset_get(original-shm);
dst_data = scale_map + cserve2_shm_map_offset_get(scale_shm);
 
-   DBG(Scaling image ([%d,%d:%dx%d] -- [%d,%d:%dx%d]),
+   DBG(Scaling image ([%dx%d]:[%d,%d:%dx%d] -- [%d,%d:%dx%d]),
+   orig_idata-w, orig_idata-h,
idata-opts.scale_load.src_x, idata-opts.scale_load.src_y,
idata-opts.scale_load.src_w, idata-opts.scale_load.src_h,
0, 0,
idata-opts.scale_load.dst_w, idata-opts.scale_load.dst_h);
 
cserve2_rgba_image_scale_do(
-src_data, dst_data,
+src_data, orig_idata-w, orig_idata-h,
+dst_data,
 idata-opts.scale_load.src_x, idata-opts.scale_load.src_y,
 idata-opts.scale_load.src_w, idata-opts.scale_load.src_h,
 0, 0,
@@ -875,6 +888,8 @@ _scaling_prepare_and_do(Image_Entry *ientry, Image_Data 
*idata)
cserve2_shared_string_del(idata-shm_id);
ientry-shm = scale_shm;
idata-shm_id = 0;
+   idata-w = idata-opts.scale_load.dst_w;
+   idata-h = idata-opts.scale_load.dst_h;
 
   

[EGIT] [core/efl] master 50/77: evas/cserve2: Fallback to normal cache for mmap

2013-10-28 Thread Jean-Philippe Andre
jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=d76e869a5908a56c04bb8ad9927ef45b1cf70faa

commit d76e869a5908a56c04bb8ad9927ef45b1cf70faa
Author: Jean-Philippe Andre jp.an...@samsung.com
Date:   Mon Sep 2 18:53:18 2013 +0900

evas/cserve2: Fallback to normal cache for mmap

cserve2 can't handle virtual files (mmap-only), by design.
Proper support can be added later on, but for now we might want
to just fallback to the normal cache functions.

Fixes photocam test
---
 src/lib/evas/cache2/evas_cache2.c   |  7 +++
 src/lib/evas/cache2/evas_cache2.h   |  1 +
 src/lib/evas/canvas/evas_render.c   |  2 +-
 src/modules/evas/engines/software_generic/evas_engine.c | 14 +++---
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/lib/evas/cache2/evas_cache2.c 
b/src/lib/evas/cache2/evas_cache2.c
index 1a033b5..4b51b32 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -549,6 +549,13 @@ evas_cache2_shutdown(Evas_Cache2 *cache)
free(cache);
 }
 
+EAPI Eina_Bool
+evas_cache2_image_cached(Image_Entry *ie)
+{
+   if (!ie) return EINA_FALSE;
+   return (ie-cache2 != NULL);
+}
+
 EAPI void
 evas_cache2_image_cache_key_create(char *hkey, const char *path, size_t 
pathlen,
const char *key, size_t keylen,
diff --git a/src/lib/evas/cache2/evas_cache2.h 
b/src/lib/evas/cache2/evas_cache2.h
index 6f8e588..7cd9c79 100644
--- a/src/lib/evas/cache2/evas_cache2.h
+++ b/src/lib/evas/cache2/evas_cache2.h
@@ -76,6 +76,7 @@ EAPI Image_Entry * evas_cache2_image_size_set(Image_Entry 
*im, unsigned int w, u
 EAPI Image_Entry * evas_cache2_image_dirty(Image_Entry *im, unsigned int x, 
unsigned int y, unsigned int w, unsigned int h);
 EAPI Image_Entry * evas_cache2_image_empty(Evas_Cache2 *cache);
 EAPI void evas_cache2_image_surface_alloc(Image_Entry *ie, int w, int h);
+EAPI Eina_Bool evas_cache2_image_cached(Image_Entry *ie);
 
 EAPI int evas_cache2_flush(Evas_Cache2 *cache);
 EAPI void evas_cache2_limit_set(Evas_Cache2 *cache, int limit);
diff --git a/src/lib/evas/canvas/evas_render.c 
b/src/lib/evas/canvas/evas_render.c
index b08e006..2ceca4d 100644
--- a/src/lib/evas/canvas/evas_render.c
+++ b/src/lib/evas/canvas/evas_render.c
@@ -1571,7 +1571,7 @@ static Eina_Bool
 _drop_image_cache_ref(const void *container EINA_UNUSED, void *data, void 
*fdata EINA_UNUSED)
 {
 #ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
+   if (evas_cserve2_use_get()  evas_cache2_image_cached(data))
  evas_cache2_image_close((Image_Entry *)data);
else
 #endif
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c 
b/src/modules/evas/engines/software_generic/evas_engine.c
index 5163a56..8b34414 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -962,7 +962,7 @@ eng_image_mmap(void *data EINA_UNUSED, Eina_File *f, const 
char *key, int *error
*error = EVAS_LOAD_ERROR_NONE;
 #ifdef EVAS_CSERVE2
// FIXME: Need to pass fd to make that useful, so just get the filename for 
now.
-   if (evas_cserve2_use_get())
+   if (evas_cserve2_use_get()  !eina_file_virtual(f))
  {
 Image_Entry *ie;
 ie = evas_cache2_image_open(evas_common_image_cache2_get(),
@@ -1006,7 +1006,7 @@ static void
 eng_image_free(void *data EINA_UNUSED, void *image)
 {
 #ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
+   if (evas_cserve2_use_get()  evas_cache2_image_cached(image))
  {
 evas_cache2_image_close(image);
 return;
@@ -1031,7 +1031,7 @@ eng_image_size_set(void *data EINA_UNUSED, void *image, 
int w, int h)
Image_Entry *im = image;
if (!im) return NULL;
 #ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
+   if (evas_cserve2_use_get()  evas_cache2_image_cached(im))
  return evas_cache2_image_size_set(im, w, h);
 #endif
return evas_cache_image_size_set(im, w, h);
@@ -1043,7 +1043,7 @@ eng_image_dirty_region(void *data EINA_UNUSED, void 
*image, int x, int y, int w,
Image_Entry *im = image;
if (!im) return NULL;
 #ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
+   if (evas_cserve2_use_get()  evas_cache2_image_cached(im))
  return evas_cache2_image_dirty(im, x, y, w, h);
 #endif
return evas_cache_image_dirty(im, x, y, w, h);
@@ -1063,7 +1063,7 @@ eng_image_data_get(void *data EINA_UNUSED, void *image, 
int to_write, DATA32 **i
im = image;
 
 #ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
+   if (evas_cserve2_use_get()  evas_cache2_image_cached(im-cache_entry))
  {
 error = evas_cache2_image_load_data(im-cache_entry);
 if (err) *err = error;
@@ -1157,7 +1157,7 @@ eng_image_data_preload_request(void *data EINA_UNUSED, 
void *image, const Eo *ta
if (!im) return;
 
 #ifdef EVAS_CSERVE2
-   if (evas_cserve2_use_get())
+   if 

Re: [E-devel] [RFC] configure options for maintainers

2013-10-28 Thread The Rasterman
On Mon, 28 Oct 2013 17:31:44 +0900 Cedric BAIL cedric.b...@free.fr said:

 On Mon, Oct 28, 2013 at 4:27 PM, Carsten Haitzler ras...@rasterman.com
 wrote:
  On Mon, 28 Oct 2013 14:45:38 +0900 Cedric BAIL cedric.b...@free.fr said:
  On Mon, Oct 28, 2013 at 11:49 AM, Carsten Haitzler ras...@rasterman.com
  wrote:
   On Sat, 12 Oct 2013 11:43:33 +0900 Jérôme Pinot ngc...@gmail.com said:
  
   great.. but how do you EXTRACT this info then from the lib? :) it's a
   lib.. it can't execute on its own... and printfing such strings on every
   fn call is just anti-social :)
 
  I would have said :
   #define EFL_BUILD_DISTRO MyDistro
   #define EFL_BUILD_VENDOR Main Tainer f...@bar.org
   #define EFL_BUILD_VERSION 42
 
  ummm... ok - and so then we have tyo rely on application executables
  specifically finding these and printfing them or stuffing them into dialogs?
 
 We could put those variable also in the pkg-config, but I was inclined
 on using that in our .e-crashdump.txt infra. So plain C code there.

that's the point i was hinting at.. if its just some strings inside the libs...
then we need special stuff to extract it. if we add it to pc files or otherwise
make it easy to find... then thats useful.

   Hi,
  
   During the Enlightenment French League^W^W dinner, we had this idea of
   having a configure option for the EFL to setup a string identifying the
   compiler/maintainer/distribution of the build. Several projects use this
   kind of string, for instance TexLive, LibreOffice or POV-Ray. It can be
   use to find quickly the maintainer, to generate automatic bug reports
   and most important, blame someone else (not you, no, really).
  
   There are several way to accomplish this during configuration:
  
   POV-Ray uses the COMPILED_BY=Main Tainer f...@bar.org environment
   variable
  
   TexLive uses --with-banner-add=Tex Live 2013/MyDistro Main Tainer
   f...@bar.org
  
   LibreOffice uses several options:
   --with-distro=MyDistro
   --with-vendor=Main Tainer f...@bar.org
   --with-build-version=42
  
   It seems to me that the LibreOffice options are better.
  
   What do you think about this?
  
   --
   Jérôme Pinot
   http://ngc891.blogdns.net/
  
  
   --
   - Codito, ergo sum - I code, therefore I am --
   The Rasterman (Carsten Haitzler)ras...@rasterman.com
  
  
   --
   October Webinars: Code for Performance
   Free Intel webinars can help you accelerate application performance.
   Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
   from the latest Intel processors and coprocessors. See abstracts and
   register 
   http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
   ___ enlightenment-devel
   mailing list enlightenment-devel@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
 
 
 
  --
  Cedric BAIL
 
  --
  October Webinars: Code for Performance
  Free Intel webinars can help you accelerate application performance.
  Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
  from the latest Intel processors and coprocessors. See abstracts and
  register 
  http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
  ___ enlightenment-devel
  mailing list enlightenment-devel@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
 
 
  --
  - Codito, ergo sum - I code, therefore I am --
  The Rasterman (Carsten Haitzler)ras...@rasterman.com
 
 
  --
  October Webinars: Code for Performance
  Free Intel webinars can help you accelerate application performance.
  Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
  from the latest Intel processors and coprocessors. See abstracts and
  register 
  http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
  ___ enlightenment-devel mailing
  list enlightenment-devel@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
 
 
 
 -- 
 Cedric BAIL
 
 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 

[EGIT] [apps/terminology] master 01/03: terminology: inline the most common case for a small 2% speed up.

2013-10-28 Thread Cedric Bail
cedric pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=c1b516f2318e6041ab1174de9e4a718de2e74eb8

commit c1b516f2318e6041ab1174de9e4a718de2e74eb8
Author: Cedric Bail cedric.b...@samsung.com
Date:   Mon Oct 28 18:54:30 2013 +0900

terminology: inline the most common case for a small 2% speed up.
---
 src/bin/termptydbl.c | 12 +---
 src/bin/termptydbl.h | 27 +--
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/bin/termptydbl.c b/src/bin/termptydbl.c
index 34151d0..b4c442d 100644
--- a/src/bin/termptydbl.c
+++ b/src/bin/termptydbl.c
@@ -5,21 +5,12 @@
 #include termptydbl.h
 
 Eina_Bool
-_termpty_is_dblwidth_get(Termpty *ty, int g)
+_termpty_is_dblwidth_slow_get(Termpty *ty, int g)
 {
-#if defined(SUPPORT_DBLWIDTH)
// check for east asian full-width (F), half-width (H), wide (W),
// narrow (Na) or ambiguous (A) codepoints
// ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt
 
-   // optimize for latin1 non-ambiguous
-   if (g = 0xa0)
- return EINA_FALSE;
-   // (F)
-   if ((g == 0x3000) ||
-   ((g = 0xff01)  (g = 0xff60)) ||
-   ((g = 0xffe0)  (g = 0xffe6)))
- return EINA_TRUE;
// (W)
if (
// 1XXX
@@ -273,6 +264,5 @@ _termpty_is_dblwidth_get(Termpty *ty, int g)
  }

// Na, H - not checked
-#endif
return EINA_FALSE;
 }
diff --git a/src/bin/termptydbl.h b/src/bin/termptydbl.h
index 04e3e5f..da9ca5d 100644
--- a/src/bin/termptydbl.h
+++ b/src/bin/termptydbl.h
@@ -1,2 +1,25 @@
-Eina_Bool _termpty_is_dblwidth_get(Termpty *ty, int g);
-
+Eina_Bool _termpty_is_dblwidth_slow_get(Termpty *ty, int g);
+
+static inline Eina_Bool
+_termpty_is_dblwidth_get(Termpty *ty, int g)
+{
+#if defined(SUPPORT_DBLWIDTH)
+   // check for east asian full-width (F), half-width (H), wide (W),
+   // narrow (Na) or ambiguous (A) codepoints
+   // ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt
+
+   // optimize for latin1 non-ambiguous
+   if (g = 0xa0)
+ return EINA_FALSE;
+   // (F)
+   if ((g == 0x3000) ||
+   ((g = 0xff01)  (g = 0xff60)) ||
+   ((g = 0xffe0)  (g = 0xffe6)))
+ return EINA_TRUE;
+
+   return _termpty_is_dblwidth_slow_get(ty, g);
+#else
+   return EINA_FALSE;
+#endif
+}
+

-- 




[EGIT] [apps/terminology] master 02/03: terminology: let the compiler inline more agressively the common case for a 1% win.

2013-10-28 Thread Cedric Bail
cedric pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=433b18b2119daa0318a8b4d3899ca6034e8fcebe

commit 433b18b2119daa0318a8b4d3899ca6034e8fcebe
Author: Cedric Bail cedric.b...@samsung.com
Date:   Mon Oct 28 18:55:19 2013 +0900

terminology: let the compiler inline more agressively the common case for a 
1% win.
---
 src/bin/termpty.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index fe7b4f9..78035d7 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1429,15 +1429,12 @@ termpty_block_chid_get(Termpty *ty, const char *chid)
return tb;
 }
 
-
-
-static inline void
-_handle_block_codepoint_overwrite(Termpty *ty, int oldc, int newc)
+static void
+_handle_block_codepoint_overwrite_heavy(Termpty *ty, int oldc, int newc)
 {
Termblock *tb;
int ido = 0, idn = 0;
 
-   if (!((oldc | newc)  0x8000)) return;
if (oldc  0x8000) ido = (oldc  18)  0x1fff;
if (newc  0x8000) idn = (newc  18)  0x1fff;
if (((oldc  0x8000)  (newc  0x8000))  (idn == ido)) return;
@@ -1463,6 +1460,14 @@ _handle_block_codepoint_overwrite(Termpty *ty, int oldc, 
int newc)
  }
 }
 
+/* Try to trick the compiler into inlining the first test */
+static inline void
+_handle_block_codepoint_overwrite(Termpty *ty, int oldc, int newc)
+{
+   if (!((oldc | newc)  0x8000)) return;
+   _handle_block_codepoint_overwrite_heavy(ty, oldc, newc);
+}
+
 void
 termpty_cell_copy(Termpty *ty, Termcell *src, Termcell *dst, int n)
 {
@@ -1515,13 +1520,13 @@ termpty_cell_fill(Termpty *ty, Termcell *src, Termcell 
*dst, int n)
 void
 termpty_cell_codepoint_att_fill(Termpty *ty, int codepoint, Termatt att, 
Termcell *dst, int n)
 {
+   Termcell local = { codepoint, att };
int i;

for (i = 0; i  n; i++)
  {
 _handle_block_codepoint_overwrite(ty, dst[i].codepoint, codepoint);
-dst[i].codepoint = codepoint;
-dst[i].att = att;
+dst[i] = local;
  }
 }
 

-- 




[EGIT] [apps/terminology] master 03/03: terminology: factorise some code and help the compiler figure out which branch is the most likely one.

2013-10-28 Thread Cedric Bail
cedric pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=964e1f39a972052ce54f1d4fc0e01aad40aa6d44

commit 964e1f39a972052ce54f1d4fc0e01aad40aa6d44
Author: Cedric Bail cedric.b...@samsung.com
Date:   Mon Oct 28 18:55:53 2013 +0900

terminology: factorise some code and help the compiler figure out which 
branch is the most likely one.
---
 src/bin/termptyops.c | 38 +-
 1 file changed, 13 insertions(+), 25 deletions(-)

diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index 2547038..91bb781 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -204,7 +204,7 @@ _termpty_text_append(Termpty *ty, const Eina_Unicode 
*codepoints, int len)
 (cells[ty-state.cx]), 1);
 #if defined(SUPPORT_DBLWIDTH)
 cells[ty-state.cx].att.dblwidth = _termpty_is_dblwidth_get(ty, g);
-if ((cells[ty-state.cx].att.dblwidth)  (ty-state.cx  (ty-w - 1)))
+if (EINA_UNLIKELY((cells[ty-state.cx].att.dblwidth)  (ty-state.cx 
 (ty-w - 1
   {
  TERMPTY_FMTCLR(cells[ty-state.cx].att);
  termpty_cell_codepoint_att_fill(ty, 0, cells[ty-state.cx].att,
@@ -213,44 +213,32 @@ _termpty_text_append(Termpty *ty, const Eina_Unicode 
*codepoints, int len)
 #endif
 if (ty-state.wrap)
   {
+ unsigned char offset = 1;
+
  ty-state.wrapnext = 0;
 #if defined(SUPPORT_DBLWIDTH)
- if (cells[ty-state.cx].att.dblwidth)
-   {
-  if (ty-state.cx = (ty-w - 2)) ty-state.wrapnext = 1;
-  else ty-state.cx += 2;
-   }
- else
-   {
-  if (ty-state.cx = (ty-w - 1)) ty-state.wrapnext = 1;
-  else ty-state.cx++;
-   }
-#else
- if (ty-state.cx = (ty-w - 1)) ty-state.wrapnext = 1;
- else ty-state.cx++;
+if (EINA_UNLIKELY(cells[ty-state.cx].att.dblwidth))
+   offset = 2;
 #endif
+ if (EINA_UNLIKELY(ty-state.cx = (ty-w - offset))) 
ty-state.wrapnext = 1;
+ else ty-state.cx += offset;
   }
 else
   {
+ unsigned char offset = 1;
+
  ty-state.wrapnext = 0;
  ty-state.cx++;
  if (ty-state.cx = (ty-w - 1)) return;
 #if defined(SUPPORT_DBLWIDTH)
- if (cells[ty-state.cx].att.dblwidth)
+ if (EINA_UNLIKELY(cells[ty-state.cx].att.dblwidth))
{
   ty-state.cx++;
-  if (ty-state.cx = (ty-w - 1))
-ty-state.cx = ty-w - 2;
-   }
- else
-   {
-  if (ty-state.cx = ty-w)
-ty-state.cx = ty-w - 1;
+  offset = 2;
}
-#else
- if (ty-state.cx = ty-w)
-   ty-state.cx = ty-w - 1;
 #endif
+ if (ty-state.cx = (ty-w - (offset - 1)))
+   ty-state.cx = ty-w - offset;
   }
  }
 }

-- 




[EGIT] [core/efl] master 04/04: evas: fix possible memory leak in the ellipsis code.

2013-10-28 Thread Cedric Bail
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8b01f7b06d0cae28a86d9a749a1dcaea4a33ef24

commit 8b01f7b06d0cae28a86d9a749a1dcaea4a33ef24
Author: Cedric Bail cedric.b...@samsung.com
Date:   Mon Oct 28 18:44:26 2013 +0900

evas: fix possible memory leak in the ellipsis code.
---
 src/lib/evas/canvas/evas_object_text.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/lib/evas/canvas/evas_object_text.c 
b/src/lib/evas/canvas/evas_object_text.c
index 1738a12..c479ddc 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -201,7 +201,13 @@ _evas_object_text_items_clean(Evas_Object_Protected_Data 
*obj, Evas_Object_Text
  }
else
  {
+/* It is not guaranteed that the ellipsis are still inside the items, 
so remove them by force  */
+if (o-last_computed.ellipsis_start)
+  _evas_object_text_item_del(o, o-last_computed.ellipsis_start);
 o-last_computed.ellipsis_start = NULL;
+
+if (o-last_computed.ellipsis_end)
+  _evas_object_text_item_del(o, o-last_computed.ellipsis_end);
 o-last_computed.ellipsis_end = NULL;
  }
while (o-items)
@@ -1047,7 +1053,7 @@ _text_text_set(Eo *eo_obj, void *_pd, va_list *list)
/* DO II */
/*Update bidi_props*/
 
-   if (o-items) _evas_object_text_items_clear(o);
+   _evas_object_text_items_clear(o);
 
_evas_object_text_recalc(eo_obj, text);
eina_stringshare_replace(o-cur.utf8_text, _text);

-- 




[EGIT] [core/efl] master 01/04: eina: avoid possible race condition when unreffing an Eina_File.

2013-10-28 Thread Cedric Bail
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=60a34c1cd0e7e5b51bb83a07ffa2cae869eb0179

commit 60a34c1cd0e7e5b51bb83a07ffa2cae869eb0179
Author: Cedric Bail cedric.b...@samsung.com
Date:   Mon Oct 28 18:23:02 2013 +0900

eina: avoid possible race condition when unreffing an Eina_File.
---
 src/lib/eina/eina_file_common.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c
index ac7d020..e5b1250 100644
--- a/src/lib/eina/eina_file_common.c
+++ b/src/lib/eina/eina_file_common.c
@@ -445,12 +445,15 @@ eina_file_dup(Eina_File *file)
 EAPI void
 eina_file_close(Eina_File *file)
 {
+   Eina_Bool leave = EINA_TRUE;
+
EINA_SAFETY_ON_NULL_RETURN(file);
 
eina_lock_take(file-lock);
file-refcount--;
+   if (file-refcount == 0) leave = EINA_FALSE;
eina_lock_release(file-lock);
-   if (file-refcount != 0) return;
+   if (leave) return;
 
eina_lock_take(_eina_file_lock_cache);
 

-- 




[EGIT] [core/efl] master 03/04: eet: help the kernel to actually load the eet file in memory more efficiently.

2013-10-28 Thread Cedric Bail
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=1a3c9d68d068c531cb99b5c8b0fe4514927e1f92

commit 1a3c9d68d068c531cb99b5c8b0fe4514927e1f92
Author: Cedric Bail cedric.b...@samsung.com
Date:   Mon Oct 28 18:28:38 2013 +0900

eet: help the kernel to actually load the eet file in memory more 
efficiently.

When you open a theme, it is very likely that most of the data in it will 
be needed
at some point, that's why it is a good idea to tell it in advance to the 
kernel so
it could load them if it has some spare ressource.

We can't just blindly turn EINA_FILE_WILLNEED on any file or a wrong eet 
file would
be loaded in memory when we don't need it. So we shall keep the sequential 
load until
we are sure that the file is correct and then explicitely tell the kernel 
that the
rest of the data should be loaded in ram.
---
 src/lib/eet/eet_lib.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c
index f85209a..7fa8ce9 100644
--- a/src/lib/eet/eet_lib.c
+++ b/src/lib/eet/eet_lib.c
@@ -1043,6 +1043,16 @@ eet_internal_read2(Eet_File *ef)
 #endif /* ifdef HAVE_SIGNATURE */
  }
 
+   /* At this stage we have a valid eet file, let's tell the system we are 
likely to need most of its data */
+   if (ef-readfp  ef-ed)
+ {
+unsigned long int offset;
+
+offset = (unsigned char*) ef-ed-start - (unsigned char*) ef-data;
+eina_file_map_populate(ef-readfp, EINA_FILE_WILLNEED, ef-data,
+   offset, ef-data_size - offset);
+ }
+
return ef;
 }
 

-- 




[EGIT] [core/efl] master 02/04: eina: fix API as we don't and never will touch memory for write in that function.

2013-10-28 Thread Cedric Bail
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=570ce667f385c2fa3d36f0280eef6222a3e19a0b

commit 570ce667f385c2fa3d36f0280eef6222a3e19a0b
Author: Cedric Bail cedric.b...@samsung.com
Date:   Mon Oct 28 18:26:10 2013 +0900

eina: fix API as we don't and never will touch memory for write in that 
function.
---
 src/lib/eina/eina_file.c | 2 +-
 src/lib/eina/eina_file.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c
index b9d7b14..7b8aaff 100644
--- a/src/lib/eina/eina_file.c
+++ b/src/lib/eina/eina_file.c
@@ -1122,7 +1122,7 @@ eina_file_map_free(Eina_File *file, void *map)
 }
 
 EAPI void
-eina_file_map_populate(Eina_File *file, Eina_File_Populate rule, void *map,
+eina_file_map_populate(Eina_File *file, Eina_File_Populate rule, const void 
*map,
unsigned long int offset, unsigned long int length)
 {
Eina_File_Map *em;
diff --git a/src/lib/eina/eina_file.h b/src/lib/eina/eina_file.h
index 234cb2a..8384e2a 100644
--- a/src/lib/eina/eina_file.h
+++ b/src/lib/eina/eina_file.h
@@ -629,7 +629,7 @@ EAPI void eina_file_map_free(Eina_File *file, void *map);
  * @sine 1.8
  */
 EAPI void
-eina_file_map_populate(Eina_File *file, Eina_File_Populate rule, void *map,
+eina_file_map_populate(Eina_File *file, Eina_File_Populate rule, const void 
*map,
unsigned long int offset, unsigned long int length);
 
 /**

-- 




[EGIT] [core/efl] master 01/02: evas: fix leak of ellipsis object in Evas_Object_Text.

2013-10-28 Thread Cedric Bail
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6bc393e740384134705d815ede95cb888ae2befe

commit 6bc393e740384134705d815ede95cb888ae2befe
Author: Cedric Bail cedric.b...@samsung.com
Date:   Mon Oct 28 19:45:46 2013 +0900

evas: fix leak of ellipsis object in Evas_Object_Text.
---
 src/lib/evas/canvas/evas_object_text.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib/evas/canvas/evas_object_text.c 
b/src/lib/evas/canvas/evas_object_text.c
index c479ddc..5dc38a8 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -222,13 +222,13 @@ _evas_object_text_items_clear(Evas_Object_Text *o)
if ((o-last_computed.ellipsis_start) 
(o-last_computed.ellipsis_start != o-items))
  {
-_evas_object_text_item_clean(o-last_computed.ellipsis_start);
+_evas_object_text_item_del(o, o-last_computed.ellipsis_start);
  }
o-last_computed.ellipsis_start = NULL;
if ((o-last_computed.ellipsis_end) 
(EINA_INLIST_GET(o-last_computed.ellipsis_end) != 
EINA_INLIST_GET(o-items)-last))
  {
-_evas_object_text_item_clean(o-last_computed.ellipsis_end);
+_evas_object_text_item_del(o, o-last_computed.ellipsis_end);
  }
o-last_computed.ellipsis_end = NULL;
while (o-items)

-- 




[EGIT] [core/efl] master 02/02: eina: long forgotten function in Eina_File for Windows.

2013-10-28 Thread Cedric Bail
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e35c7b19fbc98215edf606ce59ceb7f0964cbd36

commit e35c7b19fbc98215edf606ce59ceb7f0964cbd36
Author: Cedric Bail cedric.b...@samsung.com
Date:   Mon Oct 28 19:47:40 2013 +0900

eina: long forgotten function in Eina_File for Windows.
---
 src/lib/eina/eina_file_win32.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/lib/eina/eina_file_win32.c b/src/lib/eina/eina_file_win32.c
index 920ef4d..cddf2da 100644
--- a/src/lib/eina/eina_file_win32.c
+++ b/src/lib/eina/eina_file_win32.c
@@ -873,6 +873,12 @@ EAPI Eina_Iterator *eina_file_xattr_value_get(Eina_File 
*file EINA_UNUSED)
return NULL;
 }
 
+EAPI void
+eina_file_map_populate(Eina_File *file EINA_UNUSED, Eina_File_Populate rule 
EINA_UNUSED, const void *map EINA_UNUSED,
+   unsigned long int offset EINA_UNUSED, unsigned long int 
length EINA_UNUSED)
+{
+}
+
 EAPI void *
 eina_file_map_all(Eina_File *file, Eina_File_Populate rule EINA_UNUSED)
 {

-- 




[E-devel] Weekly news from the automated build and QA front

2013-10-28 Thread Stefan Schmidt
Hello.

I skipped last week because I was out of the office and my etup was not 
ready to handle it on the road. Thats fixed now.

This should give everyone an overview over what has happened in the last
week regarding our continuous integration builds, unit tests and
coverage as well as all static analyser runs and things like
address-sanitizer.

The numbers in parentheses reflect the values from last week to give you
a trend.

CI:
o Overall build statistic: 5.1% (3.5%) failed and 94.9% (96.5%)
succeeded.
https://build.enlightenment.org/

clang scan-build:
o EFL scan-build reports 505 (503) issues.
https://build.enlightenment.org/job/nightly_efl_clang_x86_64/lastSuccessfu
lBuild/artifact/scan-build/build/

Exactness:
o The edje exactness builds are working now. Elm exactness still failing.
o Problems with icons and paths (file selector widget)
o Still waiting for the first successful run on jenkins

Unit tests:
o 277 (271) unit tests for efl and none failing
o Thanks goes to Cedric for adding more tests for eina_file.

Coverage:
o EFL total coverage is at 25.9% (25.7%) lines and 28.7% (28.5%) functions
https://build.enlightenment.org/view/Test%20Coverage/

Coverity:
o Added terminology on the request of Boris Faure
o EFL: Outstanding defects 439 (452) with a density of 0.83 (0.85). 23
defects fixed since last build and 14 added.
o Elm: Outstanding defects 21 (21) with a density of 0.10 (0.10). 2
defects fixed since last build and 0 added.
o E: Outstanding defects 198 (199) with a density of 0.71 (0.71). 3
defects fixed since last build and 1 added.
o Terminology: Outstanding defects 19 (23) with a density of 0.30
(0.37). 4 defects fixed since last build and 0 added.

If anybody wants to see something added here let me know and be my guest.

regards
Stefan Schmidt

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [RFC] configure options for maintainers

2013-10-28 Thread Guillaume Friloux

On 28/10/2013 03:49, Carsten Haitzler (The Rasterman) wrote:

great.. but how do you EXTRACT this info then from the lib? :) it's a lib.. it
can't execute on its own... and printfing such strings on every fn call is just
anti-social :)


Its actually possible, but needs some hack.
glibc does it :
 /lib/libc-2.18.so
GNU C Library (GNU libc) stable release version 2.18, by Roland McGrath 
et al.

Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.8.1 20130725 (prerelease).
Compiled on a Linux 3.10.6 system on 2013-09-24.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
https://bugs.archlinux.org/.

attachment: guillaume_friloux.vcf--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135991iu=/4140/ostg.clktrk___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] Evas cserve2

2013-10-28 Thread Rafael Antognolli
Is this some kind of write-only email, or am I missing something?

On Mon, Oct 28, 2013 at 6:07 AM, Jean-Philippe André j...@videolan.org wrote:
 Hello there!

 The commit is there:
 https://git.enlightenment.org/core/efl.git/commit/?id=7338164468370056e35c206a47ca3fe1b1b61f38

 It's a merge of 77 commits from my public branch, rebased (fast-forward)
 onto master.
 Sorry about the [EGIT] mail flood, I thought --no-ff would prevent that
 from happening...

 Should any breakage happen (build, runtime, anything), please let me know
 soon :)

 If the build is broken for you and you are in a hurry, please use git
 revert 1 
 7338164https://git.enlightenment.org/core/efl.git/commit/?id=7338164468370056e35c206a47ca3fe1b1b61f38
 to revert this merge on your local branch.

 Have a great day,

 JP


 2013/10/28 ChunEon Park her...@naver.com

 Also it will be useful when you post it to the phabricator article.
 https://phab.enlightenment.org/phame/post/all/

 
 -Regards, Hermet-

 -Original Message-
 From: Jean-Philippe Andréj...@videolan.org
 To: Enlightenment developer list
 enlightenment-devel@lists.sourceforge.net;
 Cc:
 Sent: 2013-10-24 (목) 10:45:31
 Subject: [E-devel] Evas cserve2

 Dear EFL developers,


 TL;DR I'd like to merge my work on cserve2 into EFL master soon. This is a
 commit-flood warning mail.


 I hope the lucky of you folks who attended EFL dev day 2013 had fun there.
 Also I hope this was a productive event and you got the opportunity to
 discuss various EFL-related topics.

 Amongst those, I trust Cedric made an awesome presentation about cserve2,
 and introduced the work I've put on top of what had already been done :-)

 Now is about time to merge this work into the master branch, as it's
 reached a state where it is (almost?) fast  stable enough to be used to
 run E18.

 For those who forgot or could not attend, let me summarize what this is all
 about:

 Evas cserve2 is a caching mechanism for Evas images and font (glyphs) that
 is based on a client-server model. A program, evas_cserve2, runs as a
 server on the system, waits for commands on a UNIX socket, and loads image
 files, image data and font data in memory. The memory is then shared and
 exposed in virtual files in /dev/shm and all applications can access it.
 This means multiple apps will reuse the exact same resources in memory, and
 won't need to duplicate common elements such as font glyphs and theme image
 data.

 When I first started working on cserve2, it was in an experimentally
 working state. That is, it worked pretty well in some situations, but there
 were huge performance bottlenecks, that made it impractical to use in
 production.

 One of the main bottlenecks was the massive amount of IPC involved in just
 opening  loading an image. (Example: client A sends a message to cserve2
 to OPEN an image, then waits for cserve2 to answer. cserve2 sends a message
 to its slave to OPEN that image, receives a message from the slave when
 it's done, sends a message back to the client A, ... So far the data itself
 is still not even loaded, and client A will have to request the data in a
 second message to cserve2...) In particular, most scaling was done on the
 server and not on the client side, which means that lots of scaled images
 could be cached even when used only once.

 So, I worked on reducing unnecessary IPC and optimizing data loading, in
 two ways:
 - Reuse the scalecache logic for scaled images (cache only images that
 would otherwise hit the scalecache, scale on the fly all the rest)
 - Implement a shared indexing system, where cserve2 exposes its internal
 cache structure to all the clients. The clients can then scan the indexes
 (also stored in /dev/shm), bypass part of the heavy IPC and directly open
 the data. This works very well for images as they will not change at all
 after being fully loaded.

 In terms of stability, I've also improved the following:
 - Support the GL engine (very basic support right now)
 - Support some exotic stuff (eg. animated Gif)
 - Allow cserve2 to crash without affecting clients (as long as the system
 restarts the server)


 The overall objective of cserve2 is to reduce memory usage at the system
 level, as applications will share more resources. Also, we can integrate in
 the future with E, so that the required resources are loaded ASAP when an
 app starts (predict what an app needs before even it has requested them).
 So there is a potential performance increase as well, on slower devices at
 least.

 I've been actually using it for a couple days and it's surprisingly quite
 stable ^^.
 I will fix bugs as they come [1].


 The source code is available in my dev branch (rebased on top of master):
 https://git.enlightenment.org/core/efl.git/log/?h=devs/jpeg/cserve2

 It's a LOT of commits, so out of question that I push them without previous
 notice  discussion :-)
 As usual, if there's any bug left, blame Cedric.


 Best regards,


 

[EGIT] [core/enlightenment] master 01/01: unbreak temp module exe event handlers

2013-10-28 Thread Mike Blumenkrantz
discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=c2e0679c3d3dca6820d11ab71cba6e4c0b9e25af

commit c2e0679c3d3dca6820d11ab71cba6e4c0b9e25af
Author: Mike Blumenkrantz m.blumenk...@samsung.com
Date:   Mon Oct 28 13:22:28 2013 +

unbreak temp module exe event handlers

returning 0/DONE breaks successive handlers, and that's really bad if 
you're breaking handlers for exes that you don't own.
---
 src/modules/temperature/e_mod_tempget.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/temperature/e_mod_tempget.c 
b/src/modules/temperature/e_mod_tempget.c
index c9cc19a..b50ed72 100644
--- a/src/modules/temperature/e_mod_tempget.c
+++ b/src/modules/temperature/e_mod_tempget.c
@@ -10,7 +10,7 @@ _temperature_cb_exe_data(void *data, __UNUSED__ int type, 
void *event)
 
ev = event;
inst = data;
-   if (ev-exe != inst-tempget_exe) return ECORE_CALLBACK_PASS_ON;
+   if ((!inst-tempget_exe) || (ev-exe != inst-tempget_exe)) return 
ECORE_CALLBACK_PASS_ON;
temp = -999;
if ((ev-lines)  (ev-lines[0].line))
  {
@@ -70,7 +70,7 @@ _temperature_cb_exe_del(void *data, __UNUSED__ int type, void 
*event)
 
ev = event;
inst = data;
-   if (ev-exe != inst-tempget_exe) return ECORE_CALLBACK_PASS_ON;
+   if ((!inst-tempget_exe) || (ev-exe != inst-tempget_exe)) return 
ECORE_CALLBACK_PASS_ON;
inst-tempget_exe = NULL;
return ECORE_CALLBACK_DONE;
 }

-- 




[EGIT] [core/efl] master 01/01: change init done bindings.

2013-10-28 Thread Rafael Antognolli
antognolli pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=b87afd1b943b260c92f8493647b7d9cae327656e

commit b87afd1b943b260c92f8493647b7d9cae327656e
Author: Rafael Antognolli rafael.antogno...@intel.com
Date:   Mon Oct 28 14:07:25 2013 -0200

change init done bindings.
---
 src/lib/ecore_wayland/Ecore_Wayland.h  |  6 ++
 src/lib/ecore_wayland/ecore_wl.c   | 65 --
 .../engines/wayland/ecore_evas_wayland_egl.c   |  2 -
 .../engines/wayland/ecore_evas_wayland_shm.c   |  2 -
 4 files changed, 55 insertions(+), 20 deletions(-)

diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h 
b/src/lib/ecore_wayland/Ecore_Wayland.h
index 30545b7..15c5940 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -120,6 +120,8 @@ struct _Ecore_Wl_Display
struct wl_list outputs;
struct wl_list globals; /** @since 1.7.6 */
 
+   Eina_Bool init_done;
+
struct
  {
 struct xkb_context *context;
@@ -366,6 +368,10 @@ struct _Ecore_Wl_Event_Interfaces_Bound
Eina_Bool compositor : 1;
Eina_Bool shm : 1;
Eina_Bool shell : 1;
+   Eina_Bool output : 1;
+   Eina_Bool seat : 1;
+   Eina_Bool data_device_manager : 1;
+   Eina_Bool subcompositor : 1;
 };
 
 /**
diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index ee614e0..8766834 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -22,6 +22,7 @@ static void _ecore_wl_animator_callback(void *data, struct 
wl_callback *callback
 static Eina_Bool _ecore_wl_animator_window_add(const Eina_Hash *hash 
EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED);
 static void _ecore_wl_signal_exit(void);
 static void _ecore_wl_signal_exit_free(void *data EINA_UNUSED, void *event);
+static void _ecore_wl_init_callback(void *data, struct wl_callback *callback, 
uint32_t serial EINA_UNUSED);
 
 /* local variables */
 static int _ecore_wl_init_count = 0;
@@ -40,6 +41,11 @@ static const struct wl_callback_listener 
_ecore_wl_sync_listener =
_ecore_wl_sync_callback
 };
 
+static const struct wl_callback_listener _ecore_wl_init_sync_listener =
+{
+   _ecore_wl_init_callback
+};
+
 static const struct wl_callback_listener _ecore_wl_anim_listener = 
 {
_ecore_wl_animator_callback
@@ -66,9 +72,40 @@ EAPI int ECORE_WL_EVENT_SELECTION_DATA_READY = 0;
 EAPI int ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = 0;
 EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0;
 
+static void
+_ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t 
serial EINA_UNUSED)
+{
+   Ecore_Wl_Display *ewd = data;
+   Ecore_Wl_Event_Interfaces_Bound *ev;
+
+   wl_callback_destroy(callback);
+   ewd-init_done = EINA_TRUE;
+
+   if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Interfaces_Bound
+ return;
+
+   ev-compositor = (ewd-wl.compositor != NULL);
+   ev-shm = (ewd-wl.shm != NULL);
+   ev-shell = (ewd-wl.shell != NULL);
+   ev-output = (ewd-output != NULL);
+   ev-seat = (ewd-input != NULL);
+   ev-data_device_manager = (ewd-wl.data_device_manager != NULL);
+   ev-subcompositor = (ewd-wl.subcompositor != NULL);
+
+   ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL);
+}
+
+static void
+_ecore_wl_init_wait(void)
+{
+   while (!_ecore_wl_disp-init_done)
+ wl_display_dispatch(_ecore_wl_disp-wl.display);
+}
+
 EAPI int
 ecore_wl_init(const char *name)
 {
+   struct wl_callback *callback;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
if (++_ecore_wl_init_count != 1) return _ecore_wl_init_count;
@@ -181,6 +218,10 @@ ecore_wl_init(const char *name)
_ecore_wl_window_init();
_ecore_wl_events_init();
 
+   callback = wl_display_sync(_ecore_wl_disp-wl.display);
+   wl_callback_add_listener(callback, _ecore_wl_init_sync_listener,
+_ecore_wl_disp);
+
return _ecore_wl_init_count;
 }
 
@@ -212,6 +253,9 @@ EAPI struct wl_shm *
 ecore_wl_shm_get(void)
 {
if (!_ecore_wl_disp) return NULL;
+
+   _ecore_wl_init_wait();
+
return _ecore_wl_disp-wl.shm;
 }
 
@@ -228,6 +272,9 @@ ecore_wl_globals_get(void)
 {
if ((!_ecore_wl_disp) || (!_ecore_wl_disp-wl.display)) 
  return NULL;
+
+   _ecore_wl_init_wait();
+
return (_ecore_wl_disp-globals);
 }
 
@@ -236,6 +283,7 @@ ecore_wl_registry_get(void)
 {
if ((!_ecore_wl_disp) || (!_ecore_wl_disp-wl.display)) 
  return NULL;
+
return _ecore_wl_disp-wl.registry;
 }
 
@@ -249,8 +297,7 @@ ecore_wl_screen_size_get(int *w, int *h)
 
if ((!_ecore_wl_disp) || (!_ecore_wl_disp-wl.display)) return;
 
-   if (!_ecore_wl_disp-output)
- ecore_wl_sync();
+   _ecore_wl_init_wait();
 
if (!_ecore_wl_disp-output) return;
 
@@ -545,20 +592,6 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry 
*registry, unsigned in
 ewd-wl.data_device_manager =
   wl_registry_bind(registry, id, wl_data_device_manager_interface, 1);
  }
-
-  

[EGIT] [core/efl] master 01/01: Revert change init done bindings.

2013-10-28 Thread Rafael Antognolli
antognolli pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=ad731e8b213ff38fed95f069a3ba79aba339925a

commit ad731e8b213ff38fed95f069a3ba79aba339925a
Author: Rafael Antognolli rafael.antogno...@intel.com
Date:   Mon Oct 28 14:46:40 2013 -0200

Revert change init done bindings.

This reverts commit b87afd1b943b260c92f8493647b7d9cae327656e.

Wrong branch, wrong commit.
---
 src/lib/ecore_wayland/Ecore_Wayland.h  |  6 --
 src/lib/ecore_wayland/ecore_wl.c   | 65 ++
 .../engines/wayland/ecore_evas_wayland_egl.c   |  2 +
 .../engines/wayland/ecore_evas_wayland_shm.c   |  2 +
 4 files changed, 20 insertions(+), 55 deletions(-)

diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h 
b/src/lib/ecore_wayland/Ecore_Wayland.h
index 15c5940..30545b7 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -120,8 +120,6 @@ struct _Ecore_Wl_Display
struct wl_list outputs;
struct wl_list globals; /** @since 1.7.6 */
 
-   Eina_Bool init_done;
-
struct
  {
 struct xkb_context *context;
@@ -368,10 +366,6 @@ struct _Ecore_Wl_Event_Interfaces_Bound
Eina_Bool compositor : 1;
Eina_Bool shm : 1;
Eina_Bool shell : 1;
-   Eina_Bool output : 1;
-   Eina_Bool seat : 1;
-   Eina_Bool data_device_manager : 1;
-   Eina_Bool subcompositor : 1;
 };
 
 /**
diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index 8766834..ee614e0 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -22,7 +22,6 @@ static void _ecore_wl_animator_callback(void *data, struct 
wl_callback *callback
 static Eina_Bool _ecore_wl_animator_window_add(const Eina_Hash *hash 
EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED);
 static void _ecore_wl_signal_exit(void);
 static void _ecore_wl_signal_exit_free(void *data EINA_UNUSED, void *event);
-static void _ecore_wl_init_callback(void *data, struct wl_callback *callback, 
uint32_t serial EINA_UNUSED);
 
 /* local variables */
 static int _ecore_wl_init_count = 0;
@@ -41,11 +40,6 @@ static const struct wl_callback_listener 
_ecore_wl_sync_listener =
_ecore_wl_sync_callback
 };
 
-static const struct wl_callback_listener _ecore_wl_init_sync_listener =
-{
-   _ecore_wl_init_callback
-};
-
 static const struct wl_callback_listener _ecore_wl_anim_listener = 
 {
_ecore_wl_animator_callback
@@ -72,40 +66,9 @@ EAPI int ECORE_WL_EVENT_SELECTION_DATA_READY = 0;
 EAPI int ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = 0;
 EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0;
 
-static void
-_ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t 
serial EINA_UNUSED)
-{
-   Ecore_Wl_Display *ewd = data;
-   Ecore_Wl_Event_Interfaces_Bound *ev;
-
-   wl_callback_destroy(callback);
-   ewd-init_done = EINA_TRUE;
-
-   if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Interfaces_Bound
- return;
-
-   ev-compositor = (ewd-wl.compositor != NULL);
-   ev-shm = (ewd-wl.shm != NULL);
-   ev-shell = (ewd-wl.shell != NULL);
-   ev-output = (ewd-output != NULL);
-   ev-seat = (ewd-input != NULL);
-   ev-data_device_manager = (ewd-wl.data_device_manager != NULL);
-   ev-subcompositor = (ewd-wl.subcompositor != NULL);
-
-   ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL);
-}
-
-static void
-_ecore_wl_init_wait(void)
-{
-   while (!_ecore_wl_disp-init_done)
- wl_display_dispatch(_ecore_wl_disp-wl.display);
-}
-
 EAPI int
 ecore_wl_init(const char *name)
 {
-   struct wl_callback *callback;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
if (++_ecore_wl_init_count != 1) return _ecore_wl_init_count;
@@ -218,10 +181,6 @@ ecore_wl_init(const char *name)
_ecore_wl_window_init();
_ecore_wl_events_init();
 
-   callback = wl_display_sync(_ecore_wl_disp-wl.display);
-   wl_callback_add_listener(callback, _ecore_wl_init_sync_listener,
-_ecore_wl_disp);
-
return _ecore_wl_init_count;
 }
 
@@ -253,9 +212,6 @@ EAPI struct wl_shm *
 ecore_wl_shm_get(void)
 {
if (!_ecore_wl_disp) return NULL;
-
-   _ecore_wl_init_wait();
-
return _ecore_wl_disp-wl.shm;
 }
 
@@ -272,9 +228,6 @@ ecore_wl_globals_get(void)
 {
if ((!_ecore_wl_disp) || (!_ecore_wl_disp-wl.display)) 
  return NULL;
-
-   _ecore_wl_init_wait();
-
return (_ecore_wl_disp-globals);
 }
 
@@ -283,7 +236,6 @@ ecore_wl_registry_get(void)
 {
if ((!_ecore_wl_disp) || (!_ecore_wl_disp-wl.display)) 
  return NULL;
-
return _ecore_wl_disp-wl.registry;
 }
 
@@ -297,7 +249,8 @@ ecore_wl_screen_size_get(int *w, int *h)
 
if ((!_ecore_wl_disp) || (!_ecore_wl_disp-wl.display)) return;
 
-   _ecore_wl_init_wait();
+   if (!_ecore_wl_disp-output)
+ ecore_wl_sync();
 
if (!_ecore_wl_disp-output) return;
 
@@ -592,6 +545,20 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry 
*registry, unsigned in
 

[EGIT] [core/efl] master 01/02: ecore/wayland: Add info about other bound interfaces.

2013-10-28 Thread Rafael Antognolli
antognolli pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3aca95bb22cac0f0ab86eede49a3118fbcc7c93e

commit 3aca95bb22cac0f0ab86eede49a3118fbcc7c93e
Author: Rafael Antognolli rafael.antogno...@intel.com
Date:   Mon Oct 28 14:12:27 2013 -0200

ecore/wayland: Add info about other bound interfaces.

Add output, seat, data_device_manager and subcompositor as possible
bound interfaces, on the ECORE_WL_EVENT_INTERFACES_BOUND event info.
---
 src/lib/ecore_wayland/Ecore_Wayland.h | 4 
 src/lib/ecore_wayland/ecore_wl.c  | 4 
 2 files changed, 8 insertions(+)

diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h 
b/src/lib/ecore_wayland/Ecore_Wayland.h
index 30545b7..4238c46 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -366,6 +366,10 @@ struct _Ecore_Wl_Event_Interfaces_Bound
Eina_Bool compositor : 1;
Eina_Bool shm : 1;
Eina_Bool shell : 1;
+   Eina_Bool output : 1;
+   Eina_Bool seat : 1;
+   Eina_Bool data_device_manager : 1;
+   Eina_Bool subcompositor : 1;
 };
 
 /**
diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index ee614e0..9e8fa46 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -556,6 +556,10 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry 
*registry, unsigned in
 ev-compositor = (ewd-wl.compositor != NULL);
 ev-shm = (ewd-wl.shm != NULL);
 ev-shell = (ewd-wl.shell != NULL);
+ev-output = (ewd-output != NULL);
+ev-seat = (ewd-input != NULL);
+ev-data_device_manager = (ewd-wl.data_device_manager != NULL);
+ev-subcompositor = (ewd-wl.subcompositor != NULL);
 
 ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL);
  }

-- 




[EGIT] [core/efl] master 02/02: ecore/wayland: Use sync callback to report end of ecore_wl_init().

2013-10-28 Thread Rafael Antognolli
antognolli pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=ccdeae7ce498d21088e4b0849ceb2394148f9877

commit ccdeae7ce498d21088e4b0849ceb2394148f9877
Author: Rafael Antognolli rafael.antogno...@intel.com
Date:   Mon Oct 28 14:07:25 2013 -0200

ecore/wayland: Use sync callback to report end of ecore_wl_init().

At the end of the ecore_wl_init() function, send a sync request to the
server, and add a callback listener to the done event. When this event
is received, we are sure that all the registry bind requests done so
far were processed already, and that the registry and globals are
available and can be used.

Now, on the functions that request interfaces or registry, we call
_ecore_wl_init_wait(), which will check if the callback was received
already (that means that all requests inside the init were processed).
If it was not yet, then we wait until receiving that callback, before
returning the requested data.
---
 src/lib/ecore_wayland/Ecore_Wayland.h  | 11 +++
 src/lib/ecore_wayland/ecore_wl.c   | 36 --
 .../engines/wayland/ecore_evas_wayland_egl.c   |  2 --
 .../engines/wayland/ecore_evas_wayland_shm.c   |  2 --
 4 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h 
b/src/lib/ecore_wayland/Ecore_Wayland.h
index 4238c46..9ba7636 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -120,6 +120,8 @@ struct _Ecore_Wl_Display
struct wl_list outputs;
struct wl_list globals; /** @since 1.7.6 */
 
+   Eina_Bool init_done;
+
struct
  {
 struct xkb_context *context;
@@ -558,6 +560,15 @@ EAPI struct wl_list *ecore_wl_outputs_get(void);
 /**
  * Retrieves the Wayland Globals Interface list used for the current Wayland 
connection.
  *
+ * This call, if done after the ECORE_WL_EVENT_INTERFACES_BOUND event was
+ * received already, won't block the mainloop or trigger a dispatch. It will
+ * return the current globals immediately. However, if done before this event,
+ * it will probably block the mainloop waiting for the sync done event to be
+ * received (by using one or more wl_display_dispatch call), and then finally
+ * return the wl globals list.
+ *
+ * There's no need to call dispatch manually, since this call will do it if 
necessary.
+ *
  * @return The current wayland globals interface list
  *
  * @ingroup Ecore_Wl_Display_Group
diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index 9e8fa46..451aa79 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -22,6 +22,7 @@ static void _ecore_wl_animator_callback(void *data, struct 
wl_callback *callback
 static Eina_Bool _ecore_wl_animator_window_add(const Eina_Hash *hash 
EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED);
 static void _ecore_wl_signal_exit(void);
 static void _ecore_wl_signal_exit_free(void *data EINA_UNUSED, void *event);
+static void _ecore_wl_init_callback(void *data, struct wl_callback *callback, 
uint32_t serial EINA_UNUSED);
 
 /* local variables */
 static int _ecore_wl_init_count = 0;
@@ -40,6 +41,11 @@ static const struct wl_callback_listener 
_ecore_wl_sync_listener =
_ecore_wl_sync_callback
 };
 
+static const struct wl_callback_listener _ecore_wl_init_sync_listener =
+{
+   _ecore_wl_init_callback
+};
+
 static const struct wl_callback_listener _ecore_wl_anim_listener = 
 {
_ecore_wl_animator_callback
@@ -66,9 +72,26 @@ EAPI int ECORE_WL_EVENT_SELECTION_DATA_READY = 0;
 EAPI int ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = 0;
 EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0;
 
+static void
+_ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t 
serial EINA_UNUSED)
+{
+   Ecore_Wl_Display *ewd = data;
+
+   wl_callback_destroy(callback);
+   ewd-init_done = EINA_TRUE;
+}
+
+static void
+_ecore_wl_init_wait(void)
+{
+   while (!_ecore_wl_disp-init_done)
+ wl_display_dispatch(_ecore_wl_disp-wl.display);
+}
+
 EAPI int
 ecore_wl_init(const char *name)
 {
+   struct wl_callback *callback;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
if (++_ecore_wl_init_count != 1) return _ecore_wl_init_count;
@@ -181,6 +204,10 @@ ecore_wl_init(const char *name)
_ecore_wl_window_init();
_ecore_wl_events_init();
 
+   callback = wl_display_sync(_ecore_wl_disp-wl.display);
+   wl_callback_add_listener(callback, _ecore_wl_init_sync_listener,
+_ecore_wl_disp);
+
return _ecore_wl_init_count;
 }
 
@@ -212,6 +239,9 @@ EAPI struct wl_shm *
 ecore_wl_shm_get(void)
 {
if (!_ecore_wl_disp) return NULL;
+
+   _ecore_wl_init_wait();
+
return _ecore_wl_disp-wl.shm;
 }
 
@@ -228,6 +258,9 @@ ecore_wl_globals_get(void)
 {
if ((!_ecore_wl_disp) || (!_ecore_wl_disp-wl.display)) 
  return NULL;
+
+   _ecore_wl_init_wait();
+

[EGIT] [bindings/python/python-efl] master 01/02: Simplify and correct string representation functions.

2013-10-28 Thread Kai Huuhko
kuuko pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=1e40a8f5bbe493801143b0e2647e958c5d3a11ec

commit 1e40a8f5bbe493801143b0e2647e958c5d3a11ec
Author: Kai Huuhko kai.huu...@gmail.com
Date:   Mon Oct 28 06:47:14 2013 +0200

Simplify and correct string representation functions.

Calling str() uses __repr__ when __str__ is not found.

__repr__ should return a string with angle brackets when the object
cannot be reconstructed with exec(repr(obj)).
---
 efl/elementary/genlist_item.pxi | 26 ++
 efl/elementary/object_item.pyx  | 22 --
 efl/eo/efl.eo.pyx   | 28 
 efl/evas/efl.evas_object.pxi| 34 +++---
 4 files changed, 41 insertions(+), 69 deletions(-)

diff --git a/efl/elementary/genlist_item.pxi b/efl/elementary/genlist_item.pxi
index f0e2d35..65fc259 100644
--- a/efl/elementary/genlist_item.pxi
+++ b/efl/elementary/genlist_item.pxi
@@ -73,23 +73,17 @@ cdef class GenlistItem(ObjectItem):
 assert self.item != NULL, Object must wrap something
 self.item = NULL
 
-def __str__(self):
-return %s(item_class=%s, func=%s, item_data=%s) % \
-   (type(self).__name__,
-type(self.item_class).__name__,
-self.cb_func,
-self.item_data)
-
 def __repr__(self):
-return (%s(%#x, refcount=%d, Elm_Object_Item=%#x, 
-item_class=%s, func=%s, item_data=%r)) % \
-   (type(self).__name__,
-unsigned longvoid*self,
-PY_REFCOUNT(self),
-unsigned longself.item,
-type(self.item_class).__name__,
-self.cb_func,
-self.item_data)
+return (%s(%#x, refcount=%d, Elm_Object_Item=%#x, 
+item_class=%s, func=%s, item_data=%r)) % (
+type(self).__name__,
+unsigned longvoid*self,
+PY_REFCOUNT(self),
+unsigned longself.item,
+type(self.item_class).__name__,
+self.cb_func,
+self.item_data
+)
 
 def append_to(self, Genlist genlist not None):
 append_to(Genlist genlist) - GenlistItem
diff --git a/efl/elementary/object_item.pyx b/efl/elementary/object_item.pyx
index 55db14a..3f69d13 100644
--- a/efl/elementary/object_item.pyx
+++ b/efl/elementary/object_item.pyx
@@ -49,7 +49,11 @@ cdef _object_item_to_python(Elm_Object_Item *it):
 data = elm_object_item_data_get(it)
 
 if data == NULL:
-# Attempt to create a dummy object item
+#
+# Attempt to create a dummy object item.
+#
+# TODO: Warn here that the item is not complete.
+#
 item = ObjectItem.__new__(ObjectItem)
 item._set_obj(it)
 else:
@@ -113,16 +117,14 @@ cdef class ObjectItem(object):
 Py_INCREF(self)
 return 1
 
-def __str__(self):
-return (ObjectItem(class=%s, obj=%#x, refcount=%d)) % \
-(type(self).__name__, unsigned longself.item,
- PY_REFCOUNT(self))
-
 def __repr__(self):
-return (ObjectItem(class=%s, obj=%#x, refcount=%d)) % \
-(type(self).__name__, unsigned longself.item,
- PY_REFCOUNT(self))
-
+return (%s object (ObjectItem) at %#x (obj=%#x, refcount=%d, 
widget=%s)) % (
+type(self).__name__,
+unsigned longvoid *self,
+unsigned longself.item,
+PY_REFCOUNT(self),
+repr(object_from_instance(elm_object_item_widget_get(self.item)))
+)
 
 property widget:
 Get the widget object's handle which contains a given item
diff --git a/efl/eo/efl.eo.pyx b/efl/eo/efl.eo.pyx
index 14f4bcd..45a113e 100644
--- a/efl/eo/efl.eo.pyx
+++ b/efl/eo/efl.eo.pyx
@@ -95,20 +95,20 @@ cdef object object_from_instance(cEo *obj):
 
 cls_name = eo_class_name_get(eo_class_get(obj))
 if cls_name == NULL:
-raise ValueError(Eo object %#x does not have a type! % longobj)
+raise ValueError(Eo object at %#x does not have a type! % unsigned 
longobj)
 #print(Class name: %s % cls_name)
 
 cls_ret = eina_hash_find(object_mapping, cls_name)
 
 if cls_ret == NULL:
-raise ValueError(Eo object %#x of type %s does not have a mapping! %
- (longobj, cls_name))
+raise ValueError(Eo object at %#x of type %s does not have a 
mapping! %
+ (unsigned longobj, cls_name))
 
-cls = type?cls_ret
+cls = typecls_ret
 
 if cls is None:
-raise ValueError(Eo object %#x of type %s does not have a mapping! %
- (longobj, cls_name))
+raise ValueError(Mapping for Eo object at %#x, type %s, contains 
None! %
+ (unsigned longobj, cls_name))
 
 #print(MAPPING OBJECT:, cls_name, 

[EGIT] [bindings/python/python-efl] master 02/02: Fix customization of logger class when using Py2

2013-10-28 Thread Kai Huuhko
kuuko pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=6a0e8a716669e65e7ce910ee5a18f3a1eaf202d8

commit 6a0e8a716669e65e7ce910ee5a18f3a1eaf202d8
Author: Kai Huuhko kai.huu...@gmail.com
Date:   Mon Oct 28 16:54:23 2013 +0200

Fix customization of logger class when using Py2
---
 efl/utils/logger.pyx | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/efl/utils/logger.pyx b/efl/utils/logger.pyx
index 515c566..2866a51 100644
--- a/efl/utils/logger.pyx
+++ b/efl/utils/logger.pyx
@@ -54,19 +54,24 @@ cdef void py_eina_log_print_cb(const_Eina_Log_Domain *d,
 
 eina_log_print_cb_set(py_eina_log_print_cb, NULL)
 
+def setLevel(self, lvl):
+cname = self.name
+if isinstance(cname, unicode): cname = PyUnicode_AsUTF8String(cname)
+eina_log_domain_level_set(cname, log_levels.index(lvl))
+logging.Logger.setLevel(self, lvl)
+
 class PyEFLLogger(logging.Logger):
+
 def __init__(self, name):
 cname = name
 if isinstance(cname, unicode): cname = PyUnicode_AsUTF8String(cname)
 self.eina_log_domain = eina_log_domain_register(cname, NULL)
 loggers[name] = self
 logging.Logger.__init__(self, name)
-
-def setLevel(self, lvl):
-cname = self.name
-if isinstance(cname, unicode): cname = PyUnicode_AsUTF8String(cname)
-eina_log_domain_level_set(cname, log_levels.index(lvl))
-logging.Logger.setLevel(self, lvl)
+if PY_VERSION_HEX  0x0300:
+self.setLevel = types.MethodType(setLevel, self, type(self))
+else:
+self.setLevel = types.MethodType(setLevel, self)
 
 cdef object add_logger(object name):
 logging.setLoggerClass(PyEFLLogger)
@@ -82,9 +87,9 @@ cdef object add_logger(object name):
 lvl = log.getEffectiveLevel()
 eina_log_domain_level_set(cname, log_levels.index(lvl))
 if PY_VERSION_HEX  0x0300:
-log.setLevel = types.MethodType(PyEFLLogger.setLevel, log, 
PyEFLLogger)
+log.setLevel = types.MethodType(setLevel, log, type(log))
 else:
-log.setLevel = types.MethodType(PyEFLLogger.setLevel, log)
+log.setLevel = types.MethodType(setLevel, log)
 else:
 log.propagate = True
 log.setLevel(logging.WARNING)

-- 




  1   2   >