static void region_destructor( FusionObject *object, bool zombie ) { CoreLayerRegion *region = (CoreLayerRegion*) object; CoreLayerContext *context = region->context; CoreLayer *layer = dfb_layer_at( context->layer_id ); CoreLayerShared *shared = layer->shared; (void) shared; D_DEBUG_AT( Core_Layers, "destroying region %p (%s, %dx%d, " "%s, %s, %s, %s%s)\n", region, shared->description.name, region->config.width, region->config.height, D_FLAGS_IS_SET( region->state, CLRSF_CONFIGURED ) ? "configured" : "unconfigured", D_FLAGS_IS_SET( region->state, CLRSF_ENABLED ) ? "enabled" : "disabled", D_FLAGS_IS_SET( region->state, CLRSF_ACTIVE ) ? "active" : "inactive", D_FLAGS_IS_SET( region->state, CLRSF_REALIZED ) ? "realized" : "not realized", zombie ? " - ZOMBIE" : "" ); /* Hide region etc. */ if (D_FLAGS_IS_SET( region->state, CLRSF_ENABLED )) dfb_layer_region_disable( region ); /* Remove the region from the context. */ dfb_layer_context_remove_region( region->context, region ); /* Throw away its surface. */ if (region->surface) { /* Detach the global listener. */ dfb_surface_detach_global( region->surface, ®ion->surface_reaction ); /* Unlink from structure. */ dfb_surface_unlink( ®ion->surface ); } /* Unlink the context from the structure. */ dfb_layer_context_unlink( ®ion->context ); /* Free driver's region data. */ if (region->region_data) SHFREE( region->region_data ); /* Deinitialize the lock. */ fusion_skirmish_destroy( ®ion->lock ); /* Destroy the object. */ fusion_object_destroy( object ); }
DFBResult dfb_layer_region_create( CoreLayerContext *context, CoreLayerRegion **ret_region ) { CoreLayer *layer; CoreLayerRegion *region; D_ASSERT( context != NULL ); D_ASSERT( ret_region != NULL ); layer = dfb_layer_at( context->layer_id ); /* Create the object. */ region = dfb_core_create_layer_region( layer->core ); if (!region) return DFB_FUSION; /* Link the context into the structure. */ if (dfb_layer_context_link( ®ion->context, context )) { fusion_object_destroy( ®ion->object ); return DFB_FUSION; } /* Initialize the lock. */ if (fusion_skirmish_init( ®ion->lock, "Layer Region", dfb_core_world(layer->core) )) { dfb_layer_context_unlink( ®ion->context ); fusion_object_destroy( ®ion->object ); return DFB_FUSION; } /* Change global reaction lock. */ fusion_object_set_lock( ®ion->object, ®ion->lock ); region->state = CLRSF_FROZEN; /* Activate the object. */ fusion_object_activate( ®ion->object ); /* Add the region to the context. */ dfb_layer_context_add_region( context, region ); /* Return the new region. */ *ret_region = region; return DFB_OK; }