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

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp

Issue 1171733003: Remove typdefs for pointer types in fx_system.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual fixes. Created 5 years, 6 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
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 "../../../../third_party/base/nonstd_unique_ptr.h" 7 #include "../../../../third_party/base/nonstd_unique_ptr.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fpdfapi/fpdf_pageobj.h" 9 #include "../../../include/fpdfapi/fpdf_pageobj.h"
10 #include "../../../include/fpdfapi/fpdf_render.h" 10 #include "../../../include/fpdfapi/fpdf_render.h"
11 #include "../../../include/fxcodec/fx_codec.h" 11 #include "../../../include/fxcodec/fx_codec.h"
12 #include "../../../include/fxcrt/fx_safe_types.h" 12 #include "../../../include/fxcrt/fx_safe_types.h"
13 #include "../../../include/fxge/fx_ge.h" 13 #include "../../../include/fxge/fx_ge.h"
14 #include "../fpdf_page/pageint.h" 14 #include "../fpdf_page/pageint.h"
15 #include "render_int.h" 15 #include "render_int.h"
16 16
17 namespace { 17 namespace {
18 18
19 unsigned int _GetBits8(FX_LPCBYTE pData, int bitpos, int nbits) 19 unsigned int _GetBits8(const uint8_t* pData, int bitpos, int nbits)
20 { 20 {
21 unsigned int byte = pData[bitpos / 8]; 21 unsigned int byte = pData[bitpos / 8];
22 if (nbits == 8) { 22 if (nbits == 8) {
23 return byte; 23 return byte;
24 } else if (nbits == 4) { 24 } else if (nbits == 4) {
25 return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4); 25 return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4);
26 } else if (nbits == 2) { 26 } else if (nbits == 2) {
27 return (byte >> (6 - bitpos % 8)) & 0x03; 27 return (byte >> (6 - bitpos % 8)) & 0x03;
28 } else if (nbits == 1) { 28 } else if (nbits == 1) {
29 return (byte >> (7 - bitpos % 8)) & 0x01; 29 return (byte >> (7 - bitpos % 8)) & 0x01;
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 int max_num = pArray->GetInteger(i * 2 + 1); 577 int max_num = pArray->GetInteger(i * 2 + 1);
578 pCompData[i].m_ColorKeyMin = FX_MAX(min_num, 0); 578 pCompData[i].m_ColorKeyMin = FX_MAX(min_num, 0);
579 pCompData[i].m_ColorKeyMax = FX_MIN(max_num, max_data); 579 pCompData[i].m_ColorKeyMax = FX_MIN(max_num, max_data);
580 } 580 }
581 } 581 }
582 bColorKey = TRUE; 582 bColorKey = TRUE;
583 } 583 }
584 } 584 }
585 return pCompData; 585 return pCompData;
586 } 586 }
587 ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(FX_LPCBYTE src_buf, FX_DWORD sr c_size, int width, int height, 587 ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(const uint8_t* src_buf, FX_DWOR D src_size, int width, int height,
588 const CPDF_Dictionary* pParams); 588 const CPDF_Dictionary* pParams);
589 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, 589 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DW ORD src_size, int width, int height,
590 int nComps, int bpc, const CPDF_Dictionary* pParams); 590 int nComps, int bpc, const CPDF_Dictionary* pParams);
591 int CPDF_DIBSource::CreateDecoder() 591 int CPDF_DIBSource::CreateDecoder()
592 { 592 {
593 const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder(); 593 const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder();
594 if (decoder.IsEmpty()) { 594 if (decoder.IsEmpty()) {
595 return 1; 595 return 1;
596 } 596 }
597 if (m_bDoBpcCheck && m_bpc == 0) { 597 if (m_bDoBpcCheck && m_bpc == 0) {
598 return 0; 598 return 0;
599 } 599 }
600 FX_LPCBYTE src_data = m_pStreamAcc->GetData(); 600 const uint8_t* src_data = m_pStreamAcc->GetData();
601 FX_DWORD src_size = m_pStreamAcc->GetSize(); 601 FX_DWORD src_size = m_pStreamAcc->GetSize();
602 const CPDF_Dictionary* pParams = m_pStreamAcc->GetImageParam(); 602 const CPDF_Dictionary* pParams = m_pStreamAcc->GetImageParam();
603 if (decoder == FX_BSTRC("CCITTFaxDecode")) { 603 if (decoder == FX_BSTRC("CCITTFaxDecode")) {
604 m_pDecoder = FPDFAPI_CreateFaxDecoder(src_data, src_size, m_Width, m_Hei ght, pParams); 604 m_pDecoder = FPDFAPI_CreateFaxDecoder(src_data, src_size, m_Width, m_Hei ght, pParams);
605 } else if (decoder == FX_BSTRC("DCTDecode")) { 605 } else if (decoder == FX_BSTRC("DCTDecode")) {
606 m_pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(src_d ata, src_size, m_Width, m_Height, 606 m_pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(src_d ata, src_size, m_Width, m_Height,
607 m_nComponents, pParams ? pParams->GetInteger(FX_BSTR("Color Transform"), 1) : 1); 607 m_nComponents, pParams ? pParams->GetInteger(FX_BSTR("Color Transform"), 1) : 1);
608 if (!m_pDecoder) { 608 if (!m_pDecoder) {
609 FX_BOOL bTransform = FALSE; 609 FX_BOOL bTransform = FALSE;
610 int comps, bpc; 610 int comps, bpc;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 bTranslateColor, 743 bTranslateColor,
744 context->output_offsets())) { 744 context->output_offsets())) {
745 m_pCachedBitmap.reset(); 745 m_pCachedBitmap.reset();
746 return; 746 return;
747 } 747 }
748 if (m_pColorSpace && 748 if (m_pColorSpace &&
749 m_pColorSpace->GetFamily() == PDFCS_INDEXED && 749 m_pColorSpace->GetFamily() == PDFCS_INDEXED &&
750 m_bpc < 8) { 750 m_bpc < 8) {
751 int scale = 8 - m_bpc; 751 int scale = 8 - m_bpc;
752 for (FX_DWORD row = 0; row < height; ++row) { 752 for (FX_DWORD row = 0; row < height; ++row) {
753 FX_LPBYTE scanline = (FX_LPBYTE)m_pCachedBitmap->GetScanline(row); 753 uint8_t* scanline = (uint8_t*)m_pCachedBitmap->GetScanline(row);
754 for (FX_DWORD col = 0; col < width; ++col) { 754 for (FX_DWORD col = 0; col < width; ++col) {
755 *scanline = (*scanline) >> scale; 755 *scanline = (*scanline) >> scale;
756 ++scanline; 756 ++scanline;
757 } 757 }
758 } 758 }
759 } 759 }
760 m_bpc = 8; 760 m_bpc = 8;
761 } 761 }
762 CPDF_DIBSource* CPDF_DIBSource::LoadMask(FX_DWORD& MatteColor) 762 CPDF_DIBSource* CPDF_DIBSource::LoadMask(FX_DWORD& MatteColor)
763 { 763 {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 // but too many documents don't conform to it. 953 // but too many documents don't conform to it.
954 m_bpc = 8; 954 m_bpc = 8;
955 } 955 }
956 } 956 }
957 } 957 }
958 if (m_bpc != 1 && m_bpc != 2 && m_bpc != 4 && m_bpc != 8 && m_bpc != 16) { 958 if (m_bpc != 1 && m_bpc != 2 && m_bpc != 4 && m_bpc != 8 && m_bpc != 16) {
959 m_bpc = 0; 959 m_bpc = 0;
960 } 960 }
961 } 961 }
962 #define NORMALCOLOR_MAX(color, max) (color) > (max) ? (max) : (color) < 0 ? 0 : (color); 962 #define NORMALCOLOR_MAX(color, max) (color) > (max) ? (max) : (color) < 0 ? 0 : (color);
963 void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_ scan) const 963 void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, const uint8_t* s rc_scan) const
964 { 964 {
965 if (m_bpc == 0) { 965 if (m_bpc == 0) {
966 return; 966 return;
967 } 967 }
968 int max_data = (1 << m_bpc) - 1; 968 int max_data = (1 << m_bpc) - 1;
969 if (m_bDefaultDecode) { 969 if (m_bDefaultDecode) {
970 if (m_Family == PDFCS_DEVICERGB || m_Family == PDFCS_CALRGB) { 970 if (m_Family == PDFCS_DEVICERGB || m_Family == PDFCS_CALRGB) {
971 FX_LPCBYTE src_pos = src_scan; 971 const uint8_t* src_pos = src_scan;
972 switch (m_bpc) { 972 switch (m_bpc) {
973 case 16: 973 case 16:
974 for (int col = 0; col < m_Width; col ++) { 974 for (int col = 0; col < m_Width; col ++) {
975 *dest_scan++ = src_pos[4]; 975 *dest_scan++ = src_pos[4];
976 *dest_scan++ = src_pos[2]; 976 *dest_scan++ = src_pos[2];
977 *dest_scan++ = *src_pos; 977 *dest_scan++ = *src_pos;
978 src_pos += 6; 978 src_pos += 6;
979 } 979 }
980 break; 980 break;
981 case 8: 981 case 8:
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 R = NORMALCOLOR_MAX(R, 1); 1063 R = NORMALCOLOR_MAX(R, 1);
1064 G = NORMALCOLOR_MAX(G, 1); 1064 G = NORMALCOLOR_MAX(G, 1);
1065 B = NORMALCOLOR_MAX(B, 1); 1065 B = NORMALCOLOR_MAX(B, 1);
1066 dest_scan[dest_byte_pos] = (int32_t)(B * 255); 1066 dest_scan[dest_byte_pos] = (int32_t)(B * 255);
1067 dest_scan[dest_byte_pos + 1] = (int32_t)(G * 255); 1067 dest_scan[dest_byte_pos + 1] = (int32_t)(G * 255);
1068 dest_scan[dest_byte_pos + 2] = (int32_t)(R * 255); 1068 dest_scan[dest_byte_pos + 2] = (int32_t)(R * 255);
1069 dest_byte_pos += 3; 1069 dest_byte_pos += 3;
1070 } 1070 }
1071 } 1071 }
1072 } 1072 }
1073 FX_LPBYTE CPDF_DIBSource::GetBuffer() const 1073 uint8_t* CPDF_DIBSource::GetBuffer() const
1074 { 1074 {
1075 if (m_pCachedBitmap) { 1075 if (m_pCachedBitmap) {
1076 return m_pCachedBitmap->GetBuffer(); 1076 return m_pCachedBitmap->GetBuffer();
1077 } 1077 }
1078 return NULL; 1078 return NULL;
1079 } 1079 }
1080 FX_LPCBYTE CPDF_DIBSource::GetScanline(int line) const 1080 const uint8_t* CPDF_DIBSource::GetScanline(int line) const
1081 { 1081 {
1082 if (m_bpc == 0) { 1082 if (m_bpc == 0) {
1083 return NULL; 1083 return NULL;
1084 } 1084 }
1085 FX_SAFE_DWORD src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width, 1); 1085 FX_SAFE_DWORD src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width, 1);
1086 if (!src_pitch.IsValid()) 1086 if (!src_pitch.IsValid())
1087 return NULL; 1087 return NULL;
1088 FX_DWORD src_pitch_value = src_pitch.ValueOrDie(); 1088 FX_DWORD src_pitch_value = src_pitch.ValueOrDie();
1089 FX_LPCBYTE pSrcLine = NULL; 1089 const uint8_t* pSrcLine = NULL;
1090 if (m_pCachedBitmap) { 1090 if (m_pCachedBitmap) {
1091 if (line >= m_pCachedBitmap->GetHeight()) { 1091 if (line >= m_pCachedBitmap->GetHeight()) {
1092 line = m_pCachedBitmap->GetHeight() - 1; 1092 line = m_pCachedBitmap->GetHeight() - 1;
1093 } 1093 }
1094 pSrcLine = m_pCachedBitmap->GetScanline(line); 1094 pSrcLine = m_pCachedBitmap->GetScanline(line);
1095 } else if (m_pDecoder) { 1095 } else if (m_pDecoder) {
1096 pSrcLine = m_pDecoder->GetScanline(line); 1096 pSrcLine = m_pDecoder->GetScanline(line);
1097 } else { 1097 } else {
1098 if (m_pStreamAcc->GetSize() >= (line + 1) * src_pitch_value) { 1098 if (m_pStreamAcc->GetSize() >= (line + 1) * src_pitch_value) {
1099 pSrcLine = m_pStreamAcc->GetData() + line * src_pitch_value; 1099 pSrcLine = m_pStreamAcc->GetData() + line * src_pitch_value;
1100 } 1100 }
1101 } 1101 }
1102 if (pSrcLine == NULL) { 1102 if (pSrcLine == NULL) {
1103 FX_LPBYTE pLineBuf = m_pMaskedLine ? m_pMaskedLine : m_pLineBuf; 1103 uint8_t* pLineBuf = m_pMaskedLine ? m_pMaskedLine : m_pLineBuf;
1104 FXSYS_memset8(pLineBuf, 0xff, m_Pitch); 1104 FXSYS_memset8(pLineBuf, 0xff, m_Pitch);
1105 return pLineBuf; 1105 return pLineBuf;
1106 } 1106 }
1107 if (m_bpc * m_nComponents == 1) { 1107 if (m_bpc * m_nComponents == 1) {
1108 if (m_bImageMask && m_bDefaultDecode) { 1108 if (m_bImageMask && m_bDefaultDecode) {
1109 for (FX_DWORD i = 0; i < src_pitch_value; i++) { 1109 for (FX_DWORD i = 0; i < src_pitch_value; i++) {
1110 m_pLineBuf[i] = ~pSrcLine[i]; 1110 m_pLineBuf[i] = ~pSrcLine[i];
1111 } 1111 }
1112 } else if (m_bColorKey) { 1112 } else if (m_bColorKey) {
1113 FX_DWORD reset_argb, set_argb; 1113 FX_DWORD reset_argb, set_argb;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 int color_index = 0; 1145 int color_index = 0;
1146 for (FX_DWORD color = 0; color < m_nComponents; color ++) { 1146 for (FX_DWORD color = 0; color < m_nComponents; color ++) {
1147 int data = _GetBits8(pSrcLine, src_bit_pos, m_bpc); 1147 int data = _GetBits8(pSrcLine, src_bit_pos, m_bpc);
1148 color_index |= data << (color * m_bpc); 1148 color_index |= data << (color * m_bpc);
1149 src_bit_pos += m_bpc; 1149 src_bit_pos += m_bpc;
1150 } 1150 }
1151 m_pLineBuf[col] = color_index; 1151 m_pLineBuf[col] = color_index;
1152 } 1152 }
1153 } 1153 }
1154 if (m_bColorKey) { 1154 if (m_bColorKey) {
1155 FX_LPBYTE pDestPixel = m_pMaskedLine; 1155 uint8_t* pDestPixel = m_pMaskedLine;
1156 FX_LPCBYTE pSrcPixel = m_pLineBuf; 1156 const uint8_t* pSrcPixel = m_pLineBuf;
1157 for (int col = 0; col < m_Width; col ++) { 1157 for (int col = 0; col < m_Width; col ++) {
1158 uint8_t index = *pSrcPixel++; 1158 uint8_t index = *pSrcPixel++;
1159 if (m_pPalette) { 1159 if (m_pPalette) {
1160 *pDestPixel++ = FXARGB_B(m_pPalette[index]); 1160 *pDestPixel++ = FXARGB_B(m_pPalette[index]);
1161 *pDestPixel++ = FXARGB_G(m_pPalette[index]); 1161 *pDestPixel++ = FXARGB_G(m_pPalette[index]);
1162 *pDestPixel++ = FXARGB_R(m_pPalette[index]); 1162 *pDestPixel++ = FXARGB_R(m_pPalette[index]);
1163 } else { 1163 } else {
1164 *pDestPixel++ = index; 1164 *pDestPixel++ = index;
1165 *pDestPixel++ = index; 1165 *pDestPixel++ = index;
1166 *pDestPixel++ = index; 1166 *pDestPixel++ = index;
1167 } 1167 }
1168 *pDestPixel = (index < m_pCompData[0].m_ColorKeyMin || index > m _pCompData[0].m_ColorKeyMax) ? 0xff : 0; 1168 *pDestPixel = (index < m_pCompData[0].m_ColorKeyMin || index > m _pCompData[0].m_ColorKeyMax) ? 0xff : 0;
1169 pDestPixel ++ ; 1169 pDestPixel ++ ;
1170 } 1170 }
1171 return m_pMaskedLine; 1171 return m_pMaskedLine;
1172 } 1172 }
1173 return m_pLineBuf; 1173 return m_pLineBuf;
1174 } 1174 }
1175 if (m_bColorKey) { 1175 if (m_bColorKey) {
1176 if (m_nComponents == 3 && m_bpc == 8) { 1176 if (m_nComponents == 3 && m_bpc == 8) {
1177 FX_LPBYTE alpha_channel = m_pMaskedLine + 3; 1177 uint8_t* alpha_channel = m_pMaskedLine + 3;
1178 for (int col = 0; col < m_Width; col ++) { 1178 for (int col = 0; col < m_Width; col ++) {
1179 FX_LPCBYTE pPixel = pSrcLine + col * 3; 1179 const uint8_t* pPixel = pSrcLine + col * 3;
1180 alpha_channel[col * 4] = (pPixel[0] < m_pCompData[0].m_ColorKeyM in || pPixel[0] > m_pCompData[0].m_ColorKeyMax || 1180 alpha_channel[col * 4] = (pPixel[0] < m_pCompData[0].m_ColorKeyM in || pPixel[0] > m_pCompData[0].m_ColorKeyMax ||
1181 pPixel[1] < m_pCompData[1].m_ColorKeyM in || pPixel[1] > m_pCompData[1].m_ColorKeyMax || 1181 pPixel[1] < m_pCompData[1].m_ColorKeyM in || pPixel[1] > m_pCompData[1].m_ColorKeyMax ||
1182 pPixel[2] < m_pCompData[2].m_ColorKeyM in || pPixel[2] > m_pCompData[2].m_ColorKeyMax) ? 0xff : 0; 1182 pPixel[2] < m_pCompData[2].m_ColorKeyM in || pPixel[2] > m_pCompData[2].m_ColorKeyMax) ? 0xff : 0;
1183 } 1183 }
1184 } else { 1184 } else {
1185 FXSYS_memset8(m_pMaskedLine, 0xff, m_Pitch); 1185 FXSYS_memset8(m_pMaskedLine, 0xff, m_Pitch);
1186 } 1186 }
1187 } 1187 }
1188 if (m_pColorSpace) { 1188 if (m_pColorSpace) {
1189 TranslateScanline24bpp(m_pLineBuf, pSrcLine); 1189 TranslateScanline24bpp(m_pLineBuf, pSrcLine);
1190 pSrcLine = m_pLineBuf; 1190 pSrcLine = m_pLineBuf;
1191 } 1191 }
1192 if (m_bColorKey) { 1192 if (m_bColorKey) {
1193 FX_LPCBYTE pSrcPixel = pSrcLine; 1193 const uint8_t* pSrcPixel = pSrcLine;
1194 FX_LPBYTE pDestPixel = m_pMaskedLine; 1194 uint8_t* pDestPixel = m_pMaskedLine;
1195 for (int col = 0; col < m_Width; col ++) { 1195 for (int col = 0; col < m_Width; col ++) {
1196 *pDestPixel++ = *pSrcPixel++; 1196 *pDestPixel++ = *pSrcPixel++;
1197 *pDestPixel++ = *pSrcPixel++; 1197 *pDestPixel++ = *pSrcPixel++;
1198 *pDestPixel++ = *pSrcPixel++; 1198 *pDestPixel++ = *pSrcPixel++;
1199 pDestPixel ++; 1199 pDestPixel ++;
1200 } 1200 }
1201 return m_pMaskedLine; 1201 return m_pMaskedLine;
1202 } 1202 }
1203 return pSrcLine; 1203 return pSrcLine;
1204 } 1204 }
1205 FX_BOOL CPDF_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const 1205 FX_BOOL CPDF_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const
1206 { 1206 {
1207 if (m_pDecoder) { 1207 if (m_pDecoder) {
1208 return m_pDecoder->SkipToScanline(line, pPause); 1208 return m_pDecoder->SkipToScanline(line, pPause);
1209 } 1209 }
1210 return FALSE; 1210 return FALSE;
1211 } 1211 }
1212 void CPDF_DIBSource::DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_ bpp, 1212 void CPDF_DIBSource::DownSampleScanline(int line, uint8_t* dest_scan, int dest_b pp,
1213 int dest_width, FX_BOOL bFlipX, int clip _left, int clip_width) const 1213 int dest_width, FX_BOOL bFlipX, int clip _left, int clip_width) const
1214 { 1214 {
1215 if (line < 0 || dest_scan == NULL || dest_bpp <= 0 || 1215 if (line < 0 || dest_scan == NULL || dest_bpp <= 0 ||
1216 dest_width <= 0 || clip_left < 0 || clip_width <= 0) { 1216 dest_width <= 0 || clip_left < 0 || clip_width <= 0) {
1217 return; 1217 return;
1218 } 1218 }
1219 1219
1220 FX_DWORD src_width = m_Width; 1220 FX_DWORD src_width = m_Width;
1221 FX_SAFE_DWORD pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width, 1); 1221 FX_SAFE_DWORD pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width, 1);
1222 if (!pitch.IsValid()) { 1222 if (!pitch.IsValid()) {
1223 return; 1223 return;
1224 } 1224 }
1225 1225
1226 FX_LPCBYTE pSrcLine = NULL; 1226 const uint8_t* pSrcLine = NULL;
1227 if (m_pCachedBitmap) { 1227 if (m_pCachedBitmap) {
1228 pSrcLine = m_pCachedBitmap->GetScanline(line); 1228 pSrcLine = m_pCachedBitmap->GetScanline(line);
1229 } else if (m_pDecoder) { 1229 } else if (m_pDecoder) {
1230 pSrcLine = m_pDecoder->GetScanline(line); 1230 pSrcLine = m_pDecoder->GetScanline(line);
1231 } else { 1231 } else {
1232 FX_DWORD src_pitch = pitch.ValueOrDie(); 1232 FX_DWORD src_pitch = pitch.ValueOrDie();
1233 pitch *= (line+1); 1233 pitch *= (line+1);
1234 if (!pitch.IsValid()) { 1234 if (!pitch.IsValid()) {
1235 return; 1235 return;
1236 } 1236 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 } 1337 }
1338 pSrcLine = m_pLineBuf; 1338 pSrcLine = m_pLineBuf;
1339 } 1339 }
1340 if (m_bColorKey) { 1340 if (m_bColorKey) {
1341 for (int i = 0; i < clip_width; i ++) { 1341 for (int i = 0; i < clip_width; i ++) {
1342 FX_DWORD src_x = (clip_left + i) * src_width / dest_width; 1342 FX_DWORD src_x = (clip_left + i) * src_width / dest_width;
1343 if (bFlipX) { 1343 if (bFlipX) {
1344 src_x = src_width - src_x - 1; 1344 src_x = src_width - src_x - 1;
1345 } 1345 }
1346 src_x %= src_width; 1346 src_x %= src_width;
1347 FX_LPBYTE pDestPixel = dest_scan + i * 4; 1347 uint8_t* pDestPixel = dest_scan + i * 4;
1348 uint8_t index = pSrcLine[src_x]; 1348 uint8_t index = pSrcLine[src_x];
1349 if (m_pPalette) { 1349 if (m_pPalette) {
1350 *pDestPixel++ = FXARGB_B(m_pPalette[index]); 1350 *pDestPixel++ = FXARGB_B(m_pPalette[index]);
1351 *pDestPixel++ = FXARGB_G(m_pPalette[index]); 1351 *pDestPixel++ = FXARGB_G(m_pPalette[index]);
1352 *pDestPixel++ = FXARGB_R(m_pPalette[index]); 1352 *pDestPixel++ = FXARGB_R(m_pPalette[index]);
1353 } else { 1353 } else {
1354 *pDestPixel++ = index; 1354 *pDestPixel++ = index;
1355 *pDestPixel++ = index; 1355 *pDestPixel++ = index;
1356 *pDestPixel++ = index; 1356 *pDestPixel++ = index;
1357 } 1357 }
(...skipping 21 matching lines...) Expand all
1379 return; 1379 return;
1380 } else { 1380 } else {
1381 int last_src_x = -1; 1381 int last_src_x = -1;
1382 FX_ARGB last_argb; 1382 FX_ARGB last_argb;
1383 FX_FLOAT orig_Not8Bpp = (FX_FLOAT)m_bpc * (FX_FLOAT)m_nComponents / 8.0f ; 1383 FX_FLOAT orig_Not8Bpp = (FX_FLOAT)m_bpc * (FX_FLOAT)m_nComponents / 8.0f ;
1384 FX_FLOAT unit_To8Bpc = 255.0f / ((1 << m_bpc) - 1); 1384 FX_FLOAT unit_To8Bpc = 255.0f / ((1 << m_bpc) - 1);
1385 for (int i = 0; i < clip_width; i ++) { 1385 for (int i = 0; i < clip_width; i ++) {
1386 int dest_x = clip_left + i; 1386 int dest_x = clip_left + i;
1387 FX_DWORD src_x = (bFlipX ? (dest_width - dest_x - 1) : dest_x) * (in t64_t)src_width / dest_width; 1387 FX_DWORD src_x = (bFlipX ? (dest_width - dest_x - 1) : dest_x) * (in t64_t)src_width / dest_width;
1388 src_x %= src_width; 1388 src_x %= src_width;
1389 FX_LPCBYTE pSrcPixel = NULL; 1389 const uint8_t* pSrcPixel = NULL;
1390 if (m_bpc % 8 == 0) { 1390 if (m_bpc % 8 == 0) {
1391 pSrcPixel = pSrcLine + src_x * orig_Bpp; 1391 pSrcPixel = pSrcLine + src_x * orig_Bpp;
1392 } else { 1392 } else {
1393 pSrcPixel = pSrcLine + (int)(src_x * orig_Not8Bpp); 1393 pSrcPixel = pSrcLine + (int)(src_x * orig_Not8Bpp);
1394 } 1394 }
1395 FX_LPBYTE pDestPixel = dest_scan + i * dest_Bpp; 1395 uint8_t* pDestPixel = dest_scan + i * dest_Bpp;
1396 FX_ARGB argb; 1396 FX_ARGB argb;
1397 if (src_x == last_src_x) { 1397 if (src_x == last_src_x) {
1398 argb = last_argb; 1398 argb = last_argb;
1399 } else { 1399 } else {
1400 if (m_pColorSpace) { 1400 if (m_pColorSpace) {
1401 uint8_t color[4]; 1401 uint8_t color[4];
1402 if (!m_bDefaultDecode) { 1402 if (!m_bDefaultDecode) {
1403 for (int i = 0; i < m_nComponents; i ++) { 1403 for (int i = 0; i < m_nComponents; i ++) {
1404 int color_value = (int)((m_pCompData[i].m_DecodeMin + m_pCompData[i].m_DecodeStep * (FX_FLOAT)pSrcPixel[i]) * 255.0f + 0.5f); 1404 int color_value = (int)((m_pCompData[i].m_DecodeMin + m_pCompData[i].m_DecodeStep * (FX_FLOAT)pSrcPixel[i]) * 255.0f + 0.5f);
1405 temp[i] = color_value > 255 ? 255 : (color_value < 0 ? 0 : color_value); 1405 temp[i] = color_value > 255 ? 255 : (color_value < 0 ? 0 : color_value);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 } 1529 }
1530 if (pCache) { 1530 if (pCache) {
1531 pCache->GetCachedBitmap(pImage->m_pImage->GetStream(), m_pBitmap, m_pMas k, m_MatteColor, bStdCS, GroupFamily, bLoadMask, pRenderStatus, m_nDownsampleWid th, m_nDownsampleHeight); 1531 pCache->GetCachedBitmap(pImage->m_pImage->GetStream(), m_pBitmap, m_pMas k, m_MatteColor, bStdCS, GroupFamily, bLoadMask, pRenderStatus, m_nDownsampleWid th, m_nDownsampleHeight);
1532 m_bCached = TRUE; 1532 m_bCached = TRUE;
1533 } else { 1533 } else {
1534 m_pBitmap = pImage->m_pImage->LoadDIBSource(&m_pMask, &m_MatteColor, bSt dCS, GroupFamily, bLoadMask); 1534 m_pBitmap = pImage->m_pImage->LoadDIBSource(&m_pMask, &m_MatteColor, bSt dCS, GroupFamily, bLoadMask);
1535 m_bCached = FALSE; 1535 m_bCached = FALSE;
1536 } 1536 }
1537 return FALSE; 1537 return FALSE;
1538 } 1538 }
1539 FX_BOOL CPDF_ImageLoader::StartLoadImage(const CPDF_ImageObject* pImage, CPDF_Pa geRenderCache* pCache, FX_LPVOID& LoadHandle, FX_BOOL bStdCS, FX_DWORD GroupFami ly, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t nDownsampleWidt h, int32_t nDownsampleHeight) 1539 FX_BOOL CPDF_ImageLoader::StartLoadImage(const CPDF_ImageObject* pImage, CPDF_Pa geRenderCache* pCache, void*& LoadHandle, FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t nDownsampleWidth, i nt32_t nDownsampleHeight)
1540 { 1540 {
1541 m_nDownsampleWidth = nDownsampleWidth; 1541 m_nDownsampleWidth = nDownsampleWidth;
1542 m_nDownsampleHeight = nDownsampleHeight; 1542 m_nDownsampleHeight = nDownsampleHeight;
1543 CPDF_ProgressiveImageLoaderHandle* pLoaderHandle = new CPDF_ProgressiveImage LoaderHandle; 1543 CPDF_ProgressiveImageLoaderHandle* pLoaderHandle = new CPDF_ProgressiveImage LoaderHandle;
1544 FX_BOOL ret = pLoaderHandle->Start(this, pImage, pCache, bStdCS, GroupFamily , bLoadMask, pRenderStatus, m_nDownsampleWidth, m_nDownsampleHeight); 1544 FX_BOOL ret = pLoaderHandle->Start(this, pImage, pCache, bStdCS, GroupFamily , bLoadMask, pRenderStatus, m_nDownsampleWidth, m_nDownsampleHeight);
1545 LoadHandle = pLoaderHandle; 1545 LoadHandle = pLoaderHandle;
1546 return ret; 1546 return ret;
1547 } 1547 }
1548 FX_BOOL»CPDF_ImageLoader::Continue(FX_LPVOID LoadHandle, IFX_Pause* pPause) 1548 FX_BOOL»CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause)
1549 { 1549 {
1550 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); 1550 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause);
1551 } 1551 }
1552 CPDF_ImageLoader::~CPDF_ImageLoader() 1552 CPDF_ImageLoader::~CPDF_ImageLoader()
1553 { 1553 {
1554 if (!m_bCached) { 1554 if (!m_bCached) {
1555 delete m_pBitmap; 1555 delete m_pBitmap;
1556 delete m_pMask; 1556 delete m_pMask;
1557 } 1557 }
1558 } 1558 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698