OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/cpdf_renderstatus.h" | 7 #include "core/fpdfapi/render/cpdf_renderstatus.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "core/fxcodec/fx_codec.h" | 48 #include "core/fxcodec/fx_codec.h" |
49 #include "core/fxcrt/cfx_maybe_owned.h" | 49 #include "core/fxcrt/cfx_maybe_owned.h" |
50 #include "core/fxcrt/fx_safe_types.h" | 50 #include "core/fxcrt/fx_safe_types.h" |
51 #include "core/fxge/cfx_fxgedevice.h" | 51 #include "core/fxge/cfx_fxgedevice.h" |
52 #include "core/fxge/cfx_graphstatedata.h" | 52 #include "core/fxge/cfx_graphstatedata.h" |
53 #include "core/fxge/cfx_pathdata.h" | 53 #include "core/fxge/cfx_pathdata.h" |
54 #include "core/fxge/cfx_renderdevice.h" | 54 #include "core/fxge/cfx_renderdevice.h" |
55 #include "core/fxge/ifx_renderdevicedriver.h" | 55 #include "core/fxge/ifx_renderdevicedriver.h" |
56 #include "third_party/base/numerics/safe_math.h" | 56 #include "third_party/base/numerics/safe_math.h" |
57 #include "third_party/base/ptr_util.h" | 57 #include "third_party/base/ptr_util.h" |
| 58 #include "third_party/base/stl_util.h" |
58 | 59 |
59 #ifdef _SKIA_SUPPORT_ | 60 #ifdef _SKIA_SUPPORT_ |
60 #include "core/fxge/skia/fx_skia_device.h" | 61 #include "core/fxge/skia/fx_skia_device.h" |
61 #endif | 62 #endif |
62 | 63 |
63 #define SHADING_STEPS 256 | 64 #define SHADING_STEPS 256 |
64 | 65 |
65 namespace { | 66 namespace { |
66 | 67 |
67 void ReleaseCachedType3(CPDF_Type3Font* pFont) { | 68 void ReleaseCachedType3(CPDF_Type3Font* pFont) { |
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 return nullptr; | 1776 return nullptr; |
1776 } | 1777 } |
1777 pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict()); | 1778 pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict()); |
1778 return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont); | 1779 return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont); |
1779 } | 1780 } |
1780 | 1781 |
1781 // TODO(npm): Font fallback for type 3 fonts? (Completely separate code!!) | 1782 // TODO(npm): Font fallback for type 3 fonts? (Completely separate code!!) |
1782 bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, | 1783 bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, |
1783 const CFX_Matrix* pObj2Device) { | 1784 const CFX_Matrix* pObj2Device) { |
1784 CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->AsType3Font(); | 1785 CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->AsType3Font(); |
1785 for (int i = 0; i < m_Type3FontCache.GetSize(); ++i) { | 1786 if (pdfium::ContainsValue(m_Type3FontCache, pType3Font)) |
1786 if (m_Type3FontCache.GetAt(i) == pType3Font) | 1787 return true; |
1787 return true; | |
1788 } | |
1789 | 1788 |
1790 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 1789 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
1791 FX_FLOAT sa = FXSYS_fabs(dCTM.a); | 1790 FX_FLOAT sa = FXSYS_fabs(dCTM.a); |
1792 FX_FLOAT sd = FXSYS_fabs(dCTM.d); | 1791 FX_FLOAT sd = FXSYS_fabs(dCTM.d); |
1793 CFX_Matrix text_matrix; | 1792 CFX_Matrix text_matrix; |
1794 textobj->GetTextMatrix(&text_matrix); | 1793 textobj->GetTextMatrix(&text_matrix); |
1795 CFX_Matrix char_matrix = pType3Font->GetFontMatrix(); | 1794 CFX_Matrix char_matrix = pType3Font->GetFontMatrix(); |
1796 FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); | 1795 FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); |
1797 char_matrix.Scale(font_size, font_size); | 1796 char_matrix.Scale(font_size, font_size); |
1798 FX_ARGB fill_argb = GetFillArgb(textobj, true); | 1797 FX_ARGB fill_argb = GetFillArgb(textobj, true); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 if (pType3Char->m_pForm && pType3Char->m_pForm->m_pFormDict) { | 1843 if (pType3Char->m_pForm && pType3Char->m_pForm->m_pFormDict) { |
1845 pFormResource = | 1844 pFormResource = |
1846 pType3Char->m_pForm->m_pFormDict->GetDictFor("Resources"); | 1845 pType3Char->m_pForm->m_pFormDict->GetDictFor("Resources"); |
1847 } | 1846 } |
1848 if (fill_alpha == 255) { | 1847 if (fill_alpha == 255) { |
1849 CPDF_RenderStatus status; | 1848 CPDF_RenderStatus status; |
1850 status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this, | 1849 status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this, |
1851 pStates, &Options, | 1850 pStates, &Options, |
1852 pType3Char->m_pForm->m_Transparency, m_bDropObjects, | 1851 pType3Char->m_pForm->m_Transparency, m_bDropObjects, |
1853 pFormResource, false, pType3Char, fill_argb); | 1852 pFormResource, false, pType3Char, fill_argb); |
1854 status.m_Type3FontCache.Append(m_Type3FontCache); | 1853 status.m_Type3FontCache = m_Type3FontCache; |
1855 status.m_Type3FontCache.Add(pType3Font); | 1854 status.m_Type3FontCache.push_back(pType3Font); |
1856 m_pDevice->SaveState(); | 1855 m_pDevice->SaveState(); |
1857 status.RenderObjectList(pType3Char->m_pForm.get(), &matrix); | 1856 status.RenderObjectList(pType3Char->m_pForm.get(), &matrix); |
1858 m_pDevice->RestoreState(false); | 1857 m_pDevice->RestoreState(false); |
1859 } else { | 1858 } else { |
1860 CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox(); | 1859 CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox(); |
1861 rect_f.Transform(&matrix); | 1860 rect_f.Transform(&matrix); |
1862 FX_RECT rect = rect_f.GetOuterRect(); | 1861 FX_RECT rect = rect_f.GetOuterRect(); |
1863 CFX_FxgeDevice bitmap_device; | 1862 CFX_FxgeDevice bitmap_device; |
1864 if (!bitmap_device.Create((int)(rect.Width() * sa), | 1863 if (!bitmap_device.Create((int)(rect.Width() * sa), |
1865 (int)(rect.Height() * sd), FXDIB_Argb, | 1864 (int)(rect.Height() * sd), FXDIB_Argb, |
1866 nullptr)) { | 1865 nullptr)) { |
1867 return true; | 1866 return true; |
1868 } | 1867 } |
1869 bitmap_device.GetBitmap()->Clear(0); | 1868 bitmap_device.GetBitmap()->Clear(0); |
1870 CPDF_RenderStatus status; | 1869 CPDF_RenderStatus status; |
1871 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, this, | 1870 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, this, |
1872 pStates, &Options, | 1871 pStates, &Options, |
1873 pType3Char->m_pForm->m_Transparency, m_bDropObjects, | 1872 pType3Char->m_pForm->m_Transparency, m_bDropObjects, |
1874 pFormResource, false, pType3Char, fill_argb); | 1873 pFormResource, false, pType3Char, fill_argb); |
1875 status.m_Type3FontCache.Append(m_Type3FontCache); | 1874 status.m_Type3FontCache = m_Type3FontCache; |
1876 status.m_Type3FontCache.Add(pType3Font); | 1875 status.m_Type3FontCache.push_back(pType3Font); |
1877 matrix.TranslateI(-rect.left, -rect.top); | 1876 matrix.TranslateI(-rect.left, -rect.top); |
1878 matrix.Scale(sa, sd); | 1877 matrix.Scale(sa, sd); |
1879 status.RenderObjectList(pType3Char->m_pForm.get(), &matrix); | 1878 status.RenderObjectList(pType3Char->m_pForm.get(), &matrix); |
1880 m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.top); | 1879 m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.top); |
1881 } | 1880 } |
1882 delete pStates; | 1881 delete pStates; |
1883 } else if (pType3Char->m_pBitmap) { | 1882 } else if (pType3Char->m_pBitmap) { |
1884 if (device_class == FXDC_DISPLAY) { | 1883 if (device_class == FXDC_DISPLAY) { |
1885 CPDF_Type3Cache* pCache = GetCachedType3(pType3Font); | 1884 CPDF_Type3Cache* pCache = GetCachedType3(pType3Font); |
1886 refTypeCache.m_dwCount++; | 1885 refTypeCache.m_dwCount++; |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2628 } else if (pFunc) { | 2627 } else if (pFunc) { |
2629 int size = dest_pitch * height; | 2628 int size = dest_pitch * height; |
2630 for (int i = 0; i < size; i++) { | 2629 for (int i = 0; i < size; i++) { |
2631 dest_buf[i] = transfers[src_buf[i]]; | 2630 dest_buf[i] = transfers[src_buf[i]]; |
2632 } | 2631 } |
2633 } else { | 2632 } else { |
2634 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 2633 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
2635 } | 2634 } |
2636 return pMask; | 2635 return pMask; |
2637 } | 2636 } |
OLD | NEW |