本文整理汇总了C++中IDirectFBSurface类的典型用法代码示例。如果您正苦于以下问题:C++ IDirectFBSurface类的具体用法?C++ IDirectFBSurface怎么用?C++ IDirectFBSurface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IDirectFBSurface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
IDirectFB *dfb = NULL;
IDirectFBDisplayLayer *layer = NULL;
IDirectFBSurface *surface = NULL;
IDirectFBVideoProvider *vp = NULL;
CHECK(DirectFBInit (&argc, &argv));
if (argc != 2) {
return 1;
}
CHECK(DirectFBCreate(&dfb));
/* Signals */
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGUSR1, signal_handler);
signal(SIGUSR2, signal_handler);
CHECK(dfb->GetDisplayLayer(dfb, 0, &layer));
CHECK(dfb->CreateVideoProvider(dfb, argv[1], &vp));
CHECK(layer->GetSurface(layer, &surface));
CHECK(vp->PlayTo(vp, surface, NULL, flip, surface));
while(to_exit == 0) {
sleep(1);
}
CHECK(vp->Stop(vp));
CHECK(vp->Release(vp));
CHECK(surface->Release(surface));
CHECK(layer->Release(layer));
CHECK(dfb->Release(dfb));
return 0;
}
示例2: DirectFB_RenderDrawPoints
static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
const SDL_FPoint * points, int count)
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *destsurf = data->target;
DFBRegion clip_region;
int i;
DirectFB_ActivateRenderer(renderer);
PrepareDraw(renderer);
destsurf->GetClip(destsurf, &clip_region);
for (i=0; i < count; i++) {
int x = points[i].x + clip_region.x1;
int y = points[i].y + clip_region.y1;
SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, x, y, x, y));
}
return 0;
error:
return -1;
}
示例3: DirectFB_UpdateClipRect
static int
DirectFB_UpdateClipRect(SDL_Renderer * renderer)
{
const SDL_Rect *rect = &renderer->clip_rect;
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *destsurf = get_dfb_surface(data->window);
DFBRegion region;
if (!SDL_RectEmpty(rect)) {
region.x1 = rect->x;
region.x2 = rect->x + rect->w;
region.y1 = rect->y;
region.y2 = rect->y + rect->h;
SDL_DFB_CHECKERR(destsurf->SetClip(destsurf, ®ion));
} else {
SDL_DFB_CHECKERR(destsurf->SetClip(destsurf, NULL));
}
return 0;
error:
return -1;
}
示例4: directfb_get_empty_bitmap
static int
directfb_get_empty_bitmap (struct bitmap *bmp)
{
IDirectFBSurface *surface;
DFBSurfaceDescription desc;
bmp->data = bmp->flags = NULL;
desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;
desc.width = bmp->x;
desc.height = bmp->y;
if (dfb->CreateSurface (dfb, &desc, &surface) != DFB_OK)
return 0;
surface->Lock (surface, DSLF_READ | DSLF_WRITE, &bmp->data, &bmp->skip);
bmp->flags = surface;
return 0;
}
示例5: update
static void
update( Context *context )
{
unsigned long t;
IDirectFBSurface *surface = context->surface;
static __u8 r = 0, g = 0, b = 0;
context->gl->Lock( context->gl );
glClearColor( r++/255.0, g++/255.0, b++/255.0, 1.0 );
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
context->gl->Unlock( context->gl );
if (context->fps) {
char buf[16];
snprintf(buf, sizeof(buf), "%.1f FPS\n", context->fps);
surface->SetColor( surface, 0xff, 0x00, 0x00, 0xff );
surface->DrawString( surface, buf, -1,
context->width - 5, 5, DSTF_TOPRIGHT );
}
surface->Flip( surface, NULL, 0 );
context->frames++;
t = get_millis();
if (t - context->last_time >= 2000) {
float seconds = (t - context->last_time) / 1000.0f;
context->fps = context->frames / seconds;
context->last_time = t;
context->frames = 0;
}
}
示例6: DirectFB_RenderDrawLines
static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
const SDL_Point * points, int count)
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *destsurf = get_dfb_surface(data->window);
int i;
DirectFB_ActivateRenderer(renderer);
PrepareDraw(renderer);
/* Use antialiasing when available */
#if (DFB_VERSION_ATLEAST(1,2,0))
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, DSRO_ANTIALIAS));
#endif
for (i=0; i < count - 1; i++)
SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, points[i].x, points[i].y, points[i+1].x, points[i+1].y));
return 0;
error:
return -1;
}
示例7: QDirectFBPixmapData
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);
}
示例8: sizeof
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;
}
示例9: Render
/* render callback */
virtual void Render( IDirectFBSurface &surface ) {
surface.Clear( 0, 0, 255, 255 );
surface.SetFont( font );
surface.SetColor( 0, 0, 0, 255 );
surface.SetSrcBlendFunction( DSBF_INVSRCALPHA );
surface.SetDstBlendFunction( DSBF_INVSRCALPHA );
surface.DrawString( "Test Text", -1, 10, 10, (DFBSurfaceTextFlags)(DSTF_TOPLEFT | DSTF_BLEND_FUNCS) );
}
示例10: render_loop
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;
}
示例11: DirectFB_CreateRenderer
SDL_Renderer *
DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
{
IDirectFBSurface *winsurf = get_dfb_surface(window);
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_Renderer *renderer = NULL;
DirectFB_RenderData *data = NULL;
DFBSurfaceCapabilities scaps;
SDL_DFB_ALLOC_CLEAR(renderer, sizeof(*renderer));
SDL_DFB_ALLOC_CLEAR(data, sizeof(*data));
renderer->WindowEvent = DirectFB_WindowEvent;
renderer->CreateTexture = DirectFB_CreateTexture;
renderer->SetTextureAlphaMod = DirectFB_SetTextureAlphaMod;
renderer->SetTextureColorMod = DirectFB_SetTextureColorMod;
renderer->SetTextureBlendMode = DirectFB_SetTextureBlendMode;
renderer->UpdateTexture = DirectFB_UpdateTexture;
renderer->LockTexture = DirectFB_LockTexture;
renderer->RenderClear = DirectFB_RenderClear;
renderer->UnlockTexture = DirectFB_UnlockTexture;
renderer->RenderDrawPoints = DirectFB_RenderDrawPoints;
renderer->RenderDrawLines = DirectFB_RenderDrawLines;
/* SetDrawColor - no needed */
renderer->RenderFillRects = DirectFB_RenderFillRects;
renderer->RenderCopy = DirectFB_RenderCopy;
renderer->RenderPresent = DirectFB_RenderPresent;
/* FIXME: Yet to be tested */
renderer->RenderReadPixels = DirectFB_RenderReadPixels;
/* renderer->RenderWritePixels = DirectFB_RenderWritePixels; */
renderer->DestroyTexture = DirectFB_DestroyTexture;
renderer->DestroyRenderer = DirectFB_DestroyRenderer;
renderer->UpdateViewport = DirectFB_UpdateViewport;
renderer->UpdateClipRect = DirectFB_UpdateClipRect;
renderer->SetRenderTarget = DirectFB_SetRenderTarget;
#if 0
renderer->QueryTexturePixels = DirectFB_QueryTexturePixels;
renderer->SetTexturePalette = DirectFB_SetTexturePalette;
renderer->GetTexturePalette = DirectFB_GetTexturePalette;
renderer->SetTextureScaleMode = DirectFB_SetTextureScaleMode;
renderer->DirtyTexture = DirectFB_DirtyTexture;
renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode;
renderer->RenderDrawRects = DirectFB_RenderDrawRects;
#endif
renderer->info = DirectFB_RenderDriver.info;
renderer->window = window; /* SDL window */
renderer->driverdata = data;
renderer->info.flags =
SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
data->window = window;
data->target = winsurf;
data->flipflags = DSFLIP_PIPELINE | DSFLIP_BLIT;
if (flags & SDL_RENDERER_PRESENTVSYNC) {
data->flipflags |= DSFLIP_WAITFORSYNC | DSFLIP_ONSYNC;
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
} else
data->flipflags |= DSFLIP_ONSYNC;
SDL_DFB_CHECKERR(winsurf->GetCapabilities(winsurf, &scaps));
#if 0
if (scaps & DSCAPS_DOUBLE)
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
else if (scaps & DSCAPS_TRIPLE)
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
else
renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
#endif
DirectFB_SetSupportedPixelFormats(&renderer->info);
#if 0
/* Set up a palette watch on the display palette */
if (display-> palette) {
SDL_AddPaletteWatch(display->palette, DisplayPaletteChanged, data);
}
#endif
return renderer;
error:
SDL_DFB_FREE(renderer);
SDL_DFB_FREE(data);
return NULL;
}
示例12: DirectFB_WM_RedrawLayout
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;
}
示例13: main
int
main( int argc, char *argv[] )
{
DFBResult ret;
bool quit = false;
int i;
IDirectFB dfb;
IDirectFBDisplayLayer layer;
IDirectFBSurface surface;
DFBDisplayLayerConfig config;
DFBDimension sizes[2] = { {400, 400}, {600, 600} };
size_t num_sizes = D_ARRAY_SIZE(sizes);
DFBInputEvent evt;
IDirectFBEventBuffer keybuffer;
/* Initialize DirectFB. */
DirectFB::Init( &argc, &argv );
/* Create super interface. */
dfb = DirectFB::Create();
layer = dfb.GetDisplayLayer( DLID_PRIMARY );
/* Create an input buffer for key events */
keybuffer = dfb.CreateInputEventBuffer( DICAPS_KEYS, DFB_TRUE );
layer.SetCooperativeLevel( DLSCL_EXCLUSIVE );
layer.GetConfiguration( &config );
config.width = sizes[0].w;
config.height = sizes[0].h;
layer.SetConfiguration( config );
surface = layer.GetSurface();
while (true) {
surface.Clear( 0, 0, 0, 0xff );
surface.SetColor( 0x00, 0xff, 0x00, 0xff );
surface.DrawRectangle( 0, 0, config.width, config.height );
surface.Flip( NULL, DSFLIP_NONE );
keybuffer.WaitForEventWithTimeout( 3, 0 );
/* Process keybuffer */
while (keybuffer.GetEvent( DFB_EVENT(&evt) )) {
if (evt.type == DIET_KEYPRESS) {
switch (DFB_LOWER_CASE(evt.key_symbol)) {
case DIKS_ESCAPE:
case DIKS_SMALL_Q:
case DIKS_BACK:
case DIKS_STOP:
case DIKS_EXIT:
/* Quit main loop & test thread */
quit = 1;
break;
case DIKS_SPACE:
case DIKS_OK:
i++;
config.width = sizes[i % num_sizes].w;
config.height = sizes[i % num_sizes].h;
layer.SetConfiguration( config );
break;
default:
break;
}
}
}
}
return 0;
}
示例14: SetBlendMode
static void
SetBlendMode(DirectFB_RenderData * data, int blendMode,
DirectFB_TextureData * source)
{
IDirectFBSurface *destsurf = data->target;
/* FIXME: check for format change */
if (1 || data->lastBlendMode != blendMode) {
switch (blendMode) {
case SDL_BLENDMODE_NONE:
/**< No blending */
data->blitFlags = DSBLIT_NOFX;
data->drawFlags = DSDRAW_NOFX;
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO));
break;
#if 0
case SDL_BLENDMODE_MASK:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA));
break;
#endif
case SDL_BLENDMODE_BLEND:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA));
break;
case SDL_BLENDMODE_ADD:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
/* FIXME: SRCALPHA kills performance on radeon ...
* It will be cheaper to copy the surface to a temporary surface and premultiply
*/
if (source && TextureHasAlpha(source))
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA));
else
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ONE));
break;
case SDL_BLENDMODE_MOD:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ZERO));
SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_SRCCOLOR));
break;
}
data->lastBlendMode = blendMode;
}
}
示例15: main
int
main( int argc, char *argv[] )
{
DFBResult ret;
IDirectFB *dfb;
IDirectFBDisplayLayer *layer;
/* Initialize DirectFB. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
D_DERROR( ret, "DFBTest/Window_Surface: DirectFBInit() failed!\n" );
return ret;
}
/* Create super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
D_DERROR( ret, "DFBTest/Window_Surface: DirectFBCreate() failed!\n" );
return ret;
}
dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
while (true) {
DFBWindowDescription desc;
IDirectFBWindow *window;
IDirectFBSurface *surface;
desc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS;
desc.posx = 150;
desc.posy = 150;
desc.width = 300;
desc.height = 300;
desc.caps = DWCAPS_ALPHACHANNEL;
ret = layer->CreateWindow( layer, &desc, &window );
if (ret) {
D_DERROR( ret, "DFBTest/Window_Surface: CreateWindow() failed!\n" );
return ret;
}
window->GetSurface( window, &surface );
D_INFO( "Created window and surface, going to release window... (in 2 seconds)\n" );
usleep( 2000000 );
D_INFO("Releasing window...\n");
window->Release( window );
D_INFO("Window released, going to release surface... (in 2 seconds)\n");
usleep( 2000000 );
D_INFO("Releasing surface...\n");
surface->Release( surface );
D_INFO("Surface released, done.\n");
usleep( 5000000 );
}
/* Shutdown DirectFB. */
dfb->Release( dfb );
return ret;
}