From 1437643bfaca635d52f4cb9ec41e3075cf893f79 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 10 Jul 2017 14:16:05 -0400 Subject: Reland "typeface double delete" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 75e1ab05e731d99b9acdc86de47640720e848415. Reason for revert: Using the custom skia smart pointer is the correct approach over CFX_UnownedPtr. Original change's description: > Revert "typeface double delete" > > This reverts commit ddf2418ba8e5d925909d7955ac22b33f37ccce44. > > Reason for revert: not right > > Original change's description: > > typeface double delete > > > > SkTypeface was doubly deleted at pdfium teardown > > SkTypeface has two pointers but no owners. > > Making the font cache an owner fixes the bug but > > violates checkdeps rules. Let me know what to > > do about that. > > > > R=​dsinclair@chromium.org,npm@chromium.org > > Bug: 736133 > > Change-Id: I756a41258a5ac86e70139d7a587c5da9bb7a707b > > Reviewed-on: https://pdfium-review.googlesource.com/7270 > > Reviewed-by: Nicolás Peña > > Commit-Queue: Cary Clark > > TBR=dsinclair@chromium.org,caryclark@google.com,npm@chromium.org,caryclark@skia.org > > Change-Id: I255f50acf2cbaecc85b8e5ac3893c1fbc77b6492 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: 736133 > Reviewed-on: https://pdfium-review.googlesource.com/7310 > Reviewed-by: Cary Clark > Commit-Queue: Cary Clark TBR=dsinclair@chromium.org,caryclark@google.com,npm@chromium.org,caryclark@skia.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 736133 Change-Id: I0ab949e9da2fdab9559e7ffe0ceed24d8eb9b66a Reviewed-on: https://pdfium-review.googlesource.com/7510 Commit-Queue: dsinclair Reviewed-by: dsinclair Reviewed-by: Tom Sepez --- core/fxge/DEPS | 3 +++ core/fxge/cfx_facecache.h | 6 +++++- core/fxge/ge/DEPS | 3 --- core/fxge/ge/cfx_facecache.cpp | 15 +++++---------- 4 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 core/fxge/DEPS delete mode 100644 core/fxge/ge/DEPS diff --git a/core/fxge/DEPS b/core/fxge/DEPS new file mode 100644 index 0000000000..6492756b7e --- /dev/null +++ b/core/fxge/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + '+third_party/skia/include' +] diff --git a/core/fxge/cfx_facecache.h b/core/fxge/cfx_facecache.h index d6847debdb..076ba1f330 100644 --- a/core/fxge/cfx_facecache.h +++ b/core/fxge/cfx_facecache.h @@ -14,6 +14,10 @@ #include "core/fxge/fx_font.h" #include "core/fxge/fx_freetype.h" +#if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_ +#include "third_party/skia/include/core/SkTypeface.h" +#endif + class CFX_FaceCache { public: explicit CFX_FaceCache(FXFT_Face face); @@ -60,7 +64,7 @@ class CFX_FaceCache { std::map> m_SizeMap; std::map> m_PathMap; #if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_ - CFX_UnownedPtr m_pTypeface; + sk_sp m_pTypeface; #endif }; diff --git a/core/fxge/ge/DEPS b/core/fxge/ge/DEPS deleted file mode 100644 index 6492756b7e..0000000000 --- a/core/fxge/ge/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - '+third_party/skia/include' -] diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp index 6049729089..e675e11510 100644 --- a/core/fxge/ge/cfx_facecache.cpp +++ b/core/fxge/ge/cfx_facecache.cpp @@ -89,9 +89,6 @@ CFX_FaceCache::CFX_FaceCache(FXFT_Face face) } CFX_FaceCache::~CFX_FaceCache() { -#if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_ - SkSafeUnref(m_pTypeface.Get()); -#endif } std::unique_ptr CFX_FaceCache::RenderGlyph( @@ -358,19 +355,17 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(const CFX_Font* pFont, #if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_ CFX_TypeFace* CFX_FaceCache::GetDeviceCache(const CFX_Font* pFont) { if (!m_pTypeface) { - m_pTypeface = - SkTypeface::MakeFromStream( - new SkMemoryStream(pFont->GetFontData(), pFont->GetSize())) - .release(); + m_pTypeface = SkTypeface::MakeFromStream( + new SkMemoryStream(pFont->GetFontData(), pFont->GetSize())); } #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ if (!m_pTypeface) { sk_sp customMgr(SkFontMgr_New_Custom_Empty()); - m_pTypeface = customMgr->createFromStream( - new SkMemoryStream(pFont->GetFontData(), pFont->GetSize())); + m_pTypeface.reset(customMgr->createFromStream( + new SkMemoryStream(pFont->GetFontData(), pFont->GetSize()))); } #endif - return m_pTypeface.Get(); + return m_pTypeface.get(); } #endif -- cgit v1.2.3