Bug 611689 - Mask ClearType settings from flash to prevent paint buffer alpha corruption. r=roc, a=betaN

This commit is contained in:
Jim Mathies 2011-01-14 16:13:43 -06:00
Родитель 8e6579e472
Коммит 75f2992343
4 изменённых файлов: 50 добавлений и 3 удалений

Просмотреть файл

@ -161,6 +161,7 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface)
#endif // OS_WIN #endif // OS_WIN
#if defined(OS_WIN) #if defined(OS_WIN)
InitPopupMenuHook(); InitPopupMenuHook();
HookSystemParametersInfo();
#endif // OS_WIN #endif // OS_WIN
#ifdef MOZ_X11 #ifdef MOZ_X11
// Maemo flash can render plugin with any provided rectangle and not require this quirk. // Maemo flash can render plugin with any provided rectangle and not require this quirk.
@ -1210,6 +1211,47 @@ PluginInstanceChild::PluginWindowProc(HWND hWnd,
return res; return res;
} }
/* system parameters info hook for flash */
typedef BOOL (WINAPI *User32SystemParametersInfoW)(UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni);
static User32SystemParametersInfoW sUser32SystemParametersInfoWStub = NULL;
static BOOL WINAPI User32SystemParametersInfoHook(UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni)
{
if (!sUser32SystemParametersInfoWStub) {
NS_NOTREACHED("sUser32SystemParametersInfoWStub not set??");
return FALSE;
}
// Tell them cleartype is disabled, so they don't mess with
// the alpha channel in our buffers.
if (uiAction == SPI_GETFONTSMOOTHINGTYPE && pvParam) {
*((UINT*)(pvParam)) = FE_FONTSMOOTHINGSTANDARD;
return TRUE;
}
return sUser32SystemParametersInfoWStub(uiAction, uiParam, pvParam, fWinIni);
}
void
PluginInstanceChild::HookSystemParametersInfo()
{
if (!(GetQuirks() & PluginModuleChild::QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS))
return;
if (sUser32SystemParametersInfoWStub)
return;
sUser32Intercept.Init("gdi32.dll");
sUser32Intercept.AddHook("SystemParametersInfoW", User32SystemParametersInfoHook,
(void**) &sUser32SystemParametersInfoWStub);
}
/* set window long ptr hook for flash */ /* set window long ptr hook for flash */
/* /*

Просмотреть файл

@ -279,6 +279,7 @@ private:
int nIndex, int nIndex,
LONG newLong); LONG newLong);
#endif #endif
void HookSystemParametersInfo();
class FlashThrottleAsyncMsg : public ChildAsyncCall class FlashThrottleAsyncMsg : public ChildAsyncCall
{ {

Просмотреть файл

@ -1788,7 +1788,7 @@ PluginModuleChild::AllocPPluginInstance(const nsCString& aMimeType,
InitQuirksModes(aMimeType); InitQuirksModes(aMimeType);
#ifdef XP_WIN #ifdef XP_WIN
if (mQuirks & QUIRK_FLASH_HOOK_GETWINDOINFO) { if (mQuirks & QUIRK_FLASH_HOOK_GETWINDOWINFO) {
sUser32Intercept.Init("user32.dll"); sUser32Intercept.Init("user32.dll");
sUser32Intercept.AddHook("GetWindowInfo", PMCGetWindowInfoHook, sUser32Intercept.AddHook("GetWindowInfo", PMCGetWindowInfoHook,
(void**) &sGetWindowInfoPtrStub); (void**) &sGetWindowInfoPtrStub);
@ -1827,7 +1827,8 @@ PluginModuleChild::InitQuirksModes(const nsCString& aMimeType)
mQuirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK; mQuirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK;
mQuirks |= QUIRK_FLASH_THROTTLE_WMUSER_EVENTS; mQuirks |= QUIRK_FLASH_THROTTLE_WMUSER_EVENTS;
mQuirks |= QUIRK_FLASH_HOOK_SETLONGPTR; mQuirks |= QUIRK_FLASH_HOOK_SETLONGPTR;
mQuirks |= QUIRK_FLASH_HOOK_GETWINDOINFO; mQuirks |= QUIRK_FLASH_HOOK_GETWINDOWINFO;
mQuirks |= QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS;
} }
#endif #endif
} }

Просмотреть файл

@ -234,7 +234,10 @@ public:
// Win32: Catch get window info calls on the browser and tweak the // Win32: Catch get window info calls on the browser and tweak the
// results so mouse input works when flash is displaying it's settings // results so mouse input works when flash is displaying it's settings
// window. // window.
QUIRK_FLASH_HOOK_GETWINDOINFO = 1 << 5, QUIRK_FLASH_HOOK_GETWINDOWINFO = 1 << 5,
// Win: Flash trashes the alpha channel in our buffers when cleartype
// is enabled. Mask this setting so they don't know it's enabled.
QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS = 1 << 6,
}; };
int GetQuirks() { return mQuirks; } int GetQuirks() { return mQuirks; }