DFBResult dfb_state_set_index_translation( CardState *state, const int *indices, int num_indices ) { D_MAGIC_ASSERT( state, CardState ); D_ASSERT( indices != NULL || num_indices == 0 ); dfb_state_lock( state ); if (state->num_translation != num_indices) { int *new_trans = D_REALLOC( state->index_translation, num_indices * sizeof(int) ); D_ASSERT( num_indices || new_trans == NULL ); if (num_indices && !new_trans) { dfb_state_unlock( state ); return D_OOM(); } state->index_translation = new_trans; state->num_translation = num_indices; } if (num_indices) direct_memcpy( state->index_translation, indices, num_indices * sizeof(int) ); state->modified |= SMF_INDEX_TRANSLATION; dfb_state_unlock( state ); return DFB_OK; }
DFBResult dfb_state_set_source2( CardState *state, CoreSurface *source2 ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); if (state->source2 != source2) { if (source2 && dfb_surface_ref( source2 )) { D_WARN( "could not ref() source2" ); dfb_state_unlock( state ); return DFB_DEAD; } if (state->source2) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_SOURCE2 ) ); dfb_surface_unref( state->source2 ); } state->source2 = source2; state->modified |= SMF_SOURCE2; if (source2) { direct_serial_copy( &state->src2_serial, &source2->serial ); D_FLAGS_SET( state->flags, CSF_SOURCE2 ); } else D_FLAGS_CLEAR( state->flags, CSF_SOURCE2 ); } dfb_state_unlock( state ); return DFB_OK; }
DFBResult dfb_state_set_source_mask( CardState *state, CoreSurface *source_mask ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); if (state->source_mask != source_mask) { if (source_mask && dfb_surface_ref( source_mask )) { D_WARN( "could not ref() source mask" ); dfb_state_unlock( state ); return DFB_DEAD; } if (state->source_mask) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_SOURCE_MASK ) ); dfb_surface_unref( state->source_mask ); } state->source_mask = source_mask; state->modified |= SMF_SOURCE_MASK; if (source_mask) { direct_serial_copy( &state->src_mask_serial, &source_mask->serial ); D_FLAGS_SET( state->flags, CSF_SOURCE_MASK ); } else D_FLAGS_CLEAR( state->flags, CSF_SOURCE_MASK ); } dfb_state_unlock( state ); return DFB_OK; }
static DFBResult IDirectFBSurface_Layer_Flip( IDirectFBSurface *thiz, const DFBRegion *region, DFBSurfaceFlipFlags flags ) { DFBRegion reg; DIRECT_INTERFACE_GET_DATA(IDirectFBSurface_Layer) D_DEBUG_AT( Surface, "%s( %p, %p, 0x%08x )\n", __FUNCTION__, thiz, region, flags ); if (!data->base.surface) return DFB_DESTROYED; if (data->base.locked) return DFB_LOCKED; if (!data->base.area.current.w || !data->base.area.current.h || (region && (region->x1 > region->x2 || region->y1 > region->y2))) return DFB_INVAREA; IDirectFBSurface_StopAll( &data->base ); if (data->base.parent) { IDirectFBSurface_data *parent_data; DIRECT_INTERFACE_GET_DATA_FROM( data->base.parent, parent_data, IDirectFBSurface ); if (parent_data) { /* Signal end of sequence of operations. */ dfb_state_lock( &parent_data->state ); dfb_state_stop_drawing( &parent_data->state ); dfb_state_unlock( &parent_data->state ); } } dfb_region_from_rectangle( ®, &data->base.area.current ); if (region) { DFBRegion clip = DFB_REGION_INIT_TRANSLATED( region, data->base.area.wanted.x, data->base.area.wanted.y ); if (!dfb_region_region_intersect( ®, &clip )) return DFB_INVAREA; } D_DEBUG_AT( Surface, " -> FLIP %4d,%4d-%4dx%4d\n", DFB_RECTANGLE_VALS_FROM_REGION( ® ) ); return CoreLayerRegion_FlipUpdate( data->region, ®, flags ); }
DFBResult dfb_state_get_acceleration_mask( CardState *state, DFBAccelerationMask *ret_accel ) { DFBAccelerationMask mask = DFXL_NONE; D_MAGIC_ASSERT( state, CardState ); D_ASSERT( ret_accel != NULL ); dfb_state_lock( state ); /* Check drawing functions */ if (dfb_gfxcard_state_check( state, DFXL_FILLRECTANGLE )) D_FLAGS_SET( mask, DFXL_FILLRECTANGLE ); if (dfb_gfxcard_state_check( state, DFXL_DRAWRECTANGLE )) D_FLAGS_SET( mask, DFXL_DRAWRECTANGLE ); if (dfb_gfxcard_state_check( state, DFXL_DRAWLINE )) D_FLAGS_SET( mask, DFXL_DRAWLINE ); if (dfb_gfxcard_state_check( state, DFXL_FILLTRIANGLE )) D_FLAGS_SET( mask, DFXL_FILLTRIANGLE ); if (dfb_gfxcard_state_check( state, DFXL_FILLTRAPEZOID )) D_FLAGS_SET( mask, DFXL_FILLTRAPEZOID ); /* Check blitting functions */ if (state->source) { if (dfb_gfxcard_state_check( state, DFXL_BLIT )) D_FLAGS_SET( mask, DFXL_BLIT ); if (dfb_gfxcard_state_check( state, DFXL_STRETCHBLIT )) D_FLAGS_SET( mask, DFXL_STRETCHBLIT ); if (dfb_gfxcard_state_check( state, DFXL_TEXTRIANGLES )) D_FLAGS_SET( mask, DFXL_TEXTRIANGLES ); } /* Check blitting functions */ if (state->source2) { if (dfb_gfxcard_state_check( state, DFXL_BLIT2 )) D_FLAGS_SET( mask, DFXL_BLIT2 ); } dfb_state_unlock( state ); *ret_accel = mask; return DFB_OK; }
DFBResult dfb_state_set_source_2( CardState *state, CoreSurface *source, u32 flip_count ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); if (state->source != source || state->source_flip_count != flip_count || !state->source_flip_count_used) { bool ref = true;//!fusion_config->secure_fusion || dfb_core_is_master( core_dfb ); if (source && ref && dfb_surface_ref( source )) { D_WARN( "could not ref() source" ); dfb_state_unlock( state ); return DFB_DEAD; } if (state->source) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_SOURCE ) ); if (ref) dfb_surface_unref( state->source ); } state->source = source; state->modified |= SMF_SOURCE; state->source_flip_count = flip_count; state->source_flip_count_used = true; if (source) { direct_serial_copy( &state->src_serial, &source->serial ); D_FLAGS_SET( state->flags, CSF_SOURCE ); } else D_FLAGS_CLEAR( state->flags, CSF_SOURCE ); } dfb_state_unlock( state ); return DFB_OK; }
DFBResult dfb_state_set_destination( CardState *state, CoreSurface *destination ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); D_ASSUME( !(state->flags & CSF_DRAWING) ); if (state->destination != destination) { if (destination) { if (dfb_surface_ref( destination )) { D_WARN( "could not ref() destination" ); dfb_state_unlock( state ); return DFB_DEAD; } validate_clip( state, destination->config.size.w - 1, destination->config.size.h - 1, false ); } if (state->destination) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_DESTINATION ) ); dfb_surface_unref( state->destination ); } state->destination = destination; state->modified |= SMF_DESTINATION; if (destination) { direct_serial_copy( &state->dst_serial, &destination->serial ); D_FLAGS_SET( state->flags, CSF_DESTINATION ); } else D_FLAGS_CLEAR( state->flags, CSF_DESTINATION ); } dfb_state_unlock( state ); return DFB_OK; }
DFBResult dfb_state_set_source2( CardState *state, CoreSurface *source2 ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); if (state->source2 != source2) { bool ref = true;//!fusion_config->secure_fusion || dfb_core_is_master( core_dfb ); if (source2 && ref && dfb_surface_ref( source2 )) { D_WARN( "could not ref() source2" ); dfb_state_unlock( state ); return DFB_DEAD; } if (state->source2) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_SOURCE2 ) ); if (ref) dfb_surface_unref( state->source2 ); } state->source2 = source2; state->modified |= SMF_SOURCE2; if (source2) { direct_serial_copy( &state->src2_serial, &source2->serial ); D_FLAGS_SET( state->flags, CSF_SOURCE2 ); } else D_FLAGS_CLEAR( state->flags, CSF_SOURCE2 ); } dfb_state_unlock( state ); return DFB_OK; }