2 * Video Mixing Renderer for dx9
4 * Copyright 2004 Christian Costa
5 * Copyright 2008 Maarten Lankhorst
6 * Copyright 2012 Aric Stewart
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "quartz_private.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
48 BaseRenderer renderer
;
49 BaseControlWindow baseControlWindow
;
50 BaseControlVideo baseControlVideo
;
52 IUnknown IUnknown_inner
;
53 IAMCertifiedOutputProtection IAMCertifiedOutputProtection_iface
;
54 IAMFilterMiscFlags IAMFilterMiscFlags_iface
;
55 IVMRFilterConfig IVMRFilterConfig_iface
;
56 IVMRFilterConfig9 IVMRFilterConfig9_iface
;
57 IVMRMonitorConfig IVMRMonitorConfig_iface
;
58 IVMRMonitorConfig9 IVMRMonitorConfig9_iface
;
59 IVMRSurfaceAllocatorNotify IVMRSurfaceAllocatorNotify_iface
;
60 IVMRSurfaceAllocatorNotify9 IVMRSurfaceAllocatorNotify9_iface
;
61 IVMRWindowlessControl IVMRWindowlessControl_iface
;
62 IVMRWindowlessControl9 IVMRWindowlessControl9_iface
;
64 IVMRSurfaceAllocatorEx9
*allocator
;
65 IVMRImagePresenter9
*presenter
;
69 * The Video Mixing Renderer supports 3 modes, renderless, windowless and windowed
70 * What I do is implement windowless as a special case of renderless, and then
71 * windowed also as a special case of windowless. This is probably the easiest way.
74 BITMAPINFOHEADER bmiheader
;
81 /* Presentation related members */
82 IDirect3DDevice9
*allocator_d3d9_dev
;
83 HMONITOR allocator_mon
;
88 /* for Windowless Mode */
89 HWND hWndClippingWindow
;
97 static inline struct quartz_vmr
*impl_from_inner_IUnknown(IUnknown
*iface
)
99 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IUnknown_inner
);
102 static inline struct quartz_vmr
*impl_from_BaseWindow(BaseWindow
*wnd
)
104 return CONTAINING_RECORD(wnd
, struct quartz_vmr
, baseControlWindow
.baseWindow
);
107 static inline struct quartz_vmr
*impl_from_IVideoWindow(IVideoWindow
*iface
)
109 return CONTAINING_RECORD(iface
, struct quartz_vmr
, baseControlWindow
.IVideoWindow_iface
);
112 static inline struct quartz_vmr
*impl_from_BaseControlVideo(BaseControlVideo
*cvid
)
114 return CONTAINING_RECORD(cvid
, struct quartz_vmr
, baseControlVideo
);
117 static inline struct quartz_vmr
*impl_from_IBasicVideo(IBasicVideo
*iface
)
119 return CONTAINING_RECORD(iface
, struct quartz_vmr
, baseControlVideo
.IBasicVideo_iface
);
122 static inline struct quartz_vmr
*impl_from_IAMCertifiedOutputProtection(IAMCertifiedOutputProtection
*iface
)
124 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IAMCertifiedOutputProtection_iface
);
127 static inline struct quartz_vmr
*impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags
*iface
)
129 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IAMFilterMiscFlags_iface
);
132 static inline struct quartz_vmr
*impl_from_IVMRFilterConfig(IVMRFilterConfig
*iface
)
134 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRFilterConfig_iface
);
137 static inline struct quartz_vmr
*impl_from_IVMRFilterConfig9(IVMRFilterConfig9
*iface
)
139 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRFilterConfig9_iface
);
142 static inline struct quartz_vmr
*impl_from_IVMRMonitorConfig(IVMRMonitorConfig
*iface
)
144 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRMonitorConfig_iface
);
147 static inline struct quartz_vmr
*impl_from_IVMRMonitorConfig9(IVMRMonitorConfig9
*iface
)
149 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRMonitorConfig9_iface
);
152 static inline struct quartz_vmr
*impl_from_IVMRSurfaceAllocatorNotify(IVMRSurfaceAllocatorNotify
*iface
)
154 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRSurfaceAllocatorNotify_iface
);
157 static inline struct quartz_vmr
*impl_from_IVMRSurfaceAllocatorNotify9(IVMRSurfaceAllocatorNotify9
*iface
)
159 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRSurfaceAllocatorNotify9_iface
);
162 static inline struct quartz_vmr
*impl_from_IVMRWindowlessControl(IVMRWindowlessControl
*iface
)
164 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRWindowlessControl_iface
);
167 static inline struct quartz_vmr
*impl_from_IVMRWindowlessControl9(IVMRWindowlessControl9
*iface
)
169 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRWindowlessControl9_iface
);
174 IVMRImagePresenter9 IVMRImagePresenter9_iface
;
175 IVMRSurfaceAllocatorEx9 IVMRSurfaceAllocatorEx9_iface
;
183 IDirect3DDevice9
*d3d9_dev
;
184 IDirect3D9
*d3d9_ptr
;
185 IDirect3DSurface9
**d3d9_surfaces
;
186 IDirect3DVertexBuffer9
*d3d9_vertex
;
191 VMR9AllocationInfo info
;
193 struct quartz_vmr
* pVMR9
;
194 IVMRSurfaceAllocatorNotify9
*SurfaceAllocatorNotify
;
195 } VMR9DefaultAllocatorPresenterImpl
;
197 static inline VMR9DefaultAllocatorPresenterImpl
*impl_from_IVMRImagePresenter9( IVMRImagePresenter9
*iface
)
199 return CONTAINING_RECORD(iface
, VMR9DefaultAllocatorPresenterImpl
, IVMRImagePresenter9_iface
);
202 static inline VMR9DefaultAllocatorPresenterImpl
*impl_from_IVMRSurfaceAllocatorEx9( IVMRSurfaceAllocatorEx9
*iface
)
204 return CONTAINING_RECORD(iface
, VMR9DefaultAllocatorPresenterImpl
, IVMRSurfaceAllocatorEx9_iface
);
207 static HRESULT
VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr
*parent
, LPVOID
* ppv
);
209 static DWORD
VMR9_SendSampleData(struct quartz_vmr
*This
, VMR9PresentationInfo
*info
, LPBYTE data
,
216 BITMAPINFOHEADER
*bmiHeader
;
219 TRACE("%p %p %d\n", This
, data
, size
);
221 amt
= &This
->renderer
.pInputPin
->pin
.mtCurrent
;
223 if (IsEqualIID(&amt
->formattype
, &FORMAT_VideoInfo
))
225 bmiHeader
= &((VIDEOINFOHEADER
*)amt
->pbFormat
)->bmiHeader
;
227 else if (IsEqualIID(&amt
->formattype
, &FORMAT_VideoInfo2
))
229 bmiHeader
= &((VIDEOINFOHEADER2
*)amt
->pbFormat
)->bmiHeader
;
233 FIXME("Unknown type %s\n", debugstr_guid(&amt
->subtype
));
234 return VFW_E_RUNTIME_ERROR
;
237 TRACE("biSize = %d\n", bmiHeader
->biSize
);
238 TRACE("biWidth = %d\n", bmiHeader
->biWidth
);
239 TRACE("biHeight = %d\n", bmiHeader
->biHeight
);
240 TRACE("biPlanes = %d\n", bmiHeader
->biPlanes
);
241 TRACE("biBitCount = %d\n", bmiHeader
->biBitCount
);
242 TRACE("biCompression = %s\n", debugstr_an((LPSTR
)&(bmiHeader
->biCompression
), 4));
243 TRACE("biSizeImage = %d\n", bmiHeader
->biSizeImage
);
245 width
= bmiHeader
->biWidth
;
246 height
= bmiHeader
->biHeight
;
248 TRACE("Src Rect: %d %d %d %d\n", This
->source_rect
.left
, This
->source_rect
.top
, This
->source_rect
.right
, This
->source_rect
.bottom
);
249 TRACE("Dst Rect: %d %d %d %d\n", This
->target_rect
.left
, This
->target_rect
.top
, This
->target_rect
.right
, This
->target_rect
.bottom
);
251 hr
= IDirect3DSurface9_LockRect(info
->lpSurf
, &lock
, NULL
, D3DLOCK_DISCARD
);
254 ERR("IDirect3DSurface9_LockRect failed (%x)\n",hr
);
258 if (lock
.Pitch
!= width
* bmiHeader
->biBitCount
/ 8)
260 WARN("Slow path! %u/%u\n", lock
.Pitch
, width
* bmiHeader
->biBitCount
/8);
264 memcpy(lock
.pBits
, data
, width
* bmiHeader
->biBitCount
/ 8);
265 data
= data
+ width
* bmiHeader
->biBitCount
/ 8;
266 lock
.pBits
= (char *)lock
.pBits
+ lock
.Pitch
;
269 else memcpy(lock
.pBits
, data
, size
);
271 IDirect3DSurface9_UnlockRect(info
->lpSurf
);
273 hr
= IVMRImagePresenter9_PresentImage(This
->presenter
, This
->cookie
, info
);
277 static HRESULT WINAPI
VMR9_DoRenderSample(BaseRenderer
*iface
, IMediaSample
* pSample
)
279 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
280 LPBYTE pbSrcStream
= NULL
;
281 long cbSrcStream
= 0;
282 REFERENCE_TIME tStart
, tStop
;
283 VMR9PresentationInfo info
;
286 TRACE("%p %p\n", iface
, pSample
);
288 /* It is possible that there is no device at this point */
290 if (!This
->allocator
|| !This
->presenter
)
292 ERR("NO PRESENTER!!\n");
296 hr
= IMediaSample_GetTime(pSample
, &tStart
, &tStop
);
298 info
.dwFlags
= VMR9Sample_SrcDstRectsValid
;
300 info
.dwFlags
= VMR9Sample_SrcDstRectsValid
| VMR9Sample_TimeValid
;
302 if (IMediaSample_IsDiscontinuity(pSample
) == S_OK
)
303 info
.dwFlags
|= VMR9Sample_Discontinuity
;
305 if (IMediaSample_IsPreroll(pSample
) == S_OK
)
306 info
.dwFlags
|= VMR9Sample_Preroll
;
308 if (IMediaSample_IsSyncPoint(pSample
) == S_OK
)
309 info
.dwFlags
|= VMR9Sample_SyncPoint
;
311 /* If we render ourselves, and this is a preroll sample, discard it */
312 if (This
->baseControlWindow
.baseWindow
.hWnd
&& (info
.dwFlags
& VMR9Sample_Preroll
))
317 hr
= IMediaSample_GetPointer(pSample
, &pbSrcStream
);
320 ERR("Cannot get pointer to sample data (%x)\n", hr
);
324 cbSrcStream
= IMediaSample_GetActualDataLength(pSample
);
326 info
.rtStart
= tStart
;
328 info
.szAspectRatio
.cx
= This
->bmiheader
.biWidth
;
329 info
.szAspectRatio
.cy
= This
->bmiheader
.biHeight
;
331 hr
= IVMRSurfaceAllocatorEx9_GetSurface(This
->allocator
, This
->cookie
, (++This
->cur_surface
)%This
->num_surfaces
, 0, &info
.lpSurf
);
336 VMR9_SendSampleData(This
, &info
, pbSrcStream
, cbSrcStream
);
337 IDirect3DSurface9_Release(info
.lpSurf
);
342 static HRESULT WINAPI
VMR9_CheckMediaType(BaseRenderer
*iface
, const AM_MEDIA_TYPE
* pmt
)
344 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
346 if (!IsEqualIID(&pmt
->majortype
, &MEDIATYPE_Video
) || !pmt
->pbFormat
)
349 /* Ignore subtype, test for bicompression instead */
350 if (IsEqualIID(&pmt
->formattype
, &FORMAT_VideoInfo
))
352 VIDEOINFOHEADER
*format
= (VIDEOINFOHEADER
*)pmt
->pbFormat
;
354 This
->bmiheader
= format
->bmiHeader
;
355 TRACE("Resolution: %dx%d\n", format
->bmiHeader
.biWidth
, format
->bmiHeader
.biHeight
);
356 This
->VideoWidth
= format
->bmiHeader
.biWidth
;
357 This
->VideoHeight
= format
->bmiHeader
.biHeight
;
358 SetRect(&This
->source_rect
, 0, 0, This
->VideoWidth
, This
->VideoHeight
);
360 else if (IsEqualIID(&pmt
->formattype
, &FORMAT_VideoInfo2
))
362 VIDEOINFOHEADER2
*format
= (VIDEOINFOHEADER2
*)pmt
->pbFormat
;
364 This
->bmiheader
= format
->bmiHeader
;
366 TRACE("Resolution: %dx%d\n", format
->bmiHeader
.biWidth
, format
->bmiHeader
.biHeight
);
367 This
->VideoWidth
= format
->bmiHeader
.biWidth
;
368 This
->VideoHeight
= format
->bmiHeader
.biHeight
;
369 SetRect(&This
->source_rect
, 0, 0, This
->VideoWidth
, This
->VideoHeight
);
373 ERR("Format type %s not supported\n", debugstr_guid(&pmt
->formattype
));
376 if (This
->bmiheader
.biCompression
)
381 static HRESULT
VMR9_maybe_init(struct quartz_vmr
*This
, BOOL force
)
383 VMR9AllocationInfo info
;
387 TRACE("my mode: %u, my window: %p, my last window: %p\n", This
->mode
, This
->baseControlWindow
.baseWindow
.hWnd
, This
->hWndClippingWindow
);
388 if (This
->baseControlWindow
.baseWindow
.hWnd
|| !This
->renderer
.pInputPin
->pin
.pConnectedTo
)
391 if (This
->mode
== VMR9Mode_Windowless
&& !This
->hWndClippingWindow
)
392 return (force
? VFW_E_RUNTIME_ERROR
: S_OK
);
394 TRACE("Initializing\n");
395 info
.dwFlags
= VMR9AllocFlag_TextureSurface
;
396 info
.dwHeight
= This
->source_rect
.bottom
;
397 info
.dwWidth
= This
->source_rect
.right
;
398 info
.Pool
= D3DPOOL_DEFAULT
;
400 FIXME("Reduce ratio to least common denominator\n");
401 info
.szAspectRatio
.cx
= info
.dwWidth
;
402 info
.szAspectRatio
.cy
= info
.dwHeight
;
403 info
.szNativeSize
.cx
= This
->bmiheader
.biWidth
;
404 info
.szNativeSize
.cy
= This
->bmiheader
.biHeight
;
407 switch (This
->bmiheader
.biBitCount
)
409 case 8: info
.Format
= D3DFMT_R3G3B2
; break;
410 case 15: info
.Format
= D3DFMT_X1R5G5B5
; break;
411 case 16: info
.Format
= D3DFMT_R5G6B5
; break;
412 case 24: info
.Format
= D3DFMT_R8G8B8
; break;
413 case 32: info
.Format
= D3DFMT_X8R8G8B8
; break;
415 FIXME("Unknown bpp %u\n", This
->bmiheader
.biBitCount
);
419 This
->cur_surface
= 0;
420 if (This
->num_surfaces
)
422 ERR("num_surfaces or d3d9_surfaces not 0\n");
426 hr
= IVMRSurfaceAllocatorEx9_InitializeDevice(This
->allocator
, This
->cookie
, &info
, &buffers
);
429 SetRect(&This
->source_rect
, 0, 0, This
->bmiheader
.biWidth
, This
->bmiheader
.biHeight
);
431 This
->num_surfaces
= buffers
;
436 static VOID WINAPI
VMR9_OnStartStreaming(BaseRenderer
* iface
)
438 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
440 TRACE("(%p)\n", This
);
442 VMR9_maybe_init(This
, TRUE
);
443 IVMRImagePresenter9_StartPresenting(This
->presenter
, This
->cookie
);
444 SetWindowPos(This
->baseControlWindow
.baseWindow
.hWnd
, NULL
,
445 This
->source_rect
.left
,
446 This
->source_rect
.top
,
447 This
->source_rect
.right
- This
->source_rect
.left
,
448 This
->source_rect
.bottom
- This
->source_rect
.top
,
449 SWP_NOZORDER
|SWP_NOMOVE
|SWP_DEFERERASE
);
450 ShowWindow(This
->baseControlWindow
.baseWindow
.hWnd
, SW_SHOW
);
451 GetClientRect(This
->baseControlWindow
.baseWindow
.hWnd
, &This
->target_rect
);
454 static VOID WINAPI
VMR9_OnStopStreaming(BaseRenderer
* iface
)
456 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
458 TRACE("(%p)\n", This
);
460 if (This
->renderer
.filter
.state
== State_Running
)
461 IVMRImagePresenter9_StopPresenting(This
->presenter
, This
->cookie
);
464 static HRESULT WINAPI
VMR9_ShouldDrawSampleNow(BaseRenderer
*This
, IMediaSample
*pSample
, REFERENCE_TIME
*pStartTime
, REFERENCE_TIME
*pEndTime
)
466 /* Preroll means the sample isn't shown, this is used for key frames and things like that */
467 if (IMediaSample_IsPreroll(pSample
) == S_OK
)
472 static HRESULT WINAPI
VMR9_CompleteConnect(BaseRenderer
*This
, IPin
*pReceivePin
)
474 struct quartz_vmr
*pVMR9
= (struct quartz_vmr
*)This
;
477 TRACE("(%p)\n", This
);
480 SUCCEEDED(hr
= IVMRFilterConfig9_SetRenderingMode(&pVMR9
->IVMRFilterConfig9_iface
, VMR9Mode_Windowed
)))
481 hr
= VMR9_maybe_init(pVMR9
, FALSE
);
486 static HRESULT WINAPI
VMR9_BreakConnect(BaseRenderer
*This
)
488 struct quartz_vmr
*pVMR9
= (struct quartz_vmr
*)This
;
493 if (This
->pInputPin
->pin
.pConnectedTo
&& pVMR9
->allocator
&& pVMR9
->presenter
)
495 if (pVMR9
->renderer
.filter
.state
!= State_Stopped
)
497 ERR("Disconnecting while not stopped! UNTESTED!!\n");
499 if (pVMR9
->renderer
.filter
.state
== State_Running
)
500 hr
= IVMRImagePresenter9_StopPresenting(pVMR9
->presenter
, pVMR9
->cookie
);
501 IVMRSurfaceAllocatorEx9_TerminateDevice(pVMR9
->allocator
, pVMR9
->cookie
);
502 pVMR9
->num_surfaces
= 0;
507 static const BaseRendererFuncTable BaseFuncTable
= {
514 VMR9_OnStartStreaming
,
515 VMR9_OnStopStreaming
,
519 VMR9_ShouldDrawSampleNow
,
522 VMR9_CompleteConnect
,
529 static LPWSTR WINAPI
VMR9_GetClassWindowStyles(BaseWindow
*This
, DWORD
*pClassStyles
, DWORD
*pWindowStyles
, DWORD
*pWindowStylesEx
)
531 static WCHAR classnameW
[] = { 'I','V','M','R','9',' ','C','l','a','s','s', 0 };
534 *pWindowStyles
= WS_SIZEBOX
;
535 *pWindowStylesEx
= 0;
540 static RECT WINAPI
VMR9_GetDefaultRect(BaseWindow
*This
)
542 struct quartz_vmr
* pVMR9
= impl_from_BaseWindow(This
);
545 SetRect(&defRect
, 0, 0, pVMR9
->VideoWidth
, pVMR9
->VideoHeight
);
550 static BOOL WINAPI
VMR9_OnSize(BaseWindow
*This
, LONG Width
, LONG Height
)
552 struct quartz_vmr
* pVMR9
= impl_from_BaseWindow(This
);
554 TRACE("WM_SIZE %d %d\n", Width
, Height
);
555 GetClientRect(This
->hWnd
, &pVMR9
->target_rect
);
556 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
557 pVMR9
->target_rect
.left
,
558 pVMR9
->target_rect
.top
,
559 pVMR9
->target_rect
.right
- pVMR9
->target_rect
.left
,
560 pVMR9
->target_rect
.bottom
- pVMR9
->target_rect
.top
);
561 return BaseWindowImpl_OnSize(This
, Width
, Height
);
564 static const BaseWindowFuncTable renderer_BaseWindowFuncTable
= {
565 VMR9_GetClassWindowStyles
,
568 BaseControlWindowImpl_PossiblyEatMessage
,
572 static HRESULT WINAPI
VMR9_GetSourceRect(BaseControlVideo
* This
, RECT
*pSourceRect
)
574 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
575 CopyRect(pSourceRect
,&pVMR9
->source_rect
);
579 static HRESULT WINAPI
VMR9_GetStaticImage(BaseControlVideo
* This
, LONG
*pBufferSize
, LONG
*pDIBImage
)
581 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
582 BITMAPINFOHEADER
*bmiHeader
;
584 AM_MEDIA_TYPE
*amt
= &pVMR9
->renderer
.pInputPin
->pin
.mtCurrent
;
587 FIXME("(%p/%p)->(%p, %p): partial stub\n", pVMR9
, This
, pBufferSize
, pDIBImage
);
589 EnterCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
591 if (!pVMR9
->renderer
.pMediaSample
)
593 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
594 return (pVMR9
->renderer
.filter
.state
== State_Paused
? E_UNEXPECTED
: VFW_E_NOT_PAUSED
);
597 if (IsEqualIID(&amt
->formattype
, &FORMAT_VideoInfo
))
599 bmiHeader
= &((VIDEOINFOHEADER
*)amt
->pbFormat
)->bmiHeader
;
601 else if (IsEqualIID(&amt
->formattype
, &FORMAT_VideoInfo2
))
603 bmiHeader
= &((VIDEOINFOHEADER2
*)amt
->pbFormat
)->bmiHeader
;
607 FIXME("Unknown type %s\n", debugstr_guid(&amt
->subtype
));
608 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
609 return VFW_E_RUNTIME_ERROR
;
612 needed_size
= bmiHeader
->biSize
;
613 needed_size
+= IMediaSample_GetActualDataLength(pVMR9
->renderer
.pMediaSample
);
617 *pBufferSize
= needed_size
;
618 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
622 if (needed_size
< *pBufferSize
)
624 ERR("Buffer too small %u/%u\n", needed_size
, *pBufferSize
);
625 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
628 *pBufferSize
= needed_size
;
630 memcpy(pDIBImage
, bmiHeader
, bmiHeader
->biSize
);
631 IMediaSample_GetPointer(pVMR9
->renderer
.pMediaSample
, (BYTE
**)&ptr
);
632 memcpy((char *)pDIBImage
+ bmiHeader
->biSize
, ptr
, IMediaSample_GetActualDataLength(pVMR9
->renderer
.pMediaSample
));
634 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
638 static HRESULT WINAPI
VMR9_GetTargetRect(BaseControlVideo
* This
, RECT
*pTargetRect
)
640 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
641 CopyRect(pTargetRect
,&pVMR9
->target_rect
);
645 static VIDEOINFOHEADER
* WINAPI
VMR9_GetVideoFormat(BaseControlVideo
* This
)
647 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
650 TRACE("(%p/%p)\n", pVMR9
, This
);
652 pmt
= &pVMR9
->renderer
.pInputPin
->pin
.mtCurrent
;
653 if (IsEqualIID(&pmt
->formattype
, &FORMAT_VideoInfo
)) {
654 return (VIDEOINFOHEADER
*)pmt
->pbFormat
;
655 } else if (IsEqualIID(&pmt
->formattype
, &FORMAT_VideoInfo2
)) {
656 static VIDEOINFOHEADER vih
;
657 VIDEOINFOHEADER2
*vih2
= (VIDEOINFOHEADER2
*)pmt
->pbFormat
;
658 memcpy(&vih
,vih2
,sizeof(VIDEOINFOHEADER
));
659 memcpy(&vih
.bmiHeader
, &vih2
->bmiHeader
, sizeof(BITMAPINFOHEADER
));
662 ERR("Unknown format type %s\n", qzdebugstr_guid(&pmt
->formattype
));
667 static HRESULT WINAPI
VMR9_IsDefaultSourceRect(BaseControlVideo
* This
)
669 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
670 FIXME("(%p/%p)->(): stub !!!\n", pVMR9
, This
);
675 static HRESULT WINAPI
VMR9_IsDefaultTargetRect(BaseControlVideo
* This
)
677 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
678 FIXME("(%p/%p)->(): stub !!!\n", pVMR9
, This
);
683 static HRESULT WINAPI
VMR9_SetDefaultSourceRect(BaseControlVideo
* This
)
685 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
687 SetRect(&pVMR9
->source_rect
, 0, 0, pVMR9
->VideoWidth
, pVMR9
->VideoHeight
);
692 static HRESULT WINAPI
VMR9_SetDefaultTargetRect(BaseControlVideo
* This
)
695 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
697 if (!GetClientRect(pVMR9
->baseControlWindow
.baseWindow
.hWnd
, &rect
))
700 SetRect(&pVMR9
->target_rect
, 0, 0, rect
.right
, rect
.bottom
);
705 static HRESULT WINAPI
VMR9_SetSourceRect(BaseControlVideo
* This
, RECT
*pSourceRect
)
707 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
708 CopyRect(&pVMR9
->source_rect
,pSourceRect
);
712 static HRESULT WINAPI
VMR9_SetTargetRect(BaseControlVideo
* This
, RECT
*pTargetRect
)
714 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
715 CopyRect(&pVMR9
->target_rect
,pTargetRect
);
719 static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable
= {
724 VMR9_IsDefaultSourceRect
,
725 VMR9_IsDefaultTargetRect
,
726 VMR9_SetDefaultSourceRect
,
727 VMR9_SetDefaultTargetRect
,
732 static HRESULT WINAPI
VMR9Inner_QueryInterface(IUnknown
* iface
, REFIID riid
, LPVOID
* ppv
)
734 struct quartz_vmr
*This
= impl_from_inner_IUnknown(iface
);
735 TRACE("(%p/%p)->(%s, %p)\n", This
, iface
, qzdebugstr_guid(riid
), ppv
);
737 if (This
->bAggregatable
)
738 This
->bUnkOuterValid
= TRUE
;
742 if (IsEqualIID(riid
, &IID_IUnknown
))
743 *ppv
= &This
->IUnknown_inner
;
744 else if (IsEqualIID(riid
, &IID_IVideoWindow
))
745 *ppv
= &This
->baseControlWindow
.IVideoWindow_iface
;
746 else if (IsEqualIID(riid
, &IID_IBasicVideo
))
747 *ppv
= &This
->baseControlVideo
.IBasicVideo_iface
;
748 else if (IsEqualIID(riid
, &IID_IAMCertifiedOutputProtection
))
749 *ppv
= &This
->IAMCertifiedOutputProtection_iface
;
750 else if (IsEqualIID(riid
, &IID_IAMFilterMiscFlags
))
751 *ppv
= &This
->IAMFilterMiscFlags_iface
;
752 else if (IsEqualIID(riid
, &IID_IVMRFilterConfig
))
753 *ppv
= &This
->IVMRFilterConfig_iface
;
754 else if (IsEqualIID(riid
, &IID_IVMRFilterConfig9
))
755 *ppv
= &This
->IVMRFilterConfig9_iface
;
756 else if (IsEqualIID(riid
, &IID_IVMRMonitorConfig
))
757 *ppv
= &This
->IVMRMonitorConfig_iface
;
758 else if (IsEqualIID(riid
, &IID_IVMRMonitorConfig9
))
759 *ppv
= &This
->IVMRMonitorConfig9_iface
;
760 else if (IsEqualIID(riid
, &IID_IVMRSurfaceAllocatorNotify
) && This
->mode
== (VMR9Mode
)VMRMode_Renderless
)
761 *ppv
= &This
->IVMRSurfaceAllocatorNotify_iface
;
762 else if (IsEqualIID(riid
, &IID_IVMRSurfaceAllocatorNotify9
) && This
->mode
== VMR9Mode_Renderless
)
763 *ppv
= &This
->IVMRSurfaceAllocatorNotify9_iface
;
764 else if (IsEqualIID(riid
, &IID_IVMRWindowlessControl
) && This
->mode
== (VMR9Mode
)VMRMode_Windowless
)
765 *ppv
= &This
->IVMRWindowlessControl_iface
;
766 else if (IsEqualIID(riid
, &IID_IVMRWindowlessControl9
) && This
->mode
== VMR9Mode_Windowless
)
767 *ppv
= &This
->IVMRWindowlessControl9_iface
;
771 hr
= BaseRendererImpl_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
778 IUnknown_AddRef((IUnknown
*)(*ppv
));
782 else if (IsEqualIID(riid
, &IID_IBasicVideo2
))
783 FIXME("No interface for IID_IBasicVideo2\n");
784 else if (IsEqualIID(riid
, &IID_IVMRWindowlessControl9
))
786 else if (IsEqualIID(riid
, &IID_IVMRSurfaceAllocatorNotify9
))
788 else if (IsEqualIID(riid
, &IID_IMediaPosition
))
789 FIXME("No interface for IID_IMediaPosition\n");
790 else if (IsEqualIID(riid
, &IID_IQualProp
))
791 FIXME("No interface for IID_IQualProp\n");
792 else if (IsEqualIID(riid
, &IID_IVMRAspectRatioControl9
))
793 FIXME("No interface for IID_IVMRAspectRatioControl9\n");
794 else if (IsEqualIID(riid
, &IID_IVMRDeinterlaceControl9
))
795 FIXME("No interface for IID_IVMRDeinterlaceControl9\n");
796 else if (IsEqualIID(riid
, &IID_IVMRMixerBitmap9
))
797 FIXME("No interface for IID_IVMRMixerBitmap9\n");
798 else if (IsEqualIID(riid
, &IID_IVMRMixerControl9
))
799 FIXME("No interface for IID_IVMRMixerControl9\n");
801 FIXME("No interface for %s\n", debugstr_guid(riid
));
803 return E_NOINTERFACE
;
806 static ULONG WINAPI
VMR9Inner_AddRef(IUnknown
* iface
)
808 struct quartz_vmr
*This
= impl_from_inner_IUnknown(iface
);
809 ULONG refCount
= BaseFilterImpl_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
811 TRACE("(%p/%p)->() AddRef from %d\n", This
, iface
, refCount
- 1);
816 static ULONG WINAPI
VMR9Inner_Release(IUnknown
* iface
)
818 struct quartz_vmr
*This
= impl_from_inner_IUnknown(iface
);
819 ULONG refCount
= BaseRendererImpl_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
821 TRACE("(%p/%p)->() Release from %d\n", This
, iface
, refCount
+ 1);
825 TRACE("Destroying\n");
826 BaseControlWindow_Destroy(&This
->baseControlWindow
);
827 FreeLibrary(This
->hD3d9
);
830 IVMRSurfaceAllocatorEx9_Release(This
->allocator
);
832 IVMRImagePresenter9_Release(This
->presenter
);
834 This
->num_surfaces
= 0;
835 if (This
->allocator_d3d9_dev
)
837 IDirect3DDevice9_Release(This
->allocator_d3d9_dev
);
838 This
->allocator_d3d9_dev
= NULL
;
846 static const IUnknownVtbl IInner_VTable
=
848 VMR9Inner_QueryInterface
,
853 static HRESULT WINAPI
VMR9_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
855 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
857 if (This
->bAggregatable
)
858 This
->bUnkOuterValid
= TRUE
;
862 if (This
->bAggregatable
)
863 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
865 if (IsEqualIID(riid
, &IID_IUnknown
))
869 IUnknown_AddRef(&This
->IUnknown_inner
);
870 hr
= IUnknown_QueryInterface(&This
->IUnknown_inner
, riid
, ppv
);
871 IUnknown_Release(&This
->IUnknown_inner
);
872 This
->bAggregatable
= TRUE
;
877 return E_NOINTERFACE
;
880 return IUnknown_QueryInterface(&This
->IUnknown_inner
, riid
, ppv
);
883 static ULONG WINAPI
VMR9_AddRef(IBaseFilter
* iface
)
885 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
888 if (This
->outer_unk
&& This
->bUnkOuterValid
)
889 ret
= IUnknown_AddRef(This
->outer_unk
);
891 ret
= IUnknown_AddRef(&This
->IUnknown_inner
);
893 TRACE("(%p)->AddRef from %d\n", iface
, ret
- 1);
898 static ULONG WINAPI
VMR9_Release(IBaseFilter
* iface
)
900 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
903 if (This
->outer_unk
&& This
->bUnkOuterValid
)
904 ret
= IUnknown_Release(This
->outer_unk
);
906 ret
= IUnknown_Release(&This
->IUnknown_inner
);
908 TRACE("(%p)->Release from %d\n", iface
, ret
+ 1);
915 static const IBaseFilterVtbl VMR_Vtbl
=
920 BaseFilterImpl_GetClassID
,
921 BaseRendererImpl_Stop
,
922 BaseRendererImpl_Pause
,
923 BaseRendererImpl_Run
,
924 BaseRendererImpl_GetState
,
925 BaseRendererImpl_SetSyncSource
,
926 BaseFilterImpl_GetSyncSource
,
927 BaseFilterImpl_EnumPins
,
928 BaseRendererImpl_FindPin
,
929 BaseFilterImpl_QueryFilterInfo
,
930 BaseFilterImpl_JoinFilterGraph
,
931 BaseFilterImpl_QueryVendorInfo
934 /*** IUnknown methods ***/
935 static HRESULT WINAPI
Videowindow_QueryInterface(IVideoWindow
*iface
, REFIID riid
, LPVOID
*ppvObj
)
937 struct quartz_vmr
*This
= impl_from_IVideoWindow(iface
);
939 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
941 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
944 static ULONG WINAPI
Videowindow_AddRef(IVideoWindow
*iface
)
946 struct quartz_vmr
*This
= impl_from_IVideoWindow(iface
);
948 TRACE("(%p/%p)->()\n", This
, iface
);
950 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
953 static ULONG WINAPI
Videowindow_Release(IVideoWindow
*iface
)
955 struct quartz_vmr
*This
= impl_from_IVideoWindow(iface
);
957 TRACE("(%p/%p)->()\n", This
, iface
);
959 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
962 static const IVideoWindowVtbl IVideoWindow_VTable
=
964 Videowindow_QueryInterface
,
967 BaseControlWindowImpl_GetTypeInfoCount
,
968 BaseControlWindowImpl_GetTypeInfo
,
969 BaseControlWindowImpl_GetIDsOfNames
,
970 BaseControlWindowImpl_Invoke
,
971 BaseControlWindowImpl_put_Caption
,
972 BaseControlWindowImpl_get_Caption
,
973 BaseControlWindowImpl_put_WindowStyle
,
974 BaseControlWindowImpl_get_WindowStyle
,
975 BaseControlWindowImpl_put_WindowStyleEx
,
976 BaseControlWindowImpl_get_WindowStyleEx
,
977 BaseControlWindowImpl_put_AutoShow
,
978 BaseControlWindowImpl_get_AutoShow
,
979 BaseControlWindowImpl_put_WindowState
,
980 BaseControlWindowImpl_get_WindowState
,
981 BaseControlWindowImpl_put_BackgroundPalette
,
982 BaseControlWindowImpl_get_BackgroundPalette
,
983 BaseControlWindowImpl_put_Visible
,
984 BaseControlWindowImpl_get_Visible
,
985 BaseControlWindowImpl_put_Left
,
986 BaseControlWindowImpl_get_Left
,
987 BaseControlWindowImpl_put_Width
,
988 BaseControlWindowImpl_get_Width
,
989 BaseControlWindowImpl_put_Top
,
990 BaseControlWindowImpl_get_Top
,
991 BaseControlWindowImpl_put_Height
,
992 BaseControlWindowImpl_get_Height
,
993 BaseControlWindowImpl_put_Owner
,
994 BaseControlWindowImpl_get_Owner
,
995 BaseControlWindowImpl_put_MessageDrain
,
996 BaseControlWindowImpl_get_MessageDrain
,
997 BaseControlWindowImpl_get_BorderColor
,
998 BaseControlWindowImpl_put_BorderColor
,
999 BaseControlWindowImpl_get_FullScreenMode
,
1000 BaseControlWindowImpl_put_FullScreenMode
,
1001 BaseControlWindowImpl_SetWindowForeground
,
1002 BaseControlWindowImpl_NotifyOwnerMessage
,
1003 BaseControlWindowImpl_SetWindowPosition
,
1004 BaseControlWindowImpl_GetWindowPosition
,
1005 BaseControlWindowImpl_GetMinIdealImageSize
,
1006 BaseControlWindowImpl_GetMaxIdealImageSize
,
1007 BaseControlWindowImpl_GetRestorePosition
,
1008 BaseControlWindowImpl_HideCursor
,
1009 BaseControlWindowImpl_IsCursorHidden
1012 /*** IUnknown methods ***/
1013 static HRESULT WINAPI
Basicvideo_QueryInterface(IBasicVideo
*iface
, REFIID riid
, LPVOID
* ppvObj
)
1015 struct quartz_vmr
*This
= impl_from_IBasicVideo(iface
);
1017 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1019 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
1022 static ULONG WINAPI
Basicvideo_AddRef(IBasicVideo
*iface
)
1024 struct quartz_vmr
*This
= impl_from_IBasicVideo(iface
);
1026 TRACE("(%p/%p)->()\n", This
, iface
);
1028 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1031 static ULONG WINAPI
Basicvideo_Release(IBasicVideo
*iface
)
1033 struct quartz_vmr
*This
= impl_from_IBasicVideo(iface
);
1035 TRACE("(%p/%p)->()\n", This
, iface
);
1037 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1040 static const IBasicVideoVtbl IBasicVideo_VTable
=
1042 Basicvideo_QueryInterface
,
1045 BaseControlVideoImpl_GetTypeInfoCount
,
1046 BaseControlVideoImpl_GetTypeInfo
,
1047 BaseControlVideoImpl_GetIDsOfNames
,
1048 BaseControlVideoImpl_Invoke
,
1049 BaseControlVideoImpl_get_AvgTimePerFrame
,
1050 BaseControlVideoImpl_get_BitRate
,
1051 BaseControlVideoImpl_get_BitErrorRate
,
1052 BaseControlVideoImpl_get_VideoWidth
,
1053 BaseControlVideoImpl_get_VideoHeight
,
1054 BaseControlVideoImpl_put_SourceLeft
,
1055 BaseControlVideoImpl_get_SourceLeft
,
1056 BaseControlVideoImpl_put_SourceWidth
,
1057 BaseControlVideoImpl_get_SourceWidth
,
1058 BaseControlVideoImpl_put_SourceTop
,
1059 BaseControlVideoImpl_get_SourceTop
,
1060 BaseControlVideoImpl_put_SourceHeight
,
1061 BaseControlVideoImpl_get_SourceHeight
,
1062 BaseControlVideoImpl_put_DestinationLeft
,
1063 BaseControlVideoImpl_get_DestinationLeft
,
1064 BaseControlVideoImpl_put_DestinationWidth
,
1065 BaseControlVideoImpl_get_DestinationWidth
,
1066 BaseControlVideoImpl_put_DestinationTop
,
1067 BaseControlVideoImpl_get_DestinationTop
,
1068 BaseControlVideoImpl_put_DestinationHeight
,
1069 BaseControlVideoImpl_get_DestinationHeight
,
1070 BaseControlVideoImpl_SetSourcePosition
,
1071 BaseControlVideoImpl_GetSourcePosition
,
1072 BaseControlVideoImpl_SetDefaultSourcePosition
,
1073 BaseControlVideoImpl_SetDestinationPosition
,
1074 BaseControlVideoImpl_GetDestinationPosition
,
1075 BaseControlVideoImpl_SetDefaultDestinationPosition
,
1076 BaseControlVideoImpl_GetVideoSize
,
1077 BaseControlVideoImpl_GetVideoPaletteEntries
,
1078 BaseControlVideoImpl_GetCurrentImage
,
1079 BaseControlVideoImpl_IsUsingDefaultSource
,
1080 BaseControlVideoImpl_IsUsingDefaultDestination
1083 static HRESULT WINAPI
AMCertifiedOutputProtection_QueryInterface(IAMCertifiedOutputProtection
*iface
,
1084 REFIID riid
, void **ppv
)
1086 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1087 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1090 static ULONG WINAPI
AMCertifiedOutputProtection_AddRef(IAMCertifiedOutputProtection
*iface
)
1092 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1093 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1096 static ULONG WINAPI
AMCertifiedOutputProtection_Release(IAMCertifiedOutputProtection
*iface
)
1098 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1099 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1102 static HRESULT WINAPI
AMCertifiedOutputProtection_KeyExchange(IAMCertifiedOutputProtection
*iface
,
1103 GUID
* pRandom
, BYTE
** VarLenCertGH
,
1104 DWORD
* pdwLengthCertGH
)
1106 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1108 FIXME("(%p/%p)->(%p, %p, %p) stub\n", iface
, This
, pRandom
, VarLenCertGH
, pdwLengthCertGH
);
1109 return VFW_E_NO_COPP_HW
;
1112 static HRESULT WINAPI
AMCertifiedOutputProtection_SessionSequenceStart(IAMCertifiedOutputProtection
*iface
,
1113 AMCOPPSignature
* pSig
)
1115 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1117 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pSig
);
1118 return VFW_E_NO_COPP_HW
;
1121 static HRESULT WINAPI
AMCertifiedOutputProtection_ProtectionCommand(IAMCertifiedOutputProtection
*iface
,
1122 const AMCOPPCommand
* cmd
)
1124 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1126 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, cmd
);
1127 return VFW_E_NO_COPP_HW
;
1130 static HRESULT WINAPI
AMCertifiedOutputProtection_ProtectionStatus(IAMCertifiedOutputProtection
*iface
,
1131 const AMCOPPStatusInput
* pStatusInput
,
1132 AMCOPPStatusOutput
* pStatusOutput
)
1134 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1136 FIXME("(%p/%p)->(%p, %p) stub\n", iface
, This
, pStatusInput
, pStatusOutput
);
1137 return VFW_E_NO_COPP_HW
;
1140 static const IAMCertifiedOutputProtectionVtbl IAMCertifiedOutputProtection_Vtbl
=
1142 AMCertifiedOutputProtection_QueryInterface
,
1143 AMCertifiedOutputProtection_AddRef
,
1144 AMCertifiedOutputProtection_Release
,
1145 AMCertifiedOutputProtection_KeyExchange
,
1146 AMCertifiedOutputProtection_SessionSequenceStart
,
1147 AMCertifiedOutputProtection_ProtectionCommand
,
1148 AMCertifiedOutputProtection_ProtectionStatus
1151 static HRESULT WINAPI
AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags
*iface
, REFIID riid
, void **ppv
) {
1152 struct quartz_vmr
*This
= impl_from_IAMFilterMiscFlags(iface
);
1153 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1156 static ULONG WINAPI
AMFilterMiscFlags_AddRef(IAMFilterMiscFlags
*iface
) {
1157 struct quartz_vmr
*This
= impl_from_IAMFilterMiscFlags(iface
);
1158 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1161 static ULONG WINAPI
AMFilterMiscFlags_Release(IAMFilterMiscFlags
*iface
) {
1162 struct quartz_vmr
*This
= impl_from_IAMFilterMiscFlags(iface
);
1163 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1166 static ULONG WINAPI
AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags
*iface
) {
1167 return AM_FILTER_MISC_FLAGS_IS_RENDERER
;
1170 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
= {
1171 AMFilterMiscFlags_QueryInterface
,
1172 AMFilterMiscFlags_AddRef
,
1173 AMFilterMiscFlags_Release
,
1174 AMFilterMiscFlags_GetMiscFlags
1177 static HRESULT WINAPI
VMR7FilterConfig_QueryInterface(IVMRFilterConfig
*iface
, REFIID riid
,
1180 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1181 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1184 static ULONG WINAPI
VMR7FilterConfig_AddRef(IVMRFilterConfig
*iface
)
1186 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1187 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1190 static ULONG WINAPI
VMR7FilterConfig_Release(IVMRFilterConfig
*iface
)
1192 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1193 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1196 static HRESULT WINAPI
VMR7FilterConfig_SetImageCompositor(IVMRFilterConfig
*iface
,
1197 IVMRImageCompositor
*compositor
)
1199 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1201 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, compositor
);
1205 static HRESULT WINAPI
VMR7FilterConfig_SetNumberOfStreams(IVMRFilterConfig
*iface
, DWORD max
)
1207 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1209 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, max
);
1213 static HRESULT WINAPI
VMR7FilterConfig_GetNumberOfStreams(IVMRFilterConfig
*iface
, DWORD
*max
)
1215 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1217 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, max
);
1221 static HRESULT WINAPI
VMR7FilterConfig_SetRenderingPrefs(IVMRFilterConfig
*iface
, DWORD renderflags
)
1223 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1225 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, renderflags
);
1229 static HRESULT WINAPI
VMR7FilterConfig_GetRenderingPrefs(IVMRFilterConfig
*iface
, DWORD
*renderflags
)
1231 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1233 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, renderflags
);
1237 static HRESULT WINAPI
VMR7FilterConfig_SetRenderingMode(IVMRFilterConfig
*iface
, DWORD mode
)
1239 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1241 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, mode
);
1245 static HRESULT WINAPI
VMR7FilterConfig_GetRenderingMode(IVMRFilterConfig
*iface
, DWORD
*mode
)
1247 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1249 TRACE("(%p/%p)->(%p) stub\n", iface
, This
, mode
);
1250 if (!mode
) return E_POINTER
;
1255 *mode
= VMRMode_Windowed
;
1260 static const IVMRFilterConfigVtbl VMR7_FilterConfig_Vtbl
=
1262 VMR7FilterConfig_QueryInterface
,
1263 VMR7FilterConfig_AddRef
,
1264 VMR7FilterConfig_Release
,
1265 VMR7FilterConfig_SetImageCompositor
,
1266 VMR7FilterConfig_SetNumberOfStreams
,
1267 VMR7FilterConfig_GetNumberOfStreams
,
1268 VMR7FilterConfig_SetRenderingPrefs
,
1269 VMR7FilterConfig_GetRenderingPrefs
,
1270 VMR7FilterConfig_SetRenderingMode
,
1271 VMR7FilterConfig_GetRenderingMode
1274 struct get_available_monitors_args
1276 VMRMONITORINFO
*info7
;
1277 VMR9MonitorInfo
*info9
;
1282 static BOOL CALLBACK
get_available_monitors_proc(HMONITOR hmon
, HDC hdc
, LPRECT lprc
, LPARAM lparam
)
1284 struct get_available_monitors_args
*args
= (struct get_available_monitors_args
*)lparam
;
1287 if (args
->info7
|| args
->info9
)
1290 if (!args
->arraysize
)
1293 mi
.cbSize
= sizeof(mi
);
1294 if (!GetMonitorInfoW(hmon
, (MONITORINFO
*)&mi
))
1297 /* fill VMRMONITORINFO struct */
1300 VMRMONITORINFO
*info
= args
->info7
++;
1301 memset(info
, 0, sizeof(*info
));
1303 if (args
->numdev
> 0)
1305 info
->guid
.pGUID
= &info
->guid
.GUID
;
1306 info
->guid
.GUID
.Data4
[7] = args
->numdev
;
1309 info
->guid
.pGUID
= NULL
;
1311 CopyRect(&info
->rcMonitor
, &mi
.rcMonitor
);
1313 info
->dwFlags
= mi
.dwFlags
;
1315 lstrcpynW(info
->szDevice
, mi
.szDevice
, sizeof(info
->szDevice
)/sizeof(WCHAR
));
1317 /* FIXME: how to get these values? */
1318 info
->szDescription
[0] = 0;
1321 /* fill VMR9MonitorInfo struct */
1324 VMR9MonitorInfo
*info
= args
->info9
++;
1325 memset(info
, 0, sizeof(*info
));
1327 info
->uDevID
= 0; /* FIXME */
1328 CopyRect(&info
->rcMonitor
, &mi
.rcMonitor
);
1330 info
->dwFlags
= mi
.dwFlags
;
1332 lstrcpynW(info
->szDevice
, mi
.szDevice
, sizeof(info
->szDevice
)/sizeof(WCHAR
));
1334 /* FIXME: how to get these values? */
1335 info
->szDescription
[0] = 0;
1336 info
->dwVendorId
= 0;
1337 info
->dwDeviceId
= 0;
1338 info
->dwSubSysId
= 0;
1339 info
->dwRevision
= 0;
1349 static HRESULT WINAPI
VMR7MonitorConfig_QueryInterface(IVMRMonitorConfig
*iface
, REFIID riid
,
1352 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1353 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1356 static ULONG WINAPI
VMR7MonitorConfig_AddRef(IVMRMonitorConfig
*iface
)
1358 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1359 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1362 static ULONG WINAPI
VMR7MonitorConfig_Release(IVMRMonitorConfig
*iface
)
1364 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1365 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1368 static HRESULT WINAPI
VMR7MonitorConfig_SetMonitor(IVMRMonitorConfig
*iface
, const VMRGUID
*pGUID
)
1370 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1372 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pGUID
);
1380 static HRESULT WINAPI
VMR7MonitorConfig_GetMonitor(IVMRMonitorConfig
*iface
, VMRGUID
*pGUID
)
1382 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1384 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pGUID
);
1389 pGUID
->pGUID
= NULL
; /* default DirectDraw device */
1393 static HRESULT WINAPI
VMR7MonitorConfig_SetDefaultMonitor(IVMRMonitorConfig
*iface
,
1394 const VMRGUID
*pGUID
)
1396 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1398 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pGUID
);
1406 static HRESULT WINAPI
VMR7MonitorConfig_GetDefaultMonitor(IVMRMonitorConfig
*iface
, VMRGUID
*pGUID
)
1408 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1410 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pGUID
);
1415 pGUID
->pGUID
= NULL
; /* default DirectDraw device */
1419 static HRESULT WINAPI
VMR7MonitorConfig_GetAvailableMonitors(IVMRMonitorConfig
*iface
,
1420 VMRMONITORINFO
*info
, DWORD arraysize
,
1423 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1424 struct get_available_monitors_args args
;
1426 FIXME("(%p/%p)->(%p, %u, %p) semi-stub\n", iface
, This
, info
, arraysize
, numdev
);
1431 if (info
&& arraysize
== 0)
1432 return E_INVALIDARG
;
1436 args
.arraysize
= arraysize
;
1438 EnumDisplayMonitors(NULL
, NULL
, get_available_monitors_proc
, (LPARAM
)&args
);
1440 *numdev
= args
.numdev
;
1444 static const IVMRMonitorConfigVtbl VMR7_MonitorConfig_Vtbl
=
1446 VMR7MonitorConfig_QueryInterface
,
1447 VMR7MonitorConfig_AddRef
,
1448 VMR7MonitorConfig_Release
,
1449 VMR7MonitorConfig_SetMonitor
,
1450 VMR7MonitorConfig_GetMonitor
,
1451 VMR7MonitorConfig_SetDefaultMonitor
,
1452 VMR7MonitorConfig_GetDefaultMonitor
,
1453 VMR7MonitorConfig_GetAvailableMonitors
1456 static HRESULT WINAPI
VMR9MonitorConfig_QueryInterface(IVMRMonitorConfig9
*iface
, REFIID riid
,
1459 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1460 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1463 static ULONG WINAPI
VMR9MonitorConfig_AddRef(IVMRMonitorConfig9
*iface
)
1465 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1466 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1469 static ULONG WINAPI
VMR9MonitorConfig_Release(IVMRMonitorConfig9
*iface
)
1471 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1472 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1475 static HRESULT WINAPI
VMR9MonitorConfig_SetMonitor(IVMRMonitorConfig9
*iface
, UINT uDev
)
1477 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1479 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, uDev
);
1484 static HRESULT WINAPI
VMR9MonitorConfig_GetMonitor(IVMRMonitorConfig9
*iface
, UINT
*uDev
)
1486 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1488 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, uDev
);
1497 static HRESULT WINAPI
VMR9MonitorConfig_SetDefaultMonitor(IVMRMonitorConfig9
*iface
, UINT uDev
)
1499 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1501 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, uDev
);
1506 static HRESULT WINAPI
VMR9MonitorConfig_GetDefaultMonitor(IVMRMonitorConfig9
*iface
, UINT
*uDev
)
1508 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1510 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, uDev
);
1519 static HRESULT WINAPI
VMR9MonitorConfig_GetAvailableMonitors(IVMRMonitorConfig9
*iface
,
1520 VMR9MonitorInfo
*info
, DWORD arraysize
,
1523 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1524 struct get_available_monitors_args args
;
1526 FIXME("(%p/%p)->(%p, %u, %p) semi-stub\n", iface
, This
, info
, arraysize
, numdev
);
1531 if (info
&& arraysize
== 0)
1532 return E_INVALIDARG
;
1536 args
.arraysize
= arraysize
;
1538 EnumDisplayMonitors(NULL
, NULL
, get_available_monitors_proc
, (LPARAM
)&args
);
1540 *numdev
= args
.numdev
;
1544 static const IVMRMonitorConfig9Vtbl VMR9_MonitorConfig_Vtbl
=
1546 VMR9MonitorConfig_QueryInterface
,
1547 VMR9MonitorConfig_AddRef
,
1548 VMR9MonitorConfig_Release
,
1549 VMR9MonitorConfig_SetMonitor
,
1550 VMR9MonitorConfig_GetMonitor
,
1551 VMR9MonitorConfig_SetDefaultMonitor
,
1552 VMR9MonitorConfig_GetDefaultMonitor
,
1553 VMR9MonitorConfig_GetAvailableMonitors
1556 static HRESULT WINAPI
VMR9FilterConfig_QueryInterface(IVMRFilterConfig9
*iface
, REFIID riid
, LPVOID
* ppv
)
1558 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1559 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1562 static ULONG WINAPI
VMR9FilterConfig_AddRef(IVMRFilterConfig9
*iface
)
1564 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1565 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1568 static ULONG WINAPI
VMR9FilterConfig_Release(IVMRFilterConfig9
*iface
)
1570 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1571 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1574 static HRESULT WINAPI
VMR9FilterConfig_SetImageCompositor(IVMRFilterConfig9
*iface
, IVMRImageCompositor9
*compositor
)
1576 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1578 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, compositor
);
1582 static HRESULT WINAPI
VMR9FilterConfig_SetNumberOfStreams(IVMRFilterConfig9
*iface
, DWORD max
)
1584 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1586 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, max
);
1590 static HRESULT WINAPI
VMR9FilterConfig_GetNumberOfStreams(IVMRFilterConfig9
*iface
, DWORD
*max
)
1592 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1594 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, max
);
1598 static HRESULT WINAPI
VMR9FilterConfig_SetRenderingPrefs(IVMRFilterConfig9
*iface
, DWORD renderflags
)
1600 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1602 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, renderflags
);
1606 static HRESULT WINAPI
VMR9FilterConfig_GetRenderingPrefs(IVMRFilterConfig9
*iface
, DWORD
*renderflags
)
1608 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1610 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, renderflags
);
1614 static HRESULT WINAPI
VMR9FilterConfig_SetRenderingMode(IVMRFilterConfig9
*iface
, DWORD mode
)
1617 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1619 TRACE("(%p/%p)->(%u)\n", iface
, This
, mode
);
1621 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1624 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1625 return VFW_E_WRONG_STATE
;
1628 if (This
->allocator
)
1629 IVMRSurfaceAllocatorEx9_Release(This
->allocator
);
1630 if (This
->presenter
)
1631 IVMRImagePresenter9_Release(This
->presenter
);
1633 This
->allocator
= NULL
;
1634 This
->presenter
= NULL
;
1638 case VMR9Mode_Windowed
:
1639 case VMR9Mode_Windowless
:
1640 This
->allocator_is_ex
= 0;
1643 hr
= VMR9DefaultAllocatorPresenterImpl_create(This
, (LPVOID
*)&This
->presenter
);
1645 hr
= IVMRImagePresenter9_QueryInterface(This
->presenter
, &IID_IVMRSurfaceAllocatorEx9
, (LPVOID
*)&This
->allocator
);
1648 ERR("Unable to find Presenter interface\n");
1649 IVMRImagePresenter9_Release(This
->presenter
);
1650 This
->allocator
= NULL
;
1651 This
->presenter
= NULL
;
1654 hr
= IVMRSurfaceAllocatorEx9_AdviseNotify(This
->allocator
, &This
->IVMRSurfaceAllocatorNotify9_iface
);
1656 case VMR9Mode_Renderless
:
1659 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1660 return E_INVALIDARG
;
1664 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1668 static HRESULT WINAPI
VMR9FilterConfig_GetRenderingMode(IVMRFilterConfig9
*iface
, DWORD
*mode
)
1670 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1672 TRACE("(%p/%p)->(%p) stub\n", iface
, This
, mode
);
1679 *mode
= VMR9Mode_Windowed
;
1684 static const IVMRFilterConfig9Vtbl VMR9_FilterConfig_Vtbl
=
1686 VMR9FilterConfig_QueryInterface
,
1687 VMR9FilterConfig_AddRef
,
1688 VMR9FilterConfig_Release
,
1689 VMR9FilterConfig_SetImageCompositor
,
1690 VMR9FilterConfig_SetNumberOfStreams
,
1691 VMR9FilterConfig_GetNumberOfStreams
,
1692 VMR9FilterConfig_SetRenderingPrefs
,
1693 VMR9FilterConfig_GetRenderingPrefs
,
1694 VMR9FilterConfig_SetRenderingMode
,
1695 VMR9FilterConfig_GetRenderingMode
1698 static HRESULT WINAPI
VMR7WindowlessControl_QueryInterface(IVMRWindowlessControl
*iface
, REFIID riid
,
1701 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1702 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1705 static ULONG WINAPI
VMR7WindowlessControl_AddRef(IVMRWindowlessControl
*iface
)
1707 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1708 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1711 static ULONG WINAPI
VMR7WindowlessControl_Release(IVMRWindowlessControl
*iface
)
1713 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1714 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1717 static HRESULT WINAPI
VMR7WindowlessControl_GetNativeVideoSize(IVMRWindowlessControl
*iface
,
1718 LONG
*width
, LONG
*height
,
1719 LONG
*arwidth
, LONG
*arheight
)
1721 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1722 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", iface
, This
, width
, height
, arwidth
, arheight
);
1724 if (!width
|| !height
|| !arwidth
|| !arheight
)
1726 ERR("Got no pointer\n");
1730 *width
= This
->bmiheader
.biWidth
;
1731 *height
= This
->bmiheader
.biHeight
;
1732 *arwidth
= This
->bmiheader
.biWidth
;
1733 *arheight
= This
->bmiheader
.biHeight
;
1738 static HRESULT WINAPI
VMR7WindowlessControl_GetMinIdealVideoSize(IVMRWindowlessControl
*iface
,
1739 LONG
*width
, LONG
*height
)
1741 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1743 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1747 static HRESULT WINAPI
VMR7WindowlessControl_GetMaxIdealVideoSize(IVMRWindowlessControl
*iface
,
1748 LONG
*width
, LONG
*height
)
1750 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1752 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1756 static HRESULT WINAPI
VMR7WindowlessControl_SetVideoPosition(IVMRWindowlessControl
*iface
,
1757 const RECT
*source
, const RECT
*dest
)
1759 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1761 TRACE("(%p/%p)->(%p, %p)\n", iface
, This
, source
, dest
);
1763 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1766 This
->source_rect
= *source
;
1769 This
->target_rect
= *dest
;
1770 if (This
->baseControlWindow
.baseWindow
.hWnd
)
1772 FIXME("Output rectangle: starting at %dx%d, up to point %dx%d\n",
1773 dest
->left
, dest
->top
, dest
->right
, dest
->bottom
);
1774 SetWindowPos(This
->baseControlWindow
.baseWindow
.hWnd
, NULL
,
1775 dest
->left
, dest
->top
, dest
->right
- dest
->left
, dest
->bottom
-dest
->top
,
1776 SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOOWNERZORDER
|SWP_NOREDRAW
);
1780 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1785 static HRESULT WINAPI
VMR7WindowlessControl_GetVideoPosition(IVMRWindowlessControl
*iface
,
1786 RECT
*source
, RECT
*dest
)
1788 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1791 *source
= This
->source_rect
;
1794 *dest
= This
->target_rect
;
1796 FIXME("(%p/%p)->(%p/%p) stub\n", iface
, This
, source
, dest
);
1800 static HRESULT WINAPI
VMR7WindowlessControl_GetAspectRatioMode(IVMRWindowlessControl
*iface
,
1803 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1805 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1809 static HRESULT WINAPI
VMR7WindowlessControl_SetAspectRatioMode(IVMRWindowlessControl
*iface
,
1812 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1814 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1818 static HRESULT WINAPI
VMR7WindowlessControl_SetVideoClippingWindow(IVMRWindowlessControl
*iface
,
1821 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1823 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1827 static HRESULT WINAPI
VMR7WindowlessControl_RepaintVideo(IVMRWindowlessControl
*iface
,
1830 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1832 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1836 static HRESULT WINAPI
VMR7WindowlessControl_DisplayModeChanged(IVMRWindowlessControl
*iface
)
1838 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1840 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1844 static HRESULT WINAPI
VMR7WindowlessControl_GetCurrentImage(IVMRWindowlessControl
*iface
,
1847 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1849 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1853 static HRESULT WINAPI
VMR7WindowlessControl_SetBorderColor(IVMRWindowlessControl
*iface
,
1856 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1858 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1862 static HRESULT WINAPI
VMR7WindowlessControl_GetBorderColor(IVMRWindowlessControl
*iface
,
1865 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1867 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1871 static HRESULT WINAPI
VMR7WindowlessControl_SetColorKey(IVMRWindowlessControl
*iface
, COLORREF color
)
1873 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1875 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1879 static HRESULT WINAPI
VMR7WindowlessControl_GetColorKey(IVMRWindowlessControl
*iface
, COLORREF
*color
)
1881 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1883 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1887 static const IVMRWindowlessControlVtbl VMR7_WindowlessControl_Vtbl
=
1889 VMR7WindowlessControl_QueryInterface
,
1890 VMR7WindowlessControl_AddRef
,
1891 VMR7WindowlessControl_Release
,
1892 VMR7WindowlessControl_GetNativeVideoSize
,
1893 VMR7WindowlessControl_GetMinIdealVideoSize
,
1894 VMR7WindowlessControl_GetMaxIdealVideoSize
,
1895 VMR7WindowlessControl_SetVideoPosition
,
1896 VMR7WindowlessControl_GetVideoPosition
,
1897 VMR7WindowlessControl_GetAspectRatioMode
,
1898 VMR7WindowlessControl_SetAspectRatioMode
,
1899 VMR7WindowlessControl_SetVideoClippingWindow
,
1900 VMR7WindowlessControl_RepaintVideo
,
1901 VMR7WindowlessControl_DisplayModeChanged
,
1902 VMR7WindowlessControl_GetCurrentImage
,
1903 VMR7WindowlessControl_SetBorderColor
,
1904 VMR7WindowlessControl_GetBorderColor
,
1905 VMR7WindowlessControl_SetColorKey
,
1906 VMR7WindowlessControl_GetColorKey
1909 static HRESULT WINAPI
VMR9WindowlessControl_QueryInterface(IVMRWindowlessControl9
*iface
, REFIID riid
, LPVOID
* ppv
)
1911 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1912 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1915 static ULONG WINAPI
VMR9WindowlessControl_AddRef(IVMRWindowlessControl9
*iface
)
1917 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1918 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1921 static ULONG WINAPI
VMR9WindowlessControl_Release(IVMRWindowlessControl9
*iface
)
1923 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1924 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1927 static HRESULT WINAPI
VMR9WindowlessControl_GetNativeVideoSize(IVMRWindowlessControl9
*iface
, LONG
*width
, LONG
*height
, LONG
*arwidth
, LONG
*arheight
)
1929 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1930 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", iface
, This
, width
, height
, arwidth
, arheight
);
1932 if (!width
|| !height
|| !arwidth
|| !arheight
)
1934 ERR("Got no pointer\n");
1938 *width
= This
->bmiheader
.biWidth
;
1939 *height
= This
->bmiheader
.biHeight
;
1940 *arwidth
= This
->bmiheader
.biWidth
;
1941 *arheight
= This
->bmiheader
.biHeight
;
1946 static HRESULT WINAPI
VMR9WindowlessControl_GetMinIdealVideoSize(IVMRWindowlessControl9
*iface
, LONG
*width
, LONG
*height
)
1948 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1950 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1954 static HRESULT WINAPI
VMR9WindowlessControl_GetMaxIdealVideoSize(IVMRWindowlessControl9
*iface
, LONG
*width
, LONG
*height
)
1956 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1958 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1962 static HRESULT WINAPI
VMR9WindowlessControl_SetVideoPosition(IVMRWindowlessControl9
*iface
, const RECT
*source
, const RECT
*dest
)
1964 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1966 TRACE("(%p/%p)->(%p, %p)\n", iface
, This
, source
, dest
);
1968 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1971 This
->source_rect
= *source
;
1974 This
->target_rect
= *dest
;
1975 if (This
->baseControlWindow
.baseWindow
.hWnd
)
1977 FIXME("Output rectangle: starting at %dx%d, up to point %dx%d\n", dest
->left
, dest
->top
, dest
->right
, dest
->bottom
);
1978 SetWindowPos(This
->baseControlWindow
.baseWindow
.hWnd
, NULL
, dest
->left
, dest
->top
, dest
->right
- dest
->left
,
1979 dest
->bottom
-dest
->top
, SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOOWNERZORDER
|SWP_NOREDRAW
);
1983 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1988 static HRESULT WINAPI
VMR9WindowlessControl_GetVideoPosition(IVMRWindowlessControl9
*iface
, RECT
*source
, RECT
*dest
)
1990 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1993 *source
= This
->source_rect
;
1996 *dest
= This
->target_rect
;
1998 FIXME("(%p/%p)->(%p/%p) stub\n", iface
, This
, source
, dest
);
2002 static HRESULT WINAPI
VMR9WindowlessControl_GetAspectRatioMode(IVMRWindowlessControl9
*iface
, DWORD
*mode
)
2004 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2006 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2010 static HRESULT WINAPI
VMR9WindowlessControl_SetAspectRatioMode(IVMRWindowlessControl9
*iface
, DWORD mode
)
2012 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2014 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2018 static HRESULT WINAPI
VMR9WindowlessControl_SetVideoClippingWindow(IVMRWindowlessControl9
*iface
, HWND hwnd
)
2020 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2022 TRACE("(%p/%p)->(%p)\n", iface
, This
, hwnd
);
2024 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
2025 This
->hWndClippingWindow
= hwnd
;
2026 VMR9_maybe_init(This
, FALSE
);
2028 IVMRSurfaceAllocatorEx9_TerminateDevice(This
->allocator
, This
->cookie
);
2029 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
2033 static HRESULT WINAPI
VMR9WindowlessControl_RepaintVideo(IVMRWindowlessControl9
*iface
, HWND hwnd
, HDC hdc
)
2035 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2038 FIXME("(%p/%p)->(...) semi-stub\n", iface
, This
);
2040 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
2041 if (hwnd
!= This
->hWndClippingWindow
&& hwnd
!= This
->baseControlWindow
.baseWindow
.hWnd
)
2043 ERR("Not handling changing windows yet!!!\n");
2044 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
2048 if (!This
->allocator_d3d9_dev
)
2050 ERR("No d3d9 device!\n");
2051 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
2052 return VFW_E_WRONG_STATE
;
2055 /* Windowless extension */
2056 hr
= IDirect3DDevice9_Present(This
->allocator_d3d9_dev
, NULL
, NULL
, This
->baseControlWindow
.baseWindow
.hWnd
, NULL
);
2057 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
2062 static HRESULT WINAPI
VMR9WindowlessControl_DisplayModeChanged(IVMRWindowlessControl9
*iface
)
2064 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2066 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2070 static HRESULT WINAPI
VMR9WindowlessControl_GetCurrentImage(IVMRWindowlessControl9
*iface
, BYTE
**dib
)
2072 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2074 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2078 static HRESULT WINAPI
VMR9WindowlessControl_SetBorderColor(IVMRWindowlessControl9
*iface
, COLORREF color
)
2080 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2082 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2086 static HRESULT WINAPI
VMR9WindowlessControl_GetBorderColor(IVMRWindowlessControl9
*iface
, COLORREF
*color
)
2088 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2090 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2094 static const IVMRWindowlessControl9Vtbl VMR9_WindowlessControl_Vtbl
=
2096 VMR9WindowlessControl_QueryInterface
,
2097 VMR9WindowlessControl_AddRef
,
2098 VMR9WindowlessControl_Release
,
2099 VMR9WindowlessControl_GetNativeVideoSize
,
2100 VMR9WindowlessControl_GetMinIdealVideoSize
,
2101 VMR9WindowlessControl_GetMaxIdealVideoSize
,
2102 VMR9WindowlessControl_SetVideoPosition
,
2103 VMR9WindowlessControl_GetVideoPosition
,
2104 VMR9WindowlessControl_GetAspectRatioMode
,
2105 VMR9WindowlessControl_SetAspectRatioMode
,
2106 VMR9WindowlessControl_SetVideoClippingWindow
,
2107 VMR9WindowlessControl_RepaintVideo
,
2108 VMR9WindowlessControl_DisplayModeChanged
,
2109 VMR9WindowlessControl_GetCurrentImage
,
2110 VMR9WindowlessControl_SetBorderColor
,
2111 VMR9WindowlessControl_GetBorderColor
2114 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_QueryInterface(IVMRSurfaceAllocatorNotify
*iface
,
2115 REFIID riid
, LPVOID
* ppv
)
2117 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2118 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
2121 static ULONG WINAPI
VMR7SurfaceAllocatorNotify_AddRef(IVMRSurfaceAllocatorNotify
*iface
)
2123 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2124 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
2127 static ULONG WINAPI
VMR7SurfaceAllocatorNotify_Release(IVMRSurfaceAllocatorNotify
*iface
)
2129 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2130 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
2133 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_AdviseSurfaceAllocator(IVMRSurfaceAllocatorNotify
*iface
,
2135 IVMRSurfaceAllocator
*alloc
)
2137 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2139 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2143 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_SetDDrawDevice(IVMRSurfaceAllocatorNotify
*iface
,
2144 IDirectDraw7
*device
, HMONITOR monitor
)
2146 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2148 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2152 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_ChangeDDrawDevice(IVMRSurfaceAllocatorNotify
*iface
,
2153 IDirectDraw7
*device
, HMONITOR monitor
)
2155 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2157 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2161 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_RestoreDDrawSurfaces(IVMRSurfaceAllocatorNotify
*iface
)
2163 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2165 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2169 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_NotifyEvent(IVMRSurfaceAllocatorNotify
*iface
, LONG code
,
2170 LONG_PTR param1
, LONG_PTR param2
)
2172 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2174 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2178 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_SetBorderColor(IVMRSurfaceAllocatorNotify
*iface
,
2181 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2183 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2187 static const IVMRSurfaceAllocatorNotifyVtbl VMR7_SurfaceAllocatorNotify_Vtbl
=
2189 VMR7SurfaceAllocatorNotify_QueryInterface
,
2190 VMR7SurfaceAllocatorNotify_AddRef
,
2191 VMR7SurfaceAllocatorNotify_Release
,
2192 VMR7SurfaceAllocatorNotify_AdviseSurfaceAllocator
,
2193 VMR7SurfaceAllocatorNotify_SetDDrawDevice
,
2194 VMR7SurfaceAllocatorNotify_ChangeDDrawDevice
,
2195 VMR7SurfaceAllocatorNotify_RestoreDDrawSurfaces
,
2196 VMR7SurfaceAllocatorNotify_NotifyEvent
,
2197 VMR7SurfaceAllocatorNotify_SetBorderColor
2200 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_QueryInterface(IVMRSurfaceAllocatorNotify9
*iface
, REFIID riid
, LPVOID
* ppv
)
2202 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2203 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
2206 static ULONG WINAPI
VMR9SurfaceAllocatorNotify_AddRef(IVMRSurfaceAllocatorNotify9
*iface
)
2208 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2209 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
2212 static ULONG WINAPI
VMR9SurfaceAllocatorNotify_Release(IVMRSurfaceAllocatorNotify9
*iface
)
2214 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2215 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
2218 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_AdviseSurfaceAllocator(IVMRSurfaceAllocatorNotify9
*iface
, DWORD_PTR id
, IVMRSurfaceAllocator9
*alloc
)
2220 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2222 /* FIXME: This code is not tested!!! */
2223 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2226 if (This
->presenter
)
2227 return VFW_E_WRONG_STATE
;
2229 if (FAILED(IVMRSurfaceAllocator9_QueryInterface(alloc
, &IID_IVMRImagePresenter9
, (void **)&This
->presenter
)))
2230 return E_NOINTERFACE
;
2232 if (SUCCEEDED(IVMRSurfaceAllocator9_QueryInterface(alloc
, &IID_IVMRSurfaceAllocatorEx9
, (void **)&This
->allocator
)))
2233 This
->allocator_is_ex
= 1;
2236 This
->allocator
= (IVMRSurfaceAllocatorEx9
*)alloc
;
2237 IVMRSurfaceAllocator9_AddRef(alloc
);
2238 This
->allocator_is_ex
= 0;
2244 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_SetD3DDevice(IVMRSurfaceAllocatorNotify9
*iface
, IDirect3DDevice9
*device
, HMONITOR monitor
)
2246 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2248 FIXME("(%p/%p)->(...) semi-stub\n", iface
, This
);
2249 if (This
->allocator_d3d9_dev
)
2250 IDirect3DDevice9_Release(This
->allocator_d3d9_dev
);
2251 This
->allocator_d3d9_dev
= device
;
2252 IDirect3DDevice9_AddRef(This
->allocator_d3d9_dev
);
2253 This
->allocator_mon
= monitor
;
2258 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_ChangeD3DDevice(IVMRSurfaceAllocatorNotify9
*iface
, IDirect3DDevice9
*device
, HMONITOR monitor
)
2260 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2262 FIXME("(%p/%p)->(...) semi-stub\n", iface
, This
);
2263 if (This
->allocator_d3d9_dev
)
2264 IDirect3DDevice9_Release(This
->allocator_d3d9_dev
);
2265 This
->allocator_d3d9_dev
= device
;
2266 IDirect3DDevice9_AddRef(This
->allocator_d3d9_dev
);
2267 This
->allocator_mon
= monitor
;
2272 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_AllocateSurfaceHelper(IVMRSurfaceAllocatorNotify9
*iface
, VMR9AllocationInfo
*allocinfo
, DWORD
*numbuffers
, IDirect3DSurface9
**surface
)
2274 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2278 FIXME("(%p/%p)->(%p, %p => %u, %p) semi-stub\n", iface
, This
, allocinfo
, numbuffers
, (numbuffers
? *numbuffers
: 0), surface
);
2280 if (!allocinfo
|| !numbuffers
|| !surface
)
2283 if (!*numbuffers
|| *numbuffers
< allocinfo
->MinBuffers
)
2285 ERR("Invalid number of buffers?\n");
2286 return E_INVALIDARG
;
2289 if (!This
->allocator_d3d9_dev
)
2291 ERR("No direct3d device when requested to allocate a surface!\n");
2292 return VFW_E_WRONG_STATE
;
2295 if (allocinfo
->dwFlags
& VMR9AllocFlag_OffscreenSurface
)
2297 ERR("Creating offscreen surface\n");
2298 for (i
= 0; i
< *numbuffers
; ++i
)
2300 hr
= IDirect3DDevice9_CreateOffscreenPlainSurface(This
->allocator_d3d9_dev
, allocinfo
->dwWidth
, allocinfo
->dwHeight
,
2301 allocinfo
->Format
, allocinfo
->Pool
, &surface
[i
], NULL
);
2306 else if (allocinfo
->dwFlags
& VMR9AllocFlag_TextureSurface
)
2308 TRACE("Creating texture surface\n");
2309 for (i
= 0; i
< *numbuffers
; ++i
)
2311 IDirect3DTexture9
*texture
;
2313 hr
= IDirect3DDevice9_CreateTexture(This
->allocator_d3d9_dev
, allocinfo
->dwWidth
, allocinfo
->dwHeight
, 1, 0,
2314 allocinfo
->Format
, allocinfo
->Pool
, &texture
, NULL
);
2317 IDirect3DTexture9_GetSurfaceLevel(texture
, 0, &surface
[i
]);
2318 IDirect3DTexture9_Release(texture
);
2323 FIXME("Could not allocate for type %08x\n", allocinfo
->dwFlags
);
2327 if (i
>= allocinfo
->MinBuffers
)
2334 for ( ; i
> 0; --i
) IDirect3DSurface9_Release(surface
[i
- 1]);
2340 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_NotifyEvent(IVMRSurfaceAllocatorNotify9
*iface
, LONG code
, LONG_PTR param1
, LONG_PTR param2
)
2342 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2344 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2348 static const IVMRSurfaceAllocatorNotify9Vtbl VMR9_SurfaceAllocatorNotify_Vtbl
=
2350 VMR9SurfaceAllocatorNotify_QueryInterface
,
2351 VMR9SurfaceAllocatorNotify_AddRef
,
2352 VMR9SurfaceAllocatorNotify_Release
,
2353 VMR9SurfaceAllocatorNotify_AdviseSurfaceAllocator
,
2354 VMR9SurfaceAllocatorNotify_SetD3DDevice
,
2355 VMR9SurfaceAllocatorNotify_ChangeD3DDevice
,
2356 VMR9SurfaceAllocatorNotify_AllocateSurfaceHelper
,
2357 VMR9SurfaceAllocatorNotify_NotifyEvent
2360 static HRESULT
vmr_create(IUnknown
*outer_unk
, LPVOID
*ppv
, const CLSID
*clsid
)
2363 struct quartz_vmr
* pVMR
;
2365 TRACE("(%p, %p)\n", outer_unk
, ppv
);
2369 pVMR
= CoTaskMemAlloc(sizeof(struct quartz_vmr
));
2371 pVMR
->hD3d9
= LoadLibraryA("d3d9.dll");
2374 WARN("Could not load d3d9.dll\n");
2375 CoTaskMemFree(pVMR
);
2376 return VFW_E_DDRAW_CAPS_NOT_SUITABLE
;
2379 pVMR
->outer_unk
= outer_unk
;
2380 pVMR
->bUnkOuterValid
= FALSE
;
2381 pVMR
->bAggregatable
= FALSE
;
2382 pVMR
->IUnknown_inner
.lpVtbl
= &IInner_VTable
;
2383 pVMR
->IAMCertifiedOutputProtection_iface
.lpVtbl
= &IAMCertifiedOutputProtection_Vtbl
;
2384 pVMR
->IAMFilterMiscFlags_iface
.lpVtbl
= &IAMFilterMiscFlags_Vtbl
;
2387 pVMR
->allocator_d3d9_dev
= NULL
;
2388 pVMR
->allocator_mon
= NULL
;
2389 pVMR
->num_surfaces
= pVMR
->cur_surface
= 0;
2390 pVMR
->allocator
= NULL
;
2391 pVMR
->presenter
= NULL
;
2392 pVMR
->hWndClippingWindow
= NULL
;
2393 pVMR
->IVMRFilterConfig_iface
.lpVtbl
= &VMR7_FilterConfig_Vtbl
;
2394 pVMR
->IVMRFilterConfig9_iface
.lpVtbl
= &VMR9_FilterConfig_Vtbl
;
2395 pVMR
->IVMRMonitorConfig_iface
.lpVtbl
= &VMR7_MonitorConfig_Vtbl
;
2396 pVMR
->IVMRMonitorConfig9_iface
.lpVtbl
= &VMR9_MonitorConfig_Vtbl
;
2397 pVMR
->IVMRSurfaceAllocatorNotify_iface
.lpVtbl
= &VMR7_SurfaceAllocatorNotify_Vtbl
;
2398 pVMR
->IVMRSurfaceAllocatorNotify9_iface
.lpVtbl
= &VMR9_SurfaceAllocatorNotify_Vtbl
;
2399 pVMR
->IVMRWindowlessControl_iface
.lpVtbl
= &VMR7_WindowlessControl_Vtbl
;
2400 pVMR
->IVMRWindowlessControl9_iface
.lpVtbl
= &VMR9_WindowlessControl_Vtbl
;
2402 if (IsEqualGUID(clsid
, &CLSID_VideoMixingRenderer
))
2403 hr
= BaseRenderer_Init(&pVMR
->renderer
, &VMR_Vtbl
, outer_unk
, &CLSID_VideoMixingRenderer
,
2404 (DWORD_PTR
)(__FILE__
": VMR7Impl.csFilter"), &BaseFuncTable
);
2406 hr
= BaseRenderer_Init(&pVMR
->renderer
, &VMR_Vtbl
, outer_unk
, &CLSID_VideoMixingRenderer9
,
2407 (DWORD_PTR
)(__FILE__
": VMR9Impl.csFilter"), &BaseFuncTable
);
2412 hr
= BaseControlWindow_Init(&pVMR
->baseControlWindow
, &IVideoWindow_VTable
, &pVMR
->renderer
.filter
,
2413 &pVMR
->renderer
.filter
.csFilter
, &pVMR
->renderer
.pInputPin
->pin
,
2414 &renderer_BaseWindowFuncTable
);
2418 hr
= BaseControlVideo_Init(&pVMR
->baseControlVideo
, &IBasicVideo_VTable
, &pVMR
->renderer
.filter
,
2419 &pVMR
->renderer
.filter
.csFilter
, &pVMR
->renderer
.pInputPin
->pin
,
2420 &renderer_BaseControlVideoFuncTable
);
2424 *ppv
= (LPVOID
)pVMR
;
2425 ZeroMemory(&pVMR
->source_rect
, sizeof(RECT
));
2426 ZeroMemory(&pVMR
->target_rect
, sizeof(RECT
));
2427 TRACE("Created at %p\n", pVMR
);
2431 BaseRendererImpl_Release(&pVMR
->renderer
.filter
.IBaseFilter_iface
);
2432 FreeLibrary(pVMR
->hD3d9
);
2433 CoTaskMemFree(pVMR
);
2437 HRESULT
VMR7Impl_create(IUnknown
*outer_unk
, LPVOID
*ppv
)
2439 return vmr_create(outer_unk
, ppv
, &CLSID_VideoMixingRenderer
);
2442 HRESULT
VMR9Impl_create(IUnknown
*outer_unk
, LPVOID
*ppv
)
2444 return vmr_create(outer_unk
, ppv
, &CLSID_VideoMixingRenderer9
);
2448 static HRESULT WINAPI
VMR9_ImagePresenter_QueryInterface(IVMRImagePresenter9
*iface
, REFIID riid
, LPVOID
* ppv
)
2450 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2451 TRACE("(%p/%p)->(%s, %p)\n", This
, iface
, qzdebugstr_guid(riid
), ppv
);
2455 if (IsEqualIID(riid
, &IID_IUnknown
))
2456 *ppv
= (LPVOID
)&(This
->IVMRImagePresenter9_iface
);
2457 else if (IsEqualIID(riid
, &IID_IVMRImagePresenter9
))
2458 *ppv
= &This
->IVMRImagePresenter9_iface
;
2459 else if (IsEqualIID(riid
, &IID_IVMRSurfaceAllocatorEx9
))
2460 *ppv
= &This
->IVMRSurfaceAllocatorEx9_iface
;
2464 IUnknown_AddRef((IUnknown
*)(*ppv
));
2468 FIXME("No interface for %s\n", debugstr_guid(riid
));
2470 return E_NOINTERFACE
;
2473 static ULONG WINAPI
VMR9_ImagePresenter_AddRef(IVMRImagePresenter9
*iface
)
2475 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2476 ULONG refCount
= InterlockedIncrement(&This
->refCount
);
2478 TRACE("(%p)->() AddRef from %d\n", iface
, refCount
- 1);
2483 static ULONG WINAPI
VMR9_ImagePresenter_Release(IVMRImagePresenter9
*iface
)
2485 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2486 ULONG refCount
= InterlockedDecrement(&This
->refCount
);
2488 TRACE("(%p)->() Release from %d\n", iface
, refCount
+ 1);
2493 TRACE("Destroying\n");
2494 CloseHandle(This
->ack
);
2495 IDirect3D9_Release(This
->d3d9_ptr
);
2497 TRACE("Number of surfaces: %u\n", This
->num_surfaces
);
2498 for (i
= 0; i
< This
->num_surfaces
; ++i
)
2500 IDirect3DSurface9
*surface
= This
->d3d9_surfaces
[i
];
2501 TRACE("Releasing surface %p\n", surface
);
2503 IDirect3DSurface9_Release(surface
);
2506 CoTaskMemFree(This
->d3d9_surfaces
);
2507 This
->d3d9_surfaces
= NULL
;
2508 This
->num_surfaces
= 0;
2509 if (This
->d3d9_vertex
)
2511 IDirect3DVertexBuffer9_Release(This
->d3d9_vertex
);
2512 This
->d3d9_vertex
= NULL
;
2514 CoTaskMemFree(This
);
2520 static HRESULT WINAPI
VMR9_ImagePresenter_StartPresenting(IVMRImagePresenter9
*iface
, DWORD_PTR id
)
2522 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2524 TRACE("(%p/%p/%p)->(...) stub\n", iface
, This
,This
->pVMR9
);
2528 static HRESULT WINAPI
VMR9_ImagePresenter_StopPresenting(IVMRImagePresenter9
*iface
, DWORD_PTR id
)
2530 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2532 TRACE("(%p/%p/%p)->(...) stub\n", iface
, This
,This
->pVMR9
);
2536 #define USED_FVF (D3DFVF_XYZRHW | D3DFVF_TEX1)
2537 struct VERTEX
{ float x
, y
, z
, rhw
, u
, v
; };
2539 static HRESULT
VMR9_ImagePresenter_PresentTexture(VMR9DefaultAllocatorPresenterImpl
*This
, IDirect3DSurface9
*surface
)
2541 IDirect3DTexture9
*texture
= NULL
;
2544 hr
= IDirect3DDevice9_SetFVF(This
->d3d9_dev
, USED_FVF
);
2547 FIXME("SetFVF: %08x\n", hr
);
2551 hr
= IDirect3DDevice9_SetStreamSource(This
->d3d9_dev
, 0, This
->d3d9_vertex
, 0, sizeof(struct VERTEX
));
2554 FIXME("SetStreamSource: %08x\n", hr
);
2558 hr
= IDirect3DSurface9_GetContainer(surface
, &IID_IDirect3DTexture9
, (void **) &texture
);
2561 FIXME("IDirect3DSurface9_GetContainer failed\n");
2564 hr
= IDirect3DDevice9_SetTexture(This
->d3d9_dev
, 0, (IDirect3DBaseTexture9
*)texture
);
2565 IDirect3DTexture9_Release(texture
);
2568 FIXME("SetTexture: %08x\n", hr
);
2572 hr
= IDirect3DDevice9_DrawPrimitive(This
->d3d9_dev
, D3DPT_TRIANGLESTRIP
, 0, 2);
2575 FIXME("DrawPrimitive: %08x\n", hr
);
2582 static HRESULT
VMR9_ImagePresenter_PresentOffscreenSurface(VMR9DefaultAllocatorPresenterImpl
*This
, IDirect3DSurface9
*surface
)
2585 IDirect3DSurface9
*target
= NULL
;
2588 hr
= IDirect3DDevice9_GetBackBuffer(This
->d3d9_dev
, 0, 0, D3DBACKBUFFER_TYPE_MONO
, &target
);
2591 ERR("IDirect3DDevice9_GetBackBuffer -- %08x\n", hr
);
2595 target_rect
= This
->pVMR9
->target_rect
;
2596 target_rect
.right
-= target_rect
.left
;
2597 target_rect
.bottom
-= target_rect
.top
;
2598 target_rect
.left
= target_rect
.top
= 0;
2601 target_rect
.top
= target_rect
.bottom
;
2602 target_rect
.bottom
= 0;
2604 hr
= IDirect3DDevice9_StretchRect(This
->d3d9_dev
, surface
, &This
->pVMR9
->source_rect
, target
, &target_rect
, D3DTEXF_LINEAR
);
2606 ERR("IDirect3DDevice9_StretchRect -- %08x\n", hr
);
2607 IDirect3DSurface9_Release(target
);
2612 static HRESULT WINAPI
VMR9_ImagePresenter_PresentImage(IVMRImagePresenter9
*iface
, DWORD_PTR id
, VMR9PresentationInfo
*info
)
2614 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2617 BOOL render
= FALSE
;
2619 TRACE("(%p/%p/%p)->(...) stub\n", iface
, This
, This
->pVMR9
);
2620 GetWindowRect(This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, &output
);
2621 TRACE("Output rectangle: starting at %dx%d, up to point %dx%d\n", output
.left
, output
.top
, output
.right
, output
.bottom
);
2623 /* This might happen if we don't have active focus (eg on a different virtual desktop) */
2624 if (!This
->d3d9_dev
)
2627 /* Display image here */
2628 hr
= IDirect3DDevice9_Clear(This
->d3d9_dev
, 0, NULL
, D3DCLEAR_TARGET
, D3DCOLOR_XRGB(0, 0, 0), 1.0f
, 0);
2630 FIXME("hr: %08x\n", hr
);
2631 hr
= IDirect3DDevice9_BeginScene(This
->d3d9_dev
);
2634 if (This
->d3d9_vertex
)
2635 hr
= VMR9_ImagePresenter_PresentTexture(This
, info
->lpSurf
);
2637 hr
= VMR9_ImagePresenter_PresentOffscreenSurface(This
, info
->lpSurf
);
2638 render
= SUCCEEDED(hr
);
2641 FIXME("BeginScene: %08x\n", hr
);
2642 hr
= IDirect3DDevice9_EndScene(This
->d3d9_dev
);
2643 if (render
&& SUCCEEDED(hr
))
2645 hr
= IDirect3DDevice9_Present(This
->d3d9_dev
, NULL
, NULL
, This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, NULL
);
2647 FIXME("Presenting image: %08x\n", hr
);
2653 static const IVMRImagePresenter9Vtbl VMR9_ImagePresenter
=
2655 VMR9_ImagePresenter_QueryInterface
,
2656 VMR9_ImagePresenter_AddRef
,
2657 VMR9_ImagePresenter_Release
,
2658 VMR9_ImagePresenter_StartPresenting
,
2659 VMR9_ImagePresenter_StopPresenting
,
2660 VMR9_ImagePresenter_PresentImage
2663 static HRESULT WINAPI
VMR9_SurfaceAllocator_QueryInterface(IVMRSurfaceAllocatorEx9
*iface
, REFIID riid
, LPVOID
* ppv
)
2665 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2667 return VMR9_ImagePresenter_QueryInterface(&This
->IVMRImagePresenter9_iface
, riid
, ppv
);
2670 static ULONG WINAPI
VMR9_SurfaceAllocator_AddRef(IVMRSurfaceAllocatorEx9
*iface
)
2672 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2674 return VMR9_ImagePresenter_AddRef(&This
->IVMRImagePresenter9_iface
);
2677 static ULONG WINAPI
VMR9_SurfaceAllocator_Release(IVMRSurfaceAllocatorEx9
*iface
)
2679 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2681 return VMR9_ImagePresenter_Release(&This
->IVMRImagePresenter9_iface
);
2684 static HRESULT
VMR9_SurfaceAllocator_SetAllocationSettings(VMR9DefaultAllocatorPresenterImpl
*This
, VMR9AllocationInfo
*allocinfo
)
2690 if (!(allocinfo
->dwFlags
& VMR9AllocFlag_TextureSurface
))
2691 /* Only needed for texture surfaces */
2694 hr
= IDirect3DDevice9_GetDeviceCaps(This
->d3d9_dev
, &caps
);
2698 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_POW2
) || (caps
.TextureCaps
& D3DPTEXTURECAPS_SQUAREONLY
))
2700 width
= allocinfo
->dwWidth
;
2701 height
= allocinfo
->dwHeight
;
2706 while (width
< allocinfo
->dwWidth
)
2709 while (height
< allocinfo
->dwHeight
)
2711 FIXME("NPOW2 support missing, not using proper surfaces!\n");
2714 if (caps
.TextureCaps
& D3DPTEXTURECAPS_SQUAREONLY
)
2720 FIXME("Square texture support required..\n");
2723 hr
= IDirect3DDevice9_CreateVertexBuffer(This
->d3d9_dev
, 4 * sizeof(struct VERTEX
), D3DUSAGE_WRITEONLY
, USED_FVF
, allocinfo
->Pool
, &This
->d3d9_vertex
, NULL
);
2726 ERR("Couldn't create vertex buffer: %08x\n", hr
);
2731 allocinfo
->dwHeight
= height
;
2732 allocinfo
->dwWidth
= width
;
2737 static DWORD WINAPI
MessageLoop(LPVOID lpParameter
)
2741 VMR9DefaultAllocatorPresenterImpl
*This
= lpParameter
;
2743 TRACE("Starting message loop\n");
2745 if (FAILED(BaseWindowImpl_PrepareWindow(&This
->pVMR9
->baseControlWindow
.baseWindow
)))
2747 FIXME("Failed to prepare window\n");
2751 SetEvent(This
->ack
);
2752 while ((fGotMessage
= GetMessageW(&msg
, NULL
, 0, 0)) != 0 && fGotMessage
!= -1)
2754 TranslateMessage(&msg
);
2755 DispatchMessageW(&msg
);
2758 TRACE("End of message loop\n");
2763 static UINT
d3d9_adapter_from_hwnd(IDirect3D9
*d3d9
, HWND hwnd
, HMONITOR
*mon_out
)
2768 mon
= MonitorFromWindow(hwnd
, MONITOR_DEFAULTTONULL
);
2773 for (d3d9_adapter
= 0; d3d9_adapter
< IDirect3D9_GetAdapterCount(d3d9
); ++d3d9_adapter
)
2775 if (mon
== IDirect3D9_GetAdapterMonitor(d3d9
, d3d9_adapter
))
2778 if (d3d9_adapter
>= IDirect3D9_GetAdapterCount(d3d9
))
2783 return d3d9_adapter
;
2786 static BOOL
CreateRenderingWindow(VMR9DefaultAllocatorPresenterImpl
*This
, VMR9AllocationInfo
*info
, DWORD
*numbuffers
)
2788 D3DPRESENT_PARAMETERS d3dpp
;
2792 TRACE("(%p)->()\n", This
);
2794 This
->hWndThread
= CreateThread(NULL
, 0, MessageLoop
, This
, 0, &This
->tid
);
2795 if (!This
->hWndThread
)
2798 WaitForSingleObject(This
->ack
, INFINITE
);
2800 if (!This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
) return FALSE
;
2802 /* Obtain a monitor and d3d9 device */
2803 d3d9_adapter
= d3d9_adapter_from_hwnd(This
->d3d9_ptr
, This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, &This
->hMon
);
2805 /* Now try to create the d3d9 device */
2806 ZeroMemory(&d3dpp
, sizeof(d3dpp
));
2807 d3dpp
.Windowed
= TRUE
;
2808 d3dpp
.hDeviceWindow
= This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
;
2809 d3dpp
.SwapEffect
= D3DSWAPEFFECT_DISCARD
;
2810 d3dpp
.BackBufferHeight
= This
->pVMR9
->target_rect
.bottom
- This
->pVMR9
->target_rect
.top
;
2811 d3dpp
.BackBufferWidth
= This
->pVMR9
->target_rect
.right
- This
->pVMR9
->target_rect
.left
;
2813 hr
= IDirect3D9_CreateDevice(This
->d3d9_ptr
, d3d9_adapter
, D3DDEVTYPE_HAL
, NULL
, D3DCREATE_MIXED_VERTEXPROCESSING
, &d3dpp
, &This
->d3d9_dev
);
2816 ERR("Could not create device: %08x\n", hr
);
2817 BaseWindowImpl_DoneWithWindow(&This
->pVMR9
->baseControlWindow
.baseWindow
);
2820 IVMRSurfaceAllocatorNotify9_SetD3DDevice(This
->SurfaceAllocatorNotify
, This
->d3d9_dev
, This
->hMon
);
2822 This
->d3d9_surfaces
= CoTaskMemAlloc(*numbuffers
* sizeof(IDirect3DSurface9
*));
2823 ZeroMemory(This
->d3d9_surfaces
, *numbuffers
* sizeof(IDirect3DSurface9
*));
2825 hr
= VMR9_SurfaceAllocator_SetAllocationSettings(This
, info
);
2827 ERR("Setting allocation settings failed: %08x\n", hr
);
2831 hr
= IVMRSurfaceAllocatorNotify9_AllocateSurfaceHelper(This
->SurfaceAllocatorNotify
, info
, numbuffers
, This
->d3d9_surfaces
);
2833 ERR("Allocating surfaces failed: %08x\n", hr
);
2838 IVMRSurfaceAllocatorEx9_TerminateDevice(This
->pVMR9
->allocator
, This
->pVMR9
->cookie
);
2839 BaseWindowImpl_DoneWithWindow(&This
->pVMR9
->baseControlWindow
.baseWindow
);
2843 This
->num_surfaces
= *numbuffers
;
2848 static HRESULT WINAPI
VMR9_SurfaceAllocator_InitializeDevice(IVMRSurfaceAllocatorEx9
*iface
, DWORD_PTR id
, VMR9AllocationInfo
*allocinfo
, DWORD
*numbuffers
)
2850 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2852 if (This
->pVMR9
->mode
!= VMR9Mode_Windowed
&& !This
->pVMR9
->hWndClippingWindow
)
2854 ERR("No window set\n");
2855 return VFW_E_WRONG_STATE
;
2858 This
->info
= *allocinfo
;
2860 if (!CreateRenderingWindow(This
, allocinfo
, numbuffers
))
2862 ERR("Failed to create rendering window, expect no output!\n");
2863 return VFW_E_WRONG_STATE
;
2869 static HRESULT WINAPI
VMR9_SurfaceAllocator_TerminateDevice(IVMRSurfaceAllocatorEx9
*iface
, DWORD_PTR id
)
2871 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2873 if (!This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
)
2878 SendMessageW(This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, WM_CLOSE
, 0, 0);
2879 PostThreadMessageW(This
->tid
, WM_QUIT
, 0, 0);
2880 WaitForSingleObject(This
->hWndThread
, INFINITE
);
2881 This
->hWndThread
= NULL
;
2882 BaseWindowImpl_DoneWithWindow(&This
->pVMR9
->baseControlWindow
.baseWindow
);
2887 /* Recreate all surfaces (If allocated as D3DPOOL_DEFAULT) and survive! */
2888 static HRESULT
VMR9_SurfaceAllocator_UpdateDeviceReset(VMR9DefaultAllocatorPresenterImpl
*This
)
2890 struct VERTEX t_vert
[4];
2894 D3DPRESENT_PARAMETERS d3dpp
;
2897 if (!This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
)
2903 if (!This
->d3d9_surfaces
|| !This
->reset
)
2906 This
->reset
= FALSE
;
2907 TRACE("RESETTING\n");
2908 if (This
->d3d9_vertex
)
2910 IDirect3DVertexBuffer9_Release(This
->d3d9_vertex
);
2911 This
->d3d9_vertex
= NULL
;
2914 for (i
= 0; i
< This
->num_surfaces
; ++i
)
2916 IDirect3DSurface9
*surface
= This
->d3d9_surfaces
[i
];
2917 TRACE("Releasing surface %p\n", surface
);
2919 IDirect3DSurface9_Release(surface
);
2921 ZeroMemory(This
->d3d9_surfaces
, sizeof(IDirect3DSurface9
*) * This
->num_surfaces
);
2923 /* Now try to create the d3d9 device */
2924 ZeroMemory(&d3dpp
, sizeof(d3dpp
));
2925 d3dpp
.Windowed
= TRUE
;
2926 d3dpp
.hDeviceWindow
= This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
;
2927 d3dpp
.SwapEffect
= D3DSWAPEFFECT_DISCARD
;
2930 IDirect3DDevice9_Release(This
->d3d9_dev
);
2931 This
->d3d9_dev
= NULL
;
2932 hr
= IDirect3D9_CreateDevice(This
->d3d9_ptr
, d3d9_adapter_from_hwnd(This
->d3d9_ptr
, This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, &This
->hMon
), D3DDEVTYPE_HAL
, NULL
, D3DCREATE_HARDWARE_VERTEXPROCESSING
, &d3dpp
, &This
->d3d9_dev
);
2935 hr
= IDirect3D9_CreateDevice(This
->d3d9_ptr
, d3d9_adapter_from_hwnd(This
->d3d9_ptr
, This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, &This
->hMon
), D3DDEVTYPE_HAL
, NULL
, D3DCREATE_MIXED_VERTEXPROCESSING
, &d3dpp
, &This
->d3d9_dev
);
2938 ERR("--> Creating device: %08x\n", hr
);
2942 IVMRSurfaceAllocatorNotify9_ChangeD3DDevice(This
->SurfaceAllocatorNotify
, This
->d3d9_dev
, This
->hMon
);
2944 IVMRSurfaceAllocatorNotify9_AllocateSurfaceHelper(This
->SurfaceAllocatorNotify
, &This
->info
, &This
->num_surfaces
, This
->d3d9_surfaces
);
2946 This
->reset
= FALSE
;
2948 if (!(This
->info
.dwFlags
& VMR9AllocFlag_TextureSurface
))
2951 hr
= IDirect3DDevice9_CreateVertexBuffer(This
->d3d9_dev
, 4 * sizeof(struct VERTEX
), D3DUSAGE_WRITEONLY
, USED_FVF
,
2952 This
->info
.Pool
, &This
->d3d9_vertex
, NULL
);
2954 width
= This
->info
.dwWidth
;
2955 height
= This
->info
.dwHeight
;
2957 for (i
= 0; i
< sizeof(t_vert
) / sizeof(t_vert
[0]); ++i
)
2961 t_vert
[i
].x
= (float)This
->pVMR9
->target_rect
.right
- (float)This
->pVMR9
->target_rect
.left
- 0.5f
;
2962 t_vert
[i
].u
= (float)This
->pVMR9
->source_rect
.right
/ (float)width
;
2966 t_vert
[i
].x
= -0.5f
;
2967 t_vert
[i
].u
= (float)This
->pVMR9
->source_rect
.left
/ (float)width
;
2972 t_vert
[i
].y
= -0.5f
;
2973 t_vert
[i
].v
= (float)This
->pVMR9
->source_rect
.bottom
/ (float)height
;
2977 t_vert
[i
].y
= (float)This
->pVMR9
->target_rect
.bottom
- (float)This
->pVMR9
->target_rect
.top
- 0.5f
;
2978 t_vert
[i
].v
= (float)This
->pVMR9
->source_rect
.top
/ (float)height
;
2981 t_vert
[i
].rhw
= 1.0f
;
2984 FIXME("Vertex rectangle:\n");
2985 FIXME("X, Y: %f, %f\n", t_vert
[0].x
, t_vert
[0].y
);
2986 FIXME("X, Y: %f, %f\n", t_vert
[3].x
, t_vert
[3].y
);
2987 FIXME("TOP, LEFT: %f, %f\n", t_vert
[0].u
, t_vert
[0].v
);
2988 FIXME("DOWN, BOTTOM: %f, %f\n", t_vert
[3].u
, t_vert
[3].v
);
2990 IDirect3DVertexBuffer9_Lock(This
->d3d9_vertex
, 0, sizeof(t_vert
), &bits
, 0);
2991 memcpy(bits
, t_vert
, sizeof(t_vert
));
2992 IDirect3DVertexBuffer9_Unlock(This
->d3d9_vertex
);
2997 static HRESULT WINAPI
VMR9_SurfaceAllocator_GetSurface(IVMRSurfaceAllocatorEx9
*iface
, DWORD_PTR id
, DWORD surfaceindex
, DWORD flags
, IDirect3DSurface9
**surface
)
2999 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
3001 /* Update everything first, this is needed because the surface might be destroyed in the reset */
3002 if (!This
->d3d9_dev
)
3004 TRACE("Device has left me!\n");
3008 VMR9_SurfaceAllocator_UpdateDeviceReset(This
);
3010 if (surfaceindex
>= This
->num_surfaces
)
3012 ERR("surfaceindex is greater than num_surfaces\n");
3015 *surface
= This
->d3d9_surfaces
[surfaceindex
];
3016 IDirect3DSurface9_AddRef(*surface
);
3021 static HRESULT WINAPI
VMR9_SurfaceAllocator_AdviseNotify(IVMRSurfaceAllocatorEx9
*iface
, IVMRSurfaceAllocatorNotify9
*allocnotify
)
3023 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
3025 TRACE("(%p/%p)->(...)\n", iface
, This
);
3027 /* No AddRef taken here or the base VMR9 filter would never be destroied */
3028 This
->SurfaceAllocatorNotify
= allocnotify
;
3032 static const IVMRSurfaceAllocatorEx9Vtbl VMR9_SurfaceAllocator
=
3034 VMR9_SurfaceAllocator_QueryInterface
,
3035 VMR9_SurfaceAllocator_AddRef
,
3036 VMR9_SurfaceAllocator_Release
,
3037 VMR9_SurfaceAllocator_InitializeDevice
,
3038 VMR9_SurfaceAllocator_TerminateDevice
,
3039 VMR9_SurfaceAllocator_GetSurface
,
3040 VMR9_SurfaceAllocator_AdviseNotify
,
3041 NULL
/* This isn't the SurfaceAllocatorEx type yet, working on it */
3044 static IDirect3D9
*init_d3d9(HMODULE d3d9_handle
)
3046 IDirect3D9
* (__stdcall
* d3d9_create
)(UINT SDKVersion
);
3048 d3d9_create
= (void *)GetProcAddress(d3d9_handle
, "Direct3DCreate9");
3049 if (!d3d9_create
) return NULL
;
3051 return d3d9_create(D3D_SDK_VERSION
);
3054 static HRESULT
VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr
*parent
, LPVOID
* ppv
)
3058 VMR9DefaultAllocatorPresenterImpl
* This
;
3060 This
= CoTaskMemAlloc(sizeof(VMR9DefaultAllocatorPresenterImpl
));
3062 return E_OUTOFMEMORY
;
3064 This
->d3d9_ptr
= init_d3d9(parent
->hD3d9
);
3065 if (!This
->d3d9_ptr
)
3067 WARN("Could not initialize d3d9.dll\n");
3068 CoTaskMemFree(This
);
3069 return VFW_E_DDRAW_CAPS_NOT_SUITABLE
;
3075 D3DDISPLAYMODE mode
;
3077 hr
= IDirect3D9_EnumAdapterModes(This
->d3d9_ptr
, i
++, D3DFMT_X8R8G8B8
, 0, &mode
);
3078 if (hr
== D3DERR_INVALIDCALL
) break; /* out of adapters */
3079 } while (FAILED(hr
));
3081 ERR("HR: %08x\n", hr
);
3082 if (hr
== D3DERR_NOTAVAILABLE
)
3084 ERR("Format not supported\n");
3085 IDirect3D9_Release(This
->d3d9_ptr
);
3086 CoTaskMemFree(This
);
3087 return VFW_E_DDRAW_CAPS_NOT_SUITABLE
;
3090 This
->IVMRImagePresenter9_iface
.lpVtbl
= &VMR9_ImagePresenter
;
3091 This
->IVMRSurfaceAllocatorEx9_iface
.lpVtbl
= &VMR9_SurfaceAllocator
;
3094 This
->pVMR9
= parent
;
3095 This
->d3d9_surfaces
= NULL
;
3096 This
->d3d9_dev
= NULL
;
3098 This
->d3d9_vertex
= NULL
;
3099 This
->num_surfaces
= 0;
3100 This
->hWndThread
= NULL
;
3101 This
->ack
= CreateEventW(NULL
, 0, 0, NULL
);
3102 This
->SurfaceAllocatorNotify
= NULL
;
3103 This
->reset
= FALSE
;
3105 *ppv
= &This
->IVMRImagePresenter9_iface
;