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

Side by Side Diff: core/fxge/apple/fx_quartz_device.cpp

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

Powered by Google App Engine
This is Rietveld 408576698