Bug 1919083 - [ci] Enable os-integration variant for more suites, r=jmaher
[gecko.git] / gfx / thebes / FontPaletteCache.cpp
blob02ca74097794d4f733de48b13ef56bc222f25869
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 #include "FontPaletteCache.h"
7 #include "COLRFonts.h"
8 #include "gfxFontEntry.h"
10 using namespace mozilla;
12 void gfx::PaletteCache::SetPaletteValueSet(
13 const gfx::FontPaletteValueSet* aSet) {
14 mPaletteValueSet = aSet;
15 Clear();
18 already_AddRefed<gfx::FontPalette> gfx::PaletteCache::GetPaletteFor(
19 gfxFontEntry* aFontEntry, nsAtom* aPaletteName) {
20 auto entry = Lookup(std::pair(aFontEntry, aPaletteName));
21 if (!entry) {
22 CacheData newData;
23 newData.mKey = std::pair(aFontEntry, aPaletteName);
25 gfxFontEntry::AutoHBFace face = aFontEntry->GetHBFace();
26 newData.mPalette = new FontPalette(gfx::COLRFonts::CreateColorPalette(
27 face, mPaletteValueSet, aPaletteName, aFontEntry->FamilyName()));
29 entry.Set(std::move(newData));
31 RefPtr result = entry.Data().mPalette;
32 return result.forget();