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_system.h" | 7 #include "core/fxcrt/include/fx_system.h" |
8 | 8 |
9 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 9 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
10 | 10 |
11 #ifndef _SKIA_SUPPORT_ | 11 #ifndef _SKIA_SUPPORT_ |
12 #include "core/fxge/agg/fx_agg_driver.h" | 12 #include "core/fxge/agg/fx_agg_driver.h" |
13 #endif | 13 #endif |
14 | 14 |
15 #include "core/fxge/apple/apple_int.h" | 15 #include "core/fxge/apple/apple_int.h" |
16 #include "core/fxge/apple/cfx_quartzdevice.h" | 16 #include "core/fxge/apple/cfx_quartzdevice.h" |
17 #include "core/fxge/dib/dib_int.h" | 17 #include "core/fxge/dib/dib_int.h" |
18 #include "core/fxge/ge/cfx_cliprgn.h" | 18 #include "core/fxge/ge/cfx_cliprgn.h" |
19 #include "core/fxge/ge/fx_text_int.h" | 19 #include "core/fxge/ge/fx_text_int.h" |
20 #include "core/fxge/include/cfx_facecache.h" | 20 #include "core/fxge/include/cfx_facecache.h" |
21 #include "core/fxge/include/cfx_fontcache.h" | |
22 #include "core/fxge/include/cfx_gemodule.h" | 21 #include "core/fxge/include/cfx_gemodule.h" |
23 #include "core/fxge/include/cfx_renderdevice.h" | 22 #include "core/fxge/include/cfx_renderdevice.h" |
24 #include "core/fxge/include/fx_freetype.h" | 23 #include "core/fxge/include/fx_freetype.h" |
25 | 24 |
26 #ifndef _SKIA_SUPPORT_ | 25 #ifndef _SKIA_SUPPORT_ |
27 | 26 |
28 namespace { | 27 namespace { |
29 | 28 |
30 void DoNothing(void* info, const void* data, size_t size) {} | 29 void DoNothing(void* info, const void* data, size_t size) {} |
31 | 30 |
32 FX_BOOL CGDrawGlyphRun(CGContextRef pContext, | 31 FX_BOOL CGDrawGlyphRun(CGContextRef pContext, |
33 int nChars, | 32 int nChars, |
34 const FXTEXT_CHARPOS* pCharPos, | 33 const FXTEXT_CHARPOS* pCharPos, |
35 CFX_Font* pFont, | 34 CFX_Font* pFont, |
36 CFX_FontCache* pCache, | |
37 const CFX_Matrix* pObject2Device, | 35 const CFX_Matrix* pObject2Device, |
38 FX_FLOAT font_size, | 36 FX_FLOAT font_size, |
39 uint32_t argb) { | 37 uint32_t argb) { |
40 if (nChars == 0) | 38 if (nChars == 0) |
41 return TRUE; | 39 return TRUE; |
42 | 40 |
43 CFX_Matrix new_matrix; | 41 CFX_Matrix new_matrix; |
44 FX_BOOL bNegSize = font_size < 0; | 42 FX_BOOL bNegSize = font_size < 0; |
45 if (bNegSize) | 43 if (bNegSize) |
46 font_size = -font_size; | 44 font_size = -font_size; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 ->m_quartz2d; | 97 ->m_quartz2d; |
100 if (m_pPlatformGraphics) { | 98 if (m_pPlatformGraphics) { |
101 quartz2d.destroyGraphics(m_pPlatformGraphics); | 99 quartz2d.destroyGraphics(m_pPlatformGraphics); |
102 m_pPlatformGraphics = nullptr; | 100 m_pPlatformGraphics = nullptr; |
103 } | 101 } |
104 } | 102 } |
105 | 103 |
106 FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, | 104 FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, |
107 const FXTEXT_CHARPOS* pCharPos, | 105 const FXTEXT_CHARPOS* pCharPos, |
108 CFX_Font* pFont, | 106 CFX_Font* pFont, |
109 CFX_FontCache* pCache, | |
110 const CFX_Matrix* pObject2Device, | 107 const CFX_Matrix* pObject2Device, |
111 FX_FLOAT font_size, | 108 FX_FLOAT font_size, |
112 uint32_t argb) { | 109 uint32_t argb) { |
113 if (!pFont) | 110 if (!pFont) |
114 return FALSE; | 111 return FALSE; |
115 | 112 |
116 FX_BOOL bBold = pFont->IsBold(); | 113 FX_BOOL bBold = pFont->IsBold(); |
117 if (!bBold && pFont->GetSubstFont() && | 114 if (!bBold && pFont->GetSubstFont() && |
118 pFont->GetSubstFont()->m_Weight >= 500 && | 115 pFont->GetSubstFont()->m_Weight >= 500 && |
119 pFont->GetSubstFont()->m_Weight <= 600) { | 116 pFont->GetSubstFont()->m_Weight <= 600) { |
(...skipping 28 matching lines...) Expand all Loading... |
148 } | 145 } |
149 } else { | 146 } else { |
150 rect_cg = CGRectMake(0, 0, m_pBitmap->GetWidth(), m_pBitmap->GetHeight()); | 147 rect_cg = CGRectMake(0, 0, m_pBitmap->GetWidth(), m_pBitmap->GetHeight()); |
151 } | 148 } |
152 rect_cg = CGContextConvertRectToDeviceSpace(ctx, rect_cg); | 149 rect_cg = CGContextConvertRectToDeviceSpace(ctx, rect_cg); |
153 if (pImageCG) | 150 if (pImageCG) |
154 CGContextClipToMask(ctx, rect_cg, pImageCG); | 151 CGContextClipToMask(ctx, rect_cg, pImageCG); |
155 else | 152 else |
156 CGContextClipToRect(ctx, rect_cg); | 153 CGContextClipToRect(ctx, rect_cg); |
157 | 154 |
158 FX_BOOL ret = CGDrawGlyphRun(ctx, nChars, pCharPos, pFont, pCache, | 155 FX_BOOL ret = CGDrawGlyphRun(ctx, nChars, pCharPos, pFont, pObject2Device, |
159 pObject2Device, font_size, argb); | 156 font_size, argb); |
160 if (pImageCG) | 157 if (pImageCG) |
161 CGImageRelease(pImageCG); | 158 CGImageRelease(pImageCG); |
162 CGContextRestoreGState(ctx); | 159 CGContextRestoreGState(ctx); |
163 return ret; | 160 return ret; |
164 } | 161 } |
165 | 162 |
166 #endif // _SKIA_SUPPORT_ | 163 #endif // _SKIA_SUPPORT_ |
167 | 164 |
168 void CFX_FaceCache::InitPlatform() {} | 165 void CFX_FaceCache::InitPlatform() {} |
169 | 166 |
170 void CFX_FaceCache::DestroyPlatform() {} | 167 void CFX_FaceCache::DestroyPlatform() {} |
171 | 168 |
172 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext( | 169 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext( |
173 CFX_Font* pFont, | 170 const CFX_Font* pFont, |
174 uint32_t glyph_index, | 171 uint32_t glyph_index, |
175 const CFX_Matrix* pMatrix, | 172 const CFX_Matrix* pMatrix, |
176 int dest_width, | 173 int dest_width, |
177 int anti_alias) { | 174 int anti_alias) { |
178 return nullptr; | 175 return nullptr; |
179 } | 176 } |
180 | 177 |
181 void CFX_Font::ReleasePlatformResource() { | 178 void CFX_Font::ReleasePlatformResource() { |
182 if (m_pPlatformFont) { | 179 if (m_pPlatformFont) { |
183 CQuartz2D& quartz2d = | 180 CQuartz2D& quartz2d = |
184 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) | 181 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) |
185 ->m_quartz2d; | 182 ->m_quartz2d; |
186 quartz2d.DestroyFont(m_pPlatformFont); | 183 quartz2d.DestroyFont(m_pPlatformFont); |
187 m_pPlatformFont = nullptr; | 184 m_pPlatformFont = nullptr; |
188 } | 185 } |
189 } | 186 } |
190 | 187 |
191 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 188 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
OLD | NEW |