void dfb_gfx_clear( CoreSurface *surface, CoreSurfaceBufferRole role ) { DFBRectangle rect = { 0, 0, surface->config.size.w, surface->config.size.h }; StateClient *client = state_client_tls.Get(); D_FLAGS_SET( client->state.modified, SMF_CLIP | SMF_COLOR | SMF_DESTINATION | SMF_TO ); client->state.clip.x2 = surface->config.size.w - 1; client->state.clip.y2 = surface->config.size.h - 1; client->state.destination = surface; client->state.to = role; client->state.to_eye = DSSE_LEFT; client->state.color.a = 0; client->state.color.r = 0; client->state.color.g = 0; client->state.color.b = 0; client->state.color_index = 0; CoreGraphicsStateClient_FillRectangles( &client->client, &rect, 1 ); CoreGraphicsStateClient_Flush( &client->client, 0, CGSCFF_NONE ); /* Signal end of sequence. */ dfb_state_stop_drawing( &client->state ); client->state.destination = NULL; }
void dfb_gfx_copy_to( CoreSurface *source, CoreSurface *destination, const DFBRectangle *rect, int x, int y, bool from_back ) { DFBRectangle sourcerect = { 0, 0, source->config.size.w, source->config.size.h }; pthread_mutex_lock( ©_lock ); if (!copy_state_inited) { dfb_state_init( ©_state, NULL ); copy_state_inited = true; } copy_state.modified |= SMF_CLIP | SMF_SOURCE | SMF_DESTINATION; copy_state.clip.x2 = destination->config.size.w - 1; copy_state.clip.y2 = destination->config.size.h - 1; copy_state.source = source; copy_state.destination = destination; copy_state.from = from_back ? CSBR_BACK : CSBR_FRONT; copy_state.to = CSBR_BACK; if (rect) { if (dfb_rectangle_intersect( &sourcerect, rect )) dfb_gfxcard_blit( &sourcerect, x + sourcerect.x - rect->x, y + sourcerect.y - rect->y, ©_state ); } else dfb_gfxcard_blit( &sourcerect, x, y, ©_state ); /* Signal end of sequence. */ dfb_state_stop_drawing( ©_state ); pthread_mutex_unlock( ©_lock ); }
void dfb_gfx_copy_regions_stereo( CoreSurface *source, CoreSurfaceBufferRole from, DFBSurfaceStereoEye source_eye, CoreSurface *destination, CoreSurfaceBufferRole to, DFBSurfaceStereoEye destination_eye, const DFBRegion *regions, unsigned int num, int x, int y ) { unsigned int i, n = 0; DFBRectangle rect = { 0, 0, source->config.size.w, source->config.size.h }; DFBRectangle rects[num]; DFBPoint points[num]; D_ASSERT( !dfb_config->task_manager ); for (i=0; i<num; i++) { DFB_REGION_ASSERT( ®ions[i] ); rects[n] = DFB_RECTANGLE_INIT_FROM_REGION( ®ions[i] ); if (dfb_rectangle_intersect( &rects[n], &rect )) { points[n].x = x + rects[n].x - rect.x; points[n].y = y + rects[n].y - rect.y; n++; } } if (n > 0) { StateClient *client = state_client_tls.Get(); D_FLAGS_SET( client->state.modified, SMF_CLIP | SMF_SOURCE | SMF_DESTINATION | SMF_FROM | SMF_TO ); client->state.clip.x2 = destination->config.size.w - 1; client->state.clip.y2 = destination->config.size.h - 1; client->state.source = source; client->state.destination = destination; client->state.from = from; client->state.from_eye = source_eye; client->state.to = to; client->state.to_eye = destination_eye; CoreGraphicsStateClient_Blit( &client->client, rects, points, n ); CoreGraphicsStateClient_Flush( &client->client, 0, CGSCFF_NONE ); /* Signal end of sequence. */ dfb_state_stop_drawing( &client->state ); client->state.destination = NULL; client->state.source = NULL; } }
void dfb_gfx_copy_regions( CoreSurface *source, CoreSurfaceBufferRole from, CoreSurface *destination, CoreSurfaceBufferRole to, const DFBRegion *regions, unsigned int num, int x, int y ) { unsigned int i, n = 0; DFBRectangle rect = { 0, 0, source->config.size.w, source->config.size.h }; DFBRectangle rects[num]; DFBPoint points[num]; for (i=0; i<num; i++) { DFB_REGION_ASSERT( ®ions[i] ); rects[n] = DFB_RECTANGLE_INIT_FROM_REGION( ®ions[i] ); if (dfb_rectangle_intersect( &rects[n], &rect )) { points[n].x = x + rects[n].x - rect.x; points[n].y = y + rects[n].y - rect.y; n++; } } if (n > 0) { pthread_mutex_lock( ©_lock ); if (!copy_state_inited) { dfb_state_init( ©_state, NULL ); copy_state_inited = true; } copy_state.modified |= SMF_CLIP | SMF_SOURCE | SMF_DESTINATION; copy_state.clip.x2 = destination->config.size.w - 1; copy_state.clip.y2 = destination->config.size.h - 1; copy_state.source = source; copy_state.destination = destination; copy_state.from = from; copy_state.to = to; dfb_gfxcard_batchblit( rects, points, n, ©_state ); /* Signal end of sequence. */ dfb_state_stop_drawing( ©_state ); pthread_mutex_unlock( ©_lock ); } }
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 ); }
void dfb_gfx_copy_stereo( CoreSurface *source, DFBSurfaceStereoEye source_eye, CoreSurface *destination, DFBSurfaceStereoEye destination_eye, const DFBRectangle *rect, int x, int y, bool from_back ) { DFBRectangle sourcerect = { 0, 0, source->config.size.w, source->config.size.h }; StateClient *client = state_client_tls.Get(); D_FLAGS_SET( client->state.modified, SMF_CLIP | SMF_SOURCE | SMF_DESTINATION | SMF_FROM | SMF_TO ); client->state.clip.x2 = destination->config.size.w - 1; client->state.clip.y2 = destination->config.size.h - 1; client->state.source = source; client->state.destination = destination; client->state.from = from_back ? CSBR_BACK : CSBR_FRONT; client->state.from_eye = source_eye; client->state.to = CSBR_BACK; client->state.to_eye = destination_eye; if (rect) { if (dfb_rectangle_intersect( &sourcerect, rect )) { DFBPoint point = { x + sourcerect.x - rect->x, y + sourcerect.y - rect->y }; CoreGraphicsStateClient_Blit( &client->client, &sourcerect, &point, 1 ); } } else { DFBPoint point = { x, y }; CoreGraphicsStateClient_Blit( &client->client, &sourcerect, &point, 1 ); } CoreGraphicsStateClient_Flush( &client->client, 0, CGSCFF_NONE ); /* Signal end of sequence. */ dfb_state_stop_drawing( &client->state ); client->state.destination = NULL; client->state.source = NULL; }
void dfb_gfx_stretch_stereo( CoreSurface *source, DFBSurfaceStereoEye source_eye, CoreSurface *destination, DFBSurfaceStereoEye destination_eye, const DFBRectangle *srect, const DFBRectangle *drect, bool from_back ) { DFBRectangle sourcerect = { 0, 0, source->config.size.w, source->config.size.h }; DFBRectangle destrect = { 0, 0, destination->config.size.w, destination->config.size.h }; D_ASSERT( !dfb_config->task_manager ); if (srect) { if (!dfb_rectangle_intersect( &sourcerect, srect )) return; } if (drect) { if (!dfb_rectangle_intersect( &destrect, drect )) return; } StateClient *client = state_client_tls.Get(); D_FLAGS_SET( client->state.modified, SMF_CLIP | SMF_SOURCE | SMF_DESTINATION | SMF_FROM | SMF_TO ); client->state.clip.x2 = destination->config.size.w - 1; client->state.clip.y2 = destination->config.size.h - 1; client->state.source = source; client->state.destination = destination; client->state.from = from_back ? CSBR_BACK : CSBR_FRONT; client->state.from_eye = source_eye; client->state.to = CSBR_BACK; client->state.to_eye = destination_eye; CoreGraphicsStateClient_StretchBlit( &client->client, &sourcerect, &destrect, 1 ); CoreGraphicsStateClient_Flush( &client->client, 0, CGSCFF_NONE ); /* Signal end of sequence. */ dfb_state_stop_drawing( &client->state ); client->state.destination = NULL; client->state.source = NULL; }
void dfb_clear_depth( CoreSurface *surface, const DFBRegion *region ) { #if FIXME_SC_3 SurfaceBuffer *tmp; DFBRectangle rect = { 0, 0, surface->config.size.w - 1, surface->config.size.h - 1 }; if (region && !dfb_rectangle_intersect_by_region( &rect, region )) return; pthread_mutex_lock( &cd_lock ); if (!cd_state_inited) { dfb_state_init( &cd_state, NULL ); cd_state.color.r = 0xff; cd_state.color.g = 0xff; cd_state.color.b = 0xff; cd_state_inited = true; } cd_state.modified |= SMF_CLIP | SMF_DESTINATION; cd_state.clip.x2 = surface->config.size.w - 1; cd_state.clip.y2 = surface->config.size.h - 1; cd_state.destination = surface; dfb_surfacemanager_lock( surface->manager ); tmp = surface->back_buffer; surface->back_buffer = surface->depth_buffer; dfb_gfxcard_fillrectangles( &rect, 1, &cd_state ); surface->back_buffer = tmp; dfb_surfacemanager_unlock( surface->manager ); /* Signal end of sequence. */ dfb_state_stop_drawing( &cd_state ); pthread_mutex_unlock( &cd_lock ); #endif }
void dfb_gfx_stretch_to( CoreSurface *source, CoreSurface *destination, const DFBRectangle *srect, const DFBRectangle *drect, bool from_back ) { DFBRectangle sourcerect = { 0, 0, source->config.size.w, source->config.size.h }; DFBRectangle destrect = { 0, 0, destination->config.size.w, destination->config.size.h }; if (srect) { if (!dfb_rectangle_intersect( &sourcerect, srect )) return; } if (drect) { if (!dfb_rectangle_intersect( &destrect, drect )) return; } pthread_mutex_lock( ©_lock ); if (!copy_state_inited) { dfb_state_init( ©_state, NULL ); copy_state_inited = true; } copy_state.modified |= SMF_CLIP | SMF_SOURCE | SMF_DESTINATION; copy_state.clip.x2 = destination->config.size.w - 1; copy_state.clip.y2 = destination->config.size.h - 1; copy_state.source = source; copy_state.destination = destination; copy_state.from = from_back ? CSBR_BACK : CSBR_FRONT; dfb_gfxcard_stretchblit( &sourcerect, &destrect, ©_state ); /* Signal end of sequence. */ dfb_state_stop_drawing( ©_state ); pthread_mutex_unlock( ©_lock ); }
static void back_to_front_copy( CoreSurface *surface, const DFBRegion *region, DFBSurfaceBlittingFlags flags, int rotation) { DFBRectangle rect; int dx, dy; if (region) { rect.x = region->x1; rect.y = region->y1; rect.w = region->x2 - region->x1 + 1; rect.h = region->y2 - region->y1 + 1; } else { rect.x = 0; rect.y = 0; rect.w = surface->config.size.w; rect.h = surface->config.size.h; } dx = rect.x; dy = rect.y; pthread_mutex_lock( &btf_lock ); if (!btf_state_inited) { dfb_state_init( &btf_state, NULL ); btf_state.from = CSBR_BACK; btf_state.to = CSBR_FRONT; btf_state_inited = true; } btf_state.modified |= SMF_CLIP | SMF_SOURCE | SMF_DESTINATION; btf_state.clip.x2 = surface->config.size.w - 1; btf_state.clip.y2 = surface->config.size.h - 1; btf_state.source = surface; btf_state.destination = surface; if (rotation == 90) { dx = rect.y; dy = surface->config.size.w - rect.w - rect.x; flags |= DSBLIT_ROTATE90; } else if (rotation == 180) { dx = surface->config.size.w - rect.w - rect.x; dy = surface->config.size.h - rect.h - rect.y; flags |= DSBLIT_ROTATE180; } else if (rotation == 270) { dx = surface->config.size.h - rect.h - rect.y; dy = rect.x; flags |= DSBLIT_ROTATE270; } dfb_state_set_blitting_flags( &btf_state, flags ); dfb_gfxcard_blit( &rect, dx, dy, &btf_state ); /* Signal end of sequence. */ dfb_state_stop_drawing( &btf_state ); pthread_mutex_unlock( &btf_lock ); }
static void back_to_front_copy( CoreSurface *surface, DFBSurfaceStereoEye eye, const DFBRegion *region, DFBSurfaceBlittingFlags flags, int rotation) { DFBRectangle rect; DFBPoint point; StateClient *client = state_client_tls.Get(); if (region) { rect.x = region->x1; rect.y = region->y1; rect.w = region->x2 - region->x1 + 1; rect.h = region->y2 - region->y1 + 1; } else { rect.x = 0; rect.y = 0; rect.w = surface->config.size.w; rect.h = surface->config.size.h; } point.x = rect.x; point.y = rect.y; if (rotation == 90) { point.x = rect.y; point.y = surface->config.size.w - rect.w - rect.x; D_FLAGS_SET( flags, DSBLIT_ROTATE90 ); } else if (rotation == 180) { point.x = surface->config.size.w - rect.w - rect.x; point.y = surface->config.size.h - rect.h - rect.y; D_FLAGS_SET( flags, DSBLIT_ROTATE180 ); } else if (rotation == 270) { point.x = surface->config.size.h - rect.h - rect.y; point.y = rect.x; D_FLAGS_SET( flags, DSBLIT_ROTATE270 ); } D_FLAGS_SET( client->state.modified, SMF_CLIP | SMF_SOURCE | SMF_DESTINATION | SMF_FROM | SMF_TO ); client->state.clip.x2 = surface->config.size.w - 1; client->state.clip.y2 = surface->config.size.h - 1; client->state.source = surface; client->state.destination = surface; client->state.from = CSBR_BACK; client->state.from_eye = eye; client->state.to = CSBR_FRONT; client->state.to_eye = eye; client->state.blittingflags = flags; CoreGraphicsStateClient_Blit( &client->client, &rect, &point, 1 ); CoreGraphicsStateClient_Flush( &client->client, 0, CGSCFF_FOLLOW_READER ); /* Signal end of sequence. */ dfb_state_stop_drawing( &client->state ); client->state.destination = NULL; client->state.source = NULL; }