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 <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 } | 639 } |
640 } | 640 } |
641 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); | 641 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); |
642 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); | 642 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); |
643 bitmap_device1.GetBitmap()->MultiplyAlpha(255); | 643 bitmap_device1.GetBitmap()->MultiplyAlpha(255); |
644 } | 644 } |
645 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( | 645 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
646 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); | 646 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); |
647 return FALSE; | 647 return FALSE; |
648 } | 648 } |
| 649 |
649 FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { | 650 FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { |
650 if (m_pRenderStatus->m_bPrint && | 651 if (m_pRenderStatus->m_bPrint && |
651 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 652 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
652 m_Result = FALSE; | 653 m_Result = FALSE; |
653 return FALSE; | 654 return FALSE; |
654 } | 655 } |
655 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); | 656 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); |
656 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 657 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
657 if (rect.IsEmpty()) { | 658 if (rect.IsEmpty()) { |
658 return FALSE; | 659 return FALSE; |
659 } | 660 } |
660 CFX_Matrix new_matrix = m_ImageMatrix; | 661 CFX_Matrix new_matrix = m_ImageMatrix; |
661 new_matrix.TranslateI(-rect.left, -rect.top); | 662 new_matrix.TranslateI(-rect.left, -rect.top); |
662 int width = rect.Width(); | 663 int width = rect.Width(); |
663 int height = rect.Height(); | 664 int height = rect.Height(); |
664 CFX_FxgeDevice bitmap_device1; | 665 CFX_FxgeDevice bitmap_device1; |
665 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) | 666 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) |
666 return TRUE; | 667 return TRUE; |
667 | 668 |
| 669 #if defined _SKIA_SUPPORT_ |
| 670 bitmap_device1.Clear(0xffffff); |
| 671 #else |
668 bitmap_device1.GetBitmap()->Clear(0xffffff); | 672 bitmap_device1.GetBitmap()->Clear(0xffffff); |
| 673 #endif |
669 { | 674 { |
670 CPDF_RenderStatus bitmap_render; | 675 CPDF_RenderStatus bitmap_render; |
671 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, | 676 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, |
672 nullptr, nullptr, nullptr, nullptr, nullptr, 0, | 677 nullptr, nullptr, nullptr, nullptr, nullptr, 0, |
673 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); | 678 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); |
674 CPDF_ImageRenderer image_render; | 679 CPDF_ImageRenderer image_render; |
675 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, | 680 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, |
676 m_Flags, TRUE)) { | 681 m_Flags, TRUE)) { |
677 image_render.Continue(nullptr); | 682 image_render.Continue(nullptr); |
678 } | 683 } |
679 } | 684 } |
680 { | 685 { |
681 CFX_FxgeDevice bitmap_device2; | 686 CFX_FxgeDevice bitmap_device2; |
682 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) | 687 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) |
683 return TRUE; | 688 return TRUE; |
684 | 689 |
| 690 #if defined _SKIA_SUPPORT_ |
| 691 bitmap_device2.Clear(0); |
| 692 #else |
685 bitmap_device2.GetBitmap()->Clear(0); | 693 bitmap_device2.GetBitmap()->Clear(0); |
| 694 #endif |
686 CPDF_RenderStatus bitmap_render; | 695 CPDF_RenderStatus bitmap_render; |
687 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, | 696 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, |
688 nullptr, nullptr, nullptr, nullptr, nullptr, 0, | 697 nullptr, nullptr, nullptr, nullptr, nullptr, 0, |
689 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); | 698 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); |
690 CPDF_ImageRenderer image_render; | 699 CPDF_ImageRenderer image_render; |
691 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, | 700 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, |
692 &new_matrix, m_Flags, TRUE)) { | 701 &new_matrix, m_Flags, TRUE)) { |
693 image_render.Continue(nullptr); | 702 image_render.Continue(nullptr); |
694 } | 703 } |
695 if (m_Loader.m_MatteColor != 0xffffffff) { | 704 if (m_Loader.m_MatteColor != 0xffffffff) { |
(...skipping 28 matching lines...) Expand all Loading... |
724 orig = 255; | 733 orig = 255; |
725 } | 734 } |
726 *dest_scan++ = orig; | 735 *dest_scan++ = orig; |
727 dest_scan++; | 736 dest_scan++; |
728 } else { | 737 } else { |
729 dest_scan += 4; | 738 dest_scan += 4; |
730 } | 739 } |
731 } | 740 } |
732 } | 741 } |
733 } | 742 } |
| 743 #ifdef _SKIA_SUPPORT_ |
| 744 m_pRenderStatus->m_pDevice->SetBitsWithMask( |
| 745 bitmap_device1.GetBitmap(), bitmap_device2.GetBitmap(), rect.left, |
| 746 rect.top, m_BitmapAlpha, m_BlendType); |
| 747 } |
| 748 #else |
734 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); | 749 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); |
735 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); | 750 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); |
736 #ifdef _SKIA_SUPPORT_ | |
737 CFX_SkiaDeviceDriver::PreMultiply(bitmap_device1.GetBitmap()); | |
738 #endif | |
739 if (m_BitmapAlpha < 255) { | 751 if (m_BitmapAlpha < 255) { |
740 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); | 752 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); |
741 } | 753 } |
742 } | 754 } |
743 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( | 755 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
744 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); | 756 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); |
| 757 #endif // _SKIA_SUPPORT_ |
745 return FALSE; | 758 return FALSE; |
746 } | 759 } |
747 | 760 |
748 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { | 761 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { |
749 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { | 762 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { |
750 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * | 763 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * |
751 m_pDIBSource->GetHeight(); | 764 m_pDIBSource->GetHeight(); |
752 if (image_size > FPDF_HUGE_IMAGE_SIZE && | 765 if (image_size > FPDF_HUGE_IMAGE_SIZE && |
753 !(m_Flags & RENDER_FORCE_HALFTONE)) { | 766 !(m_Flags & RENDER_FORCE_HALFTONE)) { |
754 m_Flags |= RENDER_FORCE_DOWNSAMPLE; | 767 m_Flags |= RENDER_FORCE_DOWNSAMPLE; |
755 } | 768 } |
756 } | 769 } |
757 #ifdef _SKIA_SUPPORT_ | 770 #ifdef _SKIA_SUPPORT_ |
758 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone(); | 771 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone(); |
759 CFX_SkiaDeviceDriver::PreMultiply(premultiplied); | 772 if (m_pDIBSource->HasAlpha()) |
| 773 CFX_SkiaDeviceDriver::PreMultiply(premultiplied); |
760 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( | 774 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( |
761 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, | 775 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, |
762 m_DeviceHandle, m_BlendType)) { | 776 m_DeviceHandle, m_BlendType)) { |
763 if (m_DeviceHandle) { | 777 if (m_DeviceHandle) { |
764 m_Status = 3; | 778 m_Status = 3; |
765 return TRUE; | 779 return TRUE; |
766 } | 780 } |
767 return FALSE; | 781 return FALSE; |
768 } | 782 } |
769 #else | 783 #else |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 } else if (pFunc) { | 1068 } else if (pFunc) { |
1055 int size = dest_pitch * height; | 1069 int size = dest_pitch * height; |
1056 for (int i = 0; i < size; i++) { | 1070 for (int i = 0; i < size; i++) { |
1057 dest_buf[i] = transfers[src_buf[i]]; | 1071 dest_buf[i] = transfers[src_buf[i]]; |
1058 } | 1072 } |
1059 } else { | 1073 } else { |
1060 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1074 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
1061 } | 1075 } |
1062 return pMask.release(); | 1076 return pMask.release(); |
1063 } | 1077 } |
OLD | NEW |