Beispiel #1
0
void QDirectFBPixmapData::resize(int width, int height)
{
    if (width <= 0 || height <= 0) {
        setSerialNumber(0);
        return;
    }

    IDirectFB *dfb = QDirectFBScreen::instance()->dfb();
    if (!dfb)
        qFatal("QDirectFBPixmapData::resize(): "
               "Unable to get DirectFB handle!");

    DFBSurfaceDescription description;
    description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH |
                                                   DSDESC_HEIGHT);
    description.width = width;
    description.height = height;

    DFBResult result = dfb->CreateSurface(dfb, &description, &surface);
    if (result != DFB_OK) {
        DirectFBErrorFatal("QDirectFBPixmapData::resize(): "
                           "Unable to allocate surface", result);
    }

    setSerialNumber(++global_ser_no);
}
void QDirectFBWindowSurface::createWindow(const QRect &rect)
{
    IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer();
    if (!layer)
        qFatal("QDirectFBWindowSurface: Unable to get primary display layer!");

    updateIsOpaque();

    DFBWindowDescription description;
    memset(&description, 0, sizeof(DFBWindowDescription));

    description.flags = DWDESC_CAPS|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT;
    description.caps = DWCAPS_NODECORATION;
    description.surface_caps = DSCAPS_NONE;
    imageFormat = screen->pixelFormat();

    if (!(surfaceFlags() & Opaque)) {
        imageFormat = screen->alphaPixmapFormat();
        description.caps |= DWCAPS_ALPHACHANNEL;
#if (Q_DIRECTFB_VERSION >= 0x010200)
        description.flags |= DWDESC_OPTIONS;
        description.options |= DWOP_ALPHACHANNEL;
#endif
    }
    description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(imageFormat);
    description.posx = rect.x();
    description.posy = rect.y();
    description.width = rect.width();
    description.height = rect.height();

    if (QDirectFBScreen::isPremultiplied(imageFormat))
        description.surface_caps = DSCAPS_PREMULTIPLIED;

    if (screen->directFBFlags() & QDirectFBScreen::VideoOnly)
        description.surface_caps |= DSCAPS_VIDEOONLY;

    DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow);

    if (result != DFB_OK)
        DirectFBErrorFatal("QDirectFBWindowSurface::createWindow", result);

    if (window()) {
        if (window()->windowFlags() & Qt::WindowStaysOnTopHint) {
            dfbWindow->SetStackingClass(dfbWindow, DWSC_UPPER);
        }
        DFBWindowID winid;
        result = dfbWindow->GetID(dfbWindow, &winid);
        if (result != DFB_OK) {
            DirectFBError("QDirectFBWindowSurface::createWindow. Can't get ID", result);
        } else {
            window()->setProperty("_q_DirectFBWindowID", winid);
        }
    }

    Q_ASSERT(!dfbSurface);
    dfbWindow->GetSurface(dfbWindow, &dfbSurface);
}
IDirectFBDisplayLayer *QDirectFbConvenience::dfbDisplayLayer(int display)
{
    IDirectFBDisplayLayer *layer;
    DFBResult result = QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),display,&layer);
    if (result != DFB_OK)
        DirectFBErrorFatal("QDirectFbConvenience: "
                           "Unable to get primary display layer!", result);
    return layer;
}
Beispiel #4
0
static DFBEnumerationResult
screen_callback( DFBScreenID           id,
                 DFBScreenDescription  desc,
                 void                 *arg )
{
     int              i;
     DFBResult        ret;
     IDirectFBScreen *screen;

     ret = dfb->GetScreen( dfb, id, &screen );
     if (ret)
          DirectFBErrorFatal( "IDirectFB::GetScreen", ret );

     /* Name */
     printf( "Screen (%02x) %-30s", id, desc.name );

     switch (id) {
          case DSCID_PRIMARY:
               printf( "  (primary screen)" );
               break;
          default:
               break;
     }

     printf( "\n" );

     /* Caps */
     printf( "   Caps: " );

     for (i=0; screen_caps[i].capability; i++) {
          if (desc.caps & screen_caps[i].capability)
               printf( "%s ", screen_caps[i].name );
     }

     printf( "\n\n" );


     /* Mixers */
     if (desc.mixers)
          dump_mixers( screen, desc.mixers );

     /* Encoders */
     if (desc.encoders)
          dump_encoders( screen, desc.encoders );

     /* Outputs */
     if (desc.outputs)
          dump_outputs( screen, desc.outputs );

     /* Display layers */
     enum_display_layers( screen );

     screen->Release( screen );

     return DFB_OK;
}
QT_BEGIN_NAMESPACE

IDirectFB *QDirectFbConvenience::dfbInterface()
{
    static IDirectFB *dfb = 0;
    if (!dfb) {
        DFBResult result = DirectFBCreate(&dfb);
        if (result != DFB_OK) {
            DirectFBErrorFatal("QDirectFBConvenience: error creating DirectFB interface", result);
            return 0;
        }
    }
    return dfb;
}
Beispiel #6
0
void df_Pointer_New(rdpContext* context, rdpPointer* pointer)
{
	dfInfo* dfi;
	DFBResult result;
	dfPointer* df_pointer;
	DFBSurfaceDescription dsc;

	dfi = ((dfContext*) context)->dfi;
	df_pointer = (dfPointer*) pointer;

	dsc.flags = DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
	dsc.caps = DSCAPS_SYSTEMONLY;
	dsc.width = pointer->width;
	dsc.height = pointer->height;
	dsc.pixelformat = DSPF_ARGB;

	result = dfi->dfb->CreateSurface(dfi->dfb, &dsc, &(df_pointer->surface));

	if (result == DFB_OK)
	{
		int pitch;
		uint8* point = NULL;

		df_pointer->xhot = pointer->xPos;
		df_pointer->yhot = pointer->yPos;

		result = df_pointer->surface->Lock(df_pointer->surface,
				DSLF_WRITE, (void**) &point, &pitch);

		if (result != DFB_OK)
		{
			DirectFBErrorFatal("Error while creating pointer surface", result);
			return;
		}

		if ((pointer->andMaskData != 0) && (pointer->xorMaskData != 0))
		{
			freerdp_alpha_cursor_convert(point, pointer->xorMaskData, pointer->andMaskData,
					pointer->width, pointer->height, pointer->xorBpp, dfi->clrconv);
		}

		if (pointer->xorBpp > 24)
		{
			freerdp_image_swap_color_order(point, pointer->width, pointer->height);
		}

		df_pointer->surface->Unlock(df_pointer->surface);
	}
}
Beispiel #7
0
void df_Pointer_Set(rdpContext* context, rdpPointer* pointer)
{
	dfInfo* dfi;
	DFBResult result;
	dfPointer* df_pointer;

	dfi = ((dfContext*) context)->dfi;
	df_pointer = (dfPointer*) pointer;

	dfi->layer->SetCooperativeLevel(dfi->layer, DLSCL_ADMINISTRATIVE);

	result = dfi->layer->SetCursorShape(dfi->layer,
			df_pointer->surface, df_pointer->xhot, df_pointer->yhot);

	if (result != DFB_OK)
	{
		DirectFBErrorFatal("SetCursorShape Error", result);
		return;
	}

	dfi->layer->SetCooperativeLevel(dfi->layer, DLSCL_SHARED);
}
void CFbAccel::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp)
{
	DFBRectangle src;
	DFBResult err;
	IDirectFBSurface *surf;
	DFBSurfaceDescription dsc;

	src.x = xp;
	src.y = yp;
	src.w = width - xp;
	src.h = height - yp;

	dsc.flags  = (DFBSurfaceDescriptionFlags)(DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PREALLOCATED);
	dsc.caps   = DSCAPS_NONE;
	dsc.width  = width;
	dsc.height = height;
	dsc.preallocated[0].data  = fbbuff;
	dsc.preallocated[0].pitch = width * sizeof(fb_pixel_t);
	err = dfb->CreateSurface(dfb, &dsc, &surf);
	/* TODO: maybe we should not die if this fails? */
	if (err != DFB_OK) {
		fprintf(stderr, "CFbAccel::blit2FB: ");
		DirectFBErrorFatal("dfb->CreateSurface(dfb, &dsc, &surf)", err);
	}

	if (transp)
	{
		surf->SetSrcColorKey(surf, 0, 0, 0);
		dfbdest->SetBlittingFlags(dfbdest, DSBLIT_SRC_COLORKEY);
	}
	else
		dfbdest->SetBlittingFlags(dfbdest, DSBLIT_BLEND_ALPHACHANNEL);

	dfbdest->Blit(dfbdest, surf, &src, xoff, yoff);
	surf->Release(surf);
	return;
}
Beispiel #9
0
int main (int argc, char **argv)
{
    DFBResult dfberr;

    if( (dfberr = DirectFBInit( &argc, &argv )) != DFB_OK )
    { DirectFBErrorFatal("DirectFBInit( &argc, &argv )", dfberr); }

    IDirectFB * main_interface = NULL;
    IDirectFB * main_interface_2 = NULL;                                  
    /* 1) */

    if( (dfberr = DirectFBCreate( &main_interface )) != DFB_OK )
    { DirectFBErrorFatal( "DirectFBCreate( &main_interface )", dfberr); }
#if 0
        /* 2) */
    if( (dfberr = DirectFBCreate( &main_interface )) != DFB_OK )          
    { DirectFBErrorFatal( "DirectFBCreate( &main_interface )", dfberr); }
#endif

/*if( (dfberr 
= main_dfb_interface->SetVideoMode( main_interface, 100, 100, 0 )) != 
DFB_OK ) { fprintf(stderr, "File: %s, Line: %d:\n", __FILE__, __LINE__); 
DirectFBErrorFatal( "SetVideoMode( main_interface, 100, 100, 100 )", 
dfberr); }*/
            
    if( (dfberr = DirectFBCreate( &main_interface_2 )) != DFB_OK )
    { DirectFBErrorFatal( "DirectFBCreate( &main_interface_2 )", dfberr); }

if (main_interface == main_interface_2)
{
printf("Returns same\n");
printf("Returns same\n");
printf("Returns same\n");
sleep(10);
}

    if( (dfberr = main_interface->SetCooperativeLevel( main_interface, DFSCL_FULLSCREEN )) != DFB_OK )
    { DirectFBErrorFatal( "SetCooperativeLevel( main_interface, DFSCL_FULLSCREEN )", dfberr); }
        if( (dfberr = main_interface_2->SetCooperativeLevel( main_interface_2, DFSCL_FULLSCREEN )) != DFB_OK )         /* 3) */
        { DirectFBErrorFatal( "SetCooperativeLevel( main_interface_2, DFSCL_FULLSCREEN )", dfberr); }
}
Beispiel #10
0
void QDirectFBWindowSurface::setGeometry(const QRect &rect)
{
    const QRect oldRect = geometry();
    if (oldRect == rect)
        return;

    IDirectFBSurface *oldSurface = dfbSurface;
    const bool sizeChanged = oldRect.size() != rect.size();
    if (sizeChanged) {
        delete engine;
        engine = 0;
        releaseSurface();
        Q_ASSERT(!dfbSurface);
    }

    if (rect.isNull()) {
#ifndef QT_NO_DIRECTFB_WM
        if (dfbWindow) {
            if (window())
                window()->setProperty("_q_DirectFBWindowID", QVariant());

            dfbWindow->Release(dfbWindow);
            dfbWindow = 0;
        }
#endif
        Q_ASSERT(!dfbSurface);
#ifdef QT_DIRECTFB_SUBSURFACE
        Q_ASSERT(!subSurface);
#endif
    } else {
#ifdef QT_DIRECTFB_WM
        if (!dfbWindow) {
            createWindow(rect);
        } else {
            setWindowGeometry(dfbWindow, oldRect, rect);
            Q_ASSERT(!sizeChanged || !dfbSurface);
            if (sizeChanged)
                dfbWindow->GetSurface(dfbWindow, &dfbSurface);
        }
#else
        IDirectFBSurface *primarySurface = screen->primarySurface();
        DFBResult result = DFB_OK;
        if (mode == Primary) {
            Q_ASSERT(primarySurface);
            if (rect == screen->region().boundingRect()) {
                dfbSurface = primarySurface;
            } else {
                const DFBRectangle r = { rect.x(), rect.y(),
                                         rect.width(), rect.height() };
                result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface);
            }
        } else { // mode == Offscreen
            if (!dfbSurface) {
                dfbSurface = screen->createDFBSurface(rect.size(), surfaceFlags() & Opaque ? screen->pixelFormat() : screen->alphaPixmapFormat(),
                                                      QDirectFBScreen::DontTrackSurface);
            }
        }
        if (result != DFB_OK)
            DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result);
#endif
    }
    if (oldSurface != dfbSurface) {
        imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid;
    }

    if (oldRect.size() != rect.size()) {
        QWSWindowSurface::setGeometry(rect);
    } else {
        QWindowSurface::setGeometry(rect);
    }
}