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"
8 #include "gfxFontEntry.h"
10 using namespace mozilla
;
12 void gfx::PaletteCache::SetPaletteValueSet(
13 const gfx::FontPaletteValueSet
* aSet
) {
14 mPaletteValueSet
= aSet
;
18 already_AddRefed
<gfx::FontPalette
> gfx::PaletteCache::GetPaletteFor(
19 gfxFontEntry
* aFontEntry
, nsAtom
* aPaletteName
) {
20 auto entry
= Lookup(std::pair(aFontEntry
, aPaletteName
));
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();