<div dir="ltr">sorry - got some artifacts in <a href="http://configure.ac">configure.ac</a> - will resubmit<br><br><div class="gmail_quote">On Thu, Jul 22, 2010 at 5:16 PM, David Kaplan <span dir="ltr"><<a href="mailto:david@2of1.org">david@2of1.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Adds support for the D2D API on Win7/Vista SP2 with Platform Update<br>
Requires d2d1 contrib headers<br>
---<br>
 <a href="http://configure.ac" target="_blank">configure.ac</a>                        |   27 ++-<br>
 modules/video_output/msw/Modules.am |    8 +<br>
 modules/video_output/msw/common.c   |    9 +-<br>
 modules/video_output/msw/common.h   |    9 +<br>
 modules/video_output/msw/direct2d.c |  399 +++++++++++++++++++++++++++++++++++<br>
 modules/video_output/msw/events.c   |    3 +<br>
 6 files changed, 447 insertions(+), 8 deletions(-)<br>
 create mode 100644 modules/video_output/msw/direct2d.c<br>
<br>
diff --git a/<a href="http://configure.ac" target="_blank">configure.ac</a> b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
index 8a8701e..45aaf30 100644<br>
--- a/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
@@ -876,7 +876,7 @@ AC_ARG_VAR(PKG_CONFIG_PATH,<br>
           [Paths where to find .pc not at the default location])<br>
 PKG_PROG_PKG_CONFIG()<br>
<br>
-dnl On some OS we need static linking<br>
+dnl On some OS we need static linking<br>
        AS_IF([test -n "${PKG_CONFIG}" ],[<br>
              AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce" -o "${SYS}" = "darwin" ],[<br>
                  PKG_CONFIG="${PKG_CONFIG} --static"<br>
@@ -886,14 +886,14 @@ dnl On some OS we need static linking<br>
<br>
 dnl<br>
 dnl Check for zlib.h and -lz along with system -lminizip if available<br>
-dnl<br>
+dnl<br>
 AC_CHECK_HEADERS(zlib.h, [ have_zlib=yes ], [ have_zlib=no ])<br>
 AM_CONDITIONAL(HAVE_ZLIB, [ test "${have_zlib}" = "yes" ])<br>
 if test "${have_zlib}" = "yes"<br>
 then<br>
   VLC_ADD_LIBS([access_http gme mp4 skins2 sap mkv unzip zip],[-lz])<br>
   PKG_CHECK_MODULES([MINIZIP], [minizip] , [ have_minizip=yes ], [<br>
-    AC_CHECK_HEADERS([unzip.h], [<br>
+    AC_CHECK_HEADERS([unzip.h], [<br>
       have_minizip=yes<br>
       MINIZIP_LIBS="-lminizip -lz"<br>
     ], [<br>
@@ -1841,7 +1841,7 @@ lternatively you can use --disable-live555 to disable the liveMedia plugin.])<br>
         AC_MSG_RESULT(no)<br>
       if test "${enable_live555}" = "yes"; then<br>
         AC_MSG_ERROR([cannot find ${real_live555_tree}/liveMedia/libliveMedia.a, make sure you compiled live555 in ${with_live555_tree}])<br>
-      fi<br>
+      fi<br>
     fi<br>
   fi<br>
 fi<br>
@@ -2697,7 +2697,7 @@ AC_ARG_ENABLE(dxva2,<br>
 AS_IF([test "${enable_dxva2}" != "no"], [<br>
   if test "${SYS}" = "mingw32"; then<br>
   AS_IF([test "x${have_avcodec}" = "xyes"], [<br>
-    AC_CHECK_HEADERS(dxva2api.h,<br>
+    AC_CHECK_HEADERS(dxva2api.h,<br>
       [<br>
         AC_CHECK_HEADERS(libavcodec/dxva2.h, [<br>
            VLC_ADD_LIBS([avcodec],[-lole32 -lshlwapi -luuid])<br>
@@ -3458,6 +3458,23 @@ then<br>
 fi<br>
<br>
 dnl<br>
+dnl  Windows Direct2D plugin<br>
+dnl<br>
+AC_ARG_ENABLE(direct2d,<br>
+  [  --enable-direct2d         Win32 Direct2D support (default enabled on Win32)])<br>
+if test "${enable_direct2d}" != "no"; then<br>
+  if test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"<br>
+  then<br>
+    AC_CHECK_HEADERS(d2d1.h,<br>
+      [<br>
+        VLC_ADD_PLUGIN([direct2d])<br>
+        VLC_ADD_LIBS([direct2d],[-lgdi32 -lole32])<br>
+      ], [AC_MSG_ERROR([Cannot find Direct2D headers!])]<br>
+    )<br>
+  fi<br>
+fi<br>
+<br>
+dnl<br>
 dnl  Windows DirectX module<br>
 dnl<br>
<br>
diff --git a/modules/video_output/msw/Modules.am b/modules/video_output/msw/Modules.am<br>
index 51807c8..0613bae 100644<br>
--- a/modules/video_output/msw/Modules.am<br>
+++ b/modules/video_output/msw/Modules.am<br>
@@ -1,3 +1,11 @@<br>
+SOURCES_direct2d = \<br>
+        direct2d.c \<br>
+        common.h \<br>
+        events.h \<br>
+        events.c \<br>
+        common.c \<br>
+        $(NULL)<br>
+<br>
 SOURCES_directx = \<br>
        directx.c \<br>
        common.h \<br>
diff --git a/modules/video_output/msw/common.c b/modules/video_output/msw/common.c<br>
index 5704d5c..fddbd3d 100644<br>
--- a/modules/video_output/msw/common.c<br>
+++ b/modules/video_output/msw/common.c<br>
@@ -48,6 +48,9 @@<br>
 #ifdef MODULE_NAME_IS_glwin32<br>
 #include "../opengl.h"<br>
 #endif<br>
+#ifdef MODULE_NAME_IS_direct2d<br>
+#include <d2d1.h><br>
+#endif<br>
<br>
 #include "common.h"<br>
<br>
@@ -379,7 +382,7 @@ void UpdateRects(vout_display_t *vd,<br>
                      SWP_NOCOPYBITS|SWP_NOZORDER|SWP_ASYNCWINDOWPOS);<br>
<br>
     /* Destination image position and dimensions */<br>
-#if defined(MODULE_NAME_IS_direct3d)<br>
+#if defined(MODULE_NAME_IS_direct3d) || defined(MODULE_NAME_IS_direct2d)<br>
     rect_dest.left   = 0;<br>
     rect_dest.right  = place.width;<br>
     rect_dest.top    = 0;<br>
@@ -398,7 +401,7 @@ void UpdateRects(vout_display_t *vd,<br>
<br>
 #endif<br>
<br>
-#if defined(MODULE_NAME_IS_directx) || defined(MODULE_NAME_IS_direct3d)<br>
+#if defined(MODULE_NAME_IS_directx) || defined(MODULE_NAME_IS_direct3d) || defined(MODULE_NAME_IS_direct2d)<br>
     /* UpdateOverlay directdraw function doesn't automatically clip to the<br>
      * display size so we need to do it otherwise it will fail<br>
      * It is also needed for d3d to avoid exceding our surface size */<br>
@@ -457,7 +460,7 @@ void UpdateRects(vout_display_t *vd,<br>
     /* Apply overlay hardware constraints */<br>
     if (sys->use_overlay)<br>
         AlignRect(&rect_src_clipped, sys->i_align_src_boundary, sys->i_align_src_size);<br>
-#elif defined(MODULE_NAME_IS_direct3d)<br>
+#elif defined(MODULE_NAME_IS_direct3d) || defined(MODULE_NAME_IS_direct2d)<br>
     /* Needed at least with YUV content */<br>
     rect_src_clipped.left &= ~1;<br>
     rect_src_clipped.right &= ~1;<br>
diff --git a/modules/video_output/msw/common.h b/modules/video_output/msw/common.h<br>
index e023ef4..db6a2d8 100644<br>
--- a/modules/video_output/msw/common.h<br>
+++ b/modules/video_output/msw/common.h<br>
@@ -157,6 +157,15 @@ struct vout_display_sys_t<br>
     vout_display_opengl_t vgl;<br>
 #endif<br>
<br>
+#ifdef MODULE_NAME_IS_direct2d<br>
+    HINSTANCE              h_d2_dll;            /* handle of the opened d3d9 dll */<br>
+    FLOAT                  f_d2_dpi_x;                                  /* DPI x */<br>
+    FLOAT                  f_d2_dpi_y;                                  /* DPI y */<br>
+    ID2D1Factory           *p_d2_factory;                         /* D2D factory */<br>
+    ID2D1HwndRenderTarget  *p_d2_render_target;          /* D2D rendering target */<br>
+    ID2D1Bitmap            *p_d2_bitmap;                            /* D2 bitmap */<br>
+#endif<br>
+<br>
 #ifdef MODULE_NAME_IS_direct3d<br>
     bool allow_hw_yuv;    /* Should we use hardware YUV->RGB conversions */<br>
     /* show video on desktop window ? */<br>
diff --git a/modules/video_output/msw/direct2d.c b/modules/video_output/msw/direct2d.c<br>
new file mode 100644<br>
index 0000000..c04cdf6<br>
--- /dev/null<br>
+++ b/modules/video_output/msw/direct2d.c<br>
@@ -0,0 +1,399 @@<br>
+/*****************************************************************************<br>
+ * direct2d.c : Direct2D video output plugin for vlc (Win7/Vista SP2 PF update)<br>
+ *****************************************************************************<br>
+ * Copyright (C) 2010 VideoLAN and AUTHORS<br>
+ * $Id$<br>
+ *<br>
+ * Author: David Kaplan <<a href="mailto:david@2of1.org">david@2of1.org</a>><br>
+ *<br>
+ * This program is free software; you can redistribute it and/or modify<br>
+ * it under the terms of the GNU General Public License as published by<br>
+ * the Free Software Foundation; either version 2 of the License, or<br>
+ * (at your option) any later version.<br>
+ *<br>
+ * This program is distributed in the hope that it will be useful,<br>
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>
+ * GNU General Public License for more details.<br>
+ *<br>
+ * You should have received a copy of the GNU General Public License<br>
+ * along with this program; if not, write to the Free Software<br>
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br>
+ *****************************************************************************/<br>
+<br>
+/*****************************************************************************<br>
+ * Preamble<br>
+ *****************************************************************************/<br>
+<br>
+#ifdef HAVE_CONFIG_H<br>
+# include "config.h"<br>
+#endif<br>
+#include <assert.h><br>
+<br>
+#include <vlc_common.h><br>
+#include <vlc_plugin.h><br>
+#include <vlc_playlist.h><br>
+#include <vlc_vout_display.h><br>
+<br>
+#include <windows.h><br>
+#include <commctrl.h><br>
+<br>
+#include <d2d1.h><br>
+<br>
+#include "common.h"<br>
+<br>
+#include <initguid.h><br>
+#undef GUID_EXT<br>
+#define GUID_EXT<br>
+DEFINE_GUID(IID_ID2D1Factory, 102048327, 28496, 18010, 146, 69, 17, 139, 253, 59, 96, 7);<br>
+<br>
+#ifndef WS_NONAVDONEBUTTON<br>
+#   define WS_NONAVDONEBUTTON 0<br>
+#endif<br>
+<br>
+/*****************************************************************************<br>
+ * Module descriptor<br>
+ *****************************************************************************/<br>
+static int  Open (vlc_object_t *);<br>
+static void Close(vlc_object_t *);<br>
+<br>
+#define D2D_HELP N_("Video output for Windows 7/Windows Vista with Platform update")<br>
+<br>
+vlc_module_begin ()<br>
+    set_category(CAT_VIDEO)<br>
+    set_subcategory(SUBCAT_VIDEO_VOUT)<br>
+    set_help(D2D_HELP)<br>
+    set_shortname("Direct2D")<br>
+    set_description(N_("Direct2D video output"))<br>
+    set_capability("vout display", 10)<br>
+    add_shortcut("direct2d")<br>
+    set_callbacks(Open, Close)<br>
+vlc_module_end ()<br>
+<br>
+<br>
+/*****************************************************************************<br>
+ * Local prototypes<br>
+ *****************************************************************************/<br>
+static picture_pool_t *Pool  (vout_display_t *, unsigned);<br>
+static void           Prepare(vout_display_t *, picture_t *);<br>
+static void           Display(vout_display_t *, picture_t *);<br>
+static int            Control(vout_display_t *, int, va_list);<br>
+static void           Manage (vout_display_t *);<br>
+<br>
+void D2D_CreateRenderTarget(vout_display_t *vd);<br>
+void D2D_ResizeRenderTarget(vout_display_t *vd);<br>
+void D2D_DestroyRenderTarget(vout_display_t *vd);<br>
+<br>
+/**<br>
+ * Initialises Direct2D vout module<br>
+ */<br>
+static int Open(vlc_object_t *object)<br>
+{<br>
+    vout_display_t *vd = (vout_display_t *)object;<br>
+    vout_display_sys_t *sys;<br>
+<br>
+    vd->sys = sys = calloc(1, sizeof(*sys));<br>
+    if (!sys)<br>
+        return VLC_ENOMEM;<br>
+<br>
+    if (CommonInit(vd))<br>
+        goto error;<br>
+<br>
+    sys->h_d2_dll = LoadLibrary(TEXT("D2D1.DLL"));<br>
+    if (!sys->h_d2_dll) {<br>
+        if (object->b_force)<br>
+            msg_Err(vd, "Cannot load D2D1.DLL, aborting");<br>
+        goto error;<br>
+    }<br>
+<br>
+    D2D1_FACTORY_OPTIONS fo = {<br>
+        D2D1_DEBUG_LEVEL_NONE<br>
+    };<br>
+<br>
+    HRESULT (WINAPI *_D2D1CreateFactory)( D2D1_FACTORY_TYPE, REFIID,<br>
+        const D2D1_FACTORY_OPTIONS *, void ** );<br>
+<br>
+    _D2D1CreateFactory = (void *)GetProcAddress(sys->h_d2_dll,<br>
+        TEXT("D2D1CreateFactory"));<br>
+    if (!_D2D1CreateFactory) {<br>
+        if (object->b_force)<br>
+            msg_Err(vd,<br>
+                "Cannot locate reference to a D2D1CreateFactory ABI in D2D1.DLL");<br>
+        goto error;<br>
+    }<br>
+<br>
+#ifndef NDEBUG<br>
+    msg_Dbg(vd, "D2D1.DLL loaded");<br>
+#endif<br>
+<br>
+    HRESULT hr = _D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,<br>
+        (REFIID)&IID_ID2D1Factory, &fo, (void **)&sys->p_d2_factory);<br>
+    if (hr != S_OK) {<br>
+        if (object->b_force)<br>
+            msg_Err(vd, "Cannot create Direct2D factory (hr = 0x%x)!",<br>
+                (uint32_t)hr);<br>
+        goto error;<br>
+    }<br>
+<br>
+    sys->p_d2_render_target = NULL;<br>
+    D2D_CreateRenderTarget(vd);<br>
+<br>
+    vout_display_info_t info = vd->info;<br>
+    info.is_slow              = false;<br>
+    info.has_double_click     = true;<br>
+    info.has_hide_mouse       = true;<br>
+    info.has_pictures_invalid = true;<br>
+    vd->info = info;<br>
+<br>
+    RECT rc;<br>
+    GetClientRect(sys->hvideownd, &rc);<br>
+    D2D1_SIZE_U size = {<br>
+        rc.right - rc.left,<br>
+        rc.bottom - rc.top<br>
+    };<br>
+<br>
+    vd->fmt.i_chroma = VLC_CODEC_RGB32; /* masks change this to BGR32 for ID2D1Bitmap */<br>
+    vd->fmt.i_rmask  = 0x000000ff;<br>
+    vd->fmt.i_gmask  = 0x0000ff00;<br>
+    vd->fmt.i_bmask  = 0x00000000; /* todo - fix this (should be 0x00ff0000) */<br>
+    vd->fmt.i_width  = size.width;<br>
+    vd->fmt.i_height = size.height;<br>
+<br>
+    vd->pool    = Pool;<br>
+    vd->prepare = Prepare;<br>
+    vd->display = Display;<br>
+    vd->manage  = Manage;<br>
+    vd->control = Control;<br>
+<br>
+    EventThreadUpdateTitle(sys->event, VOUT_TITLE " (Direct2D output)");<br>
+<br>
+#ifndef NDEBUG<br>
+    msg_Dbg(vd, "Ready");<br>
+#endif<br>
+<br>
+    return VLC_SUCCESS;<br>
+<br>
+error:<br>
+    Close(VLC_OBJECT(vd));<br>
+    return VLC_EGENERIC;<br>
+}<br>
+<br>
+/**<br>
+ * Close Direct2D vout<br>
+ */<br>
+static void Close(vlc_object_t *object)<br>
+{<br>
+    vout_display_t *vd = (vout_display_t *)object;<br>
+<br>
+    D2D_DestroyRenderTarget(vd);<br>
+<br>
+    if (vd->sys->pool)<br>
+        picture_pool_Delete(vd->sys->pool);<br>
+<br>
+    CommonClean(vd);<br>
+<br>
+    free(vd->sys);<br>
+}<br>
+<br>
+/**<br>
+ * Handles pool allocations for bitmaps<br>
+ */<br>
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count)<br>
+{<br>
+    vout_display_sys_t *sys = vd->sys;<br>
+<br>
+    if (!sys->pool) {<br>
+        sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);<br>
+#ifndef NDEBUG<br>
+        msg_Dbg(vd, "New picture pool created");<br>
+#endif<br>
+    }<br>
+<br>
+    return sys->pool;<br>
+}<br>
+<br>
+/**<br>
+ * Performs set up of ID2D1Bitmap memory ready for blitting<br>
+ */<br>
+static void Prepare(vout_display_t *vd, picture_t *picture)<br>
+{<br>
+    vout_display_sys_t *sys = vd->sys;<br>
+<br>
+    if (sys->p_d2_render_target && sys->p_d2_bitmap)<br>
+    {<br>
+        UINT32 pitch = vd->fmt.i_width * 4;<br>
+<br>
+        HRESULT hr = ID2D1Bitmap_CopyFromMemory(sys->p_d2_bitmap, NULL,<br>
+            picture->p[0].p_pixels, pitch);<br>
+        if( hr != S_OK )<br>
+            msg_Err(vd, "Failed to copy bitmap memory (hr = 0x%x)!",<br>
+                (uint32_t)hr);<br>
+<br>
+#ifndef NDEBUG<br>
+        /*msg_Dbg(vd, "Bitmap dbg: target = %p, pitch = %d, bitmap = %p",<br>
+            sys->p_d2_render_target, pitch, sys->p_d2_bitmap);*/<br>
+#endif<br>
+    }<br>
+}<br>
+<br>
+/**<br>
+ * Blits a scaled picture_t to the render target<br>
+ */<br>
+static void Display(vout_display_t *vd, picture_t *picture)<br>
+{<br>
+    vout_display_sys_t *sys = vd->sys;<br>
+<br>
+    D2D1_RECT_F rc = {<br>
+        sys->rect_dest.left,<br>
+        sys->rect_dest.top,<br>
+        sys->rect_dest.right,<br>
+        sys->rect_dest.bottom<br>
+    };<br>
+<br>
+    if (sys->p_d2_render_target && sys->p_d2_bitmap) {<br>
+        ID2D1HwndRenderTarget_BeginDraw(sys->p_d2_render_target);<br>
+        ID2D1HwndRenderTarget_DrawBitmap(sys->p_d2_render_target,<br>
+            sys->p_d2_bitmap, &rc, 1.0f,<br>
+            D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, NULL);<br>
+        ID2D1HwndRenderTarget_EndDraw(sys->p_d2_render_target, NULL, NULL);<br>
+    }<br>
+<br>
+    picture_Release(picture);<br>
+<br>
+    CommonDisplay(vd);<br>
+}<br>
+<br>
+ /**<br>
+  * Control event handler<br>
+  */<br>
+static int Control(vout_display_t *vd, int query, va_list args)<br>
+{<br>
+    return CommonControl(vd, query, args);<br>
+}<br>
+<br>
+/**<br>
+ * Handles surface management<br>
+ * ID2D1RenderTargets cannot be resized and must be recreated<br>
+ */<br>
+static void Manage(vout_display_t *vd)<br>
+{<br>
+    vout_display_sys_t *sys = vd->sys;<br>
+<br>
+    CommonManage(vd);<br>
+<br>
+    if (sys->changes & DX_POSITION_CHANGE) {<br>
+        D2D_ResizeRenderTarget(vd);<br>
+        sys->changes &= ~DX_POSITION_CHANGE;<br>
+    }<br>
+}<br>
+<br>
+/**<br>
+ * Resizes a ID2D1HWndRenderTarget<br>
+ */<br>
+void D2D_ResizeRenderTarget(vout_display_t *vd)<br>
+{<br>
+    vout_display_sys_t *sys = vd->sys;<br>
+<br>
+    D2D1_SIZE_U size = {<br>
+        sys->rect_dest.right - sys->rect_dest.left,<br>
+        sys->rect_dest.bottom - sys->rect_dest.top<br>
+    };<br>
+<br>
+    HRESULT hr  = ID2D1HwndRenderTarget_Resize(sys->p_d2_render_target, &size);<br>
+    if(hr != S_OK) {<br>
+        msg_Err(vd, "Cannot resize render target (width = %d, height = %d, hr = 0x%x)!",<br>
+            size.width, size.height, (uint32_t)hr);<br>
+<br>
+        D2D_DestroyRenderTarget(vd);<br>
+    }<br>
+}<br>
+<br>
+/**<br>
+ * Creates a ID2D1HwndRenderTarget and associated ID2D1Bitmap<br>
+ */<br>
+void D2D_CreateRenderTarget(vout_display_t *vd)<br>
+{<br>
+    vout_display_sys_t *sys = vd->sys;<br>
+<br>
+    D2D1_PIXEL_FORMAT pf = {<br>
+        DXGI_FORMAT_B8G8R8A8_UNORM,<br>
+        D2D1_ALPHA_MODE_IGNORE<br>
+    };<br>
+<br>
+    D2D1_RENDER_TARGET_PROPERTIES rtp = {<br>
+        D2D1_RENDER_TARGET_TYPE_DEFAULT,<br>
+        pf,<br>
+        0,<br>
+        0,<br>
+        D2D1_RENDER_TARGET_USAGE_NONE,<br>
+        D2D1_FEATURE_LEVEL_DEFAULT<br>
+    };<br>
+<br>
+    D2D1_SIZE_U size = {<br>
+        sys->rect_dest.right - sys->rect_dest.left,<br>
+        sys->rect_dest.bottom - sys->rect_dest.top<br>
+    };<br>
+<br>
+    D2D1_HWND_RENDER_TARGET_PROPERTIES hrtp = {<br>
+        sys->hvideownd,<br>
+        size,<br>
+        D2D1_PRESENT_OPTIONS_IMMEDIATELY /* this might need fiddling */<br>
+    };<br>
+<br>
+    HRESULT hr  = ID2D1Factory_CreateHwndRenderTarget(sys->p_d2_factory,<br>
+        &rtp, &hrtp, &sys->p_d2_render_target);<br>
+    if(hr != S_OK) {<br>
+        msg_Err(vd, "Cannot create render target (hvideownd = 0x%x, width = %d, height = %d, pf.format = %d, hr = 0x%x)!",<br>
+            (uint32_t)hrtp.hwnd, hrtp.pixelSize.width, hrtp.pixelSize.height,<br>
+            pf.format, (uint32_t)hr);<br>
+<br>
+        D2D_DestroyRenderTarget(vd);<br>
+    }<br>
+<br>
+    ID2D1Factory_GetDesktopDpi(sys->p_d2_factory, &sys->f_d2_dpi_x,<br>
+        &sys->f_d2_dpi_y);<br>
+<br>
+    D2D1_BITMAP_PROPERTIES bp = {<br>
+        pf,<br>
+        sys->f_d2_dpi_x,<br>
+        sys->f_d2_dpi_y<br>
+    };<br>
+<br>
+    D2D1_SIZE_U bitmap_size = {<br>
+        vd->fmt.i_width,<br>
+        vd->fmt.i_height<br>
+    };<br>
+<br>
+    hr = ID2D1HwndRenderTarget_CreateBitmap(sys->p_d2_render_target,<br>
+        bitmap_size, NULL, 0, &bp, &sys->p_d2_bitmap);<br>
+    if (hr != S_OK) {<br>
+        msg_Err(vd, "Failed to create bitmap (hr = 0x%x)!", (uint32_t)hr);<br>
+    }<br>
+<br>
+#ifndef NDEBUG<br>
+    msg_Dbg(vd, "Render trgt dbg: dpi = %f, render_target = %p, bitmap = %p",<br>
+        sys->f_d2_dpi_x, sys->p_d2_render_target, sys->p_d2_bitmap);<br>
+#endif<br>
+}<br>
+<br>
+/**<br>
+ * Cleans up ID2D1HwndRenderTarget and ID2D1Bitmap<br>
+ */<br>
+void D2D_DestroyRenderTarget(vout_display_t *vd)<br>
+{<br>
+    vout_display_sys_t *sys = vd->sys;<br>
+<br>
+    if(sys->p_d2_render_target) {<br>
+        ID2D1HwndRenderTarget_Release(sys->p_d2_render_target);<br>
+        sys->p_d2_render_target = NULL;<br>
+    }<br>
+<br>
+    if (sys->p_d2_bitmap) {<br>
+        ID2D1Bitmap_Release(sys->p_d2_bitmap);<br>
+        sys->p_d2_bitmap = NULL;<br>
+    }<br>
+<br>
+#ifndef NDEBUG<br>
+    msg_Dbg(vd, "Destroyed");<br>
+#endif<br>
+}<br>
diff --git a/modules/video_output/msw/events.c b/modules/video_output/msw/events.c<br>
index d2d5e26..46c15c4 100644<br>
--- a/modules/video_output/msw/events.c<br>
+++ b/modules/video_output/msw/events.c<br>
@@ -49,6 +49,9 @@<br>
 #ifdef MODULE_NAME_IS_glwin32<br>
 #include "../opengl.h"<br>
 #endif<br>
+#ifdef MODULE_NAME_IS_direct2d<br>
+#include <d2d1.h><br>
+#endif<br>
<br>
 #include <vlc_keys.h><br>
 #include "common.h"<br>
<font color="#888888">--<br>
1.7.0.4<br>
<br>
</font></blockquote></div><br></div>