void egl_server_platform_display( uint32_t win, KHRN_IMAGE_T* khrn_image, uint32_t cb_arg) { VC_IMAGE_T vc_image,*image; assert(win != EGL_PLATFORM_WIN_NONE); if (!displaying) { displaying = true; current_win = win; } assert(win == current_win); //Can only display on a single window khrn_image_fill_vcimage(khrn_image, &vc_image); image = &vc_image; assert(image->type == VC_IMAGE_TF_RGBA32 || image->type == VC_IMAGE_RGBA32 || image->type == VC_IMAGE_TF_RGBX32); vc_image_to_tga_memory(image); /* May as well call callback immediately */ egl_callback(cb_arg); }
void egl_server_platform_display( uint32_t win, KHRN_IMAGE_T* image, uint32_t cb_arg) { #ifdef DIRECT_RENDERING assert(0); return; #else assert(win != EGL_PLATFORM_WIN_NONE); if (!displaying) { displaying = true; current_win = win; } assert(win == current_win); //Can only display on a single window { android_native_buffer_t* buffer; void* bits; if (!nativeWindow) nativeWindow = get_android_native_window(); if (nativeWindow) { int fenceFd; nativeWindow->dequeueBuffer(nativeWindow, &buffer,&fenceFd); if(fenceFd >= 0) close(fenceFd); module->lock(module, buffer->handle, GRALLOC_USAGE_SW_WRITE_OFTEN, 0, 0, buffer->width, buffer->height, &bits); if (!bpp) bpp = getBytesPerPixel(buffer->format); if (check_color_format_khrn_image_vs_native_window(image, buffer)) { VC_IMAGE_T vc_image; khrn_image_fill_vcimage(image, &vc_image); vc_image_to_RSO_memory(&vc_image, buffer, bits); } else { khrn_image_to_native_buffer(image, buffer, bits); } module->unlock(module, buffer->handle); nativeWindow->queueBuffer(nativeWindow, buffer,&fenceFd); if(fenceFd >= 0) close(fenceFd); } } /* May as well call callback immediately */ if (egl_callback) egl_callback(cb_arg); #endif }
void egl_server_platform_display(uint32_t win, KHRN_IMAGE_T *image, uint32_t cb_arg) { #ifdef DISPLAY_IS_BROKEN egl_callback(cb_arg); #else DISPMANX_UPDATE_HANDLE_T update = dispmanx_update_start(0); VC_IMAGE_T vc_image; khrn_image_fill_vcimage(image, &vc_image); if (vc_image.type == VC_IMAGE_RGBX32) vc_image.type = VC_IMAGE_RGBA32; /* XXX scalerlib can't handle it! */ #ifdef ARTS_AUTOMATION arts_display_hook(&vc_image); #endif dispmanx_element_change_source(update, (DISPMANX_ELEMENT_HANDLE_T)win, &vc_image); if (flip_it(&vc_image)) dispmanx_element_change_transform(update, (DISPMANX_ELEMENT_HANDLE_T)win, DISPMANX_FLIP_VERT); dispmanx_update_submit(update, our_callback, (void *)cb_arg); #endif }
void egl_server_platform_display(uint32_t win, KHRN_IMAGE_T *image, uint32_t cb_arg) { #ifdef DISPLAY_IS_BROKEN egl_callback(cb_arg); #else uint32_t display_width, display_height, display_zoom; VC_RECT_T dr; VC_IMAGE_T vc_image; khrn_image_fill_vcimage(image, &vc_image); if (vc_image.type == VC_IMAGE_RGBX32) vc_image.type = VC_IMAGE_RGBA32; /* XXX scalerlib can't handle it! */ #ifdef ARTS_AUTOMATION arts_display_hook(&vc_image); #endif #ifdef BLOOM VC_IMAGE_T *bloom_image; vc_image.width &= ~63; vc_image.height &= ~63; bloom_i = (bloom_i + 1) % 3; #endif if (!inited) { inited = 1; dispmanx_init(); display = dispmanx_display_open(display_num); #ifdef BLOOM vcos_assert(bloom_handle == 0); bloom_result[0] = vc_image_parmalloc(vc_image.type, "Bloom result", vc_image.width / 4, vc_image.height / 4); bloom_result[1] = vc_image_parmalloc(vc_image.type, "Bloom result", vc_image.width / 4, vc_image.height / 4); bloom_result[2] = vc_image_parmalloc(vc_image.type, "Bloom result", vc_image.width / 4, vc_image.height / 4); bloom_handle = vcbloom_genbloom(bloom_result[0]->type, vc_image.type, 25, /*0,1*/7, 29, 1, 4, 1, 0, 0); bloom_tmp = malloc(vcbloom_calctmpbuffersize(bloom_handle, bloom_result[0], &vc_image)); vcos_assert(bloom_handle != 0 && bloom_tmp != 0 && bloom_result[0] != 0 && bloom_result[1] != 0 && bloom_result[2] != 0); #endif } #ifdef BLOOM vc_image_lock(&vc_image, &vc_image); vclib_obtain_VRF(1); vcbloom_do(bloom_handle, bloom_result[bloom_i], &vc_image, bloom_tmp); vclib_release_VRF(); vc_image_unlock(&vc_image); bloom_image = bloom_result[bloom_i]; #endif #ifdef ALWAYS_HDMI frame++; //hdmi_hotplug_checker(NULL); if (display_num == 0) { #if 0 dispmanx_display_close(display); vcos_assert(display_num == 0); display_num = 2; HDMI_RES_T hdmi_res = {HDMI_RES_GROUP_DMT, /*HDMI_DMT_SWXGAP_60*//*HDMI_DMT_SWXGAP_RB*/HDMI_DMT_UXGA_60}; hdmi_hotplug_checker(NULL); //_vasm("bkpt"); hdmi_power_on(HDMI_MODE_DVI/*HDMI*/, hdmi_res, display_num); vcos_sleep(1000); #endif HDMI_RES_T best_res = {HDMI_RES_GROUP_DMT, HDMI_DMT_SWXGAP_60/*HDMI_DMT_SWXGAP_RB*/}; HDMI_MODE_T mode = HDMI_MODE_HDMI; if (1/*hdmi_get_mode() != VC_HDMI_UNPLUGGED*/) { int32_t hdmi_support; //int result = hdmi_supported_modes(&mode, &preferred_res, cea_modes, dmt_modes); //assert(result == 0); get_hdmi_best_mode(&mode, &hdmi_support, &best_res.group, &best_res.mode); #ifdef HDMI_14_3D best_res.group = HDMI_RES_GROUP_CEA; best_res.mode = HDMI_CEA_1080p60; #endif dispmanx_display_close(display); uint32_t frame_rate, interlaced; hdmi_get_screen_size(best_res, &hdmi_width, &hdmi_height, &frame_rate, &interlaced); hdmi_power_on(mode, best_res, 2); vcos_sleep(100); display_num = 2; while ((display = dispmanx_display_open(display_num)) == 0) { vcos_sleep(1000); _vasm("bkpt"); } #ifdef HDMI_14_3D { /* Set the info frame to enable 3D using half-height, full-width packed signals */ //uint8_t info_frame[HDMI_NUM_PACKET_BYTES] = {0x00, 0x03, 0x0c, 0x00, 0x40, 0x60, }; /* Set the info frame to enable 3D using full-height, half-width packed signals */ uint8_t info_frame[HDMI_NUM_PACKET_BYTES] = {0x00, 0x03, 0x0c, 0x00, 0x40, 0x80, 0x00, }; hdmi_set_infoframe(HDMI_INFOFRAME_VS, info_frame, /*5*/ 6); } #endif } } else { if (0/*hdmi_get_mode() == VC_HDMI_UNPLUGGED*/) { dispmanx_display_close(display); display_num = 0; display = dispmanx_display_open(display_num); } } #endif #ifdef PRESSING_E_PUTS_IT_ON_HDMI if (game_button_pressed(GAME_KEY_E)) { dispmanx_display_close(display); display_num ^= 2; display = dispmanx_display_open(display_num); } #endif #ifdef __VIDEOCORE4__ if (display_num) { display_width = hdmi_width; display_height = hdmi_height; display_zoom = 1; } else { display_width = 800; display_height = 480; display_zoom = 0; } #else display_width = display_num ? 1280 : 800; display_height = display_num ? 720 : 480; display_zoom = display_num ? 1 : 0; #endif DISPMANX_UPDATE_HANDLE_T update = dispmanx_update_start(0); remove_element(update, win); if (display) { uint32_t w,h; DISPMANX_ALPHA_T alpha = {DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS, 255, 0}; w = vc_image.width; h = vc_image.height; #ifdef KHRN_SIMPLE_MULTISAMPLE w /= 2; h /= 2; #endif if (display_zoom) { float zoom0 = (float)display_width / (float)w; float zoom1 = (float)display_height / (float)h; if (zoom0 < zoom1) { w = (int)(w * zoom0); h = (int)(h * zoom0); } else { w = (int)(w * zoom1); h = (int)(h * zoom1); } } dr.x = ((display_width - (UNPACK_NATIVE_WINDOW_N(win) * w)) >> 1) + (UNPACK_NATIVE_WINDOW_I(win) * w); dr.width = w; //VC_RECT_T sr = {0, 0, image->width<<8, image->height<<8}; if (h > display_height) { dr.y = 0; dr.height = display_height; } else { dr.y = display_height - h >> 1; dr.height = h; } #ifdef BLOOM add_element(dispmanx_element_add(update, display, 0, &dr, &vc_image, 0, DISPMANX_PROTECTION_NONE, &alpha, 0/*clamp*/, flip_it(&vc_image) ? DISPMANX_FLIP_VERT : DISPMANX_NO_ROTATE), win); if (bloom_amount) { alpha.opacity = bloom_amount; add_element(dispmanx_element_add(update, display, 0, &dr, bloom_image, 0, DISPMANX_PROTECTION_NONE, &alpha, 0/*clamp*/, DISPMANX_NO_ROTATE), win); } #else add_element(dispmanx_element_add(update, display, 0, &dr, &vc_image, 0, DISPMANX_PROTECTION_NONE, &alpha, 0/*clamp*/, flip_it(&vc_image) ? DISPMANX_FLIP_VERT : DISPMANX_NO_ROTATE), win); #endif } dispmanx_update_submit(update, our_callback, (void *)cb_arg); #endif }