Purge hb font on Minikin font destruction

am: 1ea4165

* commit '1ea4165cef7651770fe28a0eada3da593bb149ad':
  Purge hb font on Minikin font destruction

Change-Id: Idb2034353407e8b390cc07862803f846d5adea0c
This commit is contained in:
Raph Levien
2016-04-07 22:38:47 +00:00
committed by android-build-merger
5 changed files with 40 additions and 0 deletions

View File

@@ -96,6 +96,8 @@ class MinikinFontFreeType;
class MinikinFont : public MinikinRefCounted {
public:
virtual ~MinikinFont();
virtual float GetHorizontalAdvance(uint32_t glyph_id,
const MinikinPaint &paint) const = 0;

View File

@@ -32,6 +32,7 @@ minikin_src_files := \
Measurement.cpp \
MinikinInternal.cpp \
MinikinRefCounted.cpp \
MinikinFont.cpp \
MinikinFontFreeType.cpp \
SparseBitSet.cpp \
WordBreaker.cpp

View File

@@ -75,6 +75,10 @@ public:
mCache.clear();
}
void remove(int32_t fontId) {
mCache.remove(fontId);
}
private:
static const size_t kMaxEntries = 100;
@@ -95,6 +99,12 @@ void purgeHbFontCacheLocked() {
getFontCacheLocked()->clear();
}
void purgeHbFont(const MinikinFont* minikinFont) {
AutoMutex _l(gMinikinLock);
const int32_t fontId = minikinFont->GetUniqueId();
getFontCacheLocked()->remove(fontId);
}
hb_font_t* getHbFontLocked(MinikinFont* minikinFont) {
assertMinikinLocked();
static hb_font_t* nullFaceFont = nullptr;

View File

@@ -23,6 +23,7 @@ namespace android {
class MinikinFont;
void purgeHbFontCacheLocked();
void purgeHbFont(const MinikinFont* minikinFont);
hb_font_t* getHbFontLocked(MinikinFont* minikinFont);
} // namespace android

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <minikin/MinikinFont.h>
#include "HbFontCache.h"
namespace android {
MinikinFont::~MinikinFont() {
purgeHbFont(this);
}
} // namespace android