\hypertarget{group__Evas__Main__Group}{}\section{Top Level Functions}
\label{group__Evas__Main__Group}\index{Top Level Functions@{Top Level Functions}}


Functions that affect Evas as a whole.  


\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{group__Evas__Main__Group_ga65b3f060b6dd9e488afd0b8cbe101869}{evas\+\_\+init} (void)
\begin{DoxyCompactList}\small\item\em Initialize Evas. \end{DoxyCompactList}\item 
int \hyperlink{group__Evas__Main__Group_ga95a8864f81d944a92bb012b77ffd1b09}{evas\+\_\+shutdown} (void)
\begin{DoxyCompactList}\small\item\em Shutdown Evas. \end{DoxyCompactList}\item 
\hyperlink{Evas__Common_8h_ae0181b78df8e248703a72a978d271208}{Evas\+\_\+\+Alloc\+\_\+\+Error} \hyperlink{group__Evas__Main__Group_gacfae4f589c777003f58d51e502c52835}{evas\+\_\+alloc\+\_\+error} (void)
\begin{DoxyCompactList}\small\item\em Return if any allocation errors have occurred during the prior function. \end{DoxyCompactList}\item 
int \hyperlink{group__Evas__Main__Group_ga301c7d776c3d00085659fcf00c52b22d}{evas\+\_\+async\+\_\+events\+\_\+fd\+\_\+get} (void)
\begin{DoxyCompactList}\small\item\em Get evas\textquotesingle{} internal asynchronous events read file descriptor. \end{DoxyCompactList}\item 
int \hyperlink{group__Evas__Main__Group_ga80fa27be7ba9fe5180ebbd1ec551e4a3}{evas\+\_\+async\+\_\+events\+\_\+process} (void)
\begin{DoxyCompactList}\small\item\em Trigger the processing of all events waiting on the file descriptor returned by \hyperlink{group__Evas__Main__Group_ga301c7d776c3d00085659fcf00c52b22d}{evas\+\_\+async\+\_\+events\+\_\+fd\+\_\+get()}. \end{DoxyCompactList}\item 
\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} \hyperlink{group__Evas__Main__Group_gab4dda3c2ef0c587a849935bafea9f66a}{evas\+\_\+async\+\_\+events\+\_\+put} (const void $\ast$target, \hyperlink{Evas__Common_8h_a076b2a9b2de2b2144a4193b1d12ed448}{Evas\+\_\+\+Callback\+\_\+\+Type} type, void $\ast$event\+\_\+info, \hyperlink{Evas__Common_8h_ab3576dd5cab3a57a614a94098a2c4f78}{Evas\+\_\+\+Async\+\_\+\+Events\+\_\+\+Put\+\_\+\+Cb} func)
\begin{DoxyCompactList}\small\item\em Insert asynchronous events on the canvas. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Functions that affect Evas as a whole. 



\subsection{Function Documentation}
\hypertarget{group__Evas__Main__Group_ga65b3f060b6dd9e488afd0b8cbe101869}{}\index{Top Level Functions@{Top Level Functions}!evas\+\_\+init@{evas\+\_\+init}}
\index{evas\+\_\+init@{evas\+\_\+init}!Top Level Functions@{Top Level Functions}}
\subsubsection[{evas\+\_\+init}]{\setlength{\rightskip}{0pt plus 5cm}int evas\+\_\+init (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\label{group__Evas__Main__Group_ga65b3f060b6dd9e488afd0b8cbe101869}


Initialize Evas. 

\begin{DoxyReturn}{Returns}
The init counter value.
\end{DoxyReturn}
This function initializes Evas and increments a counter of the number of calls to it. It returns the new counter\textquotesingle{}s value.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__Evas__Main__Group_ga95a8864f81d944a92bb012b77ffd1b09}{evas\+\_\+shutdown()}.
\end{DoxySeeAlso}
Most E\+F\+L users wouldn\textquotesingle{}t be using this function directly, because they wouldn\textquotesingle{}t access Evas directly by themselves. Instead, they would be using higher level helpers, like {\ttfamily \hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\+\_\+evas\+\_\+init()}}. See \hyperlink{group__Ecore}{Ecore}.

You should be using this if your use is something like the following. The buffer engine is just one of the many ones Evas provides.

 
\begin{DoxyCodeInclude}
1 int main(void)
2 \{
3    Evas *canvas;
4    Evas\_Object *bg, *r1, *r2, *r3;
5 
6    evas\_init();
7 
8    // create your canvas
9    // NOTE: consider using ecore\_evas\_buffer\_new() instead!
10    canvas = create\_canvas(WIDTH, HEIGHT);
11    if (!canvas)
12      return -1;

\end{DoxyCodeInclude}
 And being the canvas creation something like\+: 
\begin{DoxyCodeInclude}
1 static Evas *create\_canvas(int width, int height)
2 \{
3    Evas *canvas;
4    Evas\_Engine\_Info\_Buffer *einfo;
5    int method;
6    void *pixels;
7 
8    method = evas\_render\_method\_lookup("buffer");
9    if (method <= 0)
10      \{
11         fputs("ERROR: evas was not compiled with 'buffer' engine!\(\backslash\)n", stderr);
12         return NULL;
13      \}
14 
15    canvas = evas\_new();
16    if (!canvas)
17      \{
18         fputs("ERROR: could not instantiate new evas canvas.\(\backslash\)n", stderr);
19         return NULL;
20      \}
21 
22    evas\_output\_method\_set(canvas, method);
23    evas\_output\_size\_set(canvas, width, height);
24    evas\_output\_viewport\_set(canvas, 0, 0, width, height);

\end{DoxyCodeInclude}


Note that this is code creating an Evas canvas with no usage of Ecore helpers at all -- no linkage with Ecore on this scenario, thus. Again, this wouldn\textquotesingle{}t be on Evas common usage for most developers. See the full \hyperlink{Example_Evas_Buffer_Simple}{example}. 

References eet\+\_\+init(), eina\+\_\+init(), eina\+\_\+log\+\_\+domain\+\_\+register(), eina\+\_\+log\+\_\+domain\+\_\+unregister(), E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+E\+R\+R, E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+S\+T\+A\+T\+E\+\_\+\+I\+N\+I\+T, eina\+\_\+log\+\_\+timing(), eina\+\_\+shutdown(), E\+I\+N\+A\+\_\+\+T\+R\+U\+E, evil\+\_\+init(), and evil\+\_\+shutdown().



Referenced by ecore\+\_\+evas\+\_\+init(), edje\+\_\+init(), and ethumb\+\_\+init().

\hypertarget{group__Evas__Main__Group_ga95a8864f81d944a92bb012b77ffd1b09}{}\index{Top Level Functions@{Top Level Functions}!evas\+\_\+shutdown@{evas\+\_\+shutdown}}
\index{evas\+\_\+shutdown@{evas\+\_\+shutdown}!Top Level Functions@{Top Level Functions}}
\subsubsection[{evas\+\_\+shutdown}]{\setlength{\rightskip}{0pt plus 5cm}int evas\+\_\+shutdown (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\label{group__Evas__Main__Group_ga95a8864f81d944a92bb012b77ffd1b09}


Shutdown Evas. 

\begin{DoxyReturn}{Returns}
Evas\textquotesingle{} init counter value.
\end{DoxyReturn}
This function finalizes Evas, decrementing the counter of the number of calls to the function \hyperlink{group__Evas__Main__Group_ga65b3f060b6dd9e488afd0b8cbe101869}{evas\+\_\+init()}. This new value for the counter is returned.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__Evas__Main__Group_ga65b3f060b6dd9e488afd0b8cbe101869}{evas\+\_\+init()}.
\end{DoxySeeAlso}
If you were the sole user of Evas, by means of \hyperlink{group__Evas__Main__Group_ga65b3f060b6dd9e488afd0b8cbe101869}{evas\+\_\+init()}, you can check if it\textquotesingle{}s being properly shut down by expecting a return value of 0.

Example code follows.  
\begin{DoxyCodeInclude}
1    // NOTE: use ecore\_evas\_buffer\_new() and here ecore\_evas\_free()
2    destroy\_canvas(canvas);
3 
4    evas\_shutdown();

\end{DoxyCodeInclude}
 Where that function would contain\+: 
\begin{DoxyCodeInclude}
1         evas\_free(canvas);

\end{DoxyCodeInclude}


Most users would be using \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\+\_\+evas\+\_\+shutdown()} instead, like told in \hyperlink{group__Evas__Main__Group_ga65b3f060b6dd9e488afd0b8cbe101869}{evas\+\_\+init()}. See the full \hyperlink{Example_Evas_Buffer_Simple}{example}. 

References eet\+\_\+shutdown(), eina\+\_\+cow\+\_\+del(), eina\+\_\+log\+\_\+domain\+\_\+unregister(), E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+E\+R\+R, E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+S\+T\+A\+T\+E\+\_\+\+S\+H\+U\+T\+D\+O\+W\+N, eina\+\_\+log\+\_\+timing(), eina\+\_\+shutdown(), evas\+\_\+font\+\_\+path\+\_\+global\+\_\+clear(), and evil\+\_\+shutdown().



Referenced by ecore\+\_\+evas\+\_\+init(), ecore\+\_\+evas\+\_\+shutdown(), and ethumb\+\_\+shutdown().

\hypertarget{group__Evas__Main__Group_gacfae4f589c777003f58d51e502c52835}{}\index{Top Level Functions@{Top Level Functions}!evas\+\_\+alloc\+\_\+error@{evas\+\_\+alloc\+\_\+error}}
\index{evas\+\_\+alloc\+\_\+error@{evas\+\_\+alloc\+\_\+error}!Top Level Functions@{Top Level Functions}}
\subsubsection[{evas\+\_\+alloc\+\_\+error}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Evas\+\_\+\+Alloc\+\_\+\+Error} evas\+\_\+alloc\+\_\+error (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\label{group__Evas__Main__Group_gacfae4f589c777003f58d51e502c52835}


Return if any allocation errors have occurred during the prior function. 

\begin{DoxyReturn}{Returns}
The allocation error flag
\end{DoxyReturn}
This function will return if any memory allocation errors occurred during, and what kind they were. The return value will be one of E\+V\+A\+S\+\_\+\+A\+L\+L\+O\+C\+\_\+\+E\+R\+R\+O\+R\+\_\+\+N\+O\+N\+E, E\+V\+A\+S\+\_\+\+A\+L\+L\+O\+C\+\_\+\+E\+R\+R\+O\+R\+\_\+\+F\+A\+T\+A\+L or E\+V\+A\+S\+\_\+\+A\+L\+L\+O\+C\+\_\+\+E\+R\+R\+O\+R\+\_\+\+R\+E\+C\+O\+V\+E\+R\+E\+D with each meaning something different.

E\+V\+A\+S\+\_\+\+A\+L\+L\+O\+C\+\_\+\+E\+R\+R\+O\+R\+\_\+\+N\+O\+N\+E means that no errors occurred at all and the function worked as expected.

E\+V\+A\+S\+\_\+\+A\+L\+L\+O\+C\+\_\+\+E\+R\+R\+O\+R\+\_\+\+F\+A\+T\+A\+L means the function was completely unable to perform its job and will have exited as cleanly as possible. The programmer should consider this as a sign of very low memory and should try and safely recover from the prior functions failure (or try free up memory elsewhere and try again after more memory is freed).

E\+V\+A\+S\+\_\+\+A\+L\+L\+O\+C\+\_\+\+E\+R\+R\+O\+R\+\_\+\+R\+E\+C\+O\+V\+E\+R\+E\+D means that an allocation error occurred, but was recovered from by evas finding memory of its own it has allocated and freeing what it sees as not really usefully allocated memory. What is freed may vary. Evas may reduce the resolution of images, free cached images or fonts, throw out pre-\/rendered data, reduce the complexity of change lists etc. Evas and the program will function as per normal after this, but this is a sign of low memory, and it is suggested that the program try and identify memory it doesn\textquotesingle{}t need, and free it.

Example\+: 
\begin{DoxyCode}
1 extern Evas\_Object *object;
2 void callback (void *data, Evas *e, Evas\_Object *obj, void *event\_info);
3 
4 evas\_object\_event\_callback\_add(object, EVAS\_CALLBACK\_MOUSE\_DOWN, callback, NULL);
5 if (evas\_alloc\_error() == EVAS\_ALLOC\_ERROR\_FATAL)
6   \{
7     fprintf(stderr, "ERROR: Completely unable to attach callback. Must\(\backslash\)n");
8     fprintf(stderr, "       destroy object now as it cannot be used.\(\backslash\)n");
9     evas\_object\_del(object);
10     object = NULL;
11     fprintf(stderr, "WARNING: Memory is really low. Cleaning out RAM.\(\backslash\)n");
12     my\_memory\_cleanup();
13   \}
14 if (evas\_alloc\_error() == EVAS\_ALLOC\_ERROR\_RECOVERED)
15   \{
16     fprintf(stderr, "WARNING: Memory is really low. Cleaning out RAM.\(\backslash\)n");
17     my\_memory\_cleanup();
18   \}
\end{DoxyCode}
 \begin{Desc}
\item[Examples\+: ]\par
\hyperlink{evas-events_8c-example}{evas-\/events.\+c}.\end{Desc}
\hypertarget{group__Evas__Main__Group_ga301c7d776c3d00085659fcf00c52b22d}{}\index{Top Level Functions@{Top Level Functions}!evas\+\_\+async\+\_\+events\+\_\+fd\+\_\+get@{evas\+\_\+async\+\_\+events\+\_\+fd\+\_\+get}}
\index{evas\+\_\+async\+\_\+events\+\_\+fd\+\_\+get@{evas\+\_\+async\+\_\+events\+\_\+fd\+\_\+get}!Top Level Functions@{Top Level Functions}}
\subsubsection[{evas\+\_\+async\+\_\+events\+\_\+fd\+\_\+get}]{\setlength{\rightskip}{0pt plus 5cm}int evas\+\_\+async\+\_\+events\+\_\+fd\+\_\+get (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\label{group__Evas__Main__Group_ga301c7d776c3d00085659fcf00c52b22d}


Get evas\textquotesingle{} internal asynchronous events read file descriptor. 

\begin{DoxyReturn}{Returns}
The canvas\textquotesingle{} asynchronous events read file descriptor.
\end{DoxyReturn}
Evas\textquotesingle{} asynchronous events are meant to be dealt with internally, i. e., when building stuff to be glued together into the E\+F\+L infrastructure -- a module, for example. The context which demands its use is when calculations need to be done out of the main thread, asynchronously, and some action must be performed after that.

An example of actual use of this A\+P\+I is for image asynchronous preload inside evas. If the canvas was instantiated through ecore-\/evas usage, ecore itself will take care of calling those events\textquotesingle{} processing.

This function returns the read file descriptor where to get the asynchronous events of the canvas. Naturally, other mainloops, apart from ecore, may make use of it. 

Referenced by ecore\+\_\+evas\+\_\+init().

\hypertarget{group__Evas__Main__Group_ga80fa27be7ba9fe5180ebbd1ec551e4a3}{}\index{Top Level Functions@{Top Level Functions}!evas\+\_\+async\+\_\+events\+\_\+process@{evas\+\_\+async\+\_\+events\+\_\+process}}
\index{evas\+\_\+async\+\_\+events\+\_\+process@{evas\+\_\+async\+\_\+events\+\_\+process}!Top Level Functions@{Top Level Functions}}
\subsubsection[{evas\+\_\+async\+\_\+events\+\_\+process}]{\setlength{\rightskip}{0pt plus 5cm}int evas\+\_\+async\+\_\+events\+\_\+process (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}\label{group__Evas__Main__Group_ga80fa27be7ba9fe5180ebbd1ec551e4a3}


Trigger the processing of all events waiting on the file descriptor returned by \hyperlink{group__Evas__Main__Group_ga301c7d776c3d00085659fcf00c52b22d}{evas\+\_\+async\+\_\+events\+\_\+fd\+\_\+get()}. 

\begin{DoxyReturn}{Returns}
The number of events processed.
\end{DoxyReturn}
All asynchronous events queued up by \hyperlink{group__Evas__Main__Group_gab4dda3c2ef0c587a849935bafea9f66a}{evas\+\_\+async\+\_\+events\+\_\+put()} are processed here. More precisely, the callback functions, informed together with other event parameters, when queued, get called (with those parameters), in that order. \hypertarget{group__Evas__Main__Group_gab4dda3c2ef0c587a849935bafea9f66a}{}\index{Top Level Functions@{Top Level Functions}!evas\+\_\+async\+\_\+events\+\_\+put@{evas\+\_\+async\+\_\+events\+\_\+put}}
\index{evas\+\_\+async\+\_\+events\+\_\+put@{evas\+\_\+async\+\_\+events\+\_\+put}!Top Level Functions@{Top Level Functions}}
\subsubsection[{evas\+\_\+async\+\_\+events\+\_\+put}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Eina\+\_\+\+Bool} evas\+\_\+async\+\_\+events\+\_\+put (
\begin{DoxyParamCaption}
\item[{const void $\ast$}]{target, }
\item[{{\bf Evas\+\_\+\+Callback\+\_\+\+Type}}]{type, }
\item[{void $\ast$}]{event\+\_\+info, }
\item[{{\bf Evas\+\_\+\+Async\+\_\+\+Events\+\_\+\+Put\+\_\+\+Cb}}]{func}
\end{DoxyParamCaption}
)}\label{group__Evas__Main__Group_gab4dda3c2ef0c587a849935bafea9f66a}


Insert asynchronous events on the canvas. 


\begin{DoxyParams}{Parameters}
{\em target} & The target to be affected by the events. \\
\hline
{\em type} & The type of callback function. \\
\hline
{\em event\+\_\+info} & Information about the event. \\
\hline
{\em func} & The callback function pointer.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
E\+I\+N\+A\+\_\+\+F\+A\+L\+S\+E if an error occured, E\+I\+N\+A\+\_\+\+T\+R\+U\+E otherwise.
\end{DoxyReturn}
This is the way, for a routine running outside evas\textquotesingle{} main thread, to report an asynchronous event. A callback function is informed, whose call is to happen after \hyperlink{group__Evas__Main__Group_ga80fa27be7ba9fe5180ebbd1ec551e4a3}{evas\+\_\+async\+\_\+events\+\_\+process()} is called. 

References E\+I\+N\+A\+\_\+\+F\+A\+L\+S\+E, eina\+\_\+inarray\+\_\+grow(), eina\+\_\+spinlock\+\_\+release(), eina\+\_\+spinlock\+\_\+take(), E\+I\+N\+A\+\_\+\+T\+R\+U\+E, and \+\_\+\+Eina\+\_\+\+Inarray\+::len.

