Chromium Code Reviews| 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 "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
| 8 #include "../../../include/fxcodec/fx_codec.h" | 8 #include "../../../include/fxcodec/fx_codec.h" |
| 9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
| 10 #include "../../../include/fpdfapi/fpdf_render.h" | 10 #include "../../../include/fpdfapi/fpdf_render.h" |
| 11 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 11 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
| 12 #include "../fpdf_page/pageint.h" | 12 #include "../fpdf_page/pageint.h" |
| 13 #include "render_int.h" | 13 #include "render_int.h" |
| 14 #include <limits.h> | 14 #include "../../../../third_party/numerics/safe_math.h" |
| 15 | |
| 16 typedef base::CheckedNumeric<FX_DWORD> FxDword; | |
|
Tom Sepez
2014/07/25 16:15:23
nit: despite what palmer says about typedefs, thes
jun_fang
2014/07/30 22:27:01
will update it in the next patch.
| |
| 17 typedef base::CheckedNumeric<int> Int; | |
| 18 | |
| 15 static unsigned int _GetBits8(FX_LPCBYTE pData, int bitpos, int nbits) | 19 static unsigned int _GetBits8(FX_LPCBYTE pData, int bitpos, int nbits) |
| 16 { | 20 { |
| 17 unsigned int byte = pData[bitpos / 8]; | 21 unsigned int byte = pData[bitpos / 8]; |
| 18 if (nbits == 8) { | 22 if (nbits == 8) { |
| 19 return byte; | 23 return byte; |
| 20 } else if (nbits == 4) { | 24 } else if (nbits == 4) { |
| 21 return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4); | 25 return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4); |
| 22 } else if (nbits == 2) { | 26 } else if (nbits == 2) { |
| 23 return (byte >> (6 - bitpos % 8)) & 0x03; | 27 return (byte >> (6 - bitpos % 8)) & 0x03; |
| 24 } else if (nbits == 1) { | 28 } else if (nbits == 1) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 m_Width = m_pDict->GetInteger(FX_BSTRC("Width")); | 172 m_Width = m_pDict->GetInteger(FX_BSTRC("Width")); |
| 169 m_Height = m_pDict->GetInteger(FX_BSTRC("Height")); | 173 m_Height = m_pDict->GetInteger(FX_BSTRC("Height")); |
| 170 if (m_Width <= 0 || m_Height <= 0 || m_Width > 0x01ffff || m_Height > 0x01ff ff) { | 174 if (m_Width <= 0 || m_Height <= 0 || m_Width > 0x01ffff || m_Height > 0x01ff ff) { |
| 171 return FALSE; | 175 return FALSE; |
| 172 } | 176 } |
| 173 m_GroupFamily = GroupFamily; | 177 m_GroupFamily = GroupFamily; |
| 174 m_bLoadMask = bLoadMask; | 178 m_bLoadMask = bLoadMask; |
| 175 if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? NULL : pFormResources, pPag eResources)) { | 179 if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? NULL : pFormResources, pPag eResources)) { |
| 176 return FALSE; | 180 return FALSE; |
| 177 } | 181 } |
| 178 FX_DWORD src_pitch = m_bpc; | 182 |
| 179 if (m_bpc != 0 && m_nComponents != 0) { | 183 if (m_bpc == 0 || m_nComponents == 0) { |
|
Tom Sepez
2014/07/25 21:13:51
We continue execution here in the old code in this
jun_fang
2014/07/30 22:27:01
You can find |FX_DWORD src_pitch = m_bpc;| at line
| |
| 180 if (src_pitch > 0 && m_nComponents > (unsigned)INT_MAX / src_pitch) { | 184 return FALSE; |
| 181 return FALSE; | |
| 182 } | |
| 183 src_pitch *= m_nComponents; | |
| 184 if (src_pitch > 0 && (FX_DWORD)m_Width > (unsigned)INT_MAX / src_pitch) { | |
| 185 return FALSE; | |
| 186 } | |
| 187 src_pitch *= m_Width; | |
| 188 if (src_pitch + 7 < src_pitch) { | |
| 189 return FALSE; | |
| 190 } | |
| 191 src_pitch += 7; | |
| 192 src_pitch /= 8; | |
| 193 if (src_pitch > 0 && (FX_DWORD)m_Height > (unsigned)INT_MAX / src_pitch) { | |
| 194 return FALSE; | |
| 195 } | |
| 196 } | 185 } |
| 186 | |
| 187 FxDword src_pitch = m_bpc; | |
| 188 src_pitch *= m_nComponents; | |
| 189 src_pitch *= m_Width; | |
| 190 src_pitch += 7; | |
| 191 src_pitch /= 8; | |
| 192 src_pitch *= m_Height; | |
| 193 if (!src_pitch.IsValid()) { | |
| 194 return FALSE; | |
| 195 } | |
| 196 | |
| 197 m_pStreamAcc = FX_NEW CPDF_StreamAcc; | 197 m_pStreamAcc = FX_NEW CPDF_StreamAcc; |
| 198 m_pStreamAcc->LoadAllData(pStream, FALSE, m_Height * src_pitch, TRUE); | 198 m_pStreamAcc->LoadAllData(pStream, FALSE, src_pitch.ValueOrDie(), TRUE); |
| 199 if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) { | 199 if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) { |
| 200 return FALSE; | 200 return FALSE; |
| 201 } | 201 } |
| 202 const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder(); | 202 const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder(); |
| 203 if (!decoder.IsEmpty() && decoder == FX_BSTRC("CCITTFaxDecode")) { | 203 if (!decoder.IsEmpty() && decoder == FX_BSTRC("CCITTFaxDecode")) { |
| 204 m_bpc = 1; | 204 m_bpc = 1; |
| 205 } | 205 } |
| 206 if (!CreateDecoder()) { | 206 if (!CreateDecoder()) { |
| 207 return FALSE; | 207 return FALSE; |
| 208 } | 208 } |
| 209 if (m_bImageMask) { | 209 if (m_bImageMask) { |
| 210 m_bpp = 1; | 210 m_bpp = 1; |
| 211 m_bpc = 1; | 211 m_bpc = 1; |
| 212 m_nComponents = 1; | 212 m_nComponents = 1; |
| 213 m_AlphaFlag = 1; | 213 m_AlphaFlag = 1; |
| 214 } else if (m_bpc * m_nComponents == 1) { | 214 } else if (m_bpc * m_nComponents == 1) { |
| 215 m_bpp = 1; | 215 m_bpp = 1; |
| 216 } else if (m_bpc * m_nComponents <= 8) { | 216 } else if (m_bpc * m_nComponents <= 8) { |
| 217 m_bpp = 8; | 217 m_bpp = 8; |
| 218 } else { | 218 } else { |
| 219 m_bpp = 24; | 219 m_bpp = 24; |
| 220 } | 220 } |
| 221 if (!m_bpc || !m_nComponents) { | 221 |
| 222 return FALSE; | 222 FxDword pitch = m_Width; |
| 223 } | 223 pitch *= m_bpp; |
| 224 m_Pitch = m_Width; | 224 pitch += 31; |
| 225 if ((FX_DWORD)m_bpp > (unsigned)INT_MAX / m_Pitch) { | 225 pitch /= 8; |
| 226 return FALSE; | 226 if (!pitch.IsValid()) return FALSE; |
|
Tom Sepez
2014/07/25 21:13:51
nit: braces, return on its own line, to match exis
Tom Sepez
2014/07/25 21:13:51
We can return here without setting m_pitch as in t
jun_fang
2014/07/30 22:27:01
m_pitch will be updated if there is no problem dur
| |
| 227 } | 227 |
| 228 m_Pitch *= m_bpp; | 228 m_pLineBuf = FX_Alloc(FX_BYTE, pitch.ValueOrDie()); |
| 229 if (m_Pitch + 31 < m_Pitch) { | |
| 230 return FALSE; | |
| 231 } | |
| 232 m_Pitch += 31; | |
| 233 m_Pitch = m_Pitch / 32 * 4; | |
| 234 m_pLineBuf = FX_Alloc(FX_BYTE, m_Pitch); | |
| 235 if (m_pColorSpace && bStdCS) { | 229 if (m_pColorSpace && bStdCS) { |
| 236 m_pColorSpace->EnableStdConversion(TRUE); | 230 m_pColorSpace->EnableStdConversion(TRUE); |
| 237 } | 231 } |
| 238 LoadPalette(); | 232 LoadPalette(); |
| 239 if (m_bColorKey) { | 233 if (m_bColorKey) { |
| 240 m_bpp = 32; | 234 m_bpp = 32; |
| 241 m_AlphaFlag = 2; | 235 m_AlphaFlag = 2; |
| 242 m_Pitch = m_Width; | 236 pitch = m_Width; |
| 243 if ((FX_DWORD)m_bpp > (unsigned)INT_MAX / m_Pitch) { | 237 pitch *= m_bpp; |
| 244 return FALSE; | 238 pitch += 31; |
| 245 } | 239 pitch /= 8; |
| 246 m_Pitch *= m_bpp; | 240 if (!pitch.IsValid()) return FALSE; |
|
Tom Sepez
2014/07/25 21:13:51
same two comments as above: nit for {} and do we
jun_fang
2014/07/30 22:27:01
Will add {} in the next patch.
| |
| 247 if (m_Pitch + 31 < m_Pitch) { | 241 |
| 248 return FALSE; | 242 m_pMaskedLine = FX_Alloc(FX_BYTE, pitch.ValueOrDie()); |
| 249 } | |
| 250 m_Pitch += 31; | |
| 251 m_Pitch = m_Pitch / 32 * 4; | |
| 252 m_pMaskedLine = FX_Alloc(FX_BYTE, m_Pitch); | |
| 253 } | 243 } |
| 244 m_Pitch = pitch.ValueOrDie(); | |
| 254 if (ppMask) { | 245 if (ppMask) { |
| 255 *ppMask = LoadMask(*pMatteColor); | 246 *ppMask = LoadMask(*pMatteColor); |
| 256 } | 247 } |
| 257 if (m_pColorSpace && bStdCS) { | 248 if (m_pColorSpace && bStdCS) { |
| 258 m_pColorSpace->EnableStdConversion(FALSE); | 249 m_pColorSpace->EnableStdConversion(FALSE); |
| 259 } | 250 } |
| 260 return TRUE; | 251 return TRUE; |
| 261 } | 252 } |
| 262 int CPDF_DIBSource::ContinueToLoadMask() | 253 int CPDF_DIBSource::ContinueToLoadMask() |
| 263 { | 254 { |
| 264 if (m_bImageMask) { | 255 if (m_bImageMask) { |
| 265 m_bpp = 1; | 256 m_bpp = 1; |
| 266 m_bpc = 1; | 257 m_bpc = 1; |
| 267 m_nComponents = 1; | 258 m_nComponents = 1; |
| 268 m_AlphaFlag = 1; | 259 m_AlphaFlag = 1; |
| 269 } else if (m_bpc * m_nComponents == 1) { | 260 } else if (m_bpc * m_nComponents == 1) { |
| 270 m_bpp = 1; | 261 m_bpp = 1; |
| 271 } else if (m_bpc * m_nComponents <= 8) { | 262 } else if (m_bpc * m_nComponents <= 8) { |
| 272 m_bpp = 8; | 263 m_bpp = 8; |
| 273 } else { | 264 } else { |
| 274 m_bpp = 24; | 265 m_bpp = 24; |
| 275 } | 266 } |
| 276 if (!m_bpc || !m_nComponents) { | 267 if (!m_bpc || !m_nComponents) { |
| 277 return 0; | 268 return 0; |
| 278 } | 269 } |
| 279 m_Pitch = m_Width; | 270 FxDword pitch = m_Width; |
| 280 if ((FX_DWORD)m_bpp > (unsigned)INT_MAX / m_Pitch) { | 271 pitch *= m_bpp; |
| 272 pitch += 31; | |
| 273 pitch /= 8; | |
| 274 if (!pitch.IsValid()) { | |
| 281 return 0; | 275 return 0; |
| 282 } | 276 } |
| 283 m_Pitch *= m_bpp; | 277 m_pLineBuf = FX_Alloc(FX_BYTE, pitch.ValueOrDie()); |
| 284 if (m_Pitch + 31 < m_Pitch) { | |
| 285 return 0; | |
| 286 } | |
| 287 m_Pitch += 31; | |
| 288 m_Pitch = m_Pitch / 32 * 4; | |
| 289 m_pLineBuf = FX_Alloc(FX_BYTE, m_Pitch); | |
| 290 if (m_pColorSpace && m_bStdCS) { | 278 if (m_pColorSpace && m_bStdCS) { |
| 291 m_pColorSpace->EnableStdConversion(TRUE); | 279 m_pColorSpace->EnableStdConversion(TRUE); |
| 292 } | 280 } |
| 293 LoadPalette(); | 281 LoadPalette(); |
| 294 if (m_bColorKey) { | 282 if (m_bColorKey) { |
| 295 m_bpp = 32; | 283 m_bpp = 32; |
| 296 m_AlphaFlag = 2; | 284 m_AlphaFlag = 2; |
| 297 m_Pitch = m_Width; | 285 pitch = m_Width; |
| 298 if ((FX_DWORD)m_bpp > (unsigned)INT_MAX / m_Pitch) { | 286 pitch *= m_bpp; |
| 287 pitch += 31; | |
| 288 pitch /= 8; | |
| 289 if (!pitch.IsValid()) { | |
| 299 return 0; | 290 return 0; |
| 300 } | 291 } |
| 301 m_Pitch *= m_bpp; | 292 m_pMaskedLine = FX_Alloc(FX_BYTE, pitch.ValueOrDie()); |
| 302 if (m_Pitch + 31 < m_Pitch) { | |
| 303 return 0; | |
| 304 } | |
| 305 m_Pitch += 31; | |
| 306 m_Pitch = m_Pitch / 32 * 4; | |
| 307 m_pMaskedLine = FX_Alloc(FX_BYTE, m_Pitch); | |
| 308 } | 293 } |
| 294 m_Pitch = pitch.ValueOrDie(); | |
| 309 return 1; | 295 return 1; |
| 310 } | 296 } |
| 311 int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Strea m* pStream, FX_BOOL bHasMask, | 297 int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Strea m* pStream, FX_BOOL bHasMask, |
| 312 CPDF_Dictionary* pFormResources, CPDF_Dic tionary* pPageResources, | 298 CPDF_Dictionary* pFormResources, CPDF_Dic tionary* pPageResources, |
| 313 FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_ BOOL bLoadMask) | 299 FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_ BOOL bLoadMask) |
| 314 { | 300 { |
| 315 if (pStream == NULL) { | 301 if (pStream == NULL) { |
| 316 return 0; | 302 return 0; |
| 317 } | 303 } |
| 318 m_pDocument = pDoc; | 304 m_pDocument = pDoc; |
| 319 m_pDict = pStream->GetDict(); | 305 m_pDict = pStream->GetDict(); |
| 320 m_pStream = pStream; | 306 m_pStream = pStream; |
| 321 m_bStdCS = bStdCS; | 307 m_bStdCS = bStdCS; |
| 322 m_bHasMask = bHasMask; | 308 m_bHasMask = bHasMask; |
| 323 m_Width = m_pDict->GetInteger(FX_BSTRC("Width")); | 309 m_Width = m_pDict->GetInteger(FX_BSTRC("Width")); |
| 324 m_Height = m_pDict->GetInteger(FX_BSTRC("Height")); | 310 m_Height = m_pDict->GetInteger(FX_BSTRC("Height")); |
| 325 if (m_Width <= 0 || m_Height <= 0 || m_Width > 0x01ffff || m_Height > 0x01ff ff) { | 311 if (m_Width <= 0 || m_Height <= 0 || m_Width > 0x01ffff || m_Height > 0x01ff ff) { |
| 326 return 0; | 312 return 0; |
| 327 } | 313 } |
| 328 m_GroupFamily = GroupFamily; | 314 m_GroupFamily = GroupFamily; |
| 329 m_bLoadMask = bLoadMask; | 315 m_bLoadMask = bLoadMask; |
| 330 if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? NULL : pFormResources, pPag eResources)) { | 316 if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? NULL : pFormResources, pPag eResources)) { |
| 331 return 0; | 317 return 0; |
| 332 } | 318 } |
| 333 FX_DWORD src_pitch = m_bpc; | 319 |
| 334 if (m_bpc != 0 && m_nComponents != 0) { | 320 if (m_bpc == 0 || m_nComponents == 0) { |
| 335 if (src_pitch > 0 && m_nComponents > (unsigned)INT_MAX / src_pitch) { | 321 return 0; |
|
Tom Sepez
2014/07/25 21:13:51
same question as above for early return.
jun_fang
2014/07/30 22:27:01
at line 353 of the original code, m_bpc will be us
| |
| 336 return 0; | |
| 337 } | |
| 338 src_pitch *= m_nComponents; | |
| 339 if (src_pitch > 0 && (FX_DWORD)m_Width > (unsigned)INT_MAX / src_pitch) { | |
| 340 return 0; | |
| 341 } | |
| 342 src_pitch *= m_Width; | |
| 343 if (src_pitch + 7 < src_pitch) { | |
| 344 return 0; | |
| 345 } | |
| 346 src_pitch += 7; | |
| 347 src_pitch /= 8; | |
| 348 if (src_pitch > 0 && (FX_DWORD)m_Height > (unsigned)INT_MAX / src_pitch) { | |
| 349 return 0; | |
| 350 } | |
| 351 } | 322 } |
| 323 | |
| 324 FxDword src_pitch = m_bpc; | |
| 325 src_pitch *= m_nComponents; | |
| 326 src_pitch *= m_Width; | |
| 327 src_pitch += 7; | |
| 328 src_pitch /= 8; | |
| 329 src_pitch *= m_Height; | |
| 330 if (!src_pitch.IsValid()) { | |
| 331 return 0; | |
| 332 } | |
| 333 | |
| 352 m_pStreamAcc = FX_NEW CPDF_StreamAcc; | 334 m_pStreamAcc = FX_NEW CPDF_StreamAcc; |
| 353 m_pStreamAcc->LoadAllData(pStream, FALSE, m_Height * src_pitch, TRUE); | 335 m_pStreamAcc->LoadAllData(pStream, FALSE, src_pitch.ValueOrDie(), TRUE); |
| 354 if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) { | 336 if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) { |
| 355 return 0; | 337 return 0; |
| 356 } | 338 } |
| 357 const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder(); | 339 const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder(); |
| 358 if (!decoder.IsEmpty() && decoder == FX_BSTRC("CCITTFaxDecode")) { | 340 if (!decoder.IsEmpty() && decoder == FX_BSTRC("CCITTFaxDecode")) { |
| 359 m_bpc = 1; | 341 m_bpc = 1; |
| 360 } | 342 } |
| 361 int ret = CreateDecoder(); | 343 int ret = CreateDecoder(); |
| 362 if (ret != 1) { | 344 if (ret != 1) { |
| 363 if (!ret) { | 345 if (!ret) { |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 FX_BOOL CPDF_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const | 1159 FX_BOOL CPDF_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const |
| 1178 { | 1160 { |
| 1179 if (m_pDecoder) { | 1161 if (m_pDecoder) { |
| 1180 return m_pDecoder->SkipToScanline(line, pPause); | 1162 return m_pDecoder->SkipToScanline(line, pPause); |
| 1181 } | 1163 } |
| 1182 return FALSE; | 1164 return FALSE; |
| 1183 } | 1165 } |
| 1184 void CPDF_DIBSource::DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_ bpp, | 1166 void CPDF_DIBSource::DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_ bpp, |
| 1185 int dest_width, FX_BOOL bFlipX, int clip _left, int clip_width) const | 1167 int dest_width, FX_BOOL bFlipX, int clip _left, int clip_width) const |
| 1186 { | 1168 { |
| 1169 if (line < 0 || dest_scan == NULL || dest_bpp <= 0 || | |
| 1170 dest_width <= 0 || clip_left < 0 || clip_width <= 0) { | |
| 1171 return; | |
| 1172 } | |
| 1173 | |
| 1187 FX_DWORD bpc = GetValidBpc(); | 1174 FX_DWORD bpc = GetValidBpc(); |
| 1188 FX_DWORD src_width = m_Width; | 1175 FX_DWORD src_width = m_Width; |
| 1189 FX_DWORD src_pitch = (src_width * bpc * m_nComponents + 7) / 8; | 1176 FxDword pitch = src_width; |
| 1177 pitch *= bpc; | |
| 1178 pitch *= m_nComponents; | |
| 1179 pitch += 7; | |
| 1180 pitch /= 8; | |
| 1181 if (!pitch.IsValid()) { | |
| 1182 return; | |
| 1183 } | |
| 1184 | |
| 1190 FX_LPCBYTE pSrcLine = NULL; | 1185 FX_LPCBYTE pSrcLine = NULL; |
| 1191 if (m_pCachedBitmap) { | 1186 if (m_pCachedBitmap) { |
| 1192 pSrcLine = m_pCachedBitmap->GetScanline(line); | 1187 pSrcLine = m_pCachedBitmap->GetScanline(line); |
| 1193 } else if (m_pDecoder) { | 1188 } else if (m_pDecoder) { |
| 1194 pSrcLine = m_pDecoder->GetScanline(line); | 1189 pSrcLine = m_pDecoder->GetScanline(line); |
| 1195 } else { | 1190 } else { |
| 1191 FX_DWORD src_pitch = pitch.ValueOrDie(); | |
| 1192 pitch *= (line+1); | |
|
Tom Sepez
2014/07/25 21:13:51
do you mean src_pitch *= (line + 1)
jun_fang
2014/07/30 22:27:01
at line 1196 of left code (OLD), there is (line +
| |
| 1193 if (!pitch.IsValid()) { | |
|
Tom Sepez
2014/07/25 21:13:51
ditto
| |
| 1194 return; | |
| 1195 } | |
| 1196 | |
| 1196 if (m_pStreamAcc->GetSize() >= (line + 1) * src_pitch) { | 1197 if (m_pStreamAcc->GetSize() >= (line + 1) * src_pitch) { |
|
Tom Sepez
2014/07/25 21:13:51
didn't we just do the (line +1) multiplication abo
jun_fang
2014/07/30 22:27:01
Will update it in the next patch.
| |
| 1197 pSrcLine = m_pStreamAcc->GetData() + line * src_pitch; | 1198 pSrcLine = m_pStreamAcc->GetData() + line * src_pitch; |
| 1198 } | 1199 } |
| 1199 } | 1200 } |
| 1200 int orig_Bpp = bpc * m_nComponents / 8; | 1201 int orig_Bpp = bpc * m_nComponents / 8; |
| 1201 int dest_Bpp = dest_bpp / 8; | 1202 int dest_Bpp = dest_bpp / 8; |
| 1202 if (pSrcLine == NULL) { | 1203 if (pSrcLine == NULL) { |
| 1203 FXSYS_memset32(dest_scan, 0xff, dest_Bpp * clip_width); | 1204 FXSYS_memset32(dest_scan, 0xff, dest_Bpp * clip_width); |
| 1204 return; | 1205 return; |
| 1205 } | 1206 } |
| 1207 | |
| 1208 Int max_src_x = clip_left; | |
| 1209 max_src_x += clip_width - 1; | |
| 1210 max_src_x *= src_width; | |
| 1211 max_src_x /= dest_width; | |
| 1212 if (!max_src_x.IsValid()) { | |
| 1213 return; | |
| 1214 } | |
| 1215 | |
| 1206 CFX_FixedBufGrow<FX_BYTE, 128> temp(orig_Bpp); | 1216 CFX_FixedBufGrow<FX_BYTE, 128> temp(orig_Bpp); |
| 1207 if (bpc * m_nComponents == 1) { | 1217 if (bpc * m_nComponents == 1) { |
| 1208 FX_DWORD set_argb = (FX_DWORD) - 1, reset_argb = 0; | 1218 FX_DWORD set_argb = (FX_DWORD) - 1, reset_argb = 0; |
| 1209 if (m_bImageMask) { | 1219 if (m_bImageMask) { |
| 1210 if (m_bDefaultDecode) { | 1220 if (m_bDefaultDecode) { |
| 1211 set_argb = 0; | 1221 set_argb = 0; |
| 1212 reset_argb = (FX_DWORD) - 1; | 1222 reset_argb = (FX_DWORD) - 1; |
| 1213 } | 1223 } |
| 1214 } else if (m_bColorKey) { | 1224 } else if (m_bColorKey) { |
| 1215 reset_argb = m_pPalette ? m_pPalette[0] : 0xff000000; | 1225 reset_argb = m_pPalette ? m_pPalette[0] : 0xff000000; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1508 if (!m_bCached) { | 1518 if (!m_bCached) { |
| 1509 if (m_pBitmap) { | 1519 if (m_pBitmap) { |
| 1510 delete m_pBitmap; | 1520 delete m_pBitmap; |
| 1511 m_pBitmap = NULL; | 1521 m_pBitmap = NULL; |
| 1512 } | 1522 } |
| 1513 if (m_pMask) { | 1523 if (m_pMask) { |
| 1514 delete m_pMask; | 1524 delete m_pMask; |
| 1515 } | 1525 } |
| 1516 } | 1526 } |
| 1517 } | 1527 } |
| OLD | NEW |