Use UnownedPtr in TextGlyphPos.
Change-Id: Ife427beb3cf2603f41182947dd3b11ec4c17243d
Reviewed-on: https://pdfium-review.googlesource.com/c/50270
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 0c47092..b796f04 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1795,20 +1795,23 @@
if (pdfium::ContainsValue(m_Type3FontCache, pType3Font))
return true;
+ int device_class = m_pDevice->GetDeviceClass();
+ FX_ARGB fill_argb = GetFillArgbForType3(textobj);
+ int fill_alpha = FXARGB_A(fill_argb);
+ if (device_class != FXDC_DISPLAY && fill_alpha < 255)
+ return false;
+
CFX_Matrix text_matrix = textobj->GetTextMatrix();
CFX_Matrix char_matrix = pType3Font->GetFontMatrix();
float font_size = textobj->m_TextState.GetFontSize();
char_matrix.Scale(font_size, font_size);
- FX_ARGB fill_argb = GetFillArgbForType3(textobj);
- int fill_alpha = FXARGB_A(fill_argb);
- int device_class = m_pDevice->GetDeviceClass();
+
+ // Must come before |glyphs|, because |glyphs| points into |refTypeCache|.
+ CPDF_RefType3Cache refTypeCache(pType3Font);
std::vector<TextGlyphPos> glyphs;
if (device_class == FXDC_DISPLAY)
glyphs.resize(textobj->GetCharCodes().size());
- else if (fill_alpha < 255)
- return false;
- CPDF_RefType3Cache refTypeCache(pType3Font);
for (size_t iChar = 0; iChar < textobj->GetCharCodes().size(); ++iChar) {
uint32_t charcode = textobj->GetCharCodes()[iChar];
if (charcode == static_cast<uint32_t>(-1))
diff --git a/core/fxge/text_glyph_pos.h b/core/fxge/text_glyph_pos.h
index 84ad0e6..b786432 100644
--- a/core/fxge/text_glyph_pos.h
+++ b/core/fxge/text_glyph_pos.h
@@ -9,6 +9,7 @@
#include "core/fxcrt/fx_coordinates.h"
+#include "core/fxcrt/unowned_ptr.h"
#include "third_party/base/optional.h"
class CFX_GlyphBitmap;
@@ -21,7 +22,7 @@
Optional<CFX_Point> GetOrigin(const CFX_Point& offset) const;
- const CFX_GlyphBitmap* m_pGlyph = nullptr;
+ UnownedPtr<const CFX_GlyphBitmap> m_pGlyph;
CFX_Point m_Origin;
CFX_PointF m_fOrigin;
};