예제 #1
0
static int l_SetBlittingFlags (lua_State* L)
{
	// [ sfc | flags ]
	IDirectFBSurface* sfc = * (IDirectFBSurface**) luaL_checkudata(L, 1, "ldirectfb.IDirectFBSurface");
	DFBCHECK( sfc->SetBlittingFlags(sfc, luaL_checknumber(L, 2)) );
	return 0;
}
예제 #2
0
static int
_dfb_surface_set_blit_params(DirectFB_Engine_Image_Entry *d, DirectFB_Engine_Image_Entry *s, RGBA_Draw_Context *dc)
{
   IDirectFBSurface *surface;
   DFBSurfaceBlittingFlags blit_flags = DSBLIT_NOFX;
   DFBResult res;
   int r, g, b, a;

   _context_get_color(dc, &r, &g, &b, &a);
   if (a == 0)
     return 0;

   if (a != 255)
     blit_flags = DSBLIT_BLEND_COLORALPHA | DSBLIT_SRC_PREMULTCOLOR;

   if ((r != a) || (g != a) || (b != a))
     {
	blit_flags |= DSBLIT_COLORIZE;

	r = 0xff * r / a;
	g = 0xff * g / a;
	b = 0xff * b / a;
   }

   if (s->cache_entry.src->flags.alpha)
     blit_flags |= DSBLIT_BLEND_ALPHACHANNEL;

   surface = d->surface;

   if (blit_flags &
       (DSBLIT_BLEND_COLORALPHA | DSBLIT_SRC_PREMULTCOLOR | DSBLIT_COLORIZE))
     {
	res = surface->SetColor(surface, r, g, b, a);
	if (res != DFB_OK)
	  goto error;
     }

   res = surface->SetBlittingFlags(surface, blit_flags);
   if (res != DFB_OK)
     goto error;

#ifdef DFB_DEBUG_FLAGS
   DBG("sfunc=%s, dfunc=%s, color=%d %d %d %d, blit=%s, draw=%s",
	  _dfb_blend_func_str(src_func), _dfb_blend_func_str(dst_func),
	  r, g, b, a,
	  _dfb_blit_flags_str(blit_flags), _dfb_draw_flags_str(draw_flags));
#endif /* DFB_DEBUG_FLAGS */

   return 1;

 error:
   ERR("Could not set blit params: %s",
	 DirectFBErrorString(res));
   return 0;
}
예제 #3
0
static mrb_value surface_set_blitting_flags(mrb_state *mrb, mrb_value self)
{
    IDirectFBSurface* surface = mrb_directfb_surface(mrb, self);
    DFBResult ret = -1;
    if (surface != NULL) {
        mrb_int flags;
        mrb_get_args(mrb, "i", &flags);
        ret = surface->SetBlittingFlags(surface, flags);
    }
    return mrb_fixnum_value(ret);
}
예제 #4
0
QImage QDirectFBPixmapData::toImage() const
{
    if (!surface)
        return QImage();

#ifdef QT_NO_DIRECTFB_PREALLOCATED
    QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
    const QImage *img = that->buffer();
    const QImage copied = img->copy();
    that->unlockDirectFB();
    return copied;
#else

    int w, h;
    surface->GetSize(surface, &w, &h);

    DFBSurfacePixelFormat format;
    surface->GetPixelFormat(surface, &format);

    QImage::Format imageFormat = QDirectFBScreen::getImageFormat(format);
    if (imageFormat == QImage::Format_Invalid)
        imageFormat = QImage::Format_ARGB32_Premultiplied;
    imageFormat = QImage::Format_ARGB32;

    QImage image(w, h, imageFormat);

    DFBSurfaceDescription description;
    description = QDirectFBScreen::getSurfaceDescription(image);

    IDirectFB *fb = QDirectFBScreen::instance()->dfb();
    IDirectFBSurface *imgSurface;
    DFBResult result = fb->CreateSurface(fb, &description, &imgSurface);
    if (result != DFB_OK) {
        DirectFBError("QDirectFBPixmapData::toImage()", result);
        return QImage();
    }

    imgSurface->SetBlittingFlags(imgSurface, DSBLIT_NOFX);
    result = imgSurface->Blit(imgSurface, surface, 0, 0, 0);
    if (result != DFB_OK) {
        DirectFBError("QDirectFBPixmapData::toImage() blit failed", result);
        return QImage();
    }
    imgSurface->Release(imgSurface);

    return image;
#endif // QT_NO_DIRECTFB_PREALLOCATED
}
예제 #5
0
static void* render_loop (void *arg)
{
     IDirectFBSurface *view = (IDirectFBSurface*)arg;

     view->SetBlittingFlags( view, DSBLIT_SRC_COLORKEY | DSBLIT_COLORIZE );

     while (started_rendering()) {
          int i;

          pthread_testcancel();

          view->SetColor( view, 0, 0, 0, 0 );
          view->FillRectangle( view, 0, 0, xres, yres );

          for (i=0; i<STARFIELD_SIZE; i++) {
               int map = (int)(t_starfield[i].pos.v[Z]) >> 8;
               int light = 0xFF - ((int)(t_starfield[i].pos.v[Z] * t_starfield[i].pos.v[Z]) >> 12);

               if (map >= 0 && light > 0) {
                    if (map >= NUM_STARS)
                         map = NUM_STARS - 1;

                    view->SetColor( view, light, light, light, 0xff );
                    view->Blit( view, stars[map], NULL,
                                (int)(t_starfield[i].pos.v[X]),
                                (int)(t_starfield[i].pos.v[Y]) );
               }
          }

          view->Flip( view, NULL, DSFLIP_WAITFORSYNC );

          finished_rendering();
     }

     pthread_testcancel();

     return NULL;
}
예제 #6
0
QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
                                         Qt::TransformationMode mode) const
{
    if (!surface || transform.type() != QTransform::TxScale
        || mode != Qt::FastTransformation)
    {
        QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
        const QImage *image = that->buffer();
        if (image) { // avoid deep copy
            const QImage transformed = image->transformed(transform, mode);
            that->unlockDirectFB();
            QDirectFBPixmapData *data = new QDirectFBPixmapData(pixelType());
            data->fromImage(transformed, Qt::AutoColor);
            return QPixmap(data);
        }
        return QPixmapData::transformed(transform, mode);
    }

    int w, h;
    surface->GetSize(surface, &w, &h);

    const QSize size = transform.mapRect(QRect(0, 0, w, h)).size();
    if (size.isEmpty())
        return QPixmap();

    QDirectFBPixmapData *data = new QDirectFBPixmapData(pixelType());
    data->resize(size.width(), size.height());

    IDirectFBSurface *dest = data->surface;
    dest->SetBlittingFlags(dest, DSBLIT_NOFX);

    const DFBRectangle srcRect = { 0, 0, w, h };
    const DFBRectangle destRect = { 0, 0, size.width(), size.height() };
    dest->StretchBlit(dest, surface, &srcRect, &destRect);

    return QPixmap(data);
}
예제 #7
0
static IDirectFBSurface *
load_image (const char *filename)
{
     IDirectFBImageProvider *provider;
     IDirectFBSurface       *tmp     = NULL;
     IDirectFBSurface       *surface = NULL;
     DFBSurfaceDescription   dsc;
     DFBResult               err;

     err = dfb->CreateImageProvider( dfb, filename, &provider );
     if (err != DFB_OK) {
          fprintf( stderr, "Couldn't load image from file '%s': %s\n",
                   filename, DirectFBErrorString( err ));
          return NULL;
     }

     provider->GetSurfaceDescription( provider, &dsc );
     dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
     dsc.pixelformat = DSPF_ARGB;
     if (dfb->CreateSurface( dfb, &dsc, &tmp ) == DFB_OK)
          provider->RenderTo( provider, tmp, NULL );

     provider->Release( provider );

     if (tmp) {
          primary->GetPixelFormat( primary, &dsc.pixelformat );
          if (dfb->CreateSurface( dfb, &dsc, &surface ) == DFB_OK) {
               surface->Clear( surface, 0, 0, 0, 0xFF );
               surface->SetBlittingFlags( surface, DSBLIT_BLEND_ALPHACHANNEL );
               surface->Blit( surface, tmp, NULL, 0, 0 );
          }
          tmp->Release( tmp );
     }

     return surface;
}
예제 #8
0
static int
DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
                    const SDL_Rect * srcrect, const SDL_FRect * dstrect)
{
    DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    IDirectFBSurface *destsurf = data->target;
    DirectFB_TextureData *texturedata =
        (DirectFB_TextureData *) texture->driverdata;
    Uint8 alpha, r, g, b;
    DFBRegion clip_region;
    DFBRectangle sr, dr;

    DirectFB_ActivateRenderer(renderer);

    SDLtoDFBRect(srcrect, &sr);
    SDLtoDFBRect_Float(dstrect, &dr);

    destsurf->GetClip(destsurf, &clip_region);
    dr.x += clip_region.x1;
    dr.y += clip_region.y1;

    if (texturedata->display) {
        int px, py;
        SDL_Window *window = renderer->window;
        IDirectFBWindow *dfbwin = get_dfb_window(window);
        SDL_DFB_WINDOWDATA(window);
        SDL_VideoDisplay *display = texturedata->display;
        DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;

        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->SetSourceRectangle(dispdata->vidlayer,
                                                      sr.x, sr.y, sr.w, sr.h));
        dfbwin->GetPosition(dfbwin, &px, &py);
        px += windata->client.x;
        py += windata->client.y;
        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->SetScreenRectangle(dispdata->vidlayer,
                                                      px + dr.x,
                                                      py + dr.y,
                                                      dr.w,
                                                      dr.h));
    } else {
        DFBSurfaceBlittingFlags flags = 0;

#if 0
        if (texturedata->dirty.list) {
            SDL_DirtyRect *dirty;
            void *pixels;
            int bpp = DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format));
            int pitch = texturedata->pitch;

            for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
                SDL_Rect *rect = &dirty->rect;
                pixels =
                    (void *) ((Uint8 *) texturedata->pixels +
                              rect->y * pitch + rect->x * bpp);
                DirectFB_UpdateTexture(renderer, texture, rect,
                                       pixels,
                                       texturedata->pitch);
            }
            SDL_ClearDirtyRects(&texturedata->dirty);
        }
#endif
        if (texturedata->isDirty)
        {
            SDL_Rect rect;

            rect.x = 0;
            rect.y = 0;
            rect.w = texture->w;
            rect.h = texture->h;

            DirectFB_UpdateTexture(renderer, texture, &rect, texturedata->pixels, texturedata->pitch);
        }

        alpha = r = g = b = 0xff;
        if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA){
            alpha = texture->a;
            flags |= DSBLIT_BLEND_COLORALPHA;
        }

        if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
            r = texture->r;
            g = texture->g;
            b = texture->b;
            flags |= DSBLIT_COLORIZE;
        }
        SDL_DFB_CHECKERR(destsurf->
                         SetColor(destsurf, r, g, b, alpha));

        /* ???? flags |= DSBLIT_SRC_PREMULTCOLOR; */

        SetBlendMode(data, texture->blendMode, texturedata);

        SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf,
                                                    data->blitFlags | flags));

#if (DFB_VERSION_ATLEAST(1,2,0))
        SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
                                                    texturedata->
                                                    render_options));
#endif

        if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
            SDL_DFB_CHECKERR(destsurf->Blit(destsurf,
                                            texturedata->surface,
                                            &sr, dr.x, dr.y));
        } else {
            SDL_DFB_CHECKERR(destsurf->StretchBlit(destsurf,
                                                   texturedata->surface,
                                                   &sr, &dr));
        }
    }
    return 0;
  error:
    return -1;
}
예제 #9
0
void
DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window)
{
    SDL_DFB_WINDOWDATA(window);
    IDirectFBSurface *s = windata->window_surface;
    DFB_Theme *t = &windata->theme;
    int i;
    int d = (t->caption_size - t->font_size) / 2;
    int x, y, w;


    if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN))
        return;

    SDL_DFB_CHECK(s->SetSrcBlendFunction(s, DSBF_ONE));
    SDL_DFB_CHECK(s->SetDstBlendFunction(s, DSBF_ZERO));
    SDL_DFB_CHECK(s->SetDrawingFlags(s, DSDRAW_NOFX));
    SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX));

    LoadFont(_this, window);
    /* s->SetDrawingFlags(s, DSDRAW_BLEND); */
    s->SetColor(s, COLOR_EXPAND(t->frame_color));
    /* top */
    for (i = 0; i < t->top_size; i++)
        s->DrawLine(s, 0, i, windata->size.w, i);
    /* bottom */
    for (i = windata->size.h - t->bottom_size; i < windata->size.h; i++)
        s->DrawLine(s, 0, i, windata->size.w, i);
    /* left */
    for (i = 0; i < t->left_size; i++)
        s->DrawLine(s, i, 0, i, windata->size.h);
    /* right */
    for (i = windata->size.w - t->right_size; i < windata->size.w; i++)
        s->DrawLine(s, i, 0, i, windata->size.h);
    /* Caption */
    s->SetColor(s, COLOR_EXPAND(t->caption_color));
    s->FillRectangle(s, t->left_size, t->top_size, windata->client.w,
                     t->caption_size);
    /* Close Button */
    w = t->caption_size;
    x = windata->size.w - t->right_size - w + d;
    y = t->top_size + d;
    s->SetColor(s, COLOR_EXPAND(t->close_color));
    DrawTriangle(s, 1, x, y, w - 2 * d);
    /* Max Button */
    s->SetColor(s, COLOR_EXPAND(t->max_color));
    DrawTriangle(s, window->flags & SDL_WINDOW_MAXIMIZED ? 1 : 0, x - w,
               y, w - 2 * d);

    /* Caption */
    if (*window->title) {
        s->SetColor(s, COLOR_EXPAND(t->font_color));
        DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
    }
    /* Icon */
    if (windata->icon) {
        DFBRectangle dr;

        dr.x = t->left_size + d;
        dr.y = t->top_size + d;
        dr.w = w - 2 * d;
        dr.h = w - 2 * d;
        s->SetBlittingFlags(s, DSBLIT_BLEND_ALPHACHANNEL);

        s->StretchBlit(s, windata->icon, NULL, &dr);
    }
    windata->wm_needs_redraw = 0;
}
예제 #10
0
int
main( int argc, char *argv[] )
{
     int                     i;
     DFBResult               ret;
     DFBSurfaceDescription   desc;
     IDirectFB              *dfb;
     IDirectFBImageProvider *provider = NULL;
     IDirectFBSurface       *source   = NULL;
     IDirectFBSurface       *dest     = NULL;
     const char             *url      = NULL;

     /* Parse arguments. */
     for (i=1; i<argc; i++) {
          if (!strcmp( argv[i], "-h" ))
               return show_usage( argv[0] );
          else if (!url)
               url = argv[i];
          else
               return show_usage( argv[0] );
     }

     /* Check if we got an URL. */
     if (!url)
          return show_usage( argv[0] );
          
     /* Initialize DirectFB. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          D_DERROR( ret, "DFBTest/Scale: DirectFBInit() failed!\n" );
          return ret;
     }

     /* Create super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/Scale: DirectFBCreate() failed!\n" );
          return ret;
     }

     /* Create an image provider for the image to be loaded. */
     ret = dfb->CreateImageProvider( dfb, url, &provider );
     if (ret) {
          D_DERROR( ret, "DFBTest/Scale: IDirectFB::CreateImageProvider( '%s' ) failed!\n", url );
          goto out;
     }

     /* Get the surface description. */
     ret = provider->GetSurfaceDescription( provider, &desc );
     if (ret) {
          D_DERROR( ret, "DFBTest/Scale: IDirectFBImageProvider::GetSurfaceDescription() failed!\n" );
          goto out;
     }
     
     desc.pixelformat = DSPF_LUT8;

     D_INFO( "DFBTest/Scale: Source is %dx%d using %s\n",
             desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );

     /* Create a surface for the image. */
     ret = dfb->CreateSurface( dfb, &desc, &source );
     if (ret) {
          D_DERROR( ret, "DFBTest/Scale: IDirectFB::CreateSurface() failed!\n" );
          goto out;
     }
     
     ret = provider->RenderTo( provider, source, NULL );
     if (ret) {
          D_DERROR( ret, "DFBTest/Scale: IDirectFBImageProvider::RenderTo() failed!\n" );
          goto out;
     }
     
     desc.width  = desc.width  * 3 / 4;
     desc.height = desc.height * 3 / 4;

     if (DFB_PIXELFORMAT_IS_INDEXED( desc.pixelformat ))
          desc.pixelformat = DSPF_ARGB;

     D_INFO( "DFBTest/Scale: Destination is %dx%d using %s\n",
             desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );

     /* Create a surface for the image. */
     ret = dfb->CreateSurface( dfb, &desc, &dest );
     if (ret) {
          D_DERROR( ret, "DFBTest/Scale: IDirectFB::CreateSurface() failed!\n" );
          goto out;
     }

     dest->SetBlittingFlags( dest, DSBLIT_SRC_PREMULTIPLY );
     dest->StretchBlit( dest, source, NULL, NULL );

     dest->Dump( dest, "dfbtest_scale", NULL );


out:
     if (dest)
          dest->Release( dest );

     if (source)
          source->Release( source );

     if (provider)
          provider->Release( provider );

     /* Shutdown DirectFB. */
     dfb->Release( dfb );

     return ret;
}
예제 #11
0
//---------------------------------------------------------------------------------
//--------------------------wael work----------------------
//---------------------------------------------------------------------------------
status_t ServerWindow::CreateWindow (IDirectFBDisplayLayer *layer){

  DFBFontDescription font_dsc;
  DFBWindowDescription wdsc;  
  IDirectFBSurface *wsurface = NULL;
  DFBSurfaceDescription dsc;
  
//  char *title;TODO: I need to convert the fTitle from BString to char *
  char title[fTitle.CountChars()+1];
  fTitle.CopyInto(title, 0, fTitle.CountChars());
  DFBRectangle frame;
  frame.x=(int)fFrame.LeftTop().x;
  frame.y=(int)fFrame.LeftTop().y;
  frame.w=(int)fFrame.IntegerWidth();
  frame.h=(int)fFrame.IntegerHeight();
    
  int width1, width2, width3;
  int height1, height2, height3;

  //create window inside the primary layer  
  wdsc.flags = (DFBWindowDescriptionFlags)(DWDESC_CAPS | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_SURFACE_CAPS);
  wdsc.caps = DWCAPS_ALPHACHANNEL;
  wdsc.width = frame.w;
  wdsc.height = frame.h;
  wdsc.posx = frame.x;
  wdsc.posy = frame.y;
  wdsc.surface_caps = DSCAPS_FLIPPING;
  DFBCHECK(layer->CreateWindow(layer, &wdsc, &window));
  
  //Get the window surface and clear it
  DFBCHECK(window->GetSurface(window, &wsurface));  
  DFBCHECK(wsurface->Clear (wsurface, 0x00, 0x00, 0x00, 0x00));
  DFBCHECK(window->SetOpaqueRegion (window, 0, 0, frame.h, frame.w));
  
  //Set the window options to be transparent
  DFBWindowOptions options;
  window->GetOptions (window, &options);
  
  options = (DFBWindowOptions) ( options | DWOP_SHAPED );
  DFBCHECK(window->SetOptions (window, options));  
  wsurface->SetSrcColorKey(wsurface, R, G, B);
  wsurface->SetBlittingFlags(wsurface, DSBLIT_SRC_COLORKEY);  
        
  if (fType==B_FLOATING_WINDOW){
  	DFBCHECK (shead->GetSize(shead, &width1, &height1));
	DFBCHECK (sok_button->GetSize(sok_button, &width2, &height2));
	DFBCHECK (sclose_button->GetSize(sclose_button, &width3, &height3));

	DFBRectangle rect;
	rect.x = 0;
	rect.y = 0;
	rect.h = height1;
	rect.w = frame.w-width2-width3;
	DFBCHECK (wsurface->StretchBlit (wsurface, shead, NULL, &rect));
	DFBCHECK (wsurface->Blit (wsurface, sok_button, NULL, rect.w, 0));
  	DFBCHECK (wsurface->Blit (wsurface, sclose_button, NULL, rect.w+width2, 0));	  	

  	// Draw the window title
  	font_dsc.flags = DFDESC_HEIGHT;
  	font_dsc.height = 10;
  	font_dsc.width = 10;  
  	DFBCHECK (app_server->dfb->CreateFont (app_server->dfb, "./decker.ttf", &font_dsc, &font));
  	DFBCHECK (wsurface->SetFont (wsurface, font));
  	DFBCHECK (wsurface->SetColor (wsurface, 0xff, 0x0, 0x0, 0xFF));
	int size = 0;
	DFBRectangle rect1;		
  	DFBCHECK (font->GetStringExtents (font, title, -1, NULL, &rect1));
	if (rect1.w > rect.w){
		do{
			size++;
			DFBCHECK (font->GetStringExtents (font, title, size, NULL, &rect1));
		}while (rect1.w < rect.w);
		size--;
	}  		  	
	DFBCHECK (wsurface->DrawString (wsurface, title, size-1, 5, 2*height1/3, DSTF_LEFT));	
		
	rect.x = 0;
	rect.y = height1;
	rect.w = frame.w;
	rect.h = frame.h-height1;
	DFBCHECK (wsurface->StretchBlit (wsurface, body, NULL, &rect));	
  }
  else if (fType==B_TITLED_WINDOW){
  	DFBCHECK (head->GetSize(head, &width1, &height1));
	DFBCHECK (ok_button->GetSize(ok_button, &width2, &height2));
	DFBCHECK (close_button->GetSize(close_button, &width3, &height3));

	DFBRectangle rect;
	rect.x = 0;
	rect.y = 0;
	rect.h = height1;
	rect.w = frame.w-width2-width3;
	DFBCHECK (wsurface->StretchBlit (wsurface, head, NULL, &rect));
	DFBCHECK (wsurface->Blit (wsurface, ok_button, NULL, rect.w, 0));
  	DFBCHECK (wsurface->Blit (wsurface, close_button, NULL, rect.w+width2, 0));
	
	// Draw the window title
  	font_dsc.flags = DFDESC_HEIGHT;
  	font_dsc.height = 15;
  	font_dsc.width = 15;  
  	DFBCHECK (app_server->dfb->CreateFont (app_server->dfb, "./decker.ttf", &font_dsc, &font));
  	DFBCHECK (wsurface->SetFont (wsurface, font));
  	DFBCHECK (wsurface->SetColor (wsurface, 0x0, 0x10, 0xfa, 0xFF));
	int size = 0;
	DFBRectangle rect1;		
  	DFBCHECK (font->GetStringExtents (font, title, -1, NULL, &rect1));
	if (rect1.w > rect.w){
		do{
			size++;
			DFBCHECK (font->GetStringExtents (font, title, size, NULL, &rect1));
		}while (rect1.w < rect.w);
		size-=2;
	}  		
	DFBCHECK (wsurface->DrawString (wsurface, title, -1, 6, 2*height1/3, DSTF_LEFT));	
		
	rect.x = 0;
	rect.y = height1;
	rect.w = frame.w;
	rect.h = frame.h-height1;
  	DFBCHECK (wsurface->StretchBlit (wsurface, body, NULL, &rect));  	
  }
  else if (fType==B_MODAL_WINDOW){
  }
  created = true;

}
예제 #12
0
	ISurface* DFBImageProvider::prepare(bool isGif) {
		ISurface* renderedSurface = NULL;

		IDirectFBImageProvider* ip;
		ip = (IDirectFBImageProvider*)decoder;

		DFBImageDescription imgDsc;
		IDirectFBSurface* destination = NULL;
		DFBSurfaceDescription surDsc;
		IColor* chromaKey = NULL;

		//IDirectFBSurface* source;
		if ((ip->GetImageDescription(ip, &imgDsc) == DFB_OK) &&
			 (ip->GetSurfaceDescription(ip, &surDsc) == DFB_OK)) {

			destination = (IDirectFBSurface*)(
					LocalDeviceManager::getInstance()->createSurface(&surDsc));

			renderedSurface = new DFBSurface(destination);

			if (imgDsc.caps & DICAPS_ALPHACHANNEL) {
				/*cout << "ImagePlayer::ImagePlayer(" << mrl << ")";
				cout << " setted alphachannel: ";*/

				//alpha channel of gif does not exists anymore, it turn into
				//black src color key (marcio 20/04/2007)
				if (isGif) {
					chromaKey = new Color(0, 0, 0);
					renderedSurface->setChromaColor(chromaKey);
					//outputDisplay->setColorKey(0, 0, 0);
					//cout << "black color cause it is a gif image" << endl;

				} else {
					renderedSurface->setCaps(DWCAPS_ALPHACHANNEL);
				}

				//cout << " trying to blit image alpha channel" << endl;

				DFBCHECK(destination->SetBlittingFlags(destination,
					 (DFBSurfaceBlittingFlags)(DSBLIT_BLEND_ALPHACHANNEL)));

				/*cout << "ImagePlayer::ImagePlayer(" << mrl << ")";
				cout << " setted alpha: '";
				cout << (((int)(imgDsc.colorkey_r & 0xFF)) & 0xFF);
				cout << ", " << (((int)(imgDsc.colorkey_g)) & 0xFF);
				cout << ", " << (((int)(imgDsc.colorkey_b)) & 0xFF);
				cout << "'" << endl;*/
			}

			if (imgDsc.caps & DICAPS_COLORKEY) {
				chromaKey = new Color(
					    imgDsc.colorkey_r,
					    imgDsc.colorkey_g,
					    imgDsc.colorkey_b);

				DFBCHECK(destination->SetBlittingFlags(destination,
					    (DFBSurfaceBlittingFlags)(
					    DSBLIT_BLEND_ALPHACHANNEL |
					    DSBLIT_SRC_COLORKEY)));

				renderedSurface->setChromaColor(chromaKey);
				/*cout << "ImagePlayer::ImagePlayer(" << mrl << ")";
				cout << " setted colorkey: '";
				cout << (((int)(imgDsc.colorkey_r & 0xFF)) & 0xFF);
				cout << ", " << (((int)(imgDsc.colorkey_g)) & 0xFF);
				cout << ", " << (((int)(imgDsc.colorkey_b)) & 0xFF);
				cout << "'" << endl;*/
			}

			if (imgDsc.caps & DICAPS_NONE) {
				DFBCHECK(destination->SetBlittingFlags(destination,
					    (DFBSurfaceBlittingFlags)DSBLIT_NOFX));

				renderedSurface->setCaps(DWCAPS_NONE);
				/*cout << "ImagePlayer::ImagePlayer(" << mrl << ")";
				cout << " NOFX" << endl;*/
			}
		}

		if (destination != NULL && renderedSurface != NULL) {
			DFBCHECK(ip->RenderTo(
					ip,
					(IDirectFBSurface*)(renderedSurface->getContent()), NULL));
		}
		return renderedSurface;
	}
예제 #13
0
int
main( int argc, char *argv[] )
{
     int                     i;
     DFBResult               ret;
     DFBSurfaceDescription   desc;
     IDirectFB              *dfb;
     IDirectFBImageProvider *provider      = NULL;
     IDirectFBSurface       *source        = NULL;
     IDirectFBSurface       *dest          = NULL;
     const char             *url           = NULL;
     DFBSurfacePixelFormat   source_format = DSPF_UNKNOWN;
     DFBSurfacePixelFormat   dest_format   = DSPF_UNKNOWN;
     bool                    dest_resize   = false;

     /* Initialize DirectFB. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          D_DERROR( ret, "DFBTest/Blit: DirectFBInit() failed!\n" );
          return ret;
     }

     /* Parse arguments. */
     for (i=1; i<argc; i++) {
          const char *arg = argv[i];

          if (strcmp( arg, "-h" ) == 0 || strcmp (arg, "--help") == 0)
               return print_usage( argv[0] );
          else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
               fprintf (stderr, "dfbtest_blit version %s\n", DIRECTFB_VERSION);
               return false;
          }
          else if (strcmp (arg, "-s") == 0 || strcmp (arg, "--source") == 0) {
               if (++i == argc) {
                    print_usage (argv[0]);
                    return false;
               }

               if (!parse_format( argv[i], &source_format ))
                    return false;
          }
          else if (strcmp (arg, "-d") == 0 || strcmp (arg, "--dest") == 0) {
               if (++i == argc) {
                    print_usage (argv[0]);
                    return false;
               }

               if (!parse_format( argv[i], &dest_format ))
                    return false;
          }
          else if (strcmp (arg, "-r") == 0 || strcmp (arg, "--resize") == 0)
               dest_resize = true;
          else if (!url)
               url = arg;
          else
               return print_usage( argv[0] );
     }

     /* Check if we got an URL. */
     if (!url)
          return print_usage( argv[0] );
          
     /* Create super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/Blit: DirectFBCreate() failed!\n" );
          return ret;
     }

     /* Create an image provider for the image to be loaded. */
     ret = dfb->CreateImageProvider( dfb, url, &provider );
     if (ret) {
          D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateImageProvider( '%s' ) failed!\n", url );
          goto out;
     }

     /* Get the surface description. */
     ret = provider->GetSurfaceDescription( provider, &desc );
     if (ret) {
          D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::GetSurfaceDescription() failed!\n" );
          goto out;
     }

     if (source_format != DSPF_UNKNOWN)
          desc.pixelformat = source_format;
     
     D_INFO( "DFBTest/Blit: Source is %dx%d using %s\n",
             desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );

     /* Create a surface for the image. */
     ret = dfb->CreateSurface( dfb, &desc, &source );
     if (ret) {
          D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
          goto out;
     }
     
     ret = provider->RenderTo( provider, source, NULL );
     if (ret) {
          D_DERROR( ret, "DFBTest/Blit: IDirectFBImageProvider::RenderTo() failed!\n" );
          goto out;
     }

     /* Fill description for a primary surface. */
     desc.flags = DSDESC_CAPS;
     desc.caps  = DSCAPS_PRIMARY | DSCAPS_FLIPPING;

     if (dest_format != DSPF_UNKNOWN) {
          desc.flags       |= DSDESC_PIXELFORMAT;
          desc.pixelformat  = dest_format;
     }

     if (dest_resize)
          desc.flags |= DSDESC_WIDTH | DSDESC_HEIGHT;

     dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );

     /* Create a primary surface. */
     ret = dfb->CreateSurface( dfb, &desc, &dest );
     if (ret) {
          D_DERROR( ret, "DFBTest/Blit: IDirectFB::CreateSurface() failed!\n" );
          goto out;
     }

     dest->GetSize( dest, &desc.width, &desc.height );
     dest->GetPixelFormat( dest, &desc.pixelformat );

     D_INFO( "DFBTest/Blit: Destination is %dx%d using %s\n",
             desc.width, desc.height, dfb_pixelformat_name(desc.pixelformat) );

     for (i=0; i<100000; i++) {
          int j,n = rand()%100;

          for (j=0; j<n; j++) {
               switch (rand()%3) {
                    case 0:
                         dest->SetDrawingFlags( dest, rand() & (DSDRAW_BLEND) );
                         dest->FillRectangle( dest, rand()%100, rand()%100, rand()%100, rand()%100 );
                         break;

                    case 1:
                         dest->SetBlittingFlags( dest, rand() & (DSBLIT_BLEND_ALPHACHANNEL |
                                                                 DSBLIT_BLEND_COLORALPHA   |
                                                                 DSBLIT_COLORIZE           |
                                                                 DSBLIT_ROTATE90) );
                         dest->Blit( dest, source, NULL, rand()%100, rand()%100 );
                         break;

                    case 2:
                         dest->SetBlittingFlags( dest, rand() & (DSBLIT_BLEND_ALPHACHANNEL |
                                                                 DSBLIT_BLEND_COLORALPHA   |
                                                                 DSBLIT_COLORIZE           |
                                                                 DSBLIT_ROTATE90) );
                         dest->StretchBlit( dest, source, NULL, NULL );
                         break;
               }
          }

          dfb->WaitIdle( dfb );

          dest->Flip( dest, NULL, DSFLIP_NONE );
     }

out:
     if (dest)
          dest->Release( dest );

     if (source)
          source->Release( source );

     if (provider)
          provider->Release( provider );

     /* Shutdown DirectFB. */
     dfb->Release( dfb );

     return ret;
}