static inline void ep9x_set_color( EP9XDriverData *ep9xdrv, EP9XDeviceData *ep9xdev, CardState *state ) { CoreSurfaceBuffer *buffer = state->dst.buffer; if (ep9xdev->smf_color) return; switch (buffer->format) { case DSPF_RGB16: ep9xdev->fill_color = PIXEL_RGB16( state->color.r, state->color.g, state->color.b ); break; case DSPF_RGB24: case DSPF_RGB32: ep9xdev->fill_color = PIXEL_RGB32( state->color.r, state->color.g, state->color.b ); break; default: D_ERROR( "unexpected pixelformat!" ); } ep9xdev->smf_color = 1; }
/* * Called by vmwareSetState() to ensure that the color register is properly set * for execution of rendering functions. */ static inline void vmware_validate_COLOR( VMWareDeviceData *vdev, CardState *state ) { switch (vdev->dst_format) { case DSPF_ARGB: vdev->color_pixel = PIXEL_ARGB( state->color.a, state->color.r, state->color.g, state->color.b ); break; case DSPF_RGB32: vdev->color_pixel = PIXEL_RGB32( state->color.r, state->color.g, state->color.b ); break; case DSPF_RGB16: vdev->color_pixel = PIXEL_RGB16( state->color.r, state->color.g, state->color.b ); break; default: D_BUG( "unexpected format %s", dfb_pixelformat_name(vdev->dst_format) ); } /* Set the flag. */ VMWARE_VALIDATE( COLOR ); }
static inline void i810_set_color(I810DriverData *i810drv, I810DeviceData *i810dev, CardState *state) { if (i810dev->i_color) return; switch (state->destination->config.format) { case DSPF_LUT8: i810dev->color_value = state->color_index; break; case DSPF_ARGB1555: i810dev->color_value = PIXEL_ARGB1555(state->color.a, state->color.r, state->color.g, state->color.b); break; case DSPF_RGB16: i810dev->color_value = PIXEL_RGB16(state->color.r, state->color.g, state->color.b); break; case DSPF_RGB24: i810dev->color_value = PIXEL_RGB32(state->color.r, state->color.g, state->color.b); break; default: D_BUG("unexpected pixelformat~"); } i810dev->i_color = 1; }
static inline void savage4_validate_color( Savage4DeviceData *sdev, CardState *state ) { if (sdev->v_color) return; switch (state->destination->config.format) { case DSPF_A8: sdev->Fill_Color = state->color.a; break; case DSPF_ARGB1555: sdev->Fill_Color = PIXEL_ARGB1555(state->color.a, state->color.r, state->color.g, state->color.b); break; case DSPF_RGB16: sdev->Fill_Color = PIXEL_RGB16(state->color.r, state->color.g, state->color.b); break; case DSPF_RGB32: sdev->Fill_Color = PIXEL_RGB32(state->color.r, state->color.g, state->color.b); break; case DSPF_ARGB: sdev->Fill_Color = PIXEL_ARGB(state->color.a, state->color.r, state->color.g, state->color.b); break; case DSPF_RGB332: sdev->Fill_Color = PIXEL_RGB332(state->color.r, state->color.g, state->color.b); break; default: D_BUG( "unexpected destination format" ); break; } sdev->v_color = 1; }
static inline void savage3D_validate_color( Savage3DDriverData *sdrv, Savage3DDeviceData *sdev, CardState *state ) { if (sdev->v_color) return; savage3D_waitfifo( sdrv, sdev, 2 ); BCI_SEND( BCI_CMD_NOP | BCI_CMD_SEND_COLOR ); switch (state->destination->config.format) { case DSPF_A8: BCI_SEND( state->color.a ); break; case DSPF_ARGB1555: BCI_SEND( PIXEL_ARGB1555(state->color.a, state->color.r, state->color.g, state->color.b) ); break; case DSPF_RGB16: BCI_SEND( PIXEL_RGB16(state->color.r, state->color.g, state->color.b) ); break; case DSPF_RGB32: BCI_SEND( PIXEL_RGB32(state->color.r, state->color.g, state->color.b) ); break; case DSPF_ARGB: BCI_SEND( PIXEL_ARGB(state->color.a, state->color.r, state->color.g, state->color.b) ); break; default: D_ONCE( "unsupported destination format" ); break; } sdev->v_color = 1; }
static inline void tdfx_validate_colorFore( TDFXDriverData *tdrv, TDFXDeviceData *tdev, CardState *state ) { if (tdev->v_colorFore) return; tdfx_waitfifo( tdrv, tdev, 1 ); switch (state->destination->config.format) { case DSPF_A8: tdrv->voodoo2D->colorFore = state->color.a; break; case DSPF_ARGB1555: tdrv->voodoo2D->colorFore = PIXEL_ARGB1555( state->color.a, state->color.r, state->color.g, state->color.b ); break; case DSPF_RGB16: tdrv->voodoo2D->colorFore = PIXEL_RGB16( state->color.r, state->color.g, state->color.b ); break; case DSPF_RGB24: case DSPF_RGB32: tdrv->voodoo2D->colorFore = PIXEL_RGB32( state->color.r, state->color.g, state->color.b ); break; case DSPF_ARGB: tdrv->voodoo2D->colorFore = PIXEL_ARGB( state->color.a, state->color.r, state->color.g, state->color.b ); break; default: D_BUG( "unexpected pixelformat!" ); break; } tdev->v_colorFore = 1; }
void sis_validate_color(SiSDriverData *drv, SiSDeviceData *dev, CardState *state) { u32 color; if (dev->v_color) return; switch (state->destination->config.format) { case DSPF_LUT8: color = state->color_index; break; case DSPF_ARGB1555: color = PIXEL_ARGB1555(state->color.a, state->color.r, state->color.g, state->color.b); break; case DSPF_RGB16: color = PIXEL_RGB16(state->color.r, state->color.g, state->color.b); break; case DSPF_RGB32: color = PIXEL_RGB32(state->color.r, state->color.g, state->color.b); break; case DSPF_ARGB: color = PIXEL_ARGB(state->color.a, state->color.r, state->color.g, state->color.b); break; default: D_BUG("unexpected pixelformat"); return; } sis_wl(drv->mmio_base, SIS315_2D_PAT_FG_COLOR, color); dev->v_color = 1; }
int refresh_display(__u8* p, size_t length) { DFBResult ret; DFBSurfacePixelFormat format; size_t i,j; int w,h; int pitch; /* Retrieve the width and height. */ surface->GetSize( surface, &w, &h); surface->GetPixelFormat( surface, &format ); if (format != DSPF_RGB32) { printf("invalid dfb pixel format!\n"); return 1; } /* Lock the surface's data for direct write access. */ ret = surface->Lock( surface, DSLF_WRITE, &data, &pitch ); if (ret) { DirectFBError( "IDirectFBSurface::Lock() failed", ret ); return 1; } for (j=0; j<h; j++) { __u32 *dst = (__u32*)((__u8*)data + j * pitch); for (i=0; i<w; i++) { // Set pixel with no alpha (a=255) dst[i] = PIXEL_RGB32(0xff, p[0], p[1], p[2]); p+=3; } } /* Unlock the surface's data. */ surface->Unlock( surface ); /* Flip the surface to display the new frame. */ surface->Flip( surface, NULL, 0 ); }
static bool stretch_hvx( CardState *state, DFBRectangle *srect, DFBRectangle *drect ) { GenefxState *gfxs; const StretchFunctionTable *table; StretchHVx stretch; bool down = false; void *dst; void *src; StretchCtx ctx; int idx = STRETCH_NONE; u32 colors[256]; D_ASSERT( state != NULL ); DFB_RECTANGLE_ASSERT( srect ); DFB_RECTANGLE_ASSERT( drect ); gfxs = state->gfxs; if (srect->w > drect->w && srect->h > drect->h) down = true; if (down) { if (!(state->render_options & DSRO_SMOOTH_DOWNSCALE)) return false; } else { if (!(state->render_options & DSRO_SMOOTH_UPSCALE)) return false; } switch (gfxs->dst_format) { case DSPF_NV12: case DSPF_NV21: return stretch_hvx_planar( state, srect, drect, down ); default: break; } if (state->blittingflags & ~(DSBLIT_COLORKEY_PROTECT | DSBLIT_SRC_COLORKEY | DSBLIT_SRC_PREMULTIPLY)) return false; if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY && !DFB_PIXELFORMAT_IS_INDEXED( gfxs->src_format )) return false; if (DFB_PIXELFORMAT_INDEX(gfxs->dst_format) >= D_ARRAY_SIZE(stretch_tables)) return false; if (DFB_PIXELFORMAT_INDEX(gfxs->src_format) >= D_ARRAY_SIZE((stretch_tables[0])->f)) return false; table = stretch_tables[DFB_PIXELFORMAT_INDEX(gfxs->dst_format)]; if (!table) return false; if (state->blittingflags & DSBLIT_SRC_COLORKEY) idx |= STRETCH_SRCKEY; if (state->blittingflags & DSBLIT_COLORKEY_PROTECT) idx |= STRETCH_PROTECT; if (down) stretch = table->f[DFB_PIXELFORMAT_INDEX(gfxs->src_format)].down[idx]; else stretch = table->f[DFB_PIXELFORMAT_INDEX(gfxs->src_format)].up[idx]; if (!stretch) return false; ctx.clip = state->clip; if (!dfb_region_rectangle_intersect( &ctx.clip, drect )) return false; dfb_region_translate( &ctx.clip, - drect->x, - drect->y ); if (DFB_PIXELFORMAT_IS_INDEXED( gfxs->src_format )) { int i; const DFBColor *entries; u16 *colors16 = (void*) colors; D_ASSERT( gfxs->Blut != NULL ); entries = gfxs->Blut->entries; switch (gfxs->dst_format) { case DSPF_ARGB: if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY) { for (i=0; i<gfxs->Blut->num_entries; i++) { int alpha = entries[i].a + 1; switch (alpha) { case 0: colors[i] = 0; break; case 255: colors[i] = PIXEL_ARGB( entries[i].a, entries[i].r, entries[i].g, entries[i].b ); break; default: colors[i] = PIXEL_ARGB( entries[i].a, (alpha * entries[i].r) >> 8, (alpha * entries[i].g) >> 8, (alpha * entries[i].b) >> 8 ); } } } else { for (i=0; i<gfxs->Blut->num_entries; i++) colors[i] = PIXEL_ARGB( entries[i].a, entries[i].r, entries[i].g, entries[i].b ); } break; case DSPF_RGB32: for (i=0; i<gfxs->Blut->num_entries; i++) colors[i] = PIXEL_RGB32( entries[i].r, entries[i].g, entries[i].b ); break; case DSPF_RGB16: for (i=0; i<gfxs->Blut->num_entries; i++) colors16[i] = PIXEL_RGB16( entries[i].r, entries[i].g, entries[i].b ); break; case DSPF_ARGB4444: if (state->blittingflags & DSBLIT_SRC_PREMULTIPLY) { for (i=0; i<gfxs->Blut->num_entries; i++) { int alpha = entries[i].a + 1; switch (alpha) { case 0: colors16[i] = 0; break; case 255: colors16[i] = PIXEL_ARGB4444( entries[i].a, entries[i].r, entries[i].g, entries[i].b ); break; default: colors16[i] = PIXEL_ARGB4444( entries[i].a, (alpha * entries[i].r) >> 8, (alpha * entries[i].g) >> 8, (alpha * entries[i].b) >> 8 ); } } } else { for (i=0; i<gfxs->Blut->num_entries; i++)