Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: core/fpdfapi/fpdf_render/fpdf_render_image.cpp

Issue 2323663002: Fix compare between signed and unsigned values in CPDF_ImageRenderer::StartDIBSource. (Closed)
Patch Set: split calculation Created 4 years, 3 months 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 | « no previous file | no next file » | 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/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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698