void gp2x_deinit(void) { int ret; gles2_destroy(); // Release OpenGL resources eglMakeCurrent( display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); eglDestroySurface( display, surface ); eglDestroyContext( display, context ); eglTerminate( display ); dispman_update = vc_dispmanx_update_start( 0 ); ret = vc_dispmanx_element_remove( dispman_update, dispman_element ); ret = vc_dispmanx_element_remove( dispman_update, dispman_element_bg ); ret = vc_dispmanx_update_submit_sync( dispman_update ); ret = vc_dispmanx_resource_delete( resource0 ); ret = vc_dispmanx_resource_delete( resource1 ); ret = vc_dispmanx_resource_delete( resource_bg ); ret = vc_dispmanx_display_close( dispman_display ); if(gp2x_screen8) free(gp2x_screen8); if(gp2x_screen15) free(gp2x_screen15); gp2x_screen8=0; gp2x_screen15=0; }
void destroyLife( LIFE_T *life) { if (life->buffer) { free(life->buffer); life->buffer = NULL; } if (life->field) { free(life->field); life->field = NULL; } if (life->fieldNext) { free(life->fieldNext); life->fieldNext = NULL; } life->width = 0; life->alignedWidth = 0; life->height = 0; life->alignedHeight = 0; life->pitch = 0; life->fieldLength = 0; //--------------------------------------------------------------------- int result = 0; DISPMANX_UPDATE_HANDLE_T update = vc_dispmanx_update_start(0); assert(update != 0); result = vc_dispmanx_element_remove(update, life->element); assert(result == 0); result = vc_dispmanx_update_submit_sync(update); assert(result == 0); //--------------------------------------------------------------------- result = vc_dispmanx_resource_delete(life->frontResource); assert(result == 0); result = vc_dispmanx_resource_delete(life->backResource); assert(result == 0); //--------------------------------------------------------------------- int32_t thread; for (thread = 0 ; thread < life->numberOfThreads ; thread++) { pthread_cancel(life->threads[thread]); } }
static void DISPMANX_FreeResources(void){ free (dispvars->pixmem); //MAC liberamos lo relacionado con dispmanx dispvars->update = vc_dispmanx_update_start( 0 ); vc_dispmanx_resource_delete( dispvars->resources[0] ); vc_dispmanx_resource_delete( dispvars->resources[1] ); vc_dispmanx_element_remove(dispvars->update, dispvars->element); vc_dispmanx_update_submit_sync( dispvars->update ); }
void Dispose() { munmap(fbp, finfo.smem_len); close(fbfd); ret = vc_dispmanx_resource_delete(screen_resource); vc_dispmanx_display_close(display); }
void DMXResource::Close() { if (m_resource != DISPMANX_NO_HANDLE) { vc_dispmanx_resource_delete(m_resource); m_resource = DISPMANX_NO_HANDLE; } }
ViewBackend::Cursor::Cursor(WPE::LibinputServer::Client& targetClient, DISPMANX_DISPLAY_HANDLE_T displayHandle, uint32_t displayWidth, uint32_t displayHeight) : targetClient(targetClient) , position({ 0, 0 }) , displaySize({ displayWidth, displayHeight }) { static VC_DISPMANX_ALPHA_T alpha = { static_cast<DISPMANX_FLAGS_ALPHA_T>(DISPMANX_FLAGS_ALPHA_FROM_SOURCE), 255, 0 }; DISPMANX_UPDATE_HANDLE_T updateHandle = vc_dispmanx_update_start(0); uint32_t imagePtr; VC_RECT_T rect; vc_dispmanx_rect_set(&rect, 0, 0, CursorData::width, CursorData::height); DISPMANX_RESOURCE_HANDLE_T pointerResource = vc_dispmanx_resource_create(VC_IMAGE_RGBA32, CursorData::width, CursorData::height, &imagePtr); vc_dispmanx_resource_write_data(pointerResource, VC_IMAGE_RGBA32, CursorData::width * 4, CursorData::data, &rect); VC_RECT_T srcRect, destRect; vc_dispmanx_rect_set(&srcRect, 0, 0, CursorData::width << 16, CursorData::height << 16); vc_dispmanx_rect_set(&destRect, position.first, position.second, cursorWidth, cursorHeight); cursorHandle = vc_dispmanx_element_add(updateHandle, displayHandle, 10, &destRect, pointerResource, &srcRect, DISPMANX_PROTECTION_NONE, &alpha, nullptr, DISPMANX_NO_ROTATE); vc_dispmanx_resource_delete(pointerResource); vc_dispmanx_update_submit_sync(updateHandle); }
bool initBackgroundLayer( BACKGROUND_LAYER_T *bg, uint16_t colour, int32_t layer) { int result = 0; VC_IMAGE_TYPE_T type = VC_IMAGE_RGBA16; uint32_t vc_image_ptr; bg->resource = vc_dispmanx_resource_create(type, 1, 1, &vc_image_ptr); if(!bg->resource) return false; //--------------------------------------------------------------------- VC_RECT_T dst_rect; vc_dispmanx_rect_set(&dst_rect, 0, 0, 1, 1); bg->layer = layer; result = vc_dispmanx_resource_write_data(bg->resource, type, sizeof(colour), &colour, &dst_rect); if(result != DISPMANX_SUCCESS){ result = vc_dispmanx_resource_delete(bg->resource); return false; } return true; }
static void dmx_region_delete(struct dmx_region_t *dmx_region, DISPMANX_UPDATE_HANDLE_T update) { vc_dispmanx_element_remove(update, dmx_region->element); vc_dispmanx_resource_delete(dmx_region->resource); free(dmx_region); }
/* Free a window manager cursor */ static void RPI_FreeCursor(SDL_Cursor * cursor) { int ret; DISPMANX_UPDATE_HANDLE_T update; RPI_CursorData *curdata; if (cursor != NULL) { curdata = (RPI_CursorData *) cursor->driverdata; if (curdata != NULL) { if (curdata->element != DISPMANX_NO_HANDLE) { update = vc_dispmanx_update_start( 10 ); SDL_assert( update ); ret = vc_dispmanx_element_remove( update, curdata->element ); SDL_assert( ret == DISPMANX_SUCCESS ); ret = vc_dispmanx_update_submit_sync( update ); SDL_assert( ret == DISPMANX_SUCCESS ); } if (curdata->resource != DISPMANX_NO_HANDLE) { ret = vc_dispmanx_resource_delete( curdata->resource ); SDL_assert( ret == DISPMANX_SUCCESS ); } SDL_free(cursor->driverdata); } SDL_free(cursor); } }
bool destroyBackgroundLayer( BACKGROUND_LAYER_T *bg) { int result = 0; bool res = true; if(bg->element) { DISPMANX_UPDATE_HANDLE_T update = vc_dispmanx_update_start(0); if(update) { result = vc_dispmanx_element_remove(update, bg->element); if(result != DISPMANX_SUCCESS) res = false; result = vc_dispmanx_update_submit_sync(update); if(result != DISPMANX_SUCCESS) res = false; }else{ res = false; } } result = vc_dispmanx_resource_delete(bg->resource); if(result != DISPMANX_SUCCESS) res = false; return res; }
int Initialize() { fbfd = 0; fbp = 0; setlogmask(LOG_UPTO(LOG_DEBUG)); openlog("fbcp", LOG_NDELAY | LOG_PID, LOG_USER); bcm_host_init(); display = vc_dispmanx_display_open(0); if (!display) { syslog(LOG_ERR, "Unable to open primary display"); return -1; } ret = vc_dispmanx_display_get_info(display, &display_info); if (ret) { syslog(LOG_ERR, "Unable to get primary display information"); return -1; } syslog(LOG_INFO, "Primary display is %d x %d", display_info.width, display_info.height); fbfd = open("/dev/fb1", O_RDWR); if (!fbfd) { syslog(LOG_ERR, "Unable to open secondary display"); return -1; } if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { syslog(LOG_ERR, "Unable to get secondary display information"); return -1; } if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { syslog(LOG_ERR, "Unable to get secondary display information"); return -1; } syslog(LOG_INFO, "Second display is %d x %d %dbps\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel); screen_resource = vc_dispmanx_resource_create(VC_IMAGE_RGB565, vinfo.xres, vinfo.yres, &image_prt); if (!screen_resource) { syslog(LOG_ERR, "Unable to create screen buffer"); close(fbfd); vc_dispmanx_display_close(display); return -1; } fbp = (char*) mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if (fbp <= 0) { syslog(LOG_ERR, "Unable to create mamory mapping"); close(fbfd); ret = vc_dispmanx_resource_delete(screen_resource); vc_dispmanx_display_close(display); return -1; } vc_dispmanx_rect_set(&rect1, 0, 0, vinfo.xres, vinfo.yres); return 1; }
void gp2x_frontend_deinit(void) { int ret; dispman_update = vc_dispmanx_update_start( 0 ); ret = vc_dispmanx_element_remove( dispman_update, dispman_element ); ret = vc_dispmanx_update_submit_sync( dispman_update ); ret = vc_dispmanx_resource_delete( resource0 ); ret = vc_dispmanx_resource_delete( resource1 ); ret = vc_dispmanx_display_close( dispman_display ); if(gp2x_screen8) free(gp2x_screen8); if(gp2x_screen15) free(gp2x_screen15); gp2x_screen8=0; gp2x_screen15=0; }
static void DISPMANX_FreeBackground (void) { dispvars->b_update = vc_dispmanx_update_start( 0 ); vc_dispmanx_resource_delete( dispvars->b_resource ); vc_dispmanx_element_remove ( dispvars->b_update, dispvars->b_element); vc_dispmanx_update_submit_sync( dispvars->b_update ); }
static void dispmanx_free_menu_resources (void *data) { struct dispmanx_video *_dispvars = data; if (!_dispvars) return; _dispvars->update = vc_dispmanx_update_start(0); vc_dispmanx_resource_delete(_dispvars->menu_resources[0]); vc_dispmanx_resource_delete(_dispvars->menu_resources[1]); vc_dispmanx_element_remove(_dispvars->update, _dispvars->menu_element); vc_dispmanx_update_submit_sync(_dispvars->update); _dispvars->menu_width = 0; _dispvars->menu_height = 0; }
void pi_deinit(void) { gles2_destroy(); // Release OpenGL resources eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroySurface(display, surface); eglDestroyContext(display, context); eglTerminate(display); dispman_update = vc_dispmanx_update_start(0); vc_dispmanx_element_remove(dispman_update, dispman_element); vc_dispmanx_element_remove(dispman_update, dispman_element_bg); vc_dispmanx_update_submit_sync(dispman_update); vc_dispmanx_resource_delete(resource0); vc_dispmanx_resource_delete(resource1); vc_dispmanx_resource_delete(resource_bg); vc_dispmanx_display_close(dispman_display); if (VideoBuffer) free(VideoBuffer); VideoBuffer = 0; }
unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool swap_red_blue) { DISPMANX_DISPLAY_HANDLE_T display; DISPMANX_RESOURCE_HANDLE_T resource; VC_RECT_T rect; unsigned char *image = NULL; uint32_t vc_image_ptr; int stride; display = vc_dispmanx_display_open( 0 /*screen*/ ); stride = ((width + 15) & ~15) * 4; image = new unsigned char [height * stride]; if (image) { resource = vc_dispmanx_resource_create( VC_IMAGE_RGBA32, width, height, &vc_image_ptr ); vc_dispmanx_snapshot(display, resource, (DISPMANX_TRANSFORM_T)0); vc_dispmanx_rect_set(&rect, 0, 0, width, height); vc_dispmanx_resource_read_data(resource, &rect, image, stride); vc_dispmanx_resource_delete( resource ); vc_dispmanx_display_close(display ); // we need to save in BGRA order so Swap RGBA -> BGRA if (swap_red_blue) { for (int y = 0; y < height; y++) { unsigned char *p = image + y * stride; for (int x = 0; x < width; x++, p+=4) { unsigned char t = p[0]; p[0] = p[2]; p[2] = t; } } } // assume we need to pack image if caller doesn't want stride if (!pstride && stride > width*4) { for (int y = 0; y < height; y++) { unsigned char *in = image + y * stride; unsigned char *out = image + y * width * 4; memmove(out, in, width*4); } } } if (pstride) *pstride = stride; return image; }
void save_snapshot(void) { DISPMANX_DISPLAY_HANDLE_T display; DISPMANX_MODEINFO_T info; DISPMANX_RESOURCE_HANDLE_T resource; VC_IMAGE_TYPE_T type = VC_IMAGE_RGB888; VC_IMAGE_TRANSFORM_T transform = 0; VC_RECT_T rect; void *image; uint32_t vc_image_ptr; int ret; uint32_t screen = 0; fprintf(stderr,"\nWriting snapshot...\n"); //fprintf(stderr,"Open display[%i]...\n", screen ); display = vc_dispmanx_display_open( screen ); ret = vc_dispmanx_display_get_info(display, &info); assert(ret == 0); //fprintf(stderr,"Display is %d x %d\n", info.width, info.height ); image = calloc( 1, info.width * 3 * info.height ); assert(image); resource = vc_dispmanx_resource_create(type, info.width, info.height,&vc_image_ptr); vc_dispmanx_snapshot(display, resource, transform); vc_dispmanx_rect_set(&rect, 0, 0, info.width, info.height); vc_dispmanx_resource_read_data(resource, &rect, image, info.width*3); char* home = getenv("HOME"); char filename[1024]; if (!home) home = "/tmp"; snprintf(filename,sizeof(filename),"%s/pidvbip-%u.ppm",home,(unsigned int)time(NULL)); FILE *fp = fopen(filename, "wb"); fprintf(fp, "P6\n%d %d\n255\n", info.width, info.height); fwrite(image, info.width*3*info.height, 1, fp); fclose(fp); fprintf(stderr,"\nSnapshot written to %s\n",filename); ret = vc_dispmanx_resource_delete( resource ); assert( ret == 0 ); ret = vc_dispmanx_display_close(display ); assert( ret == 0 ); free(image); }
static void frontend_deinit(void) { fe_update = vc_dispmanx_update_start( 0 ); vc_dispmanx_element_remove( fe_update, fe_element ); vc_dispmanx_update_submit_sync( fe_update ); vc_dispmanx_resource_delete( fe_resource ); vc_dispmanx_display_close( fe_display ); if(fe_screen) free(fe_screen); fe_screen=0; bcm_host_deinit(); }
int main(void) { DISPMANX_DISPLAY_HANDLE_T display; DISPMANX_MODEINFO_T info; DISPMANX_RESOURCE_HANDLE_T resource; VC_IMAGE_TYPE_T type = VC_IMAGE_RGB888; VC_IMAGE_TRANSFORM_T transform = 0; VC_RECT_T rect; void *image; uint32_t vc_image_ptr; int ret; uint32_t screen = 0; bcm_host_init(); printf("Open display[%i]...\n", screen ); display = vc_dispmanx_display_open( screen ); ret = vc_dispmanx_display_get_info(display, &info); assert(ret == 0); printf( "Display is %d x %d\n", info.width, info.height ); image = calloc( 1, info.width * 3 * info.height ); assert(image); resource = vc_dispmanx_resource_create( type, info.width, info.height, &vc_image_ptr ); vc_dispmanx_snapshot(display, resource, transform); vc_dispmanx_rect_set(&rect, 0, 0, info.width, info.height); vc_dispmanx_resource_read_data(resource, &rect, image, info.width*3); FILE *fp = fopen("out.ppm", "wb"); fprintf(fp, "P6\n%d %d\n255\n", info.width, info.height); fwrite(image, info.width*3*info.height, 1, fp); fclose(fp); ret = vc_dispmanx_resource_delete( resource ); assert( ret == 0 ); ret = vc_dispmanx_display_close(display ); assert( ret == 0 ); return 0; }
static void hide_cursor(ALLEGRO_DISPLAY_RASPBERRYPI *d) { (void)d; if (!cursor_added) { return; } dispman_update = vc_dispmanx_update_start(0); vc_dispmanx_element_remove(dispman_update, cursor_element); vc_dispmanx_update_submit_sync(dispman_update); vc_dispmanx_resource_delete(cursor_resource); cursor_added = false; }
void destroyWorms( WORMS_T *worms) { uint16_t i = 0; for (i = 0 ; i < worms->size ; i++) { WORM_T *worm = &(worms->worms[i]); destroyWorm(worm); } free(worms->worms); worms->size = 0; worms->worms = NULL; destroyImage(&(worms->image)); //--------------------------------------------------------------------- int result = 0; DISPMANX_UPDATE_HANDLE_T update = vc_dispmanx_update_start(0); assert(update != 0); result = vc_dispmanx_element_remove(update, worms->element); assert(result == 0); result = vc_dispmanx_update_submit_sync(update); assert(result == 0); //--------------------------------------------------------------------- result = vc_dispmanx_resource_delete(worms->frontResource); assert(result == 0); result = vc_dispmanx_resource_delete(worms->backResource); assert(result == 0); }
//------------------------------------------------------------------------------ // OsdGraphics::~OsdGraphics() { #if 0 vars->update = vc_dispmanx_update_start( 10 ); assert( vars->update ); ret = vc_dispmanx_element_remove( vars->update, vars->element ); assert( ret == 0 ); ret = vc_dispmanx_update_submit_sync( vars->update ); assert( ret == 0 ); ret = vc_dispmanx_resource_delete( vars->resource ); assert( ret == 0 ); ret = vc_dispmanx_display_close( vars->display ); assert( ret == 0 ); #endif }
void dispmanxtest() { DISPMANX_DISPLAY_HANDLE_T display; int ret; DISPMANX_MODEINFO_T displayinfo; DISPMANX_RESOURCE_HANDLE_T res; int width = 1024; int height = 576; uint32_t vc_image_ptr; DISPMANX_UPDATE_HANDLE_T update; VC_RECT_T dst_rect,src_rect; DISPMANX_ELEMENT_HANDLE_T element; bcm_host_init(); display = vc_dispmanx_display_open(0); ret = vc_dispmanx_display_get_info( display, &displayinfo); assert(ret==0); printf("display is %dx%d\n",displayinfo.width,displayinfo.height); res = vc_dispmanx_resource_create(VC_IMAGE_YUV420,width,height,&vc_image_ptr); vc_image_ptr = vc_dispmanx_resource_get_image_handle(res); printf("vc_image_ptr %x\n",vc_image_ptr); assert(res); update = vc_dispmanx_update_start(10); assert(update); vc_dispmanx_rect_set(&src_rect,0,0,width<<16,height<<16); vc_dispmanx_rect_set(&dst_rect,0,(displayinfo.height - height)/2,width-32,height); element = vc_dispmanx_element_add(update,display,2000,&dst_rect,res,&src_rect,DISPMANX_PROTECTION_NONE,NULL,NULL,DISPMANX_NO_ROTATE); ret = vc_dispmanx_update_submit_sync(update); assert(ret==0); uint8_t *rawfb = (uint8_t*)mapmem(vc_image_ptr,0x1000); for (int i=0; i<0x100; i++) { printf("%02x ",rawfb[i]); } printf("\n"); unmapmem(rawfb,0x1000); puts("sleeping"); sleep(10); update = vc_dispmanx_update_start(10); assert(update); ret = vc_dispmanx_element_remove(update,element); assert(ret==0); ret = vc_dispmanx_update_submit_sync(update); assert(ret==0); ret = vc_dispmanx_resource_delete(res); assert(ret==0); ret = vc_dispmanx_display_close(display); assert(ret==0); }
static void dispmanx_free_main_resources(void *data) { int i; struct dispmanx_video *_dispvars = data; if (!_dispvars) return; _dispvars->update = vc_dispmanx_update_start(0); for (i = 0; i < NUMPAGES; i++) vc_dispmanx_resource_delete(_dispvars->resources[i]); vc_dispmanx_element_remove(_dispvars->update, _dispvars->element); vc_dispmanx_update_submit_sync(_dispvars->update); }
static void dispmanx_surface_free(void *data, struct dispmanx_surface *surface) { int i; struct dispmanx_video *_dispvars = data; for (i = 0; i < surface->numpages; i++) { vc_dispmanx_resource_delete(surface->pages[i].resource); surface->pages[i].used = false; slock_free(surface->pages[i].page_used_mutex); } free(surface->pages); _dispvars->update = vc_dispmanx_update_start(0); vc_dispmanx_element_remove(_dispvars->update, surface->element); vc_dispmanx_update_submit_sync(_dispvars->update); surface->setup = false; }
static void fbDispmanReleaseNativeCursor(jlong nativeCursorHandle) { DispmanCursorImage *cursorImage = (DispmanCursorImage *)jlong_to_ptr(nativeCursorHandle); if (cursorImage != NULL && cursorImage->resource != 0) { if (cursor.currentCursor == nativeCursorHandle && cursor.isVisible) { DISPMANX_UPDATE_HANDLE_T update; update = vc_dispmanx_update_start(0); vc_dispmanx_element_change_source(update, cursor.element, 0 /* resource*/); vc_dispmanx_update_submit_sync(update); } vc_dispmanx_resource_delete(cursorImage->resource); } free(cursorImage); if (cursor.currentCursor == nativeCursorHandle) { cursor.currentCursor = 0; } }
void vo_close(RECT_VARS_T* vars) { int ret; /* Cleanup code from dispmanx.c */ vars->update = vc_dispmanx_update_start( 10 ); assert( vars->update ); ret = vc_dispmanx_element_remove( vars->update, vars->element ); assert( ret == 0 ); ret = vc_dispmanx_update_submit_sync( vars->update ); assert( ret == 0 ); ret = vc_dispmanx_resource_delete( vars->resource ); assert( ret == 0 ); ret = vc_dispmanx_display_close( vars->display ); assert( ret == 0 ); /* End of cleanup */ }
unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool swap_red_blue, bool video_only) { DISPMANX_DISPLAY_HANDLE_T display; DISPMANX_RESOURCE_HANDLE_T resource; VC_RECT_T rect; unsigned char *image = NULL; uint32_t vc_image_ptr; int stride; uint32_t flags = 0; if (video_only) flags |= DISPMANX_SNAPSHOT_NO_RGB|DISPMANX_SNAPSHOT_FILL; if (swap_red_blue) flags |= DISPMANX_SNAPSHOT_SWAP_RED_BLUE; if (!pstride) flags |= DISPMANX_SNAPSHOT_PACK; display = vc_dispmanx_display_open( 0 /*screen*/ ); stride = ((width + 15) & ~15) * 4; image = new unsigned char [height * stride]; if (image) { resource = vc_dispmanx_resource_create( VC_IMAGE_RGBA32, width, height, &vc_image_ptr ); vc_dispmanx_snapshot(display, resource, (DISPMANX_TRANSFORM_T)flags); vc_dispmanx_rect_set(&rect, 0, 0, width, height); vc_dispmanx_resource_read_data(resource, &rect, image, stride); vc_dispmanx_resource_delete( resource ); vc_dispmanx_display_close(display ); } if (pstride) *pstride = stride; return image; }
static void *display_thread (void *unused) { VC_DISPMANX_ALPHA_T alpha = { (DISPMANX_FLAGS_ALPHA_T)(DISPMANX_FLAGS_ALPHA_FROM_SOURCE | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS), 255 /*alpha 0->255*/ , 0 }; uint32_t vc_image_ptr; SDL_Surface *Dummy_prSDLScreen; int width, height; bool callback_registered = false; for(;;) { display_thread_busy = false; uae_u32 signal = read_comm_pipe_u32_blocking(display_pipe); display_thread_busy = true; switch(signal) { case DISPLAY_SIGNAL_SETUP: if(!callback_registered) { bcm_host_init(); dispmanxdisplay = vc_dispmanx_display_open(0); vc_dispmanx_vsync_callback(dispmanxdisplay, vsync_callback, NULL); callback_registered = true; } break; case DISPLAY_SIGNAL_SUBSHUTDOWN: if (DispManXElementpresent == 1) { DispManXElementpresent = 0; dispmanxupdate = vc_dispmanx_update_start(0); vc_dispmanx_element_remove(dispmanxupdate, dispmanxelement); vc_dispmanx_update_submit_sync(dispmanxupdate); } if (dispmanxresource_amigafb_1 != 0) { vc_dispmanx_resource_delete(dispmanxresource_amigafb_1); dispmanxresource_amigafb_1 = 0; } if (dispmanxresource_amigafb_2 != 0) { vc_dispmanx_resource_delete(dispmanxresource_amigafb_2); dispmanxresource_amigafb_2 = 0; } if(prSDLScreen != NULL) { SDL_FreeSurface(prSDLScreen); prSDLScreen = NULL; } uae_sem_post (&display_sem); break; case DISPLAY_SIGNAL_OPEN: width = display_width; height = display_height; Dummy_prSDLScreen = SDL_SetVideoMode(width, height, 16, SDL_SWSURFACE | SDL_FULLSCREEN); prSDLScreen = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, 16, Dummy_prSDLScreen->format->Rmask, Dummy_prSDLScreen->format->Gmask, Dummy_prSDLScreen->format->Bmask, Dummy_prSDLScreen->format->Amask); SDL_FreeSurface(Dummy_prSDLScreen); vc_dispmanx_display_get_info(dispmanxdisplay, &dispmanxdinfo); dispmanxresource_amigafb_1 = vc_dispmanx_resource_create(VC_IMAGE_RGB565, width, height, &vc_image_ptr); dispmanxresource_amigafb_2 = vc_dispmanx_resource_create(VC_IMAGE_RGB565, width, height, &vc_image_ptr); vc_dispmanx_rect_set(&blit_rect, 0, 0, width, height); vc_dispmanx_resource_write_data(dispmanxresource_amigafb_1, VC_IMAGE_RGB565, prSDLScreen->pitch, prSDLScreen->pixels, &blit_rect); vc_dispmanx_rect_set(&src_rect, 0, 0, width << 16, height << 16); // 16/9 to 4/3 ratio adaptation. if (currprefs.gfx_correct_aspect == 0 || screen_is_picasso) { // Fullscreen. int scaled_width = dispmanxdinfo.width * currprefs.gfx_fullscreen_ratio / 100; int scaled_height = dispmanxdinfo.height * currprefs.gfx_fullscreen_ratio / 100; vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width - scaled_width)/2, (dispmanxdinfo.height - scaled_height)/2, scaled_width, scaled_height); } else { // 4/3 shrink. int scaled_width = dispmanxdinfo.width * currprefs.gfx_fullscreen_ratio / 100; int scaled_height = dispmanxdinfo.height * currprefs.gfx_fullscreen_ratio / 100; vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width - scaled_width / 16 * 12)/2, (dispmanxdinfo.height - scaled_height)/2, scaled_width/16*12, scaled_height); } if (DispManXElementpresent == 0) { DispManXElementpresent = 1; dispmanxupdate = vc_dispmanx_update_start(0); dispmanxelement = vc_dispmanx_element_add(dispmanxupdate, dispmanxdisplay, 2, // layer &dst_rect, dispmanxresource_amigafb_1, &src_rect, DISPMANX_PROTECTION_NONE, &alpha, NULL, DISPMANX_NO_ROTATE); vc_dispmanx_update_submit(dispmanxupdate, NULL, NULL); } uae_sem_post (&display_sem); break; case DISPLAY_SIGNAL_SHOW: if (current_resource_amigafb == 1) { current_resource_amigafb = 0; vc_dispmanx_resource_write_data(dispmanxresource_amigafb_1, VC_IMAGE_RGB565, adisplays.gfxvidinfo.drawbuffer.rowbytes, adisplays.gfxvidinfo.drawbuffer.bufmem, &blit_rect); dispmanxupdate = vc_dispmanx_update_start(0); vc_dispmanx_element_change_source(dispmanxupdate, dispmanxelement, dispmanxresource_amigafb_1); } else { current_resource_amigafb = 1; vc_dispmanx_resource_write_data(dispmanxresource_amigafb_2, VC_IMAGE_RGB565, adisplays.gfxvidinfo.drawbuffer.rowbytes, adisplays.gfxvidinfo.drawbuffer.bufmem, &blit_rect); dispmanxupdate = vc_dispmanx_update_start(0); vc_dispmanx_element_change_source(dispmanxupdate, dispmanxelement, dispmanxresource_amigafb_2); } vc_dispmanx_update_submit(dispmanxupdate, NULL, NULL); break; case DISPLAY_SIGNAL_QUIT: callback_registered = false; vc_dispmanx_vsync_callback(dispmanxdisplay, NULL, NULL); vc_dispmanx_display_close(dispmanxdisplay); bcm_host_deinit(); SDL_VideoQuit(); display_tid = 0; return 0; } } }
static void open_screen(struct uae_prefs *p) { VC_DISPMANX_ALPHA_T alpha = { (DISPMANX_FLAGS_ALPHA_T ) (DISPMANX_FLAGS_ALPHA_FROM_SOURCE | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS), 255, /*alpha 0->255*/ 0 }; uint32_t vc_image_ptr; int width; int height; #ifdef PICASSO96 if (screen_is_picasso) { width = picasso_vidinfo.width; height = picasso_vidinfo.height; } else #endif { p->gfx_resolution = p->gfx_size.width > 600 ? 1 : 0; width = p->gfx_size.width; height = p->gfx_size.height; } //if(prSDLScreen != NULL) //{ // SDL_FreeSurface(prSDLScreen); // prSDLScreen = NULL; //} if(Dummy_prSDLScreen == NULL ) { const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo (); printf("DispmanX: Current resolution: %d x %d %d bpp\n",videoInfo->current_w, videoInfo->current_h, videoInfo->vfmt->BitsPerPixel); Dummy_prSDLScreen = SDL_SetVideoMode(videoInfo->current_w,videoInfo->current_h,16,SDL_SWSURFACE |SDL_FULLSCREEN); //Dummy_prSDLScreen = SDL_SetVideoMode(800,480,16,SDL_SWSURFACE ); } SDL_ShowCursor(SDL_DISABLE); // check if resolution hasn't change in menu. otherwise free the resources so that they will be re-generated with new resolution. if ((dispmanxresource_amigafb_1 != 0) && ((blit_rect.width != width) || (blit_rect.height != height) || (currprefs.gfx_correct_aspect != changed_prefs.gfx_correct_aspect))) { printf("Emulation resolution change detected.\n"); if(prSDLScreen != NULL ) { SDL_FreeSurface(prSDLScreen); prSDLScreen = 0; } graphics_dispmanshutdown(); vc_dispmanx_resource_delete( dispmanxresource_amigafb_1 ); vc_dispmanx_resource_delete( dispmanxresource_amigafb_2 ); dispmanxresource_amigafb_1 = 0; dispmanxresource_amigafb_2 = 0; } if (dispmanxresource_amigafb_1 == 0) { printf("Emulation resolution: Width %i Height: %i\n",width,height); currprefs.gfx_correct_aspect = changed_prefs.gfx_correct_aspect; prSDLScreen = SDL_CreateRGBSurface(SDL_SWSURFACE,width,height,16, Dummy_prSDLScreen->format->Rmask, Dummy_prSDLScreen->format->Gmask, Dummy_prSDLScreen->format->Bmask, Dummy_prSDLScreen->format->Amask); dispmanxdisplay = vc_dispmanx_display_open( 0 ); vc_dispmanx_display_get_info( dispmanxdisplay, &dispmanxdinfo); dispmanxresource_amigafb_1 = vc_dispmanx_resource_create( VC_IMAGE_RGB565, width, height, &vc_image_ptr); dispmanxresource_amigafb_2 = vc_dispmanx_resource_create( VC_IMAGE_RGB565, width, height, &vc_image_ptr); vc_dispmanx_rect_set( &blit_rect, 0, 0, width,height); vc_dispmanx_resource_write_data( dispmanxresource_amigafb_1, VC_IMAGE_RGB565, width *2, prSDLScreen->pixels, &blit_rect ); vc_dispmanx_rect_set( &src_rect, 0, 0, width << 16, height << 16 ); } // 16/9 to 4/3 ratio adaptation. if (currprefs.gfx_correct_aspect == 0) { // Fullscreen. vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width * 1)/100, (dispmanxdinfo.height * 2)/100 , dispmanxdinfo.width - (dispmanxdinfo.width * 2)/100 , dispmanxdinfo.height - (dispmanxdinfo.height * 4)/100 ); } else { // 4/3 shrink. vc_dispmanx_rect_set( &dst_rect, ((dispmanxdinfo.width * 13)/100) , (dispmanxdinfo.height * 2)/100 , (dispmanxdinfo.width - ((dispmanxdinfo.width * 26)/100)) , dispmanxdinfo.height - (dispmanxdinfo.height * 4)/100 ); } // For debug, in order to avoid full screen. //vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width /2), // (dispmanxdinfo.height /2) , // (dispmanxdinfo.width - (dispmanxdinfo.width * 6)/100 )/2, // (dispmanxdinfo.height - (dispmanxdinfo.height * 7)/100 )/2); if (DispManXElementpresent == 0) { DispManXElementpresent = 1; dispmanxupdate = vc_dispmanx_update_start( 10 ); dispmanxelement = vc_dispmanx_element_add( dispmanxupdate, dispmanxdisplay, 2000, // layer &dst_rect, dispmanxresource_amigafb_1, &src_rect, DISPMANX_PROTECTION_NONE, &alpha, NULL, // clamp DISPMANX_NO_ROTATE ); vc_dispmanx_update_submit(dispmanxupdate,NULL,NULL); //dispmanxupdate = vc_dispmanx_update_start( 10 ); } if(prSDLScreen != NULL) { InitAmigaVidMode(p); init_row_map(); } //framecnt = 1; // Don't draw frame before reset done }