[vlc-commits] commit: Skins: don't use GetProcAddress for TransparentBlt, AlphaBlend and SetLayeredWindowAttributes they're available since win2k ( Geoffroy Couprie )
git at videolan.org
git at videolan.org
Thu Nov 4 19:58:24 CET 2010
vlc | branch: master | Geoffroy Couprie <geal at videolan.org> | Thu Nov 4 10:11:56 2010 +0100| [ae18df14cf13641312ec1e011a2f4ebaca65232e] | committer: Jean-Baptiste Kempf
Skins: don't use GetProcAddress for TransparentBlt, AlphaBlend and SetLayeredWindowAttributes they're available since win2k
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ae18df14cf13641312ec1e011a2f4ebaca65232e
---
configure.ac | 2 +-
modules/gui/skins2/win32/win32_factory.cpp | 46 +++------------------------
modules/gui/skins2/win32/win32_factory.hpp | 12 -------
modules/gui/skins2/win32/win32_graphics.cpp | 11 +------
modules/gui/skins2/win32/win32_window.cpp | 35 +++++++++-----------
5 files changed, 23 insertions(+), 83 deletions(-)
diff --git a/configure.ac b/configure.ac
index ac95209..ca47abc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp
index 7e0b5f9..418bbf5 100644
--- a/modules/gui/skins2/win32/win32_factory.cpp
+++ b/modules/gui/skins2/win32/win32_factory.cpp
@@ -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 );
}
diff --git a/modules/gui/skins2/win32/win32_factory.hpp b/modules/gui/skins2/win32/win32_factory.hpp
index 49d8596..c6645ca 100644
--- a/modules/gui/skins2/win32/win32_factory.hpp
+++ b/modules/gui/skins2/win32/win32_factory.hpp
@@ -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:
diff --git a/modules/gui/skins2/win32/win32_graphics.cpp b/modules/gui/skins2/win32/win32_graphics.cpp
index 9ded675..141863c 100644
--- a/modules/gui/skins2/win32/win32_graphics.cpp
+++ b/modules/gui/skins2/win32/win32_graphics.cpp
@@ -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 );
diff --git a/modules/gui/skins2/win32/win32_window.cpp b/modules/gui/skins2/win32/win32_window.cpp
index d71c74c..7700d9c 100644
--- a/modules/gui/skins2/win32/win32_window.cpp
+++ b/modules/gui/skins2/win32/win32_window.cpp
@@ -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 );
}
}
More information about the vlc-commits
mailing list