diff options
author | Igor Melichev <igor.melichev@artifex.com> | 2001-04-05 08:32:28 +0000 |
---|---|---|
committer | Igor Melichev <igor.melichev@artifex.com> | 2001-04-05 08:32:28 +0000 |
commit | 298df2ad38370484645cb002fbc441de759b9f20 (patch) | |
tree | 5f9ed5ff37407e3cee901edc403d42b3cbb30c99 | |
parent | afb1436887ba661dc622a26ca99f9a510f175a6f (diff) | |
download | ghostpdl-298df2ad38370484645cb002fbc441de759b9f20.tar.gz |
Fix: Speed up shading type 1.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@1373 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r-- | gs/src/gsshade.c | 2 | ||||
-rw-r--r-- | gs/src/gxshade1.c | 43 | ||||
-rw-r--r-- | gs/src/lib.mak | 2 |
3 files changed, 30 insertions, 17 deletions
diff --git a/gs/src/gsshade.c b/gs/src/gsshade.c index 2b09f4800..349dc7357 100644 --- a/gs/src/gsshade.c +++ b/gs/src/gsshade.c @@ -500,6 +500,8 @@ gs_shading_fill_path(const gs_shading_t *psh, /*const*/ gx_path *ppath, goto out; gx_make_clip_device(&path_dev, &path_clip->rect_list->list); path_dev.target = dev; + path_dev.HWResolution[0] = dev->HWResolution[0]; + path_dev.HWResolution[1] = dev->HWResolution[1]; dev = (gx_device *)&path_dev; dev_proc(dev, open_device)(dev); dev_proc(dev, get_clipping_box)(dev, &path_box); diff --git a/gs/src/gxshade1.c b/gs/src/gxshade1.c index f96d95067..236c0199e 100644 --- a/gs/src/gxshade1.c +++ b/gs/src/gxshade1.c @@ -32,6 +32,7 @@ #include "gxistate.h" #include "gxpath.h" #include "gxshade.h" +#include "gxdevcli.h" /* ================ Utilities ================ */ @@ -117,12 +118,13 @@ typedef struct Fb_fill_state_s { #define CheckRET(a) { int code = a; if (code < 0) return code; } #define Exch(t,a,b) { t x; x = a; a = b; b = x; } -private void +private bool Fb_build_color_range(const Fb_fill_state_t * pfs, const Fb_frame_t * fp, gs_paint_color * c_min, gs_paint_color * c_max) { int ci; const gs_client_color *cc = fp->cc; + bool big = false; for (ci = 0; ci < pfs->num_components; ++ci) { float c0 = cc[0].paint.values[ci], c1 = cc[1].paint.values[ci], c2 = cc[2].paint.values[ci], c3 = cc[3].paint.values[ci]; @@ -137,7 +139,9 @@ Fb_build_color_range(const Fb_fill_state_t * pfs, const Fb_frame_t * fp, min23 = c3, max23 = c2; c_max->values[ci] = max(max01, max23); c_min->values[ci] = min(min01, min23); + big |= ((c_max->values[ci] - c_min->values[ci]) > pfs->cc_max_error[ci]); } + return !big; } private bool @@ -155,18 +159,6 @@ Fb_unite_color_range(const Fb_fill_state_t * pfs, } private int -Fb_device_region_size(const Fb_fill_state_t * pfs, const Fb_frame_t * fp, - fixed *size_x, fixed *size_y) -{ - gs_point p, q; - CheckRET(gs_distance_transform(fp->region.q.x - fp->region.p.x, 0, (gs_matrix *)&pfs->ptm, &p)); - CheckRET(gs_distance_transform(0, fp->region.q.y - fp->region.p.y, (gs_matrix *)&pfs->ptm, &q)); - *size_x = float2fixed(hypot(p.x , p.y)); - *size_y = float2fixed(hypot(q.x , q.y)); - return 0; -} - -private int Fb_build_half_region(Fb_fill_state_t * pfs, int h, bool use_old) { Fb_frame_t * fp0 = &pfs->frames[pfs->depth]; Fb_frame_t * fp1 = &pfs->frames[pfs->depth + 1]; @@ -263,15 +255,34 @@ Fb_fill_region_with_constant_color(const Fb_fill_state_t * pfs, const Fb_frame_t private int Fb_fill_region_lazy(Fb_fill_state_t * pfs) -{ fixed minsize = fixed_1 * 7 / 10; +{ fixed minsize = fixed_1 * 7 / 10; /* pixels */ + float min_extreme_dist = 4; /* points */ + fixed min_edist_x = float2fixed(min_extreme_dist * pfs->dev->HWResolution[0] / 72); + fixed min_edist_y = float2fixed(min_extreme_dist * pfs->dev->HWResolution[1] / 72); + min_edist_x = max(min_edist_x, minsize); + min_edist_y = max(min_edist_y, minsize); while (pfs->depth >= 0) { Fb_frame_t * fp = &pfs->frames[pfs->depth]; fixed size_x, size_y; + bool single_extreme, single_pixel, small_color_diff = false; switch (fp->state) { case 0: fp->painted = false; - CheckRET(Fb_device_region_size(pfs, fp, &size_x, &size_y)); - if (size_x < minsize && size_y < minsize || + { /* Region size in device space : */ + gs_point p, q; + CheckRET(gs_distance_transform(fp->region.q.x - fp->region.p.x, 0, (gs_matrix *)&pfs->ptm, &p)); + CheckRET(gs_distance_transform(0, fp->region.q.y - fp->region.p.y, (gs_matrix *)&pfs->ptm, &q)); + size_x = float2fixed(hypot(p.x, p.y)); + size_y = float2fixed(hypot(q.x, q.y)); + single_extreme = (float2fixed(any_abs(p.x) + any_abs(q.x)) < min_edist_x && + float2fixed(any_abs(p.y) + any_abs(q.y)) < min_edist_y); + single_pixel = (size_x < minsize && size_y < minsize); + /* Note: single_pixel implies single_extreme. */ + } + if (single_extreme || pfs->depth >= Fb_max_depth - 1) + small_color_diff = Fb_build_color_range(pfs, fp, &pfs->c_min, &pfs->c_max); + if (single_extreme && small_color_diff || + single_pixel || pfs->depth >= Fb_max_depth - 1) { Fb_build_color_range(pfs, fp, &pfs->c_min, &pfs->c_max); -- pfs->depth; diff --git a/gs/src/lib.mak b/gs/src/lib.mak index e314f1996..0a4d94cf9 100644 --- a/gs/src/lib.mak +++ b/gs/src/lib.mak @@ -2250,7 +2250,7 @@ $(GLOBJ)gxshade.$(OBJ) : $(GLSRC)gxshade.c $(GXERR) $(math__h)\ $(GLOBJ)gxshade1.$(OBJ) : $(GLSRC)gxshade1.c $(GXERR) $(math__h) $(memory__h)\ $(gscoord_h) $(gsmatrix_h) $(gspath_h)\ $(gxcspace_h) $(gxdcolor_h) $(gxfarith_h) $(gxfixed_h) $(gxistate_h)\ - $(gxpath_h) $(gxshade_h) + $(gxpath_h) $(gxshade_h) $(gxdevcli_h) $(GLCC) $(GLO_)gxshade1.$(OBJ) $(C_) $(GLSRC)gxshade1.c $(GLOBJ)gxshade4.$(OBJ) : $(GLSRC)gxshade4.c $(GXERR) $(memory__h)\ |