コード例 #1
0
static cairo_surface_t *
_cairo_boilerplate_directfb_bitmap_create_surface (DFBInfo	   *info,
						   cairo_content_t  content,
						   int		    width,
						   int		    height)
{
    int  err;
    DFBSurfaceDescription  desc;

    D_DEBUG_AT (CairoDFB_Boiler, "%s (%p, %s, %dx%d)\n", __FUNCTION__, info,
		content == CAIRO_CONTENT_ALPHA	     ? "ALPHA" :
		content == CAIRO_CONTENT_COLOR	     ? "RGB"   :
		content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB"  : "unknown content!",
		width, height);

    desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;
    desc.caps = DSCAPS_NONE;
    desc.width	= width;
    desc.height = height;
    if (content == CAIRO_CONTENT_COLOR_ALPHA) {
	desc.flags |= DSDESC_PIXELFORMAT;
	desc.pixelformat = DSPF_ARGB;
    }
    DFBCHECK (info->dfb->CreateSurface (info->dfb, &desc, &info->surface));

    return cairo_directfb_surface_create (info->dfb, info->surface);

ERROR:
    _cairo_boilerplate_directfb_cleanup (info);
    return NULL;
}
コード例 #2
0
ファイル: zkplayerutil.c プロジェクト: jamesyan84/zbase
void ZDrawSongInfo(IDirectFB *dfb, IDirectFBSurface *dfbsurface, const gchar *title, const gchar *artist, 
		gint w, gint h, DFBColor *color, DFBColor *strokeColor, double strokeWidth, const PangoFontDescription *desc)
{
	cairo_t *cr = NULL;
	cairo_surface_t *surface = NULL;
	cairo_surface_t *cairosurface = NULL;
	PangoLayout *layout = NULL;
	
	if(!dfb || !dfbsurface)
		return;
	
	/* prepare layout */
	layout = pango_layout_new(gdk_pango_context_get());
	pango_layout_set_single_paragraph_mode (layout, TRUE);
	pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
	pango_layout_set_width(layout, w* PANGO_SCALE);
	pango_layout_set_font_description(layout, desc);
	
	surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
	cr = cairo_create(surface);
	
	/* Draw title */
	if(title) {
		pango_layout_set_text(layout, title, -1);
		cairo_move_to(cr, 0, 0);
		pango_cairo_layout_path(cr, layout);
		ZCairoSetDFBColor(cr, strokeColor);
		cairo_set_line_width(cr, strokeWidth);
		cairo_stroke_preserve(cr);
		
		ZCairoSetDFBColor(cr, color);
		cairo_fill(cr);
	}
	
	/* Draw artist */
	if(artist) {
		pango_layout_set_text(layout, artist, -1);
		cairo_move_to(cr, 0, h/2);
		pango_cairo_layout_path(cr, layout);
		ZCairoSetDFBColor(cr, strokeColor);
		cairo_set_line_width(cr, strokeWidth);
		cairo_stroke_preserve(cr);
		
		ZCairoSetDFBColor(cr, color);
		cairo_fill(cr);
	}
	
	g_object_unref(layout);
	cairo_destroy(cr);
	
	/* Draw cairo_surface to dfbsurface */
	/* create surface */
	cairosurface = cairo_directfb_surface_create(dfb, dfbsurface);
	cr = cairo_create(cairosurface);
	cairo_set_source_surface(cr, surface, 0, 0);
	cairo_paint(cr);
	cairo_destroy(cr);
	cairo_surface_destroy(surface);
	cairo_surface_destroy(cairosurface);
}
コード例 #3
0
ファイル: Surface.cpp プロジェクト: Ecro/ilixi
cairo_surface_t*
Surface::cairoSurface()
{
    if (!_cairoSurface)
        _cairoSurface = cairo_directfb_surface_create(PlatformManager::instance().getDFB(), _dfbSurface);
    return _cairoSurface;
}
コード例 #4
0
ファイル: DragHelper.cpp プロジェクト: 91yuan/ilixi
void
DragHelper::setImageFromCairoSurface(cairo_surface_t* cairoSurface)
{
    ILOG_TRACE_W(ILX_DRAGHELPER);

    if (_surface)
        _surface->Release(_surface);

    int width = cairo_image_surface_get_width(cairoSurface);
    int height = cairo_image_surface_get_height(cairoSurface);

    DFBSurfaceDescription desc;
    desc.flags = (DFBSurfaceDescriptionFlags) (DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS);
    desc.width = width;
    desc.height = height;
    desc.pixelformat = PlatformManager::instance().forcedPixelFormat();
    desc.caps = DSCAPS_VIDEOONLY;

    PlatformManager::instance().getDFB()->CreateSurface(PlatformManager::instance().getDFB(), &desc, &_surface);

    cairo_surface_t* surface = cairo_directfb_surface_create(PlatformManager::instance().getDFB(), _surface);
    cairo_t* context = cairo_create(surface);
    cairo_set_source_surface(context, cairoSurface, 0, 0);
    cairo_paint(context);
    cairo_destroy(context);
    cairo_surface_destroy(surface);
}
コード例 #5
0
gfxDirectFBSurface::gfxDirectFBSurface(const gfxIntSize& size, gfxImageFormat format) :
    mDFB(nsnull), mDFBSurface(nsnull)
{
    DFBResult             ret;
    DFBSurfaceDescription desc;

    if (!CheckSurfaceSize(size) || size.width <= 0 || size.height <= 0)
        return;

    /* Lightweight, getting singleton */
    ret = DirectFBCreate( &mDFB );
    if (ret) {
        D_DERROR( (DirectResult) ret, "gfxDirectFBSurface: DirectFBCreate() failed!\n" );
        return;
    }

    desc.flags  = (DFBSurfaceDescriptionFlags)( DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT );
    desc.width  = size.width;
    desc.height = size.height;

    switch (format) {
    case gfxASurface::ImageFormatARGB32:
        desc.pixelformat = DSPF_ARGB;
        break;

    case gfxASurface::ImageFormatRGB24:
        desc.pixelformat = DSPF_RGB32;
        break;

    case gfxASurface::ImageFormatA8:
        desc.pixelformat = DSPF_A8;
        break;

    case gfxASurface::ImageFormatA1:
        desc.pixelformat = DSPF_A1;
        break;

    default:
        D_BUG( "unknown format" );
        return;
    }

    ret = mDFB->CreateSurface( mDFB, &desc, &mDFBSurface );
    if (ret) {
        D_DERROR( (DirectResult) ret, "gfxDirectFBSurface: "
                  "IDirectFB::CreateSurface( %dx%d ) failed!\n", desc.width, desc.height );
        return;
    }

    cairo_surface_t *surface = cairo_directfb_surface_create(mDFB, mDFBSurface);

    Init(surface);
}
コード例 #6
0
gfxDirectFBSurface::gfxDirectFBSurface(IDirectFB *dfb, IDirectFBSurface *dfbs)
    : mDFB(nsnull), mDFBSurface(nsnull)
{
    dfb->AddRef( dfb );
    dfbs->AddRef( dfbs );

    cairo_surface_t *surf = cairo_directfb_surface_create(dfb, dfbs);

    mDFB = dfb;
    mDFBSurface = dfbs;

    Init(surf);
}
コード例 #7
0
ファイル: zkplayerutil.c プロジェクト: jamesyan84/zbase
void ZCairoBlit(cairo_surface_t *cairosurface, IDirectFB *dfb, IDirectFBSurface *dfbsurface, 
		gint source_x, gint source_y, gint dest_x, gint dest_y, gint width, gint height)
{
	cairo_t *cr = NULL;
	cairo_surface_t *surface = NULL;
	
	surface = cairo_directfb_surface_create(dfb, dfbsurface);
	cr = cairo_create(surface);
	cairo_set_source_surface(cr, cairosurface, dest_x - source_x, dest_y - source_y);
	cairo_rectangle(cr, dest_x, dest_y, width, height);
	cairo_fill(cr);
	cairo_destroy(cr);
	cairo_surface_destroy(surface);
}
コード例 #8
0
gfxDirectFBSurface::gfxDirectFBSurface(IDirectFBSurface *dfbs)
    : mDFB(nsnull), mDFBSurface(nsnull)
{
    DFBResult ret;

    dfbs->AddRef( dfbs );

    /* Lightweight, getting singleton */
    ret = DirectFBCreate( &mDFB );
    if (ret) {
        D_DERROR( (DirectResult) ret, "gfxDirectFBSurface: DirectFBCreate() failed!\n" );
        return;
    }

    cairo_surface_t *surf = cairo_directfb_surface_create(mDFB, dfbs);

    mDFBSurface = dfbs;

    Init(surf);
}
コード例 #9
0
static cairo_surface_t *
_cairo_boilerplate_directfb_window_create_surface (DFBInfo	   *info,
						   cairo_content_t  content,
						   int		    width,
						   int		    height)
{
    DFBWindowDescription desc;
    int err;

    D_DEBUG_AT (CairoDFB_Boiler, "%s (%p, %s, %dx%d)\n", __FUNCTION__, info,
		content == CAIRO_CONTENT_ALPHA	     ? "ALPHA" :
		content == CAIRO_CONTENT_COLOR	     ? "RGB"   :
		content == CAIRO_CONTENT_COLOR_ALPHA ? "ARGB"  : "unknown content!",
		width, height);

    desc.flags	= DWDESC_POSX | DWDESC_POSY |
		  DWDESC_WIDTH | DWDESC_HEIGHT;
    desc.caps	= DSCAPS_NONE;
    desc.posx	= 0;
    desc.posy	= 0;
    desc.width	= width;
    desc.height = height;
    if (content == CAIRO_CONTENT_COLOR_ALPHA) {
	desc.flags |= DWDESC_CAPS | DWDESC_PIXELFORMAT;
	desc.caps  |= DWCAPS_DOUBLEBUFFER | DWCAPS_ALPHACHANNEL;
	desc.pixelformat = DSPF_ARGB;
    }

    DFBCHECK (info->layer->CreateWindow (info->layer, &desc, &info->window));
    info->window->SetOpacity (info->window, 0xFF);
    info->window->GetSurface (info->window, &info->surface);
    info->surface->SetColor (info->surface, 0xFF, 0xFF, 0xFF, 0xFF);
    info->surface->FillRectangle (info->surface,0, 0, desc.width, desc.height);
    info->surface->Flip (info->surface, NULL, 0);

    return cairo_directfb_surface_create (info->dfb, info->surface);

ERROR:
    _cairo_boilerplate_directfb_cleanup (info);
    return NULL;
}