void TtFontAsset::RenderText( SurfacePtr dest, int& x, int& y, const char* text, const pei::Color& color /*= pei::XColor(255,255,255)*/ ) { // assert ( pFont ); if (!m_TtFont || dest.get() == NULL ) { return; } #ifdef _HAS_SDL_TTF_ SDL_Surface *text_surface = NULL; // this is a hack! We swap r & g and correct the color format manually // SDL_ttf renders ARGB, but we need ABGR (or LE RGBA) to match RGBA texture format - performace reasons! SDL_Color c = { color.b, color.g, color.r, color.a }; if ( (text_surface = TTF_RenderText_Blended( (TTF_Font*)m_TtFont->GetFontHandle(), text, c )) != NULL ) { // swap r&g in the format description text_surface->format->Rmask = 0x000000ff; text_surface->format->Rshift = 0; text_surface->format->Bmask = 0x00ff0000; text_surface->format->Bshift = 16; pei::SurfacePtr txt( new pei::SDL::SurfaceWrapper(text_surface)); pei::Blitter blitter(pei::PixOpPtr(new PixOpAlphaBlitSrcAlpha(txt->GetFormat(),dest->GetFormat()) ) ); blitter.Blit( txt, dest, x, y, txt->GetWidth(), txt->GetHeight(), 0, 0 ); int tw, th; TTF_SizeText( (TTF_Font*)m_TtFont->GetFontHandle(), text, &tw, &th); Uint32 font_height = TTF_FontHeight((TTF_Font*)m_TtFont->GetFontHandle()); // - a - 2*d; y += font_height; x += tw; } #endif }
void VDPixmapBlt_UberblitAdapter(const VDPixmap& dst, const VDPixmap& src, vdpixsize w, vdpixsize h) { vdautoptr<IVDPixmapBlitter> blitter(VDPixmapCreateBlitter(dst, src)); if (w > src.w) w = src.w; if (w > dst.w) w = dst.w; if (h > src.h) h = src.h; if (h > dst.h) h = dst.h; vdrect32 r(0, 0, w, h); blitter->Blit(dst, &r, src); }
static void driver_update(void) { blitter(video, fb_dos.vesa_mode_info.BytesPerScanLine); }
/*! a generic 2D Blitter */ static s32 Blit(eBlitter operation, video::IImage * dest, const core::rect<s32> *destClipping, const core::position2d<s32> *destPos, video::IImage * const source, const core::rect<s32> *sourceClipping, u32 argb) { tExecuteBlit blitter = getBlitter( operation, dest, source ); if ( 0 == blitter ) { return 0; } // Clipping AbsRectangle sourceClip; AbsRectangle destClip; AbsRectangle v; SBlitJob job; if ( sourceClipping ) { sourceClip.x0 = sourceClipping->UpperLeftCorner.X; sourceClip.y0 = sourceClipping->UpperLeftCorner.Y; sourceClip.x1 = sourceClipping->LowerRightCorner.X; sourceClip.y1 = sourceClipping->LowerRightCorner.Y; } else { sourceClip.x0 = 0; sourceClip.y0 = 0; sourceClip.x1 = source ? source->getDimension().Width : 0; sourceClip.y1 = source ? source->getDimension().Height : 0; } if ( destClipping ) { destClip.x0 = destClipping->UpperLeftCorner.X; destClip.y0 = destClipping->UpperLeftCorner.Y; destClip.x1 = destClipping->LowerRightCorner.X; destClip.y1 = destClipping->LowerRightCorner.Y; } else { destClip.x0 = 0; destClip.y0 = 0; destClip.x1 = dest ? dest->getDimension().Width : 0; destClip.y1 = dest ? dest->getDimension().Height : 0; } v.x0 = destPos ? destPos->X : 0; v.y0 = destPos ? destPos->Y : 0; v.x1 = v.x0 + ( sourceClip.x1 - sourceClip.x0 ); v.y1 = v.y0 + ( sourceClip.y1 - sourceClip.y0 ); intersect( job.Dest, destClip, v ); if ( !isValid( job.Dest ) ) return 0; job.width = job.Dest.x1 - job.Dest.x0; job.height = job.Dest.y1 - job.Dest.y0; job.Source.x0 = sourceClip.x0 + ( job.Dest.x0 - v.x0 ); job.Source.x1 = job.Source.x0 + job.width; job.Source.y0 = sourceClip.y0 + ( job.Dest.y0 - v.y0 ); job.Source.y1 = job.Source.y0 + job.height; job.argb = argb; if ( source ) { job.srcPitch = source->getPitch(); job.srcPixelMul = source->getBytesPerPixel(); job.src = (void*) ( (u8*) source->lock() + ( job.Source.y0 * job.srcPitch ) + ( job.Source.x0 * job.srcPixelMul ) ); } else { // use srcPitch for color operation on dest job.srcPitch = job.width * dest->getBytesPerPixel(); } job.dstPitch = dest->getPitch(); job.dstPixelMul = dest->getBytesPerPixel(); job.dst = (void*) ( (u8*) dest->lock() + ( job.Dest.y0 * job.dstPitch ) + ( job.Dest.x0 * job.dstPixelMul ) ); blitter( &job ); if ( source ) source->unlock(); if ( dest ) dest->unlock(); return 1; }
//----------------------------------------------------------------------------// void Direct3D9Texture::blitToMemory(void* targetData) { D3DSurfaceBlitter blitter(d_owner.getDevice(), d_texture); blitter.blitToMemory(static_cast<uint32*>(targetData)); }
//----------------------------------------------------------------------------// void Direct3D9Texture::blitFromMemory(const void* sourceData, const Rectf& area) { D3DSurfaceBlitter blitter(d_owner.getDevice(), d_texture); blitter.blitFromMemory(static_cast<const uint32*>(sourceData), area); }