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 "../../../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 #include "../agg/include/fxfx_agg_clip_liang_barsky.h" | 9 #include "../agg/include/fxfx_agg_clip_liang_barsky.h" |
10 #include "../ge/text_int.h" | 10 #include "../ge/text_int.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 matrix->c, | 74 matrix->c, |
75 matrix->d, | 75 matrix->d, |
76 matrix->e, | 76 matrix->e, |
77 ty)); | 77 ty)); |
78 } | 78 } |
79 FX_BOOL CQuartz2D::drawGraphicsString(void* graphics, | 79 FX_BOOL CQuartz2D::drawGraphicsString(void* graphics, |
80 void* font, | 80 void* font, |
81 FX_FLOAT fontSize, | 81 FX_FLOAT fontSize, |
82 FX_WORD* glyphIndices, | 82 FX_WORD* glyphIndices, |
83 CGPoint* glyphPositions, | 83 CGPoint* glyphPositions, |
84 FX_INT32 charsCount, | 84 int32_t charsCount, |
85 FX_ARGB argb, | 85 FX_ARGB argb, |
86 CFX_AffineMatrix* matrix ) | 86 CFX_AffineMatrix* matrix ) |
87 { | 87 { |
88 if (!graphics) { | 88 if (!graphics) { |
89 return FALSE; | 89 return FALSE; |
90 } | 90 } |
91 CGContextRef context = (CGContextRef) graphics; | 91 CGContextRef context = (CGContextRef) graphics; |
92 CGContextSetFont(context, (CGFontRef)font); | 92 CGContextSetFont(context, (CGFontRef)font); |
93 CGContextSetFontSize(context, fontSize); | 93 CGContextSetFontSize(context, fontSize); |
94 if (matrix) { | 94 if (matrix) { |
95 CGAffineTransform m = CGContextGetTextMatrix(context); | 95 CGAffineTransform m = CGContextGetTextMatrix(context); |
96 m = CGAffineTransformConcat(m, | 96 m = CGAffineTransformConcat(m, |
97 CGAffineTransformMake(matrix->a, | 97 CGAffineTransformMake(matrix->a, |
98 matrix->b, | 98 matrix->b, |
99 matrix->c, | 99 matrix->c, |
100 matrix->d, | 100 matrix->d, |
101 matrix->e, | 101 matrix->e, |
102 matrix->f)); | 102 matrix->f)); |
103 CGContextSetTextMatrix(context, m); | 103 CGContextSetTextMatrix(context, m); |
104 } | 104 } |
105 FX_INT32 a, r, g, b; | 105 int32_t a, r, g, b; |
106 ArgbDecode(argb, a, r, g, b); | 106 ArgbDecode(argb, a, r, g, b); |
107 CGContextSetRGBFillColor(context, | 107 CGContextSetRGBFillColor(context, |
108 r / 255.f, | 108 r / 255.f, |
109 g / 255.f, | 109 g / 255.f, |
110 b / 255.f, | 110 b / 255.f, |
111 a / 255.f); | 111 a / 255.f); |
112 CGContextSaveGState(context); | 112 CGContextSaveGState(context); |
113 #if CGFLOAT_IS_DOUBLE | 113 #if CGFLOAT_IS_DOUBLE |
114 CGPoint* glyphPositionsCG = new CGPoint[charsCount]; | 114 CGPoint* glyphPositionsCG = new CGPoint[charsCount]; |
115 if (!glyphPositionsCG) { | 115 if (!glyphPositionsCG) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 CGContextRef context = CGBitmapContextCreate(pBitmap->GetBuffer(), | 159 CGContextRef context = CGBitmapContextCreate(pBitmap->GetBuffer(), |
160 pBitmap->GetWidth(), | 160 pBitmap->GetWidth(), |
161 pBitmap->GetHeight(), | 161 pBitmap->GetHeight(), |
162 8, | 162 8, |
163 pBitmap->GetPitch(), | 163 pBitmap->GetPitch(), |
164 colorSpace, | 164 colorSpace, |
165 bitmapInfo); | 165 bitmapInfo); |
166 CGColorSpaceRelease(colorSpace); | 166 CGColorSpaceRelease(colorSpace); |
167 return context; | 167 return context; |
168 } | 168 } |
169 CFX_QuartzDeviceDriver::CFX_QuartzDeviceDriver(CGContextRef context, FX_INT32 de
viceClass) | 169 CFX_QuartzDeviceDriver::CFX_QuartzDeviceDriver(CGContextRef context, int32_t dev
iceClass) |
170 { | 170 { |
171 m_saveCount = 0; | 171 m_saveCount = 0; |
172 _context = context; | 172 _context = context; |
173 _deviceClass = deviceClass; | 173 _deviceClass = deviceClass; |
174 CGContextRetain(_context); | 174 CGContextRetain(_context); |
175 CGRect r = CGContextGetClipBoundingBox(context); | 175 CGRect r = CGContextGetClipBoundingBox(context); |
176 _width = FXSYS_round(r.size.width); | 176 _width = FXSYS_round(r.size.width); |
177 _height = FXSYS_round(r.size.height); | 177 _height = FXSYS_round(r.size.height); |
178 _renderCaps = FXRC_SOFT_CLIP | FXRC_BLEND_MODE | | 178 _renderCaps = FXRC_SOFT_CLIP | FXRC_BLEND_MODE | |
179 FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE | | 179 FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE | |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 int alphaFlag , | 431 int alphaFlag , |
432 void* iccTransform , | 432 void* iccTransform , |
433 int blend_type ) | 433 int blend_type ) |
434 { | 434 { |
435 CGBlendMode mode = GetCGBlendMode(blend_type); | 435 CGBlendMode mode = GetCGBlendMode(blend_type); |
436 if (mode != kCGBlendModeNormal) { | 436 if (mode != kCGBlendModeNormal) { |
437 CGContextSetBlendMode(_context, mode); | 437 CGContextSetBlendMode(_context, mode); |
438 } | 438 } |
439 CGRect rect_fx = CGRectMake(rect->left, rect->top, rect->Width(), rect->Heig
ht()); | 439 CGRect rect_fx = CGRectMake(rect->left, rect->top, rect->Width(), rect->Heig
ht()); |
440 CGRect rect_usr = CGRectApplyAffineTransform(rect_fx, _foxitDevice2User); | 440 CGRect rect_usr = CGRectApplyAffineTransform(rect_fx, _foxitDevice2User); |
441 FX_INT32 a, r, g, b; | 441 int32_t a, r, g, b; |
442 ArgbDecode(fillArgb, a, r, g, b); | 442 ArgbDecode(fillArgb, a, r, g, b); |
443 CGContextSetRGBFillColor(_context, | 443 CGContextSetRGBFillColor(_context, |
444 r / 255.f, | 444 r / 255.f, |
445 g / 255.f, | 445 g / 255.f, |
446 b / 255.f, | 446 b / 255.f, |
447 a / 255.f); | 447 a / 255.f); |
448 CGContextFillRect(_context, rect_usr); | 448 CGContextFillRect(_context, rect_usr); |
449 if (mode != kCGBlendModeNormal) { | 449 if (mode != kCGBlendModeNormal) { |
450 CGContextSetBlendMode(_context, kCGBlendModeNormal); | 450 CGContextSetBlendMode(_context, kCGBlendModeNormal); |
451 } | 451 } |
(...skipping 11 matching lines...) Expand all Loading... |
463 CGBlendMode mode = GetCGBlendMode(blend_type); | 463 CGBlendMode mode = GetCGBlendMode(blend_type); |
464 if (mode != kCGBlendModeNormal) { | 464 if (mode != kCGBlendModeNormal) { |
465 CGContextSetBlendMode(_context, mode); | 465 CGContextSetBlendMode(_context, mode); |
466 } | 466 } |
467 CGPoint pt = CGPointApplyAffineTransform(CGPointMake(x1, y1), _foxitDevice2U
ser); | 467 CGPoint pt = CGPointApplyAffineTransform(CGPointMake(x1, y1), _foxitDevice2U
ser); |
468 x1 = pt.x; | 468 x1 = pt.x; |
469 y1 = pt.y; | 469 y1 = pt.y; |
470 pt = CGPointApplyAffineTransform(CGPointMake(x2, y2), _foxitDevice2User); | 470 pt = CGPointApplyAffineTransform(CGPointMake(x2, y2), _foxitDevice2User); |
471 x2 = pt.x; | 471 x2 = pt.x; |
472 y2 = pt.y; | 472 y2 = pt.y; |
473 FX_INT32 a, r, g, b; | 473 int32_t a, r, g, b; |
474 ArgbDecode(argb, a, r, g, b); | 474 ArgbDecode(argb, a, r, g, b); |
475 CGContextSetRGBStrokeColor(_context, | 475 CGContextSetRGBStrokeColor(_context, |
476 r / 255.f, | 476 r / 255.f, |
477 g / 255.f, | 477 g / 255.f, |
478 b / 255.f, | 478 b / 255.f, |
479 a / 255.f); | 479 a / 255.f); |
480 CGContextMoveToPoint(_context, x1, y1); | 480 CGContextMoveToPoint(_context, x1, y1); |
481 CGContextAddLineToPoint(_context, x2, y2); | 481 CGContextAddLineToPoint(_context, x2, y2); |
482 CGContextStrokePath(_context); | 482 CGContextStrokePath(_context); |
483 if (mode != kCGBlendModeNormal) { | 483 if (mode != kCGBlendModeNormal) { |
484 CGContextSetBlendMode(_context, kCGBlendModeNormal); | 484 CGContextSetBlendMode(_context, kCGBlendModeNormal); |
485 } | 485 } |
486 return TRUE; | 486 return TRUE; |
487 } | 487 } |
488 FX_BOOL CFX_QuartzDeviceDriver::GetClipBox(FX_RECT* rect) | 488 FX_BOOL CFX_QuartzDeviceDriver::GetClipBox(FX_RECT* rect) |
489 { | 489 { |
490 CGRect r = CGContextGetClipBoundingBox(_context); | 490 CGRect r = CGContextGetClipBoundingBox(_context); |
491 r = CGRectApplyAffineTransform(r, _user2FoxitDevice); | 491 r = CGRectApplyAffineTransform(r, _user2FoxitDevice); |
492 rect->left = FXSYS_floor(r.origin.x); | 492 rect->left = FXSYS_floor(r.origin.x); |
493 rect->top = FXSYS_floor(r.origin.y); | 493 rect->top = FXSYS_floor(r.origin.y); |
494 rect->right = FXSYS_ceil(r.origin.x + r.size.width); | 494 rect->right = FXSYS_ceil(r.origin.x + r.size.width); |
495 rect->bottom = FXSYS_ceil(r.origin.y + r.size.height); | 495 rect->bottom = FXSYS_ceil(r.origin.y + r.size.height); |
496 return TRUE; | 496 return TRUE; |
497 } | 497 } |
498 FX_BOOL CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap, | 498 FX_BOOL CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap, |
499 FX_INT32 left, | 499 int32_t left, |
500 FX_INT32 top, | 500 int32_t top, |
501 void* pIccTransform, | 501 void* pIccTransform, |
502 FX_BOOL bDEdge) | 502 FX_BOOL bDEdge) |
503 { | 503 { |
504 if (FXDC_PRINTER == _deviceClass) { | 504 if (FXDC_PRINTER == _deviceClass) { |
505 return FALSE; | 505 return FALSE; |
506 } | 506 } |
507 if (bitmap->GetBPP() < 32) { | 507 if (bitmap->GetBPP() < 32) { |
508 return FALSE; | 508 return FALSE; |
509 } | 509 } |
510 if (!(_renderCaps | FXRC_GET_BITS)) { | 510 if (!(_renderCaps | FXRC_GET_BITS)) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 if (pBitmap1 == pBitmap) { | 649 if (pBitmap1 == pBitmap) { |
650 pBitmap1 = pBitmap->Clone(); | 650 pBitmap1 = pBitmap->Clone(); |
651 if (!pBitmap1) { | 651 if (!pBitmap1) { |
652 RestoreState(FALSE); | 652 RestoreState(FALSE); |
653 return FALSE; | 653 return FALSE; |
654 } | 654 } |
655 } | 655 } |
656 for (int row = 0; row < pBitmap1->GetHeight(); row ++) { | 656 for (int row = 0; row < pBitmap1->GetHeight(); row ++) { |
657 FX_LPBYTE pScanline = (FX_LPBYTE)pBitmap1->GetScanline(row); | 657 FX_LPBYTE pScanline = (FX_LPBYTE)pBitmap1->GetScanline(row); |
658 for (int col = 0; col < pBitmap1->GetWidth(); col ++) { | 658 for (int col = 0; col < pBitmap1->GetWidth(); col ++) { |
659 pScanline[0] = (FX_BYTE)(pScanline[0] * pScanline[3] / 255.f + .
5f); | 659 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .
5f); |
660 pScanline[1] = (FX_BYTE)(pScanline[1] * pScanline[3] / 255.f + .
5f); | 660 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .
5f); |
661 pScanline[2] = (FX_BYTE)(pScanline[2] * pScanline[3] / 255.f + .
5f); | 661 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .
5f); |
662 pScanline += 4; | 662 pScanline += 4; |
663 } | 663 } |
664 } | 664 } |
665 } | 665 } |
666 CGContextRef ctx = createContextWithBitmap(pBitmap1); | 666 CGContextRef ctx = createContextWithBitmap(pBitmap1); |
667 CGImageRef image = CGBitmapContextCreateImage(ctx); | 667 CGImageRef image = CGBitmapContextCreateImage(ctx); |
668 int blend_mode = blendType; | 668 int blend_mode = blendType; |
669 if (FXDIB_BLEND_HARDLIGHT == blendType) { | 669 if (FXDIB_BLEND_HARDLIGHT == blendType) { |
670 blend_mode = kCGBlendModeSoftLight; | 670 blend_mode = kCGBlendModeSoftLight; |
671 } else if (FXDIB_BLEND_SOFTLIGHT == blendType) { | 671 } else if (FXDIB_BLEND_SOFTLIGHT == blendType) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 if (pBitmap1 == pBitmap) { | 774 if (pBitmap1 == pBitmap) { |
775 pBitmap1 = pBitmap->Clone(); | 775 pBitmap1 = pBitmap->Clone(); |
776 if (!pBitmap1) { | 776 if (!pBitmap1) { |
777 RestoreState(FALSE); | 777 RestoreState(FALSE); |
778 return FALSE; | 778 return FALSE; |
779 } | 779 } |
780 } | 780 } |
781 for (int row = 0; row < pBitmap1->GetHeight(); row ++) { | 781 for (int row = 0; row < pBitmap1->GetHeight(); row ++) { |
782 FX_LPBYTE pScanline = (FX_LPBYTE)pBitmap1->GetScanline(row); | 782 FX_LPBYTE pScanline = (FX_LPBYTE)pBitmap1->GetScanline(row); |
783 for (int col = 0; col < pBitmap1->GetWidth(); col ++) { | 783 for (int col = 0; col < pBitmap1->GetWidth(); col ++) { |
784 pScanline[0] = (FX_BYTE)(pScanline[0] * pScanline[3] / 255.f + .
5f); | 784 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .
5f); |
785 pScanline[1] = (FX_BYTE)(pScanline[1] * pScanline[3] / 255.f + .
5f); | 785 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .
5f); |
786 pScanline[2] = (FX_BYTE)(pScanline[2] * pScanline[3] / 255.f + .
5f); | 786 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .
5f); |
787 pScanline += 4; | 787 pScanline += 4; |
788 } | 788 } |
789 } | 789 } |
790 } | 790 } |
791 CGContextRef ctx = createContextWithBitmap(pBitmap1); | 791 CGContextRef ctx = createContextWithBitmap(pBitmap1); |
792 CGImageRef image = CGBitmapContextCreateImage(ctx); | 792 CGImageRef image = CGBitmapContextCreateImage(ctx); |
793 CGContextDrawImage(_context, rect, image); | 793 CGContextDrawImage(_context, rect, image); |
794 CGImageRelease(image); | 794 CGImageRelease(image); |
795 CGContextRelease(ctx); | 795 CGContextRelease(ctx); |
796 if (pBitmap1 != pBitmap) { | 796 if (pBitmap1 != pBitmap) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 CGAffineTransform matrix_cg = CGAffineTransformMake(text_matrix.a, | 837 CGAffineTransform matrix_cg = CGAffineTransformMake(text_matrix.a, |
838 text_matrix.b, | 838 text_matrix.b, |
839 text_matrix.c, | 839 text_matrix.c, |
840 text_matrix.d, | 840 text_matrix.d, |
841 text_matrix.e, | 841 text_matrix.e, |
842 text_matrix.f); | 842 text_matrix.f); |
843 matrix_cg = CGAffineTransformConcat(matrix_cg, _foxitDevice2User); | 843 matrix_cg = CGAffineTransformConcat(matrix_cg, _foxitDevice2User); |
844 CGContextSetTextMatrix(_context, matrix_cg); | 844 CGContextSetTextMatrix(_context, matrix_cg); |
845 CGContextSetFont(_context, (CGFontRef)pFont->m_pPlatformFont); | 845 CGContextSetFont(_context, (CGFontRef)pFont->m_pPlatformFont); |
846 CGContextSetFontSize(_context, FXSYS_fabs(font_size)); | 846 CGContextSetFontSize(_context, FXSYS_fabs(font_size)); |
847 FX_INT32 a, r, g, b; | 847 int32_t a, r, g, b; |
848 ArgbDecode(argb, a, r, g, b); | 848 ArgbDecode(argb, a, r, g, b); |
849 CGContextSetRGBFillColor(_context, | 849 CGContextSetRGBFillColor(_context, |
850 r / 255.f, | 850 r / 255.f, |
851 g / 255.f, | 851 g / 255.f, |
852 b / 255.f, | 852 b / 255.f, |
853 a / 255.f); | 853 a / 255.f); |
854 SaveState(); | 854 SaveState(); |
855 if (pGlyphMatrix) { | 855 if (pGlyphMatrix) { |
856 CGPoint origin = CGPointMake( glyph_positions[0].x, glyph_positions[0].
y); | 856 CGPoint origin = CGPointMake( glyph_positions[0].x, glyph_positions[0].
y); |
857 origin = CGPointApplyAffineTransform(origin, matrix_cg); | 857 origin = CGPointApplyAffineTransform(origin, matrix_cg); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 } | 890 } |
891 FX_BOOL bBold = pFont->IsBold(); | 891 FX_BOOL bBold = pFont->IsBold(); |
892 if (!bBold && pFont->GetSubstFont() && | 892 if (!bBold && pFont->GetSubstFont() && |
893 pFont->GetSubstFont()->m_Weight >= 500 && | 893 pFont->GetSubstFont()->m_Weight >= 500 && |
894 pFont->GetSubstFont()->m_Weight <= 600) { | 894 pFont->GetSubstFont()->m_Weight <= 600) { |
895 return FALSE; | 895 return FALSE; |
896 } | 896 } |
897 SaveState(); | 897 SaveState(); |
898 CGContextSetTextDrawingMode(_context, kCGTextFillClip); | 898 CGContextSetTextDrawingMode(_context, kCGTextFillClip); |
899 FX_BOOL ret = FALSE; | 899 FX_BOOL ret = FALSE; |
900 FX_INT32 i = 0; | 900 int32_t i = 0; |
901 while (i < nChars) { | 901 while (i < nChars) { |
902 if (pCharPos[i].m_bGlyphAdjust || font_size < 0) { | 902 if (pCharPos[i].m_bGlyphAdjust || font_size < 0) { |
903 if (i > 0) { | 903 if (i > 0) { |
904 ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2D
evice, font_size, color, alpha_flag, pIccTransform); | 904 ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2D
evice, font_size, color, alpha_flag, pIccTransform); |
905 if (!ret) { | 905 if (!ret) { |
906 RestoreState(FALSE); | 906 RestoreState(FALSE); |
907 return ret; | 907 return ret; |
908 } | 908 } |
909 } | 909 } |
910 const FXTEXT_CHARPOS* char_pos = pCharPos + i; | 910 const FXTEXT_CHARPOS* char_pos = pCharPos + i; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 dashArray[index] = graphState->m_DashArray[index]; | 985 dashArray[index] = graphState->m_DashArray[index]; |
986 } | 986 } |
987 #else | 987 #else |
988 CGFloat* dashArray = (CGFloat*)graphState->m_DashArray; | 988 CGFloat* dashArray = (CGFloat*)graphState->m_DashArray; |
989 #endif | 989 #endif |
990 CGContextSetLineDash(_context, graphState->m_DashPhase, dashArray, graph
State->m_DashCount); | 990 CGContextSetLineDash(_context, graphState->m_DashPhase, dashArray, graph
State->m_DashCount); |
991 #if CGFLOAT_IS_DOUBLE | 991 #if CGFLOAT_IS_DOUBLE |
992 delete[] dashArray; | 992 delete[] dashArray; |
993 #endif | 993 #endif |
994 } | 994 } |
995 FX_INT32 a, r, g, b; | 995 int32_t a, r, g, b; |
996 ArgbDecode(argb, a, r, g, b); | 996 ArgbDecode(argb, a, r, g, b); |
997 CGContextSetRGBStrokeColor(_context, | 997 CGContextSetRGBStrokeColor(_context, |
998 r / 255.f, | 998 r / 255.f, |
999 g / 255.f, | 999 g / 255.f, |
1000 b / 255.f, | 1000 b / 255.f, |
1001 a / 255.f); | 1001 a / 255.f); |
1002 } | 1002 } |
1003 void CFX_QuartzDeviceDriver::setFillInfo(FX_ARGB argb) | 1003 void CFX_QuartzDeviceDriver::setFillInfo(FX_ARGB argb) |
1004 { | 1004 { |
1005 FX_INT32 a, r, g, b; | 1005 int32_t a, r, g, b; |
1006 ArgbDecode(argb, a, r, g, b); | 1006 ArgbDecode(argb, a, r, g, b); |
1007 CGContextSetRGBFillColor(_context, | 1007 CGContextSetRGBFillColor(_context, |
1008 r / 255.f, | 1008 r / 255.f, |
1009 g / 255.f, | 1009 g / 255.f, |
1010 b / 255.f, | 1010 b / 255.f, |
1011 a / 255.f); | 1011 a / 255.f); |
1012 } | 1012 } |
1013 void CFX_QuartzDeviceDriver::setPathToContext(const CFX_PathData* pathData) | 1013 void CFX_QuartzDeviceDriver::setPathToContext(const CFX_PathData* pathData) |
1014 { | 1014 { |
1015 FX_INT32 count = pathData->GetPointCount(); | 1015 int32_t count = pathData->GetPointCount(); |
1016 FX_PATHPOINT* points = pathData->GetPoints(); | 1016 FX_PATHPOINT* points = pathData->GetPoints(); |
1017 CGContextBeginPath(_context); | 1017 CGContextBeginPath(_context); |
1018 for (FX_INT32 i = 0; i < count; i ++) { | 1018 for (int32_t i = 0; i < count; i ++) { |
1019 switch (points[i].m_Flag & FXPT_TYPE) { | 1019 switch (points[i].m_Flag & FXPT_TYPE) { |
1020 case FXPT_MOVETO: | 1020 case FXPT_MOVETO: |
1021 CGContextMoveToPoint(_context, points[i].m_PointX, points[i].m_P
ointY); | 1021 CGContextMoveToPoint(_context, points[i].m_PointX, points[i].m_P
ointY); |
1022 break; | 1022 break; |
1023 case FXPT_LINETO: | 1023 case FXPT_LINETO: |
1024 CGContextAddLineToPoint(_context, points[i].m_PointX, points[i].
m_PointY); | 1024 CGContextAddLineToPoint(_context, points[i].m_PointX, points[i].
m_PointY); |
1025 break; | 1025 break; |
1026 case FXPT_BEZIERTO: { | 1026 case FXPT_BEZIERTO: { |
1027 CGContextAddCurveToPoint(_context, | 1027 CGContextAddCurveToPoint(_context, |
1028 points[i].m_PointX, points[i].m_Poi
ntY, | 1028 points[i].m_PointX, points[i].m_Poi
ntY, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 CGContextRelease(m_pContext); | 1083 CGContextRelease(m_pContext); |
1084 } | 1084 } |
1085 if (GetBitmap() && m_bOwnedBitmap) { | 1085 if (GetBitmap() && m_bOwnedBitmap) { |
1086 delete GetBitmap(); | 1086 delete GetBitmap(); |
1087 } | 1087 } |
1088 } | 1088 } |
1089 CGContextRef CFX_QuartzDevice::GetContext() | 1089 CGContextRef CFX_QuartzDevice::GetContext() |
1090 { | 1090 { |
1091 return m_pContext; | 1091 return m_pContext; |
1092 } | 1092 } |
1093 FX_BOOL CFX_QuartzDevice::Attach(CGContextRef context, FX_INT32 nDeviceClass) | 1093 FX_BOOL CFX_QuartzDevice::Attach(CGContextRef context, int32_t nDeviceClass) |
1094 { | 1094 { |
1095 if (m_pContext) { | 1095 if (m_pContext) { |
1096 CGContextRelease(m_pContext); | 1096 CGContextRelease(m_pContext); |
1097 } | 1097 } |
1098 m_pContext = context; | 1098 m_pContext = context; |
1099 CGContextRetain(m_pContext); | 1099 CGContextRetain(m_pContext); |
1100 IFX_RenderDeviceDriver* pDriver = FX_NEW CFX_QuartzDeviceDriver(m_pContext,
nDeviceClass); | 1100 IFX_RenderDeviceDriver* pDriver = FX_NEW CFX_QuartzDeviceDriver(m_pContext,
nDeviceClass); |
1101 if (!pDriver) { | 1101 if (!pDriver) { |
1102 return FALSE; | 1102 return FALSE; |
1103 } | 1103 } |
1104 SetDeviceDriver(pDriver); | 1104 SetDeviceDriver(pDriver); |
1105 return TRUE; | 1105 return TRUE; |
1106 } | 1106 } |
1107 FX_BOOL CFX_QuartzDevice::Attach(CFX_DIBitmap* pBitmap) | 1107 FX_BOOL CFX_QuartzDevice::Attach(CFX_DIBitmap* pBitmap) |
1108 { | 1108 { |
1109 SetBitmap(pBitmap); | 1109 SetBitmap(pBitmap); |
1110 m_pContext = createContextWithBitmap(pBitmap); | 1110 m_pContext = createContextWithBitmap(pBitmap); |
1111 if (NULL == m_pContext) { | 1111 if (NULL == m_pContext) { |
1112 return FALSE; | 1112 return FALSE; |
1113 } | 1113 } |
1114 IFX_RenderDeviceDriver* pDriver = FX_NEW CFX_QuartzDeviceDriver(m_pContext,
FXDC_DISPLAY); | 1114 IFX_RenderDeviceDriver* pDriver = FX_NEW CFX_QuartzDeviceDriver(m_pContext,
FXDC_DISPLAY); |
1115 if (!pDriver) { | 1115 if (!pDriver) { |
1116 return FALSE; | 1116 return FALSE; |
1117 } | 1117 } |
1118 SetDeviceDriver(pDriver); | 1118 SetDeviceDriver(pDriver); |
1119 return TRUE; | 1119 return TRUE; |
1120 } | 1120 } |
1121 FX_BOOL CFX_QuartzDevice::Create(FX_INT32 width, FX_INT32 height, FXDIB_Format f
ormat) | 1121 FX_BOOL CFX_QuartzDevice::Create(int32_t width, int32_t height, FXDIB_Format for
mat) |
1122 { | 1122 { |
1123 if ((FX_BYTE)format < 32) { | 1123 if ((uint8_t)format < 32) { |
1124 return FALSE; | 1124 return FALSE; |
1125 } | 1125 } |
1126 CFX_DIBitmap* pBitmap = FX_NEW CFX_DIBitmap; | 1126 CFX_DIBitmap* pBitmap = FX_NEW CFX_DIBitmap; |
1127 if (!pBitmap) { | 1127 if (!pBitmap) { |
1128 return FALSE; | 1128 return FALSE; |
1129 } | 1129 } |
1130 if (!pBitmap->Create(width, height, format)) { | 1130 if (!pBitmap->Create(width, height, format)) { |
1131 delete pBitmap; | 1131 delete pBitmap; |
1132 return FALSE; | 1132 return FALSE; |
1133 } | 1133 } |
1134 m_bOwnedBitmap = TRUE; | 1134 m_bOwnedBitmap = TRUE; |
1135 return Attach(pBitmap); | 1135 return Attach(pBitmap); |
1136 } | 1136 } |
1137 #endif | 1137 #endif |
OLD | NEW |