From db444d2063df6c574882d9263e885c4fe1134133 Mon Sep 17 00:00:00 2001 From: weili Date: Thu, 2 Jun 2016 15:48:15 -0700 Subject: Fix all the code which has duplicate variable declarations When there are duplicate variable declarations, the inner names shadow the outter ones. This is error prone and harder to read. Remove all the instances found by /analyze. BUG=chromium:613623, chromium:427616 Review-Url: https://codereview.chromium.org/2027273002 --- core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 6 +- core/fpdfapi/fpdf_font/cpdf_cidfont.cpp | 19 ++-- core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 35 ++----- core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp | 38 +++----- core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp | 14 ++- core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 11 +-- core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 6 +- core/fpdfdoc/doc_annot.cpp | 4 +- core/fpdftext/fpdf_text_int.cpp | 21 ++-- core/fxcodec/codec/fx_codec_fax.cpp | 10 +- core/fxge/dib/fx_dib_composite.cpp | 107 +++++++++------------ core/fxge/dib/fx_dib_convert.cpp | 7 +- core/fxge/dib/fx_dib_transform.cpp | 2 +- core/fxge/ge/fx_ge_device.cpp | 4 +- 14 files changed, 117 insertions(+), 167 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 994c1c8a5a..0a833a4835 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -779,11 +779,11 @@ FX_BOOL CPDF_XRefStream::GenerateXRefStream(CPDF_Creator* pCreator, FX_CHAR offset_buf[20]; FXSYS_memset(offset_buf, 0, sizeof(offset_buf)); FXSYS_i64toa(m_PrevOffset, offset_buf, 10); - int32_t len = (int32_t)FXSYS_strlen(offset_buf); - if (pFile->AppendBlock(offset_buf, len) < 0) { + int32_t offset_len = (int32_t)FXSYS_strlen(offset_buf); + if (pFile->AppendBlock(offset_buf, offset_len) < 0) { return FALSE; } - offset += len + 6; + offset += offset_len + 6; } FX_BOOL bPredictor = TRUE; CPDF_FlateEncoder encoder(m_Buffer.GetBuffer(), m_Buffer.GetLength(), TRUE, diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp index cde28fd534..194db8b25c 100644 --- a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp @@ -682,17 +682,17 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph) { if (!name) { return charcode == 0 ? -1 : (int)charcode; } - uint16_t unicode = PDF_UnicodeFromAdobeName(name); - if (unicode) { + uint16_t name_unicode = PDF_UnicodeFromAdobeName(name); + if (name_unicode) { if (bMSUnicode) { - index = FXFT_Get_Char_Index(face, unicode); + index = FXFT_Get_Char_Index(face, name_unicode); } else if (bMacRoman) { uint32_t maccode = - FT_CharCodeFromUnicode(FXFT_ENCODING_APPLE_ROMAN, unicode); + FT_CharCodeFromUnicode(FXFT_ENCODING_APPLE_ROMAN, name_unicode); index = !maccode ? FXFT_Get_Name_Index(face, (char*)name) : FXFT_Get_Char_Index(face, maccode); } else { - return FXFT_Get_Char_Index(face, unicode); + return FXFT_Get_Char_Index(face, name_unicode); } } else { return charcode == 0 ? -1 : (int)charcode; @@ -815,16 +815,15 @@ void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, if (!pObj) continue; - if (CPDF_Array* pArray = pObj->AsArray()) { + if (CPDF_Array* pObjArray = pObj->AsArray()) { if (width_status != 1) return; - for (size_t j = 0; j < pArray->GetCount(); j += nElements) { + for (size_t j = 0; j < pObjArray->GetCount(); j += nElements) { result.Add(first_code); result.Add(first_code); - for (int k = 0; k < nElements; k++) { - result.Add(pArray->GetIntegerAt(j + k)); - } + for (int k = 0; k < nElements; k++) + result.Add(pObjArray->GetIntegerAt(j + k)); first_code++; } width_status = 0; diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 52576043e3..4bd4a4d529 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -1139,31 +1139,16 @@ void CPDF_StreamContentParser::Handle_SetFont() { CPDF_Object* CPDF_StreamContentParser::FindResourceObj( const CFX_ByteString& type, const CFX_ByteString& name) { - if (!m_pResources) { - return NULL; - } - if (m_pResources == m_pPageResources) { - CPDF_Dictionary* pList = m_pResources->GetDictBy(type); - if (!pList) { - return NULL; - } - CPDF_Object* pRes = pList->GetDirectObjectBy(name); - return pRes; - } - CPDF_Dictionary* pList = m_pResources->GetDictBy(type); - if (!pList) { - if (!m_pPageResources) { - return NULL; - } - CPDF_Dictionary* pList = m_pPageResources->GetDictBy(type); - if (!pList) { - return NULL; - } - CPDF_Object* pRes = pList->GetDirectObjectBy(name); - return pRes; - } - CPDF_Object* pRes = pList->GetDirectObjectBy(name); - return pRes; + if (!m_pResources) + return nullptr; + CPDF_Dictionary* pDict = m_pResources->GetDictBy(type); + if (pDict) + return pDict->GetDirectObjectBy(name); + if (m_pResources == m_pPageResources || !m_pPageResources) + return nullptr; + + CPDF_Dictionary* pPageDict = m_pPageResources->GetDictBy(type); + return pPageDict ? pPageDict->GetDirectObjectBy(name) : nullptr; } CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) { diff --git a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp index 054266765a..a4629dcf6b 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp @@ -430,10 +430,9 @@ FX_BOOL CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password, FXSYS_memset(test, 0, sizeof(test)); FXSYS_memset(tmpkey, 0, sizeof(tmpkey)); FXSYS_memcpy(test, ukey.c_str(), copy_len); - for (int i = 19; i >= 0; i--) { - for (int j = 0; j < key_len; j++) { - tmpkey[j] = key[j] ^ i; - } + for (int32_t i = 19; i >= 0; i--) { + for (int j = 0; j < key_len; j++) + tmpkey[j] = key[j] ^ static_cast(i); CRYPT_ArcFourCryptBlock(test, 32, tmpkey, key_len); } uint8_t md5[100]; @@ -457,14 +456,13 @@ CFX_ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass, int32_t key_len) { CFX_ByteString okey = m_pEncryptDict->GetStringBy("O"); uint8_t passcode[32]; - uint32_t i; - for (i = 0; i < 32; i++) { + for (uint32_t i = 0; i < 32; i++) { passcode[i] = i < pass_size ? owner_pass[i] : defpasscode[i - pass_size]; } uint8_t digest[16]; CRYPT_MD5Generate(passcode, 32, digest); if (m_Revision >= 3) { - for (int i = 0; i < 50; i++) { + for (uint32_t i = 0; i < 50; i++) { CRYPT_MD5Generate(digest, 16, digest); } } @@ -485,12 +483,11 @@ CFX_ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass, if (m_Revision == 2) { CRYPT_ArcFourCryptBlock(okeybuf, okeylen, enckey, key_len); } else { - for (int i = 19; i >= 0; i--) { + for (int32_t i = 19; i >= 0; i--) { uint8_t tempkey[32]; FXSYS_memset(tempkey, 0, sizeof(tempkey)); - for (int j = 0; j < m_KeyLen; j++) { - tempkey[j] = enckey[j] ^ i; - } + for (int j = 0; j < m_KeyLen; j++) + tempkey[j] = enckey[j] ^ static_cast(i); CRYPT_ArcFourCryptBlock(okeybuf, okeylen, tempkey, key_len); } } @@ -553,30 +550,27 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, } if (bDefault) { uint8_t passcode[32]; - uint32_t i; - for (i = 0; i < 32; i++) { + for (uint32_t i = 0; i < 32; i++) { passcode[i] = i < owner_size ? owner_pass[i] : defpasscode[i - owner_size]; } uint8_t digest[16]; CRYPT_MD5Generate(passcode, 32, digest); if (m_Revision >= 3) { - for (int i = 0; i < 50; i++) { + for (uint32_t i = 0; i < 50; i++) CRYPT_MD5Generate(digest, 16, digest); - } } uint8_t enckey[32]; FXSYS_memcpy(enckey, digest, key_len); - for (i = 0; i < 32; i++) { + for (uint32_t i = 0; i < 32; i++) { passcode[i] = i < user_size ? user_pass[i] : defpasscode[i - user_size]; } CRYPT_ArcFourCryptBlock(passcode, 32, enckey, key_len); uint8_t tempkey[32]; if (m_Revision >= 3) { - for (i = 1; i <= 19; i++) { - for (int j = 0; j < key_len; j++) { - tempkey[j] = enckey[j] ^ (uint8_t)i; - } + for (uint8_t i = 1; i <= 19; i++) { + for (int j = 0; j < key_len; j++) + tempkey[j] = enckey[j] ^ i; CRYPT_ArcFourCryptBlock(passcode, 32, tempkey, key_len); } } @@ -601,9 +595,9 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CRYPT_MD5Finish(md5, digest); CRYPT_ArcFourCryptBlock(digest, 16, m_EncryptKey, key_len); uint8_t tempkey[32]; - for (int i = 1; i <= 19; i++) { + for (uint8_t i = 1; i <= 19; i++) { for (int j = 0; j < key_len; j++) { - tempkey[j] = m_EncryptKey[j] ^ (uint8_t)i; + tempkey[j] = m_EncryptKey[j] ^ i; } CRYPT_ArcFourCryptBlock(digest, 16, tempkey, key_len); } diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp index 13a9972425..0eeb4a1afa 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp @@ -381,7 +381,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) return nullptr; - FX_FILESIZE SavedPos = m_Pos; + FX_FILESIZE SavedObjPos = m_Pos; bool bIsNumber; CFX_ByteString word = GetNextWord(&bIsNumber); if (word.GetLength() == 0) @@ -392,10 +392,8 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, CFX_ByteString nextword = GetNextWord(&bIsNumber); if (bIsNumber) { CFX_ByteString nextword2 = GetNextWord(nullptr); - if (nextword2 == "R") { - uint32_t objnum = FXSYS_atoui(word.c_str()); - return new CPDF_Reference(pObjList, objnum); - } + if (nextword2 == "R") + return new CPDF_Reference(pObjList, FXSYS_atoui(word.c_str())); } m_Pos = SavedPos; return new CPDF_Number(word.AsStringC()); @@ -492,7 +490,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, } if (word == ">>") - m_Pos = SavedPos; + m_Pos = SavedObjPos; return nullptr; } @@ -505,7 +503,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) return nullptr; - FX_FILESIZE SavedPos = m_Pos; + FX_FILESIZE SavedObjPos = m_Pos; bool bIsNumber; CFX_ByteString word = GetNextWord(&bIsNumber); if (word.GetLength() == 0) @@ -605,7 +603,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( } if (word == ">>") - m_Pos = SavedPos; + m_Pos = SavedObjPos; return nullptr; } diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index e9f5a6d468..7c489a35dc 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -447,12 +447,11 @@ CFX_WideString PDF_DecodeText(const uint8_t* src_data, uint32_t src_len) { if (unicode == 0x1b) { i += 2; while (i < max_chars * 2) { - uint16_t unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) - : (uni_str[i + 1] << 8 | uni_str[i]); + uint16_t unicode2 = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) + : (uni_str[i + 1] << 8 | uni_str[i]); i += 2; - if (unicode == 0x1b) { + if (unicode2 == 0x1b) break; - } } } else { dest_buf[dest_pos++] = unicode; @@ -506,9 +505,9 @@ CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len) { dest_buf2[0] = 0xfe; dest_buf2[1] = 0xff; dest_buf2 += 2; - for (int i = 0; i < len; i++) { + for (int j = 0; j < len; j++) { *dest_buf2++ = pString[i] >> 8; - *dest_buf2++ = (uint8_t)pString[i]; + *dest_buf2++ = (uint8_t)pString[j]; } result.ReleaseBuffer(encLen); return result; diff --git a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 75f6a231a4..4071a115df 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -381,7 +381,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) { } return ret1; } - FXCODEC_STATUS ret = pJbig2Module->ContinueDecode(m_pJbig2Context, pPause); + ret = pJbig2Module->ContinueDecode(m_pJbig2Context, pPause); if (ret < 0) { m_pCachedBitmap.reset(); m_pGlobalStream.reset(); @@ -864,8 +864,8 @@ void CPDF_DIBSource::LoadPalette() { m_pColorSpace->CountComponents() > 1) { int nComponents = m_pColorSpace->CountComponents(); std::vector temp_buf(nComponents); - for (int i = 0; i < nComponents; i++) { - temp_buf[i] = *color_value; + for (int k = 0; k < nComponents; k++) { + temp_buf[k] = *color_value; } m_pColorSpace->GetRGB(temp_buf.data(), R, G, B); } else { diff --git a/core/fpdfdoc/doc_annot.cpp b/core/fpdfdoc/doc_annot.cpp index db0322c768..f8bad07ceb 100644 --- a/core/fpdfdoc/doc_annot.cpp +++ b/core/fpdfdoc/doc_annot.cpp @@ -179,8 +179,8 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, if (as.IsEmpty()) { CFX_ByteString value = pAnnotDict->GetStringBy("V"); if (value.IsEmpty()) { - CPDF_Dictionary* pDict = pAnnotDict->GetDictBy("Parent"); - value = pDict ? pDict->GetStringBy("V") : CFX_ByteString(); + CPDF_Dictionary* pParentDict = pAnnotDict->GetDictBy("Parent"); + value = pParentDict ? pParentDict->GetStringBy("V") : CFX_ByteString(); } if (value.IsEmpty() || !pDict->KeyExist(value)) as = "Off"; diff --git a/core/fpdftext/fpdf_text_int.cpp b/core/fpdftext/fpdf_text_int.cpp index 136c44b5ed..1f8ab75e85 100644 --- a/core/fpdftext/fpdf_text_int.cpp +++ b/core/fpdftext/fpdf_text_int.cpp @@ -988,19 +988,16 @@ void CPDF_TextPage::ProcessTextObject( } int i = 0; for (i = count - 1; i >= 0; i--) { - PDFTEXT_Obj prev_Obj = m_LineObj.GetAt(i); - CFX_Matrix prev_matrix; - prev_Obj.m_pTextObj->GetTextMatrix(&prev_matrix); - FX_FLOAT Prev_x = prev_Obj.m_pTextObj->GetPosX(), - Prev_y = prev_Obj.m_pTextObj->GetPosY(); - prev_Obj.m_formMatrix.Transform(Prev_x, Prev_y); + PDFTEXT_Obj prev_text_obj = m_LineObj.GetAt(i); + FX_FLOAT Prev_x = prev_text_obj.m_pTextObj->GetPosX(), + Prev_y = prev_text_obj.m_pTextObj->GetPosY(); + prev_text_obj.m_formMatrix.Transform(Prev_x, Prev_y); m_DisplayMatrix.Transform(Prev_x, Prev_y); if (this_x >= Prev_x) { - if (i == count - 1) { + if (i == count - 1) m_LineObj.Add(Obj); - } else { + else m_LineObj.InsertAt(i + 1, Obj); - } break; } } @@ -1611,9 +1608,9 @@ int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj, if (re.Contains(pObj->GetPosX(), pObj->GetPosY())) { bNewline = FALSE; } else { - CFX_FloatRect re(0, pObj->m_Bottom, 1000, pObj->m_Top); - if (re.Contains(m_pPreTextObj->GetPosX(), - m_pPreTextObj->GetPosY())) { + CFX_FloatRect rect(0, pObj->m_Bottom, 1000, pObj->m_Top); + if (rect.Contains(m_pPreTextObj->GetPosX(), + m_pPreTextObj->GetPosY())) { bNewline = FALSE; } } diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 97b7ee2ad6..59010391c5 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -359,16 +359,16 @@ FX_BOOL FaxG4GetRow(const uint8_t* src_buf, if (bitpos >= bitsize) { return FALSE; } - FX_BOOL bit1 = NEXTBIT; + FX_BOOL next_bit1 = NEXTBIT; if (bitpos >= bitsize) { return FALSE; } - FX_BOOL bit2 = NEXTBIT; - if (bit1 && bit2) { + FX_BOOL next_bit2 = NEXTBIT; + if (next_bit1 && next_bit2) { v_delta = 2; - } else if (bit1) { + } else if (next_bit1) { v_delta = -2; - } else if (bit2) { + } else if (next_bit2) { if (bitpos >= bitsize) { return FALSE; } diff --git a/core/fxge/dib/fx_dib_composite.cpp b/core/fxge/dib/fx_dib_composite.cpp index 282b93d6da..28f6e49044 100644 --- a/core/fxge/dib/fx_dib_composite.cpp +++ b/core/fxge/dib/fx_dib_composite.cpp @@ -2512,11 +2512,10 @@ void CompositeRow_ByteMask2Argb(uint8_t* dest_scan, int alpha_ratio = src_alpha * 255 / dest_alpha; if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { int blended_colors[3]; - uint8_t src_scan[3]; - src_scan[0] = src_b; - src_scan[1] = src_g; - src_scan[2] = src_r; - RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); + uint8_t scan[3] = {static_cast(src_b), + static_cast(src_g), + static_cast(src_r)}; + RGB_Blend(blend_type, scan, dest_scan, blended_colors); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_ratio); dest_scan++; @@ -2583,11 +2582,10 @@ void CompositeRow_ByteMask2Rgba(uint8_t* dest_scan, int alpha_ratio = src_alpha * 255 / dest_alpha; if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { int blended_colors[3]; - uint8_t src_scan[3]; - src_scan[0] = src_b; - src_scan[1] = src_g; - src_scan[2] = src_r; - RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); + uint8_t scan[3] = {static_cast(src_b), + static_cast(src_g), + static_cast(src_r)}; + RGB_Blend(blend_type, scan, dest_scan, blended_colors); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_ratio); dest_scan++; @@ -2644,11 +2642,10 @@ void CompositeRow_ByteMask2Rgb(uint8_t* dest_scan, } if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { int blended_colors[3]; - uint8_t src_scan[3]; - src_scan[0] = src_b; - src_scan[1] = src_g; - src_scan[2] = src_r; - RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); + uint8_t scan[3] = {static_cast(src_b), + static_cast(src_g), + static_cast(src_r)}; + RGB_Blend(blend_type, scan, dest_scan, blended_colors); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], src_alpha); dest_scan++; *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], src_alpha); @@ -2791,11 +2788,10 @@ void CompositeRow_BitMask2Argb(uint8_t* dest_scan, int alpha_ratio = src_alpha * 255 / dest_alpha; if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { int blended_colors[3]; - uint8_t src_scan[3]; - src_scan[0] = src_b; - src_scan[1] = src_g; - src_scan[2] = src_r; - RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); + uint8_t scan[3] = {static_cast(src_b), + static_cast(src_g), + static_cast(src_r)}; + RGB_Blend(blend_type, scan, dest_scan, blended_colors); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_ratio); dest_scan++; @@ -2866,11 +2862,10 @@ void CompositeRow_BitMask2Rgb(uint8_t* dest_scan, } if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { int blended_colors[3]; - uint8_t src_scan[3]; - src_scan[0] = src_b; - src_scan[1] = src_g; - src_scan[2] = src_r; - RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); + uint8_t scan[3] = {static_cast(src_b), + static_cast(src_g), + static_cast(src_r)}; + RGB_Blend(blend_type, scan, dest_scan, blended_colors); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], src_alpha); dest_scan++; *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], src_alpha); @@ -3584,15 +3579,11 @@ void CompositeRow_ByteMask2Argb_RgbByteOrder(uint8_t* dest_scan, int alpha_ratio = src_alpha * 255 / dest_alpha; if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { int blended_colors[3]; - uint8_t src_scan[3]; - uint8_t dest_scan_o[3]; - src_scan[0] = src_b; - src_scan[1] = src_g; - src_scan[2] = src_r; - dest_scan_o[0] = dest_scan[2]; - dest_scan_o[1] = dest_scan[1]; - dest_scan_o[2] = dest_scan[0]; - RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); + uint8_t scan[3] = {static_cast(src_b), + static_cast(src_g), + static_cast(src_r)}; + uint8_t dest_scan_o[3] = {dest_scan[2], dest_scan[1], dest_scan[0]}; + RGB_Blend(blend_type, scan, dest_scan_o, blended_colors); dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], alpha_ratio); dest_scan[1] = @@ -3641,15 +3632,11 @@ void CompositeRow_ByteMask2Rgb_RgbByteOrder(uint8_t* dest_scan, } if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { int blended_colors[3]; - uint8_t src_scan[3]; - uint8_t dest_scan_o[3]; - src_scan[0] = src_b; - src_scan[1] = src_g; - src_scan[2] = src_r; - dest_scan_o[0] = dest_scan[2]; - dest_scan_o[1] = dest_scan[1]; - dest_scan_o[2] = dest_scan[0]; - RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); + uint8_t scan[3] = {static_cast(src_b), + static_cast(src_g), + static_cast(src_r)}; + uint8_t dest_scan_o[3] = {dest_scan[2], dest_scan[1], dest_scan[0]}; + RGB_Blend(blend_type, scan, dest_scan_o, blended_colors); dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], src_alpha); dest_scan[1] = @@ -3715,15 +3702,11 @@ void CompositeRow_BitMask2Argb_RgbByteOrder(uint8_t* dest_scan, int alpha_ratio = src_alpha * 255 / dest_alpha; if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { int blended_colors[3]; - uint8_t src_scan[3]; - uint8_t dest_scan_o[3]; - src_scan[0] = src_b; - src_scan[1] = src_g; - src_scan[2] = src_r; - dest_scan_o[0] = dest_scan[2]; - dest_scan_o[1] = dest_scan[1]; - dest_scan_o[2] = dest_scan[0]; - RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); + uint8_t scan[3] = {static_cast(src_b), + static_cast(src_g), + static_cast(src_r)}; + uint8_t dest_scan_o[3] = {dest_scan[2], dest_scan[1], dest_scan[0]}; + RGB_Blend(blend_type, scan, dest_scan_o, blended_colors); dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], alpha_ratio); dest_scan[1] = @@ -3788,15 +3771,11 @@ void CompositeRow_BitMask2Rgb_RgbByteOrder(uint8_t* dest_scan, } if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { int blended_colors[3]; - uint8_t src_scan[3]; - uint8_t dest_scan_o[3]; - src_scan[0] = src_b; - src_scan[1] = src_g; - src_scan[2] = src_r; - dest_scan_o[0] = dest_scan[2]; - dest_scan_o[1] = dest_scan[1]; - dest_scan_o[2] = dest_scan[0]; - RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); + uint8_t scan[3] = {static_cast(src_b), + static_cast(src_g), + static_cast(src_r)}; + uint8_t dest_scan_o[3] = {dest_scan[2], dest_scan[1], dest_scan[0]}; + RGB_Blend(blend_type, scan, dest_scan_o, blended_colors); dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], src_alpha); dest_scan[1] = @@ -4710,7 +4689,7 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left, ASSERT(!IsCmykImage() && (uint8_t)(alpha_flag >> 8) == 0); int left_shift = rect.left % 8; int right_shift = rect.right % 8; - int width = rect.right / 8 - rect.left / 8; + int new_width = rect.right / 8 - rect.left / 8; int index = 0; if (m_pPalette) { for (int i = 0; i < 2; i++) { @@ -4726,8 +4705,8 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left, uint8_t* dest_scan_top_r = (uint8_t*)GetScanline(row) + rect.right / 8; uint8_t left_flag = *dest_scan_top & (255 << (8 - left_shift)); uint8_t right_flag = *dest_scan_top_r & (255 >> right_shift); - if (width) { - FXSYS_memset(dest_scan_top + 1, index ? 255 : 0, width - 1); + if (new_width) { + FXSYS_memset(dest_scan_top + 1, index ? 255 : 0, new_width - 1); if (!index) { *dest_scan_top &= left_flag; *dest_scan_top_r &= right_flag; diff --git a/core/fxge/dib/fx_dib_convert.cpp b/core/fxge/dib/fx_dib_convert.cpp index da380ee567..8937816531 100644 --- a/core/fxge/dib/fx_dib_convert.cpp +++ b/core/fxge/dib/fx_dib_convert.cpp @@ -433,7 +433,6 @@ FX_BOOL ConvertBuffer_Rgb2PltRgb8_NoTransform(uint8_t* dest_buf, int src_top, uint32_t* dst_plt) { int bpp = pSrcBitmap->GetBPP() / 8; - int row, col; CFX_Palette palette; palette.BuildPalette(pSrcBitmap); uint32_t* cLut = palette.GetColorLut(); @@ -446,7 +445,7 @@ FX_BOOL ConvertBuffer_Rgb2PltRgb8_NoTransform(uint8_t* dest_buf, if (lut > 256) { int err, min_err; int lut_256 = lut - 256; - for (row = 0; row < lut_256; row++) { + for (int row = 0; row < lut_256; row++) { min_err = 1000000; uint8_t r, g, b; _ColorDecode(cLut[row], r, g, b); @@ -466,11 +465,11 @@ FX_BOOL ConvertBuffer_Rgb2PltRgb8_NoTransform(uint8_t* dest_buf, } } int32_t lut_1 = lut - 1; - for (row = 0; row < height; row++) { + for (int row = 0; row < height; row++) { uint8_t* src_scan = (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left; uint8_t* dest_scan = dest_buf + row * dest_pitch; - for (col = 0; col < width; col++) { + for (int col = 0; col < width; col++) { uint8_t* src_port = src_scan + col * bpp; int r = src_port[2] & 0xf0; int g = src_port[1] & 0xf0; diff --git a/core/fxge/dib/fx_dib_transform.cpp b/core/fxge/dib/fx_dib_transform.cpp index f9b4250deb..914ca58013 100644 --- a/core/fxge/dib/fx_dib_transform.cpp +++ b/core/fxge/dib/fx_dib_transform.cpp @@ -624,7 +624,6 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) { } } else { int Bpp = m_Storer.GetBitmap()->GetBPP() / 8; - int destBpp = pTransformed->GetBPP() / 8; if (Bpp == 1) { uint32_t argb[256]; FX_ARGB* pPal = m_Storer.GetBitmap()->GetPalette(); @@ -643,6 +642,7 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) { } } } + int destBpp = pTransformed->GetBPP() / 8; if (!(m_Flags & FXDIB_DOWNSAMPLE) && !(m_Flags & FXDIB_BICUBIC_INTERPOL)) { CFX_BilinearMatrix result2stretch_fix(result2stretch, 8); diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp index b9bd133e57..96e0e55cd1 100644 --- a/core/fxge/ge/fx_ge_device.cpp +++ b/core/fxge/ge/fx_ge_device.cpp @@ -388,8 +388,8 @@ FX_BOOL CFX_RenderDevice::SetDIBitsWithBlend(const CFX_DIBSource* pBitmap, blend_mode, nullptr, FALSE, nullptr)) { return FALSE; } - FX_RECT src_rect(0, 0, bg_pixel_width, bg_pixel_height); - return m_pDeviceDriver->SetDIBits(&background, 0, &src_rect, dest_rect.left, + FX_RECT rect(0, 0, bg_pixel_width, bg_pixel_height); + return m_pDeviceDriver->SetDIBits(&background, 0, &rect, dest_rect.left, dest_rect.top, FXDIB_BLEND_NORMAL); } return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, -- cgit v1.2.3