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/fxcrt/include/fx_ext.h" | 7 #include "core/fxcrt/include/fx_ext.h" |
8 | 8 |
9 #ifndef _SKIA_SUPPORT_ | 9 #ifndef _SKIA_SUPPORT_ |
10 #include "core/fxge/agg/fx_agg_driver.h" | 10 #include "core/fxge/agg/fx_agg_driver.h" |
11 #endif | 11 #endif |
12 | 12 |
13 #include "core/fxcrt/include/fx_memory.h" | 13 #include "core/fxcrt/include/fx_memory.h" |
14 #include "core/fxge/dib/dib_int.h" | 14 #include "core/fxge/dib/dib_int.h" |
15 #include "core/fxge/ge/fx_text_int.h" | 15 #include "core/fxge/ge/fx_text_int.h" |
| 16 #include "core/fxge/include/cfx_fontcache.h" |
16 #include "core/fxge/include/cfx_gemodule.h" | 17 #include "core/fxge/include/cfx_gemodule.h" |
17 #include "core/fxge/include/cfx_graphstatedata.h" | 18 #include "core/fxge/include/cfx_graphstatedata.h" |
18 #include "core/fxge/include/cfx_pathdata.h" | 19 #include "core/fxge/include/cfx_pathdata.h" |
19 #include "core/fxge/include/cfx_renderdevice.h" | 20 #include "core/fxge/include/cfx_renderdevice.h" |
20 #include "core/fxge/include/fx_freetype.h" | 21 #include "core/fxge/include/fx_freetype.h" |
21 | 22 |
22 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 23 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
23 #include "core/fxge/apple/apple_int.h" | 24 #include "core/fxge/apple/apple_int.h" |
24 #include "core/fxge/apple/cfx_quartzdevice.h" | 25 #include "core/fxge/apple/cfx_quartzdevice.h" |
25 #ifndef CGFLOAT_IS_DOUBLE | 26 #ifndef CGFLOAT_IS_DOUBLE |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 uint32_t flags, | 739 uint32_t flags, |
739 void*& handle, | 740 void*& handle, |
740 int blend_type) { | 741 int blend_type) { |
741 return FALSE; | 742 return FALSE; |
742 } | 743 } |
743 | 744 |
744 FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlyphRun( | 745 FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlyphRun( |
745 int nChars, | 746 int nChars, |
746 const FXTEXT_CHARPOS* pCharPos, | 747 const FXTEXT_CHARPOS* pCharPos, |
747 CFX_Font* pFont, | 748 CFX_Font* pFont, |
| 749 CFX_FontCache* pCache, |
748 const CFX_Matrix* pGlyphMatrix, | 750 const CFX_Matrix* pGlyphMatrix, |
749 const CFX_Matrix* pObject2Device, | 751 const CFX_Matrix* pObject2Device, |
750 FX_FLOAT font_size, | 752 FX_FLOAT font_size, |
751 uint32_t argb) { | 753 uint32_t argb) { |
752 if (nChars == 0) | 754 if (nChars == 0) |
753 return TRUE; | 755 return TRUE; |
754 | 756 |
755 CQuartz2D& quartz2d = | 757 CQuartz2D& quartz2d = |
756 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) | 758 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) |
757 ->m_quartz2d; | 759 ->m_quartz2d; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 } | 805 } |
804 CGContextShowGlyphsAtPositions(m_context, (CGGlyph*)glyph_indices, | 806 CGContextShowGlyphsAtPositions(m_context, (CGGlyph*)glyph_indices, |
805 glyph_positions, nChars); | 807 glyph_positions, nChars); |
806 RestoreState(false); | 808 RestoreState(false); |
807 return TRUE; | 809 return TRUE; |
808 } | 810 } |
809 | 811 |
810 FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, | 812 FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, |
811 const FXTEXT_CHARPOS* pCharPos, | 813 const FXTEXT_CHARPOS* pCharPos, |
812 CFX_Font* pFont, | 814 CFX_Font* pFont, |
| 815 CFX_FontCache* pCache, |
813 const CFX_Matrix* pObject2Device, | 816 const CFX_Matrix* pObject2Device, |
814 FX_FLOAT font_size, | 817 FX_FLOAT font_size, |
815 uint32_t color) { | 818 uint32_t color) { |
816 if (!pFont || !m_context) | 819 if (!pFont || !m_context) |
817 return FALSE; | 820 return FALSE; |
818 | 821 |
819 FX_BOOL bBold = pFont->IsBold(); | 822 FX_BOOL bBold = pFont->IsBold(); |
820 if (!bBold && pFont->GetSubstFont() && | 823 if (!bBold && pFont->GetSubstFont() && |
821 pFont->GetSubstFont()->m_Weight >= 500 && | 824 pFont->GetSubstFont()->m_Weight >= 500 && |
822 pFont->GetSubstFont()->m_Weight <= 600) { | 825 pFont->GetSubstFont()->m_Weight <= 600) { |
823 return FALSE; | 826 return FALSE; |
824 } | 827 } |
825 SaveState(); | 828 SaveState(); |
826 CGContextSetTextDrawingMode(m_context, kCGTextFillClip); | 829 CGContextSetTextDrawingMode(m_context, kCGTextFillClip); |
827 FX_BOOL ret = FALSE; | 830 FX_BOOL ret = FALSE; |
828 int32_t i = 0; | 831 int32_t i = 0; |
829 while (i < nChars) { | 832 while (i < nChars) { |
830 if (pCharPos[i].m_bGlyphAdjust || font_size < 0) { | 833 if (pCharPos[i].m_bGlyphAdjust || font_size < 0) { |
831 if (i > 0) { | 834 if (i > 0) { |
832 ret = CG_DrawGlyphRun(i, pCharPos, pFont, nullptr, pObject2Device, | 835 ret = CG_DrawGlyphRun(i, pCharPos, pFont, pCache, nullptr, |
833 font_size, color); | 836 pObject2Device, font_size, color); |
834 if (!ret) { | 837 if (!ret) { |
835 RestoreState(false); | 838 RestoreState(false); |
836 return ret; | 839 return ret; |
837 } | 840 } |
838 } | 841 } |
839 const FXTEXT_CHARPOS* char_pos = pCharPos + i; | 842 const FXTEXT_CHARPOS* char_pos = pCharPos + i; |
840 CFX_Matrix glphy_matrix; | 843 CFX_Matrix glphy_matrix; |
841 if (font_size < 0) { | 844 if (font_size < 0) { |
842 glphy_matrix.Concat(-1, 0, 0, -1, 0, 0); | 845 glphy_matrix.Concat(-1, 0, 0, -1, 0, 0); |
843 } | 846 } |
844 if (char_pos->m_bGlyphAdjust) { | 847 if (char_pos->m_bGlyphAdjust) { |
845 glphy_matrix.Concat( | 848 glphy_matrix.Concat( |
846 char_pos->m_AdjustMatrix[0], char_pos->m_AdjustMatrix[1], | 849 char_pos->m_AdjustMatrix[0], char_pos->m_AdjustMatrix[1], |
847 char_pos->m_AdjustMatrix[2], char_pos->m_AdjustMatrix[3], 0, 0); | 850 char_pos->m_AdjustMatrix[2], char_pos->m_AdjustMatrix[3], 0, 0); |
848 } | 851 } |
849 ret = CG_DrawGlyphRun(1, char_pos, pFont, &glphy_matrix, pObject2Device, | 852 ret = CG_DrawGlyphRun(1, char_pos, pFont, pCache, &glphy_matrix, |
850 font_size, color); | 853 pObject2Device, font_size, color); |
851 if (!ret) { | 854 if (!ret) { |
852 RestoreState(false); | 855 RestoreState(false); |
853 return ret; | 856 return ret; |
854 } | 857 } |
855 i++; | 858 i++; |
856 pCharPos += i; | 859 pCharPos += i; |
857 nChars -= i; | 860 nChars -= i; |
858 i = 0; | 861 i = 0; |
859 } else { | 862 } else { |
860 i++; | 863 i++; |
861 } | 864 } |
862 } | 865 } |
863 if (i > 0) { | 866 if (i > 0) { |
864 ret = CG_DrawGlyphRun(i, pCharPos, pFont, nullptr, pObject2Device, | 867 ret = CG_DrawGlyphRun(i, pCharPos, pFont, pCache, nullptr, pObject2Device, |
865 font_size, color); | 868 font_size, color); |
866 } | 869 } |
867 RestoreState(false); | 870 RestoreState(false); |
868 return ret; | 871 return ret; |
869 } | 872 } |
870 | 873 |
871 void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, | 874 void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, |
872 FX_ARGB argb, | 875 FX_ARGB argb, |
873 FX_FLOAT lineWidth) { | 876 FX_FLOAT lineWidth) { |
874 if (!graphState) | 877 if (!graphState) |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 if ((uint8_t)format < 32) { | 1045 if ((uint8_t)format < 32) { |
1043 return FALSE; | 1046 return FALSE; |
1044 } | 1047 } |
1045 std::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); | 1048 std::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); |
1046 if (!pBitmap->Create(width, height, format)) | 1049 if (!pBitmap->Create(width, height, format)) |
1047 return FALSE; | 1050 return FALSE; |
1048 m_bOwnedBitmap = TRUE; | 1051 m_bOwnedBitmap = TRUE; |
1049 return Attach(pBitmap.release()); | 1052 return Attach(pBitmap.release()); |
1050 } | 1053 } |
1051 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1054 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
OLD | NEW |