Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Unified Diff: core/fpdfapi/render/fpdf_render_text.cpp

Issue 2461743002: Use CompositeMask instead of TransferBitmap when drawing type 3 text (Closed)
Patch Set: Nits Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/render/fpdf_render_text.cpp
diff --git a/core/fpdfapi/render/fpdf_render_text.cpp b/core/fpdfapi/render/fpdf_render_text.cpp
index b8f44f8bd91294b3163d3a153a3de6bd51c9e330..7d29f5c87fdedaab7cedb5eac81f0be9fb1c846b 100644
--- a/core/fpdfapi/render/fpdf_render_text.cpp
+++ b/core/fpdfapi/render/fpdf_render_text.cpp
@@ -29,6 +29,7 @@
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
+#include "third_party/base/numerics/safe_math.h"
FX_BOOL CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
const CFX_Matrix* pObj2Device,
@@ -314,13 +315,25 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
if (!glyph.m_pGlyph)
continue;
- bitmap.TransferBitmap(
- static_cast<int>(
- (glyph.m_OriginX + glyph.m_pGlyph->m_Left - rect.left) * sa),
- static_cast<int>((glyph.m_OriginY - glyph.m_pGlyph->m_Top - rect.top) *
- sd),
- glyph.m_pGlyph->m_Bitmap.GetWidth(),
- glyph.m_pGlyph->m_Bitmap.GetHeight(), &glyph.m_pGlyph->m_Bitmap, 0, 0);
+ pdfium::base::CheckedNumeric<int> left = glyph.m_OriginX;
+ left += glyph.m_pGlyph->m_Left;
+ left -= rect.left;
+ left *= sa;
+ if (!left.IsValid())
+ continue;
+
+ pdfium::base::CheckedNumeric<int> top = glyph.m_OriginY;
+ top -= glyph.m_pGlyph->m_Top;
+ top -= rect.top;
+ top *= sd;
+ if (!top.IsValid())
+ continue;
+
+ bitmap.CompositeMask(left.ValueOrDie(), top.ValueOrDie(),
+ glyph.m_pGlyph->m_Bitmap.GetWidth(),
+ glyph.m_pGlyph->m_Bitmap.GetHeight(),
+ &glyph.m_pGlyph->m_Bitmap, fill_argb, 0, 0,
+ FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, nullptr);
}
m_pDevice->SetBitMask(&bitmap, rect.left, rect.top, fill_argb);
return TRUE;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698