summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-01 03:50:43 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-01 03:50:43 +0200
commit5a18d4874159ba759863a3dc29ef11fcd23924f9 (patch)
tree1783453f00a246e3d101f0148480a96ceee7016e
parent7c6ae0b110d0a29558305878482023ad7e8a66dc (diff)
downloadmupdf-5a18d4874159ba759863a3dc29ef11fcd23924f9.tar.xz
xps: Use opacity masks, and draw gradients with opacity.
-rw-r--r--draw/meshdraw.c3
-rw-r--r--fitz/fitz.h2
-rw-r--r--mupdf/pdf_shade.c2
-rw-r--r--xps/muxps.h10
-rw-r--r--xps/xpscolor.c18
-rw-r--r--xps/xpsopacity.c20
-rw-r--r--xps/xpszip.c5
7 files changed, 13 insertions, 47 deletions
diff --git a/draw/meshdraw.c b/draw/meshdraw.c
index 80b80378..71c0bdb7 100644
--- a/draw/meshdraw.c
+++ b/draw/meshdraw.c
@@ -540,6 +540,7 @@ fz_paintshade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox)
fz_convertcolor(shade->cs, shade->function[i], dest->colorspace, color);
for (k = 0; k < dest->colorspace->n; k++)
clut[i][k] = color[k] * 255;
+ clut[i][k] = shade->function[i][shade->cs->n] * 255;
}
conv = fz_newpixmapwithrect(dest->colorspace, bbox);
temp = fz_newpixmapwithrect(fz_devicegray, bbox);
@@ -565,7 +566,7 @@ fz_paintshade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox)
while (len--)
{
int v = *s++;
- int a = *s++;
+ int a = fz_mul255(*s++, clut[v][conv->n - 1]);
for (k = 0; k < conv->n - 1; k++)
*d++ = fz_mul255(clut[v][k], a);
*d++ = a;
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 5cff40b8..f8bef4c3 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -900,7 +900,7 @@ struct fz_shade_s
float background[FZ_MAXCOLORS];
int usefunction;
- float function[256][FZ_MAXCOLORS];
+ float function[256][FZ_MAXCOLORS + 1];
int type; /* linear, radial, mesh */
int extend[2];
diff --git a/mupdf/pdf_shade.c b/mupdf/pdf_shade.c
index 1242c6c8..9c4d8d09 100644
--- a/mupdf/pdf_shade.c
+++ b/mupdf/pdf_shade.c
@@ -332,6 +332,7 @@ pdf_samplecompositeshadefunction(fz_shade *shade, pdf_function *func, float t0,
{
t = t0 + (i / 255.0f) * (t1 - t0);
pdf_evalfunction(func, &t, 1, shade->function[i], shade->cs->n);
+ shade->function[i][shade->cs->n] = 1;
}
}
@@ -346,6 +347,7 @@ pdf_samplecomponentshadefunction(fz_shade *shade, int funcs, pdf_function **func
t = t0 + (i / 255.0f) * (t1 - t0);
for (k = 0; k < funcs; k++)
pdf_evalfunction(func[k], &t, 1, &shade->function[i][k], 1);
+ shade->function[i][k] = 1;
}
}
diff --git a/xps/muxps.h b/xps/muxps.h
index 1b137a59..8150996f 100644
--- a/xps/muxps.h
+++ b/xps/muxps.h
@@ -250,16 +250,6 @@ struct xps_context_s
xps_hash_table *font_table;
xps_hash_table *colorspace_table;
- /* Global toggle for transparency */
- int use_transparency;
-
- /* Hack to workaround ghostscript's lack of understanding
- * the pdf 1.4 specification of Alpha only transparency groups.
- * We have to force all colors to be grayscale whenever we are computing
- * opacity masks.
- */
- int opacity_only;
-
/* The fill_rule is set by path parsing.
* It is used by clip/fill functions.
* 1=nonzero, 0=evenodd
diff --git a/xps/xpscolor.c b/xps/xpscolor.c
index b0678603..1858c687 100644
--- a/xps/xpscolor.c
+++ b/xps/xpscolor.c
@@ -7,20 +7,10 @@ void
xps_set_color(xps_context *ctx, fz_colorspace *colorspace, float *samples)
{
int i;
-
- if (ctx->opacity_only)
- {
- ctx->colorspace = fz_devicegray;
- ctx->color[0] = samples[0];
- ctx->alpha = 1.0;
- }
- else
- {
- ctx->colorspace = colorspace;
- for (i = 0; i < colorspace->n; i++)
- ctx->color[i] = samples[i + 1];
- ctx->alpha = samples[0];
- }
+ ctx->colorspace = colorspace;
+ for (i = 0; i < colorspace->n; i++)
+ ctx->color[i] = samples[i + 1];
+ ctx->alpha = samples[0];
}
static int unhex(int chr)
diff --git a/xps/xpsopacity.c b/xps/xpsopacity.c
index 6bd640b3..047e213d 100644
--- a/xps/xpsopacity.c
+++ b/xps/xpsopacity.c
@@ -28,9 +28,6 @@ xps_begin_opacity(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource
{
fz_rect bbox;
float opacity;
- int save;
-
-return;
if (!opacity_att && !opacity_mask_tag)
return;
@@ -38,23 +35,13 @@ return;
opacity = 1.0;
if (opacity_att)
opacity = atof(opacity_att);
-// gs_setopacityalpha(ctx->pgs, opacity);
xps_bounds_in_user_space(ctx, &bbox);
+ ctx->dev->beginmask(ctx->dev->user, bbox, 0, fz_devicegray, &opacity);
if (opacity_mask_tag)
- {
- /* opacity-only mode: use alpha value as gray color to create luminosity mask */
- save = ctx->opacity_only;
- ctx->opacity_only = 1;
-
- // begin mask
xps_parse_brush(ctx, ctm, base_uri, dict, opacity_mask_tag);
-
- ctx->opacity_only = save;
- }
-
- // begin group
+ ctx->dev->endmask(ctx->dev->user);
}
void
@@ -63,5 +50,6 @@ xps_end_opacity(xps_context *ctx, char *base_uri, xps_resource *dict,
{
if (!opacity_att && !opacity_mask_tag)
return;
- // end mask+group
+
+ ctx->dev->popclip(ctx->dev->user);
}
diff --git a/xps/xpszip.c b/xps/xpszip.c
index 5528f0f7..069c83ea 100644
--- a/xps/xpszip.c
+++ b/xps/xpszip.c
@@ -498,11 +498,6 @@ xps_new_context(void)
ctx->start_part = NULL;
- ctx->use_transparency = 1;
- if (getenv("XPS_DISABLE_TRANSPARENCY"))
- ctx->use_transparency = 0;
-
- ctx->opacity_only = 0;
ctx->fill_rule = 0;
return ctx;