Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - background and foreground windows problem: (4 Items)
   
background and foreground windows problem  
in lcd driver, the foreground is enabled, and the color is set on the foreground in application test code, while layer 
update, the layer program funcition in driver is call , the layer index is 0, SDC_BG_POS(background window position) 
register is set, but not SDC_FG_POS(foreground window position) is set,right colors display,  why? thanks
RE: background and foreground windows problem  
Can you post your application test code?   I assume from your
description below you are trying to display something to the foreground
layer (layer_index 1)?

Thanks



-----Original Message-----
From: gong mingyu [mailto:community-noreply@qnx.com] 
Sent: July 28, 2009 9:21 PM
To: advanced-graphics
Subject: background and foreground windows problem

in lcd driver, the foreground is enabled, and the color is set on the
foreground in application test code, while layer update, the layer
program funcition in driver is call , the layer index is 0,
SDC_BG_POS(background window position) register is set, but not
SDC_FG_POS(foreground window position) is set,right colors display,
why? thanks



_______________________________________________

Advanced Graphics
http://community.qnx.com/sf/go/post34763
Re: RE: background and foreground windows problem  
the lcd test code as follow:

int main() {
//device & display
gf_dev_t            gdev;
gf_dev_info_t       gdev_info;
gf_display_t        display;
gf_display_info_t   display_info;
int i;
//layer
gf_layer_t  layer;
//surface
gf_surface_t    surface;
gf_surface_info_t surface_info;
unsigned height;
unsigned width;
gf_layer_info_t layer_info;
//context
gf_context_t context;
if (gf_dev_attach(&gdev, GF_DEVICE_INDEX(0), &gdev_info) != GF_ERR_OK) {
    printf("gf_dev_attach() failed\n");
perror( "gf_dev_attach()" );
    return (-1);
}
printf("gdev_info.ndisplays: %d\n",gdev_info.ndisplays);
for (i = 0; i < gdev_info.ndisplays; i++) {
    printf("Display %d: ", i);
    if (gf_display_attach(&display, gdev, i, &display_info) == GF_ERR_OK) {
        printf("%dX%d, refresh = %dHz\n", display_info.xres,
            display_info.yres, display_info.refresh);
        printf("display_info.nlayers: %d\n", display_info.nlayers);
    } else {
        printf("gf_display_attach() failed\n");
     perror( "gf_display_attach()" );
gf_dev_detach(gdev);
    }
}
if (display != NULL) {
    if (gf_layer_attach(&layer,display,display_info.main_layer_index, 0) == GF_ERR_OK) {
printf("Attaching Layer %d to display.\n ",display_info.main_layer_index);
    }
    else {
        printf("gf_layer_attach() failed\n");
gf_dev_detach( gdev );
        return (-1);
    }
}
if((gf_layer_query(layer,0,&layer_info))==GF_ERR_OK){
printf("Layer's Format 0 : 0x%x, GF_FORMAT_PACK_RGB565: 0x%x\n",layer_info.format,GF_FORMAT_PACK_RGB565);
}
else{
printf(" gf_layer_query() failed");
    return (-1);
}
width = display_info.xres;
height = display_info.yres;
if (gf_surface_create_layer(&surface, &layer, 1, 0,
width, height, layer_info.format, NULL, 0) == GF_ERR_OK) {
printf("Succesfully created surface on top of layer\n");
        gf_layer_set_surfaces(layer, &surface, 1);
        gf_surface_get_info(surface, &surface_info);    
         printf("surface's Format: 0x%x, GF_FORMAT_PKLE_RGB565: 0x%x\n",surface_info.format,GF_FORMAT_PKLE_RGB565);
    } else {
        printf("gf_surface_create_layer() failed\n");
        return (-1);
    }
if (gf_context_create(&context) != GF_ERR_OK) {
        fprintf(stderr, "gf_context_create failed\n");
        return -1;
    }
else{
printf(" Created the context succefully\n");
}
if (gf_context_set_surface(context,surface)!= GF_ERR_OK) {
            fprintf(stderr, "gf_context_set_surface failed\n");
            return -1;
        }
 else{
        printf("Context Surface is Set Succesfully\n");
        }
int x,y;
gf_draw_begin(context);
gf_context_set_penwidth(context, 1 );
gf_context_set_bgcolor( context, 0x000000 );//white, background is not enable
gf_draw_rect( context, 0, 0, width-1, height-1 ); 
gf_draw_flush(context );
x=400; 
y=240;
gf_context_set_fgcolor( context, 0xFF0000);//red output mode 18 rgb565 
gf_draw_rect(context,(width>>1)-1-x,(height>>1)-1-y,(width>>1)-1+x,(height>>1)-1+y); 
x>>=1;
y>>=1;
gf_context_set_fgcolor( context, 0x00FF00);//green 
gf_draw_rect(context,(width>>1)-1-x,(height>>1)-1-y,(width>>1)-1+x,(height>>1)-1+y); 
x>>=1;
y>>=1;
gf_context_set_fgcolor( context, 0x0000FF);//blue 
gf_draw_rect(context,(width>>1)-1-x,(height>>1)-1-y,(width>>1)-1+x,(height>>1)-1+y); 
x>>=1;
y>>=1; 
gf_context_set_fgcolor(context,0x000000);//black
gf_draw_rect(context,(width>>1)-1-x,(height>>1)-1-y,(width>>1)-1+x,(height>>1)-1+y); 
x>>=1;
y>>=1;
gf_context_set_fgcolor(context,0xFFFFFF);//white
gf_draw_rect(context,(width>>1)-1-x,(height>>1)-1-y,(width>>1)-1+x,(height>>1)-1+y); 
x>>=1;
y>>=1;
gf_context_set_fgcolor(context,0xFFFF00);//?
gf_draw_rect(context,(width>>1)-1-x,(height>>1)-1-y,(width>>1)-1+x,(height>>1)-1+y);...
View Full Message
RE: RE: background and foreground windows problem  
The code in your test application doing the gf_layer_attach() specifies display_info.main_layer_index for the layer 
index.  With the iMX31 driver this value is 0 which corresponds to the Background window.   
If you wish to use the Foreground window you will need to specify a layer_index of 1.

Note the iMX31 terms Background and Foreground have nothing to do with the setting of background or foreground color.

-----Original Message-----
From: gong mingyu [mailto:community-noreply@qnx.com] 
Sent: July 29, 2009 9:21 PM
To: advanced-graphics
Subject: Re: RE: background and foreground windows problem

the lcd test code as follow:

int main() {
//device & display
gf_dev_t            gdev;
gf_dev_info_t       gdev_info;
gf_display_t        display;
gf_display_info_t   display_info;
int i;
//layer
gf_layer_t  layer;
//surface
gf_surface_t    surface;
gf_surface_info_t surface_info;
unsigned height;
unsigned width;
gf_layer_info_t layer_info;
//context
gf_context_t context;
if (gf_dev_attach(&gdev, GF_DEVICE_INDEX(0), &gdev_info) != GF_ERR_OK) {
    printf("gf_dev_attach() failed\n");
perror( "gf_dev_attach()" );
    return (-1);
}
printf("gdev_info.ndisplays: %d\n",gdev_info.ndisplays);
for (i = 0; i < gdev_info.ndisplays; i++) {
    printf("Display %d: ", i);
    if (gf_display_attach(&display, gdev, i, &display_info) == GF_ERR_OK) {
        printf("%dX%d, refresh = %dHz\n", display_info.xres,
            display_info.yres, display_info.refresh);
        printf("display_info.nlayers: %d\n", display_info.nlayers);
    } else {
        printf("gf_display_attach() failed\n");
     perror( "gf_display_attach()" );
gf_dev_detach(gdev);
    }
}
if (display != NULL) {
    if (gf_layer_attach(&layer,display,display_info.main_layer_index, 0) == GF_ERR_OK) {
printf("Attaching Layer %d to display.\n ",display_info.main_layer_index);
    }
    else {
        printf("gf_layer_attach() failed\n");
gf_dev_detach( gdev );
        return (-1);
    }
}
if((gf_layer_query(layer,0,&layer_info))==GF_ERR_OK){
printf("Layer's Format 0 : 0x%x, GF_FORMAT_PACK_RGB565: 0x%x\n",layer_info.format,GF_FORMAT_PACK_RGB565);
}
else{
printf(" gf_layer_query() failed");
    return (-1);
}
width = display_info.xres;
height = display_info.yres;
if (gf_surface_create_layer(&surface, &layer, 1, 0,
width, height, layer_info.format, NULL, 0) == GF_ERR_OK) {
printf("Succesfully created surface on top of layer\n");
        gf_layer_set_surfaces(layer, &surface, 1);
        gf_surface_get_info(surface, &surface_info);    
         printf("surface's Format: 0x%x, GF_FORMAT_PKLE_RGB565: 0x%x\n",surface_info.format,GF_FORMAT_PKLE_RGB565);
    } else {
        printf("gf_surface_create_layer() failed\n");
        return (-1);
    }
if (gf_context_create(&context) != GF_ERR_OK) {
        fprintf(stderr, "gf_context_create failed\n");
        return -1;
    }
else{
printf(" Created the context succefully\n");
}
if (gf_context_set_surface(context,surface)!= GF_ERR_OK) {
            fprintf(stderr, "gf_context_set_surface failed\n");
            return -1;
        }
 else{
        printf("Context Surface is Set Succesfully\n");
        }
int x,y;
gf_draw_begin(context);
gf_context_set_penwidth(context, 1 );
gf_context_set_bgcolor( context, 0x000000 );//white, background is not enable
gf_draw_rect( context, 0, 0, width-1, height-1 ); 
gf_draw_flush(context );
x=400; 
y=240;
gf_context_set_fgcolor( context, 0xFF0000);//red output mode 18 rgb565 
gf_draw_rect(context,(width>>1)-1-x,(height>>1)-1-y,(width>>1)-1+x,(height>>1)-1+y); 
x>>=1;
y>>=1;
gf_context_set_fgcolor( context, 0x00FF00);//green 
gf_draw_rect(context,(width>>1)-1-x,(height>>1)-1-y,(width>>1)-1+x,(height>>1)-1+y); 
x>>=1;
y>>=1;
gf_context_set_fgcolor( context, 0x0000FF);//blue...
View Full Message