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/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); | 516 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); |
517 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 517 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
518 if (rect.IsEmpty()) { | 518 if (rect.IsEmpty()) { |
519 return FALSE; | 519 return FALSE; |
520 } | 520 } |
521 CFX_Matrix new_matrix = m_ImageMatrix; | 521 CFX_Matrix new_matrix = m_ImageMatrix; |
522 new_matrix.TranslateI(-rect.left, -rect.top); | 522 new_matrix.TranslateI(-rect.left, -rect.top); |
523 int width = rect.Width(); | 523 int width = rect.Width(); |
524 int height = rect.Height(); | 524 int height = rect.Height(); |
525 CFX_FxgeDevice bitmap_device1; | 525 CFX_FxgeDevice bitmap_device1; |
526 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32)) { | 526 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) |
527 return TRUE; | 527 return TRUE; |
528 } | 528 |
529 bitmap_device1.GetBitmap()->Clear(0xffffff); | 529 bitmap_device1.GetBitmap()->Clear(0xffffff); |
530 { | 530 { |
531 CPDF_RenderStatus bitmap_render; | 531 CPDF_RenderStatus bitmap_render; |
532 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, | 532 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, |
533 NULL, NULL, NULL, &m_pRenderStatus->m_Options, 0, | 533 NULL, NULL, NULL, &m_pRenderStatus->m_Options, 0, |
534 m_pRenderStatus->m_bDropObjects, NULL, TRUE); | 534 m_pRenderStatus->m_bDropObjects, NULL, TRUE); |
535 CFX_Matrix patternDevice = *pObj2Device; | 535 CFX_Matrix patternDevice = *pObj2Device; |
536 patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); | 536 patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); |
537 if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { | 537 if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { |
538 bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject, | 538 bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject, |
539 &patternDevice, FALSE); | 539 &patternDevice, FALSE); |
540 } else if (CPDF_ShadingPattern* pShadingPattern = | 540 } else if (CPDF_ShadingPattern* pShadingPattern = |
541 m_pPattern->AsShadingPattern()) { | 541 m_pPattern->AsShadingPattern()) { |
542 bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject, | 542 bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject, |
543 &patternDevice, FALSE); | 543 &patternDevice, FALSE); |
544 } | 544 } |
545 } | 545 } |
546 { | 546 { |
547 CFX_FxgeDevice bitmap_device2; | 547 CFX_FxgeDevice bitmap_device2; |
548 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb)) { | 548 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb, |
| 549 nullptr)) { |
549 return TRUE; | 550 return TRUE; |
550 } | 551 } |
551 bitmap_device2.GetBitmap()->Clear(0); | 552 bitmap_device2.GetBitmap()->Clear(0); |
552 CPDF_RenderStatus bitmap_render; | 553 CPDF_RenderStatus bitmap_render; |
553 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, | 554 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, |
554 NULL, NULL, NULL, NULL, 0, | 555 NULL, NULL, NULL, NULL, 0, |
555 m_pRenderStatus->m_bDropObjects, NULL, TRUE); | 556 m_pRenderStatus->m_bDropObjects, NULL, TRUE); |
556 CPDF_ImageRenderer image_render; | 557 CPDF_ImageRenderer image_render; |
557 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, | 558 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, |
558 &new_matrix, m_Flags, TRUE)) { | 559 &new_matrix, m_Flags, TRUE)) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); | 615 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); |
615 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 616 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
616 if (rect.IsEmpty()) { | 617 if (rect.IsEmpty()) { |
617 return FALSE; | 618 return FALSE; |
618 } | 619 } |
619 CFX_Matrix new_matrix = m_ImageMatrix; | 620 CFX_Matrix new_matrix = m_ImageMatrix; |
620 new_matrix.TranslateI(-rect.left, -rect.top); | 621 new_matrix.TranslateI(-rect.left, -rect.top); |
621 int width = rect.Width(); | 622 int width = rect.Width(); |
622 int height = rect.Height(); | 623 int height = rect.Height(); |
623 CFX_FxgeDevice bitmap_device1; | 624 CFX_FxgeDevice bitmap_device1; |
624 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32)) { | 625 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) |
625 return TRUE; | 626 return TRUE; |
626 } | 627 |
627 bitmap_device1.GetBitmap()->Clear(0xffffff); | 628 bitmap_device1.GetBitmap()->Clear(0xffffff); |
628 { | 629 { |
629 CPDF_RenderStatus bitmap_render; | 630 CPDF_RenderStatus bitmap_render; |
630 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, | 631 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, |
631 NULL, NULL, NULL, NULL, 0, | 632 NULL, NULL, NULL, NULL, 0, |
632 m_pRenderStatus->m_bDropObjects, NULL, TRUE); | 633 m_pRenderStatus->m_bDropObjects, NULL, TRUE); |
633 CPDF_ImageRenderer image_render; | 634 CPDF_ImageRenderer image_render; |
634 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, | 635 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, |
635 m_Flags, TRUE)) { | 636 m_Flags, TRUE)) { |
636 image_render.Continue(NULL); | 637 image_render.Continue(NULL); |
637 } | 638 } |
638 } | 639 } |
639 { | 640 { |
640 CFX_FxgeDevice bitmap_device2; | 641 CFX_FxgeDevice bitmap_device2; |
641 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb)) { | 642 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) |
642 return TRUE; | 643 return TRUE; |
643 } | 644 |
644 bitmap_device2.GetBitmap()->Clear(0); | 645 bitmap_device2.GetBitmap()->Clear(0); |
645 CPDF_RenderStatus bitmap_render; | 646 CPDF_RenderStatus bitmap_render; |
646 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, | 647 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, |
647 NULL, NULL, NULL, NULL, 0, | 648 NULL, NULL, NULL, NULL, 0, |
648 m_pRenderStatus->m_bDropObjects, NULL, TRUE); | 649 m_pRenderStatus->m_bDropObjects, NULL, TRUE); |
649 CPDF_ImageRenderer image_render; | 650 CPDF_ImageRenderer image_render; |
650 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, | 651 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, |
651 &new_matrix, m_Flags, TRUE)) { | 652 &new_matrix, m_Flags, TRUE)) { |
652 image_render.Continue(NULL); | 653 image_render.Continue(NULL); |
653 } | 654 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 matrix.TranslateI(-pClipRect->left, -pClipRect->top); | 894 matrix.TranslateI(-pClipRect->left, -pClipRect->top); |
894 | 895 |
895 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), | 896 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), |
896 pGroup); | 897 pGroup); |
897 form.ParseContent(nullptr, nullptr, nullptr); | 898 form.ParseContent(nullptr, nullptr, nullptr); |
898 | 899 |
899 CFX_FxgeDevice bitmap_device; | 900 CFX_FxgeDevice bitmap_device; |
900 FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha"; | 901 FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha"; |
901 int width = pClipRect->right - pClipRect->left; | 902 int width = pClipRect->right - pClipRect->left; |
902 int height = pClipRect->bottom - pClipRect->top; | 903 int height = pClipRect->bottom - pClipRect->top; |
| 904 FXDIB_Format format; |
903 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 905 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
904 if (!bitmap_device.Create(width, height, | 906 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; |
905 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { | |
906 return NULL; | |
907 } | |
908 #else | 907 #else |
909 if (!bitmap_device.Create(width, height, | 908 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; |
910 bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { | |
911 return NULL; | |
912 } | |
913 #endif | 909 #endif |
| 910 if (!bitmap_device.Create(width, height, format, nullptr)) |
| 911 return nullptr; |
| 912 |
914 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); | 913 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); |
915 CPDF_Object* pCSObj = NULL; | 914 CPDF_Object* pCSObj = NULL; |
916 CPDF_ColorSpace* pCS = NULL; | 915 CPDF_ColorSpace* pCS = NULL; |
917 if (bLuminosity) { | 916 if (bLuminosity) { |
918 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); | 917 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); |
919 FX_ARGB back_color = 0xff000000; | 918 FX_ARGB back_color = 0xff000000; |
920 if (pBC) { | 919 if (pBC) { |
921 CPDF_Dictionary* pDict = pGroup->GetDict(); | 920 CPDF_Dictionary* pDict = pGroup->GetDict(); |
922 if (pDict && pDict->GetDictBy("Group")) | 921 if (pDict && pDict->GetDictBy("Group")) |
923 pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS"); | 922 pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS"); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 } else if (pFunc) { | 997 } else if (pFunc) { |
999 int size = dest_pitch * height; | 998 int size = dest_pitch * height; |
1000 for (int i = 0; i < size; i++) { | 999 for (int i = 0; i < size; i++) { |
1001 dest_buf[i] = transfers[src_buf[i]]; | 1000 dest_buf[i] = transfers[src_buf[i]]; |
1002 } | 1001 } |
1003 } else { | 1002 } else { |
1004 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1003 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
1005 } | 1004 } |
1006 return pMask.release(); | 1005 return pMask.release(); |
1007 } | 1006 } |
OLD | NEW |