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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 } | 755 } |
756 } | 756 } |
757 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( | 757 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
758 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); | 758 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); |
759 #endif // _SKIA_SUPPORT_ | 759 #endif // _SKIA_SUPPORT_ |
760 return FALSE; | 760 return FALSE; |
761 } | 761 } |
762 | 762 |
763 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { | 763 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { |
764 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { | 764 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { |
765 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * | 765 FX_SAFE_SIZE_T image_size = m_pDIBSource->GetBPP(); |
766 m_pDIBSource->GetHeight(); | 766 image_size /= 8; |
767 if (image_size > FPDF_HUGE_IMAGE_SIZE && | 767 image_size *= m_pDIBSource->GetWidth(); |
| 768 image_size *= m_pDIBSource->GetHeight(); |
| 769 if (!image_size.IsValid()) { |
| 770 return FALSE; |
| 771 } |
| 772 |
| 773 if (image_size.ValueOrDie() > FPDF_HUGE_IMAGE_SIZE && |
768 !(m_Flags & RENDER_FORCE_HALFTONE)) { | 774 !(m_Flags & RENDER_FORCE_HALFTONE)) { |
769 m_Flags |= RENDER_FORCE_DOWNSAMPLE; | 775 m_Flags |= RENDER_FORCE_DOWNSAMPLE; |
770 } | 776 } |
771 } | 777 } |
772 #ifdef _SKIA_SUPPORT_ | 778 #ifdef _SKIA_SUPPORT_ |
773 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone(); | 779 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone(); |
774 if (m_pDIBSource->HasAlpha()) | 780 if (m_pDIBSource->HasAlpha()) |
775 CFX_SkiaDeviceDriver::PreMultiply(premultiplied); | 781 CFX_SkiaDeviceDriver::PreMultiply(premultiplied); |
776 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( | 782 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( |
777 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, | 783 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 } else if (pFunc) { | 1076 } else if (pFunc) { |
1071 int size = dest_pitch * height; | 1077 int size = dest_pitch * height; |
1072 for (int i = 0; i < size; i++) { | 1078 for (int i = 0; i < size; i++) { |
1073 dest_buf[i] = transfers[src_buf[i]]; | 1079 dest_buf[i] = transfers[src_buf[i]]; |
1074 } | 1080 } |
1075 } else { | 1081 } else { |
1076 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1082 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
1077 } | 1083 } |
1078 return pMask.release(); | 1084 return pMask.release(); |
1079 } | 1085 } |
OLD | NEW |