diff options
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/dib/fx_dib_composite.cpp | 124 | ||||
-rw-r--r-- | core/fxge/dib/fx_dib_main.cpp | 21 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_font.cpp | 2 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_path.cpp | 4 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_text.cpp | 5 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 4 |
6 files changed, 76 insertions, 84 deletions
diff --git a/core/fxge/dib/fx_dib_composite.cpp b/core/fxge/dib/fx_dib_composite.cpp index 0bf67ccb71..5bfe46e572 100644 --- a/core/fxge/dib/fx_dib_composite.cpp +++ b/core/fxge/dib/fx_dib_composite.cpp @@ -200,7 +200,9 @@ void _RGB_Blend(int blend_mode, const uint8_t* src_scan, uint8_t* dest_scan, int results[3]) { - _RGB src, back, result; + _RGB src; + _RGB back; + _RGB result = {0, 0, 0}; src.red = src_scan[2]; src.green = src_scan[1]; src.blue = src_scan[0]; @@ -291,7 +293,6 @@ void _CompositeRow_Argb2Graya(uint8_t* dest_scan, if (blend_type) { FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; - int blended_color; if (src_alpha_scan) { for (int col = 0; col < pixel_count; col++) { uint8_t back_alpha = *dst_alpha_scan; @@ -332,12 +333,10 @@ void _CompositeRow_Argb2Graya(uint8_t* dest_scan, } else { gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); } - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); dest_scan++; dst_alpha_scan++; @@ -498,7 +497,6 @@ inline void _CompositeRow_Argb2Gray(uint8_t* dest_scan, if (blend_type) { FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; - int blended_color; if (src_alpha_scan) { for (int col = 0; col < pixel_count; col++) { int src_alpha = *src_alpha_scan++; @@ -511,12 +509,10 @@ inline void _CompositeRow_Argb2Gray(uint8_t* dest_scan, else gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); } dest_scan++; @@ -534,12 +530,10 @@ inline void _CompositeRow_Argb2Gray(uint8_t* dest_scan, else gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); } dest_scan++; @@ -599,19 +593,16 @@ inline void _CompositeRow_Rgb2Gray(uint8_t* dest_scan, } if (blend_type) { FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; - int blended_color; for (int col = 0; col < pixel_count; col++) { if (pIccTransform) { pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); } else { gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); } - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); if (clip_scan && clip_scan[col] < 255) { *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); } else { @@ -650,7 +641,6 @@ void _CompositeRow_Rgb2Graya(uint8_t* dest_scan, pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); } if (blend_type) { - int blended_color; FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; for (int col = 0; col < pixel_count; col++) { int back_alpha = *dest_alpha_scan; @@ -685,12 +675,10 @@ void _CompositeRow_Rgb2Graya(uint8_t* dest_scan, } else { gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); } - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); dest_scan++; src_scan += src_Bpp; @@ -1849,19 +1837,16 @@ inline void _CompositeRow_8bppPal2Gray(uint8_t* dest_scan, if (src_alpha_scan) { if (blend_type) { FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; - int blended_color; for (int col = 0; col < pixel_count; col++) { uint8_t gray = pPalette[*src_scan]; int src_alpha = *src_alpha_scan++; if (clip_scan) { src_alpha = clip_scan[col] * src_alpha / 255; } - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); if (src_alpha) { *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); } else { @@ -1889,15 +1874,12 @@ inline void _CompositeRow_8bppPal2Gray(uint8_t* dest_scan, } else { if (blend_type) { FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; - int blended_color; for (int col = 0; col < pixel_count; col++) { uint8_t gray = pPalette[*src_scan]; - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); if (clip_scan && clip_scan[col] < 255) { *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); } else { @@ -1931,7 +1913,6 @@ inline void _CompositeRow_8bppPal2Graya(uint8_t* dest_scan, if (src_alpha_scan) { if (blend_type) { FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; - int blended_color; for (int col = 0; col < pixel_count; col++) { uint8_t gray = pPalette[*src_scan]; src_scan++; @@ -1961,12 +1942,10 @@ inline void _CompositeRow_8bppPal2Graya(uint8_t* dest_scan, *dest_alpha_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); dest_alpha_scan++; dest_scan++; @@ -2008,7 +1987,6 @@ inline void _CompositeRow_8bppPal2Graya(uint8_t* dest_scan, } else { if (blend_type) { FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; - int blended_color; for (int col = 0; col < pixel_count; col++) { uint8_t gray = pPalette[*src_scan]; src_scan++; @@ -2028,12 +2006,10 @@ inline void _CompositeRow_8bppPal2Graya(uint8_t* dest_scan, back_alpha + src_alpha - back_alpha * src_alpha / 255; *dest_alpha_scan++ = dest_alpha; int alpha_ratio = src_alpha * 255 / dest_alpha; - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); dest_scan++; } @@ -2074,18 +2050,15 @@ inline void _CompositeRow_1bppPal2Gray(uint8_t* dest_scan, int set_gray = pPalette[1]; if (blend_type) { FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; - int blended_color; for (int col = 0; col < pixel_count; col++) { uint8_t gray = (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) ? set_gray : reset_gray; - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); if (clip_scan && clip_scan[col] < 255) { *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); } else { @@ -2120,7 +2093,6 @@ inline void _CompositeRow_1bppPal2Graya(uint8_t* dest_scan, int set_gray = pPalette[1]; if (blend_type) { FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; - int blended_color; for (int col = 0; col < pixel_count; col++) { uint8_t gray = (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) @@ -2142,12 +2114,10 @@ inline void _CompositeRow_1bppPal2Graya(uint8_t* dest_scan, back_alpha + src_alpha - back_alpha * src_alpha / 255; *dest_alpha_scan++ = dest_alpha; int alpha_ratio = src_alpha * 255 / dest_alpha; - if (bNonseparableBlend) { - blended_color = - blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - } - gray = bNonseparableBlend ? blended_color - : _BLEND(blend_type, *dest_scan, gray); + if (bNonseparableBlend) + gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + else + gray = _BLEND(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); dest_scan++; } diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp index 8ce20568df..a7f7dc75bc 100644 --- a/core/fxge/dib/fx_dib_main.cpp +++ b/core/fxge/dib/fx_dib_main.cpp @@ -1234,14 +1234,31 @@ void CFX_DIBitmap::DownSampleScanline(int line, } } } + +// TODO(weili): Split this function into two for handling CMYK and RGB +// colors separately. FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor) { ASSERT(!IsAlphaMask()); if (!m_pBuffer || IsAlphaMask()) { return FALSE; } - int fc, fm, fy, fk, bc, bm, by, bk; - int fr, fg, fb, br, bg, bb; + // Values used for CMYK colors. + int fc = 0; + int fm = 0; + int fy = 0; + int fk = 0; + int bc = 0; + int bm = 0; + int by = 0; + int bk = 0; + // Values used for RGB colors. + int fr = 0; + int fg = 0; + int fb = 0; + int br = 0; + int bg = 0; + int bb = 0; FX_BOOL isCmykImage = IsCmykImage(); if (isCmykImage) { fc = FXSYS_GetCValue(forecolor); diff --git a/core/fxge/ge/fx_ge_font.cpp b/core/fxge/ge/fx_ge_font.cpp index 67b968b44d..098195dded 100644 --- a/core/fxge/ge/fx_ge_font.cpp +++ b/core/fxge/ge/fx_ge_font.cpp @@ -522,7 +522,7 @@ FX_DWORD CFX_UnicodeEncodingEx::CharCodeFromUnicode(FX_WCHAR Unicode) const { return Unicode; } } - return -1; + return static_cast<FX_DWORD>(-1); } CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx(CFX_Font* pFont, diff --git a/core/fxge/ge/fx_ge_path.cpp b/core/fxge/ge/fx_ge_path.cpp index 0b52cdf9e4..de84de2518 100644 --- a/core/fxge/ge/fx_ge_path.cpp +++ b/core/fxge/ge/fx_ge_path.cpp @@ -340,7 +340,9 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, -100000 * 1.0f); int iPoint = 0; FX_FLOAT half_width = line_width; - int iStartPoint, iEndPoint, iMiddlePoint; + int iStartPoint = 0; + int iEndPoint = 0; + int iMiddlePoint = 0; FX_BOOL bJoin; while (iPoint < m_PointCount) { if (m_pPoints[iPoint].m_Flag == FXPT_MOVETO) { diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index 3f001d2f96..bcc630ca71 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -375,7 +375,10 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, uint8_t* dest_buf = bitmap.GetBuffer(); int dest_pitch = bitmap.GetPitch(); int Bpp = bitmap.GetBPP() / 8; - int a, r, g, b; + int a = 0; + int r = 0; + int g = 0; + int b = 0; if (anti_alias == FXFT_RENDER_MODE_LCD) { _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); ArgbDecode(fill_color, a, r, g, b); diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index ce181bb448..2fdfa3a8c7 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -982,7 +982,7 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, } GpPen* pPen = NULL; CallFunc(GdipCreatePen1)((ARGB)argb, width, UnitWorld, &pPen); - LineCap lineCap; + LineCap lineCap = LineCapFlat; DashCap dashCap = DashCapFlat; FX_BOOL bDashExtend = FALSE; switch (pGraphState->m_LineCap) { @@ -1000,7 +1000,7 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, break; } CallFunc(GdipSetPenLineCap197819)(pPen, lineCap, lineCap, dashCap); - LineJoin lineJoin; + LineJoin lineJoin = LineJoinMiterClipped; switch (pGraphState->m_LineJoin) { case CFX_GraphStateData::LineJoinMiter: lineJoin = LineJoinMiterClipped; |