Hello,<br><br>thank you for your work!<br><br><div class="gmail_quote">On Thu, Jul 22, 2010 at 4:26 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;">
<div class="im">Adds support for the D2D API on Win7/Vista SP2 with Platform Update<br>
Requires d2d1 contrib headers<br>
---<br>
</div><br><div><div class="h5">
+++ b/modules/video_output/msw/direct2d.c<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></div></div></blockquote><div><br>Could you make a more explicit error message? Or don't display the hresult in a msg_Err, but in a msg_Dbg.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div class="h5">
<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></div></div></blockquote><div>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?<br> <br>
Best regards,<br><br>Geoffroy<br></div></div>