From 81513c8243390783540b8bb6d0f9b26d9cb0c2c1 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Wed, 12 Apr 2017 13:44:58 -0400 Subject: Cache TypeFace instead of Font MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skia tracks the font passed so it can use it later to draw. In XFA's case, the font is discarded after Skia sees it, but before it draws with it. Track the TypeFace instead, which remains available across the XFA lifetime. R=dsinclair@chromium.org Bug: 705193 Change-Id: I4fc9fee4a7d96ea25f242975f6c0d10941f5c549 Reviewed-on: https://pdfium-review.googlesource.com/4058 Reviewed-by: Nicolás Peña Commit-Queue: Nicolás Peña --- core/fxge/skia/fx_skia_device.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 5f117cb4d6..df43c18fcc 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -658,7 +658,7 @@ class SkiaState { // mark all cached state as uninitialized explicit SkiaState(CFX_SkiaDeviceDriver* pDriver) : m_pDriver(pDriver), - m_pFont(nullptr), + m_pTypeFace(nullptr), m_fontSize(0), m_fillColor(0), m_strokeColor(0), @@ -786,7 +786,7 @@ class SkiaState { if (Accumulator::kText != m_type) { m_positions.setCount(0); m_glyphs.setCount(0); - m_pFont = pFont; + m_pTypeFace = pFont->GetFace() ? pFont->GetDeviceCache() : nullptr; m_fontSize = font_size; m_fillColor = color; m_drawMatrix = *pMatrix; @@ -819,8 +819,8 @@ class SkiaState { SkPaint skPaint; skPaint.setAntiAlias(true); skPaint.setColor(m_fillColor); - if (m_pFont->GetFace()) { // exclude placeholder test fonts - sk_sp typeface(SkSafeRef(m_pFont->GetDeviceCache())); + if (m_pTypeFace) { // exclude placeholder test fonts + sk_sp typeface(SkSafeRef(m_pTypeFace)); skPaint.setTypeface(typeface); } skPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); @@ -978,7 +978,9 @@ class SkiaState { const CFX_Matrix* pMatrix, float font_size, uint32_t color) const { - return pFont != m_pFont || MatrixChanged(pMatrix, m_drawMatrix) || + CFX_TypeFace* typeface = + pFont->GetFace() ? pFont->GetDeviceCache() : nullptr; + return typeface != m_pTypeFace || MatrixChanged(pMatrix, m_drawMatrix) || font_size != m_fontSize || color != m_fillColor; } @@ -1263,7 +1265,7 @@ class SkiaState { CFX_GraphStateData m_drawState; CFX_Matrix m_clipMatrix; CFX_SkiaDeviceDriver* m_pDriver; - CFX_Font* m_pFont; + CFX_TypeFace* m_pTypeFace; float m_fontSize; uint32_t m_fillColor; uint32_t m_strokeColor; -- cgit v1.2.3