forked from enlightenment/efl
region obscuring code. this should provide for apps using evas to indicate
whihc retcangles of the evas are completely obsucred by covering windows so evas doesn't render things it doesn't need to (ie they can't be seen). SVN revision: 3619
This commit is contained in:
parent
13fa0bae83
commit
28920da8b3
|
@ -75,6 +75,10 @@ void evas_free(Evas e);
|
|||
|
||||
/* for exposes or forced redraws (relative to output drawable) */
|
||||
void evas_update_rect(Evas e, int x, int y, int w, int h);
|
||||
/* for when the evas isnt fully visible you can clip out rects that are */
|
||||
/* full obscured rects of the evas (ie windows ontop) */
|
||||
void evas_add_obscured_rect(Evas e, int x, int y, int w, int h);
|
||||
void evas_clear_obscured_rects(Evas e);
|
||||
|
||||
/* drawing */
|
||||
void evas_render(Evas e);
|
||||
|
|
|
@ -75,6 +75,7 @@ struct _Evas
|
|||
|
||||
Evas_List layers;
|
||||
Imlib_Updates updates;
|
||||
Imlib_Updates obscures;
|
||||
};
|
||||
|
||||
struct _Evas_Point
|
||||
|
|
|
@ -9,6 +9,13 @@
|
|||
#include "evas_image_routines.h"
|
||||
#include "evas_x11_routines.h"
|
||||
|
||||
#ifndef SPANS_COMMON
|
||||
#define SPANS_COMMON(x1, w1, x2, w2) \
|
||||
(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
|
||||
#define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \
|
||||
((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh))))
|
||||
#endif
|
||||
|
||||
void
|
||||
_evas_object_get_current_translated_coords(Evas e, Evas_Object o,
|
||||
int *x, int *y, int *w, int *h)
|
||||
|
@ -49,6 +56,84 @@ _evas_object_get_previous_translated_coords(Evas e, Evas_Object o,
|
|||
e->previous.viewport.h);
|
||||
}
|
||||
|
||||
void
|
||||
_evas_clip_obscures(Evas e)
|
||||
{
|
||||
Imlib_Updates up, old_up, ob;
|
||||
|
||||
up = e->updates;
|
||||
if (!up) return;
|
||||
for (ob = e->obscures; ob; ob = imlib_updates_get_next(ob))
|
||||
{
|
||||
int ox, oy, ow, oh;
|
||||
|
||||
imlib_updates_get_coordinates(ob, &ox, &oy, &ow, &oh);
|
||||
e->updates = NULL;
|
||||
old_up = up;
|
||||
while (up)
|
||||
{
|
||||
int x, y, w, h;
|
||||
|
||||
imlib_updates_get_coordinates(up, &x, &y, &w, &h);
|
||||
if (RECTS_INTERSECT(x, y, w, h, ox, oy, ow, oh))
|
||||
{
|
||||
int rx, ry, rw, rh;
|
||||
|
||||
/* left */
|
||||
rx = x; ry = y;
|
||||
rw = ox - x; rh = h;
|
||||
if ((rw > 0) && (rh > 0))
|
||||
e->updates = imlib_update_append_rect(e->updates, rx, ry, rw, rh);
|
||||
/* right */
|
||||
rx = ox + ow; ry = y;
|
||||
rw = x + w - (ox + ow); rh = h;
|
||||
if ((rw > 0) && (rh > 0))
|
||||
e->updates = imlib_update_append_rect(e->updates, rx, ry, rw, rh);
|
||||
/* top */
|
||||
rx = ox; ry = y;
|
||||
if (ox < x) rx = x;
|
||||
rw = ow; rh = oy - y;
|
||||
if ((rx + rw) > (x + w)) rw = (x + w) - rx;
|
||||
if ((rw > 0) && (rh > 0))
|
||||
e->updates = imlib_update_append_rect(e->updates, rx, ry, rw, rh);
|
||||
/* bottom */
|
||||
rx = ox; ry = oy + oh;
|
||||
if (ox < x) rx = x;
|
||||
rw = ow; rh = (y + h) - ry;
|
||||
if ((rx + rw) > (x + w)) rw = (x + w) - rx;
|
||||
if ((rw > 0) && (rh > 0))
|
||||
e->updates = imlib_update_append_rect(e->updates, rx, ry, rw, rh);
|
||||
}
|
||||
else
|
||||
e->updates = imlib_update_append_rect(e->updates, x, y, w, h);
|
||||
up = imlib_updates_get_next(up);
|
||||
}
|
||||
if (old_up) imlib_updates_free(old_up);
|
||||
up = e->updates;
|
||||
}
|
||||
}
|
||||
|
||||
/* for parts of an evas that are obscured for output */
|
||||
void
|
||||
evas_add_obscured_rect(Evas e, int x, int y, int w, int h)
|
||||
{
|
||||
if (!e) return;
|
||||
if (w <= 0) return;
|
||||
if (h <= 0) return;
|
||||
e->obscures = imlib_update_append_rect(e->obscures, x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
evas_clear_obscured_rects(Evas e)
|
||||
{
|
||||
if (!e) return;
|
||||
if (e->obscures)
|
||||
{
|
||||
imlib_updates_free(e->obscures);
|
||||
e->obscures = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* for exposes or forced redraws (relative to output drawable) */
|
||||
void
|
||||
evas_update_rect(Evas e, int x, int y, int w, int h)
|
||||
|
@ -355,6 +440,7 @@ evas_render(Evas e)
|
|||
func_init(e->current.display, e->current.screen, e->current.colors);
|
||||
if (e->updates)
|
||||
{
|
||||
_evas_clip_obscures(e);
|
||||
up = imlib_updates_merge_for_rendering(e->updates,
|
||||
e->current.drawable_width,
|
||||
e->current.drawable_height);
|
||||
|
|
|
@ -77,8 +77,8 @@ static TextBlock texts[] =
|
|||
|
||||
{ 52.0, 54.0, 58.0, 60.0, "Yes ...", NULL, NULL},
|
||||
{ 60.0, 64.0, 70.0, 74.0, "Rancid Cheese", NULL, NULL},
|
||||
|
||||
{ 76.0, 78.0, 80.0, 82.0, "But for those of you who want to code ...", NULL, NULL},
|
||||
|
||||
{ 76.0, 78.0, 80.0, 82.0, "But for those who prefer to code ...", NULL, NULL},
|
||||
{ 80.0, 82.0, 84.0, 86.0, "There is ...", NULL, NULL},
|
||||
{ 88.0, 90.0, 94.0, 98.0, "EVAS", NULL, NULL}
|
||||
};
|
||||
|
@ -172,7 +172,7 @@ setup(void)
|
|||
|
||||
XSelectInput(display, win_control, ButtonPressMask |
|
||||
ButtonReleaseMask | PointerMotionMask | ExposureMask |
|
||||
EnterWindowMask | LeaveWindowMask);
|
||||
EnterWindowMask | LeaveWindowMask | VisibilityChangeMask);
|
||||
|
||||
XMapWindow(display, win_control);
|
||||
XMapWindow(display, win_base);
|
||||
|
@ -279,7 +279,7 @@ setup_view(Evas_Render_Method method)
|
|||
win_view = evas_get_window(e);
|
||||
XSelectInput(display, win_view, ButtonPressMask |
|
||||
ButtonReleaseMask | PointerMotionMask | ExposureMask |
|
||||
EnterWindowMask | LeaveWindowMask);
|
||||
EnterWindowMask | LeaveWindowMask | VisibilityChangeMask);
|
||||
XMapWindow(display, win_view);
|
||||
|
||||
for (i = 0; i < (sizeof(texts) / sizeof(TextBlock)); i++) texts[i].o_text = NULL;
|
||||
|
@ -386,7 +386,7 @@ image(double val)
|
|||
if (!images[i].o_image)
|
||||
{
|
||||
images[i].o_image = evas_add_image_from_file(evas_view, images[i].file);
|
||||
evas_set_layer(evas_view, images[i].o_image, 100);
|
||||
evas_set_layer(evas_view, images[i].o_image, 97);
|
||||
}
|
||||
if ((val >= images[i].time1) && (val <= images[i].time4))
|
||||
{
|
||||
|
@ -743,6 +743,9 @@ handle_events(void)
|
|||
case Expose:
|
||||
evas_update_rect(e, ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height);
|
||||
break;
|
||||
case VisibilityNotify:
|
||||
/* printf("state %i\n", ev.xvisibility.state);*/
|
||||
break;
|
||||
case EnterNotify:
|
||||
if (e == evas_view)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue