From 256ef88a26cff56fc7c23119d2d9e1b41468bd1a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 5 Jan 2015 16:54:03 -0800 Subject: Cleanup: Get rid of CRLF line endings. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/837533003 --- core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp | 18 +- core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp | 94 +++---- core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp | 2 +- core/src/fxcodec/codec/fx_codec_jpx_opj.cpp | 102 +++---- core/src/fxge/freetype/fx_freetype.c | 338 +++++++++++------------ 5 files changed, 277 insertions(+), 277 deletions(-) (limited to 'core/src') diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp index 670465673b..86db177ad7 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -519,8 +519,8 @@ void CPDF_LabCS::TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int } } CPDF_IccProfile::CPDF_IccProfile(FX_LPCBYTE pData, FX_DWORD dwSize): - m_bsRGB(FALSE), - m_pTransform(NULL), + m_bsRGB(FALSE), + m_pTransform(NULL), m_nSrcComponents(0) { if (dwSize == 3144 && FXSYS_memcmp32(pData + 0x190, "sRGB IEC61966-2.1", 17) == 0) { @@ -1376,13 +1376,13 @@ void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) if (ncomps) { FXSYS_memcpy32(pvalue->m_Comps, comps, ncomps * sizeof(FX_FLOAT)); } - pvalue->m_pCountedPattern = NULL; - if (pPattern && pPattern->m_pDocument) - { - if (!pDocPageData) { - pDocPageData = pPattern->m_pDocument->GetPageData(); - } - pvalue->m_pCountedPattern = pDocPageData->FindPatternPtr(pPattern->m_pPatternObj); + pvalue->m_pCountedPattern = NULL; + if (pPattern && pPattern->m_pDocument) + { + if (!pDocPageData) { + pDocPageData = pPattern->m_pDocument->GetPageData(); + } + pvalue->m_pCountedPattern = pDocPageData->FindPatternPtr(pPattern->m_pPatternObj); } } void CPDF_Color::Copy(const CPDF_Color* pSrc) diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp index fe5665d1fb..5df664312c 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -147,32 +147,32 @@ CPDF_DocPageData::~CPDF_DocPageData() { Clear(FALSE); Clear(TRUE); - FX_POSITION pos = m_PatternMap.GetStartPosition(); - while (pos) - { - CPDF_Object* ptObj; - CPDF_CountedObject* ptData; - m_PatternMap.GetNextAssoc(pos, ptObj, ptData); - delete ptData; - } - m_PatternMap.RemoveAll(); - pos = m_FontMap.GetStartPosition(); - while (pos) - { - CPDF_Dictionary* fontDict; - CPDF_CountedObject* fontData; - m_FontMap.GetNextAssoc(pos, fontDict, fontData); - delete fontData; - } - m_FontMap.RemoveAll(); - pos = m_ColorSpaceMap.GetStartPosition(); - while (pos) - { - CPDF_Object* csKey; - CPDF_CountedObject* csData; - m_ColorSpaceMap.GetNextAssoc(pos, csKey, csData); - delete csData; - } + FX_POSITION pos = m_PatternMap.GetStartPosition(); + while (pos) + { + CPDF_Object* ptObj; + CPDF_CountedObject* ptData; + m_PatternMap.GetNextAssoc(pos, ptObj, ptData); + delete ptData; + } + m_PatternMap.RemoveAll(); + pos = m_FontMap.GetStartPosition(); + while (pos) + { + CPDF_Dictionary* fontDict; + CPDF_CountedObject* fontData; + m_FontMap.GetNextAssoc(pos, fontDict, fontData); + delete fontData; + } + m_FontMap.RemoveAll(); + pos = m_ColorSpaceMap.GetStartPosition(); + while (pos) + { + CPDF_Object* csKey; + CPDF_CountedObject* csData; + m_ColorSpaceMap.GetNextAssoc(pos, csKey, csData); + delete csData; + } m_ColorSpaceMap.RemoveAll(); } void CPDF_DocPageData::Clear(FX_BOOL bForceRelease) @@ -673,24 +673,24 @@ void CPDF_DocPageData::ReleaseFontFileStreamAcc(CPDF_Stream* pFontStream, FX_BOO return; } PDF_DocPageData_Release(m_FontFileMap, pFontStream, NULL, bForce); -} -CPDF_CountedColorSpace* CPDF_DocPageData::FindColorSpacePtr(CPDF_Object* pCSObj) const -{ - if (!pCSObj) return NULL; - CPDF_CountedObject* csData; - if (m_ColorSpaceMap.Lookup(pCSObj, csData)) - { - return csData; - } - return NULL; -} -CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr(CPDF_Object* pPatternObj) const -{ - if (!pPatternObj) return NULL; - CPDF_CountedObject* ptData; - if (m_PatternMap.Lookup(pPatternObj, ptData)) - { - return ptData; - } - return NULL; -} +} +CPDF_CountedColorSpace* CPDF_DocPageData::FindColorSpacePtr(CPDF_Object* pCSObj) const +{ + if (!pCSObj) return NULL; + CPDF_CountedObject* csData; + if (m_ColorSpaceMap.Lookup(pCSObj, csData)) + { + return csData; + } + return NULL; +} +CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr(CPDF_Object* pPatternObj) const +{ + if (!pPatternObj) return NULL; + CPDF_CountedObject* ptData; + if (m_PatternMap.Lookup(pPatternObj, ptData)) + { + return ptData; + } + return NULL; +} diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp index 4644302c5b..9e61ce2f0b 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp @@ -143,7 +143,7 @@ FX_BOOL CPDF_ShadingPattern::Load() } CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); m_pCS = pDocPageData->GetColorSpace(pCSObj, NULL); - if (m_pCS) { + if (m_pCS) { m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray()); } m_ShadingType = pShadingDict->GetInteger(FX_BSTRC("ShadingType")); diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp index 8dcecf9061..c4a0f88201 100644 --- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -168,17 +168,17 @@ static void sycc422_to_rgb(opj_image_t *img) d2 = b = FX_Alloc(int, (size_t)max); for(i = 0; i < maxh; ++i) { - for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2) - { - sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); - ++y; ++r; ++g; ++b; - sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); - ++y; ++r; ++g; ++b; ++cb; ++cr; - } - if (j < maxw) - { - sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); - ++y; ++r; ++g; ++b; ++cb; ++cr; + for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2) + { + sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); + ++y; ++r; ++g; ++b; + sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); + ++y; ++r; ++g; ++b; ++cb; ++cr; + } + if (j < maxw) + { + sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); + ++y; ++r; ++g; ++b; ++cb; ++cr; } } FX_Free(img->comps[0].data); @@ -218,46 +218,46 @@ static void sycc420_to_rgb(opj_image_t *img) d0 = r = FX_Alloc(int, (size_t)max); d1 = g = FX_Alloc(int, (size_t)max); d2 = b = FX_Alloc(int, (size_t)max); - for (i = 0; (OPJ_UINT32)i < (maxh & ~(OPJ_UINT32)1); i += 2) - { - ny = y + maxw; - nr = r + maxw; - ng = g + maxw; - nb = b + maxw; - for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2) - { - sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); - ++y; ++r; ++g; ++b; - sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); - ++y; ++r; ++g; ++b; - sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb); - ++ny; ++nr; ++ng; ++nb; - sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb); - ++ny; ++nr; ++ng; ++nb; ++cb; ++cr; - } - if (j < maxw) - { - sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); - ++y; ++r; ++g; ++b; - sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb); - ++ny; ++nr; ++ng; ++nb; ++cb; ++cr; - } - y += maxw; r += maxw; g += maxw; b += maxw; - } - if (i < maxh) - { - for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2) - { - sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); - ++y; ++r; ++g; ++b; - sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); - ++y; ++r; ++g; ++b; ++cb; ++cr; - } - if (j < maxw) - { - sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); - } - } + for (i = 0; (OPJ_UINT32)i < (maxh & ~(OPJ_UINT32)1); i += 2) + { + ny = y + maxw; + nr = r + maxw; + ng = g + maxw; + nb = b + maxw; + for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2) + { + sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); + ++y; ++r; ++g; ++b; + sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); + ++y; ++r; ++g; ++b; + sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb); + ++ny; ++nr; ++ng; ++nb; + sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb); + ++ny; ++nr; ++ng; ++nb; ++cb; ++cr; + } + if (j < maxw) + { + sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); + ++y; ++r; ++g; ++b; + sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb); + ++ny; ++nr; ++ng; ++nb; ++cb; ++cr; + } + y += maxw; r += maxw; g += maxw; b += maxw; + } + if (i < maxh) + { + for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2) + { + sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); + ++y; ++r; ++g; ++b; + sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); + ++y; ++r; ++g; ++b; ++cb; ++cr; + } + if (j < maxw) + { + sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); + } + } FX_Free(img->comps[0].data); img->comps[0].data = d0; diff --git a/core/src/fxge/freetype/fx_freetype.c b/core/src/fxge/freetype/fx_freetype.c index fe144d69a6..78dec9ad99 100644 --- a/core/src/fxge/freetype/fx_freetype.c +++ b/core/src/fxge/freetype/fx_freetype.c @@ -7,176 +7,176 @@ #include "../../../include/fxge/fx_freetype.h" #include "../../../../third_party/freetype/src/psnames/pstables.h" -static int xyq_search_node(char* glyph_name, int name_offset, int table_offset, wchar_t unicode) -{ - int i, count; - - // copy letters - while (1) { - glyph_name[name_offset] = ft_adobe_glyph_list[table_offset] & 0x7f; - name_offset++; - table_offset++; - if (!(ft_adobe_glyph_list[table_offset - 1] & 0x80)) break; - } - glyph_name[name_offset] = 0; - - // get child count - count = ft_adobe_glyph_list[table_offset] & 0x7f; - - // check if we have value for this node - if (ft_adobe_glyph_list[table_offset] & 0x80) { - unsigned short thiscode = ft_adobe_glyph_list[table_offset + 1] * 256 + ft_adobe_glyph_list[table_offset + 2]; - if (thiscode == (unsigned short)unicode) // found it! - return 1; - table_offset += 3; - } - else - table_offset++; - - // now search in sub-nodes - if (count == 0) return 0; - for (i = 0; i < count; i++) { - int child_offset = ft_adobe_glyph_list[table_offset + i * 2] * 256 + ft_adobe_glyph_list[table_offset + i * 2 + 1]; - if (xyq_search_node(glyph_name, name_offset, child_offset, unicode)) - // found in child - return 1; - } - return 0; +static int xyq_search_node(char* glyph_name, int name_offset, int table_offset, wchar_t unicode) +{ + int i, count; + + // copy letters + while (1) { + glyph_name[name_offset] = ft_adobe_glyph_list[table_offset] & 0x7f; + name_offset++; + table_offset++; + if (!(ft_adobe_glyph_list[table_offset - 1] & 0x80)) break; + } + glyph_name[name_offset] = 0; + + // get child count + count = ft_adobe_glyph_list[table_offset] & 0x7f; + + // check if we have value for this node + if (ft_adobe_glyph_list[table_offset] & 0x80) { + unsigned short thiscode = ft_adobe_glyph_list[table_offset + 1] * 256 + ft_adobe_glyph_list[table_offset + 2]; + if (thiscode == (unsigned short)unicode) // found it! + return 1; + table_offset += 3; + } + else + table_offset++; + + // now search in sub-nodes + if (count == 0) return 0; + for (i = 0; i < count; i++) { + int child_offset = ft_adobe_glyph_list[table_offset + i * 2] * 256 + ft_adobe_glyph_list[table_offset + i * 2 + 1]; + if (xyq_search_node(glyph_name, name_offset, child_offset, unicode)) + // found in child + return 1; + } + return 0; } #define VARIANT_BIT 0x80000000UL -int FXFT_unicode_from_adobe_name(const char* glyph_name) -{ - /* If the name begins with `uni', then the glyph name may be a */ - /* hard-coded unicode character code. */ - if (glyph_name[0] == 'u' && - glyph_name[1] == 'n' && - glyph_name[2] == 'i') - { - /* determine whether the next four characters following are */ - /* hexadecimal. */ - - /* XXX: Add code to deal with ligatures, i.e. glyph names like */ - /* `uniXXXXYYYYZZZZ'... */ - - FT_Int count; - FT_UInt32 value = 0; - const char* p = glyph_name + 3; - - - for (count = 4; count > 0; count--, p++) - { - char c = *p; - unsigned int d; - - - d = (unsigned char)c - '0'; - if (d >= 10) - { - d = (unsigned char)c - 'A'; - if (d >= 6) - d = 16; - else - d += 10; - } - - /* Exit if a non-uppercase hexadecimal character was found */ - /* -- this also catches character codes below `0' since such */ - /* negative numbers cast to `unsigned int' are far too big. */ - if (d >= 16) - break; - - value = (value << 4) + d; - } - - /* there must be exactly four hex digits */ - if (count == 0) - { - if (*p == '\0') - return value; - if (*p == '.') - return (FT_UInt32)(value | VARIANT_BIT); - } - } - - /* If the name begins with `u', followed by four to six uppercase */ - /* hexadecimal digits, it is a hard-coded unicode character code. */ - if (glyph_name[0] == 'u') - { - FT_Int count; - FT_UInt32 value = 0; - const char* p = glyph_name + 1; - - - for (count = 6; count > 0; count--, p++) - { - char c = *p; - unsigned int d; - - - d = (unsigned char)c - '0'; - if (d >= 10) - { - d = (unsigned char)c - 'A'; - if (d >= 6) - d = 16; - else - d += 10; - } - - if (d >= 16) - break; - - value = (value << 4) + d; - } - - if (count <= 2) - { - if (*p == '\0') - return value; - if (*p == '.') - return (FT_UInt32)(value | VARIANT_BIT); - } - } - - /* Look for a non-initial dot in the glyph name in order to */ - /* find variants like `A.swash', `e.final', etc. */ - { - const char* p = glyph_name; - const char* dot = NULL; - - - for (; *p; p++) - { - if (*p == '.' && p > glyph_name) - { - dot = p; - break; - } - } - - /* now look up the glyph in the Adobe Glyph List */ - if (!dot) - return (FT_UInt32)ft_get_adobe_glyph_index(glyph_name, p); - else - return (FT_UInt32)(ft_get_adobe_glyph_index(glyph_name, dot) | - VARIANT_BIT); - } -} - -void FXFT_adobe_name_from_unicode(char* glyph_name, wchar_t unicode) -{ - int i, count; - - // start from top level node - count = ft_adobe_glyph_list[1]; - for (i = 0; i < count; i++) { - int child_offset = ft_adobe_glyph_list[i * 2 + 2] * 256 + ft_adobe_glyph_list[i * 2 + 3]; - if (xyq_search_node(glyph_name, 0, child_offset, unicode)) - return; - } - - // failed, clear the buffer - glyph_name[0] = 0; -} +int FXFT_unicode_from_adobe_name(const char* glyph_name) +{ + /* If the name begins with `uni', then the glyph name may be a */ + /* hard-coded unicode character code. */ + if (glyph_name[0] == 'u' && + glyph_name[1] == 'n' && + glyph_name[2] == 'i') + { + /* determine whether the next four characters following are */ + /* hexadecimal. */ + + /* XXX: Add code to deal with ligatures, i.e. glyph names like */ + /* `uniXXXXYYYYZZZZ'... */ + + FT_Int count; + FT_UInt32 value = 0; + const char* p = glyph_name + 3; + + + for (count = 4; count > 0; count--, p++) + { + char c = *p; + unsigned int d; + + + d = (unsigned char)c - '0'; + if (d >= 10) + { + d = (unsigned char)c - 'A'; + if (d >= 6) + d = 16; + else + d += 10; + } + + /* Exit if a non-uppercase hexadecimal character was found */ + /* -- this also catches character codes below `0' since such */ + /* negative numbers cast to `unsigned int' are far too big. */ + if (d >= 16) + break; + + value = (value << 4) + d; + } + + /* there must be exactly four hex digits */ + if (count == 0) + { + if (*p == '\0') + return value; + if (*p == '.') + return (FT_UInt32)(value | VARIANT_BIT); + } + } + + /* If the name begins with `u', followed by four to six uppercase */ + /* hexadecimal digits, it is a hard-coded unicode character code. */ + if (glyph_name[0] == 'u') + { + FT_Int count; + FT_UInt32 value = 0; + const char* p = glyph_name + 1; + + + for (count = 6; count > 0; count--, p++) + { + char c = *p; + unsigned int d; + + + d = (unsigned char)c - '0'; + if (d >= 10) + { + d = (unsigned char)c - 'A'; + if (d >= 6) + d = 16; + else + d += 10; + } + + if (d >= 16) + break; + + value = (value << 4) + d; + } + + if (count <= 2) + { + if (*p == '\0') + return value; + if (*p == '.') + return (FT_UInt32)(value | VARIANT_BIT); + } + } + + /* Look for a non-initial dot in the glyph name in order to */ + /* find variants like `A.swash', `e.final', etc. */ + { + const char* p = glyph_name; + const char* dot = NULL; + + + for (; *p; p++) + { + if (*p == '.' && p > glyph_name) + { + dot = p; + break; + } + } + + /* now look up the glyph in the Adobe Glyph List */ + if (!dot) + return (FT_UInt32)ft_get_adobe_glyph_index(glyph_name, p); + else + return (FT_UInt32)(ft_get_adobe_glyph_index(glyph_name, dot) | + VARIANT_BIT); + } +} + +void FXFT_adobe_name_from_unicode(char* glyph_name, wchar_t unicode) +{ + int i, count; + + // start from top level node + count = ft_adobe_glyph_list[1]; + for (i = 0; i < count; i++) { + int child_offset = ft_adobe_glyph_list[i * 2 + 2] * 256 + ft_adobe_glyph_list[i * 2 + 3]; + if (xyq_search_node(glyph_name, 0, child_offset, unicode)) + return; + } + + // failed, clear the buffer + glyph_name[0] = 0; +} -- cgit v1.2.3