Bug 1337616 - Stop adding a new font key for every glyph array. r=jmuizelaar

This commit is contained in:
Mason Chang 2017-02-14 15:16:23 -08:00
Родитель f9c6425844
Коммит 78c642ecdc
3 изменённых файлов: 12 добавлений и 10 удалений

Просмотреть файл

@ -50,6 +50,7 @@ public:
#endif
virtual already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
virtual bool GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton);
virtual bool CanSerialize() override { return true; }
#ifdef USE_CAIRO_SCALED_FONT
cairo_font_face_t* GetCairoFontFace();

Просмотреть файл

@ -359,13 +359,13 @@ WebRenderBridgeParent::ProcessWebrenderCommands(InfallibleTArray<WebRenderComman
const OpDPPushText& op = cmd.get_OpDPPushText();
const nsTArray<WrGlyphArray>& glyph_array = op.glyph_array();
// TODO: We are leaking the key
wr::FontKey fontKey;
auto slice = Range<uint8_t>(op.font_buffer().mData, op.font_buffer_length());
fontKey = mApi->AddRawFont(slice);
for (size_t i = 0; i < glyph_array.Length(); i++) {
const nsTArray<WrGlyphInstance>& glyphs = glyph_array[i].glyphs;
// TODO: We are leaking the key
wr::FontKey fontKey;
auto slice = Range<uint8_t>(op.font_buffer().mData, op.font_buffer_length());
fontKey = mApi->AddRawFont(slice);
builder.PushText(op.bounds(),
op.clip(),
glyph_array[i].color,

Просмотреть файл

@ -16,9 +16,9 @@ namespace layers {
using namespace mozilla::gfx;
static void
DWriteFontFileData(const uint8_t* aData, uint32_t aLength, uint32_t aIndex,
float aGlyphSize, uint32_t aVariationCount,
const ScaledFont::VariationSetting* aVariations, void* aBaton)
WriteFontFileData(const uint8_t* aData, uint32_t aLength, uint32_t aIndex,
float aGlyphSize, uint32_t aVariationCount,
const ScaledFont::VariationSetting* aVariations, void* aBaton)
{
WebRenderTextLayer* layer = static_cast<WebRenderTextLayer*>(aBaton);
@ -46,8 +46,9 @@ WebRenderTextLayer::RenderLayer()
clip = rect;
}
MOZ_ASSERT(mFont->GetType() == FontType::DWRITE);
mFont->GetFontFileData(&DWriteFontFileData, this);
MOZ_ASSERT((mFont->GetType() == FontType::DWRITE) ||
(mFont->GetType() == FontType::MAC));
mFont->GetFontFileData(&WriteFontFileData, this);
wr::ByteBuffer fontBuffer(mFontDataLength, mFontData);
nsTArray<WrGlyphArray> wr_glyphs;