summaryrefslogtreecommitdiff
path: root/base/gxblend.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-10-04 16:54:23 +0100
committerRobin Watts <robin.watts@artifex.com>2017-10-05 19:43:57 +0100
commit3dba9682de0b69a8822507a1c11d9f782c33b4c9 (patch)
treec9d9cb962d60d479845d13c4f5a68b12b25dac60 /base/gxblend.c
parent67bae85a6f46190262cf8a6ad6c37c7aff2e6cc5 (diff)
downloadghostpdl-3dba9682de0b69a8822507a1c11d9f782c33b4c9.tar.gz
Tweak art_pdf_composite_pixel_alpha_8_inline.
Normal blending allows us to not only skip the art_blend_pixel_8_inline call, but also to simplify the calculations.
Diffstat (limited to 'base/gxblend.c')
-rw-r--r--base/gxblend.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/base/gxblend.c b/base/gxblend.c
index 59f990b1a..1adad4b4e 100644
--- a/base/gxblend.c
+++ b/base/gxblend.c
@@ -989,21 +989,31 @@ art_pdf_composite_pixel_alpha_8_inline(byte *dst, byte *src, int n_chan,
src_scale = ((a_s << 16) + (a_r >> 1)) / a_r;
if (first_spot != 0) {
- /* Do compositing with blending */
- byte blend[ART_MAX_CHAN];
-
- art_blend_pixel_8_inline(blend, dst, src, first_spot, blend_mode, pblend_procs, p14dev);
- for (i = 0; i < first_spot; i++) {
- int c_bl; /* Result of blend function */
- int c_mix; /* Blend result mixed with source color */
-
- c_s = src[i];
- c_b = dst[i];
- c_bl = blend[i];
- tmp = a_b * (c_bl - ((int)c_s)) + 0x80;
- c_mix = c_s + (((tmp >> 8) + tmp) >> 8);
- tmp = (c_b << 16) + src_scale * (c_mix - c_b) + 0x8000;
- dst[i] = tmp >> 16;
+ if (blend_mode == BLEND_MODE_Normal)
+ {
+ for (i = 0; i < first_spot; i++) {
+ c_s = src[i];
+ c_b = dst[i];
+ tmp = (c_b << 16) + src_scale * (c_s - c_b) + 0x8000;
+ dst[i] = tmp >> 16;
+ }
+ } else {
+ /* Do compositing with blending */
+ byte blend[ART_MAX_CHAN];
+
+ art_blend_pixel_8_inline(blend, dst, src, first_spot, blend_mode, pblend_procs, p14dev);
+ for (i = 0; i < first_spot; i++) {
+ int c_bl; /* Result of blend function */
+ int c_mix; /* Blend result mixed with source color */
+
+ c_s = src[i];
+ c_b = dst[i];
+ c_bl = blend[i];
+ tmp = a_b * (c_bl - ((int)c_s)) + 0x80;
+ c_mix = c_s + (((tmp >> 8) + tmp) >> 8);
+ tmp = (c_b << 16) + src_scale * (c_mix - c_b) + 0x8000;
+ dst[i] = tmp >> 16;
+ }
}
}
dst[n_chan] = a_r;