static int DirectFB_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, 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++) { SDL_Rect dst = {rects[i]->x, rects[i]->y, rects[i]->w, rects[i]->h}; dst.x += clip_region.x1; dst.y += clip_region.y1; SDL_DFB_CHECKERR(destsurf->DrawRectangle(destsurf, dst.x, dst.y, dst.w, dst.h)); } return 0; error: return -1; }
static int DirectFB_RenderDrawLines(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); /* Use antialiasing when available */ #if (DFB_VERSION_ATLEAST(1,2,0)) SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, DSRO_ANTIALIAS)); #endif destsurf->GetClip(destsurf, &clip_region); for (i=0; i < count - 1; i++) { int x1 = points[i].x + clip_region.x1; int y1 = points[i].y + clip_region.y1; int x2 = points[i + 1].x + clip_region.x1; int y2 = points[i + 1].y + clip_region.y1; SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, x1, y1, x2, y2)); } return 0; error: return -1; }
static mrb_value surface_get_clip(mrb_state *mrb, mrb_value self) { IDirectFBSurface* surface = mrb_directfb_surface(mrb, self); DFBResult ret = -1; if (surface != NULL) { DFBRegion clip; ret = surface->GetClip(surface, &clip); if (!ret) { return mrb_directfb_region_value(mrb, clip.x1, clip.y1, clip.x2, clip.y2); } } return mrb_fixnum_value(ret); }
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; }
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; }