Commit ae18df14 authored by Geoffroy Couprie's avatar Geoffroy Couprie Committed by Jean-Baptiste Kempf

Skins: don't use GetProcAddress for TransparentBlt, AlphaBlend and...

Skins: don't use GetProcAddress for TransparentBlt, AlphaBlend and SetLayeredWindowAttributes they're available since win2k
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent e68cc628
......@@ -3680,7 +3680,7 @@ if test "${enable_skins2}" != "no" ||
ALIASES="${ALIASES} svlc"
VLC_ADD_CPPFLAGS([skins2],[-U_OFF_T_ -U_off_t -Imodules/gui/skins2 -DWIN32_SKINS])
VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
VLC_ADD_LIBS([skins2],[-loleaut32 -lwinspool -lwinmm -lshell32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32])
VLC_ADD_LIBS([skins2],[-loleaut32 -lwinspool -lwinmm -lshell32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32 -lmsimg32 -luser32])
else if test "${skins2_missing_lib}" = "no" && (test "${SYS}" = "darwin"); then
VLC_ADD_PLUGIN([skins2])
......
......@@ -24,6 +24,10 @@
#ifdef WIN32_SKINS
#include <windows.h>
#include <winuser.h>
#include <wingdi.h>
#include "win32_factory.hpp"
#include "win32_graphics.hpp"
#include "win32_timer.hpp"
......@@ -108,8 +112,7 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
Win32Factory::Win32Factory( intf_thread_t *pIntf ):
OSFactory( pIntf ), TransparentBlt( NULL ), AlphaBlend( NULL ),
SetLayeredWindowAttributes( NULL ), m_hParentWindow( NULL ),
OSFactory( pIntf ), m_hParentWindow( NULL ),
m_dirSep( "\\" )
{
// see init()
......@@ -197,39 +200,6 @@ bool Win32Factory::init()
// Initialize the OLE library (for drag & drop)
OleInitialize( NULL );
// We dynamically load msimg32.dll to get a pointer to TransparentBlt()
m_hMsimg32 = LoadLibrary( _T("msimg32.dll") );
if( !m_hMsimg32 ||
!( TransparentBlt =
(BOOL (WINAPI*)(HDC, int, int, int, int,
HDC, int, int, int, int, unsigned int))
GetProcAddress( m_hMsimg32, _T("TransparentBlt") ) ) )
{
TransparentBlt = NULL;
msg_Dbg( getIntf(), "couldn't find TransparentBlt(), "
"falling back to BitBlt()" );
}
if( !m_hMsimg32 ||
!( AlphaBlend =
(BOOL (WINAPI*)( HDC, int, int, int, int, HDC, int, int,
int, int, BLENDFUNCTION ))
GetProcAddress( m_hMsimg32, _T("AlphaBlend") ) ) )
{
AlphaBlend = NULL;
msg_Dbg( getIntf(), "couldn't find AlphaBlend()" );
}
// Idem for user32.dll and SetLayeredWindowAttributes()
m_hUser32 = LoadLibrary( _T("user32.dll") );
if( !m_hUser32 ||
!( SetLayeredWindowAttributes =
(BOOL (WINAPI *)(HWND, COLORREF, BYTE, DWORD))
GetProcAddress( m_hUser32, _T("SetLayeredWindowAttributes") ) ) )
{
SetLayeredWindowAttributes = NULL;
msg_Dbg( getIntf(), "couldn't find SetLayeredWindowAttributes()" );
}
// Initialize the resource path
char *datadir = config_GetUserDir( VLC_DATA_DIR );
m_resourcePath.push_back( (string)datadir + "\\skins" );
......@@ -255,12 +225,6 @@ Win32Factory::~Win32Factory()
removeFromTray();
if( m_hParentWindow ) DestroyWindow( m_hParentWindow );
// Unload msimg32.dll and user32.dll
if( m_hMsimg32 )
FreeLibrary( m_hMsimg32 );
if( m_hUser32 )
FreeLibrary( m_hUser32 );
}
......
......@@ -116,18 +116,6 @@ public:
/// Map to find the GenericWindow associated with a Win32Window
map<HWND, GenericWindow*> m_windowMap;
/// Functions dynamically loaded from the dll, because they don't exist
/// on Win9x/NT4
// We dynamically load msimg32.dll to get a pointer to TransparentBlt()
BOOL (WINAPI *TransparentBlt)( HDC, int, int, int, int,
HDC, int, int, int, int, UINT );
BOOL (WINAPI *AlphaBlend)( HDC, int, int, int, int,
HDC, int, int, int, int, BLENDFUNCTION );
// Idem for user32.dll and SetLayeredWindowAttributes()
BOOL (WINAPI *SetLayeredWindowAttributes)( HWND, COLORREF,
BYTE, DWORD );
HWND getParentWindow() { return m_hParentWindow; }
private:
......
......@@ -191,20 +191,11 @@ void Win32Graphics::drawBitmap( const GenericBitmap &rBitmap,
bf.AlphaFormat = AC_SRC_ALPHA;
// Blend the image onto the internal DC
BOOL (WINAPI *AlphaBlend)( HDC, int, int, int, int, HDC, int, int,
int, int, BLENDFUNCTION );
AlphaBlend = ((Win32Factory*)OSFactory::instance( getIntf() ))->AlphaBlend;
if( AlphaBlend &&
!AlphaBlend( m_hDC, xDest, yDest, width, height, hDC, 0, 0,
if( !AlphaBlend( m_hDC, xDest, yDest, width, height, hDC, 0, 0,
width, height, bf ) )
{
msg_Err( getIntf(), "AlphaBlend() failed" );
}
else if( !AlphaBlend )
{
// Copy the image onto the internal DC
BitBlt( m_hDC, xDest, yDest, width, height, hDC, 0, 0, SRCCOPY );
}
// Add the bitmap mask to the global graphics mask
CombineRgn( m_mask, m_mask, mask, RGN_OR );
......
......@@ -194,27 +194,24 @@ void Win32Window::setOpacity( uint8_t value ) const
}
else
{
if( pFactory->SetLayeredWindowAttributes )
if( ! m_isLayered )
{
if( ! m_isLayered )
{
// (Re)Add the WS_EX_LAYERED attribute.
// Resizing will be very slow, now :)
SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
GetWindowLongPtr( m_hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED );
// Redraw the window, otherwise we may end up with a grey
// rectangle for some strange reason
RedrawWindow(m_hWnd, NULL, NULL,
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
m_isLayered = true;
}
// Change the opacity
pFactory->SetLayeredWindowAttributes(
m_hWnd, 0, value, LWA_ALPHA|LWA_COLORKEY );
// (Re)Add the WS_EX_LAYERED attribute.
// Resizing will be very slow, now :)
SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
GetWindowLongPtr( m_hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED );
// Redraw the window, otherwise we may end up with a grey
// rectangle for some strange reason
RedrawWindow(m_hWnd, NULL, NULL,
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
m_isLayered = true;
}
// Change the opacity
SetLayeredWindowAttributes(
m_hWnd, 0, value, LWA_ALPHA|LWA_COLORKEY );
}
}
......
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