/** * It creates a Direct3D device and the associated resources. */ static int Direct3DOpen(vout_display_t *vd, video_format_t *fmt) { vout_display_sys_t *sys = vd->sys; LPDIRECT3D9 d3dobj = sys->d3dobj; if (Direct3DFillPresentationParameters(vd)) return VLC_EGENERIC; // Create the D3DDevice LPDIRECT3DDEVICE9 d3ddev; UINT AdapterToUse = D3DADAPTER_DEFAULT; D3DDEVTYPE DeviceType = D3DDEVTYPE_HAL; #ifndef NDEBUG // Look for 'NVIDIA PerfHUD' adapter // If it is present, override default settings for (UINT Adapter=0; Adapter< IDirect3D9_GetAdapterCount(d3dobj); ++Adapter) { D3DADAPTER_IDENTIFIER9 Identifier; HRESULT Res; Res = IDirect3D9_GetAdapterIdentifier(d3dobj,Adapter,0,&Identifier); if (strstr(Identifier.Description,"PerfHUD") != 0) { AdapterToUse = Adapter; DeviceType = D3DDEVTYPE_REF; break; } } #endif HRESULT hr = IDirect3D9_CreateDevice(d3dobj, AdapterToUse, DeviceType, sys->hvideownd, D3DCREATE_SOFTWARE_VERTEXPROCESSING| D3DCREATE_MULTITHREADED, &sys->d3dpp, &d3ddev); if (FAILED(hr)) { msg_Err(vd, "Could not create the D3D device! (hr=0x%lX)", hr); return VLC_EGENERIC; } sys->d3ddev = d3ddev; UpdateRects(vd, NULL, NULL, true); if (Direct3DCreateResources(vd, fmt)) { msg_Err(vd, "Failed to allocate resources"); return VLC_EGENERIC; } /* Change the window title bar text */ EventThreadUpdateTitle(sys->event, VOUT_TITLE " (Direct3D output)"); msg_Dbg(vd, "Direct3D device adapter successfully initialized"); return VLC_SUCCESS; }
static int DirectXOpen(vout_display_t *vd, video_format_t *fmt) { vout_display_sys_t *sys = vd->sys; assert(!sys->ddobject); assert(!sys->display); assert(!sys->clipper); /* Initialise DirectDraw */ if (DirectXOpenDDraw(vd)) { msg_Err(vd, "cannot initialize DirectX DirectDraw"); return VLC_EGENERIC; } /* Create the directx display */ if (DirectXOpenDisplay(vd)) { msg_Err(vd, "cannot initialize DirectX DirectDraw"); return VLC_EGENERIC; } UpdateRects(vd, NULL, NULL, true); /* Create the picture pool */ if (DirectXCreatePool(vd, &sys->use_overlay, fmt)) { msg_Err(vd, "cannot create any DirectX surface"); return VLC_EGENERIC; } /* */ if (sys->use_overlay) DirectXUpdateOverlay(vd, NULL); EventThreadUseOverlay(sys->event, sys->use_overlay); /* Change the window title bar text */ const char *fallback; if (sys->use_overlay) fallback = VOUT_TITLE " (hardware YUV overlay DirectX output)"; else if (vlc_fourcc_IsYUV(fmt->i_chroma)) fallback = VOUT_TITLE " (hardware YUV DirectX output)"; else fallback = VOUT_TITLE " (software RGB DirectX output)"; EventThreadUpdateTitle(sys->event, fallback); return VLC_SUCCESS; }
/** * It creates an OpenGL vout display. */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; /* Allocate structure */ vd->sys = sys = calloc(1, sizeof(*sys)); if (!sys) return VLC_ENOMEM; /* */ if (CommonInit(vd)) goto error; EventThreadUpdateTitle(sys->event, VOUT_TITLE " (OpenGL output)"); /* */ sys->hGLDC = GetDC(sys->hvideownd); /* Set the pixel format for the DC */ PIXELFORMATDESCRIPTOR pfd; memset(&pfd, 0, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; SetPixelFormat(sys->hGLDC, ChoosePixelFormat(sys->hGLDC, &pfd), &pfd); /* Create and enable the render context */ sys->hGLRC = wglCreateContext(sys->hGLDC); wglMakeCurrent(sys->hGLDC, sys->hGLRC); const char *extensions = (const char*)glGetString(GL_EXTENSIONS); #ifdef WGL_EXT_swap_control if (HasExtension(extensions, "WGL_EXT_swap_control")) { PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); if (SwapIntervalEXT) SwapIntervalEXT(1); } #endif /* */ sys->gl.lock = NULL; sys->gl.unlock = NULL; sys->gl.swap = Swap; sys->gl.getProcAddress = OurGetProcAddress; sys->gl.sys = vd; video_format_t fmt = vd->fmt; const vlc_fourcc_t *subpicture_chromas; sys->vgl = vout_display_opengl_New(&fmt, &subpicture_chromas, &sys->gl); if (!sys->vgl) goto error; vout_display_info_t info = vd->info; info.has_double_click = true; info.has_hide_mouse = false; info.has_event_thread = true; info.subpicture_chromas = subpicture_chromas; /* Setup vout_display now that everything is fine */ vd->fmt = fmt; vd->info = info; vd->pool = Pool; vd->prepare = Prepare; vd->display = Display; vd->control = Control; vd->manage = Manage; return VLC_SUCCESS; error: Close(object); return VLC_EGENERIC; }
/** * Initialises Direct2D vout module */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; vd->sys = sys = calloc(1, sizeof(*sys)); if (!sys) return VLC_ENOMEM; sys->d2_render_target = NULL; sys->d2_dll = LoadLibrary(TEXT("D2D1.DLL")); if (!sys->d2_dll) { if (object->b_force) msg_Err(vd, "Cannot load D2D1.DLL, aborting"); goto error; } D2D1_FACTORY_OPTIONS fo = { D2D1_DEBUG_LEVEL_NONE }; HRESULT (WINAPI *D2D1CreateFactory)(D2D1_FACTORY_TYPE, REFIID, const D2D1_FACTORY_OPTIONS *, void **); D2D1CreateFactory = (void *)GetProcAddress(sys->d2_dll, "D2D1CreateFactory"); if (!D2D1CreateFactory) { msg_Err(vd, "Cannot locate reference to a D2D1CreateFactory ABI in D2D1.DLL"); goto error; } #ifndef NDEBUG msg_Dbg(vd, "D2D1.DLL loaded"); #endif HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, (REFIID)&IID_ID2D1Factory, &fo, (void **)&sys->d2_factory); if (hr != S_OK) { msg_Err(vd, "Cannot create Direct2D factory (hr = 0x%x)!", (unsigned)hr); goto error; } if (CommonInit(vd)) goto error; if (D2D_CreateRenderTarget(vd) != VLC_SUCCESS) goto error; vout_display_info_t info = vd->info; info.is_slow = false; info.has_double_click = true; info.has_hide_mouse = false; info.has_pictures_invalid = false; vd->info = info; vd->fmt.i_chroma = VLC_CODEC_RGB32; /* masks change this to BGR32 for ID2D1Bitmap */ vd->fmt.i_rmask = 0x0000ff00; vd->fmt.i_gmask = 0x00ff0000; vd->fmt.i_bmask = 0xff000000; vd->pool = Pool; vd->prepare = Prepare; vd->display = Display; vd->manage = Manage; vd->control = Control; EventThreadUpdateTitle(sys->event, VOUT_TITLE " (Direct2D output)"); #ifndef NDEBUG msg_Dbg(vd, "Ready"); #endif return VLC_SUCCESS; error: Close(VLC_OBJECT(vd)); return VLC_EGENERIC; }
static int Init(vout_display_t *vd, video_format_t *fmt, int width, int height) { vout_display_sys_t *sys = vd->sys; /* */ RECT *display = &sys->rect_display; display->left = 0; display->top = 0; #ifdef MODULE_NAME_IS_wingapi display->right = GXGetDisplayProperties().cxWidth; display->bottom = GXGetDisplayProperties().cyHeight; #else display->right = GetSystemMetrics(SM_CXSCREEN);; display->bottom = GetSystemMetrics(SM_CYSCREEN);; #endif /* Initialize an offscreen bitmap for direct buffer operations. */ /* */ HDC window_dc = GetDC(sys->hvideownd); /* */ #ifdef MODULE_NAME_IS_wingapi GXDisplayProperties gx_displayprop = GXGetDisplayProperties(); sys->i_depth = gx_displayprop.cBPP; #else sys->i_depth = GetDeviceCaps(window_dc, PLANES) * GetDeviceCaps(window_dc, BITSPIXEL); #endif /* */ msg_Dbg(vd, "GDI depth is %i", sys->i_depth); switch (sys->i_depth) { case 8: fmt->i_chroma = VLC_CODEC_RGB8; break; case 15: fmt->i_chroma = VLC_CODEC_RGB15; fmt->i_rmask = 0x7c00; fmt->i_gmask = 0x03e0; fmt->i_bmask = 0x001f; break; case 16: fmt->i_chroma = VLC_CODEC_RGB16; fmt->i_rmask = 0xf800; fmt->i_gmask = 0x07e0; fmt->i_bmask = 0x001f; break; case 24: fmt->i_chroma = VLC_CODEC_RGB24; fmt->i_rmask = 0x00ff0000; fmt->i_gmask = 0x0000ff00; fmt->i_bmask = 0x000000ff; break; case 32: fmt->i_chroma = VLC_CODEC_RGB32; fmt->i_rmask = 0x00ff0000; fmt->i_gmask = 0x0000ff00; fmt->i_bmask = 0x000000ff; break; default: msg_Err(vd, "screen depth %i not supported", sys->i_depth); return VLC_EGENERIC; } fmt->i_width = width; fmt->i_height = height; uint8_t *p_pic_buffer; int i_pic_pitch; #ifdef MODULE_NAME_IS_wingapi GXOpenDisplay(sys->hvideownd, GX_FULLSCREEN); EventThreadUpdateTitle(sys->event, VOUT_TITLE " (WinGAPI output)"); /* Filled by pool::lock() */ p_pic_buffer = NULL; i_pic_pitch = 0; #else /* Initialize offscreen bitmap */ BITMAPINFO *bi = &sys->bitmapinfo; memset(bi, 0, sizeof(BITMAPINFO) + 3 * sizeof(RGBQUAD)); if (sys->i_depth > 8) { ((DWORD*)bi->bmiColors)[0] = fmt->i_rmask; ((DWORD*)bi->bmiColors)[1] = fmt->i_gmask; ((DWORD*)bi->bmiColors)[2] = fmt->i_bmask;; } BITMAPINFOHEADER *bih = &sys->bitmapinfo.bmiHeader; bih->biSize = sizeof(BITMAPINFOHEADER); bih->biSizeImage = 0; bih->biPlanes = 1; bih->biCompression = (sys->i_depth == 15 || sys->i_depth == 16) ? BI_BITFIELDS : BI_RGB; bih->biBitCount = sys->i_depth; bih->biWidth = fmt->i_width; bih->biHeight = -fmt->i_height; bih->biClrImportant = 0; bih->biClrUsed = 0; bih->biXPelsPerMeter = 0; bih->biYPelsPerMeter = 0; i_pic_pitch = bih->biBitCount * bih->biWidth / 8; sys->off_bitmap = CreateDIBSection(window_dc, (BITMAPINFO *)bih, DIB_RGB_COLORS, &p_pic_buffer, NULL, 0); sys->off_dc = CreateCompatibleDC(window_dc); SelectObject(sys->off_dc, sys->off_bitmap); ReleaseDC(sys->hvideownd, window_dc); EventThreadUpdateTitle(sys->event, VOUT_TITLE " (WinGDI output)"); #endif /* */ picture_resource_t rsc; memset(&rsc, 0, sizeof(rsc)); #ifdef MODULE_NAME_IS_wingapi rsc.p_sys = malloc(sizeof(*rsc.p_sys)); if (!rsc.p_sys) return VLC_EGENERIC; rsc.p_sys->vd = vd; #endif rsc.p[0].p_pixels = p_pic_buffer; rsc.p[0].i_lines = fmt->i_height; rsc.p[0].i_pitch = i_pic_pitch;; picture_t *picture = picture_NewFromResource(fmt, &rsc); if (picture) { picture_pool_configuration_t cfg; memset(&cfg, 0, sizeof(cfg)); cfg.picture_count = 1; cfg.picture = &picture; #ifdef MODULE_NAME_IS_wingapi cfg.lock = Lock; cfg.unlock = Unlock; #endif sys->pool = picture_pool_NewExtended(&cfg); } else { free(rsc.p_sys); sys->pool = NULL; } UpdateRects(vd, NULL, NULL, true); return VLC_SUCCESS; }
static int Init(vout_display_t *vd, video_format_t *fmt) { vout_display_sys_t *sys = vd->sys; /* */ RECT *display = &sys->sys.rect_display; display->left = 0; display->top = 0; display->right = GetSystemMetrics(SM_CXSCREEN);; display->bottom = GetSystemMetrics(SM_CYSCREEN);; /* Initialize an offscreen bitmap for direct buffer operations. */ /* */ HDC window_dc = GetDC(sys->sys.hvideownd); /* */ sys->i_depth = GetDeviceCaps(window_dc, PLANES) * GetDeviceCaps(window_dc, BITSPIXEL); /* */ msg_Dbg(vd, "GDI depth is %i", sys->i_depth); switch (sys->i_depth) { case 8: fmt->i_chroma = VLC_CODEC_RGB8; break; case 15: fmt->i_chroma = VLC_CODEC_RGB15; fmt->i_rmask = 0x7c00; fmt->i_gmask = 0x03e0; fmt->i_bmask = 0x001f; break; case 16: fmt->i_chroma = VLC_CODEC_RGB16; fmt->i_rmask = 0xf800; fmt->i_gmask = 0x07e0; fmt->i_bmask = 0x001f; break; case 24: fmt->i_chroma = VLC_CODEC_RGB24; fmt->i_rmask = 0x00ff0000; fmt->i_gmask = 0x0000ff00; fmt->i_bmask = 0x000000ff; break; case 32: fmt->i_chroma = VLC_CODEC_RGB32; fmt->i_rmask = 0x00ff0000; fmt->i_gmask = 0x0000ff00; fmt->i_bmask = 0x000000ff; break; default: msg_Err(vd, "screen depth %i not supported", sys->i_depth); return VLC_EGENERIC; } void *p_pic_buffer; int i_pic_pitch; /* Initialize offscreen bitmap */ BITMAPINFO *bi = &sys->bitmapinfo; memset(bi, 0, sizeof(BITMAPINFO) + 3 * sizeof(RGBQUAD)); if (sys->i_depth > 8) { ((DWORD*)bi->bmiColors)[0] = fmt->i_rmask; ((DWORD*)bi->bmiColors)[1] = fmt->i_gmask; ((DWORD*)bi->bmiColors)[2] = fmt->i_bmask;; } BITMAPINFOHEADER *bih = &sys->bitmapinfo.bmiHeader; bih->biSize = sizeof(BITMAPINFOHEADER); bih->biSizeImage = 0; bih->biPlanes = 1; bih->biCompression = (sys->i_depth == 15 || sys->i_depth == 16) ? BI_BITFIELDS : BI_RGB; bih->biBitCount = sys->i_depth; bih->biWidth = fmt->i_width; bih->biHeight = -fmt->i_height; bih->biClrImportant = 0; bih->biClrUsed = 0; bih->biXPelsPerMeter = 0; bih->biYPelsPerMeter = 0; i_pic_pitch = bih->biBitCount * bih->biWidth / 8; sys->off_bitmap = CreateDIBSection(window_dc, (BITMAPINFO *)bih, DIB_RGB_COLORS, &p_pic_buffer, NULL, 0); sys->off_dc = CreateCompatibleDC(window_dc); SelectObject(sys->off_dc, sys->off_bitmap); ReleaseDC(sys->sys.hvideownd, window_dc); if (!sys->sys.b_windowless) EventThreadUpdateTitle(sys->sys.event, VOUT_TITLE " (WinGDI output)"); /* */ picture_resource_t rsc; memset(&rsc, 0, sizeof(rsc)); rsc.p[0].p_pixels = p_pic_buffer; rsc.p[0].i_lines = fmt->i_height; rsc.p[0].i_pitch = i_pic_pitch;; picture_t *picture = picture_NewFromResource(fmt, &rsc); if (picture != NULL) sys->sys.pool = picture_pool_New(1, &picture); else sys->sys.pool = NULL; UpdateRects(vd, true); return VLC_SUCCESS; }