[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [E-devel] Buffer canvas and transparent background

Hi raster,

On Sun, 2006-04-02 at 10:27 +0900, Carsten Haitzler wrote:
> how are you using it? using ecore_evas? are you using the update region
> callback by hand (not ecore_evas) ? i am looking at the code here - if u ask
> for EVAS_ENGINE_BUFFER_DEPTH_ARGB32 depth - it will zero out the alpha channel
> every render update - but ONLY the regions rendered to. it won't do it on
> startup though. so that might be your problem as those regions never get
> objects and never get a render update as you manually manage your canvas and
> damage regions (you don't send an initial one)

I'm not using ecore.  The problem areas are those where evas _has_
rendered objects before.

There definitely is a problem.  I spent a while trying to make a test
case and was unsuccessful until I discovered the problem only occurs
when the viewport is defined as a size larger than the output size.  See
the attached test case.  It creates a 640x480 buffer canvas and sets the
viewport to 800x600.  It creates a 50px high rectangle at (0,300) and
samples an alpha pixel at the corresponding point in the buffer.  It
then moves that rectangle to (0,0) and samples the alpha at the same
spot.  It _should_ be zero, but when (and cvs, and possibly
earlier versions) the value is unchanged.

Output with cvs from 2006-04-01:

        Should be non-zero: 94
        Update: 0,0 560x40
        Update: 0,240 560x40
        Should be zero: 94

Output with cvs from 2005-12-18:

        Should be non-zero: 155
        Update: 0,0 560x40
        Update: 0,240 560x40
        Should be zero: 0

Note also the alpha value is different between the two cvs versions.  I
am calling evas_object_color_set(rect, 255, 55, 155, 155) so I do expect
the alpha value to be 155 there.  cvs-2005-12-18 has correct behavior in
both cases, whereas 2006-04-01 shows an unexpected alpha value, and,
more importantly, it's leaving cruft behind when I move the object.

If the viewport size matches the output size or is smaller then it seems
to be fine.  It's only when the viewport is larger than the output size.

Hopefully this helps narrow down the problem.  See attached.

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <Evas.h>
#include <Evas_Engine_Buffer.h>

int main(int argc, char **argv)
    unsigned char *buffer = malloc(640*480*4);
    Evas_Engine_Info_Buffer *einfo;

    Evas *evas = evas_new();

    evas_output_method_set(evas, evas_render_method_lookup("buffer"));
    einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(evas);
    einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_BGRA32;
    einfo->info.dest_buffer_row_bytes = 640*4;
    einfo->info.dest_buffer = buffer;

    evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);

    evas_output_size_set(evas, 640, 480);

    evas_output_viewport_set(evas, 0, 0, 800, 600);
    #define OFFSET 640*4*250 + 3
    // NOTE: uncomment these lines and it's all good.
    //evas_output_viewport_set(evas, 0, 0, 640, 480);
    //#define OFFSET 640*4*300 + 3
    Evas_Object *rect = evas_object_rectangle_add(evas);
    evas_object_color_set(rect, 255, 55, 155, 155);
    evas_object_resize(rect, 700, 50);
    evas_object_move(rect, 0, 300);

    printf("Should be non-zero: %d\n", buffer[OFFSET]);

    evas_object_move(rect, 0, 0);
    Evas_List *u;
    for (u = evas_render_updates(evas); u; u = u->next) {
        Evas_Rectangle *r = u->data;
        printf("Update: %d,%d %dx%d\n", r->x, r->y, r->w, r->h);

    printf("Should be zero: %d\n", buffer[OFFSET]);