| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fpdfapi/render/render_int.h" | 7 #include "core/fpdfapi/render/render_int.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "core/fpdfapi/parser/cpdf_document.h" | 22 #include "core/fpdfapi/parser/cpdf_document.h" |
| 23 #include "core/fpdfapi/render/cpdf_renderoptions.h" | 23 #include "core/fpdfapi/render/cpdf_renderoptions.h" |
| 24 #include "core/fpdfapi/render/cpdf_textrenderer.h" | 24 #include "core/fpdfapi/render/cpdf_textrenderer.h" |
| 25 #include "core/fpdfapi/render/cpdf_type3cache.h" | 25 #include "core/fpdfapi/render/cpdf_type3cache.h" |
| 26 #include "core/fxge/cfx_facecache.h" | 26 #include "core/fxge/cfx_facecache.h" |
| 27 #include "core/fxge/cfx_fxgedevice.h" | 27 #include "core/fxge/cfx_fxgedevice.h" |
| 28 #include "core/fxge/cfx_gemodule.h" | 28 #include "core/fxge/cfx_gemodule.h" |
| 29 #include "core/fxge/cfx_graphstatedata.h" | 29 #include "core/fxge/cfx_graphstatedata.h" |
| 30 #include "core/fxge/cfx_pathdata.h" | 30 #include "core/fxge/cfx_pathdata.h" |
| 31 #include "core/fxge/cfx_renderdevice.h" | 31 #include "core/fxge/cfx_renderdevice.h" |
| 32 #include "third_party/base/numerics/safe_math.h" |
| 32 | 33 |
| 33 FX_BOOL CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, | 34 FX_BOOL CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, |
| 34 const CFX_Matrix* pObj2Device, | 35 const CFX_Matrix* pObj2Device, |
| 35 CFX_PathData* pClippingPath) { | 36 CFX_PathData* pClippingPath) { |
| 36 if (textobj->m_nChars == 0) | 37 if (textobj->m_nChars == 0) |
| 37 return TRUE; | 38 return TRUE; |
| 38 | 39 |
| 39 const TextRenderingMode text_render_mode = textobj->m_TextState.GetTextMode(); | 40 const TextRenderingMode text_render_mode = textobj->m_TextState.GetTextMode(); |
| 40 if (text_render_mode == TextRenderingMode::MODE_INVISIBLE) | 41 if (text_render_mode == TextRenderingMode::MODE_INVISIBLE) |
| 41 return TRUE; | 42 return TRUE; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 CFX_DIBitmap bitmap; | 308 CFX_DIBitmap bitmap; |
| 308 if (!bitmap.Create(static_cast<int>(rect.Width() * sa), | 309 if (!bitmap.Create(static_cast<int>(rect.Width() * sa), |
| 309 static_cast<int>(rect.Height() * sd), FXDIB_8bppMask)) { | 310 static_cast<int>(rect.Height() * sd), FXDIB_8bppMask)) { |
| 310 return TRUE; | 311 return TRUE; |
| 311 } | 312 } |
| 312 bitmap.Clear(0); | 313 bitmap.Clear(0); |
| 313 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { | 314 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { |
| 314 if (!glyph.m_pGlyph) | 315 if (!glyph.m_pGlyph) |
| 315 continue; | 316 continue; |
| 316 | 317 |
| 317 bitmap.TransferBitmap( | 318 pdfium::base::CheckedNumeric<int> left = glyph.m_OriginX; |
| 318 static_cast<int>( | 319 left += glyph.m_pGlyph->m_Left; |
| 319 (glyph.m_OriginX + glyph.m_pGlyph->m_Left - rect.left) * sa), | 320 left -= rect.left; |
| 320 static_cast<int>((glyph.m_OriginY - glyph.m_pGlyph->m_Top - rect.top) * | 321 left *= sa; |
| 321 sd), | 322 if (!left.IsValid()) |
| 322 glyph.m_pGlyph->m_Bitmap.GetWidth(), | 323 continue; |
| 323 glyph.m_pGlyph->m_Bitmap.GetHeight(), &glyph.m_pGlyph->m_Bitmap, 0, 0); | 324 |
| 325 pdfium::base::CheckedNumeric<int> top = glyph.m_OriginY; |
| 326 top -= glyph.m_pGlyph->m_Top; |
| 327 top -= rect.top; |
| 328 top *= sd; |
| 329 if (!top.IsValid()) |
| 330 continue; |
| 331 |
| 332 bitmap.CompositeMask(left.ValueOrDie(), top.ValueOrDie(), |
| 333 glyph.m_pGlyph->m_Bitmap.GetWidth(), |
| 334 glyph.m_pGlyph->m_Bitmap.GetHeight(), |
| 335 &glyph.m_pGlyph->m_Bitmap, fill_argb, 0, 0, |
| 336 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, nullptr); |
| 324 } | 337 } |
| 325 m_pDevice->SetBitMask(&bitmap, rect.left, rect.top, fill_argb); | 338 m_pDevice->SetBitMask(&bitmap, rect.left, rect.top, fill_argb); |
| 326 return TRUE; | 339 return TRUE; |
| 327 } | 340 } |
| 328 | 341 |
| 329 class CPDF_CharPosList { | 342 class CPDF_CharPosList { |
| 330 public: | 343 public: |
| 331 CPDF_CharPosList(); | 344 CPDF_CharPosList(); |
| 332 ~CPDF_CharPosList(); | 345 ~CPDF_CharPosList(); |
| 333 void Load(int nChars, | 346 void Load(int nChars, |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, | 652 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, |
| 640 charpos.m_OriginY); | 653 charpos.m_OriginY); |
| 641 path.m_Path.Append(pPath, &matrix); | 654 path.m_Path.Append(pPath, &matrix); |
| 642 path.m_Matrix = *pTextMatrix; | 655 path.m_Matrix = *pTextMatrix; |
| 643 path.m_bStroke = bStroke; | 656 path.m_bStroke = bStroke; |
| 644 path.m_FillType = bFill ? FXFILL_WINDING : 0; | 657 path.m_FillType = bFill ? FXFILL_WINDING : 0; |
| 645 path.CalcBoundingBox(); | 658 path.CalcBoundingBox(); |
| 646 ProcessPath(&path, pObj2Device); | 659 ProcessPath(&path, pObj2Device); |
| 647 } | 660 } |
| 648 } | 661 } |
| OLD | NEW |