示例#1
0
static mrb_value surface_get_capabilities(mrb_state *mrb, mrb_value self)
{
    IDirectFBSurface* surface = mrb_directfb_surface(mrb, self);
    if (surface != NULL) {
        DFBSurfaceCapabilities caps;
        DFBResult ret = surface->GetCapabilities(surface, &caps);
        if (!ret) {
            return mrb_fixnum_value(caps);
        }
    }
    return mrb_nil_value();
}
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;
}
示例#3
0
int testing_singlecore() {
    IDirectFB *dfb = NULL;
    IDirectFBSurface *surface = NULL;
    DFBSurfaceDescription dsc;
    DFBSurfaceCapabilities  caps;
    int width, height;
  	DFBSurfacePixelFormat p_format;
    int i;


    DFBCHECK(DirectFBInit(NULL, NULL));
    DFBCHECK(DirectFBCreate(&dfb));
    push_release(dfb, dfb->Release);

    DFBCHECK(dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
    dsc.flags = DSDESC_CAPS;
    dsc.caps  = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
    DFBCHECK (dfb->CreateSurface( dfb, &dsc, &surface ));
    push_release(surface, surface->Release);

    DFBCHECK(surface->GetCapabilities(surface, &caps));

    if (caps & DSCAPS_PRIMARY) {
        printf("Surface Primary\n");
    }
    if (caps & DSCAPS_SYSTEMONLY) {
        printf("Surface SystemOnly\n");
    }
    if (caps & DSCAPS_VIDEOONLY) {
        printf("Surface VideoOnly\n");
    }
    if (caps & DSCAPS_DOUBLE) {
        printf("Surface Double buffered\n");
    }
    if (caps & DSCAPS_SUBSURFACE) {
        printf("Surface is a sub surface\n");
    }
    if (caps & DSCAPS_INTERLACED) {
        printf("Surface is Interlaced\n");
    }
    if (caps & DSCAPS_SEPARATED) {
        printf("Surface is separated\n");
    }
    if (caps & DSCAPS_STATIC_ALLOC) {
        printf("Surface is static alloc\n");
    }
    if (caps & DSCAPS_TRIPLE) {
        printf("Surface is triple buffered\n");
    }
    if (caps & DSCAPS_PREMULTIPLIED) {
        printf("Surface stores premiltiplied alpha\n");
    }
    if (caps & DSCAPS_DEPTH) {
        printf("Surface has a depth buffer\n");
    }
    DFBCHECK(surface->GetSize(surface, &width, &height));
    printf("Surface size: %dx%d\n", width, height);


    DFBCHECK(surface->GetPixelFormat(surface, &p_format));
    for(i = 0; pformat_names[i].format; i++) {
        if (pformat_names[i].format == p_format) {
            printf("Surface pixelformat: %s\n", pformat_names[i].name);
        }
    }

    release_all();
    return 0;

}
示例#4
0
int get_display_layer_surface() {
    int i;
    IDirectFB *dfb = NULL;
    IDirectFBSurface *surface = NULL;
    DFBSurfaceCapabilities  caps;
    IDirectFBDisplayLayer   *layer   = NULL;
    int width, height;
  	DFBSurfacePixelFormat p_format;

    DFBCHECK(DirectFBInit(NULL, NULL));

    DFBCHECK(DirectFBCreate(&dfb));
    push_release(dfb, dfb->Release);

    DFBCHECK(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer));
    push_release(layer, layer->Release);

    DFBCHECK(layer->SetCooperativeLevel(layer, DLSCL_EXCLUSIVE));
    DFBCHECK(layer->GetSurface(layer, &surface));
    push_release(surface, surface->Release);

    DFBCHECK(surface->GetCapabilities(surface, &caps));

    if (caps & DSCAPS_PRIMARY) {
        printf("Surface Primary\n");
    }
    if (caps & DSCAPS_SYSTEMONLY) {
        printf("Surface SystemOnly\n");
    }
    if (caps & DSCAPS_VIDEOONLY) {
        printf("Surface VideoOnly\n");
    }
    if (caps & DSCAPS_DOUBLE) {
        printf("Surface Double buffered\n");
    }
    if (caps & DSCAPS_SUBSURFACE) {
        printf("Surface is a sub surface\n");
    }
    if (caps & DSCAPS_INTERLACED) {
        printf("Surface is Interlaced\n");
    }
    if (caps & DSCAPS_SEPARATED) {
        printf("Surface is separated\n");
    }
    if (caps & DSCAPS_STATIC_ALLOC) {
        printf("Surface is static alloc\n");
    }
    if (caps & DSCAPS_TRIPLE) {
        printf("Surface is triple buffered\n");
    }
    if (caps & DSCAPS_PREMULTIPLIED) {
        printf("Surface stores premiltiplied alpha\n");
    }
    if (caps & DSCAPS_DEPTH) {
        printf("Surface has a depth buffer\n");
    }
    DFBCHECK(surface->GetSize(surface, &width, &height));
    printf("Surface size: %dx%d\n", width, height);


    DFBCHECK(surface->GetPixelFormat(surface, &p_format));
    for(i = 0; pformat_names[i].format; i++) {
        if (pformat_names[i].format == p_format) {
            printf("Surface pixelformat: %s\n", pformat_names[i].name);
        }
    }

    release_all();
    return 0;


}