mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 1416542 - lock access to the blob image font data table. r=nical
MozReview-Commit-ID: 30dwLt74L38
This commit is contained in:
parent
3ed4d2fbab
commit
001e79ef65
@ -5,6 +5,7 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "gfxUtils.h"
|
#include "gfxUtils.h"
|
||||||
|
#include "mozilla/Mutex.h"
|
||||||
#include "mozilla/Range.h"
|
#include "mozilla/Range.h"
|
||||||
#include "mozilla/gfx/2D.h"
|
#include "mozilla/gfx/2D.h"
|
||||||
#include "mozilla/gfx/InlineTranslator.h"
|
#include "mozilla/gfx/InlineTranslator.h"
|
||||||
@ -51,11 +52,13 @@ struct FontTemplate {
|
|||||||
RefPtr<UnscaledFont> mUnscaledFont;
|
RefPtr<UnscaledFont> mUnscaledFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StaticMutex sFontDataTableLock;
|
||||||
std::unordered_map<FontKey, FontTemplate> sFontDataTable;
|
std::unordered_map<FontKey, FontTemplate> sFontDataTable;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void
|
void
|
||||||
AddFontData(WrFontKey aKey, const uint8_t *aData, size_t aSize, uint32_t aIndex, const ArcVecU8 *aVec) {
|
AddFontData(WrFontKey aKey, const uint8_t *aData, size_t aSize, uint32_t aIndex, const ArcVecU8 *aVec) {
|
||||||
|
StaticMutexAutoLock lock(sFontDataTableLock);
|
||||||
auto i = sFontDataTable.find(aKey);
|
auto i = sFontDataTable.find(aKey);
|
||||||
if (i == sFontDataTable.end()) {
|
if (i == sFontDataTable.end()) {
|
||||||
FontTemplate font;
|
FontTemplate font;
|
||||||
@ -69,6 +72,7 @@ AddFontData(WrFontKey aKey, const uint8_t *aData, size_t aSize, uint32_t aIndex,
|
|||||||
|
|
||||||
void
|
void
|
||||||
AddNativeFontHandle(WrFontKey aKey, void* aHandle, uint32_t aIndex) {
|
AddNativeFontHandle(WrFontKey aKey, void* aHandle, uint32_t aIndex) {
|
||||||
|
StaticMutexAutoLock lock(sFontDataTableLock);
|
||||||
auto i = sFontDataTable.find(aKey);
|
auto i = sFontDataTable.find(aKey);
|
||||||
if (i == sFontDataTable.end()) {
|
if (i == sFontDataTable.end()) {
|
||||||
FontTemplate font;
|
FontTemplate font;
|
||||||
@ -91,6 +95,7 @@ AddNativeFontHandle(WrFontKey aKey, void* aHandle, uint32_t aIndex) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DeleteFontData(WrFontKey aKey) {
|
DeleteFontData(WrFontKey aKey) {
|
||||||
|
StaticMutexAutoLock lock(sFontDataTableLock);
|
||||||
auto i = sFontDataTable.find(aKey);
|
auto i = sFontDataTable.find(aKey);
|
||||||
if (i != sFontDataTable.end()) {
|
if (i != sFontDataTable.end()) {
|
||||||
if (i->second.mVec) {
|
if (i->second.mVec) {
|
||||||
@ -103,8 +108,13 @@ DeleteFontData(WrFontKey aKey) {
|
|||||||
|
|
||||||
RefPtr<UnscaledFont>
|
RefPtr<UnscaledFont>
|
||||||
GetUnscaledFont(Translator *aTranslator, wr::FontKey key) {
|
GetUnscaledFont(Translator *aTranslator, wr::FontKey key) {
|
||||||
MOZ_ASSERT(sFontDataTable.find(key) != sFontDataTable.end());
|
StaticMutexAutoLock lock(sFontDataTableLock);
|
||||||
auto &data = sFontDataTable[key];
|
auto i = sFontDataTable.find(key);
|
||||||
|
if (i == sFontDataTable.end()) {
|
||||||
|
gfxDevCrash(LogReason::UnscaledFontNotFound) << "Failed to get UnscaledFont entry for FontKey " << key.mHandle;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto &data = i->second;
|
||||||
if (data.mUnscaledFont) {
|
if (data.mUnscaledFont) {
|
||||||
return data.mUnscaledFont;
|
return data.mUnscaledFont;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user