\begin{DoxyDate}{Date}
2000 (created)
\end{DoxyDate}
\hypertarget{evas_main_evas_toc}{}\doxysection{Table of Contents}\label{evas_main_evas_toc}
\begin{DoxyItemize}
\item \mbox{\hyperlink{evas_main_evas_main_intro}{Introduction}} \item \mbox{\hyperlink{evas_main_evas_main_work}{How does Evas work?}} \item \mbox{\hyperlink{evas_main_evas_main_compiling}{How to compile the library}} \item \mbox{\hyperlink{evas_main_evas_main_next_steps}{Recommended reading}} \item \mbox{\hyperlink{evas_main_evas_main_intro_example}{Introductory Example}}\end{DoxyItemize}
\hypertarget{evas_main_evas_main_intro}{}\doxysection{Introduction}\label{evas_main_evas_main_intro}
Evas is a clean display canvas API for several target display systems that can draw anti-\/aliased text, smooth super-\/ and sub-\/sampled scaled images, alpha-\/blend objects and more.

It abstracts the graphics drawing characteristics of the display system by implementing a canvas where graphical objects can be created, manipulated, and modified. It then handles the rendering pipeline in an optimal way for the underlying device in order to minimize redraws, via a programmatically efficient API.

A design goal for the system is to run well at both small and large scale, and be portable from embedded systems to multi-\/\+CPU workstations. Architecturally, this is achieved via \textquotesingle{}backends\textquotesingle{} that provide the specialized display logic for specific devices. As well, there are various compile options to exclude feature support not required for a target platform to help minimize disk and memory requirements.

Evas can serve as a base for widget sets or toolkits (e.\+g. \mbox{\hyperlink{elementary_main}{Elementary}}) by handling pixel drawing and regional change reporting, but does not manage windows itself, nor deal with input or window update event propagation. In other words, it is intended for use in drawing scrollbars, sliders, and push buttons but not for high-\/level logic of how the widget operates and behaves. Under Enlightenment, window and widget management is handled by other software components, including \mbox{\hyperlink{group__Ecore}{Ecore}} (see \mbox{\hyperlink{group__Ecore__Evas__Group}{Ecore\+\_\+\+Evas wrapper/helper set of functions}} in particular); however Evas is designed to not be dependent on any particular main loop architecture, and also strives to be input and output system agnostic.

Evas can be seen as a display system that stands somewhere between a widget set and an immediate mode display system. It retains basic display logic, but does very little high-\/level logic such as scrollbars, sliders, and push buttons.\hypertarget{evas_main_evas_main_work}{}\doxysection{How does Evas work?}\label{evas_main_evas_main_work}
The Evas canvas is a \textquotesingle{}retained mode\textquotesingle{} renderer, which differs from the more traditional \textquotesingle{}immediate mode\textquotesingle{} display and windowing systems by tracking drawing state information of its contained objects.

In an immediate mode rendering system, each frame is drawn from scratch by having each drawing element redraw itself. Once the commands are executed, the display system blits the frame to the screen but has no idea how to reproduce the image again, so the application has to run through the same sequence of drawing commands again. Very little or no state is kept from one frame draw to the next; while this is simple it forces each application to manually optimize their graphics code.

With retained mode systems like Evas, the application does not need to implement the display rendering code and associated logic, but merely updates the list of objects maintained in the canvas. Evas is then able to optimize the processing and rendering of the visible elements, and is better able to avoid redraws due to occlusion or opacity.

Evas is a structural system in which the programmer creates and manages display objects and their properties, and as a result of this higher level state management, the canvas is able to redraw the set of objects when needed to represent the current state of the canvas.

For example, consider the pseudo code\+:

\begin{DoxyVerb}line_handle = create_line();
set line_handle from position (0, 0) to position (100, 200);
show line_handle;

rectangle_handle = create_rectangle();
move rectangle_handle to position (10, 30);
resize rectangle_handle to size 40 x 470;
show rectangle_handle;

bitmap_handle = create_bitmap();
scale bitmap_handle to size 100 x 100;
move bitmap_handle to position (10, 30);
show bitmap_handle;

render scene;
\end{DoxyVerb}


By expressing the drawing as a set of drawable objects, Evas is able to internally handle refreshing, updating, moving, resizing, showing, and hiding the objects, and to determine to most efficiently redraw the canvas and its contents to reflect the current state. This permits the application to focus on the higher level logic, which both reduces the amount of coding and allows a more natural way of dealing with the display. Importantly, abstracting the display logic like this also simplifies porting the application to different display systems, since its own code is less tied into how that system works.\hypertarget{evas_main_evas_main_compiling}{}\doxysection{How to compile the library}\label{evas_main_evas_main_compiling}
Evas compiles automatically within EFL\textquotesingle{}s build system, and is automatically linked with \mbox{\hyperlink{group__Ecore}{Ecore}} and other components that need it. But it can also be built and used standalone, by compiling and linking your application with the compiler flags indicated by {\ttfamily pkg-\/config}. For example\+:

\begin{DoxyVerb}gcc -c -o my_main.o my_main.c `pkg-config --cflags evas`

gcc -o my_application my_main.o `pkg-config --libs evas`
\end{DoxyVerb}


See \mbox{\hyperlink{pkgconfig}{pkgconfig}}\hypertarget{evas_main_evas_main_next_steps}{}\doxysection{Recommended reading}\label{evas_main_evas_main_next_steps}
\begin{DoxyItemize}
\item \mbox{\hyperlink{group__Ecore}{Ecore}}, \mbox{\hyperlink{group__Edje}{Edje}}, and \mbox{\hyperlink{group__Elementary}{Elementary}} that provide higher level infrastructure and components for real world usage. \item \mbox{\hyperlink{group__Evas__Object__Group}{Generic Object Functions}} for how to manipulate generic objects on an Evas canvas and handle the associated events. \item \mbox{\hyperlink{group__Evas__Object__Rectangle}{Rectangle Object Functions}}, to learn about the most basic object type on Evas -- the rectangle. \item \mbox{\hyperlink{group__Evas__Object__Polygon}{Polygon Object Functions}}, to learn how to create polygon elements on the canvas. \item \mbox{\hyperlink{group__Evas__Object__Line__Group}{Line Object Functions}}, to learn how to create line elements on the canvas. \item \mbox{\hyperlink{group__Evas__Object__Image}{Image Object Functions}}, to learn about image objects, over which Evas can do a plethora of operations. \item \mbox{\hyperlink{group__Evas__Object__Text__Group}{Text Object Functions}}, to learn how to create textual elements on the canvas. \item \mbox{\hyperlink{group__Evas__Object__Textblock__Group}{Textblock Object Functions}}, to learn how to create multiline textual elements on the canvas.\end{DoxyItemize}
\begin{DoxyItemize}
\item \mbox{\hyperlink{group__Evas__Smart__Object__Group}{Smart Object Functions}} and \mbox{\hyperlink{group__Evas__Smart__Group}{Smart Functions}}, to define new objects that provide {\bfseries{custom}} functions to handle clipping, hiding, moving, resizing, color setting and more. This includes simple grouping of objects that move together (see \mbox{\hyperlink{group__Evas__Smart__Object__Clipped}{Clipped Smart Object}}) and more complex widget-\/like intelligent behaviors such as buttons and check boxes.\end{DoxyItemize}
\hypertarget{evas_main_evas_main_intro_example}{}\doxysection{Introductory Example}\label{evas_main_evas_main_intro_example}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Evas.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Evas\_Engine\_Buffer.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <errno.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define WIDTH (320)}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define HEIGHT (240)}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *create\_canvas(\textcolor{keywordtype}{int} width, \textcolor{keywordtype}{int} height);}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void} destroy\_canvas(\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *canvas);}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void} draw\_scene(\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *canvas);}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void} save\_scene(\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *canvas, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *dest);}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int} main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *canvas;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *bg, *r1, *r2, *r3;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Main__Group_gaa617071d85a52779e950e5b1d8c354e3}{evas\_init}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* After turning Evas on, we create an Evas canvas to work in.}}
\DoxyCodeLine{\textcolor{comment}{    * Canvases are graphical workspaces used for placing and organizing}}
\DoxyCodeLine{\textcolor{comment}{    * graphical objects.  Normally we'd be using Ecore-\/Evas to create}}
\DoxyCodeLine{\textcolor{comment}{    * the canvas, but for this example we'll hide the details in a}}
\DoxyCodeLine{\textcolor{comment}{    * separate routine for convenience.}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   canvas = create\_canvas(WIDTH, HEIGHT);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!canvas)}
\DoxyCodeLine{     \textcolor{keywordflow}{return} -\/1;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Next set the background to solid white.  This is typically done by}}
\DoxyCodeLine{\textcolor{comment}{    * creating a rectangle sized to the canvas, placed at the canvas}}
\DoxyCodeLine{\textcolor{comment}{    * origin.}}
\DoxyCodeLine{\textcolor{comment}{    *}}
\DoxyCodeLine{\textcolor{comment}{    * Note that if the canvas were to change size, our background}}
\DoxyCodeLine{\textcolor{comment}{    * rectangle will not automatically resize itself; we'd need to do}}
\DoxyCodeLine{\textcolor{comment}{    * that manually with another evas\_object\_resize() call.  In a real}}
\DoxyCodeLine{\textcolor{comment}{    * application using Ecore-\/Evas, functionality in Ecore will take}}
\DoxyCodeLine{\textcolor{comment}{    * care of resizing things.  For this example, we'll just keep the}}
\DoxyCodeLine{\textcolor{comment}{    * canvas dimensions fixed to avoid the problem.}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   bg = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(bg, 255, 255, 255, 255); \textcolor{comment}{// white bg, no transparency}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(bg, 0, 0);                    \textcolor{comment}{// at origin}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(bg, WIDTH, HEIGHT);         \textcolor{comment}{// covers full canvas}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bg);}
\DoxyCodeLine{}
\DoxyCodeLine{   puts(\textcolor{stringliteral}{"{}initial scene, with just background:"{}});}
\DoxyCodeLine{   draw\_scene(canvas);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* To make the scene interesting let's add a few more rectangles of}}
\DoxyCodeLine{\textcolor{comment}{    * various sizes and colors, starting with a big red one.}}
\DoxyCodeLine{\textcolor{comment}{    *}}
\DoxyCodeLine{\textcolor{comment}{    * By default all Evas objects are created in a 'hidden' state,}}
\DoxyCodeLine{\textcolor{comment}{    * meaning they are not visible, won't be checked for changes during}}
\DoxyCodeLine{\textcolor{comment}{    * canvas rendering, and won't receive input events.  Thus, like we}}
\DoxyCodeLine{\textcolor{comment}{    * did for the background object we must call evas\_object\_show() to}}
\DoxyCodeLine{\textcolor{comment}{    * make our graphics objects usable.}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   r1 = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(r1, 255, 0, 0, 255); \textcolor{comment}{// 100\% opaque red}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(r1, 10, 10);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(r1, 100, 100);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(r1);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Let's add a partly transparent rectangle on top of the red one.}}
\DoxyCodeLine{\textcolor{comment}{    *}}
\DoxyCodeLine{\textcolor{comment}{    * Graphics objects are treated as a stack in the canvas for drawing}}
\DoxyCodeLine{\textcolor{comment}{    * purposes, so subsequent objects are drawn above the ones we've}}
\DoxyCodeLine{\textcolor{comment}{    * already added to the canvas.  This is important in objects that}}
\DoxyCodeLine{\textcolor{comment}{    * have partially transparent fill coloring since we'll see part of}}
\DoxyCodeLine{\textcolor{comment}{    * what's "{}behind"{} our object.}}
\DoxyCodeLine{\textcolor{comment}{    *}}
\DoxyCodeLine{\textcolor{comment}{    * In Evas, color values are pre-\/multiplied by their alpha.  This means}}
\DoxyCodeLine{\textcolor{comment}{    * that if we want a green rectangle that's half transparent, we'd have:}}
\DoxyCodeLine{\textcolor{comment}{    *}}
\DoxyCodeLine{\textcolor{comment}{    * non-\/premul: r=0, g=255, b=0    a=128 (50\% alpha)}}
\DoxyCodeLine{\textcolor{comment}{    * premul:}}
\DoxyCodeLine{\textcolor{comment}{    *         r\_premul = r * a / 255 =      0 * 128 / 255 =      0}}
\DoxyCodeLine{\textcolor{comment}{    *         g\_premul = g * a / 255 =    255 * 128 / 255 =    128}}
\DoxyCodeLine{\textcolor{comment}{    *         b\_premul = b * a / 255 =      0 * 128 / 255 =      0}}
\DoxyCodeLine{\textcolor{comment}{    *}}
\DoxyCodeLine{\textcolor{comment}{    * Since we're placing our half transparent green rectangle on top of}}
\DoxyCodeLine{\textcolor{comment}{    * a red one, in the final output we will actually see a yellow square}}
\DoxyCodeLine{\textcolor{comment}{    * (since in RGBA color green + red = yellow).}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   r2 = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(r2, 0, 128, 0, 128); \textcolor{comment}{// 50\% opaque green}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(r2, 10, 10);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(r2, 50, 50);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(r2);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Lastly, for comparison add a dark green rectangle with no}}
\DoxyCodeLine{\textcolor{comment}{    * transparency. */}}
\DoxyCodeLine{   r3 = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(r3, 0, 128, 0, 255); \textcolor{comment}{// 100\% opaque dark green}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(r3, 60, 60);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(r3, 50, 50);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(r3);}
\DoxyCodeLine{}
\DoxyCodeLine{   puts(\textcolor{stringliteral}{"{}final scene (note updates):"{}});}
\DoxyCodeLine{   draw\_scene(canvas);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* In addition to displaying the canvas to the screen, let's also}}
\DoxyCodeLine{\textcolor{comment}{    * output the buffer to a graphics file, for comparison.  Evas}}
\DoxyCodeLine{\textcolor{comment}{    * supports a range of graphics file formats, but PPM is particularly}}
\DoxyCodeLine{\textcolor{comment}{    * trivial to write, so our save\_scene routine will output as PPM.}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   save\_scene(canvas, \textcolor{stringliteral}{"{}/tmp/evas-\/buffer-\/simple-\/render.ppm"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{   destroy\_canvas(canvas);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Main__Group_gadb9d1c9f3fcff94cea89e12942c40919}{evas\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{/* Convenience routine to allocate and initialize the canvas.}}
\DoxyCodeLine{\textcolor{comment}{ * In a real application we'd be using ecore\_evas\_buffer\_new() instead.}}
\DoxyCodeLine{\textcolor{comment}{ */}}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *create\_canvas(\textcolor{keywordtype}{int} width, \textcolor{keywordtype}{int} height)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *canvas;}
\DoxyCodeLine{   Evas\_Engine\_Info\_Buffer *einfo;}
\DoxyCodeLine{   \textcolor{keywordtype}{int} method;}
\DoxyCodeLine{   \textcolor{keywordtype}{void} *pixels;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Request a handle for the 'buffer' type of rendering engine. */}}
\DoxyCodeLine{   method = \mbox{\hyperlink{group__Evas__Output__Method_gae83ae2b11ce27503751a13ba44253564}{evas\_render\_method\_lookup}}(\textcolor{stringliteral}{"{}buffer"{}});}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (method <= 0)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fputs(\textcolor{stringliteral}{"{}ERROR: evas was not compiled with 'buffer' engine!\(\backslash\)n"{}}, stderr);}
\DoxyCodeLine{        \textcolor{keywordflow}{return} NULL;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Create a general canvas object.}}
\DoxyCodeLine{\textcolor{comment}{    * Note that we are responsible for freeing the canvas when we're done. */}}
\DoxyCodeLine{   canvas = \mbox{\hyperlink{group__Evas__Canvas_gaff177702a6d5dd364896269a4a81822d}{evas\_new}}();}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!canvas)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fputs(\textcolor{stringliteral}{"{}ERROR: could not instantiate new evas canvas.\(\backslash\)n"{}}, stderr);}
\DoxyCodeLine{        \textcolor{keywordflow}{return} NULL;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Specify that the canvas will be rendering using the buffer engine method.}}
\DoxyCodeLine{\textcolor{comment}{    * We also size the canvas and viewport to the same width and height, with}}
\DoxyCodeLine{\textcolor{comment}{    * the viewport set to the origin of the canvas.}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga9335e65d48b48b0b29408bf580071edd}{evas\_output\_method\_set}}(canvas, method);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_gad8f0d6296332695b74022ea581c519e7}{evas\_output\_size\_set}}(canvas, width, height);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_gaf7502c7443033ea5fba75df5dd8b16c1}{evas\_output\_viewport\_set}}(canvas, 0, 0, width, height);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Before we can use the engine, we *must* set its configuration}}
\DoxyCodeLine{\textcolor{comment}{    * parameters.  The available parameters are kept in a struct}}
\DoxyCodeLine{\textcolor{comment}{    * named Evas\_Engine\_Info which is internal to Evas.  Thus to set}}
\DoxyCodeLine{\textcolor{comment}{    * parameters we must first request the current info object from}}
\DoxyCodeLine{\textcolor{comment}{    * our canvas:}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   einfo = (Evas\_Engine\_Info\_Buffer *)\mbox{\hyperlink{group__Evas__Canvas_ga1fd811b76d7e2f3a6a12ed198156afa3}{evas\_engine\_info\_get}}(canvas);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!einfo)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fputs(\textcolor{stringliteral}{"{}ERROR: could not get evas engine info!\(\backslash\)n"{}}, stderr);}
\DoxyCodeLine{        \mbox{\hyperlink{group__Evas__Canvas_ga441113f8898f46a94c2f44f254de0819}{evas\_free}}(canvas);}
\DoxyCodeLine{        \textcolor{keywordflow}{return} NULL;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Create the underlying data buffer that our canvas will use.  This}}
\DoxyCodeLine{\textcolor{comment}{    * is a simple array of ARGB32 pixels.  Each color component}}
\DoxyCodeLine{\textcolor{comment}{    * (including alpha) is one byte, resulting in 4 bytes per pixel (or}}
\DoxyCodeLine{\textcolor{comment}{    * 32 bits).  We can thus store each pixel in an integer data type,}}
\DoxyCodeLine{\textcolor{comment}{    * thus calculating our data buffer as W x H x sizeof(int) bytes in}}
\DoxyCodeLine{\textcolor{comment}{    * length.}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   pixels = malloc(width * height * \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{int}));}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!pixels)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fputs(\textcolor{stringliteral}{"{}ERROR: could not allocate canvas pixels!\(\backslash\)n"{}}, stderr);}
\DoxyCodeLine{        \mbox{\hyperlink{group__Evas__Canvas_ga441113f8898f46a94c2f44f254de0819}{evas\_free}}(canvas);}
\DoxyCodeLine{        \textcolor{keywordflow}{return} NULL;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Next set the various configuration parameters.  We}}
\DoxyCodeLine{\textcolor{comment}{    * register the pixel buffer that the canvas will use,}}
\DoxyCodeLine{\textcolor{comment}{    * indicate the pixel format as ARGB32, and the size of}}
\DoxyCodeLine{\textcolor{comment}{    * each row of data. */}}
\DoxyCodeLine{   einfo-\/>info.depth\_type = EVAS\_ENGINE\_BUFFER\_DEPTH\_ARGB32;}
\DoxyCodeLine{   einfo-\/>info.dest\_buffer = pixels;}
\DoxyCodeLine{   einfo-\/>info.dest\_buffer\_row\_bytes = width * \textcolor{keyword}{sizeof}(int);}
\DoxyCodeLine{   einfo-\/>info.use\_color\_key = 0;}
\DoxyCodeLine{   einfo-\/>info.alpha\_threshold = 0;}
\DoxyCodeLine{   einfo-\/>info.func.new\_update\_region = NULL;}
\DoxyCodeLine{   einfo-\/>info.func.free\_update\_region = NULL;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Finally, we configure the canvas with our chosen parameters. */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_gaf3efb2e687b20b3ba6df18151558b16c}{evas\_engine\_info\_set}}(canvas, (\mbox{\hyperlink{struct__Evas__Engine__Info}{Evas\_Engine\_Info}} *)einfo);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} canvas;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{/* Convenience routine to shut down the canvas.}}
\DoxyCodeLine{\textcolor{comment}{ * In a real application we'd be using ecore\_evas\_free() instead}}
\DoxyCodeLine{\textcolor{comment}{ */}}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void} destroy\_canvas(\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *canvas)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   Evas\_Engine\_Info\_Buffer *einfo;}
\DoxyCodeLine{}
\DoxyCodeLine{   einfo = (Evas\_Engine\_Info\_Buffer *)\mbox{\hyperlink{group__Evas__Canvas_ga1fd811b76d7e2f3a6a12ed198156afa3}{evas\_engine\_info\_get}}(canvas);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!einfo)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fputs(\textcolor{stringliteral}{"{}ERROR: could not get evas engine info!\(\backslash\)n"{}}, stderr);}
\DoxyCodeLine{        \mbox{\hyperlink{group__Evas__Canvas_ga441113f8898f46a94c2f44f254de0819}{evas\_free}}(canvas);}
\DoxyCodeLine{        \textcolor{keywordflow}{return};}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Free the data buffer we allocated in create\_buffer() */}}
\DoxyCodeLine{   free(einfo-\/>info.dest\_buffer);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Finally, free the canvas itself. */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga441113f8898f46a94c2f44f254de0819}{evas\_free}}(canvas);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{/* Convenience routine to update the scene.}}
\DoxyCodeLine{\textcolor{comment}{ * In a real application Ecore Evas would be doing this for us.}}
\DoxyCodeLine{\textcolor{comment}{ */}}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void} draw\_scene(\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *canvas)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *updates, *n;}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__Rectangle}{Eina\_Rectangle}} *update;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Render the canvas, and get a list of the updated rectangles. */}}
\DoxyCodeLine{   updates = \mbox{\hyperlink{group__Evas__Canvas_ga3946287d9b1d06f27826f73aea58f9be}{evas\_render\_updates}}(canvas);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Just for informative purposes, print out the areas being updated: */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(updates, n, update)}
\DoxyCodeLine{     printf(\textcolor{stringliteral}{"{}UPDATED REGION: pos: \%3d, \%3d    size: \%3dx\%3d\(\backslash\)n"{}},}
\DoxyCodeLine{            update-\/>\mbox{\hyperlink{struct__Eina__Rectangle_a8358c0791dcf476432687510ca4e5d5c}{x}}, update-\/>\mbox{\hyperlink{struct__Eina__Rectangle_ae74dc834fb71a1f4cd9e3fe11dec3940}{y}}, update-\/>\mbox{\hyperlink{struct__Eina__Rectangle_af6a92d51ec25ee3464c81297ffc3a330}{w}}, update-\/>\mbox{\hyperlink{struct__Eina__Rectangle_a7570ed17f58fc94be997414a86130074}{h}});}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Free the list of update rectangles */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga538ed406dfa68641867cbde42dade5f7}{evas\_render\_updates\_free}}(updates);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{/* Output the canvas buffer to a Portable Pixel Map (PPM) file */}}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void} save\_scene(\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *canvas, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *dest)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   Evas\_Engine\_Info\_Buffer *einfo;}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} *pixels, *pixels\_end;}
\DoxyCodeLine{   \textcolor{keywordtype}{int} width, height;}
\DoxyCodeLine{   FILE *f;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Retrieve the current data buffer. */}}
\DoxyCodeLine{   einfo = (Evas\_Engine\_Info\_Buffer *)\mbox{\hyperlink{group__Evas__Canvas_ga1fd811b76d7e2f3a6a12ed198156afa3}{evas\_engine\_info\_get}}(canvas);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!einfo)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fputs(\textcolor{stringliteral}{"{}ERROR: could not get evas engine info!\(\backslash\)n"{}}, stderr);}
\DoxyCodeLine{        \textcolor{keywordflow}{return};}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Retrieve the canvas dimensions */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga9db9974a647850d7bd49afb506c9717a}{evas\_output\_size\_get}}(canvas, \&width, \&height);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Open our output PPM file for writing */}}
\DoxyCodeLine{   f = fopen(dest, \textcolor{stringliteral}{"{}wb+"{}});}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!f)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fprintf(stderr, \textcolor{stringliteral}{"{}ERROR: could not open for writing '\%s': \%s\(\backslash\)n"{}},}
\DoxyCodeLine{                dest, strerror(errno));}
\DoxyCodeLine{        \textcolor{keywordflow}{return};}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* Write out the pixel data to the PPM file */}}
\DoxyCodeLine{   pixels = einfo-\/>info.dest\_buffer;}
\DoxyCodeLine{   pixels\_end = pixels + (width * height);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* PPM P6 format is dead simple to write.  First we output a magic}}
\DoxyCodeLine{\textcolor{comment}{    * number 'P6' to designate the file as PPM, then the width and}}
\DoxyCodeLine{\textcolor{comment}{    * height on their own line in ASCII decimal, followed by the maximum}}
\DoxyCodeLine{\textcolor{comment}{    * color value (255) on its own line in ASCII decimal, and finally a}}
\DoxyCodeLine{\textcolor{comment}{    * the pixel data in RGB order with each color component written as}}
\DoxyCodeLine{\textcolor{comment}{    * a char (byte).  No alpha information is stored.}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   fprintf(f, \textcolor{stringliteral}{"{}P6\(\backslash\)n\%d \%d\(\backslash\)n255\(\backslash\)n"{}},  width, height);}
\DoxyCodeLine{   \textcolor{keywordflow}{for} (; pixels < pixels\_end; pixels++)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \textcolor{keywordtype}{int} r, g, b;}
\DoxyCodeLine{}
\DoxyCodeLine{        r = ((*pixels) \& 0xff0000) >> 16;}
\DoxyCodeLine{        g = ((*pixels) \& 0x00ff00) >> 8;}
\DoxyCodeLine{        b = (*pixels) \& 0x0000ff;}
\DoxyCodeLine{}
\DoxyCodeLine{        fprintf(f, \textcolor{stringliteral}{"{}\%c\%c\%c"{}}, r, g, b);}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   fclose(f);}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"{}saved scene as '\%s'\(\backslash\)n"{}}, dest);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}


More examples can be found at \mbox{\hyperlink{evas_examples}{Evas Examples}}. 