summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fxge/dib/fx_dib_composite.cpp404
1 files changed, 135 insertions, 269 deletions
diff --git a/core/fxge/dib/fx_dib_composite.cpp b/core/fxge/dib/fx_dib_composite.cpp
index 5f0e4935cf..ead0b268c5 100644
--- a/core/fxge/dib/fx_dib_composite.cpp
+++ b/core/fxge/dib/fx_dib_composite.cpp
@@ -171,22 +171,22 @@ void RGB_Blend(int blend_mode,
results[2] = result.red;
}
+int GetAlpha(uint8_t src_alpha, const uint8_t* clip_scan, int col) {
+ return clip_scan ? clip_scan[col] * src_alpha / 255 : src_alpha;
+}
+
void CompositeRow_Argb2Mask(uint8_t* dest_scan,
const uint8_t* src_scan,
int pixel_count,
const uint8_t* clip_scan) {
src_scan += 3;
for (int col = 0; col < pixel_count; col++) {
- int src_alpha = *src_scan;
- if (clip_scan) {
- src_alpha = clip_scan[col] * src_alpha / 255;
- }
+ int src_alpha = GetAlpha(*src_scan, clip_scan, col);
uint8_t back_alpha = *dest_scan;
- if (!back_alpha) {
+ if (!back_alpha)
*dest_scan = src_alpha;
- } else if (src_alpha) {
+ else if (src_alpha)
*dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255;
- }
dest_scan++;
src_scan += 4;
}
@@ -197,16 +197,12 @@ void CompositeRow_Rgba2Mask(uint8_t* dest_scan,
int pixel_count,
const uint8_t* clip_scan) {
for (int col = 0; col < pixel_count; col++) {
- int src_alpha = *src_alpha_scan++;
- if (clip_scan) {
- src_alpha = clip_scan[col] * src_alpha / 255;
- }
+ int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
uint8_t back_alpha = *dest_scan;
- if (!back_alpha) {
+ if (!back_alpha)
*dest_scan = src_alpha;
- } else if (src_alpha) {
+ else if (src_alpha)
*dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255;
- }
dest_scan++;
}
}
@@ -215,17 +211,28 @@ void CompositeRow_Rgb2Mask(uint8_t* dest_scan,
const uint8_t* src_scan,
int width,
const uint8_t* clip_scan) {
- if (clip_scan) {
- for (int i = 0; i < width; i++) {
- *dest_scan = FXDIB_ALPHA_UNION(*dest_scan, *clip_scan);
- dest_scan++;
- clip_scan++;
- }
- } else {
+ if (!clip_scan) {
FXSYS_memset(dest_scan, 0xff, width);
+ return;
+ }
+ for (int i = 0; i < width; i++) {
+ *dest_scan = FXDIB_ALPHA_UNION(*dest_scan, *clip_scan);
+ dest_scan++;
+ clip_scan++;
}
}
+int GetGray(void* pIccTransform,
+ CCodec_IccModule* pIccModule,
+ const uint8_t* src_scan) {
+ if (!pIccTransform)
+ return FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
+
+ uint8_t gray;
+ pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
+ return gray;
+}
+
void CompositeRow_Argb2Graya(uint8_t* dest_scan,
const uint8_t* src_scan,
int pixel_count,
@@ -239,22 +246,13 @@ void CompositeRow_Argb2Graya(uint8_t* dest_scan,
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (blend_type) {
- bool bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
if (src_alpha_scan) {
for (int col = 0; col < pixel_count; col++) {
uint8_t back_alpha = *dst_alpha_scan;
if (back_alpha == 0) {
- int src_alpha = *src_alpha_scan++;
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
+ int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha) {
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan,
- 1);
- } else {
- *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
+ *dest_scan = GetGray(pIccTransform, pIccModule, src_scan);
*dst_alpha_scan = src_alpha;
}
dest_scan++;
@@ -262,10 +260,7 @@ void CompositeRow_Argb2Graya(uint8_t* dest_scan,
src_scan += 3;
continue;
}
- uint8_t src_alpha = *src_alpha_scan++;
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
+ uint8_t src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha == 0) {
dest_scan++;
dst_alpha_scan++;
@@ -274,13 +269,8 @@ void CompositeRow_Argb2Graya(uint8_t* dest_scan,
}
*dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha);
int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan);
- uint8_t gray;
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- } else {
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
- if (bNonseparableBlend)
+ uint8_t gray = GetGray(pIccTransform, pIccModule, src_scan);
+ if (blend_type >= FXDIB_BLEND_NONSEPARABLE)
gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan;
else
gray = Blend(blend_type, *dest_scan, gray);
@@ -289,144 +279,99 @@ void CompositeRow_Argb2Graya(uint8_t* dest_scan,
dst_alpha_scan++;
src_scan += 3;
}
- } else {
- for (int col = 0; col < pixel_count; col++) {
- uint8_t back_alpha = *dst_alpha_scan;
- if (back_alpha == 0) {
- int src_alpha = src_scan[3];
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
- if (src_alpha) {
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan,
- 1);
- } else {
- *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
- *dst_alpha_scan = src_alpha;
- }
- dest_scan++;
- dst_alpha_scan++;
- src_scan += 4;
- continue;
- }
- uint8_t src_alpha = src_scan[3];
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
- if (src_alpha == 0) {
- dest_scan++;
- dst_alpha_scan++;
- src_scan += 4;
- continue;
- }
- *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha);
- int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan);
- uint8_t gray;
- if (pIccTransform)
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- else
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
-
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio);
- dest_scan++;
- dst_alpha_scan++;
- src_scan += 4;
- }
+ return;
}
- return;
- }
- if (src_alpha_scan) {
for (int col = 0; col < pixel_count; col++) {
uint8_t back_alpha = *dst_alpha_scan;
if (back_alpha == 0) {
- int src_alpha = *src_alpha_scan++;
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
+ int src_alpha = GetAlpha(src_scan[3], clip_scan, col);
if (src_alpha) {
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan,
- 1);
- } else {
- *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
+ *dest_scan = GetGray(pIccTransform, pIccModule, src_scan);
*dst_alpha_scan = src_alpha;
}
dest_scan++;
dst_alpha_scan++;
- src_scan += 3;
+ src_scan += 4;
continue;
}
- uint8_t src_alpha = *src_alpha_scan++;
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
+ uint8_t src_alpha = GetAlpha(src_scan[3], clip_scan, col);
if (src_alpha == 0) {
dest_scan++;
dst_alpha_scan++;
- src_scan += 3;
+ src_scan += 4;
continue;
}
*dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha);
int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan);
- uint8_t gray;
- if (pIccTransform)
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- else
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
+ uint8_t gray = GetGray(pIccTransform, pIccModule, src_scan);
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio);
dest_scan++;
dst_alpha_scan++;
- src_scan += 3;
+ src_scan += 4;
}
- } else {
+ return;
+ }
+ if (src_alpha_scan) {
for (int col = 0; col < pixel_count; col++) {
uint8_t back_alpha = *dst_alpha_scan;
if (back_alpha == 0) {
- int src_alpha = src_scan[3];
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
+ int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha) {
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan,
- 1);
- } else {
- *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
+ *dest_scan = GetGray(pIccTransform, pIccModule, src_scan);
*dst_alpha_scan = src_alpha;
}
dest_scan++;
dst_alpha_scan++;
- src_scan += 4;
+ src_scan += 3;
continue;
}
- uint8_t src_alpha = src_scan[3];
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
+ uint8_t src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha == 0) {
dest_scan++;
dst_alpha_scan++;
- src_scan += 4;
+ src_scan += 3;
continue;
}
*dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha);
int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan);
- uint8_t gray;
- if (pIccTransform)
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- else
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
+ uint8_t gray = GetGray(pIccTransform, pIccModule, src_scan);
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio);
dest_scan++;
dst_alpha_scan++;
+ src_scan += 3;
+ }
+ return;
+ }
+ for (int col = 0; col < pixel_count; col++) {
+ uint8_t back_alpha = *dst_alpha_scan;
+ if (back_alpha == 0) {
+ int src_alpha = GetAlpha(src_scan[3], clip_scan, col);
+ if (src_alpha) {
+ *dest_scan = GetGray(pIccTransform, pIccModule, src_scan);
+ *dst_alpha_scan = src_alpha;
+ }
+ dest_scan++;
+ dst_alpha_scan++;
src_scan += 4;
+ continue;
}
+ uint8_t src_alpha = GetAlpha(src_scan[3], clip_scan, col);
+ if (src_alpha == 0) {
+ dest_scan++;
+ dst_alpha_scan++;
+ src_scan += 4;
+ continue;
+ }
+ *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha);
+ int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan);
+ uint8_t gray = GetGray(pIccTransform, pIccModule, src_scan);
+
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio);
+ dest_scan++;
+ dst_alpha_scan++;
+ src_scan += 4;
}
}
@@ -446,15 +391,9 @@ void CompositeRow_Argb2Gray(uint8_t* dest_scan,
bool bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
if (src_alpha_scan) {
for (int col = 0; col < pixel_count; col++) {
- int src_alpha = *src_alpha_scan++;
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
+ int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha) {
- if (pIccTransform)
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- else
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
+ gray = GetGray(pIccTransform, pIccModule, src_scan);
if (bNonseparableBlend)
gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan;
@@ -465,64 +404,46 @@ void CompositeRow_Argb2Gray(uint8_t* dest_scan,
dest_scan++;
src_scan += 3;
}
- } else {
- for (int col = 0; col < pixel_count; col++) {
- int src_alpha = src_scan[3];
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
- if (src_alpha) {
- if (pIccTransform)
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- else
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
+ return;
+ }
+ for (int col = 0; col < pixel_count; col++) {
+ int src_alpha = GetAlpha(src_scan[3], clip_scan, col);
+ if (src_alpha) {
+ gray = GetGray(pIccTransform, pIccModule, src_scan);
- if (bNonseparableBlend)
- gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan;
- else
- gray = Blend(blend_type, *dest_scan, gray);
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha);
- }
- dest_scan++;
- src_scan += 4;
+ if (bNonseparableBlend)
+ gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan;
+ else
+ gray = Blend(blend_type, *dest_scan, gray);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha);
}
+ dest_scan++;
+ src_scan += 4;
}
return;
}
if (src_alpha_scan) {
for (int col = 0; col < pixel_count; col++) {
- int src_alpha = *src_alpha_scan++;
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
+ int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha) {
- if (pIccTransform)
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- else
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
+ gray = GetGray(pIccTransform, pIccModule, src_scan);
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha);
}
dest_scan++;
src_scan += 3;
}
- } else {
- for (int col = 0; col < pixel_count; col++) {
- int src_alpha = src_scan[3];
- if (clip_scan)
- src_alpha = clip_scan[col] * src_alpha / 255;
-
- if (src_alpha) {
- if (pIccTransform)
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- else
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
+ return;
+ }
+ for (int col = 0; col < pixel_count; col++) {
+ int src_alpha = GetAlpha(src_scan[3], clip_scan, col);
+ if (src_alpha) {
+ gray = GetGray(pIccTransform, pIccModule, src_scan);
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha);
- }
- dest_scan++;
- src_scan += 4;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha);
}
+ dest_scan++;
+ src_scan += 4;
}
}
@@ -535,42 +456,31 @@ void CompositeRow_Rgb2Gray(uint8_t* dest_scan,
void* pIccTransform) {
CCodec_IccModule* pIccModule = nullptr;
uint8_t gray;
- if (pIccTransform) {
+ if (pIccTransform)
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
- }
if (blend_type) {
bool bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
for (int col = 0; col < pixel_count; col++) {
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- } else {
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
+ gray = GetGray(pIccTransform, pIccModule, src_scan);
if (bNonseparableBlend)
gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan;
else
gray = Blend(blend_type, *dest_scan, gray);
- if (clip_scan && clip_scan[col] < 255) {
+ if (clip_scan && clip_scan[col] < 255)
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]);
- } else {
+ else
*dest_scan = gray;
- }
dest_scan++;
src_scan += src_Bpp;
}
return;
}
for (int col = 0; col < pixel_count; col++) {
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- } else {
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
- if (clip_scan && clip_scan[col] < 255) {
+ gray = GetGray(pIccTransform, pIccModule, src_scan);
+ if (clip_scan && clip_scan[col] < 255)
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]);
- } else {
+ else
*dest_scan = gray;
- }
dest_scan++;
src_scan += src_Bpp;
}
@@ -585,28 +495,21 @@ void CompositeRow_Rgb2Graya(uint8_t* dest_scan,
uint8_t* dest_alpha_scan,
void* pIccTransform) {
CCodec_IccModule* pIccModule = nullptr;
- if (pIccTransform) {
+ if (pIccTransform)
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
- }
if (blend_type) {
- bool bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
for (int col = 0; col < pixel_count; col++) {
int back_alpha = *dest_alpha_scan;
if (back_alpha == 0) {
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 1);
- } else {
- *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
+ *dest_scan = GetGray(pIccTransform, pIccModule, src_scan);
dest_scan++;
dest_alpha_scan++;
src_scan += src_Bpp;
continue;
}
int src_alpha = 255;
- if (clip_scan) {
+ if (clip_scan)
src_alpha = clip_scan[col];
- }
if (src_alpha == 0) {
dest_scan++;
dest_alpha_scan++;
@@ -617,13 +520,8 @@ void CompositeRow_Rgb2Graya(uint8_t* dest_scan,
back_alpha + src_alpha - back_alpha * src_alpha / 255;
*dest_alpha_scan++ = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
- uint8_t gray;
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- } else {
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
- if (bNonseparableBlend)
+ uint8_t gray = GetGray(pIccTransform, pIccModule, src_scan);
+ if (blend_type >= FXDIB_BLEND_NONSEPARABLE)
gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan;
else
gray = Blend(blend_type, *dest_scan, gray);
@@ -635,15 +533,10 @@ void CompositeRow_Rgb2Graya(uint8_t* dest_scan,
}
for (int col = 0; col < pixel_count; col++) {
int src_alpha = 255;
- if (clip_scan) {
+ if (clip_scan)
src_alpha = clip_scan[col];
- }
if (src_alpha == 255) {
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 1);
- } else {
- *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
+ *dest_scan = GetGray(pIccTransform, pIccModule, src_scan);
dest_scan++;
*dest_alpha_scan++ = 255;
src_scan += src_Bpp;
@@ -659,12 +552,7 @@ void CompositeRow_Rgb2Graya(uint8_t* dest_scan,
uint8_t dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255;
*dest_alpha_scan++ = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
- uint8_t gray;
- if (pIccTransform) {
- pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1);
- } else {
- gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan);
- }
+ uint8_t gray = GetGray(pIccTransform, pIccModule, src_scan);
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio);
dest_scan++;
src_scan += src_Bpp;
@@ -1802,19 +1690,15 @@ void CompositeRow_8bppPal2Gray(uint8_t* dest_scan,
bool bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
for (int col = 0; col < pixel_count; col++) {
uint8_t gray = pPalette[*src_scan];
- int src_alpha = *src_alpha_scan++;
- if (clip_scan) {
- src_alpha = clip_scan[col] * src_alpha / 255;
- }
+ int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (bNonseparableBlend)
gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan;
else
gray = Blend(blend_type, *dest_scan, gray);
- if (src_alpha) {
+ if (src_alpha)
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha);
- } else {
+ else
*dest_scan = gray;
- }
dest_scan++;
src_scan++;
}
@@ -1822,15 +1706,11 @@ void CompositeRow_8bppPal2Gray(uint8_t* dest_scan,
}
for (int col = 0; col < pixel_count; col++) {
uint8_t gray = pPalette[*src_scan];
- int src_alpha = *src_alpha_scan++;
- if (clip_scan) {
- src_alpha = clip_scan[col] * src_alpha / 255;
- }
- if (src_alpha) {
+ int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
+ if (src_alpha)
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha);
- } else {
+ else
*dest_scan = gray;
- }
dest_scan++;
src_scan++;
}
@@ -1843,11 +1723,10 @@ void CompositeRow_8bppPal2Gray(uint8_t* dest_scan,
gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan;
else
gray = Blend(blend_type, *dest_scan, gray);
- if (clip_scan && clip_scan[col] < 255) {
+ if (clip_scan && clip_scan[col] < 255)
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]);
- } else {
+ else
*dest_scan = gray;
- }
dest_scan++;
src_scan++;
}
@@ -1855,11 +1734,10 @@ void CompositeRow_8bppPal2Gray(uint8_t* dest_scan,
}
for (int col = 0; col < pixel_count; col++) {
uint8_t gray = pPalette[*src_scan];
- if (clip_scan && clip_scan[col] < 255) {
+ if (clip_scan && clip_scan[col] < 255)
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]);
- } else {
+ else
*dest_scan = gray;
- }
dest_scan++;
src_scan++;
}
@@ -1882,10 +1760,7 @@ void CompositeRow_8bppPal2Graya(uint8_t* dest_scan,
src_scan++;
uint8_t back_alpha = *dest_alpha_scan;
if (back_alpha == 0) {
- int src_alpha = *src_alpha_scan++;
- if (clip_scan) {
- src_alpha = clip_scan[col] * src_alpha / 255;
- }
+ int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha) {
*dest_scan = gray;
*dest_alpha_scan = src_alpha;
@@ -1894,10 +1769,7 @@ void CompositeRow_8bppPal2Graya(uint8_t* dest_scan,
dest_alpha_scan++;
continue;
}
- uint8_t src_alpha = *src_alpha_scan++;
- if (clip_scan) {
- src_alpha = clip_scan[col] * src_alpha / 255;
- }
+ uint8_t src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha == 0) {
dest_scan++;
dest_alpha_scan++;
@@ -1921,10 +1793,7 @@ void CompositeRow_8bppPal2Graya(uint8_t* dest_scan,
src_scan++;
uint8_t back_alpha = *dest_alpha_scan;
if (back_alpha == 0) {
- int src_alpha = *src_alpha_scan++;
- if (clip_scan) {
- src_alpha = clip_scan[col] * src_alpha / 255;
- }
+ int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha) {
*dest_scan = gray;
*dest_alpha_scan = src_alpha;
@@ -1933,10 +1802,7 @@ void CompositeRow_8bppPal2Graya(uint8_t* dest_scan,
dest_alpha_scan++;
continue;
}
- uint8_t src_alpha = *src_alpha_scan++;
- if (clip_scan) {
- src_alpha = clip_scan[col] * src_alpha / 255;
- }
+ uint8_t src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col);
if (src_alpha == 0) {
dest_scan++;
dest_alpha_scan++;