| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fxcrt/include/fx_ext.h" | 7 #include "core/fxcrt/include/fx_ext.h" |
| 8 | 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 CFX_Matrix CFX_QuartzDeviceDriver::GetCTM() const { | 213 CFX_Matrix CFX_QuartzDeviceDriver::GetCTM() const { |
| 214 CGAffineTransform ctm = CGContextGetCTM(m_context); | 214 CGAffineTransform ctm = CGContextGetCTM(m_context); |
| 215 return CFX_Matrix(ctm.a, ctm.b, ctm.c, ctm.d, ctm.tx, ctm.ty); | 215 return CFX_Matrix(ctm.a, ctm.b, ctm.c, ctm.d, ctm.tx, ctm.ty); |
| 216 } | 216 } |
| 217 void CFX_QuartzDeviceDriver::SaveState() { | 217 void CFX_QuartzDeviceDriver::SaveState() { |
| 218 CGContextSaveGState(m_context); | 218 CGContextSaveGState(m_context); |
| 219 m_saveCount++; | 219 m_saveCount++; |
| 220 } | 220 } |
| 221 void CFX_QuartzDeviceDriver::RestoreState(FX_BOOL isKeepSaved) { | 221 |
| 222 void CFX_QuartzDeviceDriver::RestoreState(bool isKeepSaved) { |
| 222 CGContextRestoreGState(m_context); | 223 CGContextRestoreGState(m_context); |
| 223 if (isKeepSaved) { | 224 if (isKeepSaved) { |
| 224 CGContextSaveGState(m_context); | 225 CGContextSaveGState(m_context); |
| 225 } else { | 226 } else { |
| 226 m_saveCount--; | 227 m_saveCount--; |
| 227 } | 228 } |
| 228 } | 229 } |
| 230 |
| 229 FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathFill(const CFX_PathData* pathData, | 231 FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathFill(const CFX_PathData* pathData, |
| 230 const CFX_Matrix* matrix, | 232 const CFX_Matrix* matrix, |
| 231 int fillMode) { | 233 int fillMode) { |
| 232 SaveState(); | 234 SaveState(); |
| 233 CGAffineTransform m = CGAffineTransformIdentity; | 235 CGAffineTransform m = CGAffineTransformIdentity; |
| 234 if (matrix) { | 236 if (matrix) { |
| 235 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(), | 237 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(), |
| 236 matrix->GetD(), matrix->GetE(), matrix->GetF()); | 238 matrix->GetD(), matrix->GetE(), matrix->GetF()); |
| 237 } | 239 } |
| 238 m = CGAffineTransformConcat(m, m_foxitDevice2User); | 240 m = CGAffineTransformConcat(m, m_foxitDevice2User); |
| 239 CGContextConcatCTM(m_context, m); | 241 CGContextConcatCTM(m_context, m); |
| 240 setPathToContext(pathData); | 242 setPathToContext(pathData); |
| 241 RestoreState(FALSE); | 243 RestoreState(false); |
| 242 if ((fillMode & 3) == FXFILL_WINDING) { | 244 if ((fillMode & 3) == FXFILL_WINDING) { |
| 243 CGContextClip(m_context); | 245 CGContextClip(m_context); |
| 244 } else { | 246 } else { |
| 245 CGContextEOClip(m_context); | 247 CGContextEOClip(m_context); |
| 246 } | 248 } |
| 247 return TRUE; | 249 return TRUE; |
| 248 } | 250 } |
| 249 FX_FLOAT CFX_QuartzDeviceDriver::getLineWidth( | 251 FX_FLOAT CFX_QuartzDeviceDriver::getLineWidth( |
| 250 const CFX_GraphStateData* graphState, | 252 const CFX_GraphStateData* graphState, |
| 251 CGAffineTransform ctm) { | 253 CGAffineTransform ctm) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 270 if (matrix) { | 272 if (matrix) { |
| 271 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(), | 273 m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(), |
| 272 matrix->GetD(), matrix->GetE(), matrix->GetF()); | 274 matrix->GetD(), matrix->GetE(), matrix->GetF()); |
| 273 } | 275 } |
| 274 m = CGAffineTransformConcat(m, m_foxitDevice2User); | 276 m = CGAffineTransformConcat(m, m_foxitDevice2User); |
| 275 CGContextConcatCTM(m_context, m); | 277 CGContextConcatCTM(m_context, m); |
| 276 FX_FLOAT lineWidth = getLineWidth(graphState, m); | 278 FX_FLOAT lineWidth = getLineWidth(graphState, m); |
| 277 setStrokeInfo(graphState, 0xFF000000, lineWidth); | 279 setStrokeInfo(graphState, 0xFF000000, lineWidth); |
| 278 setPathToContext(pathData); | 280 setPathToContext(pathData); |
| 279 CGContextReplacePathWithStrokedPath(m_context); | 281 CGContextReplacePathWithStrokedPath(m_context); |
| 280 RestoreState(FALSE); | 282 RestoreState(false); |
| 281 CGContextClip(m_context); | 283 CGContextClip(m_context); |
| 282 return TRUE; | 284 return TRUE; |
| 283 } | 285 } |
| 284 static CGBlendMode GetCGBlendMode(int blend_type) { | 286 static CGBlendMode GetCGBlendMode(int blend_type) { |
| 285 CGBlendMode mode = kCGBlendModeNormal; | 287 CGBlendMode mode = kCGBlendModeNormal; |
| 286 switch (blend_type) { | 288 switch (blend_type) { |
| 287 case FXDIB_BLEND_NORMAL: | 289 case FXDIB_BLEND_NORMAL: |
| 288 mode = kCGBlendModeNormal; | 290 mode = kCGBlendModeNormal; |
| 289 break; | 291 break; |
| 290 case FXDIB_BLEND_MULTIPLY: | 292 case FXDIB_BLEND_MULTIPLY: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 CGContextStrokePath(m_context); | 384 CGContextStrokePath(m_context); |
| 383 } else if (pathMode == 1) { | 385 } else if (pathMode == 1) { |
| 384 CGContextFillPath(m_context); | 386 CGContextFillPath(m_context); |
| 385 } else if (pathMode == 2) { | 387 } else if (pathMode == 2) { |
| 386 CGContextEOFillPath(m_context); | 388 CGContextEOFillPath(m_context); |
| 387 } else if (pathMode == 5) { | 389 } else if (pathMode == 5) { |
| 388 CGContextDrawPath(m_context, kCGPathFillStroke); | 390 CGContextDrawPath(m_context, kCGPathFillStroke); |
| 389 } else if (pathMode == 6) { | 391 } else if (pathMode == 6) { |
| 390 CGContextDrawPath(m_context, kCGPathEOFillStroke); | 392 CGContextDrawPath(m_context, kCGPathEOFillStroke); |
| 391 } | 393 } |
| 392 RestoreState(FALSE); | 394 RestoreState(false); |
| 393 return TRUE; | 395 return TRUE; |
| 394 } | 396 } |
| 395 FX_BOOL CFX_QuartzDeviceDriver::FillRect(const FX_RECT* rect, | 397 FX_BOOL CFX_QuartzDeviceDriver::FillRect(const FX_RECT* rect, |
| 396 FX_ARGB fillArgb, | 398 FX_ARGB fillArgb, |
| 397 int alphaFlag, | 399 int alphaFlag, |
| 398 void* iccTransform, | 400 void* iccTransform, |
| 399 int blend_type) { | 401 int blend_type) { |
| 400 CGBlendMode mode = GetCGBlendMode(blend_type); | 402 CGBlendMode mode = GetCGBlendMode(blend_type); |
| 401 if (mode != kCGBlendModeNormal) { | 403 if (mode != kCGBlendModeNormal) { |
| 402 CGContextSetBlendMode(m_context, mode); | 404 CGContextSetBlendMode(m_context, mode); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 rect_usr = CGRectOffset(rect_usr, -src_left, -src_top); | 548 rect_usr = CGRectOffset(rect_usr, -src_left, -src_top); |
| 547 CG_SetImageTransform(dest_left, dest_top, src_width, src_height, &rect_usr); | 549 CG_SetImageTransform(dest_left, dest_top, src_width, src_height, &rect_usr); |
| 548 CFX_DIBitmap* pBitmap1 = NULL; | 550 CFX_DIBitmap* pBitmap1 = NULL; |
| 549 if (pBitmap->IsAlphaMask()) { | 551 if (pBitmap->IsAlphaMask()) { |
| 550 if (pBitmap->GetBuffer()) { | 552 if (pBitmap->GetBuffer()) { |
| 551 pBitmap1 = (CFX_DIBitmap*)pBitmap; | 553 pBitmap1 = (CFX_DIBitmap*)pBitmap; |
| 552 } else { | 554 } else { |
| 553 pBitmap1 = pBitmap->Clone(); | 555 pBitmap1 = pBitmap->Clone(); |
| 554 } | 556 } |
| 555 if (NULL == pBitmap1) { | 557 if (NULL == pBitmap1) { |
| 556 RestoreState(FALSE); | 558 RestoreState(false); |
| 557 return FALSE; | 559 return FALSE; |
| 558 } | 560 } |
| 559 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData( | 561 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData( |
| 560 NULL, pBitmap1->GetBuffer(), | 562 NULL, pBitmap1->GetBuffer(), |
| 561 pBitmap1->GetPitch() * pBitmap1->GetHeight(), NULL); | 563 pBitmap1->GetPitch() * pBitmap1->GetHeight(), NULL); |
| 562 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); | 564 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); |
| 563 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; | 565 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; |
| 564 CGImageRef pImage = CGImageCreate( | 566 CGImageRef pImage = CGImageCreate( |
| 565 pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(), | 567 pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(), |
| 566 pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo, | 568 pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo, |
| 567 pBitmapProvider, NULL, true, kCGRenderingIntentDefault); | 569 pBitmapProvider, NULL, true, kCGRenderingIntentDefault); |
| 568 CGContextClipToMask(m_context, rect_usr, pImage); | 570 CGContextClipToMask(m_context, rect_usr, pImage); |
| 569 CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f, | 571 CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f, |
| 570 FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f, | 572 FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f, |
| 571 FXARGB_A(argb) / 255.f); | 573 FXARGB_A(argb) / 255.f); |
| 572 CGContextFillRect(m_context, rect_usr); | 574 CGContextFillRect(m_context, rect_usr); |
| 573 CGImageRelease(pImage); | 575 CGImageRelease(pImage); |
| 574 CGColorSpaceRelease(pColorSpace); | 576 CGColorSpaceRelease(pColorSpace); |
| 575 CGDataProviderRelease(pBitmapProvider); | 577 CGDataProviderRelease(pBitmapProvider); |
| 576 if (pBitmap1 != pBitmap) { | 578 if (pBitmap1 != pBitmap) { |
| 577 delete pBitmap1; | 579 delete pBitmap1; |
| 578 } | 580 } |
| 579 RestoreState(FALSE); | 581 RestoreState(false); |
| 580 return TRUE; | 582 return TRUE; |
| 581 } | 583 } |
| 582 if (pBitmap->GetBPP() < 32) { | 584 if (pBitmap->GetBPP() < 32) { |
| 583 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32); | 585 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32); |
| 584 } else { | 586 } else { |
| 585 if (pBitmap->GetBuffer()) { | 587 if (pBitmap->GetBuffer()) { |
| 586 pBitmap1 = (CFX_DIBitmap*)pBitmap; | 588 pBitmap1 = (CFX_DIBitmap*)pBitmap; |
| 587 } else { | 589 } else { |
| 588 pBitmap1 = pBitmap->Clone(); | 590 pBitmap1 = pBitmap->Clone(); |
| 589 } | 591 } |
| 590 } | 592 } |
| 591 if (NULL == pBitmap1) { | 593 if (NULL == pBitmap1) { |
| 592 RestoreState(FALSE); | 594 RestoreState(false); |
| 593 return FALSE; | 595 return FALSE; |
| 594 } | 596 } |
| 595 if (pBitmap1->HasAlpha()) { | 597 if (pBitmap1->HasAlpha()) { |
| 596 if (pBitmap1 == pBitmap) { | 598 if (pBitmap1 == pBitmap) { |
| 597 pBitmap1 = pBitmap->Clone(); | 599 pBitmap1 = pBitmap->Clone(); |
| 598 if (!pBitmap1) { | 600 if (!pBitmap1) { |
| 599 RestoreState(FALSE); | 601 RestoreState(false); |
| 600 return FALSE; | 602 return FALSE; |
| 601 } | 603 } |
| 602 } | 604 } |
| 603 for (int row = 0; row < pBitmap1->GetHeight(); row++) { | 605 for (int row = 0; row < pBitmap1->GetHeight(); row++) { |
| 604 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row); | 606 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row); |
| 605 for (int col = 0; col < pBitmap1->GetWidth(); col++) { | 607 for (int col = 0; col < pBitmap1->GetWidth(); col++) { |
| 606 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .5f); | 608 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .5f); |
| 607 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .5f); | 609 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .5f); |
| 608 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .5f); | 610 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .5f); |
| 609 pScanline += 4; | 611 pScanline += 4; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 623 } else if (blendType > FXDIB_BLEND_LUMINOSITY || blendType < 0) { | 625 } else if (blendType > FXDIB_BLEND_LUMINOSITY || blendType < 0) { |
| 624 blend_mode = kCGBlendModeNormal; | 626 blend_mode = kCGBlendModeNormal; |
| 625 } | 627 } |
| 626 CGContextSetBlendMode(m_context, (CGBlendMode)blend_mode); | 628 CGContextSetBlendMode(m_context, (CGBlendMode)blend_mode); |
| 627 CGContextDrawImage(m_context, rect_usr, image); | 629 CGContextDrawImage(m_context, rect_usr, image); |
| 628 CGImageRelease(image); | 630 CGImageRelease(image); |
| 629 CGContextRelease(ctx); | 631 CGContextRelease(ctx); |
| 630 if (pBitmap1 != pBitmap) { | 632 if (pBitmap1 != pBitmap) { |
| 631 delete pBitmap1; | 633 delete pBitmap1; |
| 632 } | 634 } |
| 633 RestoreState(FALSE); | 635 RestoreState(false); |
| 634 return TRUE; | 636 return TRUE; |
| 635 } | 637 } |
| 636 FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, | 638 FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, |
| 637 FX_ARGB argb, | 639 FX_ARGB argb, |
| 638 int dest_left, | 640 int dest_left, |
| 639 int dest_top, | 641 int dest_top, |
| 640 int dest_width, | 642 int dest_width, |
| 641 int dest_height, | 643 int dest_height, |
| 642 const FX_RECT* clipRect, | 644 const FX_RECT* clipRect, |
| 643 uint32_t flags, | 645 uint32_t flags, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 664 } | 666 } |
| 665 CG_SetImageTransform(dest_left, dest_top, dest_width, dest_height); | 667 CG_SetImageTransform(dest_left, dest_top, dest_width, dest_height); |
| 666 CFX_DIBitmap* pBitmap1 = NULL; | 668 CFX_DIBitmap* pBitmap1 = NULL; |
| 667 if (pBitmap->IsAlphaMask()) { | 669 if (pBitmap->IsAlphaMask()) { |
| 668 if (pBitmap->GetBuffer()) { | 670 if (pBitmap->GetBuffer()) { |
| 669 pBitmap1 = (CFX_DIBitmap*)pBitmap; | 671 pBitmap1 = (CFX_DIBitmap*)pBitmap; |
| 670 } else { | 672 } else { |
| 671 pBitmap1 = pBitmap->Clone(); | 673 pBitmap1 = pBitmap->Clone(); |
| 672 } | 674 } |
| 673 if (NULL == pBitmap1) { | 675 if (NULL == pBitmap1) { |
| 674 RestoreState(FALSE); | 676 RestoreState(false); |
| 675 return FALSE; | 677 return FALSE; |
| 676 } | 678 } |
| 677 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData( | 679 CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData( |
| 678 NULL, pBitmap1->GetBuffer(), | 680 NULL, pBitmap1->GetBuffer(), |
| 679 pBitmap1->GetPitch() * pBitmap1->GetHeight(), NULL); | 681 pBitmap1->GetPitch() * pBitmap1->GetHeight(), NULL); |
| 680 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); | 682 CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); |
| 681 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; | 683 CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; |
| 682 CGImageRef pImage = CGImageCreate( | 684 CGImageRef pImage = CGImageCreate( |
| 683 pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(), | 685 pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(), |
| 684 pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo, | 686 pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo, |
| 685 pBitmapProvider, NULL, true, kCGRenderingIntentDefault); | 687 pBitmapProvider, NULL, true, kCGRenderingIntentDefault); |
| 686 CGContextClipToMask(m_context, rect, pImage); | 688 CGContextClipToMask(m_context, rect, pImage); |
| 687 CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f, | 689 CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f, |
| 688 FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f, | 690 FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f, |
| 689 FXARGB_A(argb) / 255.f); | 691 FXARGB_A(argb) / 255.f); |
| 690 CGContextFillRect(m_context, rect); | 692 CGContextFillRect(m_context, rect); |
| 691 CGImageRelease(pImage); | 693 CGImageRelease(pImage); |
| 692 CGColorSpaceRelease(pColorSpace); | 694 CGColorSpaceRelease(pColorSpace); |
| 693 CGDataProviderRelease(pBitmapProvider); | 695 CGDataProviderRelease(pBitmapProvider); |
| 694 if (pBitmap1 != pBitmap) { | 696 if (pBitmap1 != pBitmap) { |
| 695 delete pBitmap1; | 697 delete pBitmap1; |
| 696 } | 698 } |
| 697 RestoreState(FALSE); | 699 RestoreState(false); |
| 698 return TRUE; | 700 return TRUE; |
| 699 } | 701 } |
| 700 if (pBitmap->GetBPP() < 32) { | 702 if (pBitmap->GetBPP() < 32) { |
| 701 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32); | 703 pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32); |
| 702 } else { | 704 } else { |
| 703 if (pBitmap->GetBuffer()) { | 705 if (pBitmap->GetBuffer()) { |
| 704 pBitmap1 = (CFX_DIBitmap*)pBitmap; | 706 pBitmap1 = (CFX_DIBitmap*)pBitmap; |
| 705 } else { | 707 } else { |
| 706 pBitmap1 = pBitmap->Clone(); | 708 pBitmap1 = pBitmap->Clone(); |
| 707 } | 709 } |
| 708 } | 710 } |
| 709 if (NULL == pBitmap1) { | 711 if (NULL == pBitmap1) { |
| 710 RestoreState(FALSE); | 712 RestoreState(false); |
| 711 return FALSE; | 713 return FALSE; |
| 712 } | 714 } |
| 713 if (pBitmap1->HasAlpha()) { | 715 if (pBitmap1->HasAlpha()) { |
| 714 if (pBitmap1 == pBitmap) { | 716 if (pBitmap1 == pBitmap) { |
| 715 pBitmap1 = pBitmap->Clone(); | 717 pBitmap1 = pBitmap->Clone(); |
| 716 if (!pBitmap1) { | 718 if (!pBitmap1) { |
| 717 RestoreState(FALSE); | 719 RestoreState(false); |
| 718 return FALSE; | 720 return FALSE; |
| 719 } | 721 } |
| 720 } | 722 } |
| 721 for (int row = 0; row < pBitmap1->GetHeight(); row++) { | 723 for (int row = 0; row < pBitmap1->GetHeight(); row++) { |
| 722 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row); | 724 uint8_t* pScanline = (uint8_t*)pBitmap1->GetScanline(row); |
| 723 for (int col = 0; col < pBitmap1->GetWidth(); col++) { | 725 for (int col = 0; col < pBitmap1->GetWidth(); col++) { |
| 724 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .5f); | 726 pScanline[0] = (uint8_t)(pScanline[0] * pScanline[3] / 255.f + .5f); |
| 725 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .5f); | 727 pScanline[1] = (uint8_t)(pScanline[1] * pScanline[3] / 255.f + .5f); |
| 726 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .5f); | 728 pScanline[2] = (uint8_t)(pScanline[2] * pScanline[3] / 255.f + .5f); |
| 727 pScanline += 4; | 729 pScanline += 4; |
| 728 } | 730 } |
| 729 } | 731 } |
| 730 } | 732 } |
| 731 CGContextRef ctx = createContextWithBitmap(pBitmap1); | 733 CGContextRef ctx = createContextWithBitmap(pBitmap1); |
| 732 CGImageRef image = CGBitmapContextCreateImage(ctx); | 734 CGImageRef image = CGBitmapContextCreateImage(ctx); |
| 733 CGContextDrawImage(m_context, rect, image); | 735 CGContextDrawImage(m_context, rect, image); |
| 734 CGImageRelease(image); | 736 CGImageRelease(image); |
| 735 CGContextRelease(ctx); | 737 CGContextRelease(ctx); |
| 736 if (pBitmap1 != pBitmap) { | 738 if (pBitmap1 != pBitmap) { |
| 737 delete pBitmap1; | 739 delete pBitmap1; |
| 738 } | 740 } |
| 739 RestoreState(FALSE); | 741 RestoreState(false); |
| 740 return TRUE; | 742 return TRUE; |
| 741 } | 743 } |
| 742 FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars, | 744 FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars, |
| 743 const FXTEXT_CHARPOS* pCharPos, | 745 const FXTEXT_CHARPOS* pCharPos, |
| 744 CFX_Font* pFont, | 746 CFX_Font* pFont, |
| 745 CFX_FontCache* pCache, | 747 CFX_FontCache* pCache, |
| 746 const CFX_Matrix* pGlyphMatrix, | 748 const CFX_Matrix* pGlyphMatrix, |
| 747 const CFX_Matrix* pObject2Device, | 749 const CFX_Matrix* pObject2Device, |
| 748 FX_FLOAT font_size, | 750 FX_FLOAT font_size, |
| 749 uint32_t argb, | 751 uint32_t argb, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 pGlyphMatrix->a, pGlyphMatrix->b, pGlyphMatrix->c, pGlyphMatrix->d, | 798 pGlyphMatrix->a, pGlyphMatrix->b, pGlyphMatrix->c, pGlyphMatrix->d, |
| 797 pGlyphMatrix->e, pGlyphMatrix->f); | 799 pGlyphMatrix->e, pGlyphMatrix->f); |
| 798 if (m_foxitDevice2User.d < 0) { | 800 if (m_foxitDevice2User.d < 0) { |
| 799 glyph_matrix = CGAffineTransformInvert(glyph_matrix); | 801 glyph_matrix = CGAffineTransformInvert(glyph_matrix); |
| 800 } | 802 } |
| 801 CGContextConcatCTM(m_context, glyph_matrix); | 803 CGContextConcatCTM(m_context, glyph_matrix); |
| 802 CGContextTranslateCTM(m_context, -origin.x, -origin.y); | 804 CGContextTranslateCTM(m_context, -origin.x, -origin.y); |
| 803 } | 805 } |
| 804 CGContextShowGlyphsAtPositions(m_context, (CGGlyph*)glyph_indices, | 806 CGContextShowGlyphsAtPositions(m_context, (CGGlyph*)glyph_indices, |
| 805 glyph_positions, nChars); | 807 glyph_positions, nChars); |
| 806 RestoreState(FALSE); | 808 RestoreState(false); |
| 807 return TRUE; | 809 return TRUE; |
| 808 } | 810 } |
| 809 FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, | 811 FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, |
| 810 const FXTEXT_CHARPOS* pCharPos, | 812 const FXTEXT_CHARPOS* pCharPos, |
| 811 CFX_Font* pFont, | 813 CFX_Font* pFont, |
| 812 CFX_FontCache* pCache, | 814 CFX_FontCache* pCache, |
| 813 const CFX_Matrix* pObject2Device, | 815 const CFX_Matrix* pObject2Device, |
| 814 FX_FLOAT font_size, | 816 FX_FLOAT font_size, |
| 815 uint32_t color, | 817 uint32_t color, |
| 816 int alpha_flag, | 818 int alpha_flag, |
| 817 void* pIccTransform) { | 819 void* pIccTransform) { |
| 818 if (NULL == pFont || NULL == m_context) | 820 if (NULL == pFont || NULL == m_context) |
| 819 return FALSE; | 821 return FALSE; |
| 820 FX_BOOL bBold = pFont->IsBold(); | 822 FX_BOOL bBold = pFont->IsBold(); |
| 821 if (!bBold && pFont->GetSubstFont() && | 823 if (!bBold && pFont->GetSubstFont() && |
| 822 pFont->GetSubstFont()->m_Weight >= 500 && | 824 pFont->GetSubstFont()->m_Weight >= 500 && |
| 823 pFont->GetSubstFont()->m_Weight <= 600) { | 825 pFont->GetSubstFont()->m_Weight <= 600) { |
| 824 return FALSE; | 826 return FALSE; |
| 825 } | 827 } |
| 826 SaveState(); | 828 SaveState(); |
| 827 CGContextSetTextDrawingMode(m_context, kCGTextFillClip); | 829 CGContextSetTextDrawingMode(m_context, kCGTextFillClip); |
| 828 FX_BOOL ret = FALSE; | 830 FX_BOOL ret = FALSE; |
| 829 int32_t i = 0; | 831 int32_t i = 0; |
| 830 while (i < nChars) { | 832 while (i < nChars) { |
| 831 if (pCharPos[i].m_bGlyphAdjust || font_size < 0) { | 833 if (pCharPos[i].m_bGlyphAdjust || font_size < 0) { |
| 832 if (i > 0) { | 834 if (i > 0) { |
| 833 ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device, | 835 ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device, |
| 834 font_size, color, alpha_flag, pIccTransform); | 836 font_size, color, alpha_flag, pIccTransform); |
| 835 if (!ret) { | 837 if (!ret) { |
| 836 RestoreState(FALSE); | 838 RestoreState(false); |
| 837 return ret; | 839 return ret; |
| 838 } | 840 } |
| 839 } | 841 } |
| 840 const FXTEXT_CHARPOS* char_pos = pCharPos + i; | 842 const FXTEXT_CHARPOS* char_pos = pCharPos + i; |
| 841 CFX_Matrix glphy_matrix; | 843 CFX_Matrix glphy_matrix; |
| 842 if (font_size < 0) { | 844 if (font_size < 0) { |
| 843 glphy_matrix.Concat(-1, 0, 0, -1, 0, 0); | 845 glphy_matrix.Concat(-1, 0, 0, -1, 0, 0); |
| 844 } | 846 } |
| 845 if (char_pos->m_bGlyphAdjust) { | 847 if (char_pos->m_bGlyphAdjust) { |
| 846 glphy_matrix.Concat( | 848 glphy_matrix.Concat( |
| 847 char_pos->m_AdjustMatrix[0], char_pos->m_AdjustMatrix[1], | 849 char_pos->m_AdjustMatrix[0], char_pos->m_AdjustMatrix[1], |
| 848 char_pos->m_AdjustMatrix[2], char_pos->m_AdjustMatrix[3], 0, 0); | 850 char_pos->m_AdjustMatrix[2], char_pos->m_AdjustMatrix[3], 0, 0); |
| 849 } | 851 } |
| 850 ret = CG_DrawGlypRun(1, char_pos, pFont, pCache, &glphy_matrix, | 852 ret = CG_DrawGlypRun(1, char_pos, pFont, pCache, &glphy_matrix, |
| 851 pObject2Device, font_size, color, alpha_flag, | 853 pObject2Device, font_size, color, alpha_flag, |
| 852 pIccTransform); | 854 pIccTransform); |
| 853 if (!ret) { | 855 if (!ret) { |
| 854 RestoreState(FALSE); | 856 RestoreState(false); |
| 855 return ret; | 857 return ret; |
| 856 } | 858 } |
| 857 i++; | 859 i++; |
| 858 pCharPos += i; | 860 pCharPos += i; |
| 859 nChars -= i; | 861 nChars -= i; |
| 860 i = 0; | 862 i = 0; |
| 861 } else { | 863 } else { |
| 862 i++; | 864 i++; |
| 863 } | 865 } |
| 864 } | 866 } |
| 865 if (i > 0) { | 867 if (i > 0) { |
| 866 ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device, | 868 ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device, |
| 867 font_size, color, alpha_flag, pIccTransform); | 869 font_size, color, alpha_flag, pIccTransform); |
| 868 } | 870 } |
| 869 RestoreState(FALSE); | 871 RestoreState(false); |
| 870 return ret; | 872 return ret; |
| 871 } | 873 } |
| 872 void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, | 874 void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, |
| 873 FX_ARGB argb, | 875 FX_ARGB argb, |
| 874 FX_FLOAT lineWidth) { | 876 FX_FLOAT lineWidth) { |
| 875 if (NULL == graphState) { | 877 if (NULL == graphState) { |
| 876 return; | 878 return; |
| 877 } | 879 } |
| 878 CGContextSetLineWidth(m_context, lineWidth); | 880 CGContextSetLineWidth(m_context, lineWidth); |
| 879 CGLineCap cap; | 881 CGLineCap cap; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 } | 1045 } |
| 1044 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 1046 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
| 1045 if (!pBitmap->Create(width, height, format)) { | 1047 if (!pBitmap->Create(width, height, format)) { |
| 1046 delete pBitmap; | 1048 delete pBitmap; |
| 1047 return FALSE; | 1049 return FALSE; |
| 1048 } | 1050 } |
| 1049 m_bOwnedBitmap = TRUE; | 1051 m_bOwnedBitmap = TRUE; |
| 1050 return Attach(pBitmap); | 1052 return Attach(pBitmap); |
| 1051 } | 1053 } |
| 1052 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1054 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| OLD | NEW |