diff options
author | Cary Clark <caryclark@google.com> | 2017-04-12 13:44:58 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-12 20:14:46 +0000 |
commit | 81513c8243390783540b8bb6d0f9b26d9cb0c2c1 (patch) | |
tree | 76f69583b67609daeab1f38f35aa3f78a646249f | |
parent | 27a0f350ff26ba752eb17a593bbaad17fbbe71d2 (diff) | |
download | pdfium-81513c8243390783540b8bb6d0f9b26d9cb0c2c1.tar.xz |
Cache TypeFace instead of Font
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 <npm@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 14 |
1 files 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<SkTypeface> typeface(SkSafeRef(m_pFont->GetDeviceCache())); + if (m_pTypeFace) { // exclude placeholder test fonts + sk_sp<SkTypeface> 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; |