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 #include "core/fxge/agg/fx_agg_driver.h" | 8 #include "core/fxge/agg/fx_agg_driver.h" |
9 #include "core/fxge/dib/dib_int.h" | 9 #include "core/fxge/dib/dib_int.h" |
10 #include "core/fxge/ge/fx_text_int.h" | 10 #include "core/fxge/ge/fx_text_int.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 pBitmap->GetBuffer(), pBitmap->GetWidth(), pBitmap->GetHeight(), 8, | 36 pBitmap->GetBuffer(), pBitmap->GetWidth(), pBitmap->GetHeight(), 8, |
37 pBitmap->GetPitch(), colorSpace, bmpInfo); | 37 pBitmap->GetPitch(), colorSpace, bmpInfo); |
38 CGColorSpaceRelease(colorSpace); | 38 CGColorSpaceRelease(colorSpace); |
39 return context; | 39 return context; |
40 } | 40 } |
41 void CQuartz2D::destroyGraphics(void* graphics) { | 41 void CQuartz2D::destroyGraphics(void* graphics) { |
42 if (graphics) { | 42 if (graphics) { |
43 CGContextRelease((CGContextRef)graphics); | 43 CGContextRelease((CGContextRef)graphics); |
44 } | 44 } |
45 } | 45 } |
46 void* CQuartz2D::CreateFont(const uint8_t* pFontData, FX_DWORD dwFontSize) { | 46 void* CQuartz2D::CreateFont(const uint8_t* pFontData, uint32_t dwFontSize) { |
47 CGDataProviderRef pDataProvider = | 47 CGDataProviderRef pDataProvider = |
48 CGDataProviderCreateWithData(NULL, pFontData, (size_t)dwFontSize, NULL); | 48 CGDataProviderCreateWithData(NULL, pFontData, (size_t)dwFontSize, NULL); |
49 if (NULL == pDataProvider) { | 49 if (NULL == pDataProvider) { |
50 return NULL; | 50 return NULL; |
51 } | 51 } |
52 CGFontRef pCGFont = CGFontCreateWithDataProvider(pDataProvider); | 52 CGFontRef pCGFont = CGFontCreateWithDataProvider(pDataProvider); |
53 CGDataProviderRelease(pDataProvider); | 53 CGDataProviderRelease(pDataProvider); |
54 return pCGFont; | 54 return pCGFont; |
55 } | 55 } |
56 void CQuartz2D::DestroyFont(void* pFont) { | 56 void CQuartz2D::DestroyFont(void* pFont) { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 break; | 330 break; |
331 default: | 331 default: |
332 mode = kCGBlendModeNormal; | 332 mode = kCGBlendModeNormal; |
333 break; | 333 break; |
334 } | 334 } |
335 return mode; | 335 return mode; |
336 } | 336 } |
337 FX_BOOL CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData, | 337 FX_BOOL CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData, |
338 const CFX_Matrix* matrix, | 338 const CFX_Matrix* matrix, |
339 const CFX_GraphStateData* graphState, | 339 const CFX_GraphStateData* graphState, |
340 FX_DWORD fillArgb, | 340 uint32_t fillArgb, |
341 FX_DWORD strokeArgb, | 341 uint32_t strokeArgb, |
342 int fillMode, | 342 int fillMode, |
343 int alpha_flag, | 343 int alpha_flag, |
344 void* pIccTransform, | 344 void* pIccTransform, |
345 int blend_type) { | 345 int blend_type) { |
346 SaveState(); | 346 SaveState(); |
347 CGBlendMode mode = GetCGBlendMode(blend_type); | 347 CGBlendMode mode = GetCGBlendMode(blend_type); |
348 if (mode != kCGBlendModeNormal) { | 348 if (mode != kCGBlendModeNormal) { |
349 CGContextSetBlendMode(_context, mode); | 349 CGContextSetBlendMode(_context, mode); |
350 } | 350 } |
351 CGAffineTransform m = CGAffineTransformIdentity; | 351 CGAffineTransform m = CGAffineTransformIdentity; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 CGContextFillRect(_context, rect_usr); | 407 CGContextFillRect(_context, rect_usr); |
408 if (mode != kCGBlendModeNormal) { | 408 if (mode != kCGBlendModeNormal) { |
409 CGContextSetBlendMode(_context, kCGBlendModeNormal); | 409 CGContextSetBlendMode(_context, kCGBlendModeNormal); |
410 } | 410 } |
411 return TRUE; | 411 return TRUE; |
412 } | 412 } |
413 FX_BOOL CFX_QuartzDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, | 413 FX_BOOL CFX_QuartzDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, |
414 FX_FLOAT y1, | 414 FX_FLOAT y1, |
415 FX_FLOAT x2, | 415 FX_FLOAT x2, |
416 FX_FLOAT y2, | 416 FX_FLOAT y2, |
417 FX_DWORD argb, | 417 uint32_t argb, |
418 int alphaFlag, | 418 int alphaFlag, |
419 void* iccTransform, | 419 void* iccTransform, |
420 int blend_type) { | 420 int blend_type) { |
421 CGBlendMode mode = GetCGBlendMode(blend_type); | 421 CGBlendMode mode = GetCGBlendMode(blend_type); |
422 if (mode != kCGBlendModeNormal) { | 422 if (mode != kCGBlendModeNormal) { |
423 CGContextSetBlendMode(_context, mode); | 423 CGContextSetBlendMode(_context, mode); |
424 } | 424 } |
425 CGPoint pt = | 425 CGPoint pt = |
426 CGPointApplyAffineTransform(CGPointMake(x1, y1), _foxitDevice2User); | 426 CGPointApplyAffineTransform(CGPointMake(x1, y1), _foxitDevice2User); |
427 x1 = pt.x; | 427 x1 = pt.x; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 RestoreState(FALSE); | 629 RestoreState(FALSE); |
630 return TRUE; | 630 return TRUE; |
631 } | 631 } |
632 FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, | 632 FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, |
633 FX_ARGB argb, | 633 FX_ARGB argb, |
634 int dest_left, | 634 int dest_left, |
635 int dest_top, | 635 int dest_top, |
636 int dest_width, | 636 int dest_width, |
637 int dest_height, | 637 int dest_height, |
638 const FX_RECT* clipRect, | 638 const FX_RECT* clipRect, |
639 FX_DWORD flags, | 639 uint32_t flags, |
640 int alphaFlag, | 640 int alphaFlag, |
641 void* iccTransform, | 641 void* iccTransform, |
642 int blend_type) { | 642 int blend_type) { |
643 SaveState(); | 643 SaveState(); |
644 if (clipRect) { | 644 if (clipRect) { |
645 CGContextBeginPath(_context); | 645 CGContextBeginPath(_context); |
646 CGRect rect_clip = CGRectMake(clipRect->left, clipRect->top, | 646 CGRect rect_clip = CGRectMake(clipRect->left, clipRect->top, |
647 clipRect->Width(), clipRect->Height()); | 647 clipRect->Width(), clipRect->Height()); |
648 rect_clip = CGRectApplyAffineTransform(rect_clip, _foxitDevice2User); | 648 rect_clip = CGRectApplyAffineTransform(rect_clip, _foxitDevice2User); |
649 CGContextAddRect(_context, rect_clip); | 649 CGContextAddRect(_context, rect_clip); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 RestoreState(FALSE); | 735 RestoreState(FALSE); |
736 return TRUE; | 736 return TRUE; |
737 } | 737 } |
738 FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars, | 738 FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars, |
739 const FXTEXT_CHARPOS* pCharPos, | 739 const FXTEXT_CHARPOS* pCharPos, |
740 CFX_Font* pFont, | 740 CFX_Font* pFont, |
741 CFX_FontCache* pCache, | 741 CFX_FontCache* pCache, |
742 const CFX_Matrix* pGlyphMatrix, | 742 const CFX_Matrix* pGlyphMatrix, |
743 const CFX_Matrix* pObject2Device, | 743 const CFX_Matrix* pObject2Device, |
744 FX_FLOAT font_size, | 744 FX_FLOAT font_size, |
745 FX_DWORD argb, | 745 uint32_t argb, |
746 int alpha_flag, | 746 int alpha_flag, |
747 void* pIccTransform) { | 747 void* pIccTransform) { |
748 if (nChars == 0) { | 748 if (nChars == 0) { |
749 return TRUE; | 749 return TRUE; |
750 } | 750 } |
751 CQuartz2D& quartz2d = | 751 CQuartz2D& quartz2d = |
752 ((CApplePlatform*)CFX_GEModule::Get()->GetPlatformData())->_quartz2d; | 752 ((CApplePlatform*)CFX_GEModule::Get()->GetPlatformData())->_quartz2d; |
753 if (!pFont->GetPlatformFont()) { | 753 if (!pFont->GetPlatformFont()) { |
754 if (pFont->GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) { | 754 if (pFont->GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) { |
755 return FALSE; | 755 return FALSE; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 glyph_positions, nChars); | 800 glyph_positions, nChars); |
801 RestoreState(FALSE); | 801 RestoreState(FALSE); |
802 return TRUE; | 802 return TRUE; |
803 } | 803 } |
804 FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, | 804 FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, |
805 const FXTEXT_CHARPOS* pCharPos, | 805 const FXTEXT_CHARPOS* pCharPos, |
806 CFX_Font* pFont, | 806 CFX_Font* pFont, |
807 CFX_FontCache* pCache, | 807 CFX_FontCache* pCache, |
808 const CFX_Matrix* pObject2Device, | 808 const CFX_Matrix* pObject2Device, |
809 FX_FLOAT font_size, | 809 FX_FLOAT font_size, |
810 FX_DWORD color, | 810 uint32_t color, |
811 int alpha_flag, | 811 int alpha_flag, |
812 void* pIccTransform) { | 812 void* pIccTransform) { |
813 if (NULL == pFont || NULL == _context) { | 813 if (NULL == pFont || NULL == _context) { |
814 return FALSE; | 814 return FALSE; |
815 } | 815 } |
816 FX_BOOL bBold = pFont->IsBold(); | 816 FX_BOOL bBold = pFont->IsBold(); |
817 if (!bBold && pFont->GetSubstFont() && | 817 if (!bBold && pFont->GetSubstFont() && |
818 pFont->GetSubstFont()->m_Weight >= 500 && | 818 pFont->GetSubstFont()->m_Weight >= 500 && |
819 pFont->GetSubstFont()->m_Weight <= 600) { | 819 pFont->GetSubstFont()->m_Weight <= 600) { |
820 return FALSE; | 820 return FALSE; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 } | 1039 } |
1040 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 1040 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
1041 if (!pBitmap->Create(width, height, format)) { | 1041 if (!pBitmap->Create(width, height, format)) { |
1042 delete pBitmap; | 1042 delete pBitmap; |
1043 return FALSE; | 1043 return FALSE; |
1044 } | 1044 } |
1045 m_bOwnedBitmap = TRUE; | 1045 m_bOwnedBitmap = TRUE; |
1046 return Attach(pBitmap); | 1046 return Attach(pBitmap); |
1047 } | 1047 } |
1048 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1048 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
OLD | NEW |