diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-07-23 14:42:09 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-07-23 14:42:09 -0700 |
commit | 2f2ffece124e4ed4b96d2846263015d4b5ad6c00 (patch) | |
tree | 6966e44279e8d9e1516b7c71219cf66f77a89ca2 /core/src | |
parent | d07958fd2d1c4134d865f4ccb056eb925aaa7d2a (diff) | |
download | pdfium-2f2ffece124e4ed4b96d2846263015d4b5ad6c00.tar.xz |
Merge to XFA - else after returns.
(cherry picked from commit 3c012fef2bb72c8ec1faa73e11ee35539b2559d6)
Original Review URL: https://codereview.chromium.org/1243953004 .
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1239313005 .
Diffstat (limited to 'core/src')
52 files changed, 2188 insertions, 2371 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index 2db8d6095f..e09297fc8d 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -521,7 +521,8 @@ static FX_WORD FX_GetCsFromLangCode(uint32_t uCode) const FX_LANG2CS &charset = gs_FXLang2CharsetTable[iMid]; if (uCode == charset.uLang) { return charset.uCharset; - } else if (uCode < charset.uLang) { + } + if (uCode < charset.uLang) { iEnd = iMid - 1; } else { iStart = iMid + 1; diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp index 9ed5d8ff1c..8037a8c674 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp @@ -555,13 +555,12 @@ static FX_DWORD _StringToCode(const CFX_ByteStringC& str) result = result * 16 + digit; } return result; - } else { - for (int i = 0; i < len; i ++) { - if (buf[i] < '0' || buf[i] > '9') { - break; - } - result = result * 10 + buf[i] - '0'; + } + for (int i = 0; i < len; i ++) { + if (buf[i] < '0' || buf[i] > '9') { + break; } + result = result * 10 + buf[i] - '0'; } return result; } diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp index 7a01bba97a..f70b9ecfc4 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -641,22 +641,23 @@ int CPDF_CMap::AppendChar(FX_CHAR* str, FX_DWORD charcode) const } str[iSize - 1] = (uint8_t)charcode; return iSize; - } else if (charcode < 0x10000) { + } + if (charcode < 0x10000) { str[0] = (uint8_t)(charcode >> 8); str[1] = (uint8_t)charcode; return 2; - } else if (charcode < 0x1000000) { + } + if (charcode < 0x1000000) { str[0] = (uint8_t)(charcode >> 16); str[1] = (uint8_t)(charcode >> 8); str[2] = (uint8_t)charcode; return 3; - } else { - str[0] = (uint8_t)(charcode >> 24); - str[1] = (uint8_t)(charcode >> 16); - str[2] = (uint8_t)(charcode >> 8); - str[3] = (uint8_t)charcode; - return 4; } + str[0] = (uint8_t)(charcode >> 24); + str[1] = (uint8_t)(charcode >> 16); + str[2] = (uint8_t)(charcode >> 8); + str[3] = (uint8_t)charcode; + return 4; } return 0; } @@ -794,9 +795,8 @@ FX_WCHAR CPDF_CIDFont::_UnicodeFromCharCode(FX_DWORD charcode) const #endif if (m_pCMap->m_pEmbedMap) { return _EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, charcode); - } else { - return 0; } + return 0; } return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode)); } @@ -826,7 +826,8 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const if (unicode < 0x80) { return static_cast<FX_DWORD>(unicode); - } else if (m_pCMap->m_Coding == CIDCODING_CID) { + } + if (m_pCMap->m_Coding == CIDCODING_CID) { return 0; } #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ @@ -834,14 +835,15 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const int ret = FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, (char*)buffer, 4, NULL, NULL); if (ret == 1) { return buffer[0]; - } else if (ret == 2) { + } + if (ret == 2) { return buffer[0] * 256 + buffer[1]; } - return 0; -#endif +#else if (m_pCMap->m_pEmbedMap) { return _EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, unicode); } +#endif return 0; } static void FT_UseCIDCharmap(FXFT_Face face, int coding) @@ -1234,9 +1236,8 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) } if (index == 0 || index == 0xffff) { return charcode == 0 ? -1 : (int)charcode; - } else { - return index; } + return index; } if (m_Charset == CIDSET_JAPAN1) { if (unicode == '\\') { diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp index db3966ec17..c0cdb228f4 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp @@ -754,18 +754,17 @@ void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) } int CPDF_PageObjects::EstimateParseProgress() const { - if (m_pParser == NULL) { + if (!m_pParser) { return m_ParseState == PDF_CONTENT_PARSED ? 100 : 0; } return m_pParser->EstimateProgress(); } FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, CPDF_PageObject* pNewObject) { - if (posInsertAfter == NULL) { + if (!posInsertAfter) { return m_ObjectList.AddHead(pNewObject); - } else { - return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); } + return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); } int CPDF_PageObjects::GetObjectIndex(CPDF_PageObject* pObj) const { diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp index 101a197968..198054ef7e 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -103,14 +103,15 @@ FX_BOOL CPDF_DeviceCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B pBuf[1] = G; pBuf[2] = B; return TRUE; - } else if (m_Family == PDFCS_DEVICEGRAY) { + } + if (m_Family == PDFCS_DEVICEGRAY) { if (R == G && R == B) { *pBuf = R; return TRUE; - } else { - return FALSE; } - } else if (m_Family == PDFCS_DEVICECMYK) { + return FALSE; + } + if (m_Family == PDFCS_DEVICECMYK) { sRGB_to_AdobeCMYK(R, G, B, pBuf[0], pBuf[1], pBuf[2], pBuf[3]); return TRUE; } @@ -121,9 +122,8 @@ FX_BOOL CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOA if (m_Family == PDFCS_DEVICERGB) { AdobeCMYK_to_sRGB(c, m, y, k, pBuf[0], pBuf[1], pBuf[2]); return TRUE; - } else if (m_Family == PDFCS_DEVICEGRAY) { - return FALSE; - } else if (m_Family == PDFCS_DEVICECMYK) { + } + if (m_Family == PDFCS_DEVICECMYK) { pBuf[0] = c; pBuf[1] = m; pBuf[2] = y; @@ -314,9 +314,8 @@ FX_BOOL CPDF_CalGray::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) if (R == G && R == B) { *pBuf = R; return TRUE; - } else { - return FALSE; } + return FALSE; } void CPDF_CalGray::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const { @@ -993,10 +992,9 @@ FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_F if (m_pAltCS) { m_pAltCS->GetRGB(results, R, G, B); return TRUE; - } else { - R = G = B = 0; - return FALSE; } + R = G = B = 0; + return FALSE; } void CPDF_SeparationCS::EnableStdConversion(FX_BOOL bEnabled) { diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 5b5703b868..892e2153b7 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -337,7 +337,8 @@ FX_BOOL CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) if (compare == 0) { (this->*g_OpCodes[middle].m_OpHandler)(); return TRUE; - } else if (compare < 0) { + } + if (compare < 0) { high = middle - 1; } else { low = middle + 1; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index ebd4d83310..37ffea9742 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -288,19 +288,25 @@ FX_DWORD PDF_DecodeInlineStream(const uint8_t* src_buf, FX_DWORD limit, if (decoder == FX_BSTRC("CCITTFaxDecode") || decoder == FX_BSTRC("CCF")) { ICodec_ScanlineDecoder* pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam); return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); - } else if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) { + } + if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) { return _A85Decode(src_buf, limit, dest_buf, dest_size); - } else if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) { + } + if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) { return _HexDecode(src_buf, limit, dest_buf, dest_size); - } else if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { + } + if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { return FPDFAPI_FlateOrLZWDecode(FALSE, src_buf, limit, pParam, dest_size, dest_buf, dest_size); - } else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { + } + if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { return FPDFAPI_FlateOrLZWDecode(TRUE, src_buf, limit, pParam, 0, dest_buf, dest_size); - } else if (decoder == FX_BSTRC("DCTDecode") || decoder == FX_BSTRC("DCT")) { + } + if (decoder == FX_BSTRC("DCTDecode") || decoder == FX_BSTRC("DCT")) { ICodec_ScanlineDecoder* pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( - src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BSTRC("ColorTransform"), 1) : 1); + src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BSTRC("ColorTransform"), 1) : 1); return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); - } else if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) { + } + if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) { return RunLengthDecode(src_buf, limit, dest_buf, dest_size); } dest_size = 0; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 9736c3dc8e..47c08fb4a3 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -311,9 +311,8 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dic dest_size = last_size; pImageParms = pParam; return TRUE; - } else { - offset = FPDFAPI_FlateOrLZWDecode(FALSE, last_buf, last_size, pParam, estimated_size, new_buf, new_size); } + offset = FPDFAPI_FlateOrLZWDecode(FALSE, last_buf, last_size, pParam, estimated_size, new_buf, new_size); } else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { offset = FPDFAPI_FlateOrLZWDecode(TRUE, last_buf, last_size, pParam, estimated_size, new_buf, new_size); } else if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp index 0471250fd9..f630ea52da 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp @@ -181,10 +181,9 @@ CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec) result += ':'; result += ChangeSlash(wsFileName.c_str() + 2); return result; - } else { - CFX_WideString result; - result += '\\'; - result += ChangeSlash(wsFileName.c_str()); - return result; } + CFX_WideString result; + result += '\\'; + result += ChangeSlash(wsFileName.c_str()); + return result; } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index 190cb2d0f1..8162fff297 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -160,8 +160,8 @@ CPDF_Array* CPDF_Object::GetArray() const { if (m_Type == PDFOBJ_ARRAY) return (CPDF_Array*)this; - else - return NULL; + + return NULL; } void CPDF_Object::SetString(const CFX_ByteString& str) { @@ -201,7 +201,8 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const if (pOther->m_Type != m_Type) { if (m_Type == PDFOBJ_REFERENCE && GetDirect()) { return GetDirect()->IsIdentical(pOther); - } else if (pOther->m_Type == PDFOBJ_REFERENCE) { + } + if (pOther->m_Type == PDFOBJ_REFERENCE) { return IsIdentical(pOther->GetDirect()); } return FALSE; @@ -285,27 +286,22 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visite CPDF_StreamAcc acc; acc.LoadAllData(pThis, TRUE); FX_DWORD streamSize = acc.GetSize(); - CPDF_Stream* pObj; - if (pThis->GetDict()) - pObj = new CPDF_Stream(acc.DetachData(), streamSize, (CPDF_Dictionary*)((CPDF_Object*)pThis->GetDict())->CloneInternal(bDirect, visited)); - else - pObj = new CPDF_Stream(acc.DetachData(), streamSize, NULL); - return pObj; + CPDF_Dictionary* pDict = pThis->GetDict(); + if (pDict) + pDict = (CPDF_Dictionary*)((CPDF_Object*)pDict)->CloneInternal(bDirect, visited); + return new CPDF_Stream(acc.DetachData(), streamSize, pDict); } case PDFOBJ_REFERENCE: { CPDF_Reference* pRef = (CPDF_Reference*)this; FX_DWORD obj_num = pRef->m_RefObjNum; if (bDirect && !visited->GetValueAt((void*)(uintptr_t)obj_num)) { visited->SetAt((void*)(uintptr_t)obj_num, (void*)1); - CPDF_Object* ret; - if (pRef->GetDirect()) - ret = pRef->GetDirect()->CloneInternal(TRUE, visited); - else - ret = NULL; - return ret; - } else { - return new CPDF_Reference(pRef->m_pObjList, obj_num); + if (!pRef->GetDirect()) + return nullptr; + + return pRef->GetDirect()->CloneInternal(TRUE, visited); } + return new CPDF_Reference(pRef->m_pObjList, obj_num); } } return NULL; @@ -321,12 +317,14 @@ CFX_WideString CPDF_Object::GetUnicodeText(CFX_CharMap* pCharMap) const { if (m_Type == PDFOBJ_STRING) { return PDF_DecodeText(((CPDF_String*)this)->m_String, pCharMap); - } else if (m_Type == PDFOBJ_STREAM) { + } + if (m_Type == PDFOBJ_STREAM) { CPDF_StreamAcc stream; stream.LoadAllData((CPDF_Stream*)this, FALSE); CFX_WideString result = PDF_DecodeText(stream.GetData(), stream.GetSize(), pCharMap); return result; - } else if (m_Type == PDFOBJ_NAME) { + } + if (m_Type == PDFOBJ_NAME) { return PDF_DecodeText(((CPDF_Name*)this)->m_Name, pCharMap); } return CFX_WideString(); @@ -427,8 +425,7 @@ CFX_ByteString CPDF_Array::GetString(FX_DWORD i) const CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i); return p->GetString(); } - else - return CFX_ByteString(); + return CFX_ByteString(); } CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const { @@ -436,8 +433,7 @@ CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i); return p->GetConstString(); } - else - return CFX_ByteStringC(); + return CFX_ByteStringC(); } int CPDF_Array::GetInteger(FX_DWORD i) const { @@ -458,11 +454,13 @@ FX_FLOAT CPDF_Array::GetNumber(FX_DWORD i) const CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const { CPDF_Object* p = GetElementValue(i); - if (p == NULL) { + if (!p) { return NULL; - } else if (p->GetType() == PDFOBJ_DICTIONARY) { + } + if (p->GetType() == PDFOBJ_DICTIONARY) { return (CPDF_Dictionary*)p; - } else if (p->GetType() == PDFOBJ_STREAM) { + } + if (p->GetType() == PDFOBJ_STREAM) { return ((CPDF_Stream*)p)->GetDict(); } return NULL; @@ -604,19 +602,19 @@ CFX_ByteString CPDF_Dictionary::GetString(const CFX_ByteStringC& key) const { CPDF_Object* p = NULL; m_Map.Lookup(key, (void*&)p); - if (p) + if (p) { return p->GetString(); - else - return CFX_ByteString(); + } + return CFX_ByteString(); } CFX_ByteStringC CPDF_Dictionary::GetConstString(const CFX_ByteStringC& key) const { CPDF_Object* p = NULL; m_Map.Lookup(key, (void*&)p); - if (p) + if (p) { return p->GetConstString(); - else - return CFX_ByteStringC(); + } + return CFX_ByteStringC(); } CFX_WideString CPDF_Dictionary::GetUnicodeText(const CFX_ByteStringC& key, CFX_CharMap* pCharMap) const { @@ -647,10 +645,10 @@ CFX_ByteStringC CPDF_Dictionary::GetConstString(const CFX_ByteStringC& key, cons { CPDF_Object* p = NULL; m_Map.Lookup(key, (void*&)p); - if (p) + if (p) { return p->GetConstString(); - else - return CFX_ByteStringC(def); + } + return CFX_ByteStringC(def); } int CPDF_Dictionary::GetInteger(const CFX_ByteStringC& key) const { @@ -691,14 +689,16 @@ FX_BOOL CPDF_Dictionary::GetBoolean(const CFX_ByteStringC& key, FX_BOOL bDefault CPDF_Dictionary* CPDF_Dictionary::GetDict(const CFX_ByteStringC& key) const { CPDF_Object* p = GetElementValue(key); - if (p == NULL) { - return NULL; - } else if (p->GetType() == PDFOBJ_DICTIONARY) { + if (!p) { + return nullptr; + } + if (p->GetType() == PDFOBJ_DICTIONARY) { return (CPDF_Dictionary*)p; - } else if (p->GetType() == PDFOBJ_STREAM) { + } + if (p->GetType() == PDFOBJ_STREAM) { return ((CPDF_Stream*)p)->GetDict(); } - return NULL; + return nullptr; } CPDF_Array* CPDF_Dictionary::GetArray(const CFX_ByteStringC& key) const { @@ -1270,12 +1270,11 @@ void CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, CPDF_Object* pO } void* value = NULL; if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { - if (value) - { - if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum()) + if (value) { + if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum()) { return; - else - ((CPDF_Object*)value)->Destroy(); + } + ((CPDF_Object*)value)->Destroy(); } } pObj->m_ObjNum = objnum; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index 5e673b0829..e4d3571eee 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -1997,21 +1997,16 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString() void CPDF_SyntaxParser::ToNextLine() { uint8_t ch; - while (1) { - if (!GetNextChar(ch)) { - return; - } + while (GetNextChar(ch)) { if (ch == '\n') { - return; + break; } if (ch == '\r') { GetNextChar(ch); - if (ch == '\n') { - return; - } else { - m_Pos --; - return; + if (ch != '\n') { + --m_Pos; } + break; } } } @@ -2083,24 +2078,14 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO if (bTypeOnly) { return (CPDF_Object*)PDFOBJ_REFERENCE; } - pRet = CPDF_Reference::Create(pObjList, objnum); - return pRet; - } else { - m_Pos = SavedPos; - if (bTypeOnly) { - return (CPDF_Object*)PDFOBJ_NUMBER; - } - pRet = CPDF_Number::Create(word); - return pRet; + return new CPDF_Reference(pObjList, objnum); } - } else { - m_Pos = SavedPos; - if (bTypeOnly) { - return (CPDF_Object*)PDFOBJ_NUMBER; - } - pRet = CPDF_Number::Create(word); - return pRet; } + m_Pos = SavedPos; + if (bTypeOnly) { + return (CPDF_Object*)PDFOBJ_NUMBER; + } + return CPDF_Number::Create(word); } if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { if (bTypeOnly) { @@ -2264,25 +2249,18 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList if (bIsNumber) { CFX_ByteString nextword2 = GetNextWord(bIsNumber); if (nextword2 == FX_BSTRC("R")) { - FX_DWORD objnum = FXSYS_atoi(word); if (bTypeOnly) { return (CPDF_Object*)PDFOBJ_REFERENCE; } - return CPDF_Reference::Create(pObjList, objnum); - } else { - m_Pos = SavedPos; - if (bTypeOnly) { - return (CPDF_Object*)PDFOBJ_NUMBER; - } - return CPDF_Number::Create(word); - } - } else { - m_Pos = SavedPos; - if (bTypeOnly) { - return (CPDF_Object*)PDFOBJ_NUMBER; + FX_DWORD objnum = FXSYS_atoi(word); + return new CPDF_Reference(pObjList, objnum); } - return CPDF_Number::Create(word); } + m_Pos = SavedPos; + if (bTypeOnly) { + return (CPDF_Object*)PDFOBJ_NUMBER; + } + return CPDF_Number::Create(word); } if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { if (bTypeOnly) { @@ -3152,21 +3130,20 @@ FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) m_objs_array.RemoveAll(); } return bRet; - } else { - CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - if (bRet) { - int32_t iSize = m_arrayAcroforms.GetSize(); - for (int32_t i = 0; i < iSize; ++i) { - ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release(); - } - m_arrayAcroforms.RemoveAll(); - } else { - m_objs_array.RemoveAll(); - m_objs_array.Append(new_objs_array); + } + CFX_PtrArray new_objs_array; + FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + if (bRet) { + int32_t iSize = m_arrayAcroforms.GetSize(); + for (int32_t i = 0; i < iSize; ++i) { + ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release(); } - return bRet; + m_arrayAcroforms.RemoveAll(); + } else { + m_objs_array.RemoveAll(); + m_objs_array.Append(new_objs_array); } + return bRet; } FX_BOOL CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints) { @@ -3220,16 +3197,14 @@ FX_BOOL CPDF_DataAvail::CheckDocStatus(IFX_DownloadHints *pHints) case PDF_DATAAVAIL_PAGETREE: if (m_bTotalLoadPageTree) { return CheckPages(pHints); - } else { - return LoadDocPages(pHints); } + return LoadDocPages(pHints); case PDF_DATAAVAIL_PAGE: if (m_bTotalLoadPageTree) { return CheckPage(pHints); - } else { - m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD; - return TRUE; } + m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD; + return TRUE; case PDF_DATAAVAIL_ERROR: return LoadAllFile(pHints); case PDF_DATAAVAIL_PAGE_LATERLOAD: @@ -3773,10 +3748,9 @@ FX_BOOL CPDF_DataAvail::CheckEnd(IFX_DownloadHints* pHints) SetStartOffset(m_dwXRefOffset); m_docStatus = PDF_DATAAVAIL_CROSSREF; return TRUE; - } else { - m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; } + m_docStatus = PDF_DATAAVAIL_LOADALLFILE; + return TRUE; } pHints->AddSegment(req_pos, dwSize); return FALSE; @@ -3811,9 +3785,6 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev")); pObj->Release(); return 1; - } else { - pObj->Release(); - return -1; } } pObj->Release(); @@ -3967,7 +3938,8 @@ FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(IFX_DownloadHints *pHints) m_Pos = xref_offset; } return TRUE; - } else if (nRet == -1) { + } + if (nRet == -1) { m_docStatus = PDF_DATAAVAIL_ERROR; } return FALSE; @@ -4070,11 +4042,10 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) } } return TRUE; - } else { - m_dwPrevXRefOffset = 0; - m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; - pTrailer->Release(); } + m_dwPrevXRefOffset = 0; + m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; + pTrailer->Release(); return TRUE; } pHints->AddSegment(m_Pos, iTrailerSize); @@ -4307,9 +4278,8 @@ FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints) if (CheckPageCount(pHints)) { m_docStatus = PDF_DATAAVAIL_PAGE; return TRUE; - } else { - m_bTotalLoadPageTree = TRUE; } + m_bTotalLoadPageTree = TRUE; return FALSE; } FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints) @@ -4375,15 +4345,14 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, IFX_DownloadHints* pHints m_objs_array.RemoveAll(); } return bRet; - } else { - CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - m_objs_array.RemoveAll(); - if (!bRet) { - m_objs_array.Append(new_objs_array); - } - return bRet; } + CFX_PtrArray new_objs_array; + FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + m_objs_array.RemoveAll(); + if (!bRet) { + m_objs_array.Append(new_objs_array); + } + return bRet; } FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHints* pHints) { @@ -4393,10 +4362,10 @@ FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHint } m_bAnnotsLoad = TRUE; } - if (m_bAnnotsLoad) - if (!CheckLinearizedData(pHints)) { + if (m_bAnnotsLoad) { + if (!CheckLinearizedData(pHints)) return FALSE; - } + } m_bPageLoadedOK = FALSE; return TRUE; } @@ -4551,15 +4520,14 @@ FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) m_objs_array.RemoveAll(); } return bRet; - } else { - CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - m_objs_array.RemoveAll(); - if (!bRet) { - m_objs_array.Append(new_objs_array); - } - return bRet; } + CFX_PtrArray new_objs_array; + FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + m_objs_array.RemoveAll(); + if (!bRet) { + m_objs_array.Append(new_objs_array); + } + return bRet; } void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize) { @@ -4616,16 +4584,15 @@ FX_BOOL CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum) } FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext) { - int32_t iLen = m_number_array.GetSize(); int32_t iLow = 0; - int32_t iHigh = iLen - 1; - int32_t iMid = 0; + int32_t iHigh = m_number_array.GetSize() - 1; while (iLow <= iHigh) { - iMid = (iLow + iHigh) / 2; + int32_t iMid = (iLow + iHigh) / 2; if (m_number_array.GetAt(iMid) == value) { iNext = iMid; return TRUE; - } else if (m_number_array.GetAt(iMid) > value) { + } + if (m_number_array.GetAt(iMid) > value) { iHigh = iMid - 1; } else if (m_number_array.GetAt(iMid) < value) { iLow = iMid + 1; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 6d425de6f8..4903312645 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -165,7 +165,8 @@ CFX_ByteStringC CPDF_SimpleParser::GetWord() m_dwCurPos ++; } return CFX_ByteStringC(pStart, (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData))); - } else if (dwSize == 1 && pStart[0] == '(') { + } + if (dwSize == 1 && pStart[0] == '(') { int level = 1; while (m_dwCurPos < m_dwSize) { if (m_pData[m_dwCurPos] == ')') { diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp index a894e846ee..19c01a102c 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp @@ -551,7 +551,8 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, FX_BOOL bTyp CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState; if (m_pType3Char && !bType3 && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored && (!pColorData || pColorData->m_FillColor.IsNull())))) { return m_T3FillColor; - } else if (!pColorData || pColorData->m_FillColor.IsNull()) { + } + if (!pColorData || pColorData->m_FillColor.IsNull()) { pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_InitialStates.m_ColorState; } FX_COLORREF rgb = pColorData->m_FillRGB; @@ -580,7 +581,8 @@ FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState; if (m_pType3Char && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored && (!pColorData || pColorData->m_StrokeColor.IsNull())))) { return m_T3FillColor; - } else if (!pColorData || pColorData->m_StrokeColor.IsNull()) { + } + if (!pColorData || pColorData->m_StrokeColor.IsNull()) { pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_InitialStates.m_ColorState; } FX_COLORREF rgb = pColorData->m_StrokeRGB; diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp index 0730206e23..fa9325a4d2 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -761,7 +761,8 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) m_pRenderStatus->m_pDevice->SetDIBits(m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft, m_pQuickStretcher->m_ResultTop, m_BlendType); return FALSE; - } else if (m_Status == 2) { + } + if (m_Status == 2) { if (m_pTransformer->Continue(pPause)) { return TRUE; } @@ -784,16 +785,17 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) } delete pBitmap; return FALSE; - } else if (m_Status == 3) { + } + if (m_Status == 3) { return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); - } else if (m_Status == 4) { + } + if (m_Status == 4) { if (m_Loader.Continue(m_LoadHandle, pPause)) { return TRUE; } if (StartRenderDIBSource()) { return Continue(pPause); } - return FALSE; } return FALSE; } diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index ce29baf738..7d17e78e24 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -21,13 +21,17 @@ unsigned int _GetBits8(const uint8_t* pData, int bitpos, int nbits) unsigned int byte = pData[bitpos / 8]; if (nbits == 8) { return byte; - } else if (nbits == 4) { + } + if (nbits == 4) { return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4); - } else if (nbits == 2) { + } + if (nbits == 2) { return (byte >> (6 - bitpos % 8)) & 0x03; - } else if (nbits == 1) { + } + if (nbits == 1) { return (byte >> (7 - bitpos % 8)) & 0x01; - } else if (nbits == 16) { + } + if (nbits == 16) { return byte * 256 + pData[bitpos / 8 + 1]; } return 0; @@ -462,7 +466,8 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) m_pColorSpace->EnableStdConversion(FALSE); } return ret1; - } else if (m_Status == 2) { + } + if (m_Status == 2) { return ContinueLoadMaskDIB(pPause); } return 0; @@ -1008,7 +1013,8 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, const uint8_t* s break; } return; - } else if (m_bpc == 8) { + } + if (m_bpc == 8) { if (m_nComponents == m_pColorSpace->CountComponents()) m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width, m_Width, m_Height, m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp index da2e05af2e..851b2d6709 100644 --- a/core/src/fpdfdoc/doc_action.cpp +++ b/core/src/fpdfdoc/doc_action.cpp @@ -112,9 +112,11 @@ FX_DWORD CPDF_ActionFields::GetFieldsCount() const int iType = pFields->GetType(); if (iType == PDFOBJ_DICTIONARY) { return 1; - } else if (iType == PDFOBJ_STRING) { + } + if (iType == PDFOBJ_STRING) { return 1; - } else if (iType == PDFOBJ_ARRAY) { + } + if (iType == PDFOBJ_ARRAY) { return ((CPDF_Array*)pFields)->GetCount(); } return 0; @@ -207,16 +209,17 @@ CFX_WideString CPDF_Action::GetJavaScript() const } CPDF_Dictionary* CPDF_Action::GetAnnot() const { - if (m_pDict == NULL) { - return NULL; + if (!m_pDict) { + return nullptr; } CFX_ByteString csType = m_pDict->GetString("S"); if (csType == FX_BSTRC("Rendition")) { return m_pDict->GetDict("AN"); - } else if (csType == FX_BSTRC("Movie")) { + } + if (csType == FX_BSTRC("Movie")) { return m_pDict->GetDict("Annotation"); } - return NULL; + return nullptr; } int32_t CPDF_Action::GetOperationType() const { @@ -226,15 +229,19 @@ int32_t CPDF_Action::GetOperationType() const CFX_ByteString csType = m_pDict->GetString("S"); if (csType == FX_BSTRC("Rendition")) { return m_pDict->GetInteger("OP"); - } else if (csType == FX_BSTRC("Movie")) { + } + if (csType == FX_BSTRC("Movie")) { CFX_ByteString csOP = m_pDict->GetString("Operation"); if (csOP == FX_BSTRC("Play")) { return 0; - } else if (csOP == FX_BSTRC("Stop")) { + } + if (csOP == FX_BSTRC("Stop")) { return 1; - } else if (csOP == FX_BSTRC("Pause")) { + } + if (csOP == FX_BSTRC("Pause")) { return 2; - } else if (csOP == FX_BSTRC("Resume")) { + } + if (csOP == FX_BSTRC("Resume")) { return 3; } } diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp index 2d991b39c2..f94a4d60e0 100644 --- a/core/src/fpdfdoc/doc_ap.cpp +++ b/core/src/fpdfdoc/doc_ap.cpp @@ -17,13 +17,13 @@ FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger() : 0; if (field_type == "Tx") { return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict); - } else if (field_type == "Ch") { - if (flags & (1 << 17)) { - return CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict); - } else { - return CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict); - } - } else if (field_type == "Btn") { + } + if (field_type == "Ch") { + return (flags & (1 << 17)) ? + CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict) : + CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict); + } + if (field_type == "Btn") { if (!(flags & (1 << 16))) { if (!pAnnotDict->KeyExist("AS")) { if (CPDF_Dictionary* pParentDict = pAnnotDict->GetDict("Parent")) { diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp index 9d31d15624..3ba109b016 100644 --- a/core/src/fpdfdoc/doc_basic.cpp +++ b/core/src/fpdfdoc/doc_basic.cpp @@ -148,13 +148,12 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, int nIndex, int& nCur if (nIndex >= nCurIndex + nCount) { nCurIndex += nCount; return NULL; - } else { - if (ppFind != NULL) { - *ppFind = pNames; - } - csName = pNames->GetString((nIndex - nCurIndex) * 2); - return pNames->GetElementValue((nIndex - nCurIndex) * 2 + 1); } + if (ppFind != NULL) { + *ppFind = pNames; + } + csName = pNames->GetString((nIndex - nCurIndex) * 2); + return pNames->GetElementValue((nIndex - nCurIndex) * 2 + 1); } CPDF_Array* pKids = pNode->GetArray(FX_BSTRC("Kids")); if (pKids == NULL) { diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index 3740f41510..5a2bd1425b 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -357,12 +357,11 @@ static int CALLBACK EnumFontFamExProc( ENUMLOGFONTEXA *lpelfe, { if (FontType != 0x004 || strchr(lpelfe->elfLogFont.lfFaceName, '@') != NULL) { return 1; - } else { - LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; - memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA)); - pData->bFind = TRUE; - return 0; } + LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; + memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA)); + pData->bFind = TRUE; + return 0; } static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) { @@ -700,41 +699,39 @@ int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte { const FX_CHAR* ptr1 = name1; const FX_CHAR* ptr2 = name2; - if (name1.GetLength() != name2.GetLength()) { - int i = 0; - while (ptr1[i] == ptr2[i]) { - i ++; - } - if (i == name1.GetLength()) { - return 2; - } - if (i == name2.GetLength()) { - return 3; - } - return 0; - } else { + if (name1.GetLength() == name2.GetLength()) { return name1 == name2 ? 1 : 0; } + int i = 0; + while (ptr1[i] == ptr2[i]) { + i ++; + } + if (i == name1.GetLength()) { + return 2; + } + if (i == name2.GetLength()) { + return 3; + } + return 0; } int CPDF_InterForm::CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2) { const FX_WCHAR* ptr1 = name1.c_str(); const FX_WCHAR* ptr2 = name2.c_str(); - if (name1.GetLength() != name2.GetLength()) { - int i = 0; - while (ptr1[i] == ptr2[i]) { - i ++; - } - if (i == name1.GetLength()) { - return 2; - } - if (i == name2.GetLength()) { - return 3; - } - return 0; - } else { + if (name1.GetLength() == name2.GetLength()) { return name1 == name2 ? 1 : 0; } + int i = 0; + while (ptr1[i] == ptr2[i]) { + i ++; + } + if (i == name1.GetLength()) { + return 2; + } + if (i == name2.GetLength()) { + return 3; + } + return 0; } FX_DWORD CPDF_InterForm::CountFields(const CFX_WideString &csFieldName) { @@ -903,115 +900,104 @@ CPDF_FormControl* CPDF_InterForm::GetControlByDict(CPDF_Dictionary* pWidgetDict) } FX_DWORD CPDF_InterForm::CountInternalFields(const CFX_WideString& csFieldName) const { - if (m_pFormDict == NULL) { + if (!m_pFormDict) { return 0; } CPDF_Array* pArray = m_pFormDict->GetArray("Fields"); - if (pArray == NULL) { + if (!pArray) { return 0; } if (csFieldName.IsEmpty()) { return pArray->GetCount(); - } else { - int iLength = csFieldName.GetLength(); - int iPos = 0; - CPDF_Dictionary* pDict = NULL; - while (pArray != NULL) { - CFX_WideString csSub; - if (iPos < iLength && csFieldName[iPos] == L'.') { - iPos ++; - } - while (iPos < iLength && csFieldName[iPos] != L'.') { - csSub += csFieldName[iPos ++]; - } - int iCount = pArray->GetCount(); - FX_BOOL bFind = FALSE; - for (int i = 0; i < iCount; i ++) { - pDict = pArray->GetDict(i); - if (pDict == NULL) { - continue; - } - CFX_WideString csT = pDict->GetUnicodeText("T"); - if (csT == csSub) { - bFind = TRUE; - break; - } - } - if (!bFind) { - return 0; + } + int iLength = csFieldName.GetLength(); + int iPos = 0; + CPDF_Dictionary* pDict = NULL; + while (pArray != NULL) { + CFX_WideString csSub; + if (iPos < iLength && csFieldName[iPos] == L'.') { + iPos ++; + } + while (iPos < iLength && csFieldName[iPos] != L'.') { + csSub += csFieldName[iPos ++]; + } + int iCount = pArray->GetCount(); + FX_BOOL bFind = FALSE; + for (int i = 0; i < iCount; i ++) { + pDict = pArray->GetDict(i); + if (pDict == NULL) { + continue; } - if (iPos >= iLength) { + CFX_WideString csT = pDict->GetUnicodeText("T"); + if (csT == csSub) { + bFind = TRUE; break; } - pArray = pDict->GetArray("Kids"); } - if (pDict == NULL) { + if (!bFind) { return 0; - } else { - pArray = pDict->GetArray("Kids"); - if (pArray == NULL) { - return 1; - } else { - return pArray->GetCount(); - } } + if (iPos >= iLength) { + break; + } + pArray = pDict->GetArray("Kids"); + } + if (!pDict) { + return 0; } + pArray = pDict->GetArray("Kids"); + return pArray ? pArray->GetCount() : 1; } + CPDF_Dictionary* CPDF_InterForm::GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName) const { - if (m_pFormDict == NULL) { - return NULL; + if (!m_pFormDict) { + return nullptr; } CPDF_Array* pArray = m_pFormDict->GetArray("Fields"); - if (pArray == NULL) { - return 0; + if (!pArray) { + return nullptr; } if (csFieldName.IsEmpty()) { return pArray->GetDict(index); - } else { - int iLength = csFieldName.GetLength(); - int iPos = 0; - CPDF_Dictionary* pDict = NULL; - while (pArray != NULL) { - CFX_WideString csSub; - if (iPos < iLength && csFieldName[iPos] == L'.') { - iPos ++; - } - while (iPos < iLength && csFieldName[iPos] != L'.') { - csSub += csFieldName[iPos ++]; - } - int iCount = pArray->GetCount(); - FX_BOOL bFind = FALSE; - for (int i = 0; i < iCount; i ++) { - pDict = pArray->GetDict(i); - if (pDict == NULL) { - continue; - } - CFX_WideString csT = pDict->GetUnicodeText("T"); - if (csT == csSub) { - bFind = TRUE; - break; - } - } - if (!bFind) { - return NULL; + } + int iLength = csFieldName.GetLength(); + int iPos = 0; + CPDF_Dictionary* pDict = NULL; + while (pArray != NULL) { + CFX_WideString csSub; + if (iPos < iLength && csFieldName[iPos] == L'.') { + iPos ++; + } + while (iPos < iLength && csFieldName[iPos] != L'.') { + csSub += csFieldName[iPos ++]; + } + int iCount = pArray->GetCount(); + FX_BOOL bFind = FALSE; + for (int i = 0; i < iCount; i ++) { + pDict = pArray->GetDict(i); + if (pDict == NULL) { + continue; } - if (iPos >= iLength) { + CFX_WideString csT = pDict->GetUnicodeText("T"); + if (csT == csSub) { + bFind = TRUE; break; } - pArray = pDict->GetArray("Kids"); } - if (pDict == NULL) { + if (!bFind) { return NULL; - } else { - pArray = pDict->GetArray("Kids"); - if (pArray == NULL) { - return pDict; - } else { - return pArray->GetDict(index); - } } + if (iPos >= iLength) { + break; + } + pArray = pDict->GetArray("Kids"); + } + if (!pDict) { + return nullptr; } + pArray = pDict->GetArray("Kids"); + return pArray ? pArray->GetDict(index) : pDict; } FX_BOOL CPDF_InterForm::NeedConstructAP() { diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp index 7fa17b8ffa..87eee92c2e 100644 --- a/core/src/fpdfdoc/doc_formcontrol.cpp +++ b/core/src/fpdfdoc/doc_formcontrol.cpp @@ -262,29 +262,27 @@ CPDF_Action CPDF_FormControl::GetAction() } CPDF_AAction CPDF_FormControl::GetAdditionalAction() { - if (m_pWidgetDict == NULL) { - return NULL; + if (!m_pWidgetDict) { + return nullptr; } if (m_pWidgetDict->KeyExist("AA")) { return m_pWidgetDict->GetDict("AA"); - } else { - return m_pField->GetAdditionalAction(); } + return m_pField->GetAdditionalAction(); } CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() { - if (m_pWidgetDict == NULL) { + if (!m_pWidgetDict) { return CFX_ByteString(); } if (m_pWidgetDict->KeyExist("DA")) { return m_pWidgetDict->GetString("DA"); - } else { - CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA"); - if (pObj == NULL) { - return m_pField->m_pForm->GetDefaultAppearance(); - } - return pObj->GetString(); } + CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA"); + if (!pObj) { + return m_pField->m_pForm->GetDefaultAppearance(); + } + return pObj->GetString(); } CPDF_Font* CPDF_FormControl::GetDefaultControlFont() @@ -333,18 +331,17 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() int CPDF_FormControl::GetControlAlignment() { - if (m_pWidgetDict == NULL) { + if (!m_pWidgetDict) { return 0; } if (m_pWidgetDict->KeyExist("Q")) { return m_pWidgetDict->GetInteger("Q", 0); - } else { - CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q"); - if (pObj == NULL) { - return m_pField->m_pForm->GetFormAlignment(); - } - return pObj->GetInteger(); } + CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q"); + if (pObj == NULL) { + return m_pField->m_pForm->GetFormAlignment(); + } + return pObj->GetInteger(); } FX_BOOL CPDF_ApSettings::HasMKEntry(const CFX_ByteStringC& csEntry) { diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index 1a6fc3d6d9..8b644e4f93 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -472,14 +472,15 @@ int CPDF_FormField::GetSelectedIndex(int index) return -1; } } + if (pValue->GetType() == PDFOBJ_NUMBER) { + return pValue->GetInteger(); + } CFX_WideString sel_value; if (pValue->GetType() == PDFOBJ_STRING) { if (index != 0) { return -1; } sel_value = pValue->GetUnicodeText(); - } else if (pValue->GetType() == PDFOBJ_NUMBER) { - return pValue->GetInteger(); } else { if (pValue->GetType() != PDFOBJ_ARRAY) { return -1; diff --git a/core/src/fpdfdoc/doc_metadata.cpp b/core/src/fpdfdoc/doc_metadata.cpp index a4c77debd3..7624e0a2f0 100644 --- a/core/src/fpdfdoc/doc_metadata.cpp +++ b/core/src/fpdfdoc/doc_metadata.cpp @@ -113,7 +113,8 @@ int32_t CPDF_Metadata::GetString(const CFX_ByteStringC& bsItem, CFX_WideString & } wsStr = pElmnt->GetContent(0); return wsStr.GetLength(); - } else if (bsItem == FX_BSTRC("Author")) { + } + if (bsItem == FX_BSTRC("Author")) { CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag); if (!pElmnt) { continue; @@ -128,14 +129,13 @@ int32_t CPDF_Metadata::GetString(const CFX_ByteStringC& bsItem, CFX_WideString & } wsStr = pElmnt->GetContent(0); return wsStr.GetLength(); - } else { - CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag); - if (!pElmnt) { - continue; - } - wsStr = pElmnt->GetContent(0); - return wsStr.GetLength(); } + CXML_Element *pElmnt = pTag->GetElement(NULL, bsTag); + if (!pElmnt) { + continue; + } + wsStr = pElmnt->GetContent(0); + return wsStr.GetLength(); } return -1; } diff --git a/core/src/fpdfdoc/doc_ocg.cpp b/core/src/fpdfdoc/doc_ocg.cpp index 8477cb85d0..d525227219 100644 --- a/core/src/fpdfdoc/doc_ocg.cpp +++ b/core/src/fpdfdoc/doc_ocg.cpp @@ -207,11 +207,11 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array *pExpression, FX_BOOL bFromConfig, i } if (pOCGObj->GetType() == PDFOBJ_DICTIONARY) { return !(bFromConfig ? LoadOCGState((CPDF_Dictionary*)pOCGObj) : GetOCGVisible((CPDF_Dictionary*)pOCGObj)); - } else if (pOCGObj->GetType() == PDFOBJ_ARRAY) { + } + if (pOCGObj->GetType() == PDFOBJ_ARRAY) { return !GetOCGVE((CPDF_Array*)pOCGObj, bFromConfig, nLevel + 1); - } else { - return FALSE; } + return FALSE; } if (csOperator == FX_BSTRC("Or") || csOperator == FX_BSTRC("And")) { FX_BOOL bValue = FALSE; @@ -286,15 +286,14 @@ FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary *pOCMDDict, FX_BOOL } FX_BOOL CPDF_OCContext::CheckOCGVisible(const CPDF_Dictionary *pOCGDict) { - if (pOCGDict == NULL) { + if (!pOCGDict) { return TRUE; } CFX_ByteString csType = pOCGDict->GetString(FX_BSTRC("Type"), FX_BSTRC("OCG")); if (csType == FX_BSTRC("OCG")) { return GetOCGVisible(pOCGDict); - } else { - return LoadOCMDState(pOCGDict, FALSE); } + return LoadOCMDState(pOCGDict, FALSE); } void CPDF_OCContext::ResetOCContext() { diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp index 10ca14697d..96d2ccf689 100644 --- a/core/src/fpdfdoc/doc_utils.cpp +++ b/core/src/fpdfdoc/doc_utils.cpp @@ -655,15 +655,17 @@ CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pD } CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() { - if (m_pDict == NULL) { + if (!m_pDict) { return Always; } CFX_ByteString csSW = m_pDict->GetString("SW", "A"); if (csSW == "B") { return Bigger; - } else if (csSW == "S") { + } + if (csSW == "S") { return Smaller; - } else if (csSW == "N") { + } + if (csSW == "N") { return Never; } return Always; diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp index c9f5673a60..9b87d920cf 100644 --- a/core/src/fpdfdoc/doc_vt.cpp +++ b/core/src/fpdfdoc/doc_vt.cpp @@ -96,9 +96,8 @@ CPVT_FloatRect CSection::Rearrange() ASSERT(m_pVT != NULL); if (m_pVT->m_nCharArray > 0) { return CTypeset(this).CharArray(); - } else { - return CTypeset(this).Typeset(); } + return CTypeset(this).Typeset(); } CPVT_Size CSection::GetSectionSize(FX_FLOAT fFontSize) { @@ -108,17 +107,15 @@ CPVT_WordPlace CSection::GetBeginWordPlace() const { if (CLine * pLine = m_LineArray.GetAt(0)) { return pLine->GetBeginWordPlace(); - } else { - return SecPlace; } + return SecPlace; } CPVT_WordPlace CSection::GetEndWordPlace() const { if (CLine * pLine = m_LineArray.GetAt(m_LineArray.GetSize() - 1)) { return pLine->GetEndWordPlace(); - } else { - return SecPlace; } + return SecPlace; } CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace & place) const { @@ -131,7 +128,8 @@ CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace & place) const if (CLine * pLine = m_LineArray.GetAt(place.nLineIndex)) { if (place.nWordIndex == pLine->m_LineInfo.nBeginWordIndex) { return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1); - } else if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) { + } + if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) { if (CLine * pPrevLine = m_LineArray.GetAt(place.nLineIndex - 1)) { return pPrevLine->GetEndWordPlace(); } @@ -572,17 +570,23 @@ static FX_BOOL NeedDivision(FX_WORD prevWord, FX_WORD curWord) { if ((IsLatin(prevWord) || IsDigit(prevWord)) && (IsLatin(curWord) || IsDigit(curWord))) { return FALSE; - } else if (IsSpace(curWord) || IsPunctuation(curWord)) { + } + if (IsSpace(curWord) || IsPunctuation(curWord)) { return FALSE; - } else if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) { + } + if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) { return FALSE; - } else if (IsSpace(prevWord) || IsPunctuation(prevWord)) { + } + if (IsSpace(prevWord) || IsPunctuation(prevWord)) { return TRUE; - } else if (IsPrefixSymbol(prevWord)) { + } + if (IsPrefixSymbol(prevWord)) { return FALSE; - } else if (IsPrefixSymbol(curWord) || IsCJK(curWord)) { + } + if (IsPrefixSymbol(curWord) || IsCJK(curWord)) { return TRUE; - } else if (IsCJK(prevWord)) { + } + if (IsCJK(prevWord)) { return TRUE; } return FALSE; @@ -866,16 +870,12 @@ CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace & place, FX_WO CPVT_WordPlace newplace = place; newplace.nWordIndex ++; if (m_bRichText) { - CPVT_WordProps * pNewProps = pWordProps ? FX_NEW CPVT_WordProps(*pWordProps) : FX_NEW CPVT_WordProps(); - if (pNewProps) { - pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFontIndex); - return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps)); - } - } else { - int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontIndex(word, charset, GetDefaultFontIndex()); - return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)); + CPVT_WordProps* pNewProps = pWordProps ? new CPVT_WordProps(*pWordProps) : new CPVT_WordProps(); + pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFontIndex); + return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps)); } - return place; + int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontIndex(word, charset, GetDefaultFontIndex()); + return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)); } CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace & place, const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) @@ -1123,12 +1123,10 @@ CPVT_WordPlace CPDF_VariableText::GetPrevWordPlace(const CPVT_WordPlace & place) if (place.WordCmp(pSection->GetBeginWordPlace()) <= 0) { if (CSection * pPrevSection = m_SectionArray.GetAt(place.nSecIndex - 1)) { return pPrevSection->GetEndWordPlace(); - } else { - return GetBeginWordPlace(); } - } else { - return pSection->GetPrevWordPlace(place); + return GetBeginWordPlace(); } + return pSection->GetPrevWordPlace(place); } return place; } @@ -1144,12 +1142,10 @@ CPVT_WordPlace CPDF_VariableText::GetNextWordPlace(const CPVT_WordPlace & place) if (place.WordCmp(pSection->GetEndWordPlace()) >= 0) { if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) { return pNextSection->GetBeginWordPlace(); - } else { - return GetEndWordPlace(); } - } else { - return pSection->GetNextWordPlace(place); + return GetEndWordPlace(); } + return pSection->GetNextWordPlace(place); } return place; } @@ -1204,12 +1200,11 @@ CPVT_WordPlace CPDF_VariableText::GetUpWordPlace(const CPVT_WordPlace & place, c CPDF_Point pt = OutToIn(point); if (temp.nLineIndex-- > 0) { return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp); - } else { - if (temp.nSecIndex-- > 0) { - if (CSection * pLastSection = m_SectionArray.GetAt(temp.nSecIndex)) { - temp.nLineIndex = pLastSection->m_LineArray.GetSize() - 1; - return pLastSection->SearchWordPlace(pt.x - pLastSection->m_SecInfo.rcSection.left, temp); - } + } + if (temp.nSecIndex-- > 0) { + if (CSection * pLastSection = m_SectionArray.GetAt(temp.nSecIndex)) { + temp.nLineIndex = pLastSection->m_LineArray.GetSize() - 1; + return pLastSection->SearchWordPlace(pt.x - pLastSection->m_SecInfo.rcSection.left, temp); } } } @@ -1222,12 +1217,11 @@ CPVT_WordPlace CPDF_VariableText::GetDownWordPlace(const CPVT_WordPlace & place, CPDF_Point pt = OutToIn(point); if (temp.nLineIndex++ < pSection->m_LineArray.GetSize() - 1) { return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp); - } else { - if (temp.nSecIndex++ < m_SectionArray.GetSize() - 1) { - if (CSection * pNextSection = m_SectionArray.GetAt(temp.nSecIndex)) { - temp.nLineIndex = 0; - return pNextSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp); - } + } + if (temp.nSecIndex++ < m_SectionArray.GetSize() - 1) { + if (CSection * pNextSection = m_SectionArray.GetAt(temp.nSecIndex)) { + temp.nLineIndex = 0; + return pNextSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left, temp); } } } @@ -1239,10 +1233,10 @@ CPVT_WordPlace CPDF_VariableText::GetLineBeginPlace(const CPVT_WordPlace & place } CPVT_WordPlace CPDF_VariableText::GetLineEndPlace(const CPVT_WordPlace & place) const { - if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) - if (CLine * pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) { + if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { + if (CLine* pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) return pLine->GetEndWordPlace(); - } + } return place; } CPVT_WordPlace CPDF_VariableText::GetSectionBeginPlace(const CPVT_WordPlace & place) const @@ -1439,11 +1433,7 @@ void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace & place) CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const { if (place.nWordIndex < 0 && place.nLineIndex > 0) { - if (bPrevOrNext) { - return GetPrevWordPlace(place); - } else { - return GetNextWordPlace(place); - } + return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place); } return place; } @@ -1639,14 +1629,13 @@ CPVT_FloatRect CPDF_VariableText::RearrangeSections(const CPVT_WordRange & Place } int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, FX_WORD Word, FX_WORD SubWord, int32_t nWordStyle) { - if (m_pVTProvider) { - if (SubWord > 0) { - return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle); - } else { - return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle); - } + if (!m_pVTProvider) { + return 0; + } + if (SubWord > 0) { + return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle); } - return 0; + return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle); } int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex) { @@ -1701,7 +1690,6 @@ void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place) } FX_BOOL CPDF_VariableText_Iterator::NextWord() { - ASSERT(m_pVT != NULL); if (m_CurPos == m_pVT->GetEndWordPlace()) { return FALSE; } @@ -1710,7 +1698,6 @@ FX_BOOL CPDF_VariableText_Iterator::NextWord() } FX_BOOL CPDF_VariableText_Iterator::PrevWord() { - ASSERT(m_pVT != NULL); if (m_CurPos == m_pVT->GetBeginWordPlace()) { return FALSE; } @@ -1719,33 +1706,29 @@ FX_BOOL CPDF_VariableText_Iterator::PrevWord() } FX_BOOL CPDF_VariableText_Iterator::NextLine() { - ASSERT(m_pVT != NULL); if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { if (m_CurPos.nLineIndex < pSection->m_LineArray.GetSize() - 1) { m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex + 1, -1); return TRUE; - } else { - if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { - m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); - return TRUE; - } + } + if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { + m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); + return TRUE; } } return FALSE; } FX_BOOL CPDF_VariableText_Iterator::PrevLine() { - ASSERT(m_pVT != NULL); if (m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { if (m_CurPos.nLineIndex > 0) { m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex - 1, -1); return TRUE; - } else { - if (m_CurPos.nSecIndex > 0) { - if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex - 1)) { - m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSection->m_LineArray.GetSize() - 1, -1); - return TRUE; - } + } + if (m_CurPos.nSecIndex > 0) { + if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex - 1)) { + m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSection->m_LineArray.GetSize() - 1, -1); + return TRUE; } } } @@ -1753,7 +1736,6 @@ FX_BOOL CPDF_VariableText_Iterator::PrevLine() } FX_BOOL CPDF_VariableText_Iterator::NextSection() { - ASSERT(m_pVT != NULL); if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); return TRUE; diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp index ab6cae19c2..8bcf996465 100644 --- a/core/src/fpdftext/fpdf_text_int.cpp +++ b/core/src/fpdftext/fpdf_text_int.cpp @@ -42,9 +42,11 @@ FX_FLOAT _NormalizeThreshold(FX_FLOAT threshold) { if (threshold < 300) { return threshold / 2.0f; - } else if (threshold < 500) { + } + if (threshold < 500) { return threshold / 4.0f; - } else if (threshold < 700) { + } + if (threshold < 700) { return threshold / 5.0f; } return threshold / 6.0f; @@ -162,12 +164,9 @@ void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) { m_ParseOptions.m_bNormalizeObjs = bNormalize; } -FX_BOOL CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo) +bool CPDF_TextPage::IsControlChar(const PAGECHAR_INFO& charInfo) { - if(!pCharInfo) { - return FALSE; - } - switch(pCharInfo->m_Unicode) { + switch (charInfo.m_Unicode) { case 0x2: case 0x3: case 0x93: @@ -176,13 +175,9 @@ FX_BOOL CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo) case 0x97: case 0x98: case 0xfffe: - if(pCharInfo->m_Flag == FPDFTEXT_CHAR_HYPHEN) { - return FALSE; - } else { - return TRUE; - } + return charInfo.m_Flag != FPDFTEXT_CHAR_HYPHEN; default: - return FALSE; + return false; } } FX_BOOL CPDF_TextPage::ParseTextPage() @@ -210,7 +205,7 @@ FX_BOOL CPDF_TextPage::ParseTextPage() if(charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { bNormal = TRUE; } - else if(charinfo.m_Unicode == 0 || IsControlChar(&charinfo)) + else if(charinfo.m_Unicode == 0 || IsControlChar(charinfo)) bNormal = FALSE; else { bNormal = TRUE; @@ -495,141 +490,6 @@ int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x, FX_FLOAT y, FX_FLOAT xTorelance, FX CPDF_Point point(x, y); return GetIndexAtPos(point, xTorelance, yTorelance); } -int CPDF_TextPage::GetOrderByDirection(int order, int direction) const -{ - if(m_ParseOptions.m_bGetCharCodeOnly) { - return -3; - } - if (!m_IsParsered) { - return -3; - } - if (direction == FPDFTEXT_RIGHT || direction == FPDFTEXT_LEFT) { - order += direction; - while(order >= 0 && order < m_charList.GetSize()) { - PAGECHAR_INFO cinfo = *(PAGECHAR_INFO*)m_charList.GetAt(order); - if (cinfo.m_Flag != FPDFTEXT_CHAR_GENERATED) { - break; - } else { - if (cinfo.m_Unicode == TEXT_LINEFEED_CHAR || cinfo.m_Unicode == TEXT_RETURN_CHAR) { - order += direction; - } else { - break; - } - } - } - if (order >= m_charList.GetSize()) { - order = -2; - } - return order; - } - PAGECHAR_INFO charinfo; - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(order); - CPDF_Point curPos(charinfo.m_OriginX, charinfo.m_OriginY); - FX_FLOAT difPosY = 0.0, minXdif = 1000; - int minIndex = -2; - int index = order; - FX_FLOAT height = charinfo.m_CharBox.Height(); - if (direction == FPDFTEXT_UP) { - minIndex = -1; - while (1) { - if (--index < 0) { - return -1; - } - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index); - if (FXSYS_fabs(charinfo.m_OriginY - curPos.y) > FX_MAX(height, charinfo.m_CharBox.Height()) / 2) { - difPosY = charinfo.m_OriginY; - minIndex = index; - break; - } - } - FX_FLOAT PreXdif = charinfo.m_OriginX - curPos.x; - minXdif = PreXdif; - if (PreXdif == 0) { - return index; - } - FX_FLOAT curXdif = 0; - while (--index >= 0) { - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index); - if (difPosY != charinfo.m_OriginY) { - break; - } - curXdif = charinfo.m_OriginX - curPos.x; - if (curXdif == 0) { - return index; - } - int signflag = 0; - if (curXdif > 0) { - signflag = 1; - } else { - signflag = -1; - } - if (signflag * PreXdif < 0) { - if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) { - return index + 1; - } else { - return index; - } - } - if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) { - minIndex = index; - minXdif = curXdif; - } - PreXdif = curXdif; - if (difPosY != charinfo.m_OriginY) { - break; - } - } - return minIndex; - } else if(FPDFTEXT_DOWN) { - minIndex = -2; - while (1) { - if (++index > m_charList.GetSize() - 1) { - return minIndex; - } - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index); - if (FXSYS_fabs(charinfo.m_OriginY - curPos.y) > FX_MAX(height, charinfo.m_CharBox.Height()) / 2) { - difPosY = charinfo.m_OriginY; - minIndex = index; - break; - } - } - FX_FLOAT PreXdif = charinfo.m_OriginX - curPos.x; - minXdif = PreXdif; - if (PreXdif == 0) { - return index; - } - FX_FLOAT curXdif = 0; - while (++index < m_charList.GetSize()) { - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index); - if (difPosY != charinfo.m_OriginY) { - break; - } - curXdif = charinfo.m_OriginX - curPos.x; - if (curXdif == 0) { - return index; - } - int signflag = 0; - if (curXdif > 0) { - signflag = 1; - } else { - signflag = -1; - } - if (signflag * PreXdif < 0) { - if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) { - return index - 1; - } else { - return index; - } - } - if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) { - minXdif = curXdif; - minIndex = index; - } - PreXdif = curXdif; - } - return minIndex; - } -} void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO & info) const { if(m_ParseOptions.m_bGetCharCodeOnly) { @@ -955,7 +815,6 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const return breakPos; } } - return breakPos; } else if (direction == FPDFTEXT_RIGHT) { while (++breakPos < m_charList.GetSize()) { charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); @@ -963,7 +822,6 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const return breakPos; } } - return breakPos; } return breakPos; } @@ -1164,7 +1022,7 @@ void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) { PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); FX_WCHAR wChar = str.GetAt(i); - if(!IsControlChar(&Info)) { + if(!IsControlChar(Info)) { Info.m_Index = m_TextBuf.GetLength(); if (wChar >= 0xFB00 && wChar <= 0xFB06) { FX_WCHAR* pDst = NULL; @@ -1196,7 +1054,7 @@ void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) { PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); - if(!IsControlChar(&Info)) { + if(!IsControlChar(Info)) { Info.m_Index = m_TextBuf.GetLength(); FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE); FX_WCHAR* pDst = NULL; @@ -1215,9 +1073,8 @@ void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) } FX_Free(pDst); return; - } else { - Info.m_Unicode = wChar; } + Info.m_Unicode = wChar; m_TextBuf.AppendChar(Info.m_Unicode); } else { Info.m_Index = -1; @@ -1910,11 +1767,9 @@ int32_t CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj) v.Set(dX, dY); v.Normalize(); if (v.y <= 0.0872f) { - if (v.x <= 0.0872f) { - return m_TextlineDir; - } - return 0; - } else if (v.x <= 0.0872f) { + return v.x <= 0.0872f ? m_TextlineDir : 0; + } + if (v.x <= 0.0872f) { return 1; } return m_TextlineDir; @@ -2693,22 +2548,25 @@ FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) if (str.Find(L"http://www.") != -1) { strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www.")); return TRUE; - } else if (str.Find(L"http://") != -1) { + } + if (str.Find(L"http://") != -1) { strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://")); return TRUE; - } else if (str.Find(L"https://www.") != -1) { + } + if (str.Find(L"https://www.") != -1) { strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www.")); return TRUE; - } else if (str.Find(L"https://") != -1) { + } + if (str.Find(L"https://") != -1) { strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://")); return TRUE; - } else if (str.Find(L"www.") != -1) { + } + if (str.Find(L"www.") != -1) { strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www.")); strBeCheck = L"http://" + strBeCheck; return TRUE; - } else { - return FALSE; } + return FALSE; } FX_BOOL CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) { diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h index a521c7c1f7..0acb688f6f 100644 --- a/core/src/fpdftext/text_int.h +++ b/core/src/fpdftext/text_int.h @@ -66,7 +66,6 @@ public: FX_FLOAT yTorelance) const; virtual CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const; virtual void GetRectsArrayByRect(const CFX_FloatRect& rect, CFX_RectArray& resRectArray) const; - virtual int GetOrderByDirection(int order, int direction) const; virtual CFX_WideString GetPageText(int start = 0, int nCount = -1) const; virtual int CountRects(int start, int nCount); @@ -87,7 +86,7 @@ public: static FX_BOOL IsLetter(FX_WCHAR unicode); private: FX_BOOL IsHyphen(FX_WCHAR curChar); - FX_BOOL IsControlChar(PAGECHAR_INFO* pCharInfo); + bool IsControlChar(const PAGECHAR_INFO& charInfo); FX_BOOL GetBaselineRotate(int start, int end, int& Rotate); void ProcessObject(); void ProcessFormObject(CPDF_FormObject* pFormObj, const CFX_AffineMatrix& formMatrix); diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp index da503c03fd..7507fe5d6d 100644 --- a/core/src/fxcodec/codec/fx_codec_icc.cpp +++ b/core/src/fxcodec/codec/fx_codec_icc.cpp @@ -44,7 +44,8 @@ FX_BOOL CheckComponents(cmsColorSpaceSignature cs, int nComponents, FX_BOOL bDst case cmsSigGrayData: if (bDst && nComponents != 1) { return FALSE; - } else if (!bDst && nComponents > 2) { + } + if (!bDst && nComponents > 2) { return FALSE; } break; diff --git a/core/src/fxcodec/codec/fx_codec_jbig.cpp b/core/src/fxcodec/codec/fx_codec_jbig.cpp index 7a69a24d40..51184306eb 100644 --- a/core/src/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp @@ -172,35 +172,34 @@ FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, IFX_Pause { CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; int ret = m_pJbig2Context->m_pContext->Continue(pPause); - if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECODE_FINISH) { - if(m_pJbig2Context->m_bFileReader) { - CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); - m_pJbig2Context->m_pContext = NULL; - if (ret != JBIG2_SUCCESS) { - if(m_pJbig2Context->m_src_buf) { - FX_Free(m_pJbig2Context->m_src_buf); - } - m_pJbig2Context->m_src_buf = NULL; - return FXCODEC_STATUS_ERROR; - } - delete m_pJbig2Context->m_dest_image; - FX_Free(m_pJbig2Context->m_src_buf); - return FXCODEC_STATUS_DECODE_FINISH; - } else { - CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); - m_pJbig2Context->m_pContext = NULL; - if (ret != JBIG2_SUCCESS) { - return FXCODEC_STATUS_ERROR; - } - int dword_size = m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; - FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; - for (int i = 0; i < dword_size; i ++) { - dword_buf[i] = ~dword_buf[i]; + if (m_pJbig2Context->m_pContext->GetProcessiveStatus() != FXCODEC_STATUS_DECODE_FINISH) { + return m_pJbig2Context->m_pContext->GetProcessiveStatus(); + } + if (m_pJbig2Context->m_bFileReader) { + CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); + m_pJbig2Context->m_pContext = NULL; + if (ret != JBIG2_SUCCESS) { + if(m_pJbig2Context->m_src_buf) { + FX_Free(m_pJbig2Context->m_src_buf); } - return FXCODEC_STATUS_DECODE_FINISH; + m_pJbig2Context->m_src_buf = NULL; + return FXCODEC_STATUS_ERROR; } + delete m_pJbig2Context->m_dest_image; + FX_Free(m_pJbig2Context->m_src_buf); + return FXCODEC_STATUS_DECODE_FINISH; } - return m_pJbig2Context->m_pContext->GetProcessiveStatus(); + CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); + m_pJbig2Context->m_pContext = NULL; + if (ret != JBIG2_SUCCESS) { + return FXCODEC_STATUS_ERROR; + } + int dword_size = m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; + FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; + for (int i = 0; i < dword_size; i ++) { + dword_buf[i] = ~dword_buf[i]; + } + return FXCODEC_STATUS_DECODE_FINISH; } diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp index 52f83586be..e8e075e6b0 100644 --- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp @@ -493,9 +493,11 @@ extern "C" { int ratio = (iratio_w > iratio_h) ? iratio_h : iratio_w; if (ratio >= 8) { return 8; - } else if (ratio >= 4) { + } + if (ratio >= 4) { return 4; - } else if (ratio >= 2) { + } + if (ratio >= 2) { return 2; } return 1; diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp index 56b2f57f3c..4ab34bb022 100644 --- a/core/src/fxcrt/fx_basic_array.cpp +++ b/core/src/fxcrt/fx_basic_array.cpp @@ -243,7 +243,8 @@ void** CFX_BaseSegmentedArray::GetIndex(int seg_index) const ASSERT(m_IndexDepth != 0); if (m_IndexDepth == 1) { return (void**)m_pIndex; - } else if (m_IndexDepth == 2) { + } + if (m_IndexDepth == 2) { return (void**)((void**)m_pIndex)[seg_index / m_IndexSize]; } int tree_size = 1; diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp index 9f54414110..5eeb33b049 100644 --- a/core/src/fxcrt/fx_basic_bstring.cpp +++ b/core/src/fxcrt/fx_basic_bstring.cpp @@ -132,10 +132,9 @@ CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) if (stringSrc.IsEmpty()) { m_pData = NULL; return; - } else { - m_pData = NULL; - *this = stringSrc; } + m_pData = NULL; + *this = stringSrc; } CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1, const CFX_ByteStringC& str2) { @@ -971,13 +970,15 @@ int CFX_ByteString::Compare(const CFX_ByteStringC& str) const for (int i = 0; i < min_len; i ++) { if ((uint8_t)m_pData->m_String[i] < str.GetAt(i)) { return -1; - } else if ((uint8_t)m_pData->m_String[i] > str.GetAt(i)) { + } + if ((uint8_t)m_pData->m_String[i] > str.GetAt(i)) { return 1; } } if (this_len < that_len) { return -1; - } else if (this_len > that_len) { + } + if (this_len > that_len) { return 1; } return 0; diff --git a/core/src/fxcrt/fx_basic_util.cpp b/core/src/fxcrt/fx_basic_util.cpp index 952ea87df3..fa1f6ea3ed 100644 --- a/core/src/fxcrt/fx_basic_util.cpp +++ b/core/src/fxcrt/fx_basic_util.cpp @@ -466,18 +466,18 @@ CFX_Matrix_3by3 CFX_Matrix_3by3::Inverse() FX_FLOAT det = a*(e*i - f*h) - b*(i*d - f*g) + c*(d*h - e*g); if (FXSYS_fabs(det) < 0.0000001) return CFX_Matrix_3by3(); - else - return CFX_Matrix_3by3( - (e*i - f*h) / det, - -(b*i - c*h) / det, - (b*f - c*e) / det, - -(d*i - f*g) / det, - (a*i - c*g) / det, - -(a*f - c*d) / det, - (d*h - e*g) / det, - -(a*h - b*g) / det, - (a*e - b*d) / det - ); + + return CFX_Matrix_3by3( + (e*i - f*h) / det, + -(b*i - c*h) / det, + (b*f - c*e) / det, + -(d*i - f*g) / det, + (a*i - c*g) / det, + -(a*f - c*d) / det, + (d*h - e*g) / det, + -(a*h - b*g) / det, + (a*e - b*d) / det + ); } CFX_Matrix_3by3 CFX_Matrix_3by3::Multiply(const CFX_Matrix_3by3 &m) diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp index 2442daed27..b6b595588d 100644 --- a/core/src/fxcrt/fx_basic_wstring.cpp +++ b/core/src/fxcrt/fx_basic_wstring.cpp @@ -485,7 +485,8 @@ int CFX_WideString::Compare(const CFX_WideString& str) const return 0; } return -1; - } else if (str.m_pData == NULL) { + } + if (str.m_pData == NULL) { return 1; } int this_len = m_pData->m_nDataLength; @@ -494,13 +495,15 @@ int CFX_WideString::Compare(const CFX_WideString& str) const for (int i = 0; i < min_len; i ++) { if (m_pData->m_String[i] < str.m_pData->m_String[i]) { return -1; - } else if (m_pData->m_String[i] > str.m_pData->m_String[i]) { + } + if (m_pData->m_String[i] > str.m_pData->m_String[i]) { return 1; } } if (this_len < that_len) { return -1; - } else if (this_len > that_len) { + } + if (this_len > that_len) { return 1; } return 0; diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp index 045d586924..4afb5b4b0e 100644 --- a/core/src/fxge/agg/src/fx_agg_driver.cpp +++ b/core/src/fxge/agg/src/fx_agg_driver.cpp @@ -426,7 +426,8 @@ public: } } return; - } else if (Bpp == 3 || Bpp == 4) { + } + if (Bpp == 3 || Bpp == 4) { for (int col = col_start; col < col_end; col ++) { int src_alpha; if (clip_scan) { @@ -488,7 +489,8 @@ public: } } return; - } else if (Bpp == 3 || Bpp == 4) { + } + if (Bpp == 3 || Bpp == 4) { for (int col = col_start; col < col_end; col ++) { int src_alpha; if (clip_scan) { @@ -517,7 +519,8 @@ public: continue; } return; - } else if (Bpp == 1) { + } + if (Bpp == 1) { for (int col = col_start; col < col_end; col ++) { int src_alpha; if (clip_scan) { diff --git a/core/src/fxge/dib/fx_dib_composite.cpp b/core/src/fxge/dib/fx_dib_composite.cpp index 19a870ade3..cb99a37ff4 100644 --- a/core/src/fxge/dib/fx_dib_composite.cpp +++ b/core/src/fxge/dib/fx_dib_composite.cpp @@ -3938,7 +3938,8 @@ void CFX_ScanlineCompositor::CompositePalBitmapLine(uint8_t* dest_scan, const ui if (m_SrcFormat == FXDIB_1bppRgb) { if (m_DestFormat == FXDIB_8bppRgb) { return; - } else if(m_DestFormat == FXDIB_Argb) { + } + if(m_DestFormat == FXDIB_Argb) { _CompositeRow_1bppRgb2Argb_NoBlend_RgbByteOrder(dest_scan, src_scan, src_left, width, m_pSrcPalette, clip_scan); } else { _CompositeRow_1bppRgb2Rgb_NoBlend_RgbByteOrder(dest_scan, src_scan, src_left, m_pSrcPalette, width, (m_DestFormat & 0xff) >> 3, clip_scan); @@ -3946,7 +3947,8 @@ void CFX_ScanlineCompositor::CompositePalBitmapLine(uint8_t* dest_scan, const ui } else { if (m_DestFormat == FXDIB_8bppRgb) { return; - } else if (m_DestFormat == FXDIB_Argb) { + } + if (m_DestFormat == FXDIB_Argb) { _CompositeRow_8bppRgb2Argb_NoBlend_RgbByteOrder(dest_scan, src_scan, width, m_pSrcPalette, clip_scan); } else { _CompositeRow_8bppRgb2Rgb_NoBlend_RgbByteOrder(dest_scan, src_scan, m_pSrcPalette, width, (m_DestFormat & 0xff) >> 3, clip_scan); @@ -3957,7 +3959,8 @@ void CFX_ScanlineCompositor::CompositePalBitmapLine(uint8_t* dest_scan, const ui if (m_DestFormat == FXDIB_8bppMask) { _CompositeRow_Rgb2Mask(dest_scan, src_scan, width, clip_scan); return; - } else if ((m_DestFormat & 0xff) == 8) { + } + if ((m_DestFormat & 0xff) == 8) { if (m_Transparency & 8) { if (m_DestFormat & 0x0200) { _CompositeRow_1bppPal2Graya(dest_scan, src_scan, src_left, (const uint8_t*)m_pSrcPalette, width, m_BlendType, clip_scan, dst_extra_alpha); @@ -4208,7 +4211,8 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left, int top, int width, int height, FX } } return TRUE; - } else if (m_bpp == 1) { + } + if (m_bpp == 1) { ASSERT(!IsCmykImage() && (uint8_t)(alpha_flag >> 8) == 0); int left_shift = rect.left % 8; int right_shift = rect.right % 8; diff --git a/core/src/fxge/dib/fx_dib_convert.cpp b/core/src/fxge/dib/fx_dib_convert.cpp index 3347e907cc..9e6cbee1eb 100644 --- a/core/src/fxge/dib/fx_dib_convert.cpp +++ b/core/src/fxge/dib/fx_dib_convert.cpp @@ -847,12 +847,14 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc return _ConvertBuffer_1bppPlt2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); } return _ConvertBuffer_1bppMask2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top); - } else if ((src_format & 0xff) == 8) { + } + if ((src_format & 0xff) == 8) { if (pSrcBitmap->GetPalette()) { return _ConvertBuffer_8bppPlt2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); } return _ConvertBuffer_8bppMask2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top); - } else if ((src_format & 0xff) >= 24) { + } + if ((src_format & 0xff) >= 24) { return _ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); } return FALSE; @@ -865,7 +867,8 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc d_pal = FX_Alloc(FX_DWORD, 256); if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pSrcBitmap->GetPalette()) { return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); - } else if ((src_format & 0xff) >= 24) { + } + if ((src_format & 0xff) >= 24) { return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform); } return FALSE; @@ -877,14 +880,17 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); } return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top); - } else if ((src_format & 0xff) == 8) { + } + if ((src_format & 0xff) == 8) { if (pSrcBitmap->GetPalette()) { return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); } return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top); - } else if ((src_format & 0xff) == 24) { + } + if ((src_format & 0xff) == 24) { return _ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); - } else if ((src_format & 0xff) == 32) { + } + if ((src_format & 0xff) == 32) { return _ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); } return FALSE; @@ -896,12 +902,14 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format, uint8_t* dest_buf, int dest_pitc return _ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); } return _ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top); - } else if ((src_format & 0xff) == 8) { + } + if ((src_format & 0xff) == 8) { if (pSrcBitmap->GetPalette()) { return _ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); } return _ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top); - } else if ((src_format & 0xff) >= 24) { + } + if ((src_format & 0xff) >= 24) { if (src_format & 0x0400) { return _ConvertBuffer_32bppCmyk2Rgb32(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform); } diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp index cb3559180f..fecc6f15db 100644 --- a/core/src/fxge/dib/fx_dib_engine.cpp +++ b/core/src/fxge/dib/fx_dib_engine.cpp @@ -346,9 +346,8 @@ FX_BOOL CStretchEngine::ContinueStretchHorz(IFX_Pause* pPause) if (rows_to_go == 0) { if (pPause && pPause->NeedToPauseNow()) { return TRUE; - } else { - rows_to_go = FX_STRECH_PAUSE_ROWS; } + rows_to_go = FX_STRECH_PAUSE_ROWS; } const uint8_t* src_scan = m_pSource->GetScanline(m_CurRow); uint8_t* dest_scan = m_pInterBuf + (m_CurRow - m_SrcClip.top) * m_InterPitch; @@ -745,17 +744,15 @@ FX_BOOL CFX_ImageStretcher::Start(IFX_ScanlineComposer* pDest, } if (flags & FXDIB_DOWNSAMPLE) { return StartQuickStretch(); - } else { - return StartStretch(); } + return StartStretch(); } FX_BOOL CFX_ImageStretcher::Continue(IFX_Pause* pPause) { if (m_Flags & FXDIB_DOWNSAMPLE) { return ContinueQuickStretch(pPause); - } else { - return ContinueStretch(pPause); } + return ContinueStretch(pPause); } #define MAX_PROGRESSIVE_STRETCH_PIXELS 1000000 FX_BOOL CFX_ImageStretcher::StartStretch() diff --git a/core/src/fxge/dib/fx_dib_main.cpp b/core/src/fxge/dib/fx_dib_main.cpp index 74e9c3cfd5..65a4f89804 100644 --- a/core/src/fxge/dib/fx_dib_main.cpp +++ b/core/src/fxge/dib/fx_dib_main.cpp @@ -1054,10 +1054,8 @@ FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const case FXDIB_1bppRgb: { if ((*pos) & (1 << (7 - x % 8))) { return m_pPalette ? m_pPalette[1] : 0xffffffff; - } else { - return m_pPalette ? m_pPalette[0] : 0xff000000; } - break; + return m_pPalette ? m_pPalette[0] : 0xff000000; } case FXDIB_8bppMask: return (*pos) << 24; @@ -1618,7 +1616,8 @@ FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) { if (m_Status == 1) { return m_Stretcher.Continue(pPause); - } else if (m_Status == 2) { + } + if (m_Status == 2) { if (m_pTransformer->Continue(pPause)) { return TRUE; } diff --git a/core/src/fxge/dib/fx_dib_transform.cpp b/core/src/fxge/dib/fx_dib_transform.cpp index ba5964060e..ad0a3d3025 100644 --- a/core/src/fxge/dib/fx_dib_transform.cpp +++ b/core/src/fxge/dib/fx_dib_transform.cpp @@ -348,9 +348,11 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) m_Storer.Replace(m_Storer.GetBitmap()->SwapXY(m_pMatrix->c > 0, m_pMatrix->b < 0)); } return FALSE; - } else if (m_Status == 2) { + } + if (m_Status == 2) { return m_Stretcher.Continue(pPause); - } else if (m_Status != 3) { + } + if (m_Status != 3) { return FALSE; } if (m_Stretcher.Continue(pPause)) { diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp index 793dfc5ee2..0baa99cdc7 100644 --- a/core/src/fxge/ge/fx_ge_device.cpp +++ b/core/src/fxge/ge/fx_ge_device.cpp @@ -64,13 +64,14 @@ FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width, { if (m_RenderCaps & FXRC_CMYK_OUTPUT) { return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Cmyka : FXDIB_Cmyk); - } else if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) { + } + if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) { return pDIB->Create(width, height, FXDIB_8bppMask); - } else + } #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb32); + return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb32); #else - return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); + return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); #endif } FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp index d04f4fd59d..66c4e085f6 100644 --- a/core/src/fxge/ge/fx_ge_font.cpp +++ b/core/src/fxge/ge/fx_ge_font.cpp @@ -345,9 +345,8 @@ CFX_ByteString CFX_Font::GetFamilyName() const } if (m_Face) { return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); - } else { - return m_pSubstFont->m_Family; } + return m_pSubstFont->m_Family; } CFX_ByteString CFX_Font::GetFaceName() const { @@ -365,9 +364,8 @@ CFX_ByteString CFX_Font::GetFaceName() const facename += " " + style; } return facename; - } else { - return m_pSubstFont->m_Family; } + return m_pSubstFont->m_Family; } FX_BOOL CFX_Font::GetBBox(FX_RECT &bbox) { @@ -446,21 +444,20 @@ FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCode(FX_DWORD charcode) } FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCodeEx(FX_DWORD charcode, int encoding) { - FXFT_Face face = m_pFont->GetFace(); + FXFT_Face face = m_pFont->GetFace(); if (!face) { return charcode; } if (encoding == ENCODING_UNICODE) { - return GlyphFromCharCode(charcode); - } else { - int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face); - int i = 0; - while (i < nmaps) { - int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i++]); - if (encoding != FXFT_ENCODING_UNICODE) { - FXFT_Select_Charmap(face, encoding); - break; - } + return GlyphFromCharCode(charcode); + } + int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face); + int i = 0; + while (i < nmaps) { + int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i++]); + if (encoding != FXFT_ENCODING_UNICODE) { + FXFT_Select_Charmap(face, encoding); + break; } } return FXFT_Get_Char_Index(face, charcode); diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp index 538da9ae4c..e7281f3470 100644 --- a/core/src/fxge/ge/fx_ge_fontmap.cpp +++ b/core/src/fxge/ge/fx_ge_fontmap.cpp @@ -705,7 +705,8 @@ uint8_t _GetCharsetFromCodePage(FX_WORD codepage) const CHARSET_MAP & cp = g_Codepage2CharsetTable[iMid]; if (codepage == cp.codepage) { return cp.charset; - } else if (codepage < cp.codepage) { + } + if (codepage < cp.codepage) { iEnd = iMid - 1; } else { iStart = iMid + 1; @@ -1179,14 +1180,10 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTru m_pFontMgr->GetStandardFont(pFontData, size, 12); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); return m_FoxitFaces[12]; - } else { - pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; - return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont); } -#else +#endif pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont); -#endif } if (Charset == FXFONT_ANSI_CHARSET) { pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; @@ -1195,9 +1192,8 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTru int index = m_CharsetArray.Find(Charset); if (index < 0) { return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); - } else { - hFont = m_pFontInfo->GetFont(m_FaceArray[index]); } + hFont = m_pFontInfo->GetFont(m_FaceArray[index]); } } pSubstFont->m_ExtHandle = m_pFontInfo->RetainFont(hFont); diff --git a/core/src/fxge/ge/fx_ge_linux.cpp b/core/src/fxge/ge/fx_ge_linux.cpp index 0db41b5adf..51c0e64912 100644 --- a/core/src/fxge/ge/fx_ge_linux.cpp +++ b/core/src/fxge/ge/fx_ge_linux.cpp @@ -63,15 +63,14 @@ static int32_t GetJapanesePreference(const FX_CHAR* facearr, int weight, int pic if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) { if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) { return 0; - } else { - return 1; } - } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { + return 1; + } + if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) { return 2; - } else { - return 3; } + return 3; } if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) { return 0; diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp index ea1d80390b..b1410b3911 100644 --- a/core/src/fxge/ge/fx_ge_path.cpp +++ b/core/src/fxge/ge/fx_ge_path.cpp @@ -55,7 +55,8 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect, FX_RECT mask_rect, CFX_DIBitma if (m_Box.IsEmpty()) { m_Type = RectI; return; - } else if (m_Box == mask_rect) { + } + if (m_Box == mask_rect) { m_Mask = Mask; return; } @@ -229,7 +230,8 @@ static void _UpdateLineEndPoints(CFX_FloatRect& rect, FX_FLOAT start_x, FX_FLOAT rect.UpdateRect(end_x + hw, point_y); rect.UpdateRect(end_x - hw, point_y); return; - } else if (start_y == end_y) { + } + if (start_y == end_y) { FX_FLOAT point_x; if (end_x < start_x) { point_x = end_x - hw; diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp index d211391d68..ee3d86140f 100644 --- a/core/src/fxge/ge/fx_ge_text.cpp +++ b/core/src/fxge/ge/fx_ge_text.cpp @@ -1121,41 +1121,37 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD #else if (text_flags & FXTEXT_NO_NATIVETEXT) { return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontStyle, dest_width, anti_alias); + } + CFX_GlyphBitmap* pGlyphBitmap; + CFX_SizeGlyphCache* pSizeCache = NULL; + if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { + if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGlyphBitmap)) { + return pGlyphBitmap; + } + pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias); + if (pGlyphBitmap) { + pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); + return pGlyphBitmap; + } } else { - CFX_GlyphBitmap* pGlyphBitmap; - CFX_SizeGlyphCache* pSizeCache = NULL; - if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { - if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGlyphBitmap)) { - return pGlyphBitmap; - } - pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias); - if (pGlyphBitmap) { - pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); - return pGlyphBitmap; - } - } else { - pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias); - if (pGlyphBitmap) { - pSizeCache = FX_NEW CFX_SizeGlyphCache; - if (pSizeCache == NULL) { - return NULL; - } - m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); - pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); - return pGlyphBitmap; - } + pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias); + if (pGlyphBitmap) { + pSizeCache = new CFX_SizeGlyphCache; + m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); + pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); + return pGlyphBitmap; } - if (pFont->GetSubstFont()) - keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), - (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias, - pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical()); - else - keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), - (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias); - CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); - text_flags |= FXTEXT_NO_NATIVETEXT; - return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontStyle, dest_width, anti_alias); } + if (pFont->GetSubstFont()) + keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), + (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias, + pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical()); + else + keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), + (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias); + CFX_ByteStringC FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen); + text_flags |= FXTEXT_NO_NATIVETEXT; + return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey2, glyph_index, bFontStyle, dest_width, anti_alias); #endif } CFX_SizeGlyphCache::~CFX_SizeGlyphCache() diff --git a/core/src/fxge/skia/fx_skia_blitter_new.cpp b/core/src/fxge/skia/fx_skia_blitter_new.cpp index da9e6f28f1..3437eb497d 100644 --- a/core/src/fxge/skia/fx_skia_blitter_new.cpp +++ b/core/src/fxge/skia/fx_skia_blitter_new.cpp @@ -8,1603 +8,1602 @@ #include "../../../include/fxcodec/fx_codec.h" #include "SkBlitter.h" #include "fx_skia_blitter_new.h" - // We use our own renderer here to make it simple - void CFX_SkiaRenderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) - { - FXSYS_assert(m_Alpha); - if (m_pOriDevice == NULL && composite_span == NULL) return; - if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return; - while (1) - { - int width = runs[0]; - SkASSERT(width >= 0); - if (width <= 0) - return; - unsigned aa = antialias[0]; - if (aa) - (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, aa, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan); - runs += width; - antialias += width; - x += width; - } - } + // We use our own renderer here to make it simple + void CFX_SkiaRenderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) + { + FXSYS_assert(m_Alpha); + if (m_pOriDevice == NULL && composite_span == NULL) return; + if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return; + while (1) + { + int width = runs[0]; + SkASSERT(width >= 0); + if (width <= 0) + return; + unsigned aa = antialias[0]; + if (aa) + (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, aa, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan); + runs += width; + antialias += width; + x += width; + } + } - void CFX_SkiaRenderer::blitH(int x, int y, int width) - { - FXSYS_assert(m_Alpha && width); - if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return; - (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, 255, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan); - } + void CFX_SkiaRenderer::blitH(int x, int y, int width) + { + FXSYS_assert(m_Alpha && width); + if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return; + (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, 255, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan); + } - void CFX_SkiaRenderer::blitV(int x, int y, int height, SkAlpha alpha) - { - FXSYS_assert(m_Alpha && alpha); - if (alpha == 255) { - blitRect(x, y, 1, height); - } else { - int16_t runs[2]; - runs[0] = 1; - runs[1] = 0; - while (--height >= 0) { - if (y >= m_ClipBox.bottom) - return; - blitAntiH(x, y ++, &alpha, runs); - } - } - } - void CFX_SkiaRenderer::blitRect(int x, int y, int width, int height) - { - FXSYS_assert(m_Alpha && width); - while (--height >= 0){ - if (y >= m_ClipBox.bottom) - return; - blitH(x, y ++, width); - } - } + void CFX_SkiaRenderer::blitV(int x, int y, int height, SkAlpha alpha) + { + FXSYS_assert(m_Alpha && alpha); + if (alpha == 255) { + blitRect(x, y, 1, height); + } else { + int16_t runs[2]; + runs[0] = 1; + runs[1] = 0; + while (--height >= 0) { + if (y >= m_ClipBox.bottom) + return; + blitAntiH(x, y ++, &alpha, runs); + } + } + } + void CFX_SkiaRenderer::blitRect(int x, int y, int width, int height) + { + FXSYS_assert(m_Alpha && width); + while (--height >= 0){ + if (y >= m_ClipBox.bottom) + return; + blitH(x, y ++, width); + } + } - void CFX_SkiaRenderer::blitAntiRect(int x, int y, int width, int height, + void CFX_SkiaRenderer::blitAntiRect(int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha) - { - blitV(x++, y, height, leftAlpha); - if (width > 0) { - blitRect(x, y, width, height); - x += width; - } - blitV(x, y, height, rightAlpha); - } - /*---------------------------------------------------------------------------------------------------*/ - void CFX_SkiaRenderer::CompositeSpan1bpp_0(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_bRgbByteOrder); - ASSERT(!m_pDevice->IsCmykImage()); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start/8; + { + blitV(x++, y, height, leftAlpha); + if (width > 0) { + blitRect(x, y, width, height); + x += width; + } + blitV(x, y, height, rightAlpha); + } + /*---------------------------------------------------------------------------------------------------*/ + void CFX_SkiaRenderer::CompositeSpan1bpp_0(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_bRgbByteOrder); + ASSERT(!m_pDevice->IsCmykImage()); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start/8; - int index = 0; - if (m_pDevice->GetPalette() == NULL) - index = ((uint8_t)m_Color == 0xff) ? 1 : 0; - else { - for (int i = 0; i < 2; i ++) - if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) - index = i; - } - uint8_t* dest_scan1 = dest_scan; - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - if (src_alpha) { - if (!index) - *dest_scan1 &= ~(1 << (7 - (col+span_left)%8)); - else - *dest_scan1|= 1 << (7 - (col+span_left)%8); - } - dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8; - } - } - void CFX_SkiaRenderer::CompositeSpan1bpp_4(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_bRgbByteOrder); - ASSERT(!m_pDevice->IsCmykImage()); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8; - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start/8; + int index = 0; + if (m_pDevice->GetPalette() == NULL) + index = ((uint8_t)m_Color == 0xff) ? 1 : 0; + else { + for (int i = 0; i < 2; i ++) + if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) + index = i; + } + uint8_t* dest_scan1 = dest_scan; + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + if (src_alpha) { + if (!index) + *dest_scan1 &= ~(1 << (7 - (col+span_left)%8)); + else + *dest_scan1|= 1 << (7 - (col+span_left)%8); + } + dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8; + } + } + void CFX_SkiaRenderer::CompositeSpan1bpp_4(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_bRgbByteOrder); + ASSERT(!m_pDevice->IsCmykImage()); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8; + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start/8; - int index = 0; - if (m_pDevice->GetPalette() == NULL) - index = ((uint8_t)m_Color == 0xff) ? 1 : 0; - else { - for (int i = 0; i < 2; i ++) - if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) - index = i; - } - uint8_t* dest_scan1 = dest_scan; - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = src_alpha * clip_scan[col] / 255; - if (src_alpha1) { - if (!index) - *dest_scan1 &= ~(1 << (7 - (col+span_left)%8)); - else - *dest_scan1|= 1 << (7 - (col+span_left)%8); - } - dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8; - } - } - /*-----------------------------------------------------------------------------------------------------*/ - void CFX_SkiaRenderer::CompositeSpanGray_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_pDevice->IsCmykImage()); - ASSERT(!m_bRgbByteOrder); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start; - if (cover_scan == 255 && m_Alpha == 255) { - FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start); - return; - } - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); - dest_scan++; - } - } - void CFX_SkiaRenderer::CompositeSpanGray_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_pDevice->IsCmykImage()); - ASSERT(!m_bRgbByteOrder); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; - ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start; - ori_scan += col_start; - if (m_Alpha == 255 && cover_scan == 255) { - FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start); - } else { - int src_alpha = m_Alpha; + int index = 0; + if (m_pDevice->GetPalette() == NULL) + index = ((uint8_t)m_Color == 0xff) ? 1 : 0; + else { + for (int i = 0; i < 2; i ++) + if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) + index = i; + } + uint8_t* dest_scan1 = dest_scan; + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = src_alpha * clip_scan[col] / 255; + if (src_alpha1) { + if (!index) + *dest_scan1 &= ~(1 << (7 - (col+span_left)%8)); + else + *dest_scan1|= 1 << (7 - (col+span_left)%8); + } + dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8; + } + } + /*-----------------------------------------------------------------------------------------------------*/ + void CFX_SkiaRenderer::CompositeSpanGray_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_pDevice->IsCmykImage()); + ASSERT(!m_bRgbByteOrder); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start; + if (cover_scan == 255 && m_Alpha == 255) { + FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start); + return; + } + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); + dest_scan++; + } + } + void CFX_SkiaRenderer::CompositeSpanGray_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_pDevice->IsCmykImage()); + ASSERT(!m_bRgbByteOrder); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; + ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start; + ori_scan += col_start; + if (m_Alpha == 255 && cover_scan == 255) { + FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start); + } else { + int src_alpha = m_Alpha; #if 1 - for (int col = col_start; col < col_end; col ++) { - int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); - dest_scan ++; - } + for (int col = col_start; col < col_end; col ++) { + int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); + dest_scan ++; + } #else - if (m_bFullCover) { - if (src_alpha == 255) { - FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start); - return; - } - for (int col = col_start; col < col_end; col ++) - *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); - } else { - for (int col = col_start; col < col_end; col ++) { - int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); - dest_scan++; - } - } + if (m_bFullCover) { + if (src_alpha == 255) { + FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start); + return; + } + for (int col = col_start; col < col_end; col ++) + *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); + } else { + for (int col = col_start; col < col_end; col ++) { + int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); + dest_scan++; + } + } #endif - } - } + } + } - void CFX_SkiaRenderer::CompositeSpanGray_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_bRgbByteOrder); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start; - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = src_alpha * clip_scan[col] / 255; - if (!src_alpha1) { - dest_scan ++; - continue; - } - if (src_alpha1 == 255) - *dest_scan++ = m_Gray; - else { - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha1); - dest_scan ++; - } - } - } + void CFX_SkiaRenderer::CompositeSpanGray_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_bRgbByteOrder); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start; + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = src_alpha * clip_scan[col] / 255; + if (!src_alpha1) { + dest_scan ++; + continue; + } + if (src_alpha1 == 255) + *dest_scan++ = m_Gray; + else { + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha1); + dest_scan ++; + } + } + } - void CFX_SkiaRenderer::CompositeSpanGray_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_pDevice->IsCmykImage()); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; - ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left; - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start; - ori_scan += col_start; + void CFX_SkiaRenderer::CompositeSpanGray_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_pDevice->IsCmykImage()); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; + ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left; + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start; + ori_scan += col_start; #if 1 - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (src_alpha == 255 && cover_scan == 255) { - *dest_scan++ = m_Gray; - ori_scan++; - continue; - } - int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); - dest_scan++; - } + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (src_alpha == 255 && cover_scan == 255) { + *dest_scan++ = m_Gray; + ori_scan++; + continue; + } + int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); + dest_scan++; + } #else - if (m_bFullCover) { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (!src_alpha) { - dest_scan++; - ori_scan++; - continue; - } - if (src_alpha == 255){ - *dest_scan++ = m_Gray; - ori_scan++; - continue; - } - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); - } - } else { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (src_alpha == 255 && cover_scan == 255) { - *dest_scan++ = m_Gray; - ori_scan++; - continue; - } - int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); - dest_scan++; - } - } + if (m_bFullCover) { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (!src_alpha) { + dest_scan++; + ori_scan++; + continue; + } + if (src_alpha == 255){ + *dest_scan++ = m_Gray; + ori_scan++; + continue; + } + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); + } + } else { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (src_alpha == 255 && cover_scan == 255) { + *dest_scan++ = m_Gray; + ori_scan++; + continue; + } + int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); + dest_scan++; + } + } #endif - } - /*--------------------------------------------------------------------------------------------------*/ + } + /*--------------------------------------------------------------------------------------------------*/ - void CFX_SkiaRenderer::CompositeSpanARGB_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start<<2; - if (m_Alpha == 255 && cover_scan == 255) { - FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); - return; - } - int src_alpha; + void CFX_SkiaRenderer::CompositeSpanARGB_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start<<2; + if (m_Alpha == 255 && cover_scan == 255) { + FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); + return; + } + int src_alpha; #if 0 - if (m_bFullCover) { - if (m_Alpha == 255) { - FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); - return; - } - } - else + if (m_bFullCover) { + if (m_Alpha == 255) { + FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); + return; + } + } + else #endif - src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - // Dest format: Argb - // calculate destination alpha (it's union of source and dest alpha) - if (dest_scan[3] == 0) { - dest_scan[3] = src_alpha; - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan = m_Red; - dest_scan += 2; - continue; - } - uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255; - dest_scan[3] = dest_alpha; - int alpha_ratio = src_alpha*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan += 2; - } - } + src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + // Dest format: Argb + // calculate destination alpha (it's union of source and dest alpha) + if (dest_scan[3] == 0) { + dest_scan[3] = src_alpha; + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan = m_Red; + dest_scan += 2; + continue; + } + uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255; + dest_scan[3] = dest_alpha; + int alpha_ratio = src_alpha*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan += 2; + } + } - void CFX_SkiaRenderer::CompositeSpanARGB_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_pDevice->IsCmykImage()); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); - //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start << 2; - //ori_scan += col_start << 2; + void CFX_SkiaRenderer::CompositeSpanARGB_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_pDevice->IsCmykImage()); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); + //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start << 2; + //ori_scan += col_start << 2; - if (m_Alpha == 255 && cover_scan == 255){ - FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); - return; - } - if (cover_scan == 255) { - int dst_color = (0x00ffffff&m_Color)|(m_Alpha<<24); - FXSYS_memset(dest_scan, dst_color, (col_end - col_start)<<2); - return; - } - // Do not need origin bitmap, because of merge in pure transparent background - int src_alpha_covered = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) - { - // shortcut - if (dest_scan[3] == 0) { - dest_scan[3] = src_alpha_covered; - *dest_scan ++ = m_Blue; - *dest_scan ++ = m_Green; - *dest_scan = m_Red; - dest_scan += 2; - continue; - } - // We should do alpha transition and color transition - // alpha fg color fg - // alpha bg color bg - // alpha cover color cover - dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], m_Alpha, cover_scan); - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan); - dest_scan += 2; - } - } - void CFX_SkiaRenderer::CompositeSpanARGB_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start << 2; + if (m_Alpha == 255 && cover_scan == 255){ + FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); + return; + } + if (cover_scan == 255) { + int dst_color = (0x00ffffff&m_Color)|(m_Alpha<<24); + FXSYS_memset(dest_scan, dst_color, (col_end - col_start)<<2); + return; + } + // Do not need origin bitmap, because of merge in pure transparent background + int src_alpha_covered = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) + { + // shortcut + if (dest_scan[3] == 0) { + dest_scan[3] = src_alpha_covered; + *dest_scan ++ = m_Blue; + *dest_scan ++ = m_Green; + *dest_scan = m_Red; + dest_scan += 2; + continue; + } + // We should do alpha transition and color transition + // alpha fg color fg + // alpha bg color bg + // alpha cover color cover + dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], m_Alpha, cover_scan); + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan); + dest_scan += 2; + } + } + void CFX_SkiaRenderer::CompositeSpanARGB_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start << 2; #if 1 - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = src_alpha* clip_scan[col] / 255; - if (!src_alpha1) { - dest_scan += 4; - continue; - } - if (src_alpha1 == 255) { - *(FX_DWORD*)dest_scan = m_Color; - dest_scan += 4; - } else { - // Dest format: Argb - // calculate destination alpha (it's union of source and dest alpha) - if (dest_scan[3] == 0) { - dest_scan[3] = src_alpha1; - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan = m_Red; - dest_scan += 2; - continue; - } - uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255; - dest_scan[3] = dest_alpha; - int alpha_ratio = src_alpha1*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan += 2; - } - } + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = src_alpha* clip_scan[col] / 255; + if (!src_alpha1) { + dest_scan += 4; + continue; + } + if (src_alpha1 == 255) { + *(FX_DWORD*)dest_scan = m_Color; + dest_scan += 4; + } else { + // Dest format: Argb + // calculate destination alpha (it's union of source and dest alpha) + if (dest_scan[3] == 0) { + dest_scan[3] = src_alpha1; + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan = m_Red; + dest_scan += 2; + continue; + } + uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255; + dest_scan[3] = dest_alpha; + int alpha_ratio = src_alpha1*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan += 2; + } + } #else - if (m_bFullCover) { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (!src_alpha) { - dest_scan += 4; - continue; - } - if (src_alpha == 255){ - *(FX_DWORD*)dest_scan = m_Color; - dest_scan += 4; - continue; - } else { - // Dest format: Argb - // calculate destination alpha (it's union of source and dest alpha) - if (dest_scan[3] == 0) { - dest_scan[3] = src_alpha; - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan = m_Red; - dest_scan += 2; - continue; - } - uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255; - dest_scan[3] = dest_alpha; - int alpha_ratio = src_alpha*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan += 2; - } - } - } else { - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = src_alpha* clip_scan[col] / 255; - if (!src_alpha1) { - dest_scan += 4; - continue; - } - if (src_alpha1 == 255) { - *(FX_DWORD*)dest_scan = m_Color; - dest_scan += 4; - } else { - // Dest format: Argb - // calculate destination alpha (it's union of source and dest alpha) - if (dest_scan[3] == 0) { - dest_scan[3] = src_alpha1; - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan = m_Red; - dest_scan += 2; - continue; - } - uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255; - dest_scan[3] = dest_alpha; - int alpha_ratio = src_alpha1*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan += 2; - } - } - } + if (m_bFullCover) { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (!src_alpha) { + dest_scan += 4; + continue; + } + if (src_alpha == 255){ + *(FX_DWORD*)dest_scan = m_Color; + dest_scan += 4; + continue; + } else { + // Dest format: Argb + // calculate destination alpha (it's union of source and dest alpha) + if (dest_scan[3] == 0) { + dest_scan[3] = src_alpha; + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan = m_Red; + dest_scan += 2; + continue; + } + uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255; + dest_scan[3] = dest_alpha; + int alpha_ratio = src_alpha*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan += 2; + } + } + } else { + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = src_alpha* clip_scan[col] / 255; + if (!src_alpha1) { + dest_scan += 4; + continue; + } + if (src_alpha1 == 255) { + *(FX_DWORD*)dest_scan = m_Color; + dest_scan += 4; + } else { + // Dest format: Argb + // calculate destination alpha (it's union of source and dest alpha) + if (dest_scan[3] == 0) { + dest_scan[3] = src_alpha1; + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan = m_Red; + dest_scan += 2; + continue; + } + uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255; + dest_scan[3] = dest_alpha; + int alpha_ratio = src_alpha1*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan += 2; + } + } + } #endif - } + } - void CFX_SkiaRenderer::CompositeSpanARGB_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_pDevice->IsCmykImage()); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); - //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start << 2; - //ori_scan += col_start << 2; - // Do not need origin bitmap, because of merge in pure transparent background - for (int col = col_start; col < col_end; col ++) - { - int src_alpha = m_Alpha * clip_scan[col] / 255; - int src_alpha_covered = src_alpha * cover_scan / 255; - // shortcut - if (src_alpha_covered == 0){ - dest_scan += 4; - continue; - } - // shortcut - if (cover_scan == 255 || dest_scan[3] == 0) - { - // origin alpha always zero, just get src alpha - dest_scan[3] = src_alpha_covered; - *dest_scan ++ = m_Blue; - *dest_scan ++ = m_Green; - *dest_scan = m_Red; - dest_scan += 2; - continue; - } - // We should do alpha transition and color transition - // alpha fg color fg - // alpha bg color bg - // alpha cover color cover - dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], src_alpha, cover_scan); - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan); - dest_scan += 2; - } - } + void CFX_SkiaRenderer::CompositeSpanARGB_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_pDevice->IsCmykImage()); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); + //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start << 2; + //ori_scan += col_start << 2; + // Do not need origin bitmap, because of merge in pure transparent background + for (int col = col_start; col < col_end; col ++) + { + int src_alpha = m_Alpha * clip_scan[col] / 255; + int src_alpha_covered = src_alpha * cover_scan / 255; + // shortcut + if (src_alpha_covered == 0){ + dest_scan += 4; + continue; + } + // shortcut + if (cover_scan == 255 || dest_scan[3] == 0) + { + // origin alpha always zero, just get src alpha + dest_scan[3] = src_alpha_covered; + *dest_scan ++ = m_Blue; + *dest_scan ++ = m_Green; + *dest_scan = m_Red; + dest_scan += 2; + continue; + } + // We should do alpha transition and color transition + // alpha fg color fg + // alpha bg color bg + // alpha cover color cover + dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], src_alpha, cover_scan); + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan); + dest_scan += 2; + } + } - /*-----------------------------------------------------------------------------------------------------------*/ - void CFX_SkiaRenderer::CompositeSpanRGB32_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += (col_start << 2); - if (m_Alpha == 255 && cover_scan == 255) { - FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); - return; - } - int src_alpha; + /*-----------------------------------------------------------------------------------------------------------*/ + void CFX_SkiaRenderer::CompositeSpanRGB32_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += (col_start << 2); + if (m_Alpha == 255 && cover_scan == 255) { + FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); + return; + } + int src_alpha; #if 0 - if (m_bFullCover) - src_alpha = m_Alpha; - else + if (m_bFullCover) + src_alpha = m_Alpha; + else #endif - src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - // Dest format: Rgb32 - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); - dest_scan += 2; - } - } - void CFX_SkiaRenderer::CompositeSpanRGB32_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); - ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start << 2; - ori_scan += col_start << 2; - if (m_Alpha == 255 && cover_scan == 255) { - FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); - return; - } - int src_alpha = m_Alpha; - for (int col = col_start; col < col_end; col ++) { + src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + // Dest format: Rgb32 + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); + dest_scan += 2; + } + } + void CFX_SkiaRenderer::CompositeSpanRGB32_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); + ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start << 2; + ori_scan += col_start << 2; + if (m_Alpha == 255 && cover_scan == 255) { + FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); + return; + } + int src_alpha = m_Alpha; + for (int col = col_start; col < col_end; col ++) { #if 0 - if (m_bFullCover) { - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); - *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); - dest_scan += 2; ori_scan += 2; - continue; - } + if (m_bFullCover) { + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); + *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); + dest_scan += 2; ori_scan += 2; + continue; + } #endif - int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); - int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); - int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); - ori_scan += 2; - *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); - dest_scan += 2; - } - } - void CFX_SkiaRenderer::CompositeSpanRGB32_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start << 2; + int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); + int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); + int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); + ori_scan += 2; + *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); + dest_scan += 2; + } + } + void CFX_SkiaRenderer::CompositeSpanRGB32_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start << 2; #if 1 - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = src_alpha * clip_scan[col] / 255; - if (!src_alpha1) { - dest_scan += 4; - continue; - } - if (src_alpha1 == 255) { - *(FX_DWORD*)dest_scan = m_Color; - dest_scan += 4; - } else { - // Dest format: Rgb or Rgb32 - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); - dest_scan += 2; - } - } + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = src_alpha * clip_scan[col] / 255; + if (!src_alpha1) { + dest_scan += 4; + continue; + } + if (src_alpha1 == 255) { + *(FX_DWORD*)dest_scan = m_Color; + dest_scan += 4; + } else { + // Dest format: Rgb or Rgb32 + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); + dest_scan += 2; + } + } #else - if (m_bFullCover) { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (!src_alpha) { - dest_scan += 4; - continue; - } - if (src_alpha == 255) { - *(FX_DWORD*)dest_scan = m_Color; - dest_scan += 4; - } else { - // Dest format: Rgb or Rgb32 - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); - dest_scan += 2; - } - } - } else { - // Rgb32 - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = src_alpha * clip_scan[col] / 255; - if (!src_alpha1) { - dest_scan += 4; - continue; - } - if (src_alpha1 == 255) { - *(FX_DWORD*)dest_scan = m_Color; - dest_scan += 4; - } else { - // Dest format: Rgb or Rgb32 - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); - dest_scan += 2; - } - } - } + if (m_bFullCover) { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (!src_alpha) { + dest_scan += 4; + continue; + } + if (src_alpha == 255) { + *(FX_DWORD*)dest_scan = m_Color; + dest_scan += 4; + } else { + // Dest format: Rgb or Rgb32 + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); + dest_scan += 2; + } + } + } else { + // Rgb32 + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = src_alpha * clip_scan[col] / 255; + if (!src_alpha1) { + dest_scan += 4; + continue; + } + if (src_alpha1 == 255) { + *(FX_DWORD*)dest_scan = m_Color; + dest_scan += 4; + } else { + // Dest format: Rgb or Rgb32 + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); + dest_scan += 2; + } + } + } #endif - } - void CFX_SkiaRenderer::CompositeSpanRGB32_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_pDevice->IsCmykImage()); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); - ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start << 2; - ori_scan += col_start << 2; + } + void CFX_SkiaRenderer::CompositeSpanRGB32_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_pDevice->IsCmykImage()); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); + ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start << 2; + ori_scan += col_start << 2; #if 1 - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (src_alpha == 255 && cover_scan == 255) { - *(FX_DWORD*)dest_scan = m_Color; - dest_scan += 4; - ori_scan += 4; - continue; - } - int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); - int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); - int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); - ori_scan += 2; - *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); - dest_scan += 2; - } + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (src_alpha == 255 && cover_scan == 255) { + *(FX_DWORD*)dest_scan = m_Color; + dest_scan += 4; + ori_scan += 4; + continue; + } + int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); + int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); + int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); + ori_scan += 2; + *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); + dest_scan += 2; + } #else - if (m_bFullCover) { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (!src_alpha) { - *(FX_DWORD*)dest_scan = *(FX_DWORD*)ori_scan; - dest_scan += 4; - ori_scan += 4; - continue; - } - if (src_alpha == 255) { - *(FX_DWORD*)dest_scan = m_Color; - dest_scan += 4; - ori_scan += 4; - continue; - } - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); - *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); - dest_scan += 2; ori_scan += 2; - } - } else { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (src_alpha == 255 && cover_scan == 255) { - *(FX_DWORD*)dest_scan = m_Color; - dest_scan += 4; - ori_scan += 4; - continue; - } - int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); - int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); - int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); - ori_scan += 2; - *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); - dest_scan += 2; - } - } + if (m_bFullCover) { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (!src_alpha) { + *(FX_DWORD*)dest_scan = *(FX_DWORD*)ori_scan; + dest_scan += 4; + ori_scan += 4; + continue; + } + if (src_alpha == 255) { + *(FX_DWORD*)dest_scan = m_Color; + dest_scan += 4; + ori_scan += 4; + continue; + } + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); + *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); + dest_scan += 2; ori_scan += 2; + } + } else { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (src_alpha == 255 && cover_scan == 255) { + *(FX_DWORD*)dest_scan = m_Color; + dest_scan += 4; + ori_scan += 4; + continue; + } + int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); + int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); + int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); + ori_scan += 2; + *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); + dest_scan += 2; + } + } #endif - } - /*-----------------------------------------------------------------------------------------------------*/ - void CFX_SkiaRenderer::CompositeSpanRGB24_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1); - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += (col_start<<1)+col_start; - int src_alpha; + } + /*-----------------------------------------------------------------------------------------------------*/ + void CFX_SkiaRenderer::CompositeSpanRGB24_2(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1); + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += (col_start<<1)+col_start; + int src_alpha; #if 0 - if (m_bFullCover) - src_alpha = m_Alpha; - else + if (m_bFullCover) + src_alpha = m_Alpha; + else #endif - src_alpha = m_Alpha * cover_scan / 255; - if (src_alpha == 255) { - for (int col = col_start; col < col_end; col ++) { - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan++ = m_Red; - } - return; - } - for (int col = col_start; col < col_end; col ++) { - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); - dest_scan ++; - } - } - void CFX_SkiaRenderer::CompositeSpanRGB24_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_pDevice->IsCmykImage()); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1); - ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left + (span_left<<1); - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += (col_start<<1) + col_start; - ori_scan += (col_start<<1) + col_start; - if (m_Alpha == 255&&cover_scan == 255) { - for (int col = col_start; col < col_end; col ++) { - *dest_scan ++ = m_Blue; - *dest_scan ++ = m_Green; - *dest_scan ++ = m_Red; - } - return; - } - for (int col = col_start; col < col_end; col ++) { + src_alpha = m_Alpha * cover_scan / 255; + if (src_alpha == 255) { + for (int col = col_start; col < col_end; col ++) { + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan++ = m_Red; + } + return; + } + for (int col = col_start; col < col_end; col ++) { + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); + dest_scan ++; + } + } + void CFX_SkiaRenderer::CompositeSpanRGB24_3(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_pDevice->IsCmykImage()); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1); + ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left + (span_left<<1); + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += (col_start<<1) + col_start; + ori_scan += (col_start<<1) + col_start; + if (m_Alpha == 255&&cover_scan == 255) { + for (int col = col_start; col < col_end; col ++) { + *dest_scan ++ = m_Blue; + *dest_scan ++ = m_Green; + *dest_scan ++ = m_Red; + } + return; + } + for (int col = col_start; col < col_end; col ++) { #if 0 - if (m_bFullCover) { - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); - continue; - } + if (m_bFullCover) { + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); + continue; + } #endif - int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); - int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); - int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); - *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); - dest_scan ++; - } - } - void CFX_SkiaRenderer::CompositeSpanRGB24_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1); - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start + (col_start << 1); + int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); + int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); + int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); + *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); + dest_scan ++; + } + } + void CFX_SkiaRenderer::CompositeSpanRGB24_6(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1); + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start + (col_start << 1); #if 1 - int src_alpha = m_Alpha * cover_scan /255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = src_alpha * clip_scan[col] / 255; - if (!src_alpha1) { - dest_scan += 3; - continue; - } - if (src_alpha1 == 255) { - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan++ = m_Red; - } else { - // Dest format: Rgb - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); - dest_scan ++; - } - } + int src_alpha = m_Alpha * cover_scan /255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = src_alpha * clip_scan[col] / 255; + if (!src_alpha1) { + dest_scan += 3; + continue; + } + if (src_alpha1 == 255) { + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan++ = m_Red; + } else { + // Dest format: Rgb + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); + dest_scan ++; + } + } #else - if (m_bFullCover) { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (!src_alpha) { - dest_scan += 3; - continue; - } - if (src_alpha == 255) { - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan++ = m_Red; - } else { - // Dest format: Rgb - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); - dest_scan ++; - } - } - } else { - int src_alpha = m_Alpha * cover_scan /255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = src_alpha * clip_scan[col] / 255; - if (!src_alpha1) { - dest_scan += 3; - continue; - } - if (src_alpha1 == 255) { - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan++ = m_Red; - } else { - // Dest format: Rgb - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); - dest_scan ++; - } - } - } + if (m_bFullCover) { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (!src_alpha) { + dest_scan += 3; + continue; + } + if (src_alpha == 255) { + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan++ = m_Red; + } else { + // Dest format: Rgb + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); + dest_scan ++; + } + } + } else { + int src_alpha = m_Alpha * cover_scan /255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = src_alpha * clip_scan[col] / 255; + if (!src_alpha1) { + dest_scan += 3; + continue; + } + if (src_alpha1 == 255) { + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan++ = m_Red; + } else { + // Dest format: Rgb + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); + dest_scan ++; + } + } + } #endif - } - void CFX_SkiaRenderer::CompositeSpanRGB24_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_pDevice->IsCmykImage()); - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1); - ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left+(span_left<<1); - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start + (col_start<<1); - ori_scan += col_start + (col_start<<1); + } + void CFX_SkiaRenderer::CompositeSpanRGB24_7(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_pDevice->IsCmykImage()); + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1); + ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left+(span_left<<1); + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start + (col_start<<1); + ori_scan += col_start + (col_start<<1); #if 1 - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (src_alpha == 255 && cover_scan == 255) { - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan++ = m_Red; - ori_scan += 3; - continue; - } - int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); - int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); - int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); - *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); - dest_scan ++; - } + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (src_alpha == 255 && cover_scan == 255) { + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan++ = m_Red; + ori_scan += 3; + continue; + } + int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); + int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); + int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); + *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); + dest_scan ++; + } #else - if (m_bFullCover) { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (!src_alpha){ - *dest_scan++ = *ori_scan++; - *dest_scan++ = *ori_scan++; - *dest_scan++ = *ori_scan++; - continue; - } - if (src_alpha == 255){ - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan++ = m_Red; - ori_scan += 3; - continue; - } - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); - *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); - } - } else { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (src_alpha == 255 && cover_scan == 255) { - *dest_scan++ = m_Blue; - *dest_scan++ = m_Green; - *dest_scan++ = m_Red; - ori_scan += 3; - continue; - } - int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); - int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); - int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); - *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); - dest_scan ++; - } - } + if (m_bFullCover) { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (!src_alpha){ + *dest_scan++ = *ori_scan++; + *dest_scan++ = *ori_scan++; + *dest_scan++ = *ori_scan++; + continue; + } + if (src_alpha == 255){ + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan++ = m_Red; + ori_scan += 3; + continue; + } + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); + *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); + } + } else { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (src_alpha == 255 && cover_scan == 255) { + *dest_scan++ = m_Blue; + *dest_scan++ = m_Green; + *dest_scan++ = m_Red; + ori_scan += 3; + continue; + } + int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); + int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); + int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); + *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); + dest_scan ++; + } + } #endif - } - void CFX_SkiaRenderer::CompositeSpanRGB24_10(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1); - dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start+(col_start<<1); + } + void CFX_SkiaRenderer::CompositeSpanRGB24_10(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1); + dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start+(col_start<<1); #if 1 - if (m_Alpha == 255 && cover_scan == 255) { - for (int col = col_start; col < col_end; col ++) { - *dest_scan++ = (uint8_t)m_Blue; - *dest_scan++ = (uint8_t)m_Green; - *dest_scan++ = (uint8_t)m_Red; - *dest_extra_alpha_scan++ = 255; - } - return; - } - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - // Dest format: Rgba - // calculate destination alpha (it's union of source and dest alpha) - uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - - (*dest_extra_alpha_scan) * src_alpha / 255; - *dest_extra_alpha_scan++ = dest_alpha; - int alpha_ratio = src_alpha*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan ++; - } + if (m_Alpha == 255 && cover_scan == 255) { + for (int col = col_start; col < col_end; col ++) { + *dest_scan++ = (uint8_t)m_Blue; + *dest_scan++ = (uint8_t)m_Green; + *dest_scan++ = (uint8_t)m_Red; + *dest_extra_alpha_scan++ = 255; + } + return; + } + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + // Dest format: Rgba + // calculate destination alpha (it's union of source and dest alpha) + uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - + (*dest_extra_alpha_scan) * src_alpha / 255; + *dest_extra_alpha_scan++ = dest_alpha; + int alpha_ratio = src_alpha*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan ++; + } #else - if (m_bFullCover) { - if (m_Alpha == 255) { - for (int col = col_start; col < col_end; col ++) { - *dest_scan++ = (uint8_t)m_Blue; - *dest_scan++ = (uint8_t)m_Green; - *dest_scan++ = (uint8_t)m_Red; - *dest_extra_alpha_scan++ = 255; - } - return; - } - for (int col = col_start; col < col_end; col ++) { - // Dest format: Rgba - // calculate destination alpha (it's union of source and dest alpha) - uint8_t dest_alpha = (*dest_extra_alpha_scan) + m_Alpha - - (*dest_extra_alpha_scan) * m_Alpha / 255; - *dest_extra_alpha_scan++ = dest_alpha; - int alpha_ratio = m_Alpha*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan ++; - } - } else { - if (m_Alpha == 255 && cover_scan == 255) { - for (int col = col_start; col < col_end; col ++) { - *dest_scan++ = (uint8_t)m_Blue; - *dest_scan++ = (uint8_t)m_Green; - *dest_scan++ = (uint8_t)m_Red; - *dest_extra_alpha_scan++ = 255; - } - return; - } - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - // Dest format: Rgba - // calculate destination alpha (it's union of source and dest alpha) - uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - - (*dest_extra_alpha_scan) * src_alpha / 255; - *dest_extra_alpha_scan++ = dest_alpha; - int alpha_ratio = src_alpha*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan ++; - } - } + if (m_bFullCover) { + if (m_Alpha == 255) { + for (int col = col_start; col < col_end; col ++) { + *dest_scan++ = (uint8_t)m_Blue; + *dest_scan++ = (uint8_t)m_Green; + *dest_scan++ = (uint8_t)m_Red; + *dest_extra_alpha_scan++ = 255; + } + return; + } + for (int col = col_start; col < col_end; col ++) { + // Dest format: Rgba + // calculate destination alpha (it's union of source and dest alpha) + uint8_t dest_alpha = (*dest_extra_alpha_scan) + m_Alpha - + (*dest_extra_alpha_scan) * m_Alpha / 255; + *dest_extra_alpha_scan++ = dest_alpha; + int alpha_ratio = m_Alpha*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan ++; + } + } else { + if (m_Alpha == 255 && cover_scan == 255) { + for (int col = col_start; col < col_end; col ++) { + *dest_scan++ = (uint8_t)m_Blue; + *dest_scan++ = (uint8_t)m_Green; + *dest_scan++ = (uint8_t)m_Red; + *dest_extra_alpha_scan++ = 255; + } + return; + } + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + // Dest format: Rgba + // calculate destination alpha (it's union of source and dest alpha) + uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - + (*dest_extra_alpha_scan) * src_alpha / 255; + *dest_extra_alpha_scan++ = dest_alpha; + int alpha_ratio = src_alpha*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan ++; + } + } #endif - } - void CFX_SkiaRenderer::CompositeSpanRGB24_14(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1); - dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left; - clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start + (col_start << 1); + } + void CFX_SkiaRenderer::CompositeSpanRGB24_14(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1); + dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left; + clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left; + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start + (col_start << 1); #if 1 - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = src_alpha * clip_scan[col] / 255; - if (!src_alpha1) { - dest_extra_alpha_scan++; - dest_scan += 3; - continue; - } - if (src_alpha1 == 255) { - *dest_scan++ = (uint8_t)m_Blue; - *dest_scan++ = (uint8_t)m_Green; - *dest_scan++ = (uint8_t)m_Red; - *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; - } else { - // Dest format: Rgba - // calculate destination alpha (it's union of source and dest alpha) - uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 - - (*dest_extra_alpha_scan) * src_alpha1 / 255; - *dest_extra_alpha_scan++ = dest_alpha; - int alpha_ratio = src_alpha1*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan ++; - } - } + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = src_alpha * clip_scan[col] / 255; + if (!src_alpha1) { + dest_extra_alpha_scan++; + dest_scan += 3; + continue; + } + if (src_alpha1 == 255) { + *dest_scan++ = (uint8_t)m_Blue; + *dest_scan++ = (uint8_t)m_Green; + *dest_scan++ = (uint8_t)m_Red; + *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; + } else { + // Dest format: Rgba + // calculate destination alpha (it's union of source and dest alpha) + uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 - + (*dest_extra_alpha_scan) * src_alpha1 / 255; + *dest_extra_alpha_scan++ = dest_alpha; + int alpha_ratio = src_alpha1*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan ++; + } + } #else - if (m_bFullCover) { - for (int col = col_start; col < col_end; col ++) { - int src_alpha = m_Alpha * clip_scan[col] / 255; - if (!src_alpha) { - dest_extra_alpha_scan++; - dest_scan += 3; - continue; - } - if (src_alpha == 255) { - *dest_scan++ = (uint8_t)m_Blue; - *dest_scan++ = (uint8_t)m_Green; - *dest_scan++ = (uint8_t)m_Red; - *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; - } else { - // Dest format: Rgba - // calculate destination alpha (it's union of source and dest alpha) - uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - - (*dest_extra_alpha_scan) * src_alpha / 255; - *dest_extra_alpha_scan++ = dest_alpha; - int alpha_ratio = src_alpha*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan ++; - } - } - } else { - int src_alpha = m_Alpha * cover_scan / 255; - for (int col = col_start; col < col_end; col ++) { - int src_alpha1 = m_Alpha * cover_scan * clip_scan[col] / 255; - if (!src_alpha1) { - dest_extra_alpha_scan++; - dest_scan += 3; - continue; - } - if (src_alpha1 == 255) { - *dest_scan++ = (uint8_t)m_Blue; - *dest_scan++ = (uint8_t)m_Green; - *dest_scan++ = (uint8_t)m_Red; - *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; - } else { - // Dest format: Rgba - // calculate destination alpha (it's union of source and dest alpha) - uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 - - (*dest_extra_alpha_scan) * src_alpha1 / 255; - *dest_extra_alpha_scan++ = dest_alpha; - int alpha_ratio = src_alpha1*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan ++; - } - } - } + if (m_bFullCover) { + for (int col = col_start; col < col_end; col ++) { + int src_alpha = m_Alpha * clip_scan[col] / 255; + if (!src_alpha) { + dest_extra_alpha_scan++; + dest_scan += 3; + continue; + } + if (src_alpha == 255) { + *dest_scan++ = (uint8_t)m_Blue; + *dest_scan++ = (uint8_t)m_Green; + *dest_scan++ = (uint8_t)m_Red; + *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; + } else { + // Dest format: Rgba + // calculate destination alpha (it's union of source and dest alpha) + uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - + (*dest_extra_alpha_scan) * src_alpha / 255; + *dest_extra_alpha_scan++ = dest_alpha; + int alpha_ratio = src_alpha*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan ++; + } + } + } else { + int src_alpha = m_Alpha * cover_scan / 255; + for (int col = col_start; col < col_end; col ++) { + int src_alpha1 = m_Alpha * cover_scan * clip_scan[col] / 255; + if (!src_alpha1) { + dest_extra_alpha_scan++; + dest_scan += 3; + continue; + } + if (src_alpha1 == 255) { + *dest_scan++ = (uint8_t)m_Blue; + *dest_scan++ = (uint8_t)m_Green; + *dest_scan++ = (uint8_t)m_Red; + *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; + } else { + // Dest format: Rgba + // calculate destination alpha (it's union of source and dest alpha) + uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 - + (*dest_extra_alpha_scan) * src_alpha1 / 255; + *dest_extra_alpha_scan++ = dest_alpha; + int alpha_ratio = src_alpha1*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan ++; + } + } + } #endif - } - /*-----------------------------------------------------------------------------------------------------*/ + } + /*-----------------------------------------------------------------------------------------------------*/ - // A general alpha merge function (with clipping mask). Cmyka/Cmyk device. - void CFX_SkiaRenderer::CompositeSpanCMYK(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, - int span_left, int span_len, int span_top, uint8_t cover_scan, - int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, - uint8_t* dest_extra_alpha_scan) - { - ASSERT(!m_bRgbByteOrder); - // Cmyk(a) - int col_start = span_left < clip_left ? clip_left - span_left : 0; - int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); - if (col_end < col_start) return; // do nothing. - dest_scan += col_start * 4; - Bpp; // for avoid compile warning. + // A general alpha merge function (with clipping mask). Cmyka/Cmyk device. + void CFX_SkiaRenderer::CompositeSpanCMYK(uint8_t* dest_scan, uint8_t* ori_scan,int Bpp, + int span_left, int span_len, int span_top, uint8_t cover_scan, + int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, + uint8_t* dest_extra_alpha_scan) + { + ASSERT(!m_bRgbByteOrder); + // Cmyk(a) + int col_start = span_left < clip_left ? clip_left - span_left : 0; + int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); + if (col_end < col_start) return; // do nothing. + dest_scan += col_start * 4; + Bpp; // for avoid compile warning. - if (dest_extra_alpha_scan) { - // CMYKa - for (int col = col_start; col < col_end; col ++) { - int src_alpha; - if (m_bFullCover) { - if (clip_scan) - src_alpha = m_Alpha * clip_scan[col] / 255; - else - src_alpha = m_Alpha; - } else { - if (clip_scan) - src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255; - else - src_alpha = m_Alpha * cover_scan / 255; - } + if (dest_extra_alpha_scan) { + // CMYKa + for (int col = col_start; col < col_end; col ++) { + int src_alpha; + if (m_bFullCover) { + if (clip_scan) + src_alpha = m_Alpha * clip_scan[col] / 255; + else + src_alpha = m_Alpha; + } else { + if (clip_scan) + src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255; + else + src_alpha = m_Alpha * cover_scan / 255; + } - if (src_alpha) { - if (src_alpha == 255) { - *(FX_CMYK*)dest_scan = m_Color; - *dest_extra_alpha_scan = (uint8_t)m_Alpha; - } else { - // Dest format: Cmyka - // calculate destination alpha (it's union of source and dest alpha) - uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - - (*dest_extra_alpha_scan) * src_alpha / 255; - *dest_extra_alpha_scan++ = dest_alpha; - int alpha_ratio = src_alpha*255/dest_alpha; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, alpha_ratio); - dest_scan ++; - continue; - } - } - dest_extra_alpha_scan++; - dest_scan += 4; - } - } else { - // CMYK - for (int col = col_start; col < col_end; col ++) { - int src_alpha; - if (clip_scan) - src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255; - else - src_alpha = m_Alpha * cover_scan / 255; + if (src_alpha) { + if (src_alpha == 255) { + *(FX_CMYK*)dest_scan = m_Color; + *dest_extra_alpha_scan = (uint8_t)m_Alpha; + } else { + // Dest format: Cmyka + // calculate destination alpha (it's union of source and dest alpha) + uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - + (*dest_extra_alpha_scan) * src_alpha / 255; + *dest_extra_alpha_scan++ = dest_alpha; + int alpha_ratio = src_alpha*255/dest_alpha; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, alpha_ratio); + dest_scan ++; + continue; + } + } + dest_extra_alpha_scan++; + dest_scan += 4; + } + } else { + // CMYK + for (int col = col_start; col < col_end; col ++) { + int src_alpha; + if (clip_scan) + src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255; + else + src_alpha = m_Alpha * cover_scan / 255; - if (src_alpha) { - if (src_alpha == 255) { - *(FX_CMYK*)dest_scan = m_Color; - } else { - // Dest format: cmyk - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); - dest_scan ++; - *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); - dest_scan ++; - continue; - } - } - dest_scan += 4; - } - } - } + if (src_alpha) { + if (src_alpha == 255) { + *(FX_CMYK*)dest_scan = m_Color; + } else { + // Dest format: cmyk + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); + dest_scan ++; + *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); + dest_scan ++; + continue; + } + } + dest_scan += 4; + } + } + } - //-------------------------------------------------------------------- - FX_BOOL CFX_SkiaRenderer::Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevice, const CFX_ClipRgn* pClipRgn, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bRgbByteOrder, - int alpha_flag, void* pIccTransform) //The alpha flag must be fill_flag if exist. - { - m_pDevice = pDevice; - m_pClipRgn = pClipRgn; - m_bRgbByteOrder = bRgbByteOrder; - m_pOriDevice = pOriDevice; - m_pDestScan = NULL; - m_pDestExtraAlphaScan = NULL; - m_pOriScan = NULL; - m_pClipScan = NULL; - composite_span = NULL; - if (m_pClipRgn) - m_ClipBox = m_pClipRgn->GetBox(); - else { - m_ClipBox.left = m_ClipBox.top = 0; - m_ClipBox.right = m_pDevice->GetWidth(); - m_ClipBox.bottom = m_pDevice->GetHeight(); - } - m_pClipMask = NULL; - if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) - { - m_pClipMask = m_pClipRgn->GetMask(); - m_pClipScan = m_pClipMask->GetBuffer(); - } - if (m_pDevice->m_pAlphaMask) - m_pDestExtraAlphaScan = m_pDevice->m_pAlphaMask->GetBuffer(); - if (m_pOriDevice) - m_pOriScan = m_pOriDevice->GetBuffer(); - m_pDestScan = m_pDevice->GetBuffer(); + //-------------------------------------------------------------------- + FX_BOOL CFX_SkiaRenderer::Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevice, const CFX_ClipRgn* pClipRgn, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bRgbByteOrder, + int alpha_flag, void* pIccTransform) //The alpha flag must be fill_flag if exist. + { + m_pDevice = pDevice; + m_pClipRgn = pClipRgn; + m_bRgbByteOrder = bRgbByteOrder; + m_pOriDevice = pOriDevice; + m_pDestScan = NULL; + m_pDestExtraAlphaScan = NULL; + m_pOriScan = NULL; + m_pClipScan = NULL; + composite_span = NULL; + if (m_pClipRgn) + m_ClipBox = m_pClipRgn->GetBox(); + else { + m_ClipBox.left = m_ClipBox.top = 0; + m_ClipBox.right = m_pDevice->GetWidth(); + m_ClipBox.bottom = m_pDevice->GetHeight(); + } + m_pClipMask = NULL; + if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) + { + m_pClipMask = m_pClipRgn->GetMask(); + m_pClipScan = m_pClipMask->GetBuffer(); + } + if (m_pDevice->m_pAlphaMask) + m_pDestExtraAlphaScan = m_pDevice->m_pAlphaMask->GetBuffer(); + if (m_pOriDevice) + m_pOriScan = m_pOriDevice->GetBuffer(); + m_pDestScan = m_pDevice->GetBuffer(); - m_bFullCover = bFullCover; + m_bFullCover = bFullCover; - FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag); - FX_BOOL bDeviceCMYK = pDevice->IsCmykImage(); + FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag); + FX_BOOL bDeviceCMYK = pDevice->IsCmykImage(); - m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); + m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); - ICodec_IccModule* pIccModule = NULL; - // No lcms engine, we skip the transform - if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) - pIccTransform = NULL; - else - pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); + ICodec_IccModule* pIccModule = NULL; + // No lcms engine, we skip the transform + if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) + pIccTransform = NULL; + else + pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (m_pDevice->GetBPP() == 8) { // Gray(a) device - ASSERT(!m_bRgbByteOrder); - if (m_pDevice->IsAlphaMask()) { - //Alpha Mask - m_Gray = 255; - } else { - //Gray(a) device - if (pIccTransform) { - uint8_t gray; - color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); - pIccModule->TranslateScanline(pIccTransform, &gray, (const uint8_t*)&color, 1); - m_Gray = gray; - } else { - if (bObjectCMYK) { - uint8_t r, g, b; - AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color), - r, g, b); - m_Gray = FXRGB2GRAY(r, g, b); - } else { - m_Gray = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color)); - } - } - } - } else { - if (bDeviceCMYK) { // Cmyk(a) Device - ASSERT(!m_bRgbByteOrder); - //TODO... opt for cmyk - composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK; - if (bObjectCMYK) { - m_Color = FXCMYK_TODIB(color); - if (pIccTransform) - pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&m_Color, 1); - } else { // Object RGB - if (!pIccTransform) - return FALSE; - color = FXARGB_TODIB(color); - pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&color, 1); - } - m_Red = ((uint8_t*)&m_Color)[0]; - m_Green = ((uint8_t*)&m_Color)[1]; - m_Blue = ((uint8_t*)&m_Color)[2]; - m_Gray = ((uint8_t*)&m_Color)[3]; - return TRUE; - } else { - if (pIccTransform) { - color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); - pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&color, 1); - ((uint8_t*)&m_Color)[3] = m_Alpha; - m_Red = ((uint8_t*)&m_Color)[2]; - m_Green = ((uint8_t*)&m_Color)[1]; - m_Blue = ((uint8_t*)&m_Color)[0]; - // Need Johnson to improvement it. - if (m_bRgbByteOrder) { - // swap - m_Red = ((uint8_t*)&m_Color)[0]; - m_Blue = ((uint8_t*)&m_Color)[2]; - m_Color = FXARGB_TODIB(m_Color); - m_Color = FXARGB_TOBGRORDERDIB(m_Color); - } - } else { - if (bObjectCMYK) { - uint8_t r, g, b; - AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color), - r, g, b); - m_Color = FXARGB_MAKE(m_Alpha, r, g, b); - if (m_bRgbByteOrder){ - m_Color = FXARGB_TOBGRORDERDIB(m_Color); - m_Red = b; m_Green = g; m_Blue = r;// - }else { - m_Color = FXARGB_TODIB(m_Color); - m_Red = r; m_Green = g; m_Blue = b;// - } - } else { - if (m_bRgbByteOrder){ - m_Color = FXARGB_TOBGRORDERDIB(color); - ArgbDecode(color, m_Alpha, m_Blue, m_Green, m_Red); // - }else { - m_Color = FXARGB_TODIB(color); - ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); - } - } - } - } - } - // Get palette transparency selector - m_ProcessFilter = (m_pOriDevice? 1 : 0) /* has Ori Device flag */ - + (m_pDevice->GetBPP() >= 8 ? 2 : 0) /* bpp flag */ - + (m_pClipMask? 4 : 0) /* has clip region flag */ - + (m_pDevice->m_pAlphaMask? 8 : 0); /* has Alpha Mask chanel flag */ - switch(m_ProcessFilter) { - case 0: - composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_0; - break; - case 2: - { - if (m_pDevice->GetBPP() == 8) - composite_span = &CFX_SkiaRenderer::CompositeSpanGray_2; - else if (m_pDevice->GetBPP() == 24) - composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_2; - else - composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_2 : &CFX_SkiaRenderer::CompositeSpanRGB32_2; - } - break; - case 3: - { - if (m_pDevice->GetBPP() == 8) - composite_span = &CFX_SkiaRenderer::CompositeSpanGray_3; - else if (m_pDevice->GetBPP() == 24) - composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_3; - else - composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_3 : &CFX_SkiaRenderer::CompositeSpanRGB32_3; - } - break; - case 4: - composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_4; - break; - case 6: - { - if (m_pDevice->GetBPP() == 8) - composite_span = &CFX_SkiaRenderer::CompositeSpanGray_6; - else if (m_pDevice->GetBPP() == 24) - composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_6; - else - composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_6 : &CFX_SkiaRenderer::CompositeSpanRGB32_6; - } - break; - case 7: - { - if (m_pDevice->GetBPP() == 8) - composite_span = &CFX_SkiaRenderer::CompositeSpanGray_7; - else if (m_pDevice->GetBPP() == 24) - composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_7; - else - composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_7 : &CFX_SkiaRenderer::CompositeSpanRGB32_7; - } - break; - case 1: - case 5: - case 8: - case 9: - case 11: - case 12: - case 13: - case 15: - //TODO... - break; - case 10: - composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10; - break; - case 14: - composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14; - break; - } - if (composite_span == NULL) - return FALSE; - return TRUE; - } + if (m_pDevice->GetBPP() == 8) { // Gray(a) device + ASSERT(!m_bRgbByteOrder); + if (m_pDevice->IsAlphaMask()) { + //Alpha Mask + m_Gray = 255; + } else { + //Gray(a) device + if (pIccTransform) { + uint8_t gray; + color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); + pIccModule->TranslateScanline(pIccTransform, &gray, (const uint8_t*)&color, 1); + m_Gray = gray; + } else { + if (bObjectCMYK) { + uint8_t r, g, b; + AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color), + r, g, b); + m_Gray = FXRGB2GRAY(r, g, b); + } else { + m_Gray = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color)); + } + } + } + } else { + if (bDeviceCMYK) { // Cmyk(a) Device + ASSERT(!m_bRgbByteOrder); + //TODO... opt for cmyk + composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK; + if (bObjectCMYK) { + m_Color = FXCMYK_TODIB(color); + if (pIccTransform) + pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&m_Color, 1); + } else { // Object RGB + if (!pIccTransform) + return FALSE; + color = FXARGB_TODIB(color); + pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&color, 1); + } + m_Red = ((uint8_t*)&m_Color)[0]; + m_Green = ((uint8_t*)&m_Color)[1]; + m_Blue = ((uint8_t*)&m_Color)[2]; + m_Gray = ((uint8_t*)&m_Color)[3]; + return TRUE; + } + if (pIccTransform) { + color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); + pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, (const uint8_t*)&color, 1); + ((uint8_t*)&m_Color)[3] = m_Alpha; + m_Red = ((uint8_t*)&m_Color)[2]; + m_Green = ((uint8_t*)&m_Color)[1]; + m_Blue = ((uint8_t*)&m_Color)[0]; + // Need Johnson to improvement it. + if (m_bRgbByteOrder) { + // swap + m_Red = ((uint8_t*)&m_Color)[0]; + m_Blue = ((uint8_t*)&m_Color)[2]; + m_Color = FXARGB_TODIB(m_Color); + m_Color = FXARGB_TOBGRORDERDIB(m_Color); + } + } else { + if (bObjectCMYK) { + uint8_t r, g, b; + AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color), + r, g, b); + m_Color = FXARGB_MAKE(m_Alpha, r, g, b); + if (m_bRgbByteOrder){ + m_Color = FXARGB_TOBGRORDERDIB(m_Color); + m_Red = b; m_Green = g; m_Blue = r;// + }else { + m_Color = FXARGB_TODIB(m_Color); + m_Red = r; m_Green = g; m_Blue = b;// + } + } else { + if (m_bRgbByteOrder){ + m_Color = FXARGB_TOBGRORDERDIB(color); + ArgbDecode(color, m_Alpha, m_Blue, m_Green, m_Red); // + }else { + m_Color = FXARGB_TODIB(color); + ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); + } + } + } + } + // Get palette transparency selector + m_ProcessFilter = (m_pOriDevice? 1 : 0) /* has Ori Device flag */ + + (m_pDevice->GetBPP() >= 8 ? 2 : 0) /* bpp flag */ + + (m_pClipMask? 4 : 0) /* has clip region flag */ + + (m_pDevice->m_pAlphaMask? 8 : 0); /* has Alpha Mask chanel flag */ + switch(m_ProcessFilter) { + case 0: + composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_0; + break; + case 2: + { + if (m_pDevice->GetBPP() == 8) + composite_span = &CFX_SkiaRenderer::CompositeSpanGray_2; + else if (m_pDevice->GetBPP() == 24) + composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_2; + else + composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_2 : &CFX_SkiaRenderer::CompositeSpanRGB32_2; + } + break; + case 3: + { + if (m_pDevice->GetBPP() == 8) + composite_span = &CFX_SkiaRenderer::CompositeSpanGray_3; + else if (m_pDevice->GetBPP() == 24) + composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_3; + else + composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_3 : &CFX_SkiaRenderer::CompositeSpanRGB32_3; + } + break; + case 4: + composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_4; + break; + case 6: + { + if (m_pDevice->GetBPP() == 8) + composite_span = &CFX_SkiaRenderer::CompositeSpanGray_6; + else if (m_pDevice->GetBPP() == 24) + composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_6; + else + composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_6 : &CFX_SkiaRenderer::CompositeSpanRGB32_6; + } + break; + case 7: + { + if (m_pDevice->GetBPP() == 8) + composite_span = &CFX_SkiaRenderer::CompositeSpanGray_7; + else if (m_pDevice->GetBPP() == 24) + composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_7; + else + composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_7 : &CFX_SkiaRenderer::CompositeSpanRGB32_7; + } + break; + case 1: + case 5: + case 8: + case 9: + case 11: + case 12: + case 13: + case 15: + //TODO... + break; + case 10: + composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10; + break; + case 14: + composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14; + break; + } + if (composite_span == NULL) + return FALSE; + return TRUE; + } - /*----------------------------------------------------------------------------------------------------*/ - void CFX_SkiaA8Renderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) - { - FXSYS_assert(m_pDevice); - int dst_y = y - m_Top; - if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) - return; + /*----------------------------------------------------------------------------------------------------*/ + void CFX_SkiaA8Renderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) + { + FXSYS_assert(m_pDevice); + int dst_y = y - m_Top; + if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) + return; - uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y; - uint8_t* dest_pos = dest_scan; - while (1) - { - if (x >= m_dstWidth) - return; - int width = runs[0]; - SkASSERT(width >= 0); - if (width <= 0) - return; - unsigned aa = antialias[0]; - if (aa) { - int col_start = x < m_Left ? 0 : x - m_Left; - int col_end = x + width; - col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth(); - int result = col_end - col_start; - if (result > 0) { - dest_pos = dest_scan + col_start; - if (result >= 4) - FXSYS_memset(dest_pos, FXARGB_MAKE(aa, aa, aa, aa),result); - else - FXSYS_memset(dest_pos,aa,result); - } - } - runs += width; - antialias += width; - x += width; - } - } - void CFX_SkiaA8Renderer::blitH(int x, int y, int width) - { - FXSYS_assert(m_pDevice); - int dst_y = y - m_Top; - if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) - return; - if (x >= m_dstWidth) - return; - uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y; - int col_start = x < m_Left ? 0 : x - m_Left; - int col_end = x + width; - col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth(); - int result = col_end - col_start; - if (result > 0) { - uint8_t* dest_pos = dest_scan + col_start; - if (result >= 4) - FXSYS_memset(dest_pos, 0xffffffff,result); - else - FXSYS_memset(dest_pos,255,result); - } - } - void CFX_SkiaA8Renderer::blitV(int x, int y, int height, SkAlpha alpha) - { - FXSYS_assert(alpha); - if (alpha == 255) { - blitRect(x, y, 1, height); - } else { - int16_t runs[2]; - runs[0] = 1; - runs[1] = 0; - while (--height >= 0) { - if (y >= m_dstHeight) - return; - blitAntiH(x, y ++, &alpha, runs); - } - } - } - void CFX_SkiaA8Renderer::blitRect(int x, int y, int width, int height) - { - FXSYS_assert(m_pDevice); - while (--height >= 0) { - if (y >= m_dstHeight) - return; - blitH(x , y ++, width); - } - } + uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y; + uint8_t* dest_pos = dest_scan; + while (1) + { + if (x >= m_dstWidth) + return; + int width = runs[0]; + SkASSERT(width >= 0); + if (width <= 0) + return; + unsigned aa = antialias[0]; + if (aa) { + int col_start = x < m_Left ? 0 : x - m_Left; + int col_end = x + width; + col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth(); + int result = col_end - col_start; + if (result > 0) { + dest_pos = dest_scan + col_start; + if (result >= 4) + FXSYS_memset(dest_pos, FXARGB_MAKE(aa, aa, aa, aa),result); + else + FXSYS_memset(dest_pos,aa,result); + } + } + runs += width; + antialias += width; + x += width; + } + } + void CFX_SkiaA8Renderer::blitH(int x, int y, int width) + { + FXSYS_assert(m_pDevice); + int dst_y = y - m_Top; + if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) + return; + if (x >= m_dstWidth) + return; + uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y; + int col_start = x < m_Left ? 0 : x - m_Left; + int col_end = x + width; + col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth(); + int result = col_end - col_start; + if (result > 0) { + uint8_t* dest_pos = dest_scan + col_start; + if (result >= 4) + FXSYS_memset(dest_pos, 0xffffffff,result); + else + FXSYS_memset(dest_pos,255,result); + } + } + void CFX_SkiaA8Renderer::blitV(int x, int y, int height, SkAlpha alpha) + { + FXSYS_assert(alpha); + if (alpha == 255) { + blitRect(x, y, 1, height); + } else { + int16_t runs[2]; + runs[0] = 1; + runs[1] = 0; + while (--height >= 0) { + if (y >= m_dstHeight) + return; + blitAntiH(x, y ++, &alpha, runs); + } + } + } + void CFX_SkiaA8Renderer::blitRect(int x, int y, int width, int height) + { + FXSYS_assert(m_pDevice); + while (--height >= 0) { + if (y >= m_dstHeight) + return; + blitH(x , y ++, width); + } + } - void CFX_SkiaA8Renderer::blitAntiRect(int x, int y, int width, int height, + void CFX_SkiaA8Renderer::blitAntiRect(int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha) - { - blitV(x++, y, height, leftAlpha); - if (width > 0) { - blitRect(x, y, width, height); - x += width; - } - blitV(x, y, height, rightAlpha); - } + { + blitV(x++, y, height, leftAlpha); + if (width > 0) { + blitRect(x, y, width, height); + x += width; + } + blitV(x, y, height, rightAlpha); + } - FX_BOOL CFX_SkiaA8Renderer::Init(CFX_DIBitmap* pDevice, int Left, int Top) - { - m_pDevice = pDevice; - m_Left = Left; - m_Top = Top; - if (pDevice){ - m_dstWidth = m_Left + pDevice->GetWidth(); - m_dstHeight = m_Top + pDevice->GetHeight(); - } - return TRUE; - } + FX_BOOL CFX_SkiaA8Renderer::Init(CFX_DIBitmap* pDevice, int Left, int Top) + { + m_pDevice = pDevice; + m_Left = Left; + m_Top = Top; + if (pDevice){ + m_dstWidth = m_Left + pDevice->GetWidth(); + m_dstHeight = m_Top + pDevice->GetHeight(); + } + return TRUE; + } #endif diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp index 2802a7c533..3a328c0e6a 100644 --- a/core/src/fxge/win32/fx_win32_device.cpp +++ b/core/src/fxge/win32/fx_win32_device.cpp @@ -267,7 +267,8 @@ void CWin32FontInfo::GetJapanesePreference(CFX_ByteString& face, int weight, int } } return; - } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { + } + if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) { face = "MS PMincho"; } else { @@ -992,8 +993,10 @@ FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD colo if (!bGDI) { CFX_DIBitmap background; if (!background.Create(width, height, FXDIB_Rgb32) || - !GetDIBits(&background, left, top, NULL) || - !background.CompositeMask(0, 0, width, height, pSource, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { + !GetDIBits(&background, left, top, NULL) || + !background.CompositeMask(0, 0, width, height, pSource, color, + 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, + alpha_flag, pIccTransform)) { return FALSE; } FX_RECT src_rect(0, 0, width, height); @@ -1002,23 +1005,22 @@ FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD colo FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->Height()); return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRect->top, width, height, &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLEND_NORMAL); - } else { - int width = pSrcRect->Width(), height = pSrcRect->Height(); - if (pSource->HasAlpha()) { - CFX_DIBitmap bitmap; - if (!bitmap.Create(width, height, FXDIB_Rgb) || - !GetDIBits(&bitmap, left, top, NULL) || - !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, FALSE, pIccTransform)) { - return FALSE; - } - FX_RECT src_rect(0, 0, width, height); - return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0, NULL); - } - CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; - if (pBitmap) { - return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); + } + int width = pSrcRect->Width(), height = pSrcRect->Height(); + if (pSource->HasAlpha()) { + CFX_DIBitmap bitmap; + if (!bitmap.Create(width, height, FXDIB_Rgb) || + !GetDIBits(&bitmap, left, top, NULL) || + !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, FALSE, pIccTransform)) { + return FALSE; } + FX_RECT src_rect(0, 0, width, height); + return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0, NULL); + } + CFX_DIBExtractor temp(pSource); + CFX_DIBitmap* pBitmap = temp; + if (pBitmap) { + return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); } return FALSE; } @@ -1048,9 +1050,10 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD int alpha_flag, void* pIccTransform, int blend_type) { ASSERT(pSource != NULL && pClipRect != NULL); - if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 10000 || dest_height < -10000) + if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 10000 || dest_height < -10000) { return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_width, dest_height, pClipRect, flags, alpha_flag, pIccTransform, blend_type); + } if (pSource->IsAlphaMask()) { FX_RECT image_rect; image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; @@ -1067,8 +1070,8 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD } CFX_DIBitmap background; if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || - !GetDIBits(&background, image_rect.left + clip_rect.left, image_rect.top + clip_rect.top, NULL) || - !background.CompositeMask(0, 0, clip_width, clip_height, pStretched, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { + !GetDIBits(&background, image_rect.left + clip_rect.left, image_rect.top + clip_rect.top, NULL) || + !background.CompositeMask(0, 0, clip_width, clip_height, pStretched, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { delete pStretched; return FALSE; } @@ -1076,25 +1079,24 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD FX_BOOL ret = SetDIBits(&background, 0, &src_rect, image_rect.left + clip_rect.left, image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL, 0, NULL); delete pStretched; return ret; - } else { - if (pSource->HasAlpha()) { - CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); - if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL && !pSource->IsCmykImage()) { - CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; - if (pBitmap == NULL) { - return FALSE; - } - return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, pClipRect, flags); + } + if (pSource->HasAlpha()) { + CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); + if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL && !pSource->IsCmykImage()) { + CFX_DIBExtractor temp(pSource); + CFX_DIBitmap* pBitmap = temp; + if (pBitmap == NULL) { + return FALSE; } - return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_width, dest_height, - pClipRect, flags, alpha_flag, pIccTransform, blend_type); - } - CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; - if (pBitmap) { - return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags, pIccTransform); + return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, pClipRect, flags); } + return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_width, dest_height, + pClipRect, flags, alpha_flag, pIccTransform, blend_type); + } + CFX_DIBExtractor temp(pSource); + CFX_DIBitmap* pBitmap = temp; + if (pBitmap) { + return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags, pIccTransform); } return FALSE; } diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp index b6455c3570..da6a2c3ef4 100644 --- a/core/src/fxge/win32/fx_win32_dib.cpp +++ b/core/src/fxge/win32/fx_win32_dib.cpp @@ -153,7 +153,8 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable()) { return pPlatform->m_GdiplusExt.LoadDIBitmap(args); - } else if (args.flags == WINDIB_OPEN_MEMORY) { + } + if (args.flags == WINDIB_OPEN_MEMORY) { return NULL; } HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp index 7949888ac2..e5db76d836 100644 --- a/core/src/fxge/win32/fx_win32_dwrite.cpp +++ b/core/src/fxge/win32/fx_win32_dwrite.cpp @@ -286,10 +286,9 @@ HRESULT STDMETHODCALLTYPE CDwFontFileStream::QueryInterface(REFIID iid, void** p *ppvObject = this; AddRef(); return S_OK; - } else { - *ppvObject = NULL; - return E_NOINTERFACE; } + *ppvObject = NULL; + return E_NOINTERFACE; } ULONG STDMETHODCALLTYPE CDwFontFileStream::AddRef() { @@ -310,16 +309,14 @@ HRESULT STDMETHODCALLTYPE CDwFontFileStream::ReadFileFragment( OUT void** fragmentContext ) { - if (fileOffset <= resourceSize_ && - fragmentSize <= resourceSize_ - fileOffset) { + if (fileOffset <= resourceSize_ && fragmentSize <= resourceSize_ - fileOffset) { *fragmentStart = static_cast<uint8_t const*>(resourcePtr_) + static_cast<size_t>(fileOffset); *fragmentContext = NULL; return S_OK; - } else { - *fragmentStart = NULL; - *fragmentContext = NULL; - return E_FAIL; } + *fragmentStart = NULL; + *fragmentContext = NULL; + return E_FAIL; } void STDMETHODCALLTYPE CDwFontFileStream::ReleaseFileFragment(void* fragmentContext) { @@ -345,10 +342,9 @@ HRESULT STDMETHODCALLTYPE CDwFontFileLoader::QueryInterface(REFIID iid, void** p *ppvObject = this; AddRef(); return S_OK; - } else { - *ppvObject = NULL; - return E_NOINTERFACE; } + *ppvObject = NULL; + return E_NOINTERFACE; } ULONG STDMETHODCALLTYPE CDwFontFileLoader::AddRef() { diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp index 3c63efed6a..fff9e88bbb 100644 --- a/core/src/fxge/win32/fx_win32_gdipext.cpp +++ b/core/src/fxge/win32/fx_win32_gdipext.cpp @@ -1013,14 +1013,14 @@ public: virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject) { - if (iid == __uuidof(IUnknown) || iid == __uuidof(IStream) || - iid == __uuidof(ISequentialStream)) { + if (iid == __uuidof(IUnknown) || + iid == __uuidof(IStream) || + iid == __uuidof(ISequentialStream)) { *ppvObject = static_cast<IStream*>(this); AddRef(); return S_OK; - } else { - return E_NOINTERFACE; } + return E_NOINTERFACE; } virtual ULONG STDMETHODCALLTYPE AddRef(void) { diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp index 163ee84a0a..2be8a30ecb 100644 --- a/core/src/fxge/win32/fx_win32_print.cpp +++ b/core/src/fxge/win32/fx_win32_print.cpp @@ -80,33 +80,31 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD return FALSE; } return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, dest_height, color, flags, alpha_flag, pIccTransform); - } else { - ASSERT(pSource != NULL); - if (pSource->HasAlpha()) { + } + if (pSource->HasAlpha()) { + return FALSE; + } + if (dest_width < 0 || dest_height < 0) { + CFX_DIBitmap* pFlipped = pSource->FlipImage(dest_width < 0, dest_height < 0); + if (pFlipped == NULL) { return FALSE; } - if (dest_width < 0 || dest_height < 0) { - CFX_DIBitmap* pFlipped = pSource->FlipImage(dest_width < 0, dest_height < 0); - if (pFlipped == NULL) { - return FALSE; - } - if (dest_width < 0) { - dest_left += dest_width; - } - if (dest_height < 0) { - dest_top += dest_height; - } - FX_BOOL ret = GDI_StretchDIBits(pFlipped, dest_left, dest_top, abs(dest_width), abs(dest_height), flags, pIccTransform); - delete pFlipped; - return ret; + if (dest_width < 0) { + dest_left += dest_width; } - CFX_DIBExtractor temp(pSource); - CFX_DIBitmap* pBitmap = temp; - if (pBitmap == NULL) { - return FALSE; + if (dest_height < 0) { + dest_top += dest_height; } - return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags, pIccTransform); + FX_BOOL ret = GDI_StretchDIBits(pFlipped, dest_left, dest_top, abs(dest_width), abs(dest_height), flags, pIccTransform); + delete pFlipped; + return ret; + } + CFX_DIBExtractor temp(pSource); + CFX_DIBitmap* pBitmap = temp; + if (pBitmap == NULL) { + return FALSE; } + return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags, pIccTransform); } static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc, const CFX_AffineMatrix* pDestMatrix) { |