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
23 #include "quartz_private.h"
30 BaseRenderer renderer
;
31 BaseControlWindow baseControlWindow
;
32 BaseControlVideo baseControlVideo
;
34 IUnknown IUnknown_inner
;
35 IAMCertifiedOutputProtection IAMCertifiedOutputProtection_iface
;
36 IAMFilterMiscFlags IAMFilterMiscFlags_iface
;
37 IVMRFilterConfig IVMRFilterConfig_iface
;
38 IVMRFilterConfig9 IVMRFilterConfig9_iface
;
39 IVMRMonitorConfig IVMRMonitorConfig_iface
;
40 IVMRMonitorConfig9 IVMRMonitorConfig9_iface
;
41 IVMRSurfaceAllocatorNotify IVMRSurfaceAllocatorNotify_iface
;
42 IVMRSurfaceAllocatorNotify9 IVMRSurfaceAllocatorNotify9_iface
;
43 IVMRWindowlessControl IVMRWindowlessControl_iface
;
44 IVMRWindowlessControl9 IVMRWindowlessControl9_iface
;
46 IVMRSurfaceAllocatorEx9
*allocator
;
47 IVMRImagePresenter9
*presenter
;
51 * The Video Mixing Renderer supports 3 modes, renderless, windowless and windowed
52 * What I do is implement windowless as a special case of renderless, and then
53 * windowed also as a special case of windowless. This is probably the easiest way.
56 BITMAPINFOHEADER bmiheader
;
63 /* Presentation related members */
64 IDirect3DDevice9
*allocator_d3d9_dev
;
65 HMONITOR allocator_mon
;
70 /* for Windowless Mode */
71 HWND hWndClippingWindow
;
79 static inline struct quartz_vmr
*impl_from_inner_IUnknown(IUnknown
*iface
)
81 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IUnknown_inner
);
84 static inline struct quartz_vmr
*impl_from_BaseWindow(BaseWindow
*wnd
)
86 return CONTAINING_RECORD(wnd
, struct quartz_vmr
, baseControlWindow
.baseWindow
);
89 static inline struct quartz_vmr
*impl_from_IVideoWindow(IVideoWindow
*iface
)
91 return CONTAINING_RECORD(iface
, struct quartz_vmr
, baseControlWindow
.IVideoWindow_iface
);
94 static inline struct quartz_vmr
*impl_from_BaseControlVideo(BaseControlVideo
*cvid
)
96 return CONTAINING_RECORD(cvid
, struct quartz_vmr
, baseControlVideo
);
99 static inline struct quartz_vmr
*impl_from_IBasicVideo(IBasicVideo
*iface
)
101 return CONTAINING_RECORD(iface
, struct quartz_vmr
, baseControlVideo
.IBasicVideo_iface
);
104 static inline struct quartz_vmr
*impl_from_IAMCertifiedOutputProtection(IAMCertifiedOutputProtection
*iface
)
106 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IAMCertifiedOutputProtection_iface
);
109 static inline struct quartz_vmr
*impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags
*iface
)
111 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IAMFilterMiscFlags_iface
);
114 static inline struct quartz_vmr
*impl_from_IVMRFilterConfig(IVMRFilterConfig
*iface
)
116 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRFilterConfig_iface
);
119 static inline struct quartz_vmr
*impl_from_IVMRFilterConfig9(IVMRFilterConfig9
*iface
)
121 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRFilterConfig9_iface
);
124 static inline struct quartz_vmr
*impl_from_IVMRMonitorConfig(IVMRMonitorConfig
*iface
)
126 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRMonitorConfig_iface
);
129 static inline struct quartz_vmr
*impl_from_IVMRMonitorConfig9(IVMRMonitorConfig9
*iface
)
131 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRMonitorConfig9_iface
);
134 static inline struct quartz_vmr
*impl_from_IVMRSurfaceAllocatorNotify(IVMRSurfaceAllocatorNotify
*iface
)
136 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRSurfaceAllocatorNotify_iface
);
139 static inline struct quartz_vmr
*impl_from_IVMRSurfaceAllocatorNotify9(IVMRSurfaceAllocatorNotify9
*iface
)
141 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRSurfaceAllocatorNotify9_iface
);
144 static inline struct quartz_vmr
*impl_from_IVMRWindowlessControl(IVMRWindowlessControl
*iface
)
146 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRWindowlessControl_iface
);
149 static inline struct quartz_vmr
*impl_from_IVMRWindowlessControl9(IVMRWindowlessControl9
*iface
)
151 return CONTAINING_RECORD(iface
, struct quartz_vmr
, IVMRWindowlessControl9_iface
);
156 IVMRImagePresenter9 IVMRImagePresenter9_iface
;
157 IVMRSurfaceAllocatorEx9 IVMRSurfaceAllocatorEx9_iface
;
165 IDirect3DDevice9
*d3d9_dev
;
166 IDirect3D9
*d3d9_ptr
;
167 IDirect3DSurface9
**d3d9_surfaces
;
168 IDirect3DVertexBuffer9
*d3d9_vertex
;
173 VMR9AllocationInfo info
;
175 struct quartz_vmr
* pVMR9
;
176 IVMRSurfaceAllocatorNotify9
*SurfaceAllocatorNotify
;
177 } VMR9DefaultAllocatorPresenterImpl
;
179 static inline VMR9DefaultAllocatorPresenterImpl
*impl_from_IVMRImagePresenter9( IVMRImagePresenter9
*iface
)
181 return CONTAINING_RECORD(iface
, VMR9DefaultAllocatorPresenterImpl
, IVMRImagePresenter9_iface
);
184 static inline VMR9DefaultAllocatorPresenterImpl
*impl_from_IVMRSurfaceAllocatorEx9( IVMRSurfaceAllocatorEx9
*iface
)
186 return CONTAINING_RECORD(iface
, VMR9DefaultAllocatorPresenterImpl
, IVMRSurfaceAllocatorEx9_iface
);
189 static HRESULT
VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr
*parent
, LPVOID
* ppv
);
191 static DWORD
VMR9_SendSampleData(struct quartz_vmr
*This
, VMR9PresentationInfo
*info
, LPBYTE data
,
198 BITMAPINFOHEADER
*bmiHeader
;
201 TRACE("%p %p %d\n", This
, data
, size
);
203 amt
= &This
->renderer
.pInputPin
->pin
.mtCurrent
;
205 if (IsEqualIID(&amt
->formattype
, &FORMAT_VideoInfo
))
207 bmiHeader
= &((VIDEOINFOHEADER
*)amt
->pbFormat
)->bmiHeader
;
209 else if (IsEqualIID(&amt
->formattype
, &FORMAT_VideoInfo2
))
211 bmiHeader
= &((VIDEOINFOHEADER2
*)amt
->pbFormat
)->bmiHeader
;
215 FIXME("Unknown type %s\n", debugstr_guid(&amt
->subtype
));
216 return VFW_E_RUNTIME_ERROR
;
219 TRACE("biSize = %d\n", bmiHeader
->biSize
);
220 TRACE("biWidth = %d\n", bmiHeader
->biWidth
);
221 TRACE("biHeight = %d\n", bmiHeader
->biHeight
);
222 TRACE("biPlanes = %d\n", bmiHeader
->biPlanes
);
223 TRACE("biBitCount = %d\n", bmiHeader
->biBitCount
);
224 TRACE("biCompression = %s\n", debugstr_an((LPSTR
)&(bmiHeader
->biCompression
), 4));
225 TRACE("biSizeImage = %d\n", bmiHeader
->biSizeImage
);
227 width
= bmiHeader
->biWidth
;
228 height
= bmiHeader
->biHeight
;
230 TRACE("Src Rect: %s\n", wine_dbgstr_rect(&This
->source_rect
));
231 TRACE("Dst Rect: %s\n", wine_dbgstr_rect(&This
->target_rect
));
233 hr
= IDirect3DSurface9_LockRect(info
->lpSurf
, &lock
, NULL
, D3DLOCK_DISCARD
);
236 ERR("IDirect3DSurface9_LockRect failed (%x)\n",hr
);
241 /* Bottom up image needs inverting */
242 lock
.pBits
= (char *)lock
.pBits
+ (height
* lock
.Pitch
);
245 lock
.pBits
= (char *)lock
.pBits
- lock
.Pitch
;
246 memcpy(lock
.pBits
, data
, width
* bmiHeader
->biBitCount
/ 8);
247 data
= data
+ width
* bmiHeader
->biBitCount
/ 8;
250 else if (lock
.Pitch
!= width
* bmiHeader
->biBitCount
/ 8)
252 WARN("Slow path! %u/%u\n", lock
.Pitch
, width
* bmiHeader
->biBitCount
/8);
256 memcpy(lock
.pBits
, data
, width
* bmiHeader
->biBitCount
/ 8);
257 data
= data
+ width
* bmiHeader
->biBitCount
/ 8;
258 lock
.pBits
= (char *)lock
.pBits
+ lock
.Pitch
;
261 else memcpy(lock
.pBits
, data
, size
);
263 IDirect3DSurface9_UnlockRect(info
->lpSurf
);
265 hr
= IVMRImagePresenter9_PresentImage(This
->presenter
, This
->cookie
, info
);
269 static HRESULT WINAPI
VMR9_DoRenderSample(BaseRenderer
*iface
, IMediaSample
* pSample
)
271 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
272 LPBYTE pbSrcStream
= NULL
;
273 long cbSrcStream
= 0;
274 REFERENCE_TIME tStart
, tStop
;
275 VMR9PresentationInfo info
;
278 TRACE("%p %p\n", iface
, pSample
);
280 /* It is possible that there is no device at this point */
282 if (!This
->allocator
|| !This
->presenter
)
284 ERR("NO PRESENTER!!\n");
288 hr
= IMediaSample_GetTime(pSample
, &tStart
, &tStop
);
290 info
.dwFlags
= VMR9Sample_SrcDstRectsValid
;
292 info
.dwFlags
= VMR9Sample_SrcDstRectsValid
| VMR9Sample_TimeValid
;
294 if (IMediaSample_IsDiscontinuity(pSample
) == S_OK
)
295 info
.dwFlags
|= VMR9Sample_Discontinuity
;
297 if (IMediaSample_IsPreroll(pSample
) == S_OK
)
298 info
.dwFlags
|= VMR9Sample_Preroll
;
300 if (IMediaSample_IsSyncPoint(pSample
) == S_OK
)
301 info
.dwFlags
|= VMR9Sample_SyncPoint
;
303 /* If we render ourselves, and this is a preroll sample, discard it */
304 if (This
->baseControlWindow
.baseWindow
.hWnd
&& (info
.dwFlags
& VMR9Sample_Preroll
))
309 hr
= IMediaSample_GetPointer(pSample
, &pbSrcStream
);
312 ERR("Cannot get pointer to sample data (%x)\n", hr
);
316 cbSrcStream
= IMediaSample_GetActualDataLength(pSample
);
318 info
.rtStart
= tStart
;
320 info
.szAspectRatio
.cx
= This
->bmiheader
.biWidth
;
321 info
.szAspectRatio
.cy
= This
->bmiheader
.biHeight
;
323 hr
= IVMRSurfaceAllocatorEx9_GetSurface(This
->allocator
, This
->cookie
, (++This
->cur_surface
)%This
->num_surfaces
, 0, &info
.lpSurf
);
328 VMR9_SendSampleData(This
, &info
, pbSrcStream
, cbSrcStream
);
329 IDirect3DSurface9_Release(info
.lpSurf
);
334 static HRESULT WINAPI
VMR9_CheckMediaType(BaseRenderer
*iface
, const AM_MEDIA_TYPE
* pmt
)
336 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
338 if (!IsEqualIID(&pmt
->majortype
, &MEDIATYPE_Video
) || !pmt
->pbFormat
)
341 /* Ignore subtype, test for bicompression instead */
342 if (IsEqualIID(&pmt
->formattype
, &FORMAT_VideoInfo
))
344 VIDEOINFOHEADER
*format
= (VIDEOINFOHEADER
*)pmt
->pbFormat
;
346 This
->bmiheader
= format
->bmiHeader
;
347 TRACE("Resolution: %dx%d\n", format
->bmiHeader
.biWidth
, format
->bmiHeader
.biHeight
);
348 This
->VideoWidth
= format
->bmiHeader
.biWidth
;
349 This
->VideoHeight
= format
->bmiHeader
.biHeight
;
350 SetRect(&This
->source_rect
, 0, 0, This
->VideoWidth
, This
->VideoHeight
);
352 else if (IsEqualIID(&pmt
->formattype
, &FORMAT_VideoInfo2
))
354 VIDEOINFOHEADER2
*format
= (VIDEOINFOHEADER2
*)pmt
->pbFormat
;
356 This
->bmiheader
= format
->bmiHeader
;
358 TRACE("Resolution: %dx%d\n", format
->bmiHeader
.biWidth
, format
->bmiHeader
.biHeight
);
359 This
->VideoWidth
= format
->bmiHeader
.biWidth
;
360 This
->VideoHeight
= format
->bmiHeader
.biHeight
;
361 SetRect(&This
->source_rect
, 0, 0, This
->VideoWidth
, This
->VideoHeight
);
365 ERR("Format type %s not supported\n", debugstr_guid(&pmt
->formattype
));
368 if (This
->bmiheader
.biCompression
)
373 static HRESULT
VMR9_maybe_init(struct quartz_vmr
*This
, BOOL force
)
375 VMR9AllocationInfo info
;
379 TRACE("my mode: %u, my window: %p, my last window: %p\n", This
->mode
, This
->baseControlWindow
.baseWindow
.hWnd
, This
->hWndClippingWindow
);
380 if (This
->baseControlWindow
.baseWindow
.hWnd
|| !This
->renderer
.pInputPin
->pin
.pConnectedTo
)
383 if (This
->mode
== VMR9Mode_Windowless
&& !This
->hWndClippingWindow
)
384 return (force
? VFW_E_RUNTIME_ERROR
: S_OK
);
386 TRACE("Initializing\n");
387 info
.dwFlags
= VMR9AllocFlag_TextureSurface
;
388 info
.dwHeight
= This
->source_rect
.bottom
;
389 info
.dwWidth
= This
->source_rect
.right
;
390 info
.Pool
= D3DPOOL_DEFAULT
;
392 FIXME("Reduce ratio to least common denominator\n");
393 info
.szAspectRatio
.cx
= info
.dwWidth
;
394 info
.szAspectRatio
.cy
= info
.dwHeight
;
395 info
.szNativeSize
.cx
= This
->bmiheader
.biWidth
;
396 info
.szNativeSize
.cy
= This
->bmiheader
.biHeight
;
399 switch (This
->bmiheader
.biBitCount
)
401 case 8: info
.Format
= D3DFMT_R3G3B2
; break;
402 case 15: info
.Format
= D3DFMT_X1R5G5B5
; break;
403 case 16: info
.Format
= D3DFMT_R5G6B5
; break;
404 case 24: info
.Format
= D3DFMT_R8G8B8
; break;
405 case 32: info
.Format
= D3DFMT_X8R8G8B8
; break;
407 FIXME("Unknown bpp %u\n", This
->bmiheader
.biBitCount
);
411 This
->cur_surface
= 0;
412 if (This
->num_surfaces
)
414 ERR("num_surfaces or d3d9_surfaces not 0\n");
418 hr
= IVMRSurfaceAllocatorEx9_InitializeDevice(This
->allocator
, This
->cookie
, &info
, &buffers
);
421 SetRect(&This
->source_rect
, 0, 0, This
->bmiheader
.biWidth
, This
->bmiheader
.biHeight
);
423 This
->num_surfaces
= buffers
;
428 static VOID WINAPI
VMR9_OnStartStreaming(BaseRenderer
* iface
)
430 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
432 TRACE("(%p)\n", This
);
434 VMR9_maybe_init(This
, TRUE
);
435 IVMRImagePresenter9_StartPresenting(This
->presenter
, This
->cookie
);
436 SetWindowPos(This
->baseControlWindow
.baseWindow
.hWnd
, NULL
,
437 This
->source_rect
.left
,
438 This
->source_rect
.top
,
439 This
->source_rect
.right
- This
->source_rect
.left
,
440 This
->source_rect
.bottom
- This
->source_rect
.top
,
441 SWP_NOZORDER
|SWP_NOMOVE
|SWP_DEFERERASE
);
442 ShowWindow(This
->baseControlWindow
.baseWindow
.hWnd
, SW_SHOW
);
443 GetClientRect(This
->baseControlWindow
.baseWindow
.hWnd
, &This
->target_rect
);
446 static VOID WINAPI
VMR9_OnStopStreaming(BaseRenderer
* iface
)
448 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
450 TRACE("(%p)\n", This
);
452 if (This
->renderer
.filter
.state
== State_Running
)
453 IVMRImagePresenter9_StopPresenting(This
->presenter
, This
->cookie
);
456 static HRESULT WINAPI
VMR9_ShouldDrawSampleNow(BaseRenderer
*This
, IMediaSample
*pSample
, REFERENCE_TIME
*pStartTime
, REFERENCE_TIME
*pEndTime
)
458 /* Preroll means the sample isn't shown, this is used for key frames and things like that */
459 if (IMediaSample_IsPreroll(pSample
) == S_OK
)
464 static HRESULT WINAPI
VMR9_CompleteConnect(BaseRenderer
*This
, IPin
*pReceivePin
)
466 struct quartz_vmr
*pVMR9
= (struct quartz_vmr
*)This
;
469 TRACE("(%p)\n", This
);
472 SUCCEEDED(hr
= IVMRFilterConfig9_SetRenderingMode(&pVMR9
->IVMRFilterConfig9_iface
, VMR9Mode_Windowed
)))
473 hr
= VMR9_maybe_init(pVMR9
, FALSE
);
478 static HRESULT WINAPI
VMR9_BreakConnect(BaseRenderer
*This
)
480 struct quartz_vmr
*pVMR9
= (struct quartz_vmr
*)This
;
485 if (This
->pInputPin
->pin
.pConnectedTo
&& pVMR9
->allocator
&& pVMR9
->presenter
)
487 if (pVMR9
->renderer
.filter
.state
!= State_Stopped
)
489 ERR("Disconnecting while not stopped! UNTESTED!!\n");
491 if (pVMR9
->renderer
.filter
.state
== State_Running
)
492 hr
= IVMRImagePresenter9_StopPresenting(pVMR9
->presenter
, pVMR9
->cookie
);
493 IVMRSurfaceAllocatorEx9_TerminateDevice(pVMR9
->allocator
, pVMR9
->cookie
);
494 pVMR9
->num_surfaces
= 0;
499 static const BaseRendererFuncTable BaseFuncTable
= {
506 VMR9_OnStartStreaming
,
507 VMR9_OnStopStreaming
,
511 VMR9_ShouldDrawSampleNow
,
514 VMR9_CompleteConnect
,
521 static LPWSTR WINAPI
VMR9_GetClassWindowStyles(BaseWindow
*This
, DWORD
*pClassStyles
, DWORD
*pWindowStyles
, DWORD
*pWindowStylesEx
)
523 static WCHAR classnameW
[] = { 'I','V','M','R','9',' ','C','l','a','s','s', 0 };
526 *pWindowStyles
= WS_SIZEBOX
;
527 *pWindowStylesEx
= 0;
532 static RECT WINAPI
VMR9_GetDefaultRect(BaseWindow
*This
)
534 struct quartz_vmr
* pVMR9
= impl_from_BaseWindow(This
);
537 SetRect(&defRect
, 0, 0, pVMR9
->VideoWidth
, pVMR9
->VideoHeight
);
542 static BOOL WINAPI
VMR9_OnSize(BaseWindow
*This
, LONG Width
, LONG Height
)
544 struct quartz_vmr
* pVMR9
= impl_from_BaseWindow(This
);
546 TRACE("WM_SIZE %d %d\n", Width
, Height
);
547 GetClientRect(This
->hWnd
, &pVMR9
->target_rect
);
548 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
549 pVMR9
->target_rect
.left
,
550 pVMR9
->target_rect
.top
,
551 pVMR9
->target_rect
.right
- pVMR9
->target_rect
.left
,
552 pVMR9
->target_rect
.bottom
- pVMR9
->target_rect
.top
);
553 return BaseWindowImpl_OnSize(This
, Width
, Height
);
556 static const BaseWindowFuncTable renderer_BaseWindowFuncTable
= {
557 VMR9_GetClassWindowStyles
,
560 BaseControlWindowImpl_PossiblyEatMessage
,
564 static HRESULT WINAPI
VMR9_GetSourceRect(BaseControlVideo
* This
, RECT
*pSourceRect
)
566 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
567 CopyRect(pSourceRect
,&pVMR9
->source_rect
);
571 static HRESULT WINAPI
VMR9_GetStaticImage(BaseControlVideo
* This
, LONG
*pBufferSize
, LONG
*pDIBImage
)
573 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
574 BITMAPINFOHEADER
*bmiHeader
;
576 AM_MEDIA_TYPE
*amt
= &pVMR9
->renderer
.pInputPin
->pin
.mtCurrent
;
579 FIXME("(%p/%p)->(%p, %p): partial stub\n", pVMR9
, This
, pBufferSize
, pDIBImage
);
581 EnterCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
583 if (!pVMR9
->renderer
.pMediaSample
)
585 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
586 return (pVMR9
->renderer
.filter
.state
== State_Paused
? E_UNEXPECTED
: VFW_E_NOT_PAUSED
);
589 if (IsEqualIID(&amt
->formattype
, &FORMAT_VideoInfo
))
591 bmiHeader
= &((VIDEOINFOHEADER
*)amt
->pbFormat
)->bmiHeader
;
593 else if (IsEqualIID(&amt
->formattype
, &FORMAT_VideoInfo2
))
595 bmiHeader
= &((VIDEOINFOHEADER2
*)amt
->pbFormat
)->bmiHeader
;
599 FIXME("Unknown type %s\n", debugstr_guid(&amt
->subtype
));
600 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
601 return VFW_E_RUNTIME_ERROR
;
604 needed_size
= bmiHeader
->biSize
;
605 needed_size
+= IMediaSample_GetActualDataLength(pVMR9
->renderer
.pMediaSample
);
609 *pBufferSize
= needed_size
;
610 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
614 if (needed_size
< *pBufferSize
)
616 ERR("Buffer too small %u/%u\n", needed_size
, *pBufferSize
);
617 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
620 *pBufferSize
= needed_size
;
622 memcpy(pDIBImage
, bmiHeader
, bmiHeader
->biSize
);
623 IMediaSample_GetPointer(pVMR9
->renderer
.pMediaSample
, (BYTE
**)&ptr
);
624 memcpy((char *)pDIBImage
+ bmiHeader
->biSize
, ptr
, IMediaSample_GetActualDataLength(pVMR9
->renderer
.pMediaSample
));
626 LeaveCriticalSection(&pVMR9
->renderer
.filter
.csFilter
);
630 static HRESULT WINAPI
VMR9_GetTargetRect(BaseControlVideo
* This
, RECT
*pTargetRect
)
632 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
633 CopyRect(pTargetRect
,&pVMR9
->target_rect
);
637 static VIDEOINFOHEADER
* WINAPI
VMR9_GetVideoFormat(BaseControlVideo
* This
)
639 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
642 TRACE("(%p/%p)\n", pVMR9
, This
);
644 pmt
= &pVMR9
->renderer
.pInputPin
->pin
.mtCurrent
;
645 if (IsEqualIID(&pmt
->formattype
, &FORMAT_VideoInfo
)) {
646 return (VIDEOINFOHEADER
*)pmt
->pbFormat
;
647 } else if (IsEqualIID(&pmt
->formattype
, &FORMAT_VideoInfo2
)) {
648 static VIDEOINFOHEADER vih
;
649 VIDEOINFOHEADER2
*vih2
= (VIDEOINFOHEADER2
*)pmt
->pbFormat
;
650 memcpy(&vih
,vih2
,sizeof(VIDEOINFOHEADER
));
651 memcpy(&vih
.bmiHeader
, &vih2
->bmiHeader
, sizeof(BITMAPINFOHEADER
));
654 ERR("Unknown format type %s\n", qzdebugstr_guid(&pmt
->formattype
));
659 static HRESULT WINAPI
VMR9_IsDefaultSourceRect(BaseControlVideo
* This
)
661 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
662 FIXME("(%p/%p)->(): stub !!!\n", pVMR9
, This
);
667 static HRESULT WINAPI
VMR9_IsDefaultTargetRect(BaseControlVideo
* This
)
669 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
670 FIXME("(%p/%p)->(): stub !!!\n", pVMR9
, This
);
675 static HRESULT WINAPI
VMR9_SetDefaultSourceRect(BaseControlVideo
* This
)
677 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
679 SetRect(&pVMR9
->source_rect
, 0, 0, pVMR9
->VideoWidth
, pVMR9
->VideoHeight
);
684 static HRESULT WINAPI
VMR9_SetDefaultTargetRect(BaseControlVideo
* This
)
687 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
689 if (!GetClientRect(pVMR9
->baseControlWindow
.baseWindow
.hWnd
, &rect
))
692 SetRect(&pVMR9
->target_rect
, 0, 0, rect
.right
, rect
.bottom
);
697 static HRESULT WINAPI
VMR9_SetSourceRect(BaseControlVideo
* This
, RECT
*pSourceRect
)
699 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
700 CopyRect(&pVMR9
->source_rect
,pSourceRect
);
704 static HRESULT WINAPI
VMR9_SetTargetRect(BaseControlVideo
* This
, RECT
*pTargetRect
)
706 struct quartz_vmr
* pVMR9
= impl_from_BaseControlVideo(This
);
707 CopyRect(&pVMR9
->target_rect
,pTargetRect
);
711 static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable
= {
716 VMR9_IsDefaultSourceRect
,
717 VMR9_IsDefaultTargetRect
,
718 VMR9_SetDefaultSourceRect
,
719 VMR9_SetDefaultTargetRect
,
724 static HRESULT WINAPI
VMR9Inner_QueryInterface(IUnknown
* iface
, REFIID riid
, LPVOID
* ppv
)
726 struct quartz_vmr
*This
= impl_from_inner_IUnknown(iface
);
727 TRACE("(%p/%p)->(%s, %p)\n", This
, iface
, qzdebugstr_guid(riid
), ppv
);
729 if (This
->bAggregatable
)
730 This
->bUnkOuterValid
= TRUE
;
734 if (IsEqualIID(riid
, &IID_IUnknown
))
735 *ppv
= &This
->IUnknown_inner
;
736 else if (IsEqualIID(riid
, &IID_IVideoWindow
))
737 *ppv
= &This
->baseControlWindow
.IVideoWindow_iface
;
738 else if (IsEqualIID(riid
, &IID_IBasicVideo
))
739 *ppv
= &This
->baseControlVideo
.IBasicVideo_iface
;
740 else if (IsEqualIID(riid
, &IID_IAMCertifiedOutputProtection
))
741 *ppv
= &This
->IAMCertifiedOutputProtection_iface
;
742 else if (IsEqualIID(riid
, &IID_IAMFilterMiscFlags
))
743 *ppv
= &This
->IAMFilterMiscFlags_iface
;
744 else if (IsEqualIID(riid
, &IID_IVMRFilterConfig
))
745 *ppv
= &This
->IVMRFilterConfig_iface
;
746 else if (IsEqualIID(riid
, &IID_IVMRFilterConfig9
))
747 *ppv
= &This
->IVMRFilterConfig9_iface
;
748 else if (IsEqualIID(riid
, &IID_IVMRMonitorConfig
))
749 *ppv
= &This
->IVMRMonitorConfig_iface
;
750 else if (IsEqualIID(riid
, &IID_IVMRMonitorConfig9
))
751 *ppv
= &This
->IVMRMonitorConfig9_iface
;
752 else if (IsEqualIID(riid
, &IID_IVMRSurfaceAllocatorNotify
) && This
->mode
== (VMR9Mode
)VMRMode_Renderless
)
753 *ppv
= &This
->IVMRSurfaceAllocatorNotify_iface
;
754 else if (IsEqualIID(riid
, &IID_IVMRSurfaceAllocatorNotify9
) && This
->mode
== VMR9Mode_Renderless
)
755 *ppv
= &This
->IVMRSurfaceAllocatorNotify9_iface
;
756 else if (IsEqualIID(riid
, &IID_IVMRWindowlessControl
) && This
->mode
== (VMR9Mode
)VMRMode_Windowless
)
757 *ppv
= &This
->IVMRWindowlessControl_iface
;
758 else if (IsEqualIID(riid
, &IID_IVMRWindowlessControl9
) && This
->mode
== VMR9Mode_Windowless
)
759 *ppv
= &This
->IVMRWindowlessControl9_iface
;
763 hr
= BaseRendererImpl_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
770 IUnknown_AddRef((IUnknown
*)(*ppv
));
774 else if (IsEqualIID(riid
, &IID_IBasicVideo2
))
775 FIXME("No interface for IID_IBasicVideo2\n");
776 else if (IsEqualIID(riid
, &IID_IVMRWindowlessControl9
))
778 else if (IsEqualIID(riid
, &IID_IVMRSurfaceAllocatorNotify9
))
780 else if (IsEqualIID(riid
, &IID_IMediaPosition
))
781 FIXME("No interface for IID_IMediaPosition\n");
782 else if (IsEqualIID(riid
, &IID_IQualProp
))
783 FIXME("No interface for IID_IQualProp\n");
784 else if (IsEqualIID(riid
, &IID_IVMRAspectRatioControl9
))
785 FIXME("No interface for IID_IVMRAspectRatioControl9\n");
786 else if (IsEqualIID(riid
, &IID_IVMRDeinterlaceControl9
))
787 FIXME("No interface for IID_IVMRDeinterlaceControl9\n");
788 else if (IsEqualIID(riid
, &IID_IVMRMixerBitmap9
))
789 FIXME("No interface for IID_IVMRMixerBitmap9\n");
790 else if (IsEqualIID(riid
, &IID_IVMRMixerControl9
))
791 FIXME("No interface for IID_IVMRMixerControl9\n");
793 FIXME("No interface for %s\n", debugstr_guid(riid
));
795 return E_NOINTERFACE
;
798 static ULONG WINAPI
VMR9Inner_AddRef(IUnknown
* iface
)
800 struct quartz_vmr
*This
= impl_from_inner_IUnknown(iface
);
801 ULONG refCount
= BaseFilterImpl_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
803 TRACE("(%p/%p)->() AddRef from %d\n", This
, iface
, refCount
- 1);
808 static ULONG WINAPI
VMR9Inner_Release(IUnknown
* iface
)
810 struct quartz_vmr
*This
= impl_from_inner_IUnknown(iface
);
811 ULONG refCount
= BaseRendererImpl_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
813 TRACE("(%p/%p)->() Release from %d\n", This
, iface
, refCount
+ 1);
817 TRACE("Destroying\n");
818 BaseControlWindow_Destroy(&This
->baseControlWindow
);
819 FreeLibrary(This
->hD3d9
);
822 IVMRSurfaceAllocatorEx9_Release(This
->allocator
);
824 IVMRImagePresenter9_Release(This
->presenter
);
826 This
->num_surfaces
= 0;
827 if (This
->allocator_d3d9_dev
)
829 IDirect3DDevice9_Release(This
->allocator_d3d9_dev
);
830 This
->allocator_d3d9_dev
= NULL
;
838 static const IUnknownVtbl IInner_VTable
=
840 VMR9Inner_QueryInterface
,
845 static HRESULT WINAPI
VMR9_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
847 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
849 if (This
->bAggregatable
)
850 This
->bUnkOuterValid
= TRUE
;
854 if (This
->bAggregatable
)
855 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
857 if (IsEqualIID(riid
, &IID_IUnknown
))
861 IUnknown_AddRef(&This
->IUnknown_inner
);
862 hr
= IUnknown_QueryInterface(&This
->IUnknown_inner
, riid
, ppv
);
863 IUnknown_Release(&This
->IUnknown_inner
);
864 This
->bAggregatable
= TRUE
;
869 return E_NOINTERFACE
;
872 return IUnknown_QueryInterface(&This
->IUnknown_inner
, riid
, ppv
);
875 static ULONG WINAPI
VMR9_AddRef(IBaseFilter
* iface
)
877 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
880 if (This
->outer_unk
&& This
->bUnkOuterValid
)
881 ret
= IUnknown_AddRef(This
->outer_unk
);
883 ret
= IUnknown_AddRef(&This
->IUnknown_inner
);
885 TRACE("(%p)->AddRef from %d\n", iface
, ret
- 1);
890 static ULONG WINAPI
VMR9_Release(IBaseFilter
* iface
)
892 struct quartz_vmr
*This
= (struct quartz_vmr
*)iface
;
895 if (This
->outer_unk
&& This
->bUnkOuterValid
)
896 ret
= IUnknown_Release(This
->outer_unk
);
898 ret
= IUnknown_Release(&This
->IUnknown_inner
);
900 TRACE("(%p)->Release from %d\n", iface
, ret
+ 1);
907 static const IBaseFilterVtbl VMR_Vtbl
=
912 BaseFilterImpl_GetClassID
,
913 BaseRendererImpl_Stop
,
914 BaseRendererImpl_Pause
,
915 BaseRendererImpl_Run
,
916 BaseRendererImpl_GetState
,
917 BaseRendererImpl_SetSyncSource
,
918 BaseFilterImpl_GetSyncSource
,
919 BaseFilterImpl_EnumPins
,
920 BaseRendererImpl_FindPin
,
921 BaseFilterImpl_QueryFilterInfo
,
922 BaseFilterImpl_JoinFilterGraph
,
923 BaseFilterImpl_QueryVendorInfo
926 /*** IUnknown methods ***/
927 static HRESULT WINAPI
Videowindow_QueryInterface(IVideoWindow
*iface
, REFIID riid
, LPVOID
*ppvObj
)
929 struct quartz_vmr
*This
= impl_from_IVideoWindow(iface
);
931 TRACE("(%p/%p)->(%s, %p)\n", This
, iface
, debugstr_guid(riid
), ppvObj
);
933 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
936 static ULONG WINAPI
Videowindow_AddRef(IVideoWindow
*iface
)
938 struct quartz_vmr
*This
= impl_from_IVideoWindow(iface
);
940 TRACE("(%p/%p)->()\n", This
, iface
);
942 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
945 static ULONG WINAPI
Videowindow_Release(IVideoWindow
*iface
)
947 struct quartz_vmr
*This
= impl_from_IVideoWindow(iface
);
949 TRACE("(%p/%p)->()\n", This
, iface
);
951 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
954 static const IVideoWindowVtbl IVideoWindow_VTable
=
956 Videowindow_QueryInterface
,
959 BaseControlWindowImpl_GetTypeInfoCount
,
960 BaseControlWindowImpl_GetTypeInfo
,
961 BaseControlWindowImpl_GetIDsOfNames
,
962 BaseControlWindowImpl_Invoke
,
963 BaseControlWindowImpl_put_Caption
,
964 BaseControlWindowImpl_get_Caption
,
965 BaseControlWindowImpl_put_WindowStyle
,
966 BaseControlWindowImpl_get_WindowStyle
,
967 BaseControlWindowImpl_put_WindowStyleEx
,
968 BaseControlWindowImpl_get_WindowStyleEx
,
969 BaseControlWindowImpl_put_AutoShow
,
970 BaseControlWindowImpl_get_AutoShow
,
971 BaseControlWindowImpl_put_WindowState
,
972 BaseControlWindowImpl_get_WindowState
,
973 BaseControlWindowImpl_put_BackgroundPalette
,
974 BaseControlWindowImpl_get_BackgroundPalette
,
975 BaseControlWindowImpl_put_Visible
,
976 BaseControlWindowImpl_get_Visible
,
977 BaseControlWindowImpl_put_Left
,
978 BaseControlWindowImpl_get_Left
,
979 BaseControlWindowImpl_put_Width
,
980 BaseControlWindowImpl_get_Width
,
981 BaseControlWindowImpl_put_Top
,
982 BaseControlWindowImpl_get_Top
,
983 BaseControlWindowImpl_put_Height
,
984 BaseControlWindowImpl_get_Height
,
985 BaseControlWindowImpl_put_Owner
,
986 BaseControlWindowImpl_get_Owner
,
987 BaseControlWindowImpl_put_MessageDrain
,
988 BaseControlWindowImpl_get_MessageDrain
,
989 BaseControlWindowImpl_get_BorderColor
,
990 BaseControlWindowImpl_put_BorderColor
,
991 BaseControlWindowImpl_get_FullScreenMode
,
992 BaseControlWindowImpl_put_FullScreenMode
,
993 BaseControlWindowImpl_SetWindowForeground
,
994 BaseControlWindowImpl_NotifyOwnerMessage
,
995 BaseControlWindowImpl_SetWindowPosition
,
996 BaseControlWindowImpl_GetWindowPosition
,
997 BaseControlWindowImpl_GetMinIdealImageSize
,
998 BaseControlWindowImpl_GetMaxIdealImageSize
,
999 BaseControlWindowImpl_GetRestorePosition
,
1000 BaseControlWindowImpl_HideCursor
,
1001 BaseControlWindowImpl_IsCursorHidden
1004 /*** IUnknown methods ***/
1005 static HRESULT WINAPI
Basicvideo_QueryInterface(IBasicVideo
*iface
, REFIID riid
, LPVOID
* ppvObj
)
1007 struct quartz_vmr
*This
= impl_from_IBasicVideo(iface
);
1009 TRACE("(%p/%p)->(%s, %p)\n", This
, iface
, debugstr_guid(riid
), ppvObj
);
1011 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppvObj
);
1014 static ULONG WINAPI
Basicvideo_AddRef(IBasicVideo
*iface
)
1016 struct quartz_vmr
*This
= impl_from_IBasicVideo(iface
);
1018 TRACE("(%p/%p)->()\n", This
, iface
);
1020 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1023 static ULONG WINAPI
Basicvideo_Release(IBasicVideo
*iface
)
1025 struct quartz_vmr
*This
= impl_from_IBasicVideo(iface
);
1027 TRACE("(%p/%p)->()\n", This
, iface
);
1029 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1032 static const IBasicVideoVtbl IBasicVideo_VTable
=
1034 Basicvideo_QueryInterface
,
1037 BaseControlVideoImpl_GetTypeInfoCount
,
1038 BaseControlVideoImpl_GetTypeInfo
,
1039 BaseControlVideoImpl_GetIDsOfNames
,
1040 BaseControlVideoImpl_Invoke
,
1041 BaseControlVideoImpl_get_AvgTimePerFrame
,
1042 BaseControlVideoImpl_get_BitRate
,
1043 BaseControlVideoImpl_get_BitErrorRate
,
1044 BaseControlVideoImpl_get_VideoWidth
,
1045 BaseControlVideoImpl_get_VideoHeight
,
1046 BaseControlVideoImpl_put_SourceLeft
,
1047 BaseControlVideoImpl_get_SourceLeft
,
1048 BaseControlVideoImpl_put_SourceWidth
,
1049 BaseControlVideoImpl_get_SourceWidth
,
1050 BaseControlVideoImpl_put_SourceTop
,
1051 BaseControlVideoImpl_get_SourceTop
,
1052 BaseControlVideoImpl_put_SourceHeight
,
1053 BaseControlVideoImpl_get_SourceHeight
,
1054 BaseControlVideoImpl_put_DestinationLeft
,
1055 BaseControlVideoImpl_get_DestinationLeft
,
1056 BaseControlVideoImpl_put_DestinationWidth
,
1057 BaseControlVideoImpl_get_DestinationWidth
,
1058 BaseControlVideoImpl_put_DestinationTop
,
1059 BaseControlVideoImpl_get_DestinationTop
,
1060 BaseControlVideoImpl_put_DestinationHeight
,
1061 BaseControlVideoImpl_get_DestinationHeight
,
1062 BaseControlVideoImpl_SetSourcePosition
,
1063 BaseControlVideoImpl_GetSourcePosition
,
1064 BaseControlVideoImpl_SetDefaultSourcePosition
,
1065 BaseControlVideoImpl_SetDestinationPosition
,
1066 BaseControlVideoImpl_GetDestinationPosition
,
1067 BaseControlVideoImpl_SetDefaultDestinationPosition
,
1068 BaseControlVideoImpl_GetVideoSize
,
1069 BaseControlVideoImpl_GetVideoPaletteEntries
,
1070 BaseControlVideoImpl_GetCurrentImage
,
1071 BaseControlVideoImpl_IsUsingDefaultSource
,
1072 BaseControlVideoImpl_IsUsingDefaultDestination
1075 static HRESULT WINAPI
AMCertifiedOutputProtection_QueryInterface(IAMCertifiedOutputProtection
*iface
,
1076 REFIID riid
, void **ppv
)
1078 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1079 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1082 static ULONG WINAPI
AMCertifiedOutputProtection_AddRef(IAMCertifiedOutputProtection
*iface
)
1084 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1085 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1088 static ULONG WINAPI
AMCertifiedOutputProtection_Release(IAMCertifiedOutputProtection
*iface
)
1090 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1091 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1094 static HRESULT WINAPI
AMCertifiedOutputProtection_KeyExchange(IAMCertifiedOutputProtection
*iface
,
1095 GUID
* pRandom
, BYTE
** VarLenCertGH
,
1096 DWORD
* pdwLengthCertGH
)
1098 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1100 FIXME("(%p/%p)->(%p, %p, %p) stub\n", iface
, This
, pRandom
, VarLenCertGH
, pdwLengthCertGH
);
1101 return VFW_E_NO_COPP_HW
;
1104 static HRESULT WINAPI
AMCertifiedOutputProtection_SessionSequenceStart(IAMCertifiedOutputProtection
*iface
,
1105 AMCOPPSignature
* pSig
)
1107 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1109 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pSig
);
1110 return VFW_E_NO_COPP_HW
;
1113 static HRESULT WINAPI
AMCertifiedOutputProtection_ProtectionCommand(IAMCertifiedOutputProtection
*iface
,
1114 const AMCOPPCommand
* cmd
)
1116 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1118 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, cmd
);
1119 return VFW_E_NO_COPP_HW
;
1122 static HRESULT WINAPI
AMCertifiedOutputProtection_ProtectionStatus(IAMCertifiedOutputProtection
*iface
,
1123 const AMCOPPStatusInput
* pStatusInput
,
1124 AMCOPPStatusOutput
* pStatusOutput
)
1126 struct quartz_vmr
*This
= impl_from_IAMCertifiedOutputProtection(iface
);
1128 FIXME("(%p/%p)->(%p, %p) stub\n", iface
, This
, pStatusInput
, pStatusOutput
);
1129 return VFW_E_NO_COPP_HW
;
1132 static const IAMCertifiedOutputProtectionVtbl IAMCertifiedOutputProtection_Vtbl
=
1134 AMCertifiedOutputProtection_QueryInterface
,
1135 AMCertifiedOutputProtection_AddRef
,
1136 AMCertifiedOutputProtection_Release
,
1137 AMCertifiedOutputProtection_KeyExchange
,
1138 AMCertifiedOutputProtection_SessionSequenceStart
,
1139 AMCertifiedOutputProtection_ProtectionCommand
,
1140 AMCertifiedOutputProtection_ProtectionStatus
1143 static HRESULT WINAPI
AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags
*iface
, REFIID riid
, void **ppv
) {
1144 struct quartz_vmr
*This
= impl_from_IAMFilterMiscFlags(iface
);
1145 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1148 static ULONG WINAPI
AMFilterMiscFlags_AddRef(IAMFilterMiscFlags
*iface
) {
1149 struct quartz_vmr
*This
= impl_from_IAMFilterMiscFlags(iface
);
1150 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1153 static ULONG WINAPI
AMFilterMiscFlags_Release(IAMFilterMiscFlags
*iface
) {
1154 struct quartz_vmr
*This
= impl_from_IAMFilterMiscFlags(iface
);
1155 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1158 static ULONG WINAPI
AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags
*iface
) {
1159 return AM_FILTER_MISC_FLAGS_IS_RENDERER
;
1162 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
= {
1163 AMFilterMiscFlags_QueryInterface
,
1164 AMFilterMiscFlags_AddRef
,
1165 AMFilterMiscFlags_Release
,
1166 AMFilterMiscFlags_GetMiscFlags
1169 static HRESULT WINAPI
VMR7FilterConfig_QueryInterface(IVMRFilterConfig
*iface
, REFIID riid
,
1172 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1173 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1176 static ULONG WINAPI
VMR7FilterConfig_AddRef(IVMRFilterConfig
*iface
)
1178 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1179 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1182 static ULONG WINAPI
VMR7FilterConfig_Release(IVMRFilterConfig
*iface
)
1184 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1185 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1188 static HRESULT WINAPI
VMR7FilterConfig_SetImageCompositor(IVMRFilterConfig
*iface
,
1189 IVMRImageCompositor
*compositor
)
1191 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1193 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, compositor
);
1197 static HRESULT WINAPI
VMR7FilterConfig_SetNumberOfStreams(IVMRFilterConfig
*iface
, DWORD max
)
1199 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1201 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, max
);
1205 static HRESULT WINAPI
VMR7FilterConfig_GetNumberOfStreams(IVMRFilterConfig
*iface
, DWORD
*max
)
1207 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1209 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, max
);
1213 static HRESULT WINAPI
VMR7FilterConfig_SetRenderingPrefs(IVMRFilterConfig
*iface
, DWORD renderflags
)
1215 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1217 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, renderflags
);
1221 static HRESULT WINAPI
VMR7FilterConfig_GetRenderingPrefs(IVMRFilterConfig
*iface
, DWORD
*renderflags
)
1223 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1225 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, renderflags
);
1229 static HRESULT WINAPI
VMR7FilterConfig_SetRenderingMode(IVMRFilterConfig
*iface
, DWORD mode
)
1231 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1233 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, mode
);
1237 static HRESULT WINAPI
VMR7FilterConfig_GetRenderingMode(IVMRFilterConfig
*iface
, DWORD
*mode
)
1239 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig(iface
);
1241 TRACE("(%p/%p)->(%p)\n", iface
, This
, mode
);
1242 if (!mode
) return E_POINTER
;
1247 *mode
= VMRMode_Windowed
;
1252 static const IVMRFilterConfigVtbl VMR7_FilterConfig_Vtbl
=
1254 VMR7FilterConfig_QueryInterface
,
1255 VMR7FilterConfig_AddRef
,
1256 VMR7FilterConfig_Release
,
1257 VMR7FilterConfig_SetImageCompositor
,
1258 VMR7FilterConfig_SetNumberOfStreams
,
1259 VMR7FilterConfig_GetNumberOfStreams
,
1260 VMR7FilterConfig_SetRenderingPrefs
,
1261 VMR7FilterConfig_GetRenderingPrefs
,
1262 VMR7FilterConfig_SetRenderingMode
,
1263 VMR7FilterConfig_GetRenderingMode
1266 struct get_available_monitors_args
1268 VMRMONITORINFO
*info7
;
1269 VMR9MonitorInfo
*info9
;
1274 static BOOL CALLBACK
get_available_monitors_proc(HMONITOR hmon
, HDC hdc
, LPRECT lprc
, LPARAM lparam
)
1276 struct get_available_monitors_args
*args
= (struct get_available_monitors_args
*)lparam
;
1279 if (args
->info7
|| args
->info9
)
1282 if (!args
->arraysize
)
1285 mi
.cbSize
= sizeof(mi
);
1286 if (!GetMonitorInfoW(hmon
, (MONITORINFO
*)&mi
))
1289 /* fill VMRMONITORINFO struct */
1292 VMRMONITORINFO
*info
= args
->info7
++;
1293 memset(info
, 0, sizeof(*info
));
1295 if (args
->numdev
> 0)
1297 info
->guid
.pGUID
= &info
->guid
.GUID
;
1298 info
->guid
.GUID
.Data4
[7] = args
->numdev
;
1301 info
->guid
.pGUID
= NULL
;
1303 info
->rcMonitor
= mi
.rcMonitor
;
1305 info
->dwFlags
= mi
.dwFlags
;
1307 lstrcpynW(info
->szDevice
, mi
.szDevice
, sizeof(info
->szDevice
)/sizeof(WCHAR
));
1309 /* FIXME: how to get these values? */
1310 info
->szDescription
[0] = 0;
1313 /* fill VMR9MonitorInfo struct */
1316 VMR9MonitorInfo
*info
= args
->info9
++;
1317 memset(info
, 0, sizeof(*info
));
1319 info
->uDevID
= 0; /* FIXME */
1320 info
->rcMonitor
= mi
.rcMonitor
;
1322 info
->dwFlags
= mi
.dwFlags
;
1324 lstrcpynW(info
->szDevice
, mi
.szDevice
, sizeof(info
->szDevice
)/sizeof(WCHAR
));
1326 /* FIXME: how to get these values? */
1327 info
->szDescription
[0] = 0;
1328 info
->dwVendorId
= 0;
1329 info
->dwDeviceId
= 0;
1330 info
->dwSubSysId
= 0;
1331 info
->dwRevision
= 0;
1341 static HRESULT WINAPI
VMR7MonitorConfig_QueryInterface(IVMRMonitorConfig
*iface
, REFIID riid
,
1344 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1345 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1348 static ULONG WINAPI
VMR7MonitorConfig_AddRef(IVMRMonitorConfig
*iface
)
1350 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1351 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1354 static ULONG WINAPI
VMR7MonitorConfig_Release(IVMRMonitorConfig
*iface
)
1356 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1357 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1360 static HRESULT WINAPI
VMR7MonitorConfig_SetMonitor(IVMRMonitorConfig
*iface
, const VMRGUID
*pGUID
)
1362 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1364 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pGUID
);
1372 static HRESULT WINAPI
VMR7MonitorConfig_GetMonitor(IVMRMonitorConfig
*iface
, VMRGUID
*pGUID
)
1374 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1376 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pGUID
);
1381 pGUID
->pGUID
= NULL
; /* default DirectDraw device */
1385 static HRESULT WINAPI
VMR7MonitorConfig_SetDefaultMonitor(IVMRMonitorConfig
*iface
,
1386 const VMRGUID
*pGUID
)
1388 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1390 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pGUID
);
1398 static HRESULT WINAPI
VMR7MonitorConfig_GetDefaultMonitor(IVMRMonitorConfig
*iface
, VMRGUID
*pGUID
)
1400 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1402 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, pGUID
);
1407 pGUID
->pGUID
= NULL
; /* default DirectDraw device */
1411 static HRESULT WINAPI
VMR7MonitorConfig_GetAvailableMonitors(IVMRMonitorConfig
*iface
,
1412 VMRMONITORINFO
*info
, DWORD arraysize
,
1415 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig(iface
);
1416 struct get_available_monitors_args args
;
1418 FIXME("(%p/%p)->(%p, %u, %p) semi-stub\n", iface
, This
, info
, arraysize
, numdev
);
1423 if (info
&& arraysize
== 0)
1424 return E_INVALIDARG
;
1428 args
.arraysize
= arraysize
;
1430 EnumDisplayMonitors(NULL
, NULL
, get_available_monitors_proc
, (LPARAM
)&args
);
1432 *numdev
= args
.numdev
;
1436 static const IVMRMonitorConfigVtbl VMR7_MonitorConfig_Vtbl
=
1438 VMR7MonitorConfig_QueryInterface
,
1439 VMR7MonitorConfig_AddRef
,
1440 VMR7MonitorConfig_Release
,
1441 VMR7MonitorConfig_SetMonitor
,
1442 VMR7MonitorConfig_GetMonitor
,
1443 VMR7MonitorConfig_SetDefaultMonitor
,
1444 VMR7MonitorConfig_GetDefaultMonitor
,
1445 VMR7MonitorConfig_GetAvailableMonitors
1448 static HRESULT WINAPI
VMR9MonitorConfig_QueryInterface(IVMRMonitorConfig9
*iface
, REFIID riid
,
1451 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1452 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1455 static ULONG WINAPI
VMR9MonitorConfig_AddRef(IVMRMonitorConfig9
*iface
)
1457 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1458 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1461 static ULONG WINAPI
VMR9MonitorConfig_Release(IVMRMonitorConfig9
*iface
)
1463 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1464 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1467 static HRESULT WINAPI
VMR9MonitorConfig_SetMonitor(IVMRMonitorConfig9
*iface
, UINT uDev
)
1469 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1471 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, uDev
);
1476 static HRESULT WINAPI
VMR9MonitorConfig_GetMonitor(IVMRMonitorConfig9
*iface
, UINT
*uDev
)
1478 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1480 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, uDev
);
1489 static HRESULT WINAPI
VMR9MonitorConfig_SetDefaultMonitor(IVMRMonitorConfig9
*iface
, UINT uDev
)
1491 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1493 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, uDev
);
1498 static HRESULT WINAPI
VMR9MonitorConfig_GetDefaultMonitor(IVMRMonitorConfig9
*iface
, UINT
*uDev
)
1500 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1502 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, uDev
);
1511 static HRESULT WINAPI
VMR9MonitorConfig_GetAvailableMonitors(IVMRMonitorConfig9
*iface
,
1512 VMR9MonitorInfo
*info
, DWORD arraysize
,
1515 struct quartz_vmr
*This
= impl_from_IVMRMonitorConfig9(iface
);
1516 struct get_available_monitors_args args
;
1518 FIXME("(%p/%p)->(%p, %u, %p) semi-stub\n", iface
, This
, info
, arraysize
, numdev
);
1523 if (info
&& arraysize
== 0)
1524 return E_INVALIDARG
;
1528 args
.arraysize
= arraysize
;
1530 EnumDisplayMonitors(NULL
, NULL
, get_available_monitors_proc
, (LPARAM
)&args
);
1532 *numdev
= args
.numdev
;
1536 static const IVMRMonitorConfig9Vtbl VMR9_MonitorConfig_Vtbl
=
1538 VMR9MonitorConfig_QueryInterface
,
1539 VMR9MonitorConfig_AddRef
,
1540 VMR9MonitorConfig_Release
,
1541 VMR9MonitorConfig_SetMonitor
,
1542 VMR9MonitorConfig_GetMonitor
,
1543 VMR9MonitorConfig_SetDefaultMonitor
,
1544 VMR9MonitorConfig_GetDefaultMonitor
,
1545 VMR9MonitorConfig_GetAvailableMonitors
1548 static HRESULT WINAPI
VMR9FilterConfig_QueryInterface(IVMRFilterConfig9
*iface
, REFIID riid
, LPVOID
* ppv
)
1550 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1551 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1554 static ULONG WINAPI
VMR9FilterConfig_AddRef(IVMRFilterConfig9
*iface
)
1556 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1557 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1560 static ULONG WINAPI
VMR9FilterConfig_Release(IVMRFilterConfig9
*iface
)
1562 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1563 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1566 static HRESULT WINAPI
VMR9FilterConfig_SetImageCompositor(IVMRFilterConfig9
*iface
, IVMRImageCompositor9
*compositor
)
1568 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1570 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, compositor
);
1574 static HRESULT WINAPI
VMR9FilterConfig_SetNumberOfStreams(IVMRFilterConfig9
*iface
, DWORD max
)
1576 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1578 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, max
);
1582 static HRESULT WINAPI
VMR9FilterConfig_GetNumberOfStreams(IVMRFilterConfig9
*iface
, DWORD
*max
)
1584 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1586 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, max
);
1590 static HRESULT WINAPI
VMR9FilterConfig_SetRenderingPrefs(IVMRFilterConfig9
*iface
, DWORD renderflags
)
1592 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1594 FIXME("(%p/%p)->(%u) stub\n", iface
, This
, renderflags
);
1598 static HRESULT WINAPI
VMR9FilterConfig_GetRenderingPrefs(IVMRFilterConfig9
*iface
, DWORD
*renderflags
)
1600 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1602 FIXME("(%p/%p)->(%p) stub\n", iface
, This
, renderflags
);
1606 static HRESULT WINAPI
VMR9FilterConfig_SetRenderingMode(IVMRFilterConfig9
*iface
, DWORD mode
)
1609 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1611 TRACE("(%p/%p)->(%u)\n", iface
, This
, mode
);
1613 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1616 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1617 return VFW_E_WRONG_STATE
;
1620 if (This
->allocator
)
1621 IVMRSurfaceAllocatorEx9_Release(This
->allocator
);
1622 if (This
->presenter
)
1623 IVMRImagePresenter9_Release(This
->presenter
);
1625 This
->allocator
= NULL
;
1626 This
->presenter
= NULL
;
1630 case VMR9Mode_Windowed
:
1631 case VMR9Mode_Windowless
:
1632 This
->allocator_is_ex
= 0;
1635 hr
= VMR9DefaultAllocatorPresenterImpl_create(This
, (LPVOID
*)&This
->presenter
);
1637 hr
= IVMRImagePresenter9_QueryInterface(This
->presenter
, &IID_IVMRSurfaceAllocatorEx9
, (LPVOID
*)&This
->allocator
);
1640 ERR("Unable to find Presenter interface\n");
1641 IVMRImagePresenter9_Release(This
->presenter
);
1642 This
->allocator
= NULL
;
1643 This
->presenter
= NULL
;
1646 hr
= IVMRSurfaceAllocatorEx9_AdviseNotify(This
->allocator
, &This
->IVMRSurfaceAllocatorNotify9_iface
);
1648 case VMR9Mode_Renderless
:
1651 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1652 return E_INVALIDARG
;
1656 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1660 static HRESULT WINAPI
VMR9FilterConfig_GetRenderingMode(IVMRFilterConfig9
*iface
, DWORD
*mode
)
1662 struct quartz_vmr
*This
= impl_from_IVMRFilterConfig9(iface
);
1664 TRACE("(%p/%p)->(%p)\n", iface
, This
, mode
);
1671 *mode
= VMR9Mode_Windowed
;
1676 static const IVMRFilterConfig9Vtbl VMR9_FilterConfig_Vtbl
=
1678 VMR9FilterConfig_QueryInterface
,
1679 VMR9FilterConfig_AddRef
,
1680 VMR9FilterConfig_Release
,
1681 VMR9FilterConfig_SetImageCompositor
,
1682 VMR9FilterConfig_SetNumberOfStreams
,
1683 VMR9FilterConfig_GetNumberOfStreams
,
1684 VMR9FilterConfig_SetRenderingPrefs
,
1685 VMR9FilterConfig_GetRenderingPrefs
,
1686 VMR9FilterConfig_SetRenderingMode
,
1687 VMR9FilterConfig_GetRenderingMode
1690 static HRESULT WINAPI
VMR7WindowlessControl_QueryInterface(IVMRWindowlessControl
*iface
, REFIID riid
,
1693 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1694 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1697 static ULONG WINAPI
VMR7WindowlessControl_AddRef(IVMRWindowlessControl
*iface
)
1699 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1700 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1703 static ULONG WINAPI
VMR7WindowlessControl_Release(IVMRWindowlessControl
*iface
)
1705 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1706 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1709 static HRESULT WINAPI
VMR7WindowlessControl_GetNativeVideoSize(IVMRWindowlessControl
*iface
,
1710 LONG
*width
, LONG
*height
,
1711 LONG
*arwidth
, LONG
*arheight
)
1713 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1714 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", iface
, This
, width
, height
, arwidth
, arheight
);
1716 if (!width
|| !height
|| !arwidth
|| !arheight
)
1718 ERR("Got no pointer\n");
1722 *width
= This
->bmiheader
.biWidth
;
1723 *height
= This
->bmiheader
.biHeight
;
1724 *arwidth
= This
->bmiheader
.biWidth
;
1725 *arheight
= This
->bmiheader
.biHeight
;
1730 static HRESULT WINAPI
VMR7WindowlessControl_GetMinIdealVideoSize(IVMRWindowlessControl
*iface
,
1731 LONG
*width
, LONG
*height
)
1733 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1735 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1739 static HRESULT WINAPI
VMR7WindowlessControl_GetMaxIdealVideoSize(IVMRWindowlessControl
*iface
,
1740 LONG
*width
, LONG
*height
)
1742 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1744 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1748 static HRESULT WINAPI
VMR7WindowlessControl_SetVideoPosition(IVMRWindowlessControl
*iface
,
1749 const RECT
*source
, const RECT
*dest
)
1751 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1753 TRACE("(%p/%p)->(%p, %p)\n", iface
, This
, source
, dest
);
1755 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1758 This
->source_rect
= *source
;
1761 This
->target_rect
= *dest
;
1762 if (This
->baseControlWindow
.baseWindow
.hWnd
)
1764 FIXME("Output rectangle: %s\n", wine_dbgstr_rect(dest
));
1765 SetWindowPos(This
->baseControlWindow
.baseWindow
.hWnd
, NULL
,
1766 dest
->left
, dest
->top
, dest
->right
- dest
->left
, dest
->bottom
-dest
->top
,
1767 SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOOWNERZORDER
|SWP_NOREDRAW
);
1771 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1776 static HRESULT WINAPI
VMR7WindowlessControl_GetVideoPosition(IVMRWindowlessControl
*iface
,
1777 RECT
*source
, RECT
*dest
)
1779 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1782 *source
= This
->source_rect
;
1785 *dest
= This
->target_rect
;
1787 FIXME("(%p/%p)->(%p/%p) stub\n", iface
, This
, source
, dest
);
1791 static HRESULT WINAPI
VMR7WindowlessControl_GetAspectRatioMode(IVMRWindowlessControl
*iface
,
1794 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1796 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1800 static HRESULT WINAPI
VMR7WindowlessControl_SetAspectRatioMode(IVMRWindowlessControl
*iface
,
1803 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1805 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1809 static HRESULT WINAPI
VMR7WindowlessControl_SetVideoClippingWindow(IVMRWindowlessControl
*iface
,
1812 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1814 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1818 static HRESULT WINAPI
VMR7WindowlessControl_RepaintVideo(IVMRWindowlessControl
*iface
,
1821 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1823 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1827 static HRESULT WINAPI
VMR7WindowlessControl_DisplayModeChanged(IVMRWindowlessControl
*iface
)
1829 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1831 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1835 static HRESULT WINAPI
VMR7WindowlessControl_GetCurrentImage(IVMRWindowlessControl
*iface
,
1838 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1840 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1844 static HRESULT WINAPI
VMR7WindowlessControl_SetBorderColor(IVMRWindowlessControl
*iface
,
1847 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1849 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1853 static HRESULT WINAPI
VMR7WindowlessControl_GetBorderColor(IVMRWindowlessControl
*iface
,
1856 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1858 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1862 static HRESULT WINAPI
VMR7WindowlessControl_SetColorKey(IVMRWindowlessControl
*iface
, COLORREF color
)
1864 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1866 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1870 static HRESULT WINAPI
VMR7WindowlessControl_GetColorKey(IVMRWindowlessControl
*iface
, COLORREF
*color
)
1872 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl(iface
);
1874 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1878 static const IVMRWindowlessControlVtbl VMR7_WindowlessControl_Vtbl
=
1880 VMR7WindowlessControl_QueryInterface
,
1881 VMR7WindowlessControl_AddRef
,
1882 VMR7WindowlessControl_Release
,
1883 VMR7WindowlessControl_GetNativeVideoSize
,
1884 VMR7WindowlessControl_GetMinIdealVideoSize
,
1885 VMR7WindowlessControl_GetMaxIdealVideoSize
,
1886 VMR7WindowlessControl_SetVideoPosition
,
1887 VMR7WindowlessControl_GetVideoPosition
,
1888 VMR7WindowlessControl_GetAspectRatioMode
,
1889 VMR7WindowlessControl_SetAspectRatioMode
,
1890 VMR7WindowlessControl_SetVideoClippingWindow
,
1891 VMR7WindowlessControl_RepaintVideo
,
1892 VMR7WindowlessControl_DisplayModeChanged
,
1893 VMR7WindowlessControl_GetCurrentImage
,
1894 VMR7WindowlessControl_SetBorderColor
,
1895 VMR7WindowlessControl_GetBorderColor
,
1896 VMR7WindowlessControl_SetColorKey
,
1897 VMR7WindowlessControl_GetColorKey
1900 static HRESULT WINAPI
VMR9WindowlessControl_QueryInterface(IVMRWindowlessControl9
*iface
, REFIID riid
, LPVOID
* ppv
)
1902 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1903 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
1906 static ULONG WINAPI
VMR9WindowlessControl_AddRef(IVMRWindowlessControl9
*iface
)
1908 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1909 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
1912 static ULONG WINAPI
VMR9WindowlessControl_Release(IVMRWindowlessControl9
*iface
)
1914 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1915 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
1918 static HRESULT WINAPI
VMR9WindowlessControl_GetNativeVideoSize(IVMRWindowlessControl9
*iface
, LONG
*width
, LONG
*height
, LONG
*arwidth
, LONG
*arheight
)
1920 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1921 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", iface
, This
, width
, height
, arwidth
, arheight
);
1923 if (!width
|| !height
|| !arwidth
|| !arheight
)
1925 ERR("Got no pointer\n");
1929 *width
= This
->bmiheader
.biWidth
;
1930 *height
= This
->bmiheader
.biHeight
;
1931 *arwidth
= This
->bmiheader
.biWidth
;
1932 *arheight
= This
->bmiheader
.biHeight
;
1937 static HRESULT WINAPI
VMR9WindowlessControl_GetMinIdealVideoSize(IVMRWindowlessControl9
*iface
, LONG
*width
, LONG
*height
)
1939 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1941 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1945 static HRESULT WINAPI
VMR9WindowlessControl_GetMaxIdealVideoSize(IVMRWindowlessControl9
*iface
, LONG
*width
, LONG
*height
)
1947 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1949 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
1953 static HRESULT WINAPI
VMR9WindowlessControl_SetVideoPosition(IVMRWindowlessControl9
*iface
, const RECT
*source
, const RECT
*dest
)
1955 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1957 TRACE("(%p/%p)->(%p, %p)\n", iface
, This
, source
, dest
);
1959 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
1962 This
->source_rect
= *source
;
1965 This
->target_rect
= *dest
;
1966 if (This
->baseControlWindow
.baseWindow
.hWnd
)
1968 FIXME("Output rectangle: %s\n", wine_dbgstr_rect(dest
));
1969 SetWindowPos(This
->baseControlWindow
.baseWindow
.hWnd
, NULL
, dest
->left
, dest
->top
, dest
->right
- dest
->left
,
1970 dest
->bottom
-dest
->top
, SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOOWNERZORDER
|SWP_NOREDRAW
);
1974 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
1979 static HRESULT WINAPI
VMR9WindowlessControl_GetVideoPosition(IVMRWindowlessControl9
*iface
, RECT
*source
, RECT
*dest
)
1981 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1984 *source
= This
->source_rect
;
1987 *dest
= This
->target_rect
;
1989 FIXME("(%p/%p)->(%p/%p) stub\n", iface
, This
, source
, dest
);
1993 static HRESULT WINAPI
VMR9WindowlessControl_GetAspectRatioMode(IVMRWindowlessControl9
*iface
, DWORD
*mode
)
1995 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
1997 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2001 static HRESULT WINAPI
VMR9WindowlessControl_SetAspectRatioMode(IVMRWindowlessControl9
*iface
, DWORD mode
)
2003 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2005 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2009 static HRESULT WINAPI
VMR9WindowlessControl_SetVideoClippingWindow(IVMRWindowlessControl9
*iface
, HWND hwnd
)
2011 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2013 TRACE("(%p/%p)->(%p)\n", iface
, This
, hwnd
);
2015 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
2016 This
->hWndClippingWindow
= hwnd
;
2017 VMR9_maybe_init(This
, FALSE
);
2019 IVMRSurfaceAllocatorEx9_TerminateDevice(This
->allocator
, This
->cookie
);
2020 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
2024 static HRESULT WINAPI
VMR9WindowlessControl_RepaintVideo(IVMRWindowlessControl9
*iface
, HWND hwnd
, HDC hdc
)
2026 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2029 FIXME("(%p/%p)->(...) semi-stub\n", iface
, This
);
2031 EnterCriticalSection(&This
->renderer
.filter
.csFilter
);
2032 if (hwnd
!= This
->hWndClippingWindow
&& hwnd
!= This
->baseControlWindow
.baseWindow
.hWnd
)
2034 ERR("Not handling changing windows yet!!!\n");
2035 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
2039 if (!This
->allocator_d3d9_dev
)
2041 ERR("No d3d9 device!\n");
2042 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
2043 return VFW_E_WRONG_STATE
;
2046 /* Windowless extension */
2047 hr
= IDirect3DDevice9_Present(This
->allocator_d3d9_dev
, NULL
, NULL
, This
->baseControlWindow
.baseWindow
.hWnd
, NULL
);
2048 LeaveCriticalSection(&This
->renderer
.filter
.csFilter
);
2053 static HRESULT WINAPI
VMR9WindowlessControl_DisplayModeChanged(IVMRWindowlessControl9
*iface
)
2055 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2057 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2061 static HRESULT WINAPI
VMR9WindowlessControl_GetCurrentImage(IVMRWindowlessControl9
*iface
, BYTE
**dib
)
2063 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2065 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2069 static HRESULT WINAPI
VMR9WindowlessControl_SetBorderColor(IVMRWindowlessControl9
*iface
, COLORREF color
)
2071 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2073 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2077 static HRESULT WINAPI
VMR9WindowlessControl_GetBorderColor(IVMRWindowlessControl9
*iface
, COLORREF
*color
)
2079 struct quartz_vmr
*This
= impl_from_IVMRWindowlessControl9(iface
);
2081 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2085 static const IVMRWindowlessControl9Vtbl VMR9_WindowlessControl_Vtbl
=
2087 VMR9WindowlessControl_QueryInterface
,
2088 VMR9WindowlessControl_AddRef
,
2089 VMR9WindowlessControl_Release
,
2090 VMR9WindowlessControl_GetNativeVideoSize
,
2091 VMR9WindowlessControl_GetMinIdealVideoSize
,
2092 VMR9WindowlessControl_GetMaxIdealVideoSize
,
2093 VMR9WindowlessControl_SetVideoPosition
,
2094 VMR9WindowlessControl_GetVideoPosition
,
2095 VMR9WindowlessControl_GetAspectRatioMode
,
2096 VMR9WindowlessControl_SetAspectRatioMode
,
2097 VMR9WindowlessControl_SetVideoClippingWindow
,
2098 VMR9WindowlessControl_RepaintVideo
,
2099 VMR9WindowlessControl_DisplayModeChanged
,
2100 VMR9WindowlessControl_GetCurrentImage
,
2101 VMR9WindowlessControl_SetBorderColor
,
2102 VMR9WindowlessControl_GetBorderColor
2105 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_QueryInterface(IVMRSurfaceAllocatorNotify
*iface
,
2106 REFIID riid
, LPVOID
* ppv
)
2108 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2109 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
2112 static ULONG WINAPI
VMR7SurfaceAllocatorNotify_AddRef(IVMRSurfaceAllocatorNotify
*iface
)
2114 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2115 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
2118 static ULONG WINAPI
VMR7SurfaceAllocatorNotify_Release(IVMRSurfaceAllocatorNotify
*iface
)
2120 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2121 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
2124 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_AdviseSurfaceAllocator(IVMRSurfaceAllocatorNotify
*iface
,
2126 IVMRSurfaceAllocator
*alloc
)
2128 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2130 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2134 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_SetDDrawDevice(IVMRSurfaceAllocatorNotify
*iface
,
2135 IDirectDraw7
*device
, HMONITOR monitor
)
2137 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2139 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2143 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_ChangeDDrawDevice(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_RestoreDDrawSurfaces(IVMRSurfaceAllocatorNotify
*iface
)
2154 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2156 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2160 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_NotifyEvent(IVMRSurfaceAllocatorNotify
*iface
, LONG code
,
2161 LONG_PTR param1
, LONG_PTR param2
)
2163 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2165 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2169 static HRESULT WINAPI
VMR7SurfaceAllocatorNotify_SetBorderColor(IVMRSurfaceAllocatorNotify
*iface
,
2172 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify(iface
);
2174 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2178 static const IVMRSurfaceAllocatorNotifyVtbl VMR7_SurfaceAllocatorNotify_Vtbl
=
2180 VMR7SurfaceAllocatorNotify_QueryInterface
,
2181 VMR7SurfaceAllocatorNotify_AddRef
,
2182 VMR7SurfaceAllocatorNotify_Release
,
2183 VMR7SurfaceAllocatorNotify_AdviseSurfaceAllocator
,
2184 VMR7SurfaceAllocatorNotify_SetDDrawDevice
,
2185 VMR7SurfaceAllocatorNotify_ChangeDDrawDevice
,
2186 VMR7SurfaceAllocatorNotify_RestoreDDrawSurfaces
,
2187 VMR7SurfaceAllocatorNotify_NotifyEvent
,
2188 VMR7SurfaceAllocatorNotify_SetBorderColor
2191 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_QueryInterface(IVMRSurfaceAllocatorNotify9
*iface
, REFIID riid
, LPVOID
* ppv
)
2193 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2194 return VMR9_QueryInterface(&This
->renderer
.filter
.IBaseFilter_iface
, riid
, ppv
);
2197 static ULONG WINAPI
VMR9SurfaceAllocatorNotify_AddRef(IVMRSurfaceAllocatorNotify9
*iface
)
2199 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2200 return VMR9_AddRef(&This
->renderer
.filter
.IBaseFilter_iface
);
2203 static ULONG WINAPI
VMR9SurfaceAllocatorNotify_Release(IVMRSurfaceAllocatorNotify9
*iface
)
2205 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2206 return VMR9_Release(&This
->renderer
.filter
.IBaseFilter_iface
);
2209 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_AdviseSurfaceAllocator(IVMRSurfaceAllocatorNotify9
*iface
, DWORD_PTR id
, IVMRSurfaceAllocator9
*alloc
)
2211 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2213 /* FIXME: This code is not tested!!! */
2214 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2217 if (This
->presenter
)
2218 return VFW_E_WRONG_STATE
;
2220 if (FAILED(IVMRSurfaceAllocator9_QueryInterface(alloc
, &IID_IVMRImagePresenter9
, (void **)&This
->presenter
)))
2221 return E_NOINTERFACE
;
2223 if (SUCCEEDED(IVMRSurfaceAllocator9_QueryInterface(alloc
, &IID_IVMRSurfaceAllocatorEx9
, (void **)&This
->allocator
)))
2224 This
->allocator_is_ex
= 1;
2227 This
->allocator
= (IVMRSurfaceAllocatorEx9
*)alloc
;
2228 IVMRSurfaceAllocator9_AddRef(alloc
);
2229 This
->allocator_is_ex
= 0;
2235 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_SetD3DDevice(IVMRSurfaceAllocatorNotify9
*iface
, IDirect3DDevice9
*device
, HMONITOR monitor
)
2237 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2239 FIXME("(%p/%p)->(...) semi-stub\n", iface
, This
);
2240 if (This
->allocator_d3d9_dev
)
2241 IDirect3DDevice9_Release(This
->allocator_d3d9_dev
);
2242 This
->allocator_d3d9_dev
= device
;
2243 IDirect3DDevice9_AddRef(This
->allocator_d3d9_dev
);
2244 This
->allocator_mon
= monitor
;
2249 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_ChangeD3DDevice(IVMRSurfaceAllocatorNotify9
*iface
, IDirect3DDevice9
*device
, HMONITOR monitor
)
2251 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2253 FIXME("(%p/%p)->(...) semi-stub\n", iface
, This
);
2254 if (This
->allocator_d3d9_dev
)
2255 IDirect3DDevice9_Release(This
->allocator_d3d9_dev
);
2256 This
->allocator_d3d9_dev
= device
;
2257 IDirect3DDevice9_AddRef(This
->allocator_d3d9_dev
);
2258 This
->allocator_mon
= monitor
;
2263 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_AllocateSurfaceHelper(IVMRSurfaceAllocatorNotify9
*iface
, VMR9AllocationInfo
*allocinfo
, DWORD
*numbuffers
, IDirect3DSurface9
**surface
)
2265 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2269 FIXME("(%p/%p)->(%p, %p => %u, %p) semi-stub\n", iface
, This
, allocinfo
, numbuffers
, (numbuffers
? *numbuffers
: 0), surface
);
2271 if (!allocinfo
|| !numbuffers
|| !surface
)
2274 if (!*numbuffers
|| *numbuffers
< allocinfo
->MinBuffers
)
2276 ERR("Invalid number of buffers?\n");
2277 return E_INVALIDARG
;
2280 if (!This
->allocator_d3d9_dev
)
2282 ERR("No direct3d device when requested to allocate a surface!\n");
2283 return VFW_E_WRONG_STATE
;
2286 if (allocinfo
->dwFlags
& VMR9AllocFlag_OffscreenSurface
)
2288 ERR("Creating offscreen surface\n");
2289 for (i
= 0; i
< *numbuffers
; ++i
)
2291 hr
= IDirect3DDevice9_CreateOffscreenPlainSurface(This
->allocator_d3d9_dev
, allocinfo
->dwWidth
, allocinfo
->dwHeight
,
2292 allocinfo
->Format
, allocinfo
->Pool
, &surface
[i
], NULL
);
2297 else if (allocinfo
->dwFlags
& VMR9AllocFlag_TextureSurface
)
2299 TRACE("Creating texture surface\n");
2300 for (i
= 0; i
< *numbuffers
; ++i
)
2302 IDirect3DTexture9
*texture
;
2304 hr
= IDirect3DDevice9_CreateTexture(This
->allocator_d3d9_dev
, allocinfo
->dwWidth
, allocinfo
->dwHeight
, 1, 0,
2305 allocinfo
->Format
, allocinfo
->Pool
, &texture
, NULL
);
2308 IDirect3DTexture9_GetSurfaceLevel(texture
, 0, &surface
[i
]);
2309 IDirect3DTexture9_Release(texture
);
2314 FIXME("Could not allocate for type %08x\n", allocinfo
->dwFlags
);
2318 if (i
>= allocinfo
->MinBuffers
)
2325 for ( ; i
> 0; --i
) IDirect3DSurface9_Release(surface
[i
- 1]);
2331 static HRESULT WINAPI
VMR9SurfaceAllocatorNotify_NotifyEvent(IVMRSurfaceAllocatorNotify9
*iface
, LONG code
, LONG_PTR param1
, LONG_PTR param2
)
2333 struct quartz_vmr
*This
= impl_from_IVMRSurfaceAllocatorNotify9(iface
);
2335 FIXME("(%p/%p)->(...) stub\n", iface
, This
);
2339 static const IVMRSurfaceAllocatorNotify9Vtbl VMR9_SurfaceAllocatorNotify_Vtbl
=
2341 VMR9SurfaceAllocatorNotify_QueryInterface
,
2342 VMR9SurfaceAllocatorNotify_AddRef
,
2343 VMR9SurfaceAllocatorNotify_Release
,
2344 VMR9SurfaceAllocatorNotify_AdviseSurfaceAllocator
,
2345 VMR9SurfaceAllocatorNotify_SetD3DDevice
,
2346 VMR9SurfaceAllocatorNotify_ChangeD3DDevice
,
2347 VMR9SurfaceAllocatorNotify_AllocateSurfaceHelper
,
2348 VMR9SurfaceAllocatorNotify_NotifyEvent
2351 static HRESULT
vmr_create(IUnknown
*outer_unk
, LPVOID
*ppv
, const CLSID
*clsid
)
2354 struct quartz_vmr
* pVMR
;
2356 TRACE("(%p, %p)\n", outer_unk
, ppv
);
2360 pVMR
= CoTaskMemAlloc(sizeof(struct quartz_vmr
));
2362 pVMR
->hD3d9
= LoadLibraryA("d3d9.dll");
2365 WARN("Could not load d3d9.dll\n");
2366 CoTaskMemFree(pVMR
);
2367 return VFW_E_DDRAW_CAPS_NOT_SUITABLE
;
2370 pVMR
->outer_unk
= outer_unk
;
2371 pVMR
->bUnkOuterValid
= FALSE
;
2372 pVMR
->bAggregatable
= FALSE
;
2373 pVMR
->IUnknown_inner
.lpVtbl
= &IInner_VTable
;
2374 pVMR
->IAMCertifiedOutputProtection_iface
.lpVtbl
= &IAMCertifiedOutputProtection_Vtbl
;
2375 pVMR
->IAMFilterMiscFlags_iface
.lpVtbl
= &IAMFilterMiscFlags_Vtbl
;
2378 pVMR
->allocator_d3d9_dev
= NULL
;
2379 pVMR
->allocator_mon
= NULL
;
2380 pVMR
->num_surfaces
= pVMR
->cur_surface
= 0;
2381 pVMR
->allocator
= NULL
;
2382 pVMR
->presenter
= NULL
;
2383 pVMR
->hWndClippingWindow
= NULL
;
2384 pVMR
->IVMRFilterConfig_iface
.lpVtbl
= &VMR7_FilterConfig_Vtbl
;
2385 pVMR
->IVMRFilterConfig9_iface
.lpVtbl
= &VMR9_FilterConfig_Vtbl
;
2386 pVMR
->IVMRMonitorConfig_iface
.lpVtbl
= &VMR7_MonitorConfig_Vtbl
;
2387 pVMR
->IVMRMonitorConfig9_iface
.lpVtbl
= &VMR9_MonitorConfig_Vtbl
;
2388 pVMR
->IVMRSurfaceAllocatorNotify_iface
.lpVtbl
= &VMR7_SurfaceAllocatorNotify_Vtbl
;
2389 pVMR
->IVMRSurfaceAllocatorNotify9_iface
.lpVtbl
= &VMR9_SurfaceAllocatorNotify_Vtbl
;
2390 pVMR
->IVMRWindowlessControl_iface
.lpVtbl
= &VMR7_WindowlessControl_Vtbl
;
2391 pVMR
->IVMRWindowlessControl9_iface
.lpVtbl
= &VMR9_WindowlessControl_Vtbl
;
2393 if (IsEqualGUID(clsid
, &CLSID_VideoMixingRenderer
))
2394 hr
= BaseRenderer_Init(&pVMR
->renderer
, &VMR_Vtbl
, outer_unk
, &CLSID_VideoMixingRenderer
,
2395 (DWORD_PTR
)(__FILE__
": VMR7Impl.csFilter"), &BaseFuncTable
);
2397 hr
= BaseRenderer_Init(&pVMR
->renderer
, &VMR_Vtbl
, outer_unk
, &CLSID_VideoMixingRenderer9
,
2398 (DWORD_PTR
)(__FILE__
": VMR9Impl.csFilter"), &BaseFuncTable
);
2403 hr
= BaseControlWindow_Init(&pVMR
->baseControlWindow
, &IVideoWindow_VTable
, &pVMR
->renderer
.filter
,
2404 &pVMR
->renderer
.filter
.csFilter
, &pVMR
->renderer
.pInputPin
->pin
,
2405 &renderer_BaseWindowFuncTable
);
2409 hr
= BaseControlVideo_Init(&pVMR
->baseControlVideo
, &IBasicVideo_VTable
, &pVMR
->renderer
.filter
,
2410 &pVMR
->renderer
.filter
.csFilter
, &pVMR
->renderer
.pInputPin
->pin
,
2411 &renderer_BaseControlVideoFuncTable
);
2415 *ppv
= (LPVOID
)pVMR
;
2416 ZeroMemory(&pVMR
->source_rect
, sizeof(RECT
));
2417 ZeroMemory(&pVMR
->target_rect
, sizeof(RECT
));
2418 TRACE("Created at %p\n", pVMR
);
2422 BaseRendererImpl_Release(&pVMR
->renderer
.filter
.IBaseFilter_iface
);
2423 FreeLibrary(pVMR
->hD3d9
);
2424 CoTaskMemFree(pVMR
);
2428 HRESULT
VMR7Impl_create(IUnknown
*outer_unk
, LPVOID
*ppv
)
2430 return vmr_create(outer_unk
, ppv
, &CLSID_VideoMixingRenderer
);
2433 HRESULT
VMR9Impl_create(IUnknown
*outer_unk
, LPVOID
*ppv
)
2435 return vmr_create(outer_unk
, ppv
, &CLSID_VideoMixingRenderer9
);
2439 static HRESULT WINAPI
VMR9_ImagePresenter_QueryInterface(IVMRImagePresenter9
*iface
, REFIID riid
, LPVOID
* ppv
)
2441 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2442 TRACE("(%p/%p)->(%s, %p)\n", This
, iface
, qzdebugstr_guid(riid
), ppv
);
2446 if (IsEqualIID(riid
, &IID_IUnknown
))
2447 *ppv
= (LPVOID
)&(This
->IVMRImagePresenter9_iface
);
2448 else if (IsEqualIID(riid
, &IID_IVMRImagePresenter9
))
2449 *ppv
= &This
->IVMRImagePresenter9_iface
;
2450 else if (IsEqualIID(riid
, &IID_IVMRSurfaceAllocatorEx9
))
2451 *ppv
= &This
->IVMRSurfaceAllocatorEx9_iface
;
2455 IUnknown_AddRef((IUnknown
*)(*ppv
));
2459 FIXME("No interface for %s\n", debugstr_guid(riid
));
2461 return E_NOINTERFACE
;
2464 static ULONG WINAPI
VMR9_ImagePresenter_AddRef(IVMRImagePresenter9
*iface
)
2466 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2467 ULONG refCount
= InterlockedIncrement(&This
->refCount
);
2469 TRACE("(%p)->() AddRef from %d\n", iface
, refCount
- 1);
2474 static ULONG WINAPI
VMR9_ImagePresenter_Release(IVMRImagePresenter9
*iface
)
2476 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2477 ULONG refCount
= InterlockedDecrement(&This
->refCount
);
2479 TRACE("(%p)->() Release from %d\n", iface
, refCount
+ 1);
2484 TRACE("Destroying\n");
2485 CloseHandle(This
->ack
);
2486 IDirect3D9_Release(This
->d3d9_ptr
);
2488 TRACE("Number of surfaces: %u\n", This
->num_surfaces
);
2489 for (i
= 0; i
< This
->num_surfaces
; ++i
)
2491 IDirect3DSurface9
*surface
= This
->d3d9_surfaces
[i
];
2492 TRACE("Releasing surface %p\n", surface
);
2494 IDirect3DSurface9_Release(surface
);
2497 CoTaskMemFree(This
->d3d9_surfaces
);
2498 This
->d3d9_surfaces
= NULL
;
2499 This
->num_surfaces
= 0;
2500 if (This
->d3d9_vertex
)
2502 IDirect3DVertexBuffer9_Release(This
->d3d9_vertex
);
2503 This
->d3d9_vertex
= NULL
;
2505 CoTaskMemFree(This
);
2511 static HRESULT WINAPI
VMR9_ImagePresenter_StartPresenting(IVMRImagePresenter9
*iface
, DWORD_PTR id
)
2513 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2515 TRACE("(%p/%p/%p)->(...) stub\n", iface
, This
,This
->pVMR9
);
2519 static HRESULT WINAPI
VMR9_ImagePresenter_StopPresenting(IVMRImagePresenter9
*iface
, DWORD_PTR id
)
2521 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2523 TRACE("(%p/%p/%p)->(...) stub\n", iface
, This
,This
->pVMR9
);
2527 #define USED_FVF (D3DFVF_XYZRHW | D3DFVF_TEX1)
2528 struct VERTEX
{ float x
, y
, z
, rhw
, u
, v
; };
2530 static HRESULT
VMR9_ImagePresenter_PresentTexture(VMR9DefaultAllocatorPresenterImpl
*This
, IDirect3DSurface9
*surface
)
2532 IDirect3DTexture9
*texture
= NULL
;
2535 hr
= IDirect3DDevice9_SetFVF(This
->d3d9_dev
, USED_FVF
);
2538 FIXME("SetFVF: %08x\n", hr
);
2542 hr
= IDirect3DDevice9_SetStreamSource(This
->d3d9_dev
, 0, This
->d3d9_vertex
, 0, sizeof(struct VERTEX
));
2545 FIXME("SetStreamSource: %08x\n", hr
);
2549 hr
= IDirect3DSurface9_GetContainer(surface
, &IID_IDirect3DTexture9
, (void **) &texture
);
2552 FIXME("IDirect3DSurface9_GetContainer failed\n");
2555 hr
= IDirect3DDevice9_SetTexture(This
->d3d9_dev
, 0, (IDirect3DBaseTexture9
*)texture
);
2556 IDirect3DTexture9_Release(texture
);
2559 FIXME("SetTexture: %08x\n", hr
);
2563 hr
= IDirect3DDevice9_DrawPrimitive(This
->d3d9_dev
, D3DPT_TRIANGLESTRIP
, 0, 2);
2566 FIXME("DrawPrimitive: %08x\n", hr
);
2573 static HRESULT
VMR9_ImagePresenter_PresentOffscreenSurface(VMR9DefaultAllocatorPresenterImpl
*This
, IDirect3DSurface9
*surface
)
2576 IDirect3DSurface9
*target
= NULL
;
2579 hr
= IDirect3DDevice9_GetBackBuffer(This
->d3d9_dev
, 0, 0, D3DBACKBUFFER_TYPE_MONO
, &target
);
2582 ERR("IDirect3DDevice9_GetBackBuffer -- %08x\n", hr
);
2586 /* Move rect to origin and flip it */
2587 SetRect(&target_rect
, 0, This
->pVMR9
->target_rect
.bottom
- This
->pVMR9
->target_rect
.top
,
2588 This
->pVMR9
->target_rect
.right
- This
->pVMR9
->target_rect
.left
, 0);
2590 hr
= IDirect3DDevice9_StretchRect(This
->d3d9_dev
, surface
, &This
->pVMR9
->source_rect
, target
, &target_rect
, D3DTEXF_LINEAR
);
2592 ERR("IDirect3DDevice9_StretchRect -- %08x\n", hr
);
2593 IDirect3DSurface9_Release(target
);
2598 static HRESULT WINAPI
VMR9_ImagePresenter_PresentImage(IVMRImagePresenter9
*iface
, DWORD_PTR id
, VMR9PresentationInfo
*info
)
2600 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRImagePresenter9(iface
);
2603 BOOL render
= FALSE
;
2605 TRACE("(%p/%p/%p)->(...) stub\n", iface
, This
, This
->pVMR9
);
2606 GetWindowRect(This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, &output
);
2607 TRACE("Output rectangle: %s\n", wine_dbgstr_rect(&output
));
2609 /* This might happen if we don't have active focus (eg on a different virtual desktop) */
2610 if (!This
->d3d9_dev
)
2613 /* Display image here */
2614 hr
= IDirect3DDevice9_Clear(This
->d3d9_dev
, 0, NULL
, D3DCLEAR_TARGET
, D3DCOLOR_XRGB(0, 0, 0), 1.0f
, 0);
2616 FIXME("hr: %08x\n", hr
);
2617 hr
= IDirect3DDevice9_BeginScene(This
->d3d9_dev
);
2620 if (This
->d3d9_vertex
)
2621 hr
= VMR9_ImagePresenter_PresentTexture(This
, info
->lpSurf
);
2623 hr
= VMR9_ImagePresenter_PresentOffscreenSurface(This
, info
->lpSurf
);
2624 render
= SUCCEEDED(hr
);
2627 FIXME("BeginScene: %08x\n", hr
);
2628 hr
= IDirect3DDevice9_EndScene(This
->d3d9_dev
);
2629 if (render
&& SUCCEEDED(hr
))
2631 hr
= IDirect3DDevice9_Present(This
->d3d9_dev
, NULL
, NULL
, This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, NULL
);
2633 FIXME("Presenting image: %08x\n", hr
);
2639 static const IVMRImagePresenter9Vtbl VMR9_ImagePresenter
=
2641 VMR9_ImagePresenter_QueryInterface
,
2642 VMR9_ImagePresenter_AddRef
,
2643 VMR9_ImagePresenter_Release
,
2644 VMR9_ImagePresenter_StartPresenting
,
2645 VMR9_ImagePresenter_StopPresenting
,
2646 VMR9_ImagePresenter_PresentImage
2649 static HRESULT WINAPI
VMR9_SurfaceAllocator_QueryInterface(IVMRSurfaceAllocatorEx9
*iface
, REFIID riid
, LPVOID
* ppv
)
2651 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2653 return VMR9_ImagePresenter_QueryInterface(&This
->IVMRImagePresenter9_iface
, riid
, ppv
);
2656 static ULONG WINAPI
VMR9_SurfaceAllocator_AddRef(IVMRSurfaceAllocatorEx9
*iface
)
2658 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2660 return VMR9_ImagePresenter_AddRef(&This
->IVMRImagePresenter9_iface
);
2663 static ULONG WINAPI
VMR9_SurfaceAllocator_Release(IVMRSurfaceAllocatorEx9
*iface
)
2665 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2667 return VMR9_ImagePresenter_Release(&This
->IVMRImagePresenter9_iface
);
2670 static HRESULT
VMR9_SurfaceAllocator_SetAllocationSettings(VMR9DefaultAllocatorPresenterImpl
*This
, VMR9AllocationInfo
*allocinfo
)
2676 if (!(allocinfo
->dwFlags
& VMR9AllocFlag_TextureSurface
))
2677 /* Only needed for texture surfaces */
2680 hr
= IDirect3DDevice9_GetDeviceCaps(This
->d3d9_dev
, &caps
);
2684 if (!(caps
.TextureCaps
& D3DPTEXTURECAPS_POW2
) || (caps
.TextureCaps
& D3DPTEXTURECAPS_SQUAREONLY
))
2686 width
= allocinfo
->dwWidth
;
2687 height
= allocinfo
->dwHeight
;
2692 while (width
< allocinfo
->dwWidth
)
2695 while (height
< allocinfo
->dwHeight
)
2697 FIXME("NPOW2 support missing, not using proper surfaces!\n");
2700 if (caps
.TextureCaps
& D3DPTEXTURECAPS_SQUAREONLY
)
2706 FIXME("Square texture support required..\n");
2709 hr
= IDirect3DDevice9_CreateVertexBuffer(This
->d3d9_dev
, 4 * sizeof(struct VERTEX
), D3DUSAGE_WRITEONLY
, USED_FVF
, allocinfo
->Pool
, &This
->d3d9_vertex
, NULL
);
2712 ERR("Couldn't create vertex buffer: %08x\n", hr
);
2717 allocinfo
->dwHeight
= height
;
2718 allocinfo
->dwWidth
= width
;
2723 static DWORD WINAPI
MessageLoop(LPVOID lpParameter
)
2727 VMR9DefaultAllocatorPresenterImpl
*This
= lpParameter
;
2729 TRACE("Starting message loop\n");
2731 if (FAILED(BaseWindowImpl_PrepareWindow(&This
->pVMR9
->baseControlWindow
.baseWindow
)))
2733 FIXME("Failed to prepare window\n");
2737 SetEvent(This
->ack
);
2738 while ((fGotMessage
= GetMessageW(&msg
, NULL
, 0, 0)) != 0 && fGotMessage
!= -1)
2740 TranslateMessage(&msg
);
2741 DispatchMessageW(&msg
);
2744 TRACE("End of message loop\n");
2749 static UINT
d3d9_adapter_from_hwnd(IDirect3D9
*d3d9
, HWND hwnd
, HMONITOR
*mon_out
)
2754 mon
= MonitorFromWindow(hwnd
, MONITOR_DEFAULTTONULL
);
2759 for (d3d9_adapter
= 0; d3d9_adapter
< IDirect3D9_GetAdapterCount(d3d9
); ++d3d9_adapter
)
2761 if (mon
== IDirect3D9_GetAdapterMonitor(d3d9
, d3d9_adapter
))
2764 if (d3d9_adapter
>= IDirect3D9_GetAdapterCount(d3d9
))
2769 return d3d9_adapter
;
2772 static BOOL
CreateRenderingWindow(VMR9DefaultAllocatorPresenterImpl
*This
, VMR9AllocationInfo
*info
, DWORD
*numbuffers
)
2774 D3DPRESENT_PARAMETERS d3dpp
;
2778 TRACE("(%p)->()\n", This
);
2780 This
->hWndThread
= CreateThread(NULL
, 0, MessageLoop
, This
, 0, &This
->tid
);
2781 if (!This
->hWndThread
)
2784 WaitForSingleObject(This
->ack
, INFINITE
);
2786 if (!This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
) return FALSE
;
2788 /* Obtain a monitor and d3d9 device */
2789 d3d9_adapter
= d3d9_adapter_from_hwnd(This
->d3d9_ptr
, This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, &This
->hMon
);
2791 /* Now try to create the d3d9 device */
2792 ZeroMemory(&d3dpp
, sizeof(d3dpp
));
2793 d3dpp
.Windowed
= TRUE
;
2794 d3dpp
.hDeviceWindow
= This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
;
2795 d3dpp
.SwapEffect
= D3DSWAPEFFECT_DISCARD
;
2796 d3dpp
.BackBufferHeight
= This
->pVMR9
->target_rect
.bottom
- This
->pVMR9
->target_rect
.top
;
2797 d3dpp
.BackBufferWidth
= This
->pVMR9
->target_rect
.right
- This
->pVMR9
->target_rect
.left
;
2799 hr
= IDirect3D9_CreateDevice(This
->d3d9_ptr
, d3d9_adapter
, D3DDEVTYPE_HAL
, NULL
, D3DCREATE_MIXED_VERTEXPROCESSING
, &d3dpp
, &This
->d3d9_dev
);
2802 ERR("Could not create device: %08x\n", hr
);
2803 BaseWindowImpl_DoneWithWindow(&This
->pVMR9
->baseControlWindow
.baseWindow
);
2806 IVMRSurfaceAllocatorNotify9_SetD3DDevice(This
->SurfaceAllocatorNotify
, This
->d3d9_dev
, This
->hMon
);
2808 This
->d3d9_surfaces
= CoTaskMemAlloc(*numbuffers
* sizeof(IDirect3DSurface9
*));
2809 ZeroMemory(This
->d3d9_surfaces
, *numbuffers
* sizeof(IDirect3DSurface9
*));
2811 hr
= VMR9_SurfaceAllocator_SetAllocationSettings(This
, info
);
2813 ERR("Setting allocation settings failed: %08x\n", hr
);
2817 hr
= IVMRSurfaceAllocatorNotify9_AllocateSurfaceHelper(This
->SurfaceAllocatorNotify
, info
, numbuffers
, This
->d3d9_surfaces
);
2819 ERR("Allocating surfaces failed: %08x\n", hr
);
2824 IVMRSurfaceAllocatorEx9_TerminateDevice(This
->pVMR9
->allocator
, This
->pVMR9
->cookie
);
2825 BaseWindowImpl_DoneWithWindow(&This
->pVMR9
->baseControlWindow
.baseWindow
);
2829 This
->num_surfaces
= *numbuffers
;
2834 static HRESULT WINAPI
VMR9_SurfaceAllocator_InitializeDevice(IVMRSurfaceAllocatorEx9
*iface
, DWORD_PTR id
, VMR9AllocationInfo
*allocinfo
, DWORD
*numbuffers
)
2836 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2838 if (This
->pVMR9
->mode
!= VMR9Mode_Windowed
&& !This
->pVMR9
->hWndClippingWindow
)
2840 ERR("No window set\n");
2841 return VFW_E_WRONG_STATE
;
2844 This
->info
= *allocinfo
;
2846 if (!CreateRenderingWindow(This
, allocinfo
, numbuffers
))
2848 ERR("Failed to create rendering window, expect no output!\n");
2849 return VFW_E_WRONG_STATE
;
2855 static HRESULT WINAPI
VMR9_SurfaceAllocator_TerminateDevice(IVMRSurfaceAllocatorEx9
*iface
, DWORD_PTR id
)
2857 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2859 if (!This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
)
2864 SendMessageW(This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
, WM_CLOSE
, 0, 0);
2865 PostThreadMessageW(This
->tid
, WM_QUIT
, 0, 0);
2866 WaitForSingleObject(This
->hWndThread
, INFINITE
);
2867 This
->hWndThread
= NULL
;
2868 BaseWindowImpl_DoneWithWindow(&This
->pVMR9
->baseControlWindow
.baseWindow
);
2873 /* Recreate all surfaces (If allocated as D3DPOOL_DEFAULT) and survive! */
2874 static HRESULT
VMR9_SurfaceAllocator_UpdateDeviceReset(VMR9DefaultAllocatorPresenterImpl
*This
)
2876 struct VERTEX t_vert
[4];
2880 D3DPRESENT_PARAMETERS d3dpp
;
2883 if (!This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
)
2889 if (!This
->d3d9_surfaces
|| !This
->reset
)
2892 This
->reset
= FALSE
;
2893 TRACE("RESETTING\n");
2894 if (This
->d3d9_vertex
)
2896 IDirect3DVertexBuffer9_Release(This
->d3d9_vertex
);
2897 This
->d3d9_vertex
= NULL
;
2900 for (i
= 0; i
< This
->num_surfaces
; ++i
)
2902 IDirect3DSurface9
*surface
= This
->d3d9_surfaces
[i
];
2903 TRACE("Releasing surface %p\n", surface
);
2905 IDirect3DSurface9_Release(surface
);
2907 ZeroMemory(This
->d3d9_surfaces
, sizeof(IDirect3DSurface9
*) * This
->num_surfaces
);
2909 /* Now try to create the d3d9 device */
2910 ZeroMemory(&d3dpp
, sizeof(d3dpp
));
2911 d3dpp
.Windowed
= TRUE
;
2912 d3dpp
.hDeviceWindow
= This
->pVMR9
->baseControlWindow
.baseWindow
.hWnd
;
2913 d3dpp
.SwapEffect
= D3DSWAPEFFECT_DISCARD
;
2916 IDirect3DDevice9_Release(This
->d3d9_dev
);
2917 This
->d3d9_dev
= NULL
;
2918 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
);
2921 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
);
2924 ERR("--> Creating device: %08x\n", hr
);
2928 IVMRSurfaceAllocatorNotify9_ChangeD3DDevice(This
->SurfaceAllocatorNotify
, This
->d3d9_dev
, This
->hMon
);
2930 IVMRSurfaceAllocatorNotify9_AllocateSurfaceHelper(This
->SurfaceAllocatorNotify
, &This
->info
, &This
->num_surfaces
, This
->d3d9_surfaces
);
2932 This
->reset
= FALSE
;
2934 if (!(This
->info
.dwFlags
& VMR9AllocFlag_TextureSurface
))
2937 hr
= IDirect3DDevice9_CreateVertexBuffer(This
->d3d9_dev
, 4 * sizeof(struct VERTEX
), D3DUSAGE_WRITEONLY
, USED_FVF
,
2938 This
->info
.Pool
, &This
->d3d9_vertex
, NULL
);
2940 width
= This
->info
.dwWidth
;
2941 height
= This
->info
.dwHeight
;
2943 for (i
= 0; i
< sizeof(t_vert
) / sizeof(t_vert
[0]); ++i
)
2947 t_vert
[i
].x
= (float)This
->pVMR9
->target_rect
.right
- (float)This
->pVMR9
->target_rect
.left
- 0.5f
;
2948 t_vert
[i
].u
= (float)This
->pVMR9
->source_rect
.right
/ (float)width
;
2952 t_vert
[i
].x
= -0.5f
;
2953 t_vert
[i
].u
= (float)This
->pVMR9
->source_rect
.left
/ (float)width
;
2958 t_vert
[i
].y
= -0.5f
;
2959 t_vert
[i
].v
= (float)This
->pVMR9
->source_rect
.bottom
/ (float)height
;
2963 t_vert
[i
].y
= (float)This
->pVMR9
->target_rect
.bottom
- (float)This
->pVMR9
->target_rect
.top
- 0.5f
;
2964 t_vert
[i
].v
= (float)This
->pVMR9
->source_rect
.top
/ (float)height
;
2967 t_vert
[i
].rhw
= 1.0f
;
2970 FIXME("Vertex rectangle:\n");
2971 FIXME("X, Y: %f, %f\n", t_vert
[0].x
, t_vert
[0].y
);
2972 FIXME("X, Y: %f, %f\n", t_vert
[3].x
, t_vert
[3].y
);
2973 FIXME("TOP, LEFT: %f, %f\n", t_vert
[0].u
, t_vert
[0].v
);
2974 FIXME("DOWN, BOTTOM: %f, %f\n", t_vert
[3].u
, t_vert
[3].v
);
2976 IDirect3DVertexBuffer9_Lock(This
->d3d9_vertex
, 0, sizeof(t_vert
), &bits
, 0);
2977 memcpy(bits
, t_vert
, sizeof(t_vert
));
2978 IDirect3DVertexBuffer9_Unlock(This
->d3d9_vertex
);
2983 static HRESULT WINAPI
VMR9_SurfaceAllocator_GetSurface(IVMRSurfaceAllocatorEx9
*iface
, DWORD_PTR id
, DWORD surfaceindex
, DWORD flags
, IDirect3DSurface9
**surface
)
2985 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
2987 /* Update everything first, this is needed because the surface might be destroyed in the reset */
2988 if (!This
->d3d9_dev
)
2990 TRACE("Device has left me!\n");
2994 VMR9_SurfaceAllocator_UpdateDeviceReset(This
);
2996 if (surfaceindex
>= This
->num_surfaces
)
2998 ERR("surfaceindex is greater than num_surfaces\n");
3001 *surface
= This
->d3d9_surfaces
[surfaceindex
];
3002 IDirect3DSurface9_AddRef(*surface
);
3007 static HRESULT WINAPI
VMR9_SurfaceAllocator_AdviseNotify(IVMRSurfaceAllocatorEx9
*iface
, IVMRSurfaceAllocatorNotify9
*allocnotify
)
3009 VMR9DefaultAllocatorPresenterImpl
*This
= impl_from_IVMRSurfaceAllocatorEx9(iface
);
3011 TRACE("(%p/%p)->(...)\n", iface
, This
);
3013 /* No AddRef taken here or the base VMR9 filter would never be destroyed */
3014 This
->SurfaceAllocatorNotify
= allocnotify
;
3018 static const IVMRSurfaceAllocatorEx9Vtbl VMR9_SurfaceAllocator
=
3020 VMR9_SurfaceAllocator_QueryInterface
,
3021 VMR9_SurfaceAllocator_AddRef
,
3022 VMR9_SurfaceAllocator_Release
,
3023 VMR9_SurfaceAllocator_InitializeDevice
,
3024 VMR9_SurfaceAllocator_TerminateDevice
,
3025 VMR9_SurfaceAllocator_GetSurface
,
3026 VMR9_SurfaceAllocator_AdviseNotify
,
3027 NULL
/* This isn't the SurfaceAllocatorEx type yet, working on it */
3030 static IDirect3D9
*init_d3d9(HMODULE d3d9_handle
)
3032 IDirect3D9
* (__stdcall
* d3d9_create
)(UINT SDKVersion
);
3034 d3d9_create
= (void *)GetProcAddress(d3d9_handle
, "Direct3DCreate9");
3035 if (!d3d9_create
) return NULL
;
3037 return d3d9_create(D3D_SDK_VERSION
);
3040 static HRESULT
VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr
*parent
, LPVOID
* ppv
)
3044 VMR9DefaultAllocatorPresenterImpl
* This
;
3046 This
= CoTaskMemAlloc(sizeof(VMR9DefaultAllocatorPresenterImpl
));
3048 return E_OUTOFMEMORY
;
3050 This
->d3d9_ptr
= init_d3d9(parent
->hD3d9
);
3051 if (!This
->d3d9_ptr
)
3053 WARN("Could not initialize d3d9.dll\n");
3054 CoTaskMemFree(This
);
3055 return VFW_E_DDRAW_CAPS_NOT_SUITABLE
;
3061 D3DDISPLAYMODE mode
;
3063 hr
= IDirect3D9_EnumAdapterModes(This
->d3d9_ptr
, i
++, D3DFMT_X8R8G8B8
, 0, &mode
);
3064 if (hr
== D3DERR_INVALIDCALL
) break; /* out of adapters */
3065 } while (FAILED(hr
));
3067 ERR("HR: %08x\n", hr
);
3068 if (hr
== D3DERR_NOTAVAILABLE
)
3070 ERR("Format not supported\n");
3071 IDirect3D9_Release(This
->d3d9_ptr
);
3072 CoTaskMemFree(This
);
3073 return VFW_E_DDRAW_CAPS_NOT_SUITABLE
;
3076 This
->IVMRImagePresenter9_iface
.lpVtbl
= &VMR9_ImagePresenter
;
3077 This
->IVMRSurfaceAllocatorEx9_iface
.lpVtbl
= &VMR9_SurfaceAllocator
;
3080 This
->pVMR9
= parent
;
3081 This
->d3d9_surfaces
= NULL
;
3082 This
->d3d9_dev
= NULL
;
3084 This
->d3d9_vertex
= NULL
;
3085 This
->num_surfaces
= 0;
3086 This
->hWndThread
= NULL
;
3087 This
->ack
= CreateEventW(NULL
, 0, 0, NULL
);
3088 This
->SurfaceAllocatorNotify
= NULL
;
3089 This
->reset
= FALSE
;
3091 *ppv
= &This
->IVMRImagePresenter9_iface
;