Hi,
it looks like there's a bug in the optimized RGB24 -> RGB16 conversion
routine for little-endian machines (on master, for a long time now): it
swaps the red and blue channels.
Attached is a patch against the df_porter example that modifies it to
show two bitmaps one under another. They should be identical, but the
top one is rendered directly from DSPF_RGB24 surface, while the bottom
one is first blitted into DSPF_RGB16 surface and then to the screen. But
the two images differ (LE machine, using SDL system). Works correctly if
I disable Bop_rgb24_to_Aop_rgb16_LE.
Sorry for not providing a patch, I'm still getting lost in this code :(
I was hoping that perhaps the fix would be obvious to somebody more
familiar with this code.
Regards,
Vaclav
diff --git a/src/df_porter.c b/src/df_porter.c
index b85a72a..5f7741c 100644
--- a/src/df_porter.c
+++ b/src/df_porter.c
@@ -41,6 +41,7 @@ static IDirectFBSurface *primary;
/* the temporary surface */
static IDirectFBSurface *tempsurf;
+static IDirectFBSurface *tempsurf2;
/* provider for our images/font */
static IDirectFBFont *font;
@@ -105,12 +106,10 @@ int main( int argc, char *argv[] )
/* create the temporary surface */
- sdsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT | DSDESC_WIDTH |
DSDESC_HEIGHT;
- sdsc.caps = DSCAPS_PREMULTIPLIED;
- sdsc.pixelformat = DSPF_ARGB;
- sdsc.width = screen_width;
- sdsc.height = screen_height;
-
+ sdsc.flags = DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_HEIGHT;
+ sdsc.pixelformat = DSPF_RGB24;
+ sdsc.width = screen_width/2;
+ sdsc.height = screen_height/2;
DFBCHECK(dfb->CreateSurface( dfb, &sdsc, &tempsurf ));
@@ -122,69 +121,22 @@ int main( int argc, char *argv[] )
provider->RenderTo( provider, tempsurf, NULL );
provider->Release( provider );
- /* Blit background onto primary surface (dimmed). */
- primary->SetBlittingFlags( primary, DSBLIT_COLORIZE );
- primary->SetColor( primary, 190, 200, 180, 0 );
- primary->Blit( primary, tempsurf, NULL, 0, 0 );
-
-
- tempsurf->Clear( tempsurf, 0, 0, 0, 0 );
-
-
- tempsurf->SetDrawingFlags( tempsurf, DSDRAW_SRC_PREMULTIPLY |
DSDRAW_BLEND );
- tempsurf->SetPorterDuff( tempsurf, DSPD_SRC );
-
- fdsc.flags = DFDESC_HEIGHT;
- fdsc.height = screen_width/24;
-
- DFBCHECK(dfb->CreateFont( dfb, FONT, &fdsc, &font ));
- DFBCHECK(tempsurf->SetFont( tempsurf, font ));
-
- tempsurf->SetColor( tempsurf, 0xFF, 0xFF, 0xFF, 0xFF );
- tempsurf->DrawString( tempsurf, "Porter/Duff Demo", -1, screen_width/2,
20, DSTF_TOPCENTER );
-
- font->Release( font );
-
-
- fdsc.height = screen_width/32;
+
+ /* perform RGB24 -> RGB16 conversion: */
+ sdsc.flags = DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_HEIGHT;
+ sdsc.pixelformat = DSPF_RGB16;
+ sdsc.width = screen_width/2;
+ sdsc.height = screen_height/2;
+ DFBCHECK(dfb->CreateSurface( dfb, &sdsc, &tempsurf2 ));
- DFBCHECK(dfb->CreateFont( dfb, FONT, &fdsc, &font ));
- DFBCHECK(tempsurf->SetFont( tempsurf, font ));
+ tempsurf2->SetBlittingFlags( tempsurf2, DSBLIT_NOFX );
+ tempsurf2->Blit( tempsurf2, tempsurf, NULL, 0, 0 );
- for (i=0; i<num_rules; i++) {
- int x = (1 + i % 4) * step;
- int y = (0 + i / 4) * 180;
- DFBAccelerationMask mask;
- char *str;
-
- str = strdup( rules[i] );
-
- tempsurf->SetPorterDuff( tempsurf, DSPD_SRC );
- tempsurf->SetColor( tempsurf, 255, 0, 0, 140 );
- tempsurf->FillRectangle( tempsurf, x - 50, y + 100, 80, 70 );
-
- tempsurf->SetPorterDuff( tempsurf, i+1 );
- tempsurf->SetColor( tempsurf, 0, 0, 255, 200 );
- tempsurf->FillRectangle( tempsurf, x - 30, y + 130, 80, 70 );
-
- tempsurf->GetAccelerationMask( tempsurf, NULL, &mask );
- if (mask & DFXL_FILLRECTANGLE)
- str[0] = '*';
-
- tempsurf->SetPorterDuff( tempsurf, DSPD_SRC_OVER );
- tempsurf->SetColor( tempsurf, 6*0x1F, 6*0x10+0x7f, 0xFF, 0xFF );
- tempsurf->DrawString( tempsurf, str, -1, x, y + 210, DSTF_CENTER |
DSTF_TOP );
-
- free( str );
- }
-
- font->Release( font );
-
-
- primary->SetBlittingFlags( primary, DSBLIT_BLEND_ALPHACHANNEL );
- primary->SetPorterDuff( primary, DSPD_SRC_OVER );
+ primary->SetBlittingFlags( primary, DSBLIT_NOFX );
primary->Blit( primary, tempsurf, NULL, 0, 0 );
+ primary->Blit( primary, tempsurf2, NULL, 0, screen_height/2 );
+
primary->Flip( primary, NULL, DSFLIP_NONE );
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev