diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-11-27 19:12:31 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-11-27 21:18:46 +0100 |
commit | 5b5d154d0b2de8a3a9d82e0a078cf7e835062d13 (patch) | |
tree | f1f1cff5765bdf7f4d060ecac8c6b7ef5976c4aa | |
parent | port blacklist from mozilla code to LibreOffice, part2 (diff) | |
download | core-5b5d154d0b2de8a3a9d82e0a078cf7e835062d13.tar.gz core-5b5d154d0b2de8a3a9d82e0a078cf7e835062d13.zip |
connect all pieces for OpenGL windows blacklist, part 3
Change-Id: Iaaafe7da8e717f7b127ab5806773a5a5d75b82d5
-rw-r--r-- | vcl/inc/opengl/win/WinDeviceInfo.hxx | 3 | ||||
-rw-r--r-- | vcl/opengl/win/WinDeviceInfo.cxx | 132 |
2 files changed, 130 insertions, 5 deletions
diff --git a/vcl/inc/opengl/win/WinDeviceInfo.hxx b/vcl/inc/opengl/win/WinDeviceInfo.hxx index 524198bd5bca..7e0b80fa2f28 100644 --- a/vcl/inc/opengl/win/WinDeviceInfo.hxx +++ b/vcl/inc/opengl/win/WinDeviceInfo.hxx @@ -109,7 +109,7 @@ struct DriverInfo static const DeviceFamilyVector* GetDeviceFamily(DeviceFamily id); static DeviceFamilyVector* mpDeviceFamilies[DeviceFamilyMax]; - OUString maModel, maHardware, maProduct, maManufacturer; + OUString maSuggestedVersion; }; #define GFX_DRIVER_VERSION(a,b,c,d) \ @@ -167,6 +167,7 @@ private: void GetData(); void FillBlacklist(); + bool FindBlocklistedDeviceInList(); static OUString* mpDeviceVendors[wgl::DeviceVendorMax]; static std::vector<wgl::DriverInfo> maDriverInfo; diff --git a/vcl/opengl/win/WinDeviceInfo.cxx b/vcl/opengl/win/WinDeviceInfo.cxx index e319c43537aa..86614e83405e 100644 --- a/vcl/opengl/win/WinDeviceInfo.cxx +++ b/vcl/opengl/win/WinDeviceInfo.cxx @@ -87,7 +87,8 @@ void GetDLLVersion(const sal_Unicode* aDLLPath, OUString& aVersion) template<typename T, size_t N> size_t ArrayLength(T (&aArr)[N]) { - return N; + (void) aArr; + return N; } #define GFX_DRIVER_VERSION(a,b,c,d) \ @@ -201,6 +202,29 @@ enum { kWindows10 = 0x60004 }; + +wgl::OperatingSystem WindowsVersionToOperatingSystem(int32_t aWindowsVersion) +{ + switch(aWindowsVersion) { + case kWindowsXP: + return wgl::DRIVER_OS_WINDOWS_XP; + case kWindowsServer2003: + return wgl::DRIVER_OS_WINDOWS_SERVER_2003; + case kWindowsVista: + return wgl::DRIVER_OS_WINDOWS_VISTA; + case kWindows7: + return wgl::DRIVER_OS_WINDOWS_7; + case kWindows8: + return wgl::DRIVER_OS_WINDOWS_8; + case kWindows8_1: + return wgl::DRIVER_OS_WINDOWS_8_1; + case kWindowsUnknown: + default: + return wgl::DRIVER_OS_UNKNOWN; + }; +} + + int32_t WindowsOSVersion() { static int32_t winVersion = kWindowsUnknown; @@ -321,7 +345,7 @@ template<typename T> void appendIntegerWithPadding(OUString& rString, T value, s { OUString aValue = OUString::number(value, 16); sal_Int32 nLength = aValue.getLength(); - sal_Int32 nPadLength = nChars - nLength; + sal_uInt32 nPadLength = nChars - nLength; assert(nPadLength >= 0); OUStringBuffer aBuffer; for (sal_uInt32 i = 0; i < nPadLength; ++i) @@ -366,7 +390,10 @@ DriverInfo::DriverInfo(OperatingSystem os, const OUString& vendor, meComparisonOp(op), mnDriverVersion(driverVersion), mnDriverVersionMax(0) -{} +{ + if (suggestedVersion) + maSuggestedVersion = OStringToOUString(OString(suggestedVersion), RTL_TEXTENCODING_UTF8); +} DriverInfo::DriverInfo(const DriverInfo& aOrig) : meOperatingSystem(aOrig.meOperatingSystem), @@ -551,6 +578,97 @@ WinOpenGLDeviceInfo::~WinOpenGLDeviceInfo() { } +bool WinOpenGLDeviceInfo::FindBlocklistedDeviceInList() +{ + uint64_t driverVersion; + ParseDriverVersion(maDriverVersion, &driverVersion); + + wgl::OperatingSystem eOS = WindowsVersionToOperatingSystem(mnWindowsVersion); + bool match = false; + uint32_t i = 0; + for (; i < maDriverInfo.size(); i++) { + if (maDriverInfo[i].meOperatingSystem != wgl::DRIVER_OS_ALL && + maDriverInfo[i].meOperatingSystem != eOS) + { + continue; + } + + if (maDriverInfo[i].mnOperatingSystemVersion && maDriverInfo[i].mnOperatingSystemVersion != mnWindowsVersion) { + continue; + } + + if (!maDriverInfo[i].maAdapterVendor.equalsIgnoreAsciiCase(GetDeviceVendor(wgl::VendorAll)) && + !maDriverInfo[i].maAdapterVendor.equalsIgnoreAsciiCase(maAdapterVendorID)) { + continue; + } + + if (maDriverInfo[i].mpDevices != wgl::DriverInfo::allDevices && maDriverInfo[i].mpDevices->size()) { + bool deviceMatches = false; + for (uint32_t j = 0; j < maDriverInfo[i].mpDevices->size(); j++) { + if ((*maDriverInfo[i].mpDevices)[j].equalsIgnoreAsciiCase(maAdapterDeviceID)) { + deviceMatches = true; + break; + } + } + + if (!deviceMatches) { + continue; + } + } + +#if defined(XP_WIN) || defined(ANDROID) + switch (maDriverInfo[i].meComparisonOp) { + case DRIVER_LESS_THAN: + match = driverVersion < maDriverInfo[i].mnDriverVersion; + break; + case DRIVER_LESS_THAN_OR_EQUAL: + match = driverVersion <= maDriverInfo[i].mnDriverVersion; + break; + case DRIVER_GREATER_THAN: + match = driverVersion > maDriverInfo[i].mnDriverVersion; + break; + case DRIVER_GREATER_THAN_OR_EQUAL: + match = driverVersion >= maDriverInfo[i].mnDriverVersion; + break; + case DRIVER_EQUAL: + match = driverVersion == maDriverInfo[i].mnDriverVersion; + break; + case DRIVER_NOT_EQUAL: + match = driverVersion != maDriverInfo[i].mnDriverVersion; + break; + case DRIVER_BETWEEN_EXCLUSIVE: + match = driverVersion > maDriverInfo[i].mnDriverVersion && driverVersion < maDriverInfo[i].mnDriverVersionMax; + break; + case DRIVER_BETWEEN_INCLUSIVE: + match = driverVersion >= maDriverInfo[i].mnDriverVersion && driverVersion <= maDriverInfo[i].mnDriverVersionMax; + break; + case DRIVER_BETWEEN_INCLUSIVE_START: + match = driverVersion >= maDriverInfo[i].mnDriverVersion && driverVersion < maDriverInfo[i].mnDriverVersionMax; + break; + case DRIVER_COMPARISON_IGNORED: + // We don't have a comparison op, so we match everything. + match = true; + break; + default: + SAL_WARN("vcl.opengl", "Bogus op in GfxDriverInfo"); + break; + } +#else + // We don't care what driver version it was. We only check OS version and if + // the device matches. + match = true; +#endif + + if (match || maDriverInfo[i].mnDriverVersion == wgl::DriverInfo::allDriverVersions) { + match = true; + SAL_WARN("vcl.opengl", "use : " << maDriverInfo[i].maSuggestedVersion); + break; + } + } + + return match; +} + bool WinOpenGLDeviceInfo::isDeviceBlocked() { SAL_INFO("vcl.opengl", maDriverVersion); @@ -561,7 +679,13 @@ bool WinOpenGLDeviceInfo::isDeviceBlocked() SAL_INFO("vcl.opengl", maAdapterSubsysID); SAL_INFO("vcl.opengl", maDeviceKey); SAL_INFO("vcl.opengl", maDeviceString); - return false; + + // Check if the device is blocked from the downloaded blocklist. If not, check + // the static list after that. This order is used so that we can later escape + // out of static blocks (i.e. if we were wrong or something was patched, we + // can back out our static block without doing a release). + + return FindBlocklistedDeviceInList(); } void WinOpenGLDeviceInfo::GetData() |