12#include <unicode/regex.h>
15#include <officecfg/Office/Common.hxx>
18#include <rtl/ustring.hxx>
19#include <rtl/ustrbuf.hxx>
32 maDenyList.insert(
ImplMatcher(
"Windows",
"",
"Intel\\(R\\) Corporation",
"",
"27\\.20\\.100\\.8681"));
56 css::uno::Sequence<OUString>
result(
rSet.size());
57 auto resultRange = asNonConstRange(result);
59 for (
const auto& rItem : rSet)
62 rItem.maOS.replaceAll(
"%",
"%25").replaceAll(
"/",
"%2F").replaceAll(
";",
"%3B") +
"/" +
63 rItem.maOSVersion.replaceAll(
"%",
"%25").replaceAll(
"/",
"%2F").replaceAll(
";",
"%3B") +
"/" +
64 rItem.maPlatformVendor.replaceAll(
"%",
"%25").replaceAll(
"/",
"%2F").replaceAll(
";",
"%3B") +
"/" +
65 rItem.maDevice.replaceAll(
"%",
"%25").replaceAll(
"/",
"%2F").replaceAll(
";",
"%3B") +
"/" +
66 rItem.maDriverVersion.replaceAll(
"%",
"%25").replaceAll(
"/",
"%2F").replaceAll(
";",
"%3B");
72OUString
getToken(std::u16string_view
string, sal_Int32& index)
78 while ((p = token.find(
'%', i)) != std::u16string_view::npos)
80 if (
static_cast<sal_Int32
>(p) > i)
81 result.append(token.substr(i, p - i));
82 if (p < token.size() - 2)
92 result.append(token.substr(i));
94 return result.makeStringAndClear();
101 for (
const auto& rItem : rSequence)
107 m.maPlatformVendor =
getToken(rItem, index);
109 m.maDriverVersion =
getToken(rItem, index);
117bool match(
const OUString& rPattern,
const OUString& rInput)
119 if (rPattern.isEmpty())
122 UErrorCode nIcuError(U_ZERO_ERROR);
123 icu::UnicodeString sIcuPattern(
reinterpret_cast<const UChar*
>(rPattern.getStr()), rPattern.getLength());
124 icu::UnicodeString sIcuInput(
reinterpret_cast<const UChar*
>(rInput.getStr()), rInput.getLength());
125 icu::RegexMatcher aMatcher(sIcuPattern, sIcuInput, 0, nIcuError);
127 return U_SUCCESS(nIcuError) && aMatcher.matches(nIcuError) && U_SUCCESS(nIcuError);
133 if (!rListEntry.
maOS.isEmpty() && rListEntry.
maOS !=
"Windows")
136 if (!rListEntry.
maOS.isEmpty() && rListEntry.
maOS !=
"Linux")
139 if (!rListEntry.
maOS.isEmpty() && rListEntry.
maOS !=
"OS X")
159 for (
const auto& rListEntry : rList)
161 SAL_INFO(
"opencl",
"Looking for match for platform=" << rPlatform <<
", device=" << rDevice <<
162 " in " << sKindOfList <<
" entry=" << rListEntry);
164 if (
match(rListEntry, rPlatform, rDevice))
179 result.mbUseOpenCL = officecfg::Office::Common::Misc::UseOpenCL::get();
181 result.maDenyList = StringSequenceToSetOfImplMatcher(officecfg::Office::Common::Misc::OpenCLDenyList::get());
182 result.maAllowList = StringSequenceToSetOfImplMatcher(officecfg::Office::Common::Misc::OpenCLAllowList::get());
191 officecfg::Office::Common::Misc::UseOpenCL::set(
mbUseOpenCL, batch);
192 officecfg::Office::Common::Misc::OpenCLDenyList::set(SetOfImplMatcherToStringSequence(
maDenyList), batch);
193 officecfg::Office::Common::Misc::OpenCLAllowList::set(SetOfImplMatcherToStringSequence(
maAllowList), batch);
215 SAL_INFO(
"opencl",
"Fallback: rejecting platform=" << rPlatform <<
", device=" << rDevice);
222 "UseOpenCL=" << (rConfig.
mbUseOpenCL ?
"YES" :
"NO") <<
","
232 "OS=" << rImpl.
maOS <<
","
245 for (
auto i =
rSet.cbegin();
i !=
rSet.cend(); ++
i)
247 if (
i !=
rSet.cbegin())
static std::shared_ptr< ConfigurationChanges > create()
#define SAL_INFO(area, stream)
sal_Int32 getToken(const Context &rContext, const char *pToken)
bool match(const sal_Unicode *pWild, const sal_Unicode *pStr, const sal_Unicode cEscape)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
std::ostream & operator<<(std::ostream &rStream, const OpenCLConfig &rConfig)
OUString maPlatformVendor
std::set< ImplMatcher > ImplMatcherSet
bool operator==(const OpenCLConfig &r) const
bool checkImplementation(const OpenCLPlatformInfo &rPlatform, const OpenCLDeviceInfo &rDevice) const
ImplMatcherSet maDenyList
ImplMatcherSet maAllowList
bool operator!=(const OpenCLConfig &r) const
static OpenCLConfig get()