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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 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/fx_mac_imp.cpp ('k') | core/src/fxge/dib/dib_int.h » ('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_freetype.h" 8 #include "../../../include/fxge/fx_freetype.h"
9 #include "../../../include/fxge/fx_ge.h" 9 #include "../../../include/fxge/fx_ge.h"
10 #include "../agg/include/fx_agg_driver.h" 10 #include "../agg/include/fx_agg_driver.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 CGContextRef context = (CGContextRef) graphics; 70 CGContextRef context = (CGContextRef) graphics;
71 CGFloat ty = CGBitmapContextGetHeight(context) - matrix->f; 71 CGFloat ty = CGBitmapContextGetHeight(context) - matrix->f;
72 CGContextSetTextMatrix(context, CGAffineTransformMake(matrix->a, 72 CGContextSetTextMatrix(context, CGAffineTransformMake(matrix->a,
73 matrix->b, 73 matrix->b,
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 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 int32_t 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 int32_t 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) {
116 return FALSE; 116 return false;
117 } 117 }
118 for (int index = 0; index < charsCount; ++index) { 118 for (int index = 0; index < charsCount; ++index) {
119 glyphPositionsCG[index].x = glyphPositions[index].x; 119 glyphPositionsCG[index].x = glyphPositions[index].x;
120 glyphPositionsCG[index].y = glyphPositions[index].y; 120 glyphPositionsCG[index].y = glyphPositions[index].y;
121 } 121 }
122 #else 122 #else
123 CGPoint* glyphPositionsCG = (CGPoint*)glyphPositions; 123 CGPoint* glyphPositionsCG = (CGPoint*)glyphPositions;
124 #endif 124 #endif
125 CGContextShowGlyphsAtPositions(context, 125 CGContextShowGlyphsAtPositions(context,
126 (CGGlyph *) glyphIndices, 126 (CGGlyph *) glyphIndices,
127 glyphPositionsCG, 127 glyphPositionsCG,
128 charsCount); 128 charsCount);
129 #if CGFLOAT_IS_DOUBLE 129 #if CGFLOAT_IS_DOUBLE
130 delete[] glyphPositionsCG; 130 delete[] glyphPositionsCG;
131 #endif 131 #endif
132 CGContextRestoreGState(context); 132 CGContextRestoreGState(context);
133 return TRUE; 133 return true;
134 } 134 }
135 void CQuartz2D::saveGraphicsState(void * graphics) 135 void CQuartz2D::saveGraphicsState(void * graphics)
136 { 136 {
137 if (graphics) { 137 if (graphics) {
138 CGContextSaveGState((CGContextRef) graphics); 138 CGContextSaveGState((CGContextRef) graphics);
139 } 139 }
140 } 140 }
141 void CQuartz2D::restoreGraphicsState(void * graphics) 141 void CQuartz2D::restoreGraphicsState(void * graphics)
142 { 142 {
143 if (graphics) { 143 if (graphics) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 CFX_Matrix CFX_QuartzDeviceDriver::GetCTM() const 244 CFX_Matrix CFX_QuartzDeviceDriver::GetCTM() const
245 { 245 {
246 CGAffineTransform ctm = CGContextGetCTM(_context); 246 CGAffineTransform ctm = CGContextGetCTM(_context);
247 return CFX_Matrix(ctm.a, ctm.b, ctm.c, ctm.d, ctm.tx, ctm.ty); 247 return CFX_Matrix(ctm.a, ctm.b, ctm.c, ctm.d, ctm.tx, ctm.ty);
248 } 248 }
249 void CFX_QuartzDeviceDriver::SaveState() 249 void CFX_QuartzDeviceDriver::SaveState()
250 { 250 {
251 CGContextSaveGState(_context); 251 CGContextSaveGState(_context);
252 m_saveCount++; 252 m_saveCount++;
253 } 253 }
254 void CFX_QuartzDeviceDriver::RestoreState(FX_BOOL isKeepSaved ) 254 void CFX_QuartzDeviceDriver::RestoreState(bool isKeepSaved )
255 { 255 {
256 CGContextRestoreGState(_context); 256 CGContextRestoreGState(_context);
257 if (isKeepSaved) { 257 if (isKeepSaved) {
258 CGContextSaveGState(_context); 258 CGContextSaveGState(_context);
259 } else { 259 } else {
260 m_saveCount--; 260 m_saveCount--;
261 } 261 }
262 } 262 }
263 FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathFill(const CFX_PathData* pathData , 263 bool CFX_QuartzDeviceDriver::SetClip_PathFill(const CFX_PathData* pathData,
264 const CFX_AffineMatrix* matrix, 264 const CFX_AffineMatrix* matrix,
265 int fillMode ) 265 int fillMode )
266 { 266 {
267 SaveState(); 267 SaveState();
268 CGAffineTransform m = CGAffineTransformIdentity; 268 CGAffineTransform m = CGAffineTransformIdentity;
269 if (matrix) { 269 if (matrix) {
270 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC() , matrix->GetD(), matrix->GetE(), matrix->GetF()); 270 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC() , matrix->GetD(), matrix->GetE(), matrix->GetF());
271 } 271 }
272 m = CGAffineTransformConcat(m, _foxitDevice2User); 272 m = CGAffineTransformConcat(m, _foxitDevice2User);
273 CGContextConcatCTM(_context, m); 273 CGContextConcatCTM(_context, m);
274 setPathToContext(pathData); 274 setPathToContext(pathData);
275 RestoreState(FALSE); 275 RestoreState(false);
276 if ((fillMode & 3) == FXFILL_WINDING) { 276 if ((fillMode & 3) == FXFILL_WINDING) {
277 CGContextClip(_context); 277 CGContextClip(_context);
278 } else { 278 } else {
279 CGContextEOClip(_context); 279 CGContextEOClip(_context);
280 } 280 }
281 return TRUE; 281 return true;
282 } 282 }
283 FX_FLOAT CFX_QuartzDeviceDriver::getLineWidth(const CFX_GraphStateData * graphSt ate, CGAffineTransform ctm) 283 FX_FLOAT CFX_QuartzDeviceDriver::getLineWidth(const CFX_GraphStateData * graphSt ate, CGAffineTransform ctm)
284 { 284 {
285 FX_FLOAT lineWidth = graphState->m_LineWidth; 285 FX_FLOAT lineWidth = graphState->m_LineWidth;
286 if (graphState->m_LineWidth <= 0.f) { 286 if (graphState->m_LineWidth <= 0.f) {
287 CGSize size; 287 CGSize size;
288 size.width = 1; 288 size.width = 1;
289 size.height = 1; 289 size.height = 1;
290 CGSize temp = CGSizeApplyAffineTransform(size, ctm); 290 CGSize temp = CGSizeApplyAffineTransform(size, ctm);
291 CGFloat x = 1 / temp.width; 291 CGFloat x = 1 / temp.width;
292 CGFloat y = 1 / temp.height; 292 CGFloat y = 1 / temp.height;
293 lineWidth = x > y ? x : y; 293 lineWidth = x > y ? x : y;
294 } 294 }
295 return lineWidth; 295 return lineWidth;
296 } 296 }
297 FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathStroke(const CFX_PathData* path Data, 297 bool CFX_QuartzDeviceDriver::SetClip_PathStroke(const CFX_PathData* pathDat a,
298 const CFX_AffineMatrix* matrix, 298 const CFX_AffineMatrix* matrix,
299 const CFX_GraphStateData* graphState ) 299 const CFX_GraphStateData* graphState )
300 { 300 {
301 SaveState(); 301 SaveState();
302 CGAffineTransform m = CGAffineTransformIdentity; 302 CGAffineTransform m = CGAffineTransformIdentity;
303 if (matrix) { 303 if (matrix) {
304 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC() , matrix->GetD(), matrix->GetE(), matrix->GetF()); 304 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC() , matrix->GetD(), matrix->GetE(), matrix->GetF());
305 } 305 }
306 m = CGAffineTransformConcat(m, _foxitDevice2User); 306 m = CGAffineTransformConcat(m, _foxitDevice2User);
307 CGContextConcatCTM(_context, m); 307 CGContextConcatCTM(_context, m);
308 FX_FLOAT lineWidth = getLineWidth(graphState, m); 308 FX_FLOAT lineWidth = getLineWidth(graphState, m);
309 setStrokeInfo(graphState, 0xFF000000, lineWidth); 309 setStrokeInfo(graphState, 0xFF000000, lineWidth);
310 setPathToContext(pathData); 310 setPathToContext(pathData);
311 CGContextReplacePathWithStrokedPath(_context); 311 CGContextReplacePathWithStrokedPath(_context);
312 RestoreState(FALSE); 312 RestoreState(false);
313 CGContextClip(_context); 313 CGContextClip(_context);
314 return TRUE; 314 return true;
315 } 315 }
316 static CGBlendMode GetCGBlendMode(int blend_type) 316 static CGBlendMode GetCGBlendMode(int blend_type)
317 { 317 {
318 CGBlendMode mode = kCGBlendModeNormal; 318 CGBlendMode mode = kCGBlendModeNormal;
319 switch (blend_type) { 319 switch (blend_type) {
320 case FXDIB_BLEND_NORMAL: 320 case FXDIB_BLEND_NORMAL:
321 mode = kCGBlendModeNormal; 321 mode = kCGBlendModeNormal;
322 break; 322 break;
323 case FXDIB_BLEND_MULTIPLY: 323 case FXDIB_BLEND_MULTIPLY:
324 mode = kCGBlendModeMultiply; 324 mode = kCGBlendModeMultiply;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 break; 364 break;
365 case FXDIB_BLEND_LUMINOSITY: 365 case FXDIB_BLEND_LUMINOSITY:
366 mode = kCGBlendModeLuminosity; 366 mode = kCGBlendModeLuminosity;
367 break; 367 break;
368 default: 368 default:
369 mode = kCGBlendModeNormal; 369 mode = kCGBlendModeNormal;
370 break; 370 break;
371 } 371 }
372 return mode; 372 return mode;
373 } 373 }
374 FX_BOOL CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData, 374 bool CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData,
375 const CFX_AffineMatrix* matrix, 375 const CFX_AffineMatrix* matrix,
376 const CFX_GraphStateData* graphState, 376 const CFX_GraphStateData* graphState,
377 FX_DWORD fillArgb, 377 FX_DWORD fillArgb,
378 FX_DWORD strokeArgb, 378 FX_DWORD strokeArgb,
379 int fillMode, 379 int fillMode,
380 int alpha_flag, 380 int alpha_flag,
381 void* pIccTransform, 381 void* pIccTransform,
382 int blend_type 382 int blend_type
383 ) 383 )
384 { 384 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 CGContextStrokePath(_context); 416 CGContextStrokePath(_context);
417 } else if (pathMode == 1) { 417 } else if (pathMode == 1) {
418 CGContextFillPath(_context); 418 CGContextFillPath(_context);
419 } else if (pathMode == 2) { 419 } else if (pathMode == 2) {
420 CGContextEOFillPath(_context); 420 CGContextEOFillPath(_context);
421 } else if (pathMode == 5) { 421 } else if (pathMode == 5) {
422 CGContextDrawPath(_context, kCGPathFillStroke); 422 CGContextDrawPath(_context, kCGPathFillStroke);
423 } else if (pathMode == 6) { 423 } else if (pathMode == 6) {
424 CGContextDrawPath(_context, kCGPathEOFillStroke); 424 CGContextDrawPath(_context, kCGPathEOFillStroke);
425 } 425 }
426 RestoreState(FALSE); 426 RestoreState(false);
427 return TRUE; 427 return true;
428 } 428 }
429 FX_BOOL CFX_QuartzDeviceDriver::FillRect(const FX_RECT* rect, 429 bool CFX_QuartzDeviceDriver::FillRect(const FX_RECT* rect,
430 FX_ARGB fillArgb, 430 FX_ARGB fillArgb,
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 int32_t 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 }
452 return TRUE; 452 return true;
453 } 453 }
454 FX_BOOL CFX_QuartzDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, 454 bool CFX_QuartzDeviceDriver::DrawCosmeticLine(FX_FLOAT x1,
455 FX_FLOAT y1, 455 FX_FLOAT y1,
456 FX_FLOAT x2, 456 FX_FLOAT x2,
457 FX_FLOAT y2, 457 FX_FLOAT y2,
458 FX_DWORD argb, 458 FX_DWORD argb,
459 int alphaFlag , 459 int alphaFlag ,
460 void* iccTransform , 460 void* iccTransform ,
461 int blend_type ) 461 int blend_type )
462 { 462 {
463 CGBlendMode mode = GetCGBlendMode(blend_type); 463 CGBlendMode mode = GetCGBlendMode(blend_type);
464 if (mode != kCGBlendModeNormal) { 464 if (mode != kCGBlendModeNormal) {
(...skipping 11 matching lines...) Expand all
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 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 bool CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap,
499 int32_t left, 499 int32_t left,
500 int32_t top, 500 int32_t top,
501 void* pIccTransform, 501 void* pIccTransform,
502 FX_BOOL bDEdge) 502 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)) {
511 return FALSE; 511 return false;
512 } 512 }
513 CGPoint pt = CGPointMake(left, top); 513 CGPoint pt = CGPointMake(left, top);
514 pt = CGPointApplyAffineTransform(pt, _foxitDevice2User); 514 pt = CGPointApplyAffineTransform(pt, _foxitDevice2User);
515 CGAffineTransform ctm = CGContextGetCTM(_context); 515 CGAffineTransform ctm = CGContextGetCTM(_context);
516 pt.x *= FXSYS_fabs(ctm.a); 516 pt.x *= FXSYS_fabs(ctm.a);
517 pt.y *= FXSYS_fabs(ctm.d); 517 pt.y *= FXSYS_fabs(ctm.d);
518 CGImageRef image = CGBitmapContextCreateImage(_context); 518 CGImageRef image = CGBitmapContextCreateImage(_context);
519 if (NULL == image) { 519 if (NULL == image) {
520 return FALSE; 520 return false;
521 } 521 }
522 CGFloat width = (CGFloat) bitmap->GetWidth(); 522 CGFloat width = (CGFloat) bitmap->GetWidth();
523 CGFloat height = (CGFloat) bitmap->GetHeight(); 523 CGFloat height = (CGFloat) bitmap->GetHeight();
524 if (width + pt.x > _width) { 524 if (width + pt.x > _width) {
525 width -= (width + pt.x - _width); 525 width -= (width + pt.x - _width);
526 } 526 }
527 if (height + pt.y > _height) { 527 if (height + pt.y > _height) {
528 height -= (height + pt.y - _height); 528 height -= (height + pt.y - _height);
529 } 529 }
530 CGImageRef subImage = CGImageCreateWithImageInRect(image, 530 CGImageRef subImage = CGImageCreateWithImageInRect(image,
(...skipping 14 matching lines...) Expand all
545 for (int col = 0; col < bitmap->GetWidth(); col ++) { 545 for (int col = 0; col < bitmap->GetWidth(); col ++) {
546 if (pScanline[3] > 0) { 546 if (pScanline[3] > 0) {
547 pScanline[0] = (pScanline[0] * 255.f / pScanline[3] + .5f); 547 pScanline[0] = (pScanline[0] * 255.f / pScanline[3] + .5f);
548 pScanline[1] = (pScanline[1] * 255.f / pScanline[3] + .5f); 548 pScanline[1] = (pScanline[1] * 255.f / pScanline[3] + .5f);
549 pScanline[2] = (pScanline[2] * 255.f / pScanline[3] + .5f); 549 pScanline[2] = (pScanline[2] * 255.f / pScanline[3] + .5f);
550 } 550 }
551 pScanline += 4; 551 pScanline += 4;
552 } 552 }
553 } 553 }
554 } 554 }
555 return TRUE; 555 return true;
556 } 556 }
557 FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, 557 bool CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
558 FX_ARGB argb, 558 FX_ARGB argb,
559 const FX_RECT* srcRect, 559 const FX_RECT* srcRect,
560 int dest_left, 560 int dest_left,
561 int dest_top, 561 int dest_top,
562 int blendType, 562 int blendType,
563 int alphaFlag , 563 int alphaFlag ,
564 void* iccTransform ) 564 void* iccTransform )
565 { 565 {
566 SaveState(); 566 SaveState();
567 CGFloat src_left, src_top, src_width, src_height; 567 CGFloat src_left, src_top, src_width, src_height;
(...skipping 23 matching lines...) Expand all
591 rect_usr = CGRectOffset(rect_usr, -src_left, -src_top); 591 rect_usr = CGRectOffset(rect_usr, -src_left, -src_top);
592 CG_SetImageTransform(dest_left, dest_top, src_width, src_height, &rect_usr); 592 CG_SetImageTransform(dest_left, dest_top, src_width, src_height, &rect_usr);
593 CFX_DIBitmap* pBitmap1 = NULL; 593 CFX_DIBitmap* pBitmap1 = NULL;
594 if (pBitmap->IsAlphaMask()) { 594 if (pBitmap->IsAlphaMask()) {
595 if (pBitmap->GetBuffer()) { 595 if (pBitmap->GetBuffer()) {
596 pBitmap1 = (CFX_DIBitmap*)pBitmap; 596 pBitmap1 = (CFX_DIBitmap*)pBitmap;
597 } else { 597 } else {
598 pBitmap1 = pBitmap->Clone(); 598 pBitmap1 = pBitmap->Clone();
599 } 599 }
600 if (NULL == pBitmap1) { 600 if (NULL == pBitmap1) {
601 RestoreState(FALSE); 601 RestoreState(false);
602 return FALSE; 602 return false;
603 } 603 }
604 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(NULL, 604 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(NULL,
605 pBitmap1->GetBuffer(), 605 pBitmap1->GetBuffer(),
606 pBitmap1->GetPitch() * pBitmap1->Get Height(), 606 pBitmap1->GetPitch() * pBitmap1->Get Height(),
607 NULL); 607 NULL);
608 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); 608 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray();
609 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; 609 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault;
610 CGImageRef pImage = CGImageCreate(pBitmap1->GetWidth(), 610 CGImageRef pImage = CGImageCreate(pBitmap1->GetWidth(),
611 pBitmap1->GetHeight(), 611 pBitmap1->GetHeight(),
612 pBitmap1->GetBPP(), 612 pBitmap1->GetBPP(),
613 pBitmap1->GetBPP(), 613 pBitmap1->GetBPP(),
614 pBitmap1->GetPitch(), 614 pBitmap1->GetPitch(),
615 pColorSpace, 615 pColorSpace,
616 bitmapInfo, 616 bitmapInfo,
617 pBitmapProvider, NULL, true, 617 pBitmapProvider, NULL, true,
618 kCGRenderingIntentDefault); 618 kCGRenderingIntentDefault);
619 CGContextClipToMask(_context, rect_usr, pImage); 619 CGContextClipToMask(_context, rect_usr, pImage);
620 CGContextSetRGBFillColor(_context, 620 CGContextSetRGBFillColor(_context,
621 FXARGB_R(argb) / 255.f, 621 FXARGB_R(argb) / 255.f,
622 FXARGB_G(argb) / 255.f, 622 FXARGB_G(argb) / 255.f,
623 FXARGB_B(argb) / 255.f, 623 FXARGB_B(argb) / 255.f,
624 FXARGB_A(argb) / 255.f); 624 FXARGB_A(argb) / 255.f);
625 CGContextFillRect(_context, rect_usr); 625 CGContextFillRect(_context, rect_usr);
626 CGImageRelease(pImage); 626 CGImageRelease(pImage);
627 CGColorSpaceRelease(pColorSpace); 627 CGColorSpaceRelease(pColorSpace);
628 CGDataProviderRelease(pBitmapProvider); 628 CGDataProviderRelease(pBitmapProvider);
629 if (pBitmap1 != pBitmap) { 629 if (pBitmap1 != pBitmap) {
630 delete pBitmap1; 630 delete pBitmap1;
631 } 631 }
632 RestoreState(FALSE); 632 RestoreState(false);
633 return TRUE; 633 return true;
634 } 634 }
635 if (pBitmap->GetBPP() < 32) { 635 if (pBitmap->GetBPP() < 32) {
636 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32); 636 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32);
637 } else { 637 } else {
638 if (pBitmap->GetBuffer()) { 638 if (pBitmap->GetBuffer()) {
639 pBitmap1 = (CFX_DIBitmap*)pBitmap; 639 pBitmap1 = (CFX_DIBitmap*)pBitmap;
640 } else { 640 } else {
641 pBitmap1 = pBitmap->Clone(); 641 pBitmap1 = pBitmap->Clone();
642 } 642 }
643 } 643 }
644 if (NULL == pBitmap1) { 644 if (NULL == pBitmap1) {
645 RestoreState(FALSE); 645 RestoreState(false);
646 return FALSE; 646 return false;
647 } 647 }
648 if (pBitmap1->HasAlpha()) { 648 if (pBitmap1->HasAlpha()) {
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 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row); 657 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row);
658 for (int col = 0; col < pBitmap1->GetWidth(); col ++) { 658 for (int col = 0; col < pBitmap1->GetWidth(); col ++) {
659 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + . 5f); 659 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + . 5f);
660 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + . 5f); 660 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + . 5f);
661 pScanline[2] = (uint8_t)(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 }
(...skipping 11 matching lines...) Expand all
675 } else if (blendType > FXDIB_BLEND_LUMINOSITY || blendType < 0) { 675 } else if (blendType > FXDIB_BLEND_LUMINOSITY || blendType < 0) {
676 blend_mode = kCGBlendModeNormal; 676 blend_mode = kCGBlendModeNormal;
677 } 677 }
678 CGContextSetBlendMode(_context, (CGBlendMode)blend_mode); 678 CGContextSetBlendMode(_context, (CGBlendMode)blend_mode);
679 CGContextDrawImage(_context, rect_usr, image); 679 CGContextDrawImage(_context, rect_usr, image);
680 CGImageRelease(image); 680 CGImageRelease(image);
681 CGContextRelease(ctx); 681 CGContextRelease(ctx);
682 if (pBitmap1 != pBitmap) { 682 if (pBitmap1 != pBitmap) {
683 delete pBitmap1; 683 delete pBitmap1;
684 } 684 }
685 RestoreState(FALSE); 685 RestoreState(false);
686 return TRUE; 686 return true;
687 } 687 }
688 FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, 688 bool CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap,
689 FX_ARGB argb, 689 FX_ARGB argb,
690 int dest_left, 690 int dest_left,
691 int dest_top, 691 int dest_top,
692 int dest_width, 692 int dest_width,
693 int dest_height, 693 int dest_height,
694 const FX_RECT* clipRect, 694 const FX_RECT* clipRect,
695 FX_DWORD flags, 695 FX_DWORD flags,
696 int alphaFlag , 696 int alphaFlag ,
697 void* iccTransform , 697 void* iccTransform ,
698 int blend_type) 698 int blend_type)
(...skipping 17 matching lines...) Expand all
716 } 716 }
717 CG_SetImageTransform(dest_left, dest_top, dest_width, dest_height); 717 CG_SetImageTransform(dest_left, dest_top, dest_width, dest_height);
718 CFX_DIBitmap* pBitmap1 = NULL; 718 CFX_DIBitmap* pBitmap1 = NULL;
719 if (pBitmap->IsAlphaMask()) { 719 if (pBitmap->IsAlphaMask()) {
720 if (pBitmap->GetBuffer()) { 720 if (pBitmap->GetBuffer()) {
721 pBitmap1 = (CFX_DIBitmap*)pBitmap; 721 pBitmap1 = (CFX_DIBitmap*)pBitmap;
722 } else { 722 } else {
723 pBitmap1 = pBitmap->Clone(); 723 pBitmap1 = pBitmap->Clone();
724 } 724 }
725 if (NULL == pBitmap1) { 725 if (NULL == pBitmap1) {
726 RestoreState(FALSE); 726 RestoreState(false);
727 return FALSE; 727 return false;
728 } 728 }
729 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(NULL, 729 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(NULL,
730 pBitmap1->GetBuffer(), 730 pBitmap1->GetBuffer(),
731 pBitmap1->GetPitch() * pBitmap1->Get Height(), 731 pBitmap1->GetPitch() * pBitmap1->Get Height(),
732 NULL); 732 NULL);
733 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); 733 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray();
734 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; 734 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault;
735 CGImageRef pImage = CGImageCreate(pBitmap1->GetWidth(), 735 CGImageRef pImage = CGImageCreate(pBitmap1->GetWidth(),
736 pBitmap1->GetHeight(), 736 pBitmap1->GetHeight(),
737 pBitmap1->GetBPP(), 737 pBitmap1->GetBPP(),
738 pBitmap1->GetBPP(), 738 pBitmap1->GetBPP(),
739 pBitmap1->GetPitch(), 739 pBitmap1->GetPitch(),
740 pColorSpace, 740 pColorSpace,
741 bitmapInfo, 741 bitmapInfo,
742 pBitmapProvider, NULL, true, 742 pBitmapProvider, NULL, true,
743 kCGRenderingIntentDefault); 743 kCGRenderingIntentDefault);
744 CGContextClipToMask(_context, rect, pImage); 744 CGContextClipToMask(_context, rect, pImage);
745 CGContextSetRGBFillColor(_context, 745 CGContextSetRGBFillColor(_context,
746 FXARGB_R(argb) / 255.f, 746 FXARGB_R(argb) / 255.f,
747 FXARGB_G(argb) / 255.f, 747 FXARGB_G(argb) / 255.f,
748 FXARGB_B(argb) / 255.f, 748 FXARGB_B(argb) / 255.f,
749 FXARGB_A(argb) / 255.f); 749 FXARGB_A(argb) / 255.f);
750 CGContextFillRect(_context, rect); 750 CGContextFillRect(_context, rect);
751 CGImageRelease(pImage); 751 CGImageRelease(pImage);
752 CGColorSpaceRelease(pColorSpace); 752 CGColorSpaceRelease(pColorSpace);
753 CGDataProviderRelease(pBitmapProvider); 753 CGDataProviderRelease(pBitmapProvider);
754 if (pBitmap1 != pBitmap) { 754 if (pBitmap1 != pBitmap) {
755 delete pBitmap1; 755 delete pBitmap1;
756 } 756 }
757 RestoreState(FALSE); 757 RestoreState(false);
758 return TRUE; 758 return true;
759 } 759 }
760 if (pBitmap->GetBPP() < 32) { 760 if (pBitmap->GetBPP() < 32) {
761 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32); 761 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32);
762 } else { 762 } else {
763 if (pBitmap->GetBuffer()) { 763 if (pBitmap->GetBuffer()) {
764 pBitmap1 = (CFX_DIBitmap*)pBitmap; 764 pBitmap1 = (CFX_DIBitmap*)pBitmap;
765 } else { 765 } else {
766 pBitmap1 = pBitmap->Clone(); 766 pBitmap1 = pBitmap->Clone();
767 } 767 }
768 } 768 }
769 if (NULL == pBitmap1) { 769 if (NULL == pBitmap1) {
770 RestoreState(FALSE); 770 RestoreState(false);
771 return FALSE; 771 return false;
772 } 772 }
773 if (pBitmap1->HasAlpha()) { 773 if (pBitmap1->HasAlpha()) {
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 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row); 782 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row);
783 for (int col = 0; col < pBitmap1->GetWidth(); col ++) { 783 for (int col = 0; col < pBitmap1->GetWidth(); col ++) {
784 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + . 5f); 784 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + . 5f);
785 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + . 5f); 785 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + . 5f);
786 pScanline[2] = (uint8_t)(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) {
797 delete pBitmap1; 797 delete pBitmap1;
798 } 798 }
799 RestoreState(FALSE); 799 RestoreState(false);
800 return TRUE; 800 return true;
801 } 801 }
802 FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars , 802 bool CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars,
803 const FXTEXT_CHARPOS* pCharPos, 803 const FXTEXT_CHARPOS* pCharPos,
804 CFX_Font* pFont, 804 CFX_Font* pFont,
805 CFX_FontCache* pCache, 805 CFX_FontCache* pCache,
806 const CFX_AffineMatrix* pGlyphMatrix, 806 const CFX_AffineMatrix* pGlyphMatrix,
807 const CFX_AffineMatrix* pObject2Device, 807 const CFX_AffineMatrix* pObject2Device,
808 FX_FLOAT font_size, 808 FX_FLOAT font_size,
809 FX_DWORD argb, 809 FX_DWORD argb,
810 int alpha_flag, 810 int alpha_flag,
811 void* pIccTransform) 811 void* pIccTransform)
812 { 812 {
813 if (nChars == 0) { 813 if (nChars == 0) {
814 return TRUE; 814 return true;
815 } 815 }
816 CQuartz2D& quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatformDa ta())->_quartz2d; 816 CQuartz2D& quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatformDa ta())->_quartz2d;
817 if (!pFont->m_pPlatformFont) { 817 if (!pFont->m_pPlatformFont) {
818 if (pFont->GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) { 818 if (pFont->GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) {
819 return FALSE; 819 return false;
820 } 820 }
821 pFont->m_pPlatformFont = quartz2d.CreateFont(pFont->m_pFontData, pFont-> m_dwSize); 821 pFont->m_pPlatformFont = quartz2d.CreateFont(pFont->m_pFontData, pFont-> m_dwSize);
822 if (NULL == pFont->m_pPlatformFont) { 822 if (NULL == pFont->m_pPlatformFont) {
823 return FALSE; 823 return false;
824 } 824 }
825 } 825 }
826 CFX_FixedBufGrow<FX_WORD, 32> glyph_indices(nChars); 826 CFX_FixedBufGrow<FX_WORD, 32> glyph_indices(nChars);
827 CFX_FixedBufGrow<CGPoint, 32> glyph_positions(nChars); 827 CFX_FixedBufGrow<CGPoint, 32> glyph_positions(nChars);
828 for (int i = 0; i < nChars; i++ ) { 828 for (int i = 0; i < nChars; i++ ) {
829 glyph_indices[i] = pCharPos[i].m_ExtGID; 829 glyph_indices[i] = pCharPos[i].m_ExtGID;
830 glyph_positions[i].x = pCharPos[i].m_OriginX; 830 glyph_positions[i].x = pCharPos[i].m_OriginX;
831 glyph_positions[i].y = pCharPos[i].m_OriginY; 831 glyph_positions[i].y = pCharPos[i].m_OriginY;
832 } 832 }
833 CFX_AffineMatrix text_matrix; 833 CFX_AffineMatrix text_matrix;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 if (_foxitDevice2User.d < 0) { 865 if (_foxitDevice2User.d < 0) {
866 glyph_matrix = CGAffineTransformInvert(glyph_matrix); 866 glyph_matrix = CGAffineTransformInvert(glyph_matrix);
867 } 867 }
868 CGContextConcatCTM(_context, glyph_matrix); 868 CGContextConcatCTM(_context, glyph_matrix);
869 CGContextTranslateCTM(_context, -origin.x, -origin.y); 869 CGContextTranslateCTM(_context, -origin.x, -origin.y);
870 } 870 }
871 CGContextShowGlyphsAtPositions(_context, 871 CGContextShowGlyphsAtPositions(_context,
872 (CGGlyph*)glyph_indices, 872 (CGGlyph*)glyph_indices,
873 glyph_positions, 873 glyph_positions,
874 nChars); 874 nChars);
875 RestoreState(FALSE); 875 RestoreState(false);
876 return TRUE; 876 return true;
877 } 877 }
878 FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, 878 bool CFX_QuartzDeviceDriver::DrawDeviceText(int nChars,
879 const FXTEXT_CHARPOS* pCharPos, 879 const FXTEXT_CHARPOS* pCharPos,
880 CFX_Font* pFont, 880 CFX_Font* pFont,
881 CFX_FontCache* pCache, 881 CFX_FontCache* pCache,
882 const CFX_AffineMatrix* pObject2Device, 882 const CFX_AffineMatrix* pObject2Device,
883 FX_FLOAT font_size, 883 FX_FLOAT font_size,
884 FX_DWORD color, 884 FX_DWORD color,
885 int alpha_flag , 885 int alpha_flag ,
886 void* pIccTransform) 886 void* pIccTransform)
887 { 887 {
888 if (NULL == pFont || NULL == _context) { 888 if (NULL == pFont || NULL == _context) {
889 return FALSE; 889 return false;
890 } 890 }
891 FX_BOOL bBold = pFont->IsBold(); 891 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 bool ret = false;
900 int32_t 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;
911 CFX_AffineMatrix glphy_matrix; 911 CFX_AffineMatrix glphy_matrix;
912 if (font_size < 0) { 912 if (font_size < 0) {
913 glphy_matrix.Concat(-1, 0, 0, -1, 0, 0); 913 glphy_matrix.Concat(-1, 0, 0, -1, 0, 0);
914 } 914 }
915 if (char_pos->m_bGlyphAdjust) { 915 if (char_pos->m_bGlyphAdjust) {
916 glphy_matrix.Concat(char_pos->m_AdjustMatrix[0], 916 glphy_matrix.Concat(char_pos->m_AdjustMatrix[0],
917 char_pos->m_AdjustMatrix[1], 917 char_pos->m_AdjustMatrix[1],
918 char_pos->m_AdjustMatrix[2], 918 char_pos->m_AdjustMatrix[2],
919 char_pos->m_AdjustMatrix[3], 0, 0); 919 char_pos->m_AdjustMatrix[3], 0, 0);
920 } 920 }
921 ret = CG_DrawGlypRun(1, char_pos, pFont, pCache, &glphy_matrix, pObj ect2Device, font_size, color, alpha_flag, pIccTransform); 921 ret = CG_DrawGlypRun(1, char_pos, pFont, pCache, &glphy_matrix, pObj ect2Device, font_size, color, alpha_flag, pIccTransform);
922 if (!ret) { 922 if (!ret) {
923 RestoreState(FALSE); 923 RestoreState(false);
924 return ret; 924 return ret;
925 } 925 }
926 i ++; 926 i ++;
927 pCharPos += i; 927 pCharPos += i;
928 nChars -= i; 928 nChars -= i;
929 i = 0; 929 i = 0;
930 } else { 930 } else {
931 i ++; 931 i ++;
932 } 932 }
933 } 933 }
934 if (i > 0) { 934 if (i > 0) {
935 ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device, f ont_size, color, alpha_flag, pIccTransform); 935 ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device, f ont_size, color, alpha_flag, pIccTransform);
936 } 936 }
937 RestoreState(FALSE); 937 RestoreState(false);
938 return ret; 938 return ret;
939 } 939 }
940 void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, FX_ARGB argb, FX_FLOAT lineWidth) 940 void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, FX_ARGB argb, FX_FLOAT lineWidth)
941 { 941 {
942 if (NULL == graphState) { 942 if (NULL == graphState) {
943 return; 943 return;
944 } 944 }
945 CGContextSetLineWidth(_context, lineWidth); 945 CGContextSetLineWidth(_context, lineWidth);
946 CGLineCap cap; 946 CGLineCap cap;
947 switch (graphState->m_LineCap) { 947 switch (graphState->m_LineCap) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 for (int i = 0; i < m_saveCount; ++i) { 1067 for (int i = 0; i < m_saveCount; ++i) {
1068 CGContextRestoreGState(_context); 1068 CGContextRestoreGState(_context);
1069 } 1069 }
1070 m_saveCount = 0; 1070 m_saveCount = 0;
1071 if (_context) { 1071 if (_context) {
1072 CGContextRelease(_context); 1072 CGContextRelease(_context);
1073 } 1073 }
1074 } 1074 }
1075 CFX_QuartzDevice::CFX_QuartzDevice() 1075 CFX_QuartzDevice::CFX_QuartzDevice()
1076 { 1076 {
1077 m_bOwnedBitmap = FALSE; 1077 m_bOwnedBitmap = false;
1078 m_pContext = NULL; 1078 m_pContext = NULL;
1079 } 1079 }
1080 CFX_QuartzDevice::~CFX_QuartzDevice() 1080 CFX_QuartzDevice::~CFX_QuartzDevice()
1081 { 1081 {
1082 if (m_pContext) { 1082 if (m_pContext) {
1083 CGContextRelease(m_pContext); 1083 CGContextRelease(m_pContext);
1084 } 1084 }
1085 if (m_bOwnedBitmap) { 1085 if (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, int32_t nDeviceClass) 1093 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 = new CFX_QuartzDeviceDriver(m_pContext, nDe viceClass); 1100 IFX_RenderDeviceDriver* pDriver = new CFX_QuartzDeviceDriver(m_pContext, nDe viceClass);
1101 SetDeviceDriver(pDriver); 1101 SetDeviceDriver(pDriver);
1102 return TRUE; 1102 return true;
1103 } 1103 }
1104 FX_BOOL CFX_QuartzDevice::Attach(CFX_DIBitmap* pBitmap) 1104 bool CFX_QuartzDevice::Attach(CFX_DIBitmap* pBitmap)
1105 { 1105 {
1106 SetBitmap(pBitmap); 1106 SetBitmap(pBitmap);
1107 m_pContext = createContextWithBitmap(pBitmap); 1107 m_pContext = createContextWithBitmap(pBitmap);
1108 if (NULL == m_pContext) { 1108 if (NULL == m_pContext) {
1109 return FALSE; 1109 return false;
1110 } 1110 }
1111 IFX_RenderDeviceDriver* pDriver = new CFX_QuartzDeviceDriver(m_pContext, FXD C_DISPLAY); 1111 IFX_RenderDeviceDriver* pDriver = new CFX_QuartzDeviceDriver(m_pContext, FXD C_DISPLAY);
1112 SetDeviceDriver(pDriver); 1112 SetDeviceDriver(pDriver);
1113 return TRUE; 1113 return true;
1114 } 1114 }
1115 FX_BOOL CFX_QuartzDevice::Create(int32_t width, int32_t height, FXDIB_Format for mat) 1115 bool CFX_QuartzDevice::Create(int32_t width, int32_t height, FXDIB_Format format )
1116 { 1116 {
1117 if ((uint8_t)format < 32) { 1117 if ((uint8_t)format < 32) {
1118 return FALSE; 1118 return false;
1119 } 1119 }
1120 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; 1120 CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
1121 if (!pBitmap->Create(width, height, format)) { 1121 if (!pBitmap->Create(width, height, format)) {
1122 delete pBitmap; 1122 delete pBitmap;
1123 return FALSE; 1123 return false;
1124 } 1124 }
1125 m_bOwnedBitmap = TRUE; 1125 m_bOwnedBitmap = true;
1126 return Attach(pBitmap); 1126 return Attach(pBitmap);
1127 } 1127 }
1128 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1128 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
OLDNEW
« no previous file with comments | « core/src/fxge/apple/fx_mac_imp.cpp ('k') | core/src/fxge/dib/dib_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698