summaryrefslogtreecommitdiff
path: root/source/fitz/paint-glyph.h
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-05-23 17:45:21 +0100
committerRobin Watts <robin.watts@artifex.com>2016-05-24 12:48:35 +0100
commitd0b78f4166a1503ce522944002b3aab035724cd9 (patch)
treeb8c680dc401db56a28be1110759219c7c175dd8d /source/fitz/paint-glyph.h
parent841952db71d6541a2e98fd4d1d49dede284b2cf8 (diff)
downloadmupdf-d0b78f4166a1503ce522944002b3aab035724cd9.tar.xz
fz_pixmap revamp: add stride and make alpha optional
fz_pixmaps now have an explicit stride value. By default no change from before, but code all copes with extra gaps at the end of the line. The alpha data in fz_pixmaps is no longer compulsory. mudraw: use rgb not rgba (ppmraw), cmyk not cmyka (pkmraw). Update halftone code to not expect alpha plane. Update PNG writing to cope with alpha less input. Also hide repeated params within the png output context. ARM code needs updating.
Diffstat (limited to 'source/fitz/paint-glyph.h')
-rw-r--r--source/fitz/paint-glyph.h97
1 files changed, 78 insertions, 19 deletions
diff --git a/source/fitz/paint-glyph.h b/source/fitz/paint-glyph.h
index 42b58b97..824adaf2 100644
--- a/source/fitz/paint-glyph.h
+++ b/source/fitz/paint-glyph.h
@@ -9,25 +9,38 @@
#define NAME solid
#endif
-#define FUNCTION_NAMER(NAME,N) fz_paint_glyph_##NAME##_##N
-#define FUNCTION_NAME(NAME,N) FUNCTION_NAMER(NAME,N)
+#ifdef DA
+#define NAME2 _da
+#else
+#define NAME2
+#endif
+
+#define FUNCTION_NAMER(NAME,N,NAME2) fz_paint_glyph_##NAME##_##N##NAME2
+#define FUNCTION_NAME(NAME,N,NAME2) FUNCTION_NAMER(NAME,N,NAME2)
static inline void
-FUNCTION_NAME(NAME,N)(const unsigned char * restrict colorbv,
+FUNCTION_NAME(NAME,N,NAME2)(const unsigned char * restrict colorbv,
#ifndef N
- int n,
+ const int n1,
#endif
int span, unsigned char * restrict dp, const fz_glyph * restrict glyph, int w, int h, int skip_x, int skip_y)
{
#ifdef N
- const int n = N;
+ const int n1 = N;
+#endif
+#ifdef DA
+ const int n = n1 + 1;
+#else
+ const int n = n1;
#endif
#ifdef ALPHA
- int sa = FZ_EXPAND(colorbv[n-1]);
+ int sa = FZ_EXPAND(colorbv[n1]);
#else
-#if defined(N) && N == 2
+#if defined(N) && N == 1 && defined(DA)
const uint16_t color = *(const uint16_t *)colorbv;
-#elif defined(N) && N == 4
+#elif defined(N) && N == 3 && defined(DA)
+ const uint32_t color = *(const uint32_t *)colorbv;
+#elif defined(N) && N == 4 && !defined(DA)
const uint32_t color = *(const uint32_t *)colorbv;
#endif
#endif
@@ -120,42 +133,68 @@ solid_run:
do
{
#ifdef ALPHA
-#if defined(N) && N == 2
+#if defined(N) && N == 1
ddp[0] = FZ_BLEND(colorbv[0], ddp[0], sa);
+#ifdef DA
ddp[1] = FZ_BLEND(0xFF, ddp[1], sa);
ddp += 2;
-#elif defined(N) && N == 4
+#else
+ ddp++;
+#endif
+#elif defined(N) && N == 3
ddp[0] = FZ_BLEND(colorbv[0], ddp[0], sa);
ddp[1] = FZ_BLEND(colorbv[1], ddp[1], sa);
ddp[2] = FZ_BLEND(colorbv[2], ddp[2], sa);
+#ifdef DA
ddp[3] = FZ_BLEND(0xFF, ddp[3], sa);
ddp += 4;
-#elif defined(N) && N == 5
+#else
+ ddp += 3;
+#endif
+#elif defined(N) && N == 4
ddp[0] = FZ_BLEND(colorbv[0], ddp[0], sa);
ddp[1] = FZ_BLEND(colorbv[1], ddp[1], sa);
ddp[2] = FZ_BLEND(colorbv[2], ddp[2], sa);
ddp[3] = FZ_BLEND(colorbv[3], ddp[3], sa);
+#ifdef DA
ddp[4] = FZ_BLEND(0xFF, ddp[4], sa);
ddp += 5;
#else
+ ddp += 4;
+#endif
+#else
int k = 0;
do
{
*ddp = FZ_BLEND(colorbv[k++], *ddp, sa);
ddp++;
}
- while (k != n-1);
+ while (k != n);
+#ifdef DA
*ddp = FZ_BLEND(0xFF, *ddp, sa);
ddp++;
#endif
+#endif
#else
-#if defined(N) && N == 2
+#if defined(N) && N == 1
+#ifdef DA
*(uint16_t *)ddp = color;
ddp += 2;
-#elif defined(N) && N == 4
+#else
+ *ddp++ = colorbv[0];
+#endif
+#elif defined(N) && N == 3
+#ifdef DA
*(uint32_t *)ddp = color;
ddp += 4;
-#elif defined(N) && N == 5
+#else
+ ddp[0] = colorbv[0];
+ ddp[1] = colorbv[1];
+ ddp[2] = colorbv[2];
+ ddp += 3;
+#endif
+#elif defined(N) && N == 4
+#ifdef DA
ddp[0] = colorbv[0];
ddp[1] = colorbv[1];
ddp[2] = colorbv[2];
@@ -163,6 +202,10 @@ solid_run:
ddp[4] = colorbv[4];
ddp += 5;
#else
+ *(uint32_t *)ddp = color;
+ ddp += 4;
+#endif
+#else
int k = 0;
do
{
@@ -192,33 +235,47 @@ intermediate_run:
a = FZ_EXPAND(a);
#endif
(void)k;
-#if defined(N) && N == 2
+#if defined(N) && N == 1
ddp[0] = FZ_BLEND(colorbv[0], ddp[0], a);
+#ifdef DA
ddp[1] = FZ_BLEND(0xFF, ddp[1], a);
ddp += 2;
-#elif defined(N) && N == 4
+#else
+ ddp++;
+#endif
+#elif defined(N) && N == 3
ddp[0] = FZ_BLEND(colorbv[0], ddp[0], a);
ddp[1] = FZ_BLEND(colorbv[1], ddp[1], a);
ddp[2] = FZ_BLEND(colorbv[2], ddp[2], a);
+#ifdef DA
ddp[3] = FZ_BLEND(0xFF, ddp[3], a);
ddp += 4;
-#elif defined(N) && N == 5
+#else
+ ddp += 3;
+#endif
+#elif defined(N) && N == 4
ddp[0] = FZ_BLEND(colorbv[0], ddp[0], a);
ddp[1] = FZ_BLEND(colorbv[1], ddp[1], a);
ddp[2] = FZ_BLEND(colorbv[2], ddp[2], a);
ddp[3] = FZ_BLEND(colorbv[3], ddp[3], a);
+#ifdef DA
ddp[4] = FZ_BLEND(0xFF, ddp[4], a);
ddp += 5;
#else
+ ddp += 4;
+#endif
+#else
do
{
*ddp = FZ_BLEND(colorbv[k++], *ddp, a);
ddp++;
}
- while (k != n-1);
+ while (k != n1);
+#ifdef DA
*ddp = FZ_BLEND(0xFF, *ddp, a);
ddp++;
#endif
+#endif
}
while (--len);
break;
@@ -233,6 +290,8 @@ intermediate_run:
#undef NAME
#undef ALPHA
+#undef NAME2
+#undef DA
#undef N
#undef FUNCTION_NAMER
#undef FUNCTION_NAME