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/fxge/apple/fx_quartz_device.cpp

Issue 2477443002: Remove FX_BOOL from core (Closed)
Patch Set: Created 4 years, 1 month 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/fxge/apple/fx_mac_imp.cpp ('k') | core/fxge/cfx_facecache.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 "core/fxcrt/fx_ext.h" 7 #include "core/fxcrt/fx_ext.h"
8 8
9 #ifndef _SKIA_SUPPORT_ 9 #ifndef _SKIA_SUPPORT_
10 #include "core/fxge/agg/fx_agg_driver.h" 10 #include "core/fxge/agg/fx_agg_driver.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 void CQuartz2D::setGraphicsTextMatrix(void* graphics, CFX_Matrix* matrix) { 68 void CQuartz2D::setGraphicsTextMatrix(void* graphics, CFX_Matrix* matrix) {
69 if (!graphics || !matrix) { 69 if (!graphics || !matrix) {
70 return; 70 return;
71 } 71 }
72 CGContextRef context = (CGContextRef)graphics; 72 CGContextRef context = (CGContextRef)graphics;
73 CGFloat ty = CGBitmapContextGetHeight(context) - matrix->f; 73 CGFloat ty = CGBitmapContextGetHeight(context) - matrix->f;
74 CGContextSetTextMatrix( 74 CGContextSetTextMatrix(
75 context, CGAffineTransformMake(matrix->a, matrix->b, matrix->c, matrix->d, 75 context, CGAffineTransformMake(matrix->a, matrix->b, matrix->c, matrix->d,
76 matrix->e, ty)); 76 matrix->e, ty));
77 } 77 }
78 FX_BOOL CQuartz2D::drawGraphicsString(void* graphics, 78 bool CQuartz2D::drawGraphicsString(void* graphics,
79 void* font, 79 void* font,
80 FX_FLOAT fontSize, 80 FX_FLOAT fontSize,
81 uint16_t* glyphIndices, 81 uint16_t* glyphIndices,
82 CGPoint* glyphPositions, 82 CGPoint* glyphPositions,
83 int32_t charsCount, 83 int32_t charsCount,
84 FX_ARGB argb, 84 FX_ARGB argb,
85 CFX_Matrix* matrix) { 85 CFX_Matrix* matrix) {
86 if (!graphics) { 86 if (!graphics) {
87 return FALSE; 87 return false;
88 } 88 }
89 CGContextRef context = (CGContextRef)graphics; 89 CGContextRef context = (CGContextRef)graphics;
90 CGContextSetFont(context, (CGFontRef)font); 90 CGContextSetFont(context, (CGFontRef)font);
91 CGContextSetFontSize(context, fontSize); 91 CGContextSetFontSize(context, fontSize);
92 if (matrix) { 92 if (matrix) {
93 CGAffineTransform m = CGContextGetTextMatrix(context); 93 CGAffineTransform m = CGContextGetTextMatrix(context);
94 m = CGAffineTransformConcat( 94 m = CGAffineTransformConcat(
95 m, CGAffineTransformMake(matrix->a, matrix->b, matrix->c, matrix->d, 95 m, CGAffineTransformMake(matrix->a, matrix->b, matrix->c, matrix->d,
96 matrix->e, matrix->f)); 96 matrix->e, matrix->f));
97 CGContextSetTextMatrix(context, m); 97 CGContextSetTextMatrix(context, m);
(...skipping 10 matching lines...) Expand all
108 } 108 }
109 #else 109 #else
110 CGPoint* glyphPositionsCG = (CGPoint*)glyphPositions; 110 CGPoint* glyphPositionsCG = (CGPoint*)glyphPositions;
111 #endif 111 #endif
112 CGContextShowGlyphsAtPositions(context, (CGGlyph*)glyphIndices, 112 CGContextShowGlyphsAtPositions(context, (CGGlyph*)glyphIndices,
113 glyphPositionsCG, charsCount); 113 glyphPositionsCG, charsCount);
114 #if CGFLOAT_IS_DOUBLE 114 #if CGFLOAT_IS_DOUBLE
115 delete[] glyphPositionsCG; 115 delete[] glyphPositionsCG;
116 #endif 116 #endif
117 CGContextRestoreGState(context); 117 CGContextRestoreGState(context);
118 return TRUE; 118 return true;
119 } 119 }
120 void CQuartz2D::saveGraphicsState(void* graphics) { 120 void CQuartz2D::saveGraphicsState(void* graphics) {
121 if (graphics) { 121 if (graphics) {
122 CGContextSaveGState((CGContextRef)graphics); 122 CGContextSaveGState((CGContextRef)graphics);
123 } 123 }
124 } 124 }
125 void CQuartz2D::restoreGraphicsState(void* graphics) { 125 void CQuartz2D::restoreGraphicsState(void* graphics) {
126 if (graphics) { 126 if (graphics) {
127 CGContextRestoreGState((CGContextRef)graphics); 127 CGContextRestoreGState((CGContextRef)graphics);
128 } 128 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 void CFX_QuartzDeviceDriver::RestoreState(bool isKeepSaved) { 223 void CFX_QuartzDeviceDriver::RestoreState(bool isKeepSaved) {
224 CGContextRestoreGState(m_context); 224 CGContextRestoreGState(m_context);
225 if (isKeepSaved) { 225 if (isKeepSaved) {
226 CGContextSaveGState(m_context); 226 CGContextSaveGState(m_context);
227 } else { 227 } else {
228 m_saveCount--; 228 m_saveCount--;
229 } 229 }
230 } 230 }
231 231
232 FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathFill(const CFX_PathData* pathData, 232 bool CFX_QuartzDeviceDriver::SetClip_PathFill(const CFX_PathData* pathData,
233 const CFX_Matrix* matrix, 233 const CFX_Matrix* matrix,
234 int fillMode) { 234 int fillMode) {
235 SaveState(); 235 SaveState();
236 CGAffineTransform m = CGAffineTransformIdentity; 236 CGAffineTransform m = CGAffineTransformIdentity;
237 if (matrix) { 237 if (matrix) {
238 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(), 238 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(),
239 matrix->GetD(), matrix->GetE(), matrix->GetF()); 239 matrix->GetD(), matrix->GetE(), matrix->GetF());
240 } 240 }
241 m = CGAffineTransformConcat(m, m_foxitDevice2User); 241 m = CGAffineTransformConcat(m, m_foxitDevice2User);
242 CGContextConcatCTM(m_context, m); 242 CGContextConcatCTM(m_context, m);
243 setPathToContext(pathData); 243 setPathToContext(pathData);
244 RestoreState(false); 244 RestoreState(false);
245 if ((fillMode & 3) == FXFILL_WINDING) { 245 if ((fillMode & 3) == FXFILL_WINDING) {
246 CGContextClip(m_context); 246 CGContextClip(m_context);
247 } else { 247 } else {
248 CGContextEOClip(m_context); 248 CGContextEOClip(m_context);
249 } 249 }
250 return TRUE; 250 return true;
251 } 251 }
252 FX_FLOAT CFX_QuartzDeviceDriver::getLineWidth( 252 FX_FLOAT CFX_QuartzDeviceDriver::getLineWidth(
253 const CFX_GraphStateData* graphState, 253 const CFX_GraphStateData* graphState,
254 CGAffineTransform ctm) { 254 CGAffineTransform ctm) {
255 FX_FLOAT lineWidth = graphState->m_LineWidth; 255 FX_FLOAT lineWidth = graphState->m_LineWidth;
256 if (graphState->m_LineWidth <= 0.f) { 256 if (graphState->m_LineWidth <= 0.f) {
257 CGSize size; 257 CGSize size;
258 size.width = 1; 258 size.width = 1;
259 size.height = 1; 259 size.height = 1;
260 CGSize temp = CGSizeApplyAffineTransform(size, ctm); 260 CGSize temp = CGSizeApplyAffineTransform(size, ctm);
261 CGFloat x = 1 / temp.width; 261 CGFloat x = 1 / temp.width;
262 CGFloat y = 1 / temp.height; 262 CGFloat y = 1 / temp.height;
263 lineWidth = x > y ? x : y; 263 lineWidth = x > y ? x : y;
264 } 264 }
265 return lineWidth; 265 return lineWidth;
266 } 266 }
267 FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathStroke( 267 bool CFX_QuartzDeviceDriver::SetClip_PathStroke(
268 const CFX_PathData* pathData, 268 const CFX_PathData* pathData,
269 const CFX_Matrix* matrix, 269 const CFX_Matrix* matrix,
270 const CFX_GraphStateData* graphState) { 270 const CFX_GraphStateData* graphState) {
271 SaveState(); 271 SaveState();
272 CGAffineTransform m = CGAffineTransformIdentity; 272 CGAffineTransform m = CGAffineTransformIdentity;
273 if (matrix) { 273 if (matrix) {
274 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(), 274 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(),
275 matrix->GetD(), matrix->GetE(), matrix->GetF()); 275 matrix->GetD(), matrix->GetE(), matrix->GetF());
276 } 276 }
277 m = CGAffineTransformConcat(m, m_foxitDevice2User); 277 m = CGAffineTransformConcat(m, m_foxitDevice2User);
278 CGContextConcatCTM(m_context, m); 278 CGContextConcatCTM(m_context, m);
279 FX_FLOAT lineWidth = getLineWidth(graphState, m); 279 FX_FLOAT lineWidth = getLineWidth(graphState, m);
280 setStrokeInfo(graphState, 0xFF000000, lineWidth); 280 setStrokeInfo(graphState, 0xFF000000, lineWidth);
281 setPathToContext(pathData); 281 setPathToContext(pathData);
282 CGContextReplacePathWithStrokedPath(m_context); 282 CGContextReplacePathWithStrokedPath(m_context);
283 RestoreState(false); 283 RestoreState(false);
284 CGContextClip(m_context); 284 CGContextClip(m_context);
285 return TRUE; 285 return true;
286 } 286 }
287 static CGBlendMode GetCGBlendMode(int blend_type) { 287 static CGBlendMode GetCGBlendMode(int blend_type) {
288 CGBlendMode mode = kCGBlendModeNormal; 288 CGBlendMode mode = kCGBlendModeNormal;
289 switch (blend_type) { 289 switch (blend_type) {
290 case FXDIB_BLEND_NORMAL: 290 case FXDIB_BLEND_NORMAL:
291 mode = kCGBlendModeNormal; 291 mode = kCGBlendModeNormal;
292 break; 292 break;
293 case FXDIB_BLEND_MULTIPLY: 293 case FXDIB_BLEND_MULTIPLY:
294 mode = kCGBlendModeMultiply; 294 mode = kCGBlendModeMultiply;
295 break; 295 break;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 case FXDIB_BLEND_LUMINOSITY: 335 case FXDIB_BLEND_LUMINOSITY:
336 mode = kCGBlendModeLuminosity; 336 mode = kCGBlendModeLuminosity;
337 break; 337 break;
338 default: 338 default:
339 mode = kCGBlendModeNormal; 339 mode = kCGBlendModeNormal;
340 break; 340 break;
341 } 341 }
342 return mode; 342 return mode;
343 } 343 }
344 344
345 FX_BOOL CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData, 345 bool CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData,
346 const CFX_Matrix* matrix, 346 const CFX_Matrix* matrix,
347 const CFX_GraphStateData* graphState, 347 const CFX_GraphStateData* graphState,
348 uint32_t fillArgb, 348 uint32_t fillArgb,
349 uint32_t strokeArgb, 349 uint32_t strokeArgb,
350 int fillMode, 350 int fillMode,
351 int blend_type) { 351 int blend_type) {
352 SaveState(); 352 SaveState();
353 CGBlendMode mode = GetCGBlendMode(blend_type); 353 CGBlendMode mode = GetCGBlendMode(blend_type);
354 if (mode != kCGBlendModeNormal) { 354 if (mode != kCGBlendModeNormal) {
355 CGContextSetBlendMode(m_context, mode); 355 CGContextSetBlendMode(m_context, mode);
356 } 356 }
357 CGAffineTransform m = CGAffineTransformIdentity; 357 CGAffineTransform m = CGAffineTransformIdentity;
358 if (matrix) { 358 if (matrix) {
359 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(), 359 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(),
360 matrix->GetD(), matrix->GetE(), matrix->GetF()); 360 matrix->GetD(), matrix->GetE(), matrix->GetF());
361 } 361 }
(...skipping 23 matching lines...) Expand all
385 } else if (pathMode == 1) { 385 } else if (pathMode == 1) {
386 CGContextFillPath(m_context); 386 CGContextFillPath(m_context);
387 } else if (pathMode == 2) { 387 } else if (pathMode == 2) {
388 CGContextEOFillPath(m_context); 388 CGContextEOFillPath(m_context);
389 } else if (pathMode == 5) { 389 } else if (pathMode == 5) {
390 CGContextDrawPath(m_context, kCGPathFillStroke); 390 CGContextDrawPath(m_context, kCGPathFillStroke);
391 } else if (pathMode == 6) { 391 } else if (pathMode == 6) {
392 CGContextDrawPath(m_context, kCGPathEOFillStroke); 392 CGContextDrawPath(m_context, kCGPathEOFillStroke);
393 } 393 }
394 RestoreState(false); 394 RestoreState(false);
395 return TRUE; 395 return true;
396 } 396 }
397 397
398 FX_BOOL CFX_QuartzDeviceDriver::FillRectWithBlend(const FX_RECT* rect, 398 bool CFX_QuartzDeviceDriver::FillRectWithBlend(const FX_RECT* rect,
399 FX_ARGB fillArgb, 399 FX_ARGB fillArgb,
400 int blend_type) { 400 int blend_type) {
401 CGBlendMode mode = GetCGBlendMode(blend_type); 401 CGBlendMode mode = GetCGBlendMode(blend_type);
402 if (mode != kCGBlendModeNormal) { 402 if (mode != kCGBlendModeNormal) {
403 CGContextSetBlendMode(m_context, mode); 403 CGContextSetBlendMode(m_context, mode);
404 } 404 }
405 CGRect rect_fx = 405 CGRect rect_fx =
406 CGRectMake(rect->left, rect->top, rect->Width(), rect->Height()); 406 CGRectMake(rect->left, rect->top, rect->Width(), rect->Height());
407 CGRect rect_usr = CGRectApplyAffineTransform(rect_fx, m_foxitDevice2User); 407 CGRect rect_usr = CGRectApplyAffineTransform(rect_fx, m_foxitDevice2User);
408 int32_t a, r, g, b; 408 int32_t a, r, g, b;
409 ArgbDecode(fillArgb, a, r, g, b); 409 ArgbDecode(fillArgb, a, r, g, b);
410 CGContextSetRGBFillColor(m_context, r / 255.f, g / 255.f, b / 255.f, 410 CGContextSetRGBFillColor(m_context, r / 255.f, g / 255.f, b / 255.f,
411 a / 255.f); 411 a / 255.f);
412 CGContextFillRect(m_context, rect_usr); 412 CGContextFillRect(m_context, rect_usr);
413 if (mode != kCGBlendModeNormal) { 413 if (mode != kCGBlendModeNormal) {
414 CGContextSetBlendMode(m_context, kCGBlendModeNormal); 414 CGContextSetBlendMode(m_context, kCGBlendModeNormal);
415 } 415 }
416 return TRUE; 416 return true;
417 } 417 }
418 418
419 FX_BOOL CFX_QuartzDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, 419 bool CFX_QuartzDeviceDriver::DrawCosmeticLine(FX_FLOAT x1,
420 FX_FLOAT y1, 420 FX_FLOAT y1,
421 FX_FLOAT x2, 421 FX_FLOAT x2,
422 FX_FLOAT y2, 422 FX_FLOAT y2,
423 uint32_t argb, 423 uint32_t argb,
424 int blend_type) { 424 int blend_type) {
425 CGBlendMode mode = GetCGBlendMode(blend_type); 425 CGBlendMode mode = GetCGBlendMode(blend_type);
426 if (mode != kCGBlendModeNormal) { 426 if (mode != kCGBlendModeNormal) {
427 CGContextSetBlendMode(m_context, mode); 427 CGContextSetBlendMode(m_context, mode);
428 } 428 }
429 CGPoint pt = 429 CGPoint pt =
430 CGPointApplyAffineTransform(CGPointMake(x1, y1), m_foxitDevice2User); 430 CGPointApplyAffineTransform(CGPointMake(x1, y1), m_foxitDevice2User);
431 x1 = pt.x; 431 x1 = pt.x;
432 y1 = pt.y; 432 y1 = pt.y;
433 pt = CGPointApplyAffineTransform(CGPointMake(x2, y2), m_foxitDevice2User); 433 pt = CGPointApplyAffineTransform(CGPointMake(x2, y2), m_foxitDevice2User);
434 x2 = pt.x; 434 x2 = pt.x;
435 y2 = pt.y; 435 y2 = pt.y;
436 int32_t a, r, g, b; 436 int32_t a, r, g, b;
437 ArgbDecode(argb, a, r, g, b); 437 ArgbDecode(argb, a, r, g, b);
438 CGContextSetRGBStrokeColor(m_context, r / 255.f, g / 255.f, b / 255.f, 438 CGContextSetRGBStrokeColor(m_context, r / 255.f, g / 255.f, b / 255.f,
439 a / 255.f); 439 a / 255.f);
440 CGContextMoveToPoint(m_context, x1, y1); 440 CGContextMoveToPoint(m_context, x1, y1);
441 CGContextAddLineToPoint(m_context, x2, y2); 441 CGContextAddLineToPoint(m_context, x2, y2);
442 CGContextStrokePath(m_context); 442 CGContextStrokePath(m_context);
443 if (mode != kCGBlendModeNormal) { 443 if (mode != kCGBlendModeNormal) {
444 CGContextSetBlendMode(m_context, kCGBlendModeNormal); 444 CGContextSetBlendMode(m_context, kCGBlendModeNormal);
445 } 445 }
446 return TRUE; 446 return true;
447 } 447 }
448 448
449 FX_BOOL CFX_QuartzDeviceDriver::GetClipBox(FX_RECT* rect) { 449 bool CFX_QuartzDeviceDriver::GetClipBox(FX_RECT* rect) {
450 CGRect r = CGContextGetClipBoundingBox(m_context); 450 CGRect r = CGContextGetClipBoundingBox(m_context);
451 r = CGRectApplyAffineTransform(r, m_user2FoxitDevice); 451 r = CGRectApplyAffineTransform(r, m_user2FoxitDevice);
452 rect->left = FXSYS_floor(r.origin.x); 452 rect->left = FXSYS_floor(r.origin.x);
453 rect->top = FXSYS_floor(r.origin.y); 453 rect->top = FXSYS_floor(r.origin.y);
454 rect->right = FXSYS_ceil(r.origin.x + r.size.width); 454 rect->right = FXSYS_ceil(r.origin.x + r.size.width);
455 rect->bottom = FXSYS_ceil(r.origin.y + r.size.height); 455 rect->bottom = FXSYS_ceil(r.origin.y + r.size.height);
456 return TRUE; 456 return true;
457 } 457 }
458 458
459 FX_BOOL CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap, 459 bool CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap,
460 int32_t left, 460 int32_t left,
461 int32_t top) { 461 int32_t top) {
462 if (FXDC_PRINTER == m_deviceClass || bitmap->GetBPP() < 32 || 462 if (FXDC_PRINTER == m_deviceClass || bitmap->GetBPP() < 32 ||
463 !(m_renderCaps | FXRC_GET_BITS)) { 463 !(m_renderCaps | FXRC_GET_BITS)) {
464 return FALSE; 464 return false;
465 } 465 }
466 466
467 CGPoint pt = CGPointMake(left, top); 467 CGPoint pt = CGPointMake(left, top);
468 pt = CGPointApplyAffineTransform(pt, m_foxitDevice2User); 468 pt = CGPointApplyAffineTransform(pt, m_foxitDevice2User);
469 CGAffineTransform ctm = CGContextGetCTM(m_context); 469 CGAffineTransform ctm = CGContextGetCTM(m_context);
470 pt.x *= FXSYS_fabs(ctm.a); 470 pt.x *= FXSYS_fabs(ctm.a);
471 pt.y *= FXSYS_fabs(ctm.d); 471 pt.y *= FXSYS_fabs(ctm.d);
472 CGImageRef image = CGBitmapContextCreateImage(m_context); 472 CGImageRef image = CGBitmapContextCreateImage(m_context);
473 if (!image) 473 if (!image)
474 return FALSE; 474 return false;
475 475
476 CGFloat width = (CGFloat)bitmap->GetWidth(); 476 CGFloat width = (CGFloat)bitmap->GetWidth();
477 CGFloat height = (CGFloat)bitmap->GetHeight(); 477 CGFloat height = (CGFloat)bitmap->GetHeight();
478 if (width + pt.x > m_width) 478 if (width + pt.x > m_width)
479 width -= (width + pt.x - m_width); 479 width -= (width + pt.x - m_width);
480 if (height + pt.y > m_height) 480 if (height + pt.y > m_height)
481 height -= (height + pt.y - m_height); 481 height -= (height + pt.y - m_height);
482 482
483 CGImageRef subImage = CGImageCreateWithImageInRect( 483 CGImageRef subImage = CGImageCreateWithImageInRect(
484 image, CGRectMake(pt.x, pt.y, width, height)); 484 image, CGRectMake(pt.x, pt.y, width, height));
485 CGContextRef context = createContextWithBitmap(bitmap); 485 CGContextRef context = createContextWithBitmap(bitmap);
486 CGRect rect = CGContextGetClipBoundingBox(context); 486 CGRect rect = CGContextGetClipBoundingBox(context);
487 CGContextClearRect(context, rect); 487 CGContextClearRect(context, rect);
488 CGContextDrawImage(context, rect, subImage); 488 CGContextDrawImage(context, rect, subImage);
489 CGContextRelease(context); 489 CGContextRelease(context);
490 CGImageRelease(subImage); 490 CGImageRelease(subImage);
491 CGImageRelease(image); 491 CGImageRelease(image);
492 if (!bitmap->HasAlpha()) 492 if (!bitmap->HasAlpha())
493 return TRUE; 493 return true;
494 494
495 for (int row = 0; row < bitmap->GetHeight(); row++) { 495 for (int row = 0; row < bitmap->GetHeight(); row++) {
496 uint8_t* pScanline = (uint8_t*)bitmap->GetScanline(row); 496 uint8_t* pScanline = (uint8_t*)bitmap->GetScanline(row);
497 for (int col = 0; col < bitmap->GetWidth(); col++) { 497 for (int col = 0; col < bitmap->GetWidth(); col++) {
498 if (pScanline[3] > 0) { 498 if (pScanline[3] > 0) {
499 pScanline[0] = (pScanline[0] * 255.f / pScanline[3] + .5f); 499 pScanline[0] = (pScanline[0] * 255.f / pScanline[3] + .5f);
500 pScanline[1] = (pScanline[1] * 255.f / pScanline[3] + .5f); 500 pScanline[1] = (pScanline[1] * 255.f / pScanline[3] + .5f);
501 pScanline[2] = (pScanline[2] * 255.f / pScanline[3] + .5f); 501 pScanline[2] = (pScanline[2] * 255.f / pScanline[3] + .5f);
502 } 502 }
503 pScanline += 4; 503 pScanline += 4;
504 } 504 }
505 } 505 }
506 return TRUE; 506 return true;
507 } 507 }
508 508
509 FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, 509 bool CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
510 FX_ARGB argb, 510 FX_ARGB argb,
511 const FX_RECT* srcRect, 511 const FX_RECT* srcRect,
512 int dest_left, 512 int dest_left,
513 int dest_top, 513 int dest_top,
514 int blendType) { 514 int blendType) {
515 SaveState(); 515 SaveState();
516 CGFloat src_left, src_top, src_width, src_height; 516 CGFloat src_left, src_top, src_width, src_height;
517 if (srcRect) { 517 if (srcRect) {
518 src_left = srcRect->left; 518 src_left = srcRect->left;
519 src_top = srcRect->top; 519 src_top = srcRect->top;
520 src_width = srcRect->Width(); 520 src_width = srcRect->Width();
521 src_height = srcRect->Height(); 521 src_height = srcRect->Height();
522 } else { 522 } else {
523 src_left = src_top = 0; 523 src_left = src_top = 0;
524 src_width = pBitmap->GetWidth(); 524 src_width = pBitmap->GetWidth();
(...skipping 17 matching lines...) Expand all
542 CG_SetImageTransform(dest_left, dest_top, src_width, src_height, &rect_usr); 542 CG_SetImageTransform(dest_left, dest_top, src_width, src_height, &rect_usr);
543 CFX_DIBitmap* pBitmap1 = nullptr; 543 CFX_DIBitmap* pBitmap1 = nullptr;
544 if (pBitmap->IsAlphaMask()) { 544 if (pBitmap->IsAlphaMask()) {
545 if (pBitmap->GetBuffer()) { 545 if (pBitmap->GetBuffer()) {
546 pBitmap1 = (CFX_DIBitmap*)pBitmap; 546 pBitmap1 = (CFX_DIBitmap*)pBitmap;
547 } else { 547 } else {
548 pBitmap1 = pBitmap->Clone(); 548 pBitmap1 = pBitmap->Clone();
549 } 549 }
550 if (!pBitmap1) { 550 if (!pBitmap1) {
551 RestoreState(false); 551 RestoreState(false);
552 return FALSE; 552 return false;
553 } 553 }
554 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData( 554 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(
555 nullptr, pBitmap1->GetBuffer(), 555 nullptr, pBitmap1->GetBuffer(),
556 pBitmap1->GetPitch() * pBitmap1->GetHeight(), nullptr); 556 pBitmap1->GetPitch() * pBitmap1->GetHeight(), nullptr);
557 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); 557 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray();
558 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; 558 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault;
559 CGImageRef pImage = CGImageCreate( 559 CGImageRef pImage = CGImageCreate(
560 pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(), 560 pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(),
561 pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo, 561 pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo,
562 pBitmapProvider, nullptr, true, kCGRenderingIntentDefault); 562 pBitmapProvider, nullptr, true, kCGRenderingIntentDefault);
563 CGContextClipToMask(m_context, rect_usr, pImage); 563 CGContextClipToMask(m_context, rect_usr, pImage);
564 CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f, 564 CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f,
565 FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f, 565 FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f,
566 FXARGB_A(argb) / 255.f); 566 FXARGB_A(argb) / 255.f);
567 CGContextFillRect(m_context, rect_usr); 567 CGContextFillRect(m_context, rect_usr);
568 CGImageRelease(pImage); 568 CGImageRelease(pImage);
569 CGColorSpaceRelease(pColorSpace); 569 CGColorSpaceRelease(pColorSpace);
570 CGDataProviderRelease(pBitmapProvider); 570 CGDataProviderRelease(pBitmapProvider);
571 if (pBitmap1 != pBitmap) { 571 if (pBitmap1 != pBitmap) {
572 delete pBitmap1; 572 delete pBitmap1;
573 } 573 }
574 RestoreState(false); 574 RestoreState(false);
575 return TRUE; 575 return true;
576 } 576 }
577 if (pBitmap->GetBPP() < 32) { 577 if (pBitmap->GetBPP() < 32) {
578 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32); 578 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32);
579 } else { 579 } else {
580 if (pBitmap->GetBuffer()) { 580 if (pBitmap->GetBuffer()) {
581 pBitmap1 = (CFX_DIBitmap*)pBitmap; 581 pBitmap1 = (CFX_DIBitmap*)pBitmap;
582 } else { 582 } else {
583 pBitmap1 = pBitmap->Clone(); 583 pBitmap1 = pBitmap->Clone();
584 } 584 }
585 } 585 }
586 if (!pBitmap1) { 586 if (!pBitmap1) {
587 RestoreState(false); 587 RestoreState(false);
588 return FALSE; 588 return false;
589 } 589 }
590 if (pBitmap1->HasAlpha()) { 590 if (pBitmap1->HasAlpha()) {
591 if (pBitmap1 == pBitmap) { 591 if (pBitmap1 == pBitmap) {
592 pBitmap1 = pBitmap->Clone(); 592 pBitmap1 = pBitmap->Clone();
593 if (!pBitmap1) { 593 if (!pBitmap1) {
594 RestoreState(false); 594 RestoreState(false);
595 return FALSE; 595 return false;
596 } 596 }
597 } 597 }
598 for (int row = 0; row < pBitmap1->GetHeight(); row++) { 598 for (int row = 0; row < pBitmap1->GetHeight(); row++) {
599 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row); 599 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row);
600 for (int col = 0; col < pBitmap1->GetWidth(); col++) { 600 for (int col = 0; col < pBitmap1->GetWidth(); col++) {
601 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .5f); 601 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .5f);
602 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .5f); 602 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .5f);
603 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .5f); 603 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .5f);
604 pScanline += 4; 604 pScanline += 4;
605 } 605 }
(...skipping 13 matching lines...) Expand all
619 blend_mode = kCGBlendModeNormal; 619 blend_mode = kCGBlendModeNormal;
620 } 620 }
621 CGContextSetBlendMode(m_context, (CGBlendMode)blend_mode); 621 CGContextSetBlendMode(m_context, (CGBlendMode)blend_mode);
622 CGContextDrawImage(m_context, rect_usr, image); 622 CGContextDrawImage(m_context, rect_usr, image);
623 CGImageRelease(image); 623 CGImageRelease(image);
624 CGContextRelease(ctx); 624 CGContextRelease(ctx);
625 if (pBitmap1 != pBitmap) { 625 if (pBitmap1 != pBitmap) {
626 delete pBitmap1; 626 delete pBitmap1;
627 } 627 }
628 RestoreState(false); 628 RestoreState(false);
629 return TRUE; 629 return true;
630 } 630 }
631 631
632 FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, 632 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 uint32_t flags, 639 uint32_t flags,
640 int blend_type) { 640 int blend_type) {
641 SaveState(); 641 SaveState();
642 if (clipRect) { 642 if (clipRect) {
643 CGContextBeginPath(m_context); 643 CGContextBeginPath(m_context);
644 CGRect rect_clip = CGRectMake(clipRect->left, clipRect->top, 644 CGRect rect_clip = CGRectMake(clipRect->left, clipRect->top,
645 clipRect->Width(), clipRect->Height()); 645 clipRect->Width(), clipRect->Height());
646 rect_clip = CGRectApplyAffineTransform(rect_clip, m_foxitDevice2User); 646 rect_clip = CGRectApplyAffineTransform(rect_clip, m_foxitDevice2User);
647 CGContextAddRect(m_context, rect_clip); 647 CGContextAddRect(m_context, rect_clip);
648 CGContextClip(m_context); 648 CGContextClip(m_context);
649 } 649 }
650 CGRect rect = CGRectMake(dest_left, dest_top, dest_width, dest_height); 650 CGRect rect = CGRectMake(dest_left, dest_top, dest_width, dest_height);
651 rect = CGRectApplyAffineTransform(rect, m_foxitDevice2User); 651 rect = CGRectApplyAffineTransform(rect, m_foxitDevice2User);
652 if (FXDIB_BICUBIC_INTERPOL == flags) 652 if (FXDIB_BICUBIC_INTERPOL == flags)
653 CGContextSetInterpolationQuality(m_context, kCGInterpolationHigh); 653 CGContextSetInterpolationQuality(m_context, kCGInterpolationHigh);
654 else if (FXDIB_DOWNSAMPLE == flags) 654 else if (FXDIB_DOWNSAMPLE == flags)
655 CGContextSetInterpolationQuality(m_context, kCGInterpolationNone); 655 CGContextSetInterpolationQuality(m_context, kCGInterpolationNone);
656 else 656 else
657 CGContextSetInterpolationQuality(m_context, kCGInterpolationMedium); 657 CGContextSetInterpolationQuality(m_context, kCGInterpolationMedium);
658 658
659 CG_SetImageTransform(dest_left, dest_top, dest_width, dest_height, nullptr); 659 CG_SetImageTransform(dest_left, dest_top, dest_width, dest_height, nullptr);
660 CFX_DIBitmap* pBitmap1 = nullptr; 660 CFX_DIBitmap* pBitmap1 = nullptr;
661 if (pBitmap->IsAlphaMask()) { 661 if (pBitmap->IsAlphaMask()) {
662 if (pBitmap->GetBuffer()) 662 if (pBitmap->GetBuffer())
663 pBitmap1 = (CFX_DIBitmap*)pBitmap; 663 pBitmap1 = (CFX_DIBitmap*)pBitmap;
664 else 664 else
665 pBitmap1 = pBitmap->Clone(); 665 pBitmap1 = pBitmap->Clone();
666 if (!pBitmap1) { 666 if (!pBitmap1) {
667 RestoreState(false); 667 RestoreState(false);
668 return FALSE; 668 return false;
669 } 669 }
670 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData( 670 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(
671 nullptr, pBitmap1->GetBuffer(), 671 nullptr, pBitmap1->GetBuffer(),
672 pBitmap1->GetPitch() * pBitmap1->GetHeight(), nullptr); 672 pBitmap1->GetPitch() * pBitmap1->GetHeight(), nullptr);
673 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); 673 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray();
674 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; 674 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault;
675 CGImageRef pImage = CGImageCreate( 675 CGImageRef pImage = CGImageCreate(
676 pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(), 676 pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(),
677 pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo, 677 pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo,
678 pBitmapProvider, nullptr, true, kCGRenderingIntentDefault); 678 pBitmapProvider, nullptr, true, kCGRenderingIntentDefault);
679 CGContextClipToMask(m_context, rect, pImage); 679 CGContextClipToMask(m_context, rect, pImage);
680 CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f, 680 CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f,
681 FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f, 681 FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f,
682 FXARGB_A(argb) / 255.f); 682 FXARGB_A(argb) / 255.f);
683 CGContextFillRect(m_context, rect); 683 CGContextFillRect(m_context, rect);
684 CGImageRelease(pImage); 684 CGImageRelease(pImage);
685 CGColorSpaceRelease(pColorSpace); 685 CGColorSpaceRelease(pColorSpace);
686 CGDataProviderRelease(pBitmapProvider); 686 CGDataProviderRelease(pBitmapProvider);
687 if (pBitmap1 != pBitmap) 687 if (pBitmap1 != pBitmap)
688 delete pBitmap1; 688 delete pBitmap1;
689 689
690 RestoreState(false); 690 RestoreState(false);
691 return TRUE; 691 return true;
692 } 692 }
693 if (pBitmap->GetBPP() < 32) { 693 if (pBitmap->GetBPP() < 32) {
694 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32); 694 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32);
695 } else { 695 } else {
696 if (pBitmap->GetBuffer()) 696 if (pBitmap->GetBuffer())
697 pBitmap1 = (CFX_DIBitmap*)pBitmap; 697 pBitmap1 = (CFX_DIBitmap*)pBitmap;
698 else 698 else
699 pBitmap1 = pBitmap->Clone(); 699 pBitmap1 = pBitmap->Clone();
700 } 700 }
701 if (!pBitmap1) { 701 if (!pBitmap1) {
702 RestoreState(false); 702 RestoreState(false);
703 return FALSE; 703 return false;
704 } 704 }
705 if (pBitmap1->HasAlpha()) { 705 if (pBitmap1->HasAlpha()) {
706 if (pBitmap1 == pBitmap) { 706 if (pBitmap1 == pBitmap) {
707 pBitmap1 = pBitmap->Clone(); 707 pBitmap1 = pBitmap->Clone();
708 if (!pBitmap1) { 708 if (!pBitmap1) {
709 RestoreState(false); 709 RestoreState(false);
710 return FALSE; 710 return false;
711 } 711 }
712 } 712 }
713 for (int row = 0; row < pBitmap1->GetHeight(); row++) { 713 for (int row = 0; row < pBitmap1->GetHeight(); row++) {
714 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row); 714 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row);
715 for (int col = 0; col < pBitmap1->GetWidth(); col++) { 715 for (int col = 0; col < pBitmap1->GetWidth(); col++) {
716 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .5f); 716 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .5f);
717 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .5f); 717 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .5f);
718 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .5f); 718 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .5f);
719 pScanline += 4; 719 pScanline += 4;
720 } 720 }
721 } 721 }
722 } 722 }
723 CGContextRef ctx = createContextWithBitmap(pBitmap1); 723 CGContextRef ctx = createContextWithBitmap(pBitmap1);
724 CGImageRef image = CGBitmapContextCreateImage(ctx); 724 CGImageRef image = CGBitmapContextCreateImage(ctx);
725 CGContextDrawImage(m_context, rect, image); 725 CGContextDrawImage(m_context, rect, image);
726 CGImageRelease(image); 726 CGImageRelease(image);
727 CGContextRelease(ctx); 727 CGContextRelease(ctx);
728 if (pBitmap1 != pBitmap) 728 if (pBitmap1 != pBitmap)
729 delete pBitmap1; 729 delete pBitmap1;
730 730
731 RestoreState(false); 731 RestoreState(false);
732 return TRUE; 732 return true;
733 } 733 }
734 734
735 FX_BOOL CFX_QuartzDeviceDriver::StartDIBits(const CFX_DIBSource* pBitmap, 735 bool CFX_QuartzDeviceDriver::StartDIBits(const CFX_DIBSource* pBitmap,
736 int bitmap_alpha, 736 int bitmap_alpha,
737 uint32_t color, 737 uint32_t color,
738 const CFX_Matrix* pMatrix, 738 const CFX_Matrix* pMatrix,
739 uint32_t flags, 739 uint32_t flags,
740 void*& handle, 740 void*& handle,
741 int blend_type) { 741 int blend_type) {
742 return FALSE; 742 return false;
743 } 743 }
744 744
745 FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlyphRun( 745 bool CFX_QuartzDeviceDriver::CG_DrawGlyphRun(int nChars,
746 int nChars, 746 const FXTEXT_CHARPOS* pCharPos,
747 const FXTEXT_CHARPOS* pCharPos, 747 CFX_Font* pFont,
748 CFX_Font* pFont, 748 const CFX_Matrix* pGlyphMatrix,
749 const CFX_Matrix* pGlyphMatrix, 749 const CFX_Matrix* pObject2Device,
750 const CFX_Matrix* pObject2Device, 750 FX_FLOAT font_size,
751 FX_FLOAT font_size, 751 uint32_t argb) {
752 uint32_t argb) {
753 if (nChars == 0) 752 if (nChars == 0)
754 return TRUE; 753 return true;
755 754
756 CQuartz2D& quartz2d = 755 CQuartz2D& quartz2d =
757 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) 756 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData())
758 ->m_quartz2d; 757 ->m_quartz2d;
759 if (!pFont->GetPlatformFont()) { 758 if (!pFont->GetPlatformFont()) {
760 if (pFont->GetPsName() == "DFHeiStd-W5") 759 if (pFont->GetPsName() == "DFHeiStd-W5")
761 return FALSE; 760 return false;
762 761
763 pFont->SetPlatformFont( 762 pFont->SetPlatformFont(
764 quartz2d.CreateFont(pFont->GetFontData(), pFont->GetSize())); 763 quartz2d.CreateFont(pFont->GetFontData(), pFont->GetSize()));
765 if (!pFont->GetPlatformFont()) { 764 if (!pFont->GetPlatformFont()) {
766 return FALSE; 765 return false;
767 } 766 }
768 } 767 }
769 CFX_FixedBufGrow<uint16_t, 32> glyph_indices(nChars); 768 CFX_FixedBufGrow<uint16_t, 32> glyph_indices(nChars);
770 CFX_FixedBufGrow<CGPoint, 32> glyph_positions(nChars); 769 CFX_FixedBufGrow<CGPoint, 32> glyph_positions(nChars);
771 for (int i = 0; i < nChars; i++) { 770 for (int i = 0; i < nChars; i++) {
772 glyph_indices[i] = pCharPos[i].m_ExtGID; 771 glyph_indices[i] = pCharPos[i].m_ExtGID;
773 glyph_positions[i].x = pCharPos[i].m_OriginX; 772 glyph_positions[i].x = pCharPos[i].m_OriginX;
774 glyph_positions[i].y = pCharPos[i].m_OriginY; 773 glyph_positions[i].y = pCharPos[i].m_OriginY;
775 } 774 }
776 CFX_Matrix text_matrix; 775 CFX_Matrix text_matrix;
(...skipping 21 matching lines...) Expand all
798 pGlyphMatrix->e, pGlyphMatrix->f); 797 pGlyphMatrix->e, pGlyphMatrix->f);
799 if (m_foxitDevice2User.d < 0) 798 if (m_foxitDevice2User.d < 0)
800 glyph_matrix = CGAffineTransformInvert(glyph_matrix); 799 glyph_matrix = CGAffineTransformInvert(glyph_matrix);
801 800
802 CGContextConcatCTM(m_context, glyph_matrix); 801 CGContextConcatCTM(m_context, glyph_matrix);
803 CGContextTranslateCTM(m_context, -origin.x, -origin.y); 802 CGContextTranslateCTM(m_context, -origin.x, -origin.y);
804 } 803 }
805 CGContextShowGlyphsAtPositions(m_context, (CGGlyph*)glyph_indices, 804 CGContextShowGlyphsAtPositions(m_context, (CGGlyph*)glyph_indices,
806 glyph_positions, nChars); 805 glyph_positions, nChars);
807 RestoreState(false); 806 RestoreState(false);
808 return TRUE; 807 return true;
809 } 808 }
810 809
811 FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, 810 bool CFX_QuartzDeviceDriver::DrawDeviceText(int nChars,
812 const FXTEXT_CHARPOS* pCharPos, 811 const FXTEXT_CHARPOS* pCharPos,
813 CFX_Font* pFont, 812 CFX_Font* pFont,
814 const CFX_Matrix* pObject2Device, 813 const CFX_Matrix* pObject2Device,
815 FX_FLOAT font_size, 814 FX_FLOAT font_size,
816 uint32_t color) { 815 uint32_t color) {
817 if (!pFont || !m_context) 816 if (!pFont || !m_context)
818 return FALSE; 817 return false;
819 818
820 FX_BOOL bBold = pFont->IsBold(); 819 bool bBold = pFont->IsBold();
821 if (!bBold && pFont->GetSubstFont() && 820 if (!bBold && pFont->GetSubstFont() &&
822 pFont->GetSubstFont()->m_Weight >= 500 && 821 pFont->GetSubstFont()->m_Weight >= 500 &&
823 pFont->GetSubstFont()->m_Weight <= 600) { 822 pFont->GetSubstFont()->m_Weight <= 600) {
824 return FALSE; 823 return false;
825 } 824 }
826 SaveState(); 825 SaveState();
827 CGContextSetTextDrawingMode(m_context, kCGTextFillClip); 826 CGContextSetTextDrawingMode(m_context, kCGTextFillClip);
828 FX_BOOL ret = FALSE; 827 bool ret = false;
829 int32_t i = 0; 828 int32_t i = 0;
830 while (i < nChars) { 829 while (i < nChars) {
831 if (pCharPos[i].m_bGlyphAdjust || font_size < 0) { 830 if (pCharPos[i].m_bGlyphAdjust || font_size < 0) {
832 if (i > 0) { 831 if (i > 0) {
833 ret = CG_DrawGlyphRun(i, pCharPos, pFont, nullptr, pObject2Device, 832 ret = CG_DrawGlyphRun(i, pCharPos, pFont, nullptr, pObject2Device,
834 font_size, color); 833 font_size, color);
835 if (!ret) { 834 if (!ret) {
836 RestoreState(false); 835 RestoreState(false);
837 return ret; 836 return ret;
838 } 837 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 993
995 for (int i = 0; i < m_saveCount; ++i) { 994 for (int i = 0; i < m_saveCount; ++i) {
996 CGContextRestoreGState(m_context); 995 CGContextRestoreGState(m_context);
997 } 996 }
998 m_saveCount = 0; 997 m_saveCount = 0;
999 if (m_context) { 998 if (m_context) {
1000 CGContextRelease(m_context); 999 CGContextRelease(m_context);
1001 } 1000 }
1002 } 1001 }
1003 CFX_QuartzDevice::CFX_QuartzDevice() { 1002 CFX_QuartzDevice::CFX_QuartzDevice() {
1004 m_bOwnedBitmap = FALSE; 1003 m_bOwnedBitmap = false;
1005 m_pContext = nullptr; 1004 m_pContext = nullptr;
1006 } 1005 }
1007 CFX_QuartzDevice::~CFX_QuartzDevice() { 1006 CFX_QuartzDevice::~CFX_QuartzDevice() {
1008 if (m_pContext) { 1007 if (m_pContext) {
1009 CGContextRelease(m_pContext); 1008 CGContextRelease(m_pContext);
1010 } 1009 }
1011 if (m_bOwnedBitmap) { 1010 if (m_bOwnedBitmap) {
1012 delete GetBitmap(); 1011 delete GetBitmap();
1013 } 1012 }
1014 } 1013 }
1015 CGContextRef CFX_QuartzDevice::GetContext() { 1014 CGContextRef CFX_QuartzDevice::GetContext() {
1016 return m_pContext; 1015 return m_pContext;
1017 } 1016 }
1018 FX_BOOL CFX_QuartzDevice::Attach(CGContextRef context, int32_t nDeviceClass) { 1017 bool CFX_QuartzDevice::Attach(CGContextRef context, int32_t nDeviceClass) {
1019 if (m_pContext) { 1018 if (m_pContext) {
1020 CGContextRelease(m_pContext); 1019 CGContextRelease(m_pContext);
1021 } 1020 }
1022 m_pContext = context; 1021 m_pContext = context;
1023 CGContextRetain(m_pContext); 1022 CGContextRetain(m_pContext);
1024 SetDeviceDriver( 1023 SetDeviceDriver(
1025 pdfium::MakeUnique<CFX_QuartzDeviceDriver>(m_pContext, nDeviceClass)); 1024 pdfium::MakeUnique<CFX_QuartzDeviceDriver>(m_pContext, nDeviceClass));
1026 return TRUE; 1025 return true;
1027 } 1026 }
1028 1027
1029 FX_BOOL CFX_QuartzDevice::Attach(CFX_DIBitmap* pBitmap) { 1028 bool CFX_QuartzDevice::Attach(CFX_DIBitmap* pBitmap) {
1030 SetBitmap(pBitmap); 1029 SetBitmap(pBitmap);
1031 m_pContext = createContextWithBitmap(pBitmap); 1030 m_pContext = createContextWithBitmap(pBitmap);
1032 if (!m_pContext) 1031 if (!m_pContext)
1033 return FALSE; 1032 return false;
1034 1033
1035 SetDeviceDriver( 1034 SetDeviceDriver(
1036 pdfium::MakeUnique<CFX_QuartzDeviceDriver>(m_pContext, FXDC_DISPLAY)); 1035 pdfium::MakeUnique<CFX_QuartzDeviceDriver>(m_pContext, FXDC_DISPLAY));
1037 return TRUE; 1036 return true;
1038 } 1037 }
1039 1038
1040 FX_BOOL CFX_QuartzDevice::Create(int32_t width, 1039 bool CFX_QuartzDevice::Create(int32_t width,
1041 int32_t height, 1040 int32_t height,
1042 FXDIB_Format format) { 1041 FXDIB_Format format) {
1043 if ((uint8_t)format < 32) { 1042 if ((uint8_t)format < 32) {
1044 return FALSE; 1043 return false;
1045 } 1044 }
1046 std::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); 1045 std::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap);
1047 if (!pBitmap->Create(width, height, format)) 1046 if (!pBitmap->Create(width, height, format))
1048 return FALSE; 1047 return false;
1049 m_bOwnedBitmap = TRUE; 1048 m_bOwnedBitmap = true;
1050 return Attach(pBitmap.release()); 1049 return Attach(pBitmap.release());
1051 } 1050 }
1052 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1051 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
OLDNEW
« no previous file with comments | « core/fxge/apple/fx_mac_imp.cpp ('k') | core/fxge/cfx_facecache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698