Bug 1700051: part 26) Correct typo in comment of `mozInlineSpellWordUtil::BuildSoftTe...
[gecko.git] / dom / canvas / SanitizeRenderer.h
blob1e7c5782026638866ebd443635bc8b558008178d
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_RendererSanitizer_h
7 #define mozilla_RendererSanitizer_h
9 #include <string>
11 namespace mozilla {
12 namespace dom {
14 inline static void SanitizeRenderer(std::string& aRenderer) {
15 // Remove DRM, kernel, and LLVM versions exposed by amdgpu.
16 // The string looks like this:
18 // AMD Radeon (TM) GPU model Graphics (GPUgeneration, DRM
19 // DRMversion, kernelversion, LLVM LLVMversion)
21 // e.g. AMD Radeon (TM) RX 460 Graphics (POLARIS11,
22 // DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)
24 // OR
26 // AMD Radeon GPU model (GPUgeneration, DRM DRMversion, kernelversion, LLVM
27 // LLVMversion)
29 // Just in case, let's handle the case without GPUgeneration, i.e.
31 // AMD Radeon GPU model (DRM DRMversion, kernelversion, LLVM LLVMversion)
33 // even though there's no existence proof of this variant.
34 if (aRenderer.empty()) {
35 return;
37 if (aRenderer.back() != ')') {
38 return;
40 auto pos = aRenderer.find(", DRM ");
41 if (pos != std::string::npos) {
42 aRenderer.resize(pos);
43 aRenderer.push_back(')');
44 return;
46 pos = aRenderer.find(" (DRM ");
47 if (pos != std::string::npos) {
48 aRenderer.resize(pos);
49 return;
53 }; // namespace dom
54 }; // namespace mozilla
56 #endif // mozilla_RendererSanitizer_h