static IDirectFBSurface * _dfb_surface_from_data(IDirectFB *dfb, int w, int h, void *data) { IDirectFBSurface *s; DFBSurfaceDescription desc; DFBResult r; desc.flags = (DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_PREALLOCATED); desc.caps = DSCAPS_PREMULTIPLIED; desc.width = w; desc.height = h; desc.preallocated[0].data = data; desc.preallocated[0].pitch = w * 4; desc.preallocated[1].data = NULL; desc.preallocated[1].pitch = 0; desc.pixelformat = DSPF_ARGB; r = dfb->CreateSurface(dfb, &desc, &s); if (r != DFB_OK) { ERR("Cannot create DirectFB surface: %s", DirectFBErrorString(r)); return NULL; } s->SetPorterDuff(s, DSPD_SRC_OVER); return s; }
static mrb_value surface_set_porter_duff(mrb_state *mrb, mrb_value self) { IDirectFBSurface* surface = mrb_directfb_surface(mrb, self); DFBResult ret = -1; if (surface != NULL) { mrb_int rule; mrb_get_args(mrb, "i", &rule); ret = surface->SetPorterDuff(surface, rule); } return mrb_fixnum_value(ret); }