r59676 - in /trunk/libimager-perl: Changes CountColor/CountColor.xs DynTest/DynTest.xs Flines/Flines.xs ICO/ICO.xs Imager.pm Imager.xs META.yml Mandelbrot/Mandelbrot.xs SGI/SGI.xs debian/changelog fills.c imager.h polygon.c t/t20fill.t t/t75polyaa.t
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Mon Jun 21 20:16:46 UTC 2010
Author: gregoa
Date: Mon Jun 21 20:16:37 2010
New Revision: 59676
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=59676
Log:
New upstream release.
Modified:
trunk/libimager-perl/Changes
trunk/libimager-perl/CountColor/CountColor.xs
trunk/libimager-perl/DynTest/DynTest.xs
trunk/libimager-perl/Flines/Flines.xs
trunk/libimager-perl/ICO/ICO.xs
trunk/libimager-perl/Imager.pm
trunk/libimager-perl/Imager.xs
trunk/libimager-perl/META.yml
trunk/libimager-perl/Mandelbrot/Mandelbrot.xs
trunk/libimager-perl/SGI/SGI.xs
trunk/libimager-perl/debian/changelog
trunk/libimager-perl/fills.c
trunk/libimager-perl/imager.h
trunk/libimager-perl/polygon.c
trunk/libimager-perl/t/t20fill.t
trunk/libimager-perl/t/t75polyaa.t
Modified: trunk/libimager-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/Changes?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/Changes (original)
+++ trunk/libimager-perl/Changes Mon Jun 21 20:16:37 2010
@@ -1,4 +1,18 @@
Imager release history. Older releases can be found in Changes.old
+
+Imager 0.75
+===========
+
+ - use PERL_NO_GET_CONTEXT to slightly improve performance on threaded
+ perls (not measured)
+
+Bugs:
+
+ - an opacity fill based on a fountain fill would segfault when
+ filling an 8-bit/sample image.
+
+ - merge thickline branch polygon fix
+ https://rt.cpan.org/Ticket/Display.html?id=43518
Imager 0.74 - 7 May 2010
===========
Modified: trunk/libimager-perl/CountColor/CountColor.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/CountColor/CountColor.xs?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/CountColor/CountColor.xs (original)
+++ trunk/libimager-perl/CountColor/CountColor.xs Mon Jun 21 20:16:37 2010
@@ -1,3 +1,4 @@
+#define PERL_NO_GET_CONTEXT
#ifdef __cplusplus
extern "C" {
#endif
Modified: trunk/libimager-perl/DynTest/DynTest.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/DynTest/DynTest.xs?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/DynTest/DynTest.xs (original)
+++ trunk/libimager-perl/DynTest/DynTest.xs Mon Jun 21 20:16:37 2010
@@ -1,3 +1,4 @@
+#define PERL_NO_GET_CONTEXT
#ifdef __cplusplus
extern "C" {
#endif
Modified: trunk/libimager-perl/Flines/Flines.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/Flines/Flines.xs?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/Flines/Flines.xs (original)
+++ trunk/libimager-perl/Flines/Flines.xs Mon Jun 21 20:16:37 2010
@@ -1,3 +1,4 @@
+#define PERL_NO_GET_CONTEXT
#ifdef __cplusplus
extern "C" {
#endif
Modified: trunk/libimager-perl/ICO/ICO.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/ICO/ICO.xs?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/ICO/ICO.xs (original)
+++ trunk/libimager-perl/ICO/ICO.xs Mon Jun 21 20:16:37 2010
@@ -1,3 +1,4 @@
+#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
Modified: trunk/libimager-perl/Imager.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/Imager.pm?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/Imager.pm (original)
+++ trunk/libimager-perl/Imager.pm Mon Jun 21 20:16:37 2010
@@ -173,7 +173,7 @@
BEGIN {
require Exporter;
@ISA = qw(Exporter);
- $VERSION = '0.74';
+ $VERSION = '0.75';
eval {
require XSLoader;
XSLoader::load(Imager => $VERSION);
Modified: trunk/libimager-perl/Imager.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/Imager.xs?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/Imager.xs (original)
+++ trunk/libimager-perl/Imager.xs Mon Jun 21 20:16:37 2010
@@ -1,3 +1,4 @@
+#define PERL_NO_GET_CONTEXT
#ifdef __cplusplus
extern "C" {
#endif
@@ -27,6 +28,7 @@
/* These functions are all shared - then comes platform dependant code */
static int getstr(void *hv_t,char *key,char **store) {
+ dTHX;
SV** svpp;
HV* hv=(HV*)hv_t;
@@ -41,6 +43,7 @@
}
static int getint(void *hv_t,char *key,int *store) {
+ dTHX;
SV** svpp;
HV* hv=(HV*)hv_t;
@@ -54,6 +57,7 @@
}
static int getdouble(void *hv_t,char* key,double *store) {
+ dTHX;
SV** svpp;
HV* hv=(HV*)hv_t;
@@ -66,6 +70,7 @@
}
static int getvoid(void *hv_t,char* key,void **store) {
+ dTHX;
SV** svpp;
HV* hv=(HV*)hv_t;
@@ -80,6 +85,7 @@
}
static int getobj(void *hv_t,char *key,char *type,void **store) {
+ dTHX;
SV** svpp;
HV* hv=(HV*)hv_t;
@@ -103,6 +109,7 @@
UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj};
void my_SvREFCNT_dec(void *p) {
+ dTHX;
SvREFCNT_dec((SV*)p);
}
@@ -121,6 +128,7 @@
/* used by functions that want callbacks */
static int read_callback(char *userdata, char *buffer, int need, int want) {
+ dTHX;
i_reader_data *rd = (i_reader_data *)userdata;
int count;
int result;
@@ -172,6 +180,7 @@
/* used by functions that want callbacks */
static int write_callback(char *userdata, char const *data, int size) {
+ dTHX;
i_writer_data *wd = (i_writer_data *)userdata;
int count;
int success;
@@ -243,6 +252,7 @@
*/
static ssize_t call_writer(struct cbdata *cbd, void const *buf, size_t size) {
+ dTHX;
int count;
int success;
SV *sv;
@@ -277,6 +287,7 @@
static ssize_t call_reader(struct cbdata *cbd, void *buf, size_t size,
size_t maxread) {
+ dTHX;
int count;
int result;
SV *data;
@@ -323,6 +334,7 @@
}
static ssize_t write_flush(struct cbdata *cbd) {
+ dTHX;
ssize_t result;
if (cbd->used) {
@@ -336,6 +348,7 @@
}
static off_t io_seeker(void *p, off_t offset, int whence) {
+ dTHX;
struct cbdata *cbd = p;
int count;
off_t result;
@@ -380,6 +393,7 @@
}
static ssize_t io_writer(void *p, void const *data, size_t size) {
+ dTHX;
struct cbdata *cbd = p;
/* printf("io_writer(%p, %p, %u)\n", p, data, size); */
@@ -413,6 +427,7 @@
static ssize_t
io_reader(void *p, void *data, size_t size) {
+ dTHX;
struct cbdata *cbd = p;
ssize_t total;
char *out = data; /* so we can do pointer arithmetic */
@@ -471,6 +486,7 @@
}
static int io_closer(void *p) {
+ dTHX;
struct cbdata *cbd = p;
if (cbd->writing && cbd->used > 0) {
@@ -499,6 +515,7 @@
}
static void io_destroyer(void *p) {
+ dTHX;
struct cbdata *cbd = p;
SvREFCNT_dec(cbd->writecb);
@@ -573,7 +590,7 @@
};
/* look through the hash for quantization options */
-static void handle_quant_opts(i_quantize *quant, HV *hv)
+static void handle_quant_opts(pTHX_ i_quantize *quant, HV *hv)
{
/*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
SV **sv;
@@ -711,7 +728,7 @@
}
/* copies the color map from the hv into the colors member of the HV */
-static void copy_colors_back(HV *hv, i_quantize *quant) {
+static void copy_colors_back(pTHX_ HV *hv, i_quantize *quant) {
SV **sv;
AV *av;
int i;
@@ -738,7 +755,7 @@
/* loads the segments of a fountain fill into an array */
static i_fountain_seg *
-load_fount_segs(AV *asegs, int *count) {
+load_fount_segs(pTHX_ AV *asegs, int *count) {
/* Each element of segs must contain:
[ start, middle, end, c0, c1, segtype, colortrans ]
start, middle, end are doubles from 0 to 1
@@ -884,6 +901,7 @@
static SV *
i_int_hlines_dump(i_int_hlines *hlines) {
+ dTHX;
SV *dump = newSVpvf("start_y: %d limit_y: %d start_x: %d limit_x: %d\n",
hlines->start_y, hlines->limit_y, hlines->start_x, hlines->limit_x);
int y;
@@ -1540,7 +1558,7 @@
myfree(y);
-void
+int
i_poly_aa(im,xc,yc,val)
Imager::ImgRaw im
Imager::Color val
@@ -1552,7 +1570,7 @@
SV *sv1;
SV *sv2;
int i;
- PPCODE:
+ CODE:
ICL_info(val);
if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
@@ -1570,11 +1588,13 @@
x[i]=(double)SvNV(sv1);
y[i]=(double)SvNV(sv2);
}
- i_poly_aa(im,len,x,y,val);
+ RETVAL = i_poly_aa(im,len,x,y,val);
myfree(x);
myfree(y);
-
-void
+ OUTPUT:
+ RETVAL
+
+int
i_poly_aa_cfill(im,xc,yc,fill)
Imager::ImgRaw im
Imager::FillHandle fill
@@ -1586,7 +1606,7 @@
SV *sv1;
SV *sv2;
int i;
- PPCODE:
+ CODE:
if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
@@ -1603,9 +1623,11 @@
x[i]=(double)SvNV(sv1);
y[i]=(double)SvNV(sv2);
}
- i_poly_aa_cfill(im,len,x,y,fill);
+ RETVAL = i_poly_aa_cfill(im,len,x,y,fill);
myfree(x);
myfree(y);
+ OUTPUT:
+ RETVAL
@@ -2566,7 +2588,7 @@
quant.mc_size = 256;
quant.transp = tr_threshold;
quant.tr_threshold = 127;
- handle_quant_opts(&quant, hv);
+ handle_quant_opts(aTHX_ &quant, hv);
img_count = items - 2;
RETVAL = 1;
if (img_count < 1) {
@@ -2594,7 +2616,7 @@
}
myfree(imgs);
if (RETVAL) {
- copy_colors_back(hv, &quant);
+ copy_colors_back(aTHX_ hv, &quant);
}
}
ST(0) = sv_newmortal();
@@ -2623,7 +2645,7 @@
quant.mc_size = 256;
quant.transp = tr_threshold;
quant.tr_threshold = 127;
- handle_quant_opts(&quant, hv);
+ handle_quant_opts(aTHX_ &quant, hv);
img_count = items - 3;
RETVAL = 1;
if (img_count < 1) {
@@ -2648,7 +2670,7 @@
}
myfree(imgs);
if (RETVAL) {
- copy_colors_back(hv, &quant);
+ copy_colors_back(aTHX_ hv, &quant);
}
}
ST(0) = sv_newmortal();
@@ -2675,7 +2697,7 @@
quant.mc_size = 256;
quant.transp = tr_threshold;
quant.tr_threshold = 127;
- handle_quant_opts(&quant, hv);
+ handle_quant_opts(aTHX_ &quant, hv);
img_count = items - 2;
RETVAL = 1;
if (img_count < 1) {
@@ -2699,7 +2721,7 @@
}
myfree(imgs);
if (RETVAL) {
- copy_colors_back(hv, &quant);
+ copy_colors_back(aTHX_ hv, &quant);
}
}
ST(0) = sv_newmortal();
@@ -3399,7 +3421,7 @@
croak("i_fountain: argument 11 must be an array ref");
asegs = (AV *)SvRV(ST(10));
- segs = load_fount_segs(asegs, &count);
+ segs = load_fount_segs(aTHX_ asegs, &count);
RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine,
super_sample, ssample_param, count, segs);
myfree(segs);
@@ -3426,7 +3448,7 @@
croak("i_fountain: argument 11 must be an array ref");
asegs = (AV *)SvRV(ST(9));
- segs = load_fount_segs(asegs, &count);
+ segs = load_fount_segs(aTHX_ asegs, &count);
RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine,
super_sample, ssample_param, count, segs);
myfree(segs);
@@ -3623,10 +3645,10 @@
hv = (HV *)SvRV(ST(1));
memset(&quant, 0, sizeof(quant));
quant.mc_size = 256;
- handle_quant_opts(&quant, hv);
+ handle_quant_opts(aTHX_ &quant, hv);
RETVAL = i_img_to_pal(src, &quant);
if (RETVAL) {
- copy_colors_back(hv, &quant);
+ copy_colors_back(aTHX_ hv, &quant);
}
cleanup_quant_opts(&quant);
OUTPUT:
Modified: trunk/libimager-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/META.yml?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/META.yml (original)
+++ trunk/libimager-perl/META.yml Mon Jun 21 20:16:37 2010
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Imager
-version: 0.74
+version: 0.75
abstract: Perl extension for Generating 24 bit Images
author:
- Tony Cook <tony at imager.perl.org>, Arnar M. Hrafnkelsson
Modified: trunk/libimager-perl/Mandelbrot/Mandelbrot.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/Mandelbrot/Mandelbrot.xs?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/Mandelbrot/Mandelbrot.xs (original)
+++ trunk/libimager-perl/Mandelbrot/Mandelbrot.xs Mon Jun 21 20:16:37 2010
@@ -1,3 +1,4 @@
+#define PERL_NO_GET_CONTEXT
#ifdef __cplusplus
extern "C" {
#endif
Modified: trunk/libimager-perl/SGI/SGI.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/SGI/SGI.xs?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/SGI/SGI.xs (original)
+++ trunk/libimager-perl/SGI/SGI.xs Mon Jun 21 20:16:37 2010
@@ -1,3 +1,4 @@
+#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
Modified: trunk/libimager-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/debian/changelog?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/debian/changelog (original)
+++ trunk/libimager-perl/debian/changelog Mon Jun 21 20:16:37 2010
@@ -1,3 +1,9 @@
+libimager-perl (0.75-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- gregor herrmann <gregoa at debian.org> Mon, 21 Jun 2010 22:15:56 +0200
+
libimager-perl (0.74-1) unstable; urgency=low
* New upstream release
Modified: trunk/libimager-perl/fills.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/fills.c?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/fills.c (original)
+++ trunk/libimager-perl/fills.c Mon Jun 21 20:16:37 2010
@@ -562,6 +562,11 @@
fill->other_fill = base_fill;
fill->alpha_mult = alpha_mult;
+
+ if (!base_fill->f_fill_with_color) {
+ /* base fill only does floating, so we only do that too */
+ fill->base.f_fill_with_color = NULL;
+ }
return &fill->base;
}
Modified: trunk/libimager-perl/imager.h
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/imager.h?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/imager.h (original)
+++ trunk/libimager-perl/imager.h Mon Jun 21 20:16:37 2010
@@ -198,8 +198,8 @@
extern i_img *i_matrix_transform_bg(i_img *im, int xsize, int ysize, const double *matrix, const i_color *backp, const i_fcolor *fbackp);
void i_bezier_multi(i_img *im,int l,const double *x,const double *y,const i_color *val);
-void i_poly_aa (i_img *im,int l,const double *x,const double *y,const i_color *val);
-void i_poly_aa_cfill(i_img *im,int l,const double *x,const double *y,i_fill_t *fill);
+int i_poly_aa (i_img *im,int l,const double *x,const double *y,const i_color *val);
+int i_poly_aa_cfill(i_img *im,int l,const double *x,const double *y,i_fill_t *fill);
undef_int i_flood_fill (i_img *im,int seedx,int seedy, const i_color *dcol);
undef_int i_flood_cfill(i_img *im, int seedx, int seedy, i_fill_t *fill);
Modified: trunk/libimager-perl/polygon.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/polygon.c?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/polygon.c (original)
+++ trunk/libimager-perl/polygon.c Mon Jun 21 20:16:37 2010
@@ -8,8 +8,12 @@
#define coarse(x) ((x)/16)
#define fine(x) ((x)%16)
+/*#define DEBUG_POLY*/
+#ifdef DEBUG_POLY
+#define POLY_DEB(x) x
+#else
#define POLY_DEB(x)
-
+#endif
typedef int pcord;
@@ -41,17 +45,7 @@
typedef struct {
int *line; /* temporary buffer for scanline */
int linelen; /* length of scanline */
- ss_pair *ss_list; /* list of start stop linepairs */
- int ssnext; /* index of the next pair to use */
- int sslen; /* maximum number of start stop pairs */
} ss_scanline;
-
-
-
-
-
-
-
static
int
@@ -126,7 +120,6 @@
static
void
ss_scanline_reset(ss_scanline *ss) {
- ss->ssnext = 0;
memset(ss->line, 0, sizeof(int) * ss->linelen);
}
@@ -135,8 +128,6 @@
ss_scanline_init(ss_scanline *ss, int linelen, int linepairs) {
ss->line = mymalloc( sizeof(int) * linelen );
ss->linelen = linelen;
- ss->ss_list = mymalloc( sizeof(ss_pair) * linepairs );
- ss->sslen = linepairs;
ss_scanline_reset(ss);
}
@@ -144,7 +135,6 @@
void
ss_scanline_exorcise(ss_scanline *ss) {
myfree(ss->line);
- myfree(ss->ss_list);
}
@@ -242,6 +232,7 @@
int x, ch, tv;
i_color t;
i_color *val = (i_color *)ctx;
+ POLY_DEB( printf("Flushing line %d\n", y) );
for(x=0; x<im->xsize; x++) {
tv = saturate(ss->line[x]);
i_gpix(im, x, y, &t);
@@ -273,6 +264,12 @@
pixel_coverage(p_line *line, pcord minx, pcord maxx, pcord miny, pcord maxy) {
double lycross, rycross;
int l, r;
+
+ POLY_DEB
+ (
+ printf(" pixel_coverage(..., minx %g, maxx%g, miny %g, maxy %g)\n",
+ minx/16.0, maxx/16.0, miny/16.0, maxy/16.0)
+ );
if (!line->updown) {
l = r = 0;
@@ -283,9 +280,9 @@
r = rycross <= maxy && rycross >= miny; /* true if it enters through left side */
}
POLY_DEB(
- printf("%4s(%+d): ", line->updown ? line->updown == 1 ? "up" : "down" : "vert", line->updown);
- printf("(%2d,%2d) [%3d-%3d, %3d-%3d] lycross=%.2f rycross=%.2f", coarse(minx), coarse(miny), minx, maxx, miny, maxy, lycross, rycross);
- printf(" l=%d r=%d\n", l, r)
+ printf(" %4s(%+d): ", line->updown ? line->updown == 1 ? "up" : "down" : "vert", line->updown);
+ printf(" (%2d,%2d) [%3d-%3d, %3d-%3d] lycross=%.2f rycross=%.2f", coarse(minx), coarse(miny), minx, maxx, miny, maxy, lycross, rycross);
+ printf(" l=%d r=%d\n", l, r)
);
if (l && r)
@@ -327,9 +324,8 @@
static
void
-render_slice_scanline(ss_scanline *ss, int y, p_line *l, p_line *r) {
-
- pcord miny, maxy; /* y bounds in fine coordinates */
+render_slice_scanline(ss_scanline *ss, int y, p_line *l, p_line *r, pcord miny, pcord maxy) {
+
pcord lminx, lmaxx; /* left line min/max within y bounds in fine coords */
pcord rminx, rmaxx; /* right line min/max within y bounds in fine coords */
int cpix; /* x-coordinate of current pixel */
@@ -339,12 +335,19 @@
/* Find the y bounds of scanline_slice */
- maxy = i_min( l->maxy, r->maxy );
- miny = i_max( l->miny, r->miny );
-
- maxy = i_min( maxy, (y+1)*16 );
- miny = i_max( miny, y*16 );
-
+ POLY_DEB
+ (
+ printf("render_slice_scanline(..., y=%d)\n");
+ printf(" left n=%d p1(%.2g, %.2g) p2(%.2g,%.2g) min(%.2g, %.2g) max(%.2g,%.2g) updown(%d)\n",
+ l->n, l->x1/16.0, l->y1/16.0, l->x2/16.0, l->y2/16.0,
+ l->minx/16.0, l->miny/16.0, l->maxx/16.0, l->maxy/16.0,
+ l->updown);
+ printf(" right n=%d p1(%.2g, %.2g) p2(%.2g,%.2g) min(%.2g, %.2g) max(%.2g,%.2g) updown(%d)\n",
+ r->n, r->x1/16.0, r->y1/16.0, r->x2/16.0, r->y2/16.0,
+ r->minx/16.0, r->miny/16.0, r->maxx/16.0, r->maxy/16.0,
+ r->updown);
+ );
+
lminx = i_min( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
lmaxx = i_max( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
@@ -355,6 +358,8 @@
startpix = i_max( coarse(lminx), 0 );
stoppix = i_min( coarse(rmaxx-1), ss->linelen-1 );
+
+ POLY_DEB( printf(" miny=%g maxy=%g\n", miny/16.0, maxy/16.0) );
for(cpix=startpix; cpix<=stoppix; cpix++) {
int lt = coarse(lmaxx-1) >= cpix;
@@ -362,18 +367,18 @@
int A, B, C;
- POLY_DEB( printf("(%d,%d) lt=%d rt=%d\n", cpix, y, lt, rt) );
+ POLY_DEB( printf(" (%d,%d) lt=%d rt=%d\n", cpix, y, lt, rt) );
A = lt ? pixel_coverage(l, cpix*16, cpix*16+16, miny, maxy) : 0;
B = lt ? 0 : 16*(maxy-miny);
C = rt ? pixel_coverage(r, cpix*16, cpix*16+16, miny, maxy) : 0;
- POLY_DEB( printf("A=%d B=%d C=%d\n", A, B, C) );
+ POLY_DEB( printf(" A=%d B=%d C=%d\n", A, B, C) );
ss->line[cpix] += A+B-C;
}
-
+ POLY_DEB( printf("end render_slice_scanline()\n") );
}
/* Antialiasing polygon algorithm
@@ -454,42 +459,62 @@
for(i=0; i<l-1; i++) {
int startscan = i_max( coarse(pset[i].y), 0);
int stopscan = i_min( coarse(pset[i+1].y+15), im->ysize);
-
- if (pset[i].y == pset[i+1].y) {
- POLY_DEB( printf("current slice thickness = 0 => skipping\n") );
- continue;
- }
+ pcord miny, maxy; /* y bounds in fine coordinates */
+
+ POLY_DEB( pcord cc = (pset[i].y + pset[i+1].y)/2 );
POLY_DEB(
printf("current slice is %d: %d to %d ( cpoint %d ) scanlines %d to %d\n",
i, pset[i].y, pset[i+1].y, cc, startscan, stopscan)
);
-
+ if (pset[i].y == pset[i+1].y) {
+ POLY_DEB( printf("current slice thickness = 0 => skipping\n") );
+ continue;
+ }
+
clc = lines_in_interval(lset, l, tllist, pset[i].y, pset[i+1].y);
qsort(tllist, clc, sizeof(p_slice), (int(*)(const void *,const void *))p_compx);
mark_updown_slices(lset, tllist, clc);
- POLY_DEB( printf("Interval contains %d lines\n", clc) );
-
- for(k=0; k<clc; k++) {
- POLY_DEB(
- printf("%d: line #%2d: (%2d, %2d)->(%2d, %2d) (%2d/%2d, %2d/%2d) -> (%2d/%2d, %2d/%2d) alignment=%s\n",
- k, lno, ln->x1, ln->y1, ln->x2, ln->y2,
- coarse(ln->x1), fine(ln->x1),
- coarse(ln->y1), fine(ln->y1),
- coarse(ln->x2), fine(ln->x2),
- coarse(ln->y2), fine(ln->y2),
- ln->updown == 0 ? "vert" : ln->updown == 1 ? "up" : "down")
- );
- }
+ POLY_DEB
+ (
+ printf("Interval contains %d lines\n", clc);
+ for(k=0; k<clc; k++) {
+ int lno = tllist[k].n;
+ p_line *ln = lset+lno;
+ printf("%d: line #%2d: (%2d, %2d)->(%2d, %2d) (%2d/%2d, %2d/%2d) -> (%2d/%2d, %2d/%2d) alignment=%s\n",
+ k, lno, ln->x1, ln->y1, ln->x2, ln->y2,
+ coarse(ln->x1), fine(ln->x1),
+ coarse(ln->y1), fine(ln->y1),
+ coarse(ln->x2), fine(ln->x2),
+ coarse(ln->y2), fine(ln->y2),
+ ln->updown == 0 ? "vert" : ln->updown == 1 ? "up" : "down");
+
+ }
+ );
+ maxy = im->ysize * 16;
+ miny = 0;
+ for (k = 0; k < clc; ++k) {
+ p_line const * line = lset + tllist[k].n;
+ if (line->miny > miny)
+ miny = line->miny;
+ if (line->maxy < maxy)
+ maxy = line->maxy;
+ POLY_DEB( printf(" line miny %g maxy %g\n", line->miny/16.0, line->maxy/16.0) );
+ }
+ POLY_DEB( printf("miny %g maxy %g\n", miny/16.0, maxy/16.0) );
+
for(cscl=startscan; cscl<stopscan; cscl++) {
+ pcord scan_miny = i_max(miny, cscl * 16);
+ pcord scan_maxy = i_min(maxy, (cscl + 1 ) * 16);
+
tempy = i_min(cscl*16+16, pset[i+1].y);
POLY_DEB( printf("evaluating scan line %d \n", cscl) );
for(k=0; k<clc-1; k+=2) {
POLY_DEB( printf("evaluating slice %d\n", k) );
- render_slice_scanline(&templine, cscl, lset+tllist[k].n, lset+tllist[k+1].n);
+ render_slice_scanline(&templine, cscl, lset+tllist[k].n, lset+tllist[k+1].n, scan_miny, scan_maxy);
}
if (16*coarse(tempy) == tempy) {
POLY_DEB( printf("flushing scan line %d\n", cscl) );
@@ -515,10 +540,11 @@
} /* Function */
-void
+int
i_poly_aa(i_img *im, int l, const double *x, const double *y, const i_color *val) {
i_color c = *val;
i_poly_aa_low(im, l, x, y, &c, scanline_flush);
+ return 1;
}
struct poly_render_state {
@@ -552,7 +578,7 @@
}
}
-void
+int
i_poly_aa_cfill(i_img *im, int l, const double *x, const double *y,
i_fill_t *fill) {
struct poly_render_state ctx;
@@ -563,4 +589,5 @@
i_poly_aa_low(im, l, x, y, &ctx, scanline_flush_render);
myfree(ctx.cover);
i_render_done(&ctx.render);
-}
+ return 1;
+}
Modified: trunk/libimager-perl/t/t20fill.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/t/t20fill.t?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/t/t20fill.t (original)
+++ trunk/libimager-perl/t/t20fill.t Mon Jun 21 20:16:37 2010
@@ -1,6 +1,6 @@
#!perl -w
use strict;
-use Test::More tests => 153;
+use Test::More tests => 156;
use Imager ':handy';
use Imager::Fill;
@@ -608,6 +608,32 @@
is_color3($im->getpixel(x => 0, y => 0), 255, 255, 255,
"check for correct colour");
}
+
+ {
+ require Imager::Fountain;
+ my $fount = Imager::Fountain->new;
+ $fount->add(c1 => "FFFFFF"); # simple white to black
+ # base fill is a fountain
+ my $base_fill = Imager::Fill->new
+ (
+ fountain => "linear",
+ segments => $fount,
+ xa => 0,
+ ya => 0,
+ xb => 100,
+ yb => 100,
+ );
+ ok($base_fill, "made fountain fill base");
+ my $op_fill = Imager::Fill->new
+ (
+ type => "opacity",
+ other => $base_fill,
+ opacity => 0.5,
+ );
+ ok($op_fill, "made opacity fountain fill");
+ my $im = Imager->new(xsize => 100, ysize => 100);
+ ok($im->box(fill => $op_fill), "draw with it");
+ }
}
sub color_close {
Modified: trunk/libimager-perl/t/t75polyaa.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libimager-perl/t/t75polyaa.t?rev=59676&op=diff
==============================================================================
--- trunk/libimager-perl/t/t75polyaa.t (original)
+++ trunk/libimager-perl/t/t75polyaa.t Mon Jun 21 20:16:37 2010
@@ -1,134 +1,191 @@
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl test.pl'
-
-######################### We start with some black magic to print on failure.
-
-# Change 1..1 below to 1..last_test_to_print .
-# (It may become useful if the test is moved to ./t subdirectory.)
-
-BEGIN { $| = 1; print "1..9\n"; }
-END {print "not ok 1\n" unless $loaded;}
-use Imager qw(:all);
+#!perl -w
+
+use strict;
+use Test::More tests => 18;
+
+use Imager qw/NC/;
+use Imager::Test qw(is_image is_color3);
sub PI () { 3.14159265358979323846 }
-$loaded = 1;
-print "ok 1\n";
-
-init_log("testout/t75aapolyaa.log",1);
-
-$red = Imager::Color->new(255,0,0);
-$green = Imager::Color->new(0,255,0);
-$blue = Imager::Color->new(0,0,255);
-$white = Imager::Color->new(255,255,255);
-
-
-$img = Imager->new(xsize=>20, ysize=>10);
- at data = translate(5.5,5,
- rotate(0,
- scale(5, 5,
- get_polygon(n_gon => 5)
- )
- )
- );
-
-
-my ($x, $y) = array_to_refpair(@data);
-i_poly_aa($img->{IMG}, $x, $y, $white);
-
-
-
-
-print "ok 2\n";
-
-$img->write(file=>"testout/t75.ppm") or die $img->errstr;
-print "ok 3\n";
-
-
-$zoom = make_zoom($img, 8, \@data, $red);
-$zoom->write(file=>"testout/t75zoom.ppm") or die $zoom->errstr;
-
-print "ok 4\n";
-
-$img = Imager->new(xsize=>300, ysize=>100);
-
-for $n (0..55) {
- @data = translate(20+20*($n%14),18+20*int($n/14),
- rotate(15*$n/PI,
- scale(15, 15,
- get_polygon('box')
- )
- )
- );
+Imager::init_log("testout/t75aapolyaa.log",1);
+
+my $red = Imager::Color->new(255,0,0);
+my $green = Imager::Color->new(0,255,0);
+my $blue = Imager::Color->new(0,0,255);
+my $white = Imager::Color->new(255,255,255);
+
+{ # artifacts with multiple vertical lobes
+ # https://rt.cpan.org/Ticket/Display.html?id=43518
+ # previously this would have a full coverage pixel at (0,0) caused
+ # by the (20,0.5) point in the right lobe
+
+ my @pts =
+ (
+ [ 0.5, -9 ],
+ [ 10, -9 ],
+ [ 10, 11 ],
+ [ 15, 11 ],
+ [ 15, -9 ],
+ [ 17, -9 ],
+ [ 20, 0.5 ],
+ [ 17, 11 ],
+ [ 0.5, 11 ],
+ );
+ my $im = Imager->new(xsize => 10, ysize => 2);
+ ok($im->polygon(points => \@pts,
+ color => $white),
+ "draw with inside point");
+ ok($im->write(file => "testout/t75inside.ppm"), "save to file");
+ # both scanlines should be the same
+ my $line0 = $im->crop(top => 0, height => 1);
+ my $line1 = $im->crop(top => 1, height => 1);
+ is_image($line0, $line1, "both scanlines should be the same");
+}
+
+{ # check vertical edges are consistent
+ my $im = Imager->new(xsize => 10, ysize => 10);
+ ok($im->polygon(points => [ [ 0.5, 0 ], [ 9.25, 0 ],
+ [ 9.25, 10 ], [ 0.5, 10 ] ],
+ color => $white,
+ aa => 1),
+ "draw polygon with mid pixel vertical edges")
+ or diag $im->errstr;
+ my @line0 = $im->getscanline(y => 0);
+ my $im2 = Imager->new(xsize => 10, ysize => 10);
+ for my $y (0..9) {
+ $im2->setscanline(y => $y, pixels => \@line0);
+ }
+ is_image($im, $im2, "all scan lines should be the same");
+ is_color3($line0[0], 128, 128, 128, "(0,0) should be 50% coverage");
+ is_color3($line0[9], 64, 64, 64, "(9,0) should be 25% coverage");
+}
+
+{ # check horizontal edges are consistent
+ my $im = Imager->new(xsize => 10, ysize => 10);
+ ok($im->polygon(points => [ [ 0, 0.5 ], [ 0, 9.25 ],
+ [ 10, 9.25 ], [ 10, 0.5 ] ],
+ color => $white,
+ aa => 1),
+ "draw polygon with mid-pixel horizontal edges");
+ is_deeply([ $im->getsamples(y => 0, channels => [ 0 ]) ],
+ [ (128) x 10 ],
+ "all of line 0 should be 50% coverage");
+ is_deeply([ $im->getsamples(y => 9, channels => [ 0 ]) ],
+ [ (64) x 10 ],
+ "all of line 9 should be 25% coverage");
+}
+
+{
+ my $img = Imager->new(xsize=>20, ysize=>10);
+ my @data = translate(5.5,5,
+ rotate(0,
+ scale(5, 5,
+ get_polygon(n_gon => 5)
+ )
+ )
+ );
+
+
my ($x, $y) = array_to_refpair(@data);
- i_poly_aa($img->{IMG}, $x, $y, NC(rand(255), rand(255), rand(255)));
-}
-
-$img->write(file=>"testout/t75big.ppm") or die $img->errstr;
-
-print "ok 5\n";
-
-$img = Imager->new(xsize => 300, ysize => 300);
-$img -> polygon(color=>$white,
- points => [
- translate(150,150,
- rotate(45*PI/180,
- scale(70,70,
- get_polygon('wavycircle', 32*8, sub { 1.2+1*cos(4*$_) }))))
- ],
- ) or die $img->errstr();
-
-$img->write(file=>"testout/t75wave.ppm") or die $img->errstr;
-
-print "ok 6\n";
-
-
-$img = Imager->new(xsize=>10,ysize=>6);
- at data = translate(165,5,
- scale(80,80,
- get_polygon('wavycircle', 32*8, sub { 1+1*cos(4*$_) })));
-
-print "XXX\n";
-$img -> polygon(color=>$white,
+ ok(Imager::i_poly_aa($img->{IMG}, $x, $y, $white), "primitive poly");
+
+ ok($img->write(file=>"testout/t75.ppm"), "write to file")
+ or diag $img->errstr;
+
+ my $zoom = make_zoom($img, 8, \@data, $red);
+ ok($zoom, "make zoom of primitive");
+ $zoom->write(file=>"testout/t75zoom.ppm") or die $zoom->errstr;
+}
+
+{
+ my $img = Imager->new(xsize=>300, ysize=>100);
+
+ my $good = 1;
+ for my $n (0..55) {
+ my @data = translate(20+20*($n%14),18+20*int($n/14),
+ rotate(15*$n/PI,
+ scale(15, 15,
+ get_polygon('box')
+ )
+ )
+ );
+ my ($x, $y) = array_to_refpair(@data);
+ Imager::i_poly_aa($img->{IMG}, $x, $y, NC(rand(255), rand(255), rand(255)))
+ or $good = 0;
+ }
+
+ $img->write(file=>"testout/t75big.ppm") or die $img->errstr;
+
+ ok($good, "primitive squares");
+}
+
+{
+ my $img = Imager->new(xsize => 300, ysize => 300);
+ ok($img -> polygon(color=>$white,
+ points => [
+ translate(150,150,
+ rotate(45*PI/180,
+ scale(70,70,
+ get_polygon('wavycircle', 32*8, sub { 1.2+1*cos(4*$_) }))))
+ ],
+ ), "method call")
+ or diag $img->errstr();
+
+ $img->write(file=>"testout/t75wave.ppm") or die $img->errstr;
+}
+
+{
+ my $img = Imager->new(xsize=>10,ysize=>6);
+ my @data = translate(165,5,
+ scale(80,80,
+ get_polygon('wavycircle', 32*8, sub { 1+1*cos(4*$_) })));
+
+ ok($img -> polygon(color=>$white,
points => [
translate(165,5,
scale(80,80,
get_polygon('wavycircle', 32*8, sub { 1+1*cos(4*$_) })))
],
- ) or die $img->errstr();
-
-make_zoom($img,20,\@data, $blue)->write(file=>"testout/t75wavebug.ppm") or die $img->errstr;
-
-
-print "ok 7\n";
-
-$img = Imager->new(xsize=>300, ysize=>300);
-$img->polygon(fill=>{ hatch=>'cross1', fg=>'00FF00', bg=>'0000FF', dx=>3 },
+ ), "bug check")
+ or diag $img->errstr();
+
+ make_zoom($img,20,\@data, $blue)->write(file=>"testout/t75wavebug.ppm") or die $img->errstr;
+
+}
+
+{
+ my $img = Imager->new(xsize=>300, ysize=>300);
+ ok($img->polygon(fill=>{ hatch=>'cross1', fg=>'00FF00', bg=>'0000FF', dx=>3 },
points => [
translate(150,150,
scale(70,70,
get_polygon('wavycircle', 32*8, sub { 1+1*cos(4*$_) })))
],
- ) or die $img->errstr();
-$img->write(file=>"testout/t75wave_fill.ppm") or die $img->errstr;
-
-print "ok 8\n";
-
-$img = Imager->new(xsize=>300, ysize=>300, bits=>16);
-$img->polygon(fill=>{ hatch=>'cross1', fg=>'00FF00', bg=>'0000FF' },
+ ), "poly filled with hatch")
+ or diag $img->errstr();
+ $img->write(file=>"testout/t75wave_fill.ppm") or die $img->errstr;
+}
+
+{
+ my $img = Imager->new(xsize=>300, ysize=>300, bits=>16);
+ ok($img->polygon(fill=>{ hatch=>'cross1', fg=>'00FF00', bg=>'0000FF' },
points => [
translate(150,150,
scale(70,70,
get_polygon('wavycircle', 32*8, sub { 1+1*cos(5*$_) })))
],
- ) or die $img->errstr();
-$img->write(file=>"testout/t75wave_fill16.ppm") or die $img->errstr;
-
-print "ok 9\n";
-
-malloc_state();
-
-
+ ), "hatched to 16-bit image")
+ or diag $img->errstr();
+ $img->write(file=>"testout/t75wave_fill16.ppm") or die $img->errstr;
+}
+
+Imager::malloc_state();
+
+
+#initialized in a BEGIN, later
+my %primitives;
+my %polygens;
sub get_polygon {
my $name = shift;
@@ -151,11 +208,11 @@
my $timg = $img->scale(scalefactor=>$sc, qtype=>'preview');
# draw the grid
- for($lx=0; $lx<$timg->getwidth(); $lx+=$sc) {
+ for(my $lx=0; $lx<$timg->getwidth(); $lx+=$sc) {
$timg->line(color=>$green, x1=>$lx, x2=>$lx, y1=>0, y2=>$timg->getheight(), antialias=>0);
}
- for($ly=0; $ly<$timg->getheight(); $ly+=$sc) {
+ for(my $ly=0; $ly<$timg->getheight(); $ly+=$sc) {
$timg->line(color=>$green, y1=>$ly, y2=>$ly, x1=>0, x2=>$timg->getwidth(), antialias=>0);
}
my @data = scale($sc, $sc, @$polydata);
More information about the Pkg-perl-cvs-commits
mailing list