Commit 5e45f57e authored by Damien Fouilleul's avatar Damien Fouilleul

- Optimized clipping, removed the extra child window which prevented some...

- Optimized clipping, removed the extra child window which prevented some buggy Intel DirectX drivers to render (can't handle too many sub-windows ?). Resizing looks smoother on IE, needs a lot of compatiblity checks on other apps such as VB, Delphi, etc...
- Fixed initial volume setting
parent c03f5fee
...@@ -52,26 +52,6 @@ using namespace std; ...@@ -52,26 +52,6 @@ using namespace std;
//class factory //class factory
static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch( uMsg )
{
case WM_ERASEBKGND:
return 1L;
case WM_PAINT:
PAINTSTRUCT ps;
if( GetUpdateRect(hWnd, NULL, FALSE) )
{
BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
}
return 0L;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
};
static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
VLCPlugin *p_instance = reinterpret_cast<VLCPlugin *>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); VLCPlugin *p_instance = reinterpret_cast<VLCPlugin *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
switch( uMsg ) switch( uMsg )
...@@ -125,26 +105,6 @@ VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID ...@@ -125,26 +105,6 @@ VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID
_inplace_wndclass_atom = 0; _inplace_wndclass_atom = 0;
} }
if( ! GetClassInfo(hInstance, getVideoWndClassName(), &wClass) )
{
wClass.style = CS_NOCLOSE;
wClass.lpfnWndProc = VLCVideoClassWndProc;
wClass.cbClsExtra = 0;
wClass.cbWndExtra = 0;
wClass.hInstance = hInstance;
wClass.hIcon = NULL;
wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wClass.hbrBackground = NULL;
wClass.lpszMenuName = NULL;
wClass.lpszClassName = getVideoWndClassName();
_video_wndclass_atom = RegisterClass(&wClass);
}
else
{
_video_wndclass_atom = 0;
}
HBITMAP hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); HBITMAP hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
if( NULL != hbitmap ) if( NULL != hbitmap )
{ {
...@@ -166,9 +126,6 @@ VLCPluginClass::~VLCPluginClass() ...@@ -166,9 +126,6 @@ VLCPluginClass::~VLCPluginClass()
if( 0 != _inplace_wndclass_atom ) if( 0 != _inplace_wndclass_atom )
UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance); UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance);
if( 0 != _video_wndclass_atom )
UnregisterClass(MAKEINTATOM(_video_wndclass_atom), _hinstance);
if( NULL != _inplace_picture ) if( NULL != _inplace_picture )
_inplace_picture->Release(); _inplace_picture->Release();
}; };
...@@ -244,7 +201,6 @@ STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock) ...@@ -244,7 +201,6 @@ STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock)
VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) : VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
_inplacewnd(NULL), _inplacewnd(NULL),
_videownd(NULL),
_p_class(p_class), _p_class(p_class),
_i_ref(1UL), _i_ref(1UL),
_p_libvlc(NULL), _p_libvlc(NULL),
...@@ -376,98 +332,6 @@ STDMETHODIMP_(ULONG) VLCPlugin::Release(void) ...@@ -376,98 +332,6 @@ STDMETHODIMP_(ULONG) VLCPlugin::Release(void)
////////////////////////////////////// //////////////////////////////////////
/*
** we use a window to represent plugin viewport,
** whose geometry is limited by the clipping rectangle
** all drawing within this window must follow must
** follow coordinates system described in lprPosRect
*/
static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect)
{
RECT bounds;
bounds.right = lprPosRect->right-lprPosRect->left;
if( lprClipRect->left <= lprPosRect->left )
{
// left side is not clipped out
bounds.left = 0;
if( lprClipRect->right >= lprPosRect->right )
{
// right side is not clipped out, no change
}
else if( lprClipRect->right >= lprPosRect->left )
{
// right side is clipped out
lprPosRect->right = lprClipRect->right;
}
else
{
// outside of clipping rectange, not visible
lprPosRect->right = lprPosRect->left;
}
}
else
{
// left side is clipped out
bounds.left = lprPosRect->left-lprClipRect->left;
bounds.right += bounds.left;
lprPosRect->left = lprClipRect->left;
if( lprClipRect->right >= lprPosRect->right )
{
// right side is not clipped out
}
else
{
// right side is clipped out
lprPosRect->right = lprClipRect->right;
}
}
bounds.bottom = lprPosRect->bottom-lprPosRect->top;
if( lprClipRect->top <= lprPosRect->top )
{
// top side is not clipped out
bounds.top = 0;
if( lprClipRect->bottom >= lprPosRect->bottom )
{
// bottom side is not clipped out, no change
}
else if( lprClipRect->bottom >= lprPosRect->top )
{
// bottom side is clipped out
lprPosRect->bottom = lprClipRect->bottom;
}
else
{
// outside of clipping rectange, not visible
lprPosRect->right = lprPosRect->left;
}
}
else
{
bounds.top = lprPosRect->top-lprClipRect->top;
bounds.bottom += bounds.top;
lprPosRect->top = lprClipRect->top;
if( lprClipRect->bottom >= lprPosRect->bottom )
{
// bottom side is not clipped out
}
else
{
// bottom side is clipped out
lprPosRect->bottom = lprClipRect->bottom;
}
}
*lprClipRect = *lprPosRect;
*lprPosRect = bounds;
};
HRESULT VLCPlugin::onInit(void) HRESULT VLCPlugin::onInit(void)
{ {
if( NULL == _p_libvlc ) if( NULL == _p_libvlc )
...@@ -600,19 +464,6 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) ...@@ -600,19 +464,6 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
if( _b_autoloop ) if( _b_autoloop )
ppsz_argv[ppsz_argc++] = "--loop"; ppsz_argv[ppsz_argc++] = "--loop";
// initial volume setting
char volBuffer[16];
ppsz_argv[ppsz_argc++] = "--volume";
if( _b_mute )
{
ppsz_argv[ppsz_argc++] = "0";
}
else
{
snprintf(volBuffer, sizeof(volBuffer), "%d", _i_volume);
ppsz_argv[ppsz_argc++] = volBuffer;
}
if( IsDebuggerPresent() ) if( IsDebuggerPresent() )
{ {
/* /*
...@@ -634,6 +485,14 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) ...@@ -634,6 +485,14 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
return E_FAIL; return E_FAIL;
} }
// initial volume setting
libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
if( _b_mute )
{
libvlc_audio_set_mute(_p_libvlc, TRUE, NULL);
}
// initial playlist item
if( SysStringLen(_bstr_mrl) > 0 ) if( SysStringLen(_bstr_mrl) > 0 )
{ {
char *psz_mrl = NULL; char *psz_mrl = NULL;
...@@ -792,32 +651,26 @@ BOOL VLCPlugin::isInPlaceActive(void) ...@@ -792,32 +651,26 @@ BOOL VLCPlugin::isInPlaceActive(void)
HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect) HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{ {
RECT posRect = *lprcPosRect;
RECT clipRect = *lprcClipRect; RECT clipRect = *lprcClipRect;
/* /*
** record keeping of control geometry within container ** record keeping of control geometry within container
*/ */
_posRect = posRect; _posRect = *lprcPosRect;
/*
** convert posRect & clipRect to match control viewport coordinates
*/
getViewportCoords(&posRect, &clipRect);
/* /*
** Create a window for in place activated control. ** Create a window for in place activated control.
** the window geometry matches the control viewport ** the window geometry matches the control viewport
** within container so that embedded video is always ** within container so that embedded video is always
** properly clipped. ** properly displayed.
*/ */
_inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(), _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),
"VLC Plugin In-Place Window", "VLC Plugin In-Place Window",
WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
clipRect.left, lprcPosRect->left,
clipRect.top, lprcPosRect->top,
clipRect.right-clipRect.left, lprcPosRect->right-lprcPosRect->left,
clipRect.bottom-clipRect.top, lprcPosRect->bottom-lprcPosRect->top,
hwndParent, hwndParent,
0, 0,
_p_class->getHInstance(), _p_class->getHInstance(),
...@@ -829,32 +682,11 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc ...@@ -829,32 +682,11 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
/* /* change cliprect coordinates system relative to window bounding rect */
** VLC embedded video automatically grows to cover client OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
** area of parent window.
** hence create a such a 'parent' window whose geometry
** is always correct relative to the viewport bounds
*/
_videownd = CreateWindow(_p_class->getVideoWndClassName(),
"VLC Plugin Video Window",
WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE,
posRect.left,
posRect.top,
posRect.right-posRect.left,
posRect.bottom-posRect.top,
_inplacewnd,
0,
_p_class->getHInstance(),
NULL
);
if( NULL == _videownd ) HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
{ SetWindowRgn(_inplacewnd, clipRgn, TRUE);
DestroyWindow(_inplacewnd);
return E_FAIL;
}
SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
if( _b_usermode ) if( _b_usermode )
{ {
...@@ -866,13 +698,13 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc ...@@ -866,13 +698,13 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
/* set internal video width and height */ /* set internal video width and height */
libvlc_video_set_size(p_libvlc, libvlc_video_set_size(p_libvlc,
posRect.right-posRect.left, lprcPosRect->right-lprcPosRect->left,
posRect.bottom-posRect.top, lprcPosRect->bottom-lprcPosRect->top,
NULL ); NULL );
/* set internal video parent window */ /* set internal video parent window */
libvlc_video_set_parent(p_libvlc, libvlc_video_set_parent(p_libvlc,
reinterpret_cast<libvlc_drawable_t>(_videownd), NULL); reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL);
if( _b_autoplay & (libvlc_playlist_items_count(p_libvlc, NULL) > 0) ) if( _b_autoplay & (libvlc_playlist_items_count(p_libvlc, NULL) > 0) )
{ {
...@@ -895,8 +727,6 @@ HRESULT VLCPlugin::onInPlaceDeactivate(void) ...@@ -895,8 +727,6 @@ HRESULT VLCPlugin::onInPlaceDeactivate(void)
fireOnStopEvent(); fireOnStopEvent();
} }
DestroyWindow(_videownd);
_videownd = NULL;
DestroyWindow(_inplacewnd); DestroyWindow(_inplacewnd);
_inplacewnd = NULL; _inplacewnd = NULL;
...@@ -912,7 +742,7 @@ void VLCPlugin::setVisible(BOOL fVisible) ...@@ -912,7 +742,7 @@ void VLCPlugin::setVisible(BOOL fVisible)
{ {
ShowWindow(_inplacewnd, fVisible ? SW_SHOW : SW_HIDE); ShowWindow(_inplacewnd, fVisible ? SW_SHOW : SW_HIDE);
if( fVisible ) if( fVisible )
InvalidateRect(_videownd, NULL, TRUE); InvalidateRect(_inplacewnd, NULL, TRUE);
} }
setDirty(TRUE); setDirty(TRUE);
firePropChangedEvent(DISPID_Visible); firePropChangedEvent(DISPID_Visible);
...@@ -1079,52 +909,38 @@ void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect) ...@@ -1079,52 +909,38 @@ void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect)
void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect) void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{ {
RECT clipRect = *lprcClipRect; RECT clipRect = *lprcClipRect;
RECT posRect = *lprcPosRect;
//RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); //RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
/* /*
** record keeping of control geometry within container ** record keeping of control geometry within container
*/ */
_posRect = posRect; _posRect = *lprcPosRect;
/*
** convert posRect & clipRect to match control viewport coordinates
*/
getViewportCoords(&posRect, &clipRect);
/* /*
** change in-place window geometry to match clipping region ** change in-place window geometry to match clipping region
*/ */
SetWindowPos(_inplacewnd, NULL, SetWindowPos(_inplacewnd, NULL,
clipRect.left, lprcPosRect->left,
clipRect.top, lprcPosRect->top,
clipRect.right-clipRect.left, lprcPosRect->right-lprcPosRect->left,
clipRect.bottom-clipRect.top, lprcPosRect->bottom-lprcPosRect->top,
SWP_NOACTIVATE| SWP_NOACTIVATE|
SWP_NOCOPYBITS| SWP_NOCOPYBITS|
SWP_NOZORDER| SWP_NOZORDER|
SWP_NOOWNERZORDER ); SWP_NOOWNERZORDER );
/* /* change cliprect coordinates system relative to window bounding rect */
** change video window geometry to match object bounds within clipping region OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
*/ HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
SetWindowPos(_videownd, NULL, SetWindowRgn(_inplacewnd, clipRgn, TRUE);
posRect.left,
posRect.top,
posRect.right-posRect.left,
posRect.bottom-posRect.top,
SWP_NOACTIVATE|
SWP_NOCOPYBITS|
SWP_NOZORDER|
SWP_NOOWNERZORDER );
//RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); //RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
if( isRunning() ) if( isRunning() )
{ {
libvlc_video_set_size(_p_libvlc, libvlc_video_set_size(_p_libvlc,
posRect.right-posRect.left, lprcPosRect->right-lprcPosRect->left,
posRect.bottom-posRect.top, lprcPosRect->bottom-lprcPosRect->top,
NULL ); NULL );
} }
}; };
......
...@@ -52,7 +52,6 @@ public: ...@@ -52,7 +52,6 @@ public:
REFCLSID getClassID(void) { return (REFCLSID)_classid; }; REFCLSID getClassID(void) { return (REFCLSID)_classid; };
LPCSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); }; LPCSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); };
LPCSTR getVideoWndClassName(void) const { return TEXT("VLC Plugin Video"); };
HINSTANCE getHInstance(void) const { return _hinstance; }; HINSTANCE getHInstance(void) const { return _hinstance; };
LPPICTURE getInPlacePict(void) const LPPICTURE getInPlacePict(void) const
{ if( NULL != _inplace_picture) _inplace_picture->AddRef(); return _inplace_picture; }; { if( NULL != _inplace_picture) _inplace_picture->AddRef(); return _inplace_picture; };
...@@ -67,7 +66,6 @@ private: ...@@ -67,7 +66,6 @@ private:
HINSTANCE _hinstance; HINSTANCE _hinstance;
CLSID _classid; CLSID _classid;
ATOM _inplace_wndclass_atom; ATOM _inplace_wndclass_atom;
ATOM _video_wndclass_atom;
LPPICTURE _inplace_picture; LPPICTURE _inplace_picture;
}; };
...@@ -241,10 +239,8 @@ private: ...@@ -241,10 +239,8 @@ private:
class VLCViewObject *vlcViewObject; class VLCViewObject *vlcViewObject;
class VLCDataObject *vlcDataObject; class VLCDataObject *vlcDataObject;
// in place activated window (Clipping window) // in place activated window (Plugin window)
HWND _inplacewnd; HWND _inplacewnd;
// video window (Drawing window)
HWND _videownd;
VLCPluginClass* _p_class; VLCPluginClass* _p_class;
ULONG _i_ref; ULONG _i_ref;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment