summaryrefslogtreecommitdiff
path: root/draw
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-10 01:24:01 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-10 01:24:01 +0200
commitd914e3415af1c9c7d8644dfa50fdcf9a79cc01d5 (patch)
tree42b1abdc4ebe58dd008d9f8906db24fa5187324d /draw
parente8e507b38b8c4429abd6e7b32fe8e3029bfab065 (diff)
downloadmupdf-d914e3415af1c9c7d8644dfa50fdcf9a79cc01d5.tar.xz
Make blendmode opaque.
Diffstat (limited to 'draw')
-rw-r--r--draw/draw_blend.c48
-rw-r--r--draw/draw_device.c8
2 files changed, 47 insertions, 9 deletions
diff --git a/draw/draw_blend.c b/draw/draw_blend.c
index 2d68758a..ef9d8c7c 100644
--- a/draw/draw_blend.c
+++ b/draw/draw_blend.c
@@ -4,7 +4,30 @@
typedef unsigned char byte;
-const char *fz_blendmode_names[] =
+enum
+{
+ /* PDF 1.4 -- standard separable */
+ FZ_BLEND_NORMAL,
+ FZ_BLEND_MULTIPLY,
+ FZ_BLEND_SCREEN,
+ FZ_BLEND_OVERLAY,
+ FZ_BLEND_DARKEN,
+ FZ_BLEND_LIGHTEN,
+ FZ_BLEND_COLOR_DODGE,
+ FZ_BLEND_COLOR_BURN,
+ FZ_BLEND_HARD_LIGHT,
+ FZ_BLEND_SOFT_LIGHT,
+ FZ_BLEND_DIFFERENCE,
+ FZ_BLEND_EXCLUSION,
+
+ /* PDF 1.4 -- standard non-separable */
+ FZ_BLEND_HUE,
+ FZ_BLEND_SATURATION,
+ FZ_BLEND_COLOR,
+ FZ_BLEND_LUMINOSITY,
+};
+
+static const char *fz_blendmode_names[] =
{
"Normal",
"Multiply",
@@ -22,9 +45,24 @@ const char *fz_blendmode_names[] =
"Saturation",
"Color",
"Luminosity",
- NULL
};
+int fz_find_blendmode(char *name)
+{
+ int i;
+ for (i = 0; i < nelem(fz_blendmode_names); i++)
+ if (!strcmp(name, fz_blendmode_names[i]))
+ return i;
+ return FZ_BLEND_NORMAL;
+}
+
+char *fz_blendmode_name(int blendmode)
+{
+ if (blendmode >= 0 && blendmode < nelem(fz_blendmode_names))
+ return (char*)fz_blendmode_names[blendmode];
+ return "Normal";
+}
+
/* Separable blend modes */
static inline int fz_screen_byte(int b, int s)
@@ -218,7 +256,7 @@ fz_hue_rgb(int *rr, int *rg, int *rb, int br, int bg, int bb, int sr, int sg, in
/* Blending loops */
void
-fz_blend_separable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blendmode blendmode)
+fz_blend_separable(byte * restrict bp, byte * restrict sp, int n, int w, int blendmode)
{
int k;
int n1 = n - 1;
@@ -266,7 +304,7 @@ fz_blend_separable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blen
}
void
-fz_blend_nonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode blendmode)
+fz_blend_nonseparable(byte * restrict bp, byte * restrict sp, int w, int blendmode)
{
while (w--)
{
@@ -316,7 +354,7 @@ fz_blend_nonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmod
}
void
-fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode)
+fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode)
{
unsigned char *sp, *dp;
fz_bbox bbox;
diff --git a/draw/draw_device.c b/draw/draw_device.c
index 1e011b30..ab33dc35 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -22,7 +22,7 @@ struct fz_draw_device_s
fz_bbox scissor;
fz_pixmap *dest;
fz_pixmap *mask;
- fz_blendmode blendmode;
+ int blendmode;
int luminosity;
float alpha;
fz_matrix ctm;
@@ -848,7 +848,7 @@ fz_draw_end_mask(void *user)
}
static void
-fz_draw_begin_group(void *user, fz_rect rect, int isolated, int knockout, fz_blendmode blendmode, float alpha)
+fz_draw_begin_group(void *user, fz_rect rect, int isolated, int knockout, int blendmode, float alpha)
{
fz_draw_device *dev = user;
fz_colorspace *model = dev->dest->colorspace;
@@ -882,7 +882,7 @@ fz_draw_end_group(void *user)
{
fz_draw_device *dev = user;
fz_pixmap *group = dev->dest;
- fz_blendmode blendmode;
+ int blendmode;
float alpha;
if (dev->top > 0)
@@ -893,7 +893,7 @@ fz_draw_end_group(void *user)
dev->dest = dev->stack[dev->top].dest;
dev->scissor = dev->stack[dev->top].scissor;
- if (blendmode == FZ_BLEND_NORMAL)
+ if (blendmode == 0)
fz_paint_pixmap(dev->dest, group, alpha * 255);
else
fz_blend_pixmap(dev->dest, group, alpha * 255, blendmode);