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

Side by Side Diff: core/src/fxge/apple/fx_apple_platform.cpp

Issue 402463002: Replace agg with skia (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix clang compile error Created 6 years, 5 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
« no previous file with comments | « core/src/fxge/apple/apple_int.h ('k') | core/src/fxge/apple/fx_quartz_device.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "../../../include/fxcrt/fx_ext.h" 7 #include "../../../include/fxcrt/fx_ext.h"
8 #include "../../../include/fxge/fx_ge.h" 8 #include "../../../include/fxge/fx_ge.h"
9 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 9 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
10 #include "apple_int.h" 10 #include "apple_int.h"
11 #include "../../../include/fxge/fx_ge_apple.h" 11 #include "../../../include/fxge/fx_ge_apple.h"
12 #include "../agg/include/fxfx_agg_clip_liang_barsky.h"
13 #include "../ge/text_int.h" 12 #include "../ge/text_int.h"
14 #include "../dib/dib_int.h" 13 #include "../dib/dib_int.h"
15 #include "../agg/include/fx_agg_driver.h"
16 #include "../../../include/fxge/fx_freetype.h" 14 #include "../../../include/fxge/fx_freetype.h"
17 #if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ && (!defined(_FPDFAPI_MINI_))) 15 #if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ && (!defined(_FPDFAPI_MINI_)))
18 void CFX_AggDeviceDriver::InitPlatform()
19 {
20 CQuartz2D & quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatformD ata())->_quartz2d;
21 m_pPlatformGraphics = quartz2d.createGraphics(m_pBitmap);
22 }
23 void CFX_AggDeviceDriver::DestroyPlatform()
24 {
25 CQuartz2D & quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatformD ata())->_quartz2d;
26 if (m_pPlatformGraphics) {
27 quartz2d.destroyGraphics(m_pPlatformGraphics);
28 m_pPlatformGraphics = NULL;
29 }
30 }
31 void CFX_FaceCache::InitPlatform() {} 16 void CFX_FaceCache::InitPlatform() {}
32 void CFX_FaceCache::DestroyPlatform() {} 17 void CFX_FaceCache::DestroyPlatform() {}
33 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext(CFX_Font * pFont, 18 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext(CFX_Font * pFont,
34 FX_DWORD glyph_index, 19 FX_DWORD glyph_index,
35 const CFX_AffineMatrix * pMatrix, 20 const CFX_AffineMatrix * pMatrix,
36 int dest_width, 21 int dest_width,
37 int anti_alias) 22 int anti_alias)
38 { 23 {
39 return NULL; 24 return NULL;
40 } 25 }
41 static FX_BOOL _CGDrawGlyphRun(CGContextRef pContext, 26 FX_BOOL _CGDrawGlyphRun(CGContextRef pContext,
42 int nChars, 27 int nChars,
43 const FXTEXT_CHARPOS* pCharPos, 28 const FXTEXT_CHARPOS* pCharPos,
44 CFX_Font* pFont, 29 CFX_Font* pFont,
45 CFX_FontCache* pCache, 30 CFX_FontCache* pCache,
46 const CFX_AffineMatrix* pObject2Device, 31 const CFX_AffineMatrix* pObject2Device,
47 FX_FLOAT font_size, 32 FX_FLOAT font_size,
48 FX_DWORD argb, 33 FX_DWORD argb,
49 int alpha_flag, 34 int alpha_flag,
50 void* pIccTransform) 35 void* pIccTransform)
51 { 36 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 quartz2d.setGraphicsTextMatrix(pContext, &new_matrix); 77 quartz2d.setGraphicsTextMatrix(pContext, &new_matrix);
93 return quartz2d.drawGraphicsString(pContext, 78 return quartz2d.drawGraphicsString(pContext,
94 pFont->m_pPlatformFont, 79 pFont->m_pPlatformFont,
95 font_size, 80 font_size,
96 glyph_indices, 81 glyph_indices,
97 glyph_positions, 82 glyph_positions,
98 nChars, 83 nChars,
99 argb, 84 argb,
100 NULL); 85 NULL);
101 } 86 }
102 static void _DoNothing(void *info, const void *data, size_t size) {} 87
103 FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int»» » » » » nChars,
104 const FXTEXT_CHARPOS *» pCharPos,
105 CFX_Font *» » » » pFont,
106 CFX_FontCache *»» » pCache,
107 const CFX_AffineMatrix * pObject2Device,
108 FX_FLOAT» » » » font_size,
109 FX_DWORD» » » » argb,
110 int alpha_flag, void* pIccTransform)
111 {
112 if (!pFont) {
113 return FALSE;
114 }
115 FX_BOOL bBold = pFont->IsBold();
116 if (!bBold && pFont->GetSubstFont() &&
117 pFont->GetSubstFont()->m_Weight >= 500 &&
118 pFont->GetSubstFont()->m_Weight <= 600) {
119 return FALSE;
120 }
121 for (int i = 0; i < nChars; i ++) {
122 if (pCharPos[i].m_bGlyphAdjust) {
123 return FALSE;
124 }
125 }
126 CGContextRef ctx = CGContextRef(m_pPlatformGraphics);
127 if (NULL == ctx) {
128 return FALSE;
129 }
130 CGContextSaveGState(ctx);
131 CGContextSetTextDrawingMode(ctx, kCGTextFillClip);
132 CGRect rect_cg;
133 CGImageRef pImageCG = NULL;
134 if (m_pClipRgn) {
135 rect_cg = CGRectMake(m_pClipRgn->GetBox().left, m_pClipRgn->GetBox().top , m_pClipRgn->GetBox().Width(), m_pClipRgn->GetBox().Height());
136 const CFX_DIBitmap*» pClipMask = m_pClipRgn->GetMask();
137 if (pClipMask) {
138 CGDataProviderRef pClipMaskDataProvider = CGDataProviderCreateWithDa ta(NULL,
139 pClipMask->GetBuffer(),
140 pClipMask->GetPitch() * pClipMask->GetHeight(),
141 _DoNothing);
142 CGFloat decode_f[2] = {255.f, 0.f};
143 pImageCG = CGImageMaskCreate(pClipMask->GetWidth(), pClipMask->GetHe ight(),
144 8, 8, pClipMask->GetPitch(), pClipMaskD ataProvider,
145 decode_f, FALSE);
146 CGDataProviderRelease(pClipMaskDataProvider);
147 }
148 } else {
149 rect_cg = CGRectMake(0, 0, m_pBitmap->GetWidth(), m_pBitmap->GetHeight() );
150 }
151 rect_cg = CGContextConvertRectToDeviceSpace(ctx, rect_cg);
152 if (pImageCG) {
153 CGContextClipToMask(ctx, rect_cg, pImageCG);
154 } else {
155 CGContextClipToRect(ctx, rect_cg);
156 }
157 FX_BOOL ret = _CGDrawGlyphRun(ctx, nChars, pCharPos, pFont, pCache, pObject2 Device, font_size, argb, alpha_flag, pIccTransform);
158 if (pImageCG) {
159 CGImageRelease(pImageCG);
160 }
161 CGContextRestoreGState(ctx);
162 return ret;
163 }
164 void CFX_Font::ReleasePlatformResource() 88 void CFX_Font::ReleasePlatformResource()
165 { 89 {
166 if (m_pPlatformFont) { 90 if (m_pPlatformFont) {
167 CQuartz2D & quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatf ormData())->_quartz2d; 91 CQuartz2D & quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatf ormData())->_quartz2d;
168 quartz2d.DestroyFont(m_pPlatformFont); 92 quartz2d.DestroyFont(m_pPlatformFont);
169 m_pPlatformFont = NULL; 93 m_pPlatformFont = NULL;
170 } 94 }
171 } 95 }
172 #endif 96 #endif
173 #endif 97 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/apple/apple_int.h ('k') | core/src/fxge/apple/fx_quartz_device.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698