This might be the way DirectFB is supposed to work but I was surprised to find 
the following:

1) I blit the subrect 0, 0, 100, 100 of a surface to position 100, 0 in the 
same surface
2) I blit the subrect 100, 0, 100, 100 of a surface to position 100, 100 in the 
same surface

Contrary to my expections I found that the content now found in 100, 100, 100, 
100 is what used to be in 100, 0, 100, 100 before the first blit rather than 
after it. If I put a Flip in between 1 and 2 it works as expected. 

E.g. think of each letter as a 100x100 square with a certain color in my window 
surface:

rg
by

12
34

I blit 1 onto 2 expecting this to be the contents:
rr
by

I blit 2 onto 4 expecting this to be the contents:
rr
br

instead it's this:

rr
bg

This application reproduces the problem. 

This is running DirectFB 1.2.8 using X11.

#include <directfb.h>
#include <unistd.h>

#define TEST(call) { result = call; if (result != DFB_OK) { func = #call; goto 
end; } }

int main(int argc, char **argv)
{
    const char *func = 0;
    DFBResult result = DFB_OK;
    IDirectFB *dfb = 0;
    IDirectFBSurface *windowSurface = 0;
    IDirectFBDisplayLayer *layer = 0;
    IDirectFBWindow *window = 0;
    DFBWindowDescription windowDescription;
    DFBRectangle rect = { 0, 0, 100, 100 };

    TEST(DirectFBInit(&argc, &argv));
    TEST(DirectFBCreate(&dfb));
    TEST(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer));

    windowDescription.width = windowDescription.height = 200;
    windowDescription.posx = windowDescription.posy = 200;
    windowDescription.caps = DWCAPS_DOUBLEBUFFER;
    windowDescription.flags = 
DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_CAPS;

    TEST(layer->CreateWindow(layer, &windowDescription, &window));
    TEST(window->SetOpacity(window, 255));
    TEST(window->GetSurface(window, &windowSurface));

    TEST(windowSurface->SetColor(windowSurface, 255, 0, 0, 255));
    TEST(windowSurface->FillRectangle(windowSurface, 0, 0, 100, 100));
    TEST(windowSurface->SetColor(windowSurface, 0, 255, 0, 255));
    TEST(windowSurface->FillRectangle(windowSurface, 100, 0, 100, 100));
    TEST(windowSurface->SetColor(windowSurface, 0, 0, 255, 255));
    TEST(windowSurface->FillRectangle(windowSurface, 0, 100, 100, 100));
    TEST(windowSurface->SetColor(windowSurface, 255, 0, 255, 255));
    TEST(windowSurface->FillRectangle(windowSurface, 100, 100, 100, 100));
    TEST(windowSurface->Flip(windowSurface, 0, DSFLIP_BLIT));

    TEST(windowSurface->Blit(windowSurface, windowSurface, &rect, 100, 0));
    rect.x = 100;
    TEST(windowSurface->Blit(windowSurface, windowSurface, &rect, 100, 100));

    TEST(windowSurface->Flip(windowSurface, 0, DSFLIP_BLIT));
    sleep(5);
end:
    if (result != DFB_OK)
        DirectFBError(func, result);
    if (windowSurface)
        windowSurface->Release(windowSurface);
    if (window)
        window->Release(window);
    if (layer)
        layer->Release(layer);
    if (dfb)
        dfb->Release(dfb);
    if (result != DFB_OK)
        DirectFBError(func, result);
    return 0;
}

Maybe I am doing something wrong here.

regards
-- 
Qt Development Frameworks, Nokia, http://qt.nokia.com
Anders Bakken
_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to