Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 18b54cd0250a7489168a038c67771391 > files > 100

evas-devel-1.0.1-1.fc16.i686.rpm

<html>
<head>
    <title>Evas: Evas</title>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <meta name="author" content="Andres Blanc" >
    
    <link rel="icon" href="img/favicon.png" type="image/x-icon">
    <link rel="shortcut icon" href="img/favicon.png" type="image/x-icon">
    <link rel="icon" href="img/favicon.png" type="image/ico">
    <link rel="shortcut icon" href="img/favicon.png" type="image/ico">

    <link rel="stylesheet" type="text/css" media="screen" href="e.css">
    <link rel="stylesheet" type="text/css" media="screen" href="edoxy.css">
</head>

<body>

<div id="container">

<div id="header">
<div class="layout">
    
    <h1><span>Enlightenment</span></h1>
    <h2><span>Beauty at your fingertips</span></h2>

    <div class="menu-container">
        <div class="menu">
            <ul>
	        <li class="current"><a href="http://web.enlightenment.org/p.php?p=docs">Docs</a></li>
                <li><a href="http://trac.enlightenment.org/e">Tracker</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=contact">Contact</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=contribute">Contribute</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=support">Support</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=download">Download</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=about">About</a></li>
                <li><a href="http://www.enlightenment.org/p.php?p=news">News</a></li>
                <li><a href="http://www.enlightenment.org/">Home</a></li>
            </ul>
        </div>
    </div>

    <div class="doxytitle">
        Evas Documentation <small>at Thu Jul 14 2011</small>
    </div>

    <div class="menu-container">
        <div class="submenu">
            <ul class="current">
                <li><a href="todo.html">Todo</a></li>
                <li><a href="files.html">Files</a></li>
                <li><a href="annotated.html">Data Structures</a></li>
                <li><a href="globals.html">Globals</a></li>
                <li><a href="modules.html">Modules</a></li>
                <li><a href="pages.html">Related Pages</a></li>
	        <li class="current"><a href="index.html">Main Page</a></li>
            </ul>
        </div>
    </div>


    <div class="clear"></div>
</div>
</div>

<div id="content">
<div class="layout">
<!-- Generated by Doxygen 1.7.4 -->
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Evas </div>  </div>
</div>
<div class="contents">
<div class="textblock"><div class="image">
<img src="e_big.png" alt="e_big.png"/>
</div>
<dl class="version"><dt><b>Version:</b></dt><dd>1.0.1 </dd></dl>
<dl class="author"><dt><b>Author:</b></dt><dd>Carsten Haitzler &lt;raster@rasterman.com&gt; </dd>
<dd>
Till Adam &lt;till@adam-lilienthal.de&gt; </dd>
<dd>
Steve Ireland &lt;sireland@pobox.com&gt; </dd>
<dd>
Brett Nash &lt;nash@nash.id.au&gt; </dd>
<dd>
Tilman Sauerbeck &lt;tilman@code-monkey.de&gt; </dd>
<dd>
Corey Donohoe &lt;atmos@atmos.org&gt; </dd>
<dd>
Yuri Hudobin &lt;glassy_ape@users.sourceforge.net&gt; </dd>
<dd>
Nathan Ingersoll &lt;ningerso@d.umn.edu&gt; </dd>
<dd>
Willem Monsuwe &lt;willem@stack.nl&gt; </dd>
<dd>
Jose O Gonzalez &lt;jose_ogp@juno.com&gt; </dd>
<dd>
Bernhard Nemec &lt;Bernhard.Nemec@viasyshc.com&gt; </dd>
<dd>
Jorge Luis Zapata Muga &lt;jorgeluis.zapata@gmail.com&gt; </dd>
<dd>
Cedric Bail &lt;cedric.bail@free.fr&gt; </dd>
<dd>
Gustavo Sverzut Barbieri &lt;barbieri@profusion.mobi&gt; </dd>
<dd>
Vincent Torri &lt;vtorri@univ-evry.fr&gt; </dd>
<dd>
Tim Horton &lt;hortont424@gmail.com&gt; </dd>
<dd>
Tom Hacohen &lt;tom@stosb.com&gt; </dd>
<dd>
Mathieu Taillefumier &lt;mathieu.taillefumier@free.fr&gt; </dd>
<dd>
Iván Briano &lt;ivan@profusion.mobi&gt; </dd>
<dd>
Gustavo Lima Chaves &lt;glima@profusion.mobi&gt;</dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>2000-2010</dd></dl>
<h2><a class="anchor" id="toc"></a>
Table of Contents</h2>
<ul>
<li><a class="el" href="index.html#intro">What is Evas?</a> </li>
<li><a class="el" href="index.html#work">How does Evas work?</a> </li>
<li><a class="el" href="index.html#compiling">How to compile using Evas ?</a> </li>
<li><a class="el" href="index.html#install">How is it installed?</a> </li>
<li><a class="el" href="index.html#next_steps">Next Steps</a> </li>
<li><a class="el" href="index.html#intro_example">Introductory Example</a></li>
</ul>
<h2><a class="anchor" id="intro"></a>
What is Evas?</h2>
<p>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 much and more.</p>
<p>It abstracts any need to know much about what the characteristics of your display system are or what graphics calls are used to draw them and how. It deals on an object level where all you do is create and manipulate objects in a canvas, set their properties, and the rest is done for you.</p>
<p>Evas optimises the rendering pipeline to minimise effort in redrawing changes made to the canvas and so takes this work out of the programmers hand, saving a lot of time and energy.</p>
<p>It's small and lean, designed to work on embedded systems all the way to large and powerful multi-cpu workstations. It can be compiled to only have the features you need for your target platform if you so wish, thus keeping it small and lean. It has several display back-ends, letting it display on several display systems, making it portable for cross-device and cross-platform development.</p>
<h3><a class="anchor" id="intro_not_evas"></a>
What Evas is not?</h3>
<p>Evas is not a widget set or widget toolkit, however it is their base. See Elementary (<a href="http://docs.enlightenment.org/auto/elementary/">http://docs.enlightenment.org/auto/elementary/</a>) for a toolkit based on Evas, Edje, Ecore and other Enlightenment technologies.</p>
<p>It is not dependent or aware of main loops, input or output systems. Input should be polled from various sources and feed them to Evas. Similarly, it will not create windows or report windows updates to your system, rather just drawing the pixels and reporting to the user the areas that were changed. Of course these operations are quite common and thus they are ready to use in Ecore, particularly in Ecore_Evas (<a href="http://docs.enlightenment.org/auto/ecore/">http://docs.enlightenment.org/auto/ecore/</a>).</p>
<h2><a class="anchor" id="work"></a>
How does Evas work?</h2>
<p>Evas is a canvas display library. This is markedly different from most display and windowing systems as a Canvas is structural and is also a state engine, whereas most display and windowing systems are immediate mode display targets. Evas handles the logic between a structural display via its' state engine, and controls the target windowing system in order to produce rendered results of the current canvases state on the display.</p>
<p>Immediate mode display systems retain very little, or no state. A program will execute a series of commands, as in the pseudo code:</p>
<div class="fragment"><pre class="fragment">
draw line from position (0, 0) to position (100, 200);

draw rectangle from position (10, 30) to position (50, 500);

bitmap_handle = create_bitmap();
scale bitmap_handle to size 100 x 100;
draw image bitmap_handle at position (10, 30);
</pre></div><p>The series of commands is executed by the windowing system and the results are displayed on the screen (normally). Once the commands are executed the display system has little or no idea of how to reproduce this image again, and so has to be instructed by the application how to redraw sections of the screen whenever needed. Each successive command will be executed as instructed by the application and either emulated by software or sent to the graphics hardware on the device to be performed.</p>
<p>The advantage of such a system is that it is simple, and gives a program tight control over how something looks and is drawn. Given the increasing complexity of displays and demands by users to have better looking interfaces, more and more work is needing to be done at this level by the internals of widget sets, custom display widgets and other programs. This means more and more logic and display rendering code needs to be written time and time again, each time the application needs to figure out how to minimise redraws so that display is fast and interactive, and keep track of redraw logic. The power comes at a high-price, lots of extra code and work. Programmers not very familiar with graphics programming will often make mistakes at this level and produce code that is sub optimal. Those familiar with this kind of programming will simply get bored by writing the same code again and again.</p>
<p>For example, if in the above scene, the windowing system requires the application to redraw the area from 0, 0 to 50, 50 (also referred as "expose event"), then the programmer must calculate manually the updates and repaint it again:</p>
<div class="fragment"><pre class="fragment">
Redraw from position (0, 0) to position (50, 50):

// what was in area (0, 0, 50, 50)?

// 1. intersection part of line (0, 0) to (100, 200)?
      draw line from position (0, 0) to position (25, 50);

// 2. intersection part of rectangle (10, 30) to (50, 500)?
      draw rectangle from position (10, 30) to position (50, 50)

// 3. intersection part of image at (10, 30), size 100 x 100?
      bitmap_subimage = subregion from position (0, 0) to position (40, 20)
      draw image bitmap_subimage at position (10, 30);
</pre></div><p>The clever reader might have noticed that, if all elements in the above scene are opaque, then the system is doing useless paints: part of the line is behind the rectangle, and part of the rectangle is behind the image. These useless paints tends to be very costly, as pixels tend to be 4 bytes in size, thus an overlapping region of 100 x 100 pixels is around 40000 useless writes! The developer could write code to calculate the overlapping areas and avoid painting then, but then it should be mixed with the "expose event" handling mentioned above and quickly one realizes the initially simpler method became really complex.</p>
<p>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.</p>
<p>For example, the pseudo code:</p>
<div class="fragment"><pre class="fragment">
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;
</pre></div><p>This may look longer, but when the display needs to be refreshed or updated, the programmer only moves, resizes, shows, hides etc. the objects that they need to change. The programmer simply thinks at the object logic level, and the canvas software does the rest of the work for them, figuring out what actually changed in the canvas since it was last drawn, how to most efficiently redraw he canvas and its contents to reflect the current state, and then it can go off and do the actual drawing of the canvas.</p>
<p>This lets the programmer think in a more natural way when dealing with a display, and saves time and effort of working out how to load and display images, render given the current display system etc. Since Evas also is portable across different display systems, this also gives the programmer the ability to have their code ported and display on different display systems with very little work.</p>
<p>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, push buttons etc.</p>
<h2><a class="anchor" id="compiling"></a>
How to compile using Evas ?</h2>
<p>Evas is a library your application links to. The procedure for this is very simple. You simply have to compile your application with the appropriate compiler flags that the <code>pkg-config</code> script outputs. For example:</p>
<p>Compiling C or C++ files into object files:</p>
<div class="fragment"><pre class="fragment">
gcc -c -o main.o main.c `pkg-config --cflags evas`
</pre></div><p>Linking object files into a binary executable:</p>
<div class="fragment"><pre class="fragment">
gcc -o my_application main.o `pkg-config --libs evas`
</pre></div><p>You simply have to make sure that pkg-config is in your shell's PATH (see the manual page for your appropriate shell) and evas.pc in /usr/lib/pkgconfig or its path is in the PKG_CONFIG_PATH environment variable. It's that simple to link and use Evas once you have written your code to use it.</p>
<p>Since the program is linked to Evas, it is now able to use any advertised API calls to display graphics in a canvas managed by Evas, as well as use the API calls provided to manage data as well.</p>
<p>You should make sure you add any extra compile and link flags to your compile commands that your application may need as well. The above example is only guaranteed to make Evas add it's own requirements.</p>
<h2><a class="anchor" id="install"></a>
How is it installed?</h2>
<p>Simple:</p>
<div class="fragment"><pre class="fragment">
./configure
make
su -
...
make install
</pre></div><h2><a class="anchor" id="next_steps"></a>
Next Steps</h2>
<p>After you understood what Evas is and installed it in your system you should proceed understanding the programming interface for all objects, then see the specific for the most used elements. We'd recommend you to take a while to learn Ecore (<a href="http://docs.enlightenment.org/auto/ecore/">http://docs.enlightenment.org/auto/ecore/</a>) and Edje (<a href="http://docs.enlightenment.org/auto/edje/">http://docs.enlightenment.org/auto/edje/</a>) as they will likely save you tons of work compared to using just Evas directly.</p>
<p>Recommended reading:</p>
<ul>
<li><a class="el" href="group__Evas__Object__Group.html">Generic Object Functions</a> </li>
<li><a class="el" href="group__Evas__Object__Rectangle.html">Rectangle Object Functions</a> </li>
<li><a class="el" href="group__Evas__Object__Image.html">Image Object Functions</a> </li>
<li><a class="el" href="group__Evas__Object__Text.html">Text Object Functions</a> </li>
<li><a class="el" href="group__Evas__Smart__Object__Group.html">Smart Object Functions</a> and <a class="el" href="group__Evas__Smart__Group.html">Smart Functions</a> to define an object that provides custom functions to handle clipping, hiding, moving, resizing, setting the color and more. These could be as simple as a group of objects that move together (see <a class="el" href="group__Evas__Smart__Object__Clipped.html">Clipped Smart Object</a>). These smart objects can implement what ends to be a widget, providing some intelligence (thus the name), like a button or check box.</li>
</ul>
<h2><a class="anchor" id="intro_example"></a>
Introductory Example</h2>
<div class="fragment"><pre class="fragment"><span class="comment">/**</span>
<span class="comment"> * Simple Evas example using the Buffer engine.</span>
<span class="comment"> *</span>
<span class="comment"> * You must have Evas compiled with the buffer engine, and have the</span>
<span class="comment"> * evas-software-buffer pkg-config files installed.</span>
<span class="comment"> *</span>
<span class="comment"> * Compile with:</span>
<span class="comment"> *</span>
<span class="comment"> * @verbatim</span>
<span class="comment"> * gcc -o evas-buffer-simple evas-buffer-simple.c `pkg-config --libs --cflags evas evas-software-buffer`</span>
<span class="comment"> * @endverbatim</span>
<span class="comment"> *</span>
<span class="comment"> */</span>
<span class="preprocessor">#include &lt;<a class="code" href="Evas_8h.html" title="These routines are used for Evas library interaction.">Evas.h</a>&gt;</span>
<span class="preprocessor">#include &lt;Evas_Engine_Buffer.h&gt;</span>
<span class="preprocessor">#include &lt;stdio.h&gt;</span>
<span class="preprocessor">#include &lt;errno.h&gt;</span>

<span class="preprocessor">#define WIDTH (320)</span>
<span class="preprocessor"></span><span class="preprocessor">#define HEIGHT (240)</span>
<span class="preprocessor"></span>
<span class="comment">/*</span>
<span class="comment"> * create_canvas(), destroy_canvas() and draw_scene() are support functions.</span>
<span class="comment"> *</span>
<span class="comment"> * They are only required to use raw Evas, but for real world usage,</span>
<span class="comment"> * it is recommended to use ecore and its ecore-evas submodule, that</span>
<span class="comment"> * provide convenience canvas creators, integration with main loop and</span>
<span class="comment"> * automatic render of updates (draw_scene()) when system goes back to</span>
<span class="comment"> * main loop.</span>
<span class="comment"> */</span>
<span class="keyword">static</span> <a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *create_canvas(<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height);
<span class="keyword">static</span> <span class="keywordtype">void</span> destroy_canvas(<a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *canvas);
<span class="keyword">static</span> <span class="keywordtype">void</span> draw_scene(<a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *canvas);

<span class="comment">// support function to save scene as PPM image</span>
<span class="keyword">static</span> <span class="keywordtype">void</span> save_scene(<a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *canvas, <span class="keyword">const</span> <span class="keywordtype">char</span> *dest);

<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)
{
   <a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *canvas;
   <a class="code" href="group__Evas__Object__Group.html#ga9e19e6dd1f517a0ba437c0114d3e7c97" title="An Evas Object handle.">Evas_Object</a> *bg, *r1, *r2, *r3;

   <a class="code" href="group__Evas__Group.html#ga939a904ec53bf80796a8ad763cbb4c3c" title="Initialize Evas.">evas_init</a>();

   <span class="comment">// create your canvas</span>
   <span class="comment">// NOTE: consider using ecore_evas_buffer_new() instead!</span>
   canvas = create_canvas(WIDTH, HEIGHT);
   <span class="keywordflow">if</span> (!canvas)
     <span class="keywordflow">return</span> -1;

   bg = <a class="code" href="group__Evas__Object__Rectangle.html#gaa08a28171d59c43d106e1ea4f986fefa" title="Adds a rectangle to the given evas.">evas_object_rectangle_add</a>(canvas);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga6b2dfe01eb955cebf734f4e10ac9ce7f" title="Sets the general colour of the given evas object to the given colour.">evas_object_color_set</a>(bg, 255, 255, 255, 255); <span class="comment">// white bg</span>
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga78fa8858c51707f1a557b720014b71cc" title="Moves the given evas object to the given location.">evas_object_move</a>(bg, 0, 0);                    <span class="comment">// at origin</span>
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga34df8b33704deafd2a25f40e3c09d149" title="Changes the size of the given evas object.">evas_object_resize</a>(bg, WIDTH, HEIGHT);         <span class="comment">// covers full canvas</span>
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga769ad9a3e3daecb7a828196a2c86332f" title="Makes the given evas object visible.">evas_object_show</a>(bg);

   puts(<span class="stringliteral">&quot;initial scene, with just background:&quot;</span>);
   draw_scene(canvas);

   r1 = <a class="code" href="group__Evas__Object__Rectangle.html#gaa08a28171d59c43d106e1ea4f986fefa" title="Adds a rectangle to the given evas.">evas_object_rectangle_add</a>(canvas);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga6b2dfe01eb955cebf734f4e10ac9ce7f" title="Sets the general colour of the given evas object to the given colour.">evas_object_color_set</a>(r1, 255, 0, 0, 255); <span class="comment">// 100% opaque red</span>
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga78fa8858c51707f1a557b720014b71cc" title="Moves the given evas object to the given location.">evas_object_move</a>(r1, 10, 10);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga34df8b33704deafd2a25f40e3c09d149" title="Changes the size of the given evas object.">evas_object_resize</a>(r1, 100, 100);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga769ad9a3e3daecb7a828196a2c86332f" title="Makes the given evas object visible.">evas_object_show</a>(r1);

   <span class="comment">// pay attention to transparency! Evas color values are pre-multiplied by</span>
   <span class="comment">// alpha, so 50% opaque green is:</span>
   <span class="comment">// non-premul: r=0, g=255, b=0    a=128 (50% alpha)</span>
   <span class="comment">// premul:</span>
   <span class="comment">//         r_premul = r * a / 255 =      0 * 128 / 255 =      0</span>
   <span class="comment">//         g_premul = g * a / 255 =    255 * 128 / 255 =    128</span>
   <span class="comment">//         b_premul = b * a / 255 =      0 * 128 / 255 =      0</span>
   <span class="comment">//</span>
   <span class="comment">// this 50% green is over a red background, so it will show in the</span>
   <span class="comment">// final output as yellow (green + red = yellow)</span>
   r2 = <a class="code" href="group__Evas__Object__Rectangle.html#gaa08a28171d59c43d106e1ea4f986fefa" title="Adds a rectangle to the given evas.">evas_object_rectangle_add</a>(canvas);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga6b2dfe01eb955cebf734f4e10ac9ce7f" title="Sets the general colour of the given evas object to the given colour.">evas_object_color_set</a>(r2, 0, 128, 0, 128); <span class="comment">// 50% opaque green</span>
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga78fa8858c51707f1a557b720014b71cc" title="Moves the given evas object to the given location.">evas_object_move</a>(r2, 10, 10);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga34df8b33704deafd2a25f40e3c09d149" title="Changes the size of the given evas object.">evas_object_resize</a>(r2, 50, 50);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga769ad9a3e3daecb7a828196a2c86332f" title="Makes the given evas object visible.">evas_object_show</a>(r2);

   r3 = <a class="code" href="group__Evas__Object__Rectangle.html#gaa08a28171d59c43d106e1ea4f986fefa" title="Adds a rectangle to the given evas.">evas_object_rectangle_add</a>(canvas);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga6b2dfe01eb955cebf734f4e10ac9ce7f" title="Sets the general colour of the given evas object to the given colour.">evas_object_color_set</a>(r3, 0, 128, 0, 255); <span class="comment">// 100% opaque dark green</span>
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga78fa8858c51707f1a557b720014b71cc" title="Moves the given evas object to the given location.">evas_object_move</a>(r3, 60, 60);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga34df8b33704deafd2a25f40e3c09d149" title="Changes the size of the given evas object.">evas_object_resize</a>(r3, 50, 50);
   <a class="code" href="group__Evas__Object__Group__Basic.html#ga769ad9a3e3daecb7a828196a2c86332f" title="Makes the given evas object visible.">evas_object_show</a>(r3);

   puts(<span class="stringliteral">&quot;final scene (note updates):&quot;</span>);
   draw_scene(canvas);
   save_scene(canvas, <span class="stringliteral">&quot;/tmp/evas-buffer-simple-render.ppm&quot;</span>);

   <span class="comment">// NOTE: use ecore_evas_buffer_new() and here ecore_evas_free()</span>
   destroy_canvas(canvas);

   <a class="code" href="group__Evas__Group.html#ga3170193ec2e0ce4d7f0eb55de71060ed" title="Shutdown Evas.">evas_shutdown</a>();

   <span class="keywordflow">return</span> 0;
}

<span class="keyword">static</span> <a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *create_canvas(<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height)
{
   <a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *canvas;
   Evas_Engine_Info_Buffer *einfo;
   <span class="keywordtype">int</span> method;
   <span class="keywordtype">void</span> *pixels;

   method = <a class="code" href="group__Evas__Output__Method.html#gad8a701a8d4a2acbb2ce4b741ae55ce6b" title="Look up a numeric ID from a string name of a rendering engine.">evas_render_method_lookup</a>(<span class="stringliteral">&quot;buffer&quot;</span>);
   <span class="keywordflow">if</span> (method &lt;= 0)
     {
        fputs(<span class="stringliteral">&quot;ERROR: evas was not compiled with &#39;buffer&#39; engine!\n&quot;</span>, stderr);
        <span class="keywordflow">return</span> NULL;
     }

   canvas = <a class="code" href="group__Evas__Canvas.html#ga9280ee6564c889348b142b8bcd723f87" title="Creates a new empty evas.">evas_new</a>();
   <span class="keywordflow">if</span> (!canvas)
     {
        fputs(<span class="stringliteral">&quot;ERROR: could not instantiate new evas canvas.\n&quot;</span>, stderr);
        <span class="keywordflow">return</span> NULL;
     }

   <a class="code" href="group__Evas__Output__Method.html#gab6cca6c7a5edabef057790889d560b11" title="Sets the output engine for the given evas.">evas_output_method_set</a>(canvas, method);
   <a class="code" href="group__Evas__Output__Size.html#gaaf571f18f97f4067f554ab7713f01063" title="Sets the output size of the render engine of the given evas.">evas_output_size_set</a>(canvas, width, height);
   <a class="code" href="group__Evas__Output__Size.html#ga1d39edcaff429d884d4a70aa1fca0c08" title="Sets the output viewport of the given evas in evas units.">evas_output_viewport_set</a>(canvas, 0, 0, width, height);

   einfo = (Evas_Engine_Info_Buffer *)<a class="code" href="group__Evas__Output__Method.html#ga882d5f9411b5556719bdf28a134ee713" title="Retrieves the current render engine info struct from the given evas.">evas_engine_info_get</a>(canvas);
   <span class="keywordflow">if</span> (!einfo)
     {
        fputs(<span class="stringliteral">&quot;ERROR: could not get evas engine info!\n&quot;</span>, stderr);
        <a class="code" href="group__Evas__Canvas.html#ga45ab1883cc0b145bc3af130d3c00a21f" title="Frees the given evas and any objects created on it.">evas_free</a>(canvas);
        <span class="keywordflow">return</span> NULL;
     }

   <span class="comment">// ARGB32 is sizeof(int), that is 4 bytes, per pixel</span>
   pixels = malloc(width * height * <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));
   <span class="keywordflow">if</span> (!pixels)
     {
        fputs(<span class="stringliteral">&quot;ERROR: could not allocate canvas pixels!\n&quot;</span>, stderr);
        <a class="code" href="group__Evas__Canvas.html#ga45ab1883cc0b145bc3af130d3c00a21f" title="Frees the given evas and any objects created on it.">evas_free</a>(canvas);
        <span class="keywordflow">return</span> NULL;
     }

   einfo-&gt;info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
   einfo-&gt;info.dest_buffer = pixels;
   einfo-&gt;info.dest_buffer_row_bytes = width * <span class="keyword">sizeof</span>(int);
   einfo-&gt;info.use_color_key = 0;
   einfo-&gt;info.alpha_threshold = 0;
   einfo-&gt;info.func.new_update_region = NULL;
   einfo-&gt;info.func.free_update_region = NULL;
   <a class="code" href="group__Evas__Output__Method.html#gafeff04b89b4498eedf99c89e0a06e604" title="Applies the engine settings for the given evas from the given Evas_Engine_Info structure.">evas_engine_info_set</a>(canvas, (<a class="code" href="struct__Evas__Engine__Info.html" title="Generic engine information.">Evas_Engine_Info</a> *)einfo);

   <span class="keywordflow">return</span> canvas;
}

<span class="keyword">static</span> <span class="keywordtype">void</span> destroy_canvas(<a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *canvas)
{
   Evas_Engine_Info_Buffer *einfo;

   einfo = (Evas_Engine_Info_Buffer *)<a class="code" href="group__Evas__Output__Method.html#ga882d5f9411b5556719bdf28a134ee713" title="Retrieves the current render engine info struct from the given evas.">evas_engine_info_get</a>(canvas);
   <span class="keywordflow">if</span> (!einfo)
     {
        fputs(<span class="stringliteral">&quot;ERROR: could not get evas engine info!\n&quot;</span>, stderr);
        <a class="code" href="group__Evas__Canvas.html#ga45ab1883cc0b145bc3af130d3c00a21f" title="Frees the given evas and any objects created on it.">evas_free</a>(canvas);
        <span class="keywordflow">return</span>;
     }

   free(einfo-&gt;info.dest_buffer);
   <a class="code" href="group__Evas__Canvas.html#ga45ab1883cc0b145bc3af130d3c00a21f" title="Frees the given evas and any objects created on it.">evas_free</a>(canvas);
}

<span class="keyword">static</span> <span class="keywordtype">void</span> draw_scene(<a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *canvas)
{
   Eina_List *updates, *n;
   Eina_Rectangle *update;

   <span class="comment">// render and get the updated rectangles:</span>
   updates = <a class="code" href="group__Evas__Canvas.html#ga49650dcc731a151d4881106b56f7a5ca" title="Force immediate renderization of the given canvas.">evas_render_updates</a>(canvas);

   <span class="comment">// informative only here, just print the updated areas:</span>
   EINA_LIST_FOREACH(updates, n, update)
     printf(&quot;UPDATED REGION: pos: %3d, %3d    size: %3dx%3d\n&quot;,
            update-&gt;x, update-&gt;y, update-&gt;w, update-&gt;h);

   <span class="comment">// free list of updates</span>
   <a class="code" href="group__Evas__Canvas.html#gae4889bb5ec0e6e4f6ce5d6ef99f8737b" title="Free the rectangles returned by evas_render_updates().">evas_render_updates_free</a>(updates);
}

static <span class="keywordtype">void</span> save_scene(<a class="code" href="group__Evas__Canvas.html#ga5ff87cc4ce6bc43e3b640a6d37f73043" title="An Evas canvas handle.">Evas</a> *canvas, const <span class="keywordtype">char</span> *dest)
{
   Evas_Engine_Info_Buffer *einfo;
   <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *pixels, *pixels_end;
   <span class="keywordtype">int</span> width, height;
   FILE *f;

   einfo = (Evas_Engine_Info_Buffer *)<a class="code" href="group__Evas__Output__Method.html#ga882d5f9411b5556719bdf28a134ee713" title="Retrieves the current render engine info struct from the given evas.">evas_engine_info_get</a>(canvas);
   <span class="keywordflow">if</span> (!einfo)
     {
        fputs(<span class="stringliteral">&quot;ERROR: could not get evas engine info!\n&quot;</span>, stderr);
        <span class="keywordflow">return</span>;
     }
   <a class="code" href="group__Evas__Output__Size.html#ga1f3497644d526ff5ded49b19c1ec732a" title="Retrieve the output size of the render engine of the given evas.">evas_output_size_get</a>(canvas, &amp;width, &amp;height);

   f = fopen(dest, <span class="stringliteral">&quot;wb+&quot;</span>);
   <span class="keywordflow">if</span> (!f)
     {
        fprintf(stderr, <span class="stringliteral">&quot;ERROR: could not open for writing &#39;%s&#39;: %s\n&quot;</span>,
                dest, strerror(errno));
        <span class="keywordflow">return</span>;
     }

   pixels = einfo-&gt;info.dest_buffer;
   pixels_end = pixels + (width * height);

   <span class="comment">// PPM P6 format is dead simple to write:</span>
   fprintf(f, <span class="stringliteral">&quot;P6\n%d %d\n255\n&quot;</span>,  width, height);
   <span class="keywordflow">for</span> (; pixels &lt; pixels_end; pixels++)
     {
        <span class="keywordtype">int</span> r, g, b;

        r = ((*pixels) &amp; 0xff0000) &gt;&gt; 16;
        g = ((*pixels) &amp; 0x00ff00) &gt;&gt; 8;
        b = (*pixels) &amp; 0x0000ff;

        fprintf(f, <span class="stringliteral">&quot;%c%c%c&quot;</span>, r, g, b);
     }

   fclose(f);
   printf(<span class="stringliteral">&quot;saved scene as &#39;%s&#39;\n&quot;</span>, dest);
}
</pre></div><dl class="todo"><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd><p class="startdd">(1.0) Need a way ot scaling an image and just PRODUCING the output (scaling direct to target buffe r- no blend/copy etc.) </p>
<p>(1.0) Could improve evas's scaling down code to limit multiple samples per output pixel to maybe 2x2? </p>
<p>(1.0) Document API </p>
<p>(1.0) Evas needs to check delete_me member for all object functions </p>
<p>(1.0) Evas engine that renders to Evas_Objects </p>
<p>(1.0) OpenGL engine needs to use texture meshes </p>
<p>(1.0) OpenGL engine needs texture cache and size setting </p>
<p>(1.0) OpenGL Engine needs YUV import API to YUV texture </p>
<p>(1.0) All engines need pixel import API </p>
<p>(1.0) Add parital render through composite layer api to engines </p>
<p>(1.0) Move callback processing to a queue and do it asynchronously??? </p>
<p>(1.0) Add button grabbing </p>
<p>(1.0) Add generic object method call system </p>
<p>(1.0) Add callbacks set for smart object parents to be set on all child smart objects too. </p>
<p>(1.0) Add font load query calls (so we know if a font load failed) </p>
<p>(1.0) Add font listing calls </p>
<p>(1.0) Add ability to check image comments &amp; disk format </p>
<p>(1.0) Add fontset support </p>
<p>(1.0) Export engine rendering API cleanly to Evas API </p>
<p>(1.0) Add smart object ability to provide rendering callback </p>
<p>(1.1) Make freetype optional and put in optional graymap font engine </p>
<p>(1.1) Free images if object invisible (and put back in chache) </p>
<p>(1.1) Check robustness of malloc/calloc/realloc failures. </p>
<p>(1.1) Add memory use reduction code if any allocations fail </p>
<p>(1.1) If image loads fails due to memory allocatue failure, load reduced res version </p>
<p>(1.1) If image load fails due to memory allocation failure, try split it up into tiles and demand-load them </p>
<p>(1.2) Add external image loaders (application provided callbacks to load) </p>
<p>(1.2) Add loadable image loader module support (evas loads file.so) </p>
<p>(1.2) Add external image loader modules (application provides path to file.so) </p>
<p>(1.3) Add X11 primtive engine (ie pixmap) </p>
<p>(1.3) Add immediate mode drawing commands to image objects </p>
<p>(1.3) Fix FB engine to allocate vt and release properly </p>
<p>(1.4) Add ellipse objects (circle, arc, ellipse etc.) </p>
<p>(1.5) Make software engine draw lines &amp; polys etc. with aa </p>
<p>(1.5) Add radial gradients to gradient objects </p>
<p>(1.5) Add Symbian Engine </p>
<p>(1.6) Add PalmOS Engine </p>
<p>(1.6) Add Apple OpenGL Engine </p>
<p>(1.7) Document engine API and other internals </p>
<p>(1.7) Allow any object to clip any other object, and not just rectangles </p>
<p>(1.8) Add more evas demos </p>
<p>(1.9) Write the error mechanism in evas_xcb_buffer.c </p>
<p>(1.9) Rewrite the render xcb engine </p>
<p class="enddd">(1.10) Improve Win32 Direct3D Engine</p>
</dd></dl>
</div></div>
 
 <div id="push"></div>
 </div> <!-- #content -->
  </div> <!-- .layout -->
 
 </div> <!-- #container -->
 
 
  <div id="footer">
    <table><tr>
      <td class="poweredby"><img src="doxygen.png"></td>
      <td class="copyright">Copyright &copy;2011 Enlightenment</td>
      <td class="generated">Docs generated Thu Jul 14 2011 20:45:32</td>
    </tr></table>
  </div>


</body>
</html>