forked from enlightenment/efl
imlib backend does text now too.. god that was easy!
SVN revision: 3053
This commit is contained in:
parent
40b2aef29a
commit
363ed23d29
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
This is the ``E Canvas'' - a rip off of some of the other canvas's floating
|
This is the ``E Canvas'' - a rip off of some of the other canvas's floating
|
||||||
about - Tk and gnome too. it's at the Xlib level. it's intended to be
|
about - Tk and gnome too. it's at the Xlib level. it's intended to be
|
||||||
accelerated byhardware or highly optimised software where possible. It is
|
accelerated by hardware or highly optimised software where possible. It is
|
||||||
intended to be simple and allow for the building of interfaces ontop of it.
|
intended to be simple and allow for the building of interfaces ontop of it.
|
||||||
|
|
||||||
if you got this from cvs do:
|
if you got this from cvs do:
|
||||||
|
@ -23,3 +23,41 @@ in the test directory you will find a test program:
|
||||||
cd test
|
cd test
|
||||||
./evas_test
|
./evas_test
|
||||||
|
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MORE DETAILED DESCRIPTION:
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Evas? Canvas? What? OK.. you're baffled as to what that stuff is. Time to
|
||||||
|
explain.
|
||||||
|
|
||||||
|
A canvas is a high-level rendering engine. Instead of a program having to
|
||||||
|
handle exposes or updates then redraw bit by bit (draw line, draw box,
|
||||||
|
paste image etc.) after having figured out what has changed and what need to
|
||||||
|
be re-rendered - what data loaded in maps to what... then finally order the
|
||||||
|
draw in the right way to optimize it - a canvas provides a high-level API to
|
||||||
|
this kind of thing and handles all the smarts inside.
|
||||||
|
|
||||||
|
The result is an application creates an Evas & attaches that evas to a window.
|
||||||
|
Now it just creates objects - create an image object, a text object, a line
|
||||||
|
object, a rectangle object etc. It just moves and resizes these objects around
|
||||||
|
by calling routines in Evas - Evas handles redrawing, scaling, ordering the
|
||||||
|
draws to acount for layers , clipping objects out that don't exist in the
|
||||||
|
visible Evas area etc.
|
||||||
|
|
||||||
|
This means less headache for tha application programmer. Now why do this as
|
||||||
|
a whole new library? Well - because the library can render the Evas as fast
|
||||||
|
as possible. It uses Imlib2 to do the grunt work of loading images - and
|
||||||
|
beyond that it can currently use either imlib2 or OpenGL to render to the
|
||||||
|
Evas - if you have decent hardware that's supported by OpenGL you will see
|
||||||
|
in the area of 10-50 times (in future even higher) speedups in rendering
|
||||||
|
using the GL backend instead of the Imlib2 one (even though Imlib2 is a
|
||||||
|
highly optimized software rendering engine). The good thing here is that the
|
||||||
|
application can choose what system to use. If that system isn't available or
|
||||||
|
Evas didn't compile with it, it will fall back to the nearest approximation
|
||||||
|
(it will ALWAYS have Imlib2 and X11 rendering backends - Imlib2 being able to
|
||||||
|
actually alpha blend, but X11 keeping the rendering server-side with pixmaps
|
||||||
|
and clip masks) so this means a highly optimized rendering subsystem to build
|
||||||
|
more complex things ontop of.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,11 @@ __evas_imlib_image_draw(Evas_Imlib_Image *im,
|
||||||
{
|
{
|
||||||
Evas_List l;
|
Evas_List l;
|
||||||
|
|
||||||
|
imlib_context_set_angle(0.0);
|
||||||
|
imlib_context_set_operation(IMLIB_OP_COPY);
|
||||||
|
imlib_context_set_color_modifier(NULL);
|
||||||
|
imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT);
|
||||||
|
imlib_context_set_anti_alias(1);
|
||||||
for(l = drawable_list; l; l = l->next)
|
for(l = drawable_list; l; l = l->next)
|
||||||
{
|
{
|
||||||
Evas_Imlib_Drawable *dr;
|
Evas_Imlib_Drawable *dr;
|
||||||
|
@ -93,7 +98,7 @@ __evas_imlib_image_draw(Evas_Imlib_Image *im,
|
||||||
imlib_context_set_image(up->image);
|
imlib_context_set_image(up->image);
|
||||||
imlib_blend_image_onto_image(im, 0,
|
imlib_blend_image_onto_image(im, 0,
|
||||||
src_x, src_y, src_w, src_h,
|
src_x, src_y, src_w, src_h,
|
||||||
dst_x, dst_y, dst_w, dst_h);
|
dst_x - up->x, dst_y - up->y, dst_w, dst_h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,6 +217,46 @@ __evas_imlib_text_draw(Evas_Imlib_Font *fn, Display *disp, Window win,
|
||||||
int win_w, int win_h, int x, int y, char *text,
|
int win_w, int win_h, int x, int y, char *text,
|
||||||
int r, int g, int b, int a)
|
int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
|
Evas_List l;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
if ((!fn) || (!text)) return;
|
||||||
|
imlib_context_set_color(r, g, b, a);
|
||||||
|
imlib_context_set_font((Imlib_Font)fn);
|
||||||
|
imlib_context_set_angle(0.0);
|
||||||
|
imlib_context_set_operation(IMLIB_OP_COPY);
|
||||||
|
imlib_context_set_color_modifier(NULL);
|
||||||
|
imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT);
|
||||||
|
imlib_context_set_anti_alias(1);
|
||||||
|
imlib_get_text_size(text, &w, &h);
|
||||||
|
for(l = drawable_list; l; l = l->next)
|
||||||
|
{
|
||||||
|
Evas_Imlib_Drawable *dr;
|
||||||
|
|
||||||
|
dr = l->data;
|
||||||
|
|
||||||
|
if ((dr->win == win) && (dr->disp == disp))
|
||||||
|
{
|
||||||
|
Evas_List ll;
|
||||||
|
|
||||||
|
for (ll = dr->tmp_images; ll; ll = ll->next)
|
||||||
|
{
|
||||||
|
Evas_Imlib_Update *up;
|
||||||
|
|
||||||
|
up = ll->data;
|
||||||
|
|
||||||
|
/* if image intersects image update - render */
|
||||||
|
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
|
||||||
|
x, y, w, h))
|
||||||
|
{
|
||||||
|
if (!up->image)
|
||||||
|
up->image = imlib_create_image(up->w, up->h);
|
||||||
|
imlib_context_set_image(up->image);
|
||||||
|
imlib_text_draw(x, y, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue