[vlc-devel] [PATCH] Direct2D video output module

Geoffroy Couprie geo.couprie at gmail.com
Thu Jul 22 16:51:07 CEST 2010


Hello,

thank you for your work!

On Thu, Jul 22, 2010 at 4:26 PM, David Kaplan <david at 2of1.org> wrote:

> Adds support for the D2D API on Win7/Vista SP2 with Platform Update
> Requires d2d1 contrib headers
> ---
>
> +++ b/modules/video_output/msw/direct2d.c
>
> +    HRESULT hr = _D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
> +        (REFIID)&IID_ID2D1Factory, &fo, (void **)&sys->p_d2_factory);
> +    if (hr != S_OK) {
> +        if (object->b_force)
> +            msg_Err(vd, "Cannot create Direct2D factory (hr = 0x%x)!",
> +                (uint32_t)hr);
>

Could you make a more explicit error message? Or don't display the hresult
in a msg_Err, but in a msg_Dbg.


>
> +/**
> + * Creates a ID2D1HwndRenderTarget and associated ID2D1Bitmap
> + */
> +void D2D_CreateRenderTarget(vout_display_t *vd)
> +{
> +    vout_display_sys_t *sys = vd->sys;
> +
> +    D2D1_PIXEL_FORMAT pf = {
> +        DXGI_FORMAT_B8G8R8A8_UNORM,
> +        D2D1_ALPHA_MODE_IGNORE
> +    };
> +
> +    D2D1_RENDER_TARGET_PROPERTIES rtp = {
> +        D2D1_RENDER_TARGET_TYPE_DEFAULT,
> +        pf,
> +        0,
> +        0,
> +        D2D1_RENDER_TARGET_USAGE_NONE,
> +        D2D1_FEATURE_LEVEL_DEFAULT
> +    };
> +
> +    D2D1_SIZE_U size = {
> +        sys->rect_dest.right - sys->rect_dest.left,
> +        sys->rect_dest.bottom - sys->rect_dest.top
> +    };
> +
> +    D2D1_HWND_RENDER_TARGET_PROPERTIES hrtp = {
> +        sys->hvideownd,
> +        size,
> +        D2D1_PRESENT_OPTIONS_IMMEDIATELY /* this might need fiddling */
> +    };
> +
> +    HRESULT hr  = ID2D1Factory_CreateHwndRenderTarget(sys->p_d2_factory,
> +        &rtp, &hrtp, &sys->p_d2_render_target);
> +    if(hr != S_OK) {
> +        msg_Err(vd, "Cannot create render target (hvideownd = 0x%x, width
> = %d, height = %d, pf.format = %d, hr = 0x%x)!",
> +            (uint32_t)hrtp.hwnd, hrtp.pixelSize.width,
> hrtp.pixelSize.height,
> +            pf.format, (uint32_t)hr);
> +
> +        D2D_DestroyRenderTarget(vd);
> +    }
> +
> +    ID2D1Factory_GetDesktopDpi(sys->p_d2_factory, &sys->f_d2_dpi_x,
> +        &sys->f_d2_dpi_y);
> +
> +    D2D1_BITMAP_PROPERTIES bp = {
> +        pf,
> +        sys->f_d2_dpi_x,
> +        sys->f_d2_dpi_y
> +    };
> +
> +    D2D1_SIZE_U bitmap_size = {
> +        vd->fmt.i_width,
> +        vd->fmt.i_height
> +    };
> +
> +    hr = ID2D1HwndRenderTarget_CreateBitmap(sys->p_d2_render_target,
> +        bitmap_size, NULL, 0, &bp, &sys->p_d2_bitmap);
> +    if (hr != S_OK) {
> +        msg_Err(vd, "Failed to create bitmap (hr = 0x%x)!", (uint32_t)hr);
> +    }
> +
> +#ifndef NDEBUG
> +    msg_Dbg(vd, "Render trgt dbg: dpi = %f, render_target = %p, bitmap =
> %p",
> +        sys->f_d2_dpi_x, sys->p_d2_render_target, sys->p_d2_bitmap);
> +#endif
> +}
>
How is the calling function handling the case where a render target could
not be created? Is it crashing? Is it throwing an error because it can't
write to the render target?

Best regards,

Geoffroy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100722/f1416f73/attachment.html>


More information about the vlc-devel mailing list