summaryrefslogtreecommitdiff
path: root/core/src/fxge
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fxge')
-rw-r--r--core/src/fxge/agg/src/fx_agg_driver.cpp9
-rw-r--r--core/src/fxge/dib/fx_dib_composite.cpp12
-rw-r--r--core/src/fxge/dib/fx_dib_convert.cpp24
-rw-r--r--core/src/fxge/dib/fx_dib_engine.cpp9
-rw-r--r--core/src/fxge/dib/fx_dib_main.cpp7
-rw-r--r--core/src/fxge/dib/fx_dib_transform.cpp6
-rw-r--r--core/src/fxge/ge/fx_ge_device.cpp9
-rw-r--r--core/src/fxge/ge/fx_ge_font.cpp27
-rw-r--r--core/src/fxge/ge/fx_ge_fontmap.cpp12
-rw-r--r--core/src/fxge/ge/fx_ge_linux.cpp9
-rw-r--r--core/src/fxge/ge/fx_ge_path.cpp6
-rw-r--r--core/src/fxge/ge/fx_ge_text.cpp57
-rw-r--r--core/src/fxge/skia/fx_skia_blitter_new.cpp3061
-rw-r--r--core/src/fxge/win32/fx_win32_device.cpp80
-rw-r--r--core/src/fxge/win32/fx_win32_dib.cpp3
-rw-r--r--core/src/fxge/win32/fx_win32_dwrite.cpp20
-rw-r--r--core/src/fxge/win32/fx_win32_gdipext.cpp8
-rw-r--r--core/src/fxge/win32/fx_win32_print.cpp42
18 files changed, 1699 insertions, 1702 deletions
diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp
index 118db7bf1f..475e5f6442 100644
--- a/core/src/fxge/agg/src/fx_agg_driver.cpp
+++ b/core/src/fxge/agg/src/fx_agg_driver.cpp
@@ -417,8 +417,7 @@ public:
}
}
return;
- }
- if (Bpp == 3 || Bpp == 4) {
+ } else if (Bpp == 3 || Bpp == 4) {
for (int col = col_start; col < col_end; col ++) {
int src_alpha;
if (clip_scan) {
@@ -480,8 +479,7 @@ public:
}
}
return;
- }
- if (Bpp == 3 || Bpp == 4) {
+ } else if (Bpp == 3 || Bpp == 4) {
for (int col = col_start; col < col_end; col ++) {
int src_alpha;
if (clip_scan) {
@@ -510,8 +508,7 @@ public:
continue;
}
return;
- }
- if (Bpp == 1) {
+ } else 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 cb99a37ff4..19a870ade3 100644
--- a/core/src/fxge/dib/fx_dib_composite.cpp
+++ b/core/src/fxge/dib/fx_dib_composite.cpp
@@ -3938,8 +3938,7 @@ void CFX_ScanlineCompositor::CompositePalBitmapLine(uint8_t* dest_scan, const ui
if (m_SrcFormat == FXDIB_1bppRgb) {
if (m_DestFormat == FXDIB_8bppRgb) {
return;
- }
- if(m_DestFormat == FXDIB_Argb) {
+ } else 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);
@@ -3947,8 +3946,7 @@ void CFX_ScanlineCompositor::CompositePalBitmapLine(uint8_t* dest_scan, const ui
} else {
if (m_DestFormat == FXDIB_8bppRgb) {
return;
- }
- if (m_DestFormat == FXDIB_Argb) {
+ } else 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);
@@ -3959,8 +3957,7 @@ 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;
- }
- if ((m_DestFormat & 0xff) == 8) {
+ } else 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);
@@ -4211,8 +4208,7 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left, int top, int width, int height, FX
}
}
return TRUE;
- }
- if (m_bpp == 1) {
+ } else 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 d7860aee19..8e96379d37 100644
--- a/core/src/fxge/dib/fx_dib_convert.cpp
+++ b/core/src/fxge/dib/fx_dib_convert.cpp
@@ -843,14 +843,12 @@ 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);
- }
- if ((src_format & 0xff) == 8) {
+ } else 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);
- }
- if ((src_format & 0xff) >= 24) {
+ } else if ((src_format & 0xff) >= 24) {
return _ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return FALSE;
@@ -863,8 +861,7 @@ 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);
- }
- if ((src_format & 0xff) >= 24) {
+ } else if ((src_format & 0xff) >= 24) {
return _ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
}
return FALSE;
@@ -876,17 +873,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);
- }
- if ((src_format & 0xff) == 8) {
+ } else 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);
- }
- if ((src_format & 0xff) == 24) {
+ } else if ((src_format & 0xff) == 24) {
return _ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
- }
- if ((src_format & 0xff) == 32) {
+ } else if ((src_format & 0xff) == 32) {
return _ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, pIccTransform);
}
return FALSE;
@@ -898,14 +892,12 @@ 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);
- }
- if ((src_format & 0xff) == 8) {
+ } else 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);
- }
- if ((src_format & 0xff) >= 24) {
+ } else 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 7390c431d9..11e9a110cb 100644
--- a/core/src/fxge/dib/fx_dib_engine.cpp
+++ b/core/src/fxge/dib/fx_dib_engine.cpp
@@ -346,8 +346,9 @@ 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;
@@ -744,15 +745,17 @@ 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 8a864f10a1..82a14974f4 100644
--- a/core/src/fxge/dib/fx_dib_main.cpp
+++ b/core/src/fxge/dib/fx_dib_main.cpp
@@ -1033,8 +1033,10 @@ 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;
}
- return m_pPalette ? m_pPalette[0] : 0xff000000;
+ break;
}
case FXDIB_8bppMask:
return (*pos) << 24;
@@ -1586,8 +1588,7 @@ FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause)
{
if (m_Status == 1) {
return m_Stretcher.Continue(pPause);
- }
- if (m_Status == 2) {
+ } else 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 e34e715bf2..423577977c 100644
--- a/core/src/fxge/dib/fx_dib_transform.cpp
+++ b/core/src/fxge/dib/fx_dib_transform.cpp
@@ -345,11 +345,9 @@ 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;
- }
- if (m_Status == 2) {
+ } else if (m_Status == 2) {
return m_Stretcher.Continue(pPause);
- }
- if (m_Status != 3) {
+ } else 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 0baa99cdc7..793dfc5ee2 100644
--- a/core/src/fxge/ge/fx_ge_device.cpp
+++ b/core/src/fxge/ge/fx_ge_device.cpp
@@ -64,14 +64,13 @@ 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);
- }
- if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) {
+ } else 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 6a950bf20b..f88cbaacde 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -309,8 +309,9 @@ 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
{
@@ -328,8 +329,9 @@ 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)
{
@@ -408,20 +410,21 @@ 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);
- }
- 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);
+ } 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 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 4674589911..8956cd1c88 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -688,8 +688,7 @@ uint8_t _GetCharsetFromCodePage(FX_WORD codepage)
const CHARSET_MAP & cp = g_Codepage2CharsetTable[iMid];
if (codepage == cp.codepage) {
return cp.charset;
- }
- if (codepage < cp.codepage) {
+ } else if (codepage < cp.codepage) {
iEnd = iMid - 1;
} else {
iStart = iMid + 1;
@@ -1160,10 +1159,14 @@ 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);
}
-#endif
+#else
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;
@@ -1172,8 +1175,9 @@ 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 4e7334596b..631ff8e93f 100644
--- a/core/src/fxge/ge/fx_ge_linux.cpp
+++ b/core/src/fxge/ge/fx_ge_linux.cpp
@@ -63,14 +63,15 @@ 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;
}
- return 1;
- }
- if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
+ } else 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 b1410b3911..ea1d80390b 100644
--- a/core/src/fxge/ge/fx_ge_path.cpp
+++ b/core/src/fxge/ge/fx_ge_path.cpp
@@ -55,8 +55,7 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect, FX_RECT mask_rect, CFX_DIBitma
if (m_Box.IsEmpty()) {
m_Type = RectI;
return;
- }
- if (m_Box == mask_rect) {
+ } else if (m_Box == mask_rect) {
m_Mask = Mask;
return;
}
@@ -230,8 +229,7 @@ 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;
- }
- if (start_y == end_y) {
+ } else 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 233ed94963..76c7cf429e 100644
--- a/core/src/fxge/ge/fx_ge_text.cpp
+++ b/core/src/fxge/ge/fx_ge_text.cpp
@@ -1154,37 +1154,38 @@ 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 {
- 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;
+ 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 = 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 FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
- text_flags |= FXTEXT_NO_NATIVETEXT;
- return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, 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 3437eb497d..da9e6f28f1 100644
--- a/core/src/fxge/skia/fx_skia_blitter_new.cpp
+++ b/core/src/fxge/skia/fx_skia_blitter_new.cpp
@@ -8,1602 +8,1603 @@
#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;
- }
- 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;
+ } 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;
+ }
- /*----------------------------------------------------------------------------------------------------*/
- 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 18bcc595a4..b0dbc14ebc 100644
--- a/core/src/fxge/win32/fx_win32_device.cpp
+++ b/core/src/fxge/win32/fx_win32_device.cpp
@@ -267,8 +267,7 @@ void CWin32FontInfo::GetJapanesePreference(CFX_ByteString& face, int weight, int
}
}
return;
- }
- if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
+ } else 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 {
@@ -990,10 +989,8 @@ 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,22 +999,23 @@ 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);
- }
- 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;
+ } 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);
}
- 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;
}
@@ -1047,10 +1045,9 @@ 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 +1064,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,24 +1073,25 @@ 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;
- }
- 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;
+ } 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);
}
- 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 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 3dcfce4802..191c2dc9cd 100644
--- a/core/src/fxge/win32/fx_win32_dib.cpp
+++ b/core/src/fxge/win32/fx_win32_dib.cpp
@@ -146,8 +146,7 @@ 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);
- }
- if (args.flags == WINDIB_OPEN_MEMORY) {
+ } else 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 65a35d86a1..889a5684b7 100644
--- a/core/src/fxge/win32/fx_win32_dwrite.cpp
+++ b/core/src/fxge/win32/fx_win32_dwrite.cpp
@@ -282,9 +282,10 @@ 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()
{
@@ -305,14 +306,16 @@ 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)
{
@@ -338,9 +341,10 @@ 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 d76d52e50b..8fef914cd8 100644
--- a/core/src/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/src/fxge/win32/fx_win32_gdipext.cpp
@@ -1010,14 +1010,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 86dbf9bb0a..199ab78d9f 100644
--- a/core/src/fxge/win32/fx_win32_print.cpp
+++ b/core/src/fxge/win32/fx_win32_print.cpp
@@ -80,31 +80,33 @@ 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);
- }
- 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) {
+ } else {
+ ASSERT(pSource != NULL);
+ if (pSource->HasAlpha()) {
return FALSE;
}
- if (dest_width < 0) {
- dest_left += dest_width;
+ 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_height < 0) {
- dest_top += dest_height;
+ CFX_DIBExtractor temp(pSource);
+ CFX_DIBitmap* pBitmap = temp;
+ if (pBitmap == NULL) {
+ return FALSE;
}
- 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);
}
- 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)
{