diff options
-rw-r--r-- | gs/base/gxclimag.c | 165 |
1 files changed, 85 insertions, 80 deletions
diff --git a/gs/base/gxclimag.c b/gs/base/gxclimag.c index 206bada0d..d0a4cc0fc 100644 --- a/gs/base/gxclimag.c +++ b/gs/base/gxclimag.c | |||
@@ -89,13 +89,13 @@ palette_has_color(const gs_color_space *pcs, const gs_pixel_image_t * const pim) | |||
89 | case gs_color_space_index_CIEDEFG: | 89 | case gs_color_space_index_CIEDEFG: |
90 | is_neutral = &gsicc_mcm_monitor_cmyk; | 90 | is_neutral = &gsicc_mcm_monitor_cmyk; |
91 | break; | 91 | break; |
92 | 92 | ||
93 | case gs_color_space_index_DevicePixel: | 93 | case gs_color_space_index_DevicePixel: |
94 | case gs_color_space_index_DeviceN: | 94 | case gs_color_space_index_DeviceN: |
95 | case gs_color_space_index_Separation: | 95 | case gs_color_space_index_Separation: |
96 | case gs_color_space_index_Indexed: | 96 | case gs_color_space_index_Indexed: |
97 | case gs_color_space_index_Pattern: | 97 | case gs_color_space_index_Pattern: |
98 | return true; | 98 | return true; |
99 | break; | 99 | break; |
100 | 100 | ||
101 | case gs_color_space_index_ICC: | 101 | case gs_color_space_index_ICC: |
@@ -125,7 +125,7 @@ palette_has_color(const gs_color_space *pcs, const gs_pixel_image_t * const pim) | |||
125 | if (!is_neutral(psrc, 1)) { | 125 | if (!is_neutral(psrc, 1)) { |
126 | /* Has color end this now */ | 126 | /* Has color end this now */ |
127 | return true; | 127 | return true; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | /* Must not have color */ | 130 | /* Must not have color */ |
131 | return false; | 131 | return false; |
@@ -231,7 +231,7 @@ clist_fill_mask(gx_device * dev, | |||
231 | if (code < 0 && SET_BAND_CODE(code)) | 231 | if (code < 0 && SET_BAND_CODE(code)) |
232 | goto error_in_rect; | 232 | goto error_in_rect; |
233 | do { | 233 | do { |
234 | code = cmd_put_drawing_color(cdev, re.pcls, pdcolor, &re, | 234 | code = cmd_put_drawing_color(cdev, re.pcls, pdcolor, &re, |
235 | devn_not_tile); | 235 | devn_not_tile); |
236 | if (code == gs_error_unregistered) | 236 | if (code == gs_error_unregistered) |
237 | return code; | 237 | return code; |
@@ -292,7 +292,7 @@ clist_fill_mask(gx_device * dev, | |||
292 | dp++; | 292 | dp++; |
293 | if (depth == 1) { | 293 | if (depth == 1) { |
294 | cmd_putw(0, dp); | 294 | cmd_putw(0, dp); |
295 | } | 295 | } |
296 | cmd_putxy(rect, dp); | 296 | cmd_putxy(rect, dp); |
297 | } | 297 | } |
298 | } | 298 | } |
@@ -371,14 +371,13 @@ static const gx_image_enum_procs_t clist_image_enum_procs = | |||
371 | clist_image_plane_data, clist_image_end_image | 371 | clist_image_plane_data, clist_image_end_image |
372 | }; | 372 | }; |
373 | 373 | ||
374 | /* data_size is number of bytes per component, width is number of pixels in the row. */ | ||
374 | static bool | 375 | static bool |
375 | row_has_color(byte *data_ptr, clist_image_enum *pie_c, int dsize, int width) | 376 | row_has_color(byte *data_ptr, clist_image_enum *pie_c, int data_size, int width) |
376 | { | 377 | { |
377 | clist_color_space_t pclcs = pie_c->color_space; | 378 | clist_color_space_t pclcs = pie_c->color_space; |
378 | bool ((*is_neutral)(void*, int)); | 379 | bool ((*is_neutral)(void*, int)); |
379 | byte *buffer; | 380 | int step_size = data_size * pie_c->spp; |
380 | int pdata_x; | ||
381 | int step_size = pie_c->spread * pclcs.icc_info.icc_num_components; | ||
382 | byte *ptr; | 381 | byte *ptr; |
383 | bool is_mono; | 382 | bool is_mono; |
384 | int k; | 383 | int k; |
@@ -397,13 +396,10 @@ row_has_color(byte *data_ptr, clist_image_enum *pie_c, int dsize, int width) | |||
397 | return true; | 396 | return true; |
398 | } | 397 | } |
399 | } | 398 | } |
400 | /* Now go through the raster line and determine if we have any color. First | 399 | /* Now go through the raster line and determine if we have any color. */ |
401 | unpack. */ | 400 | ptr = data_ptr; |
402 | buffer = (*pie_c->unpack)(pie_c->buffer, &pdata_x, data_ptr, 0, dsize, pie_c->map, | ||
403 | pie_c->spread, pclcs.icc_info.icc_num_components); | ||
404 | ptr = buffer; | ||
405 | for (k = 0; k < width; k++) { | 401 | for (k = 0; k < width; k++) { |
406 | is_mono = is_neutral(ptr, pie_c->spread); | 402 | is_mono = is_neutral(ptr, data_size); |
407 | if (!is_mono) { | 403 | if (!is_mono) { |
408 | return true; | 404 | return true; |
409 | } | 405 | } |
@@ -413,9 +409,9 @@ row_has_color(byte *data_ptr, clist_image_enum *pie_c, int dsize, int width) | |||
413 | } | 409 | } |
414 | 410 | ||
415 | /* We need to have the unpacking proc so that we can monitor the data. */ | 411 | /* We need to have the unpacking proc so that we can monitor the data. */ |
416 | static void | 412 | static void |
417 | get_unpack_proc(clist_image_enum *pie, const float *decode) { | 413 | get_unpack_proc(clist_image_enum *pie, const float *decode) { |
418 | 414 | ||
419 | static sample_unpack_proc_t procs[2][6] = { | 415 | static sample_unpack_proc_t procs[2][6] = { |
420 | { sample_unpack_1, sample_unpack_2, | 416 | { sample_unpack_1, sample_unpack_2, |
421 | sample_unpack_4, sample_unpack_8, | 417 | sample_unpack_4, sample_unpack_8, |
@@ -620,10 +616,10 @@ image_matrix_ok_to_band(const gs_matrix * pmat) | |||
620 | 616 | ||
621 | /* Start processing an image. */ | 617 | /* Start processing an image. */ |
622 | int | 618 | int |
623 | clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | 619 | clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, |
624 | const gs_matrix * pmat, const gs_image_common_t * pic, | 620 | const gs_matrix * pmat, const gs_image_common_t * pic, |
625 | const gs_int_rect * prect, const gx_drawing_color * pdcolor, | 621 | const gs_int_rect * prect, const gx_drawing_color * pdcolor, |
626 | const gx_clip_path * pcpath, gs_memory_t * mem, | 622 | const gx_clip_path * pcpath, gs_memory_t * mem, |
627 | gx_image_enum_common_t ** pinfo) | 623 | gx_image_enum_common_t ** pinfo) |
628 | { | 624 | { |
629 | const gs_pixel_image_t * const pim = (const gs_pixel_image_t *)pic; | 625 | const gs_pixel_image_t * const pim = (const gs_pixel_image_t *)pic; |
@@ -651,7 +647,7 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
651 | gsicc_blackptcomp_t blackptcomp = pis->blackptcomp; | 647 | gsicc_blackptcomp_t blackptcomp = pis->blackptcomp; |
652 | gsicc_rendering_param_t stored_rendering_cond; | 648 | gsicc_rendering_param_t stored_rendering_cond; |
653 | gsicc_rendering_param_t dev_render_cond; | 649 | gsicc_rendering_param_t dev_render_cond; |
654 | gs_imager_state *pis_nonconst = (gs_imager_state*) pis; | 650 | gs_imager_state *pis_nonconst = (gs_imager_state*) pis; |
655 | bool intent_changed = false; | 651 | bool intent_changed = false; |
656 | bool bp_changed = false; | 652 | bool bp_changed = false; |
657 | cmm_dev_profile_t *dev_profile = NULL; | 653 | cmm_dev_profile_t *dev_profile = NULL; |
@@ -798,21 +794,21 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
798 | if ( base_index == gs_color_space_index_ICC ) { | 794 | if ( base_index == gs_color_space_index_ICC ) { |
799 | code = dev_proc(dev, get_profile)(dev, &dev_profile); | 795 | code = dev_proc(dev, get_profile)(dev, &dev_profile); |
800 | gsicc_extract_profile(dev->graphics_type_tag, dev_profile, | 796 | gsicc_extract_profile(dev->graphics_type_tag, dev_profile, |
801 | &(gs_output_profile), | 797 | &(gs_output_profile), |
802 | (&(dev_render_cond))); | 798 | (&(dev_render_cond))); |
803 | if (!indexed) { | 799 | if (!indexed) { |
804 | src_profile = pim->ColorSpace->cmm_icc_profile_data; | 800 | src_profile = pim->ColorSpace->cmm_icc_profile_data; |
805 | } else { | 801 | } else { |
806 | src_profile = | 802 | src_profile = |
807 | pim->ColorSpace->base_space->cmm_icc_profile_data; | 803 | pim->ColorSpace->base_space->cmm_icc_profile_data; |
808 | } | 804 | } |
809 | /* Initialize the rendering conditions to what we currently | 805 | /* Initialize the rendering conditions to what we currently |
810 | have before we may blow them away with what is set in | 806 | have before we may blow them away with what is set in |
811 | the srcgtag information */ | 807 | the srcgtag information */ |
812 | stored_rendering_cond.graphics_type_tag = GS_IMAGE_TAG; | 808 | stored_rendering_cond.graphics_type_tag = GS_IMAGE_TAG; |
813 | stored_rendering_cond.override_icc = | 809 | stored_rendering_cond.override_icc = |
814 | dev_render_cond.override_icc; | 810 | dev_render_cond.override_icc; |
815 | stored_rendering_cond.preserve_black = | 811 | stored_rendering_cond.preserve_black = |
816 | dev_render_cond.preserve_black; | 812 | dev_render_cond.preserve_black; |
817 | stored_rendering_cond.cmm = gsCMM_DEFAULT; /* Unless spec. below */ | 813 | stored_rendering_cond.cmm = gsCMM_DEFAULT; /* Unless spec. below */ |
818 | /* We may need to do some substitions for the source profile */ | 814 | /* We may need to do some substitions for the source profile */ |
@@ -821,62 +817,62 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
821 | if (src_profile->data_cs == gsRGB) { | 817 | if (src_profile->data_cs == gsRGB) { |
822 | if (srcgtag_profile->rgb_profiles[gsSRC_IMAGPRO] != NULL) { | 818 | if (srcgtag_profile->rgb_profiles[gsSRC_IMAGPRO] != NULL) { |
823 | /* We only do this replacement depending upon the | 819 | /* We only do this replacement depending upon the |
824 | ICC override setting for this object and the | 820 | ICC override setting for this object and the |
825 | original color space of this object */ | 821 | original color space of this object */ |
826 | csi = gsicc_get_default_type(src_profile); | 822 | csi = gsicc_get_default_type(src_profile); |
827 | if (srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].override_icc || | 823 | if (srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].override_icc || |
828 | csi == gs_color_space_index_DeviceRGB) { | 824 | csi == gs_color_space_index_DeviceRGB) { |
829 | src_profile = | 825 | src_profile = |
830 | srcgtag_profile->rgb_profiles[gsSRC_IMAGPRO]; | 826 | srcgtag_profile->rgb_profiles[gsSRC_IMAGPRO]; |
831 | pis_nonconst->renderingintent = | 827 | pis_nonconst->renderingintent = |
832 | srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].rendering_intent; | 828 | srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].rendering_intent; |
833 | pis_nonconst->blackptcomp = | 829 | pis_nonconst->blackptcomp = |
834 | srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].black_point_comp; | 830 | srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].black_point_comp; |
835 | stored_rendering_cond = | 831 | stored_rendering_cond = |
836 | srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO]; | 832 | srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO]; |
837 | } | 833 | } |
838 | } else { | 834 | } else { |
839 | /* A possible do not use CM case */ | 835 | /* A possible do not use CM case */ |
840 | stored_rendering_cond.cmm = | 836 | stored_rendering_cond.cmm = |
841 | srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].cmm; | 837 | srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].cmm; |
842 | } | 838 | } |
843 | } else if (src_profile->data_cs == gsCMYK) { | 839 | } else if (src_profile->data_cs == gsCMYK) { |
844 | if (srcgtag_profile->cmyk_profiles[gsSRC_IMAGPRO] != NULL) { | 840 | if (srcgtag_profile->cmyk_profiles[gsSRC_IMAGPRO] != NULL) { |
845 | csi = gsicc_get_default_type(src_profile); | 841 | csi = gsicc_get_default_type(src_profile); |
846 | if (srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].override_icc || | 842 | if (srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].override_icc || |
847 | csi == gs_color_space_index_DeviceCMYK) { | 843 | csi == gs_color_space_index_DeviceCMYK) { |
848 | src_profile = | 844 | src_profile = |
849 | srcgtag_profile->cmyk_profiles[gsSRC_IMAGPRO]; | 845 | srcgtag_profile->cmyk_profiles[gsSRC_IMAGPRO]; |
850 | pis_nonconst->renderingintent = | 846 | pis_nonconst->renderingintent = |
851 | srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO].rendering_intent; | 847 | srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO].rendering_intent; |
852 | pis_nonconst->blackptcomp = | 848 | pis_nonconst->blackptcomp = |
853 | srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO].black_point_comp; | 849 | srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO].black_point_comp; |
854 | stored_rendering_cond = | 850 | stored_rendering_cond = |
855 | srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO]; | 851 | srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO]; |
856 | } | 852 | } |
857 | } else { | 853 | } else { |
858 | /* A possible do not use CM case */ | 854 | /* A possible do not use CM case */ |
859 | stored_rendering_cond.cmm = | 855 | stored_rendering_cond.cmm = |
860 | srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO].cmm; | 856 | srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO].cmm; |
861 | } | 857 | } |
862 | } | 858 | } |
863 | } | 859 | } |
864 | /* If the device RI is set and we are not setting the RI from | 860 | /* If the device RI is set and we are not setting the RI from |
865 | the source structure, then override any RI specified in the | 861 | the source structure, then override any RI specified in the |
866 | document by the RI specified in the device */ | 862 | document by the RI specified in the device */ |
867 | if (!(pis_nonconst->renderingintent & gsRI_OVERRIDE)) { /* was set by source? */ | 863 | if (!(pis_nonconst->renderingintent & gsRI_OVERRIDE)) { /* was set by source? */ |
868 | /* No it was not. See if we should override with the | 864 | /* No it was not. See if we should override with the |
869 | device setting */ | 865 | device setting */ |
870 | if (dev_render_cond.rendering_intent != gsRINOTSPECIFIED) { | 866 | if (dev_render_cond.rendering_intent != gsRINOTSPECIFIED) { |
871 | pis_nonconst->renderingintent = | 867 | pis_nonconst->renderingintent = |
872 | dev_render_cond.rendering_intent; | 868 | dev_render_cond.rendering_intent; |
873 | } | 869 | } |
874 | } | 870 | } |
875 | /* We have a similar issue to deal with with respect to the | 871 | /* We have a similar issue to deal with with respect to the |
876 | black point. */ | 872 | black point. */ |
877 | if (!(pis_nonconst->blackptcomp & gsBP_OVERRIDE)) { | 873 | if (!(pis_nonconst->blackptcomp & gsBP_OVERRIDE)) { |
878 | if (dev_render_cond.black_point_comp != gsBPNOTSPECIFIED) { | 874 | if (dev_render_cond.black_point_comp != gsBPNOTSPECIFIED) { |
879 | pis_nonconst->blackptcomp = | 875 | pis_nonconst->blackptcomp = |
880 | dev_render_cond.black_point_comp; | 876 | dev_render_cond.black_point_comp; |
881 | } | 877 | } |
882 | } | 878 | } |
@@ -885,9 +881,9 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
885 | if (blackptcomp != pis_nonconst->blackptcomp) | 881 | if (blackptcomp != pis_nonconst->blackptcomp) |
886 | bp_changed = true; | 882 | bp_changed = true; |
887 | /* Set for the rendering param structure also */ | 883 | /* Set for the rendering param structure also */ |
888 | stored_rendering_cond.rendering_intent = | 884 | stored_rendering_cond.rendering_intent = |
889 | pis_nonconst->renderingintent; | 885 | pis_nonconst->renderingintent; |
890 | stored_rendering_cond.black_point_comp = | 886 | stored_rendering_cond.black_point_comp = |
891 | pis_nonconst->blackptcomp; | 887 | pis_nonconst->blackptcomp; |
892 | stored_rendering_cond.graphics_type_tag = GS_IMAGE_TAG; | 888 | stored_rendering_cond.graphics_type_tag = GS_IMAGE_TAG; |
893 | if (!(src_profile->hash_is_valid)) { | 889 | if (!(src_profile->hash_is_valid)) { |
@@ -898,7 +894,7 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
898 | src_profile->hash_is_valid = true; | 894 | src_profile->hash_is_valid = true; |
899 | } | 895 | } |
900 | pie->color_space.icc_info.icc_hash = src_profile->hashcode; | 896 | pie->color_space.icc_info.icc_hash = src_profile->hashcode; |
901 | pie->color_space.icc_info.icc_num_components = | 897 | pie->color_space.icc_info.icc_num_components = |
902 | src_profile->num_comps; | 898 | src_profile->num_comps; |
903 | pie->color_space.icc_info.is_lab = src_profile->islab; | 899 | pie->color_space.icc_info.is_lab = src_profile->islab; |
904 | pie->color_space.icc_info.data_cs = src_profile->data_cs; | 900 | pie->color_space.icc_info.data_cs = src_profile->data_cs; |
@@ -937,25 +933,24 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
937 | goto use_default; | 933 | goto use_default; |
938 | 934 | ||
939 | /* If we are going out to a halftone device and the size of the stored | 935 | /* If we are going out to a halftone device and the size of the stored |
940 | image at device resolution and color space is going to be smaller, | 936 | image at device resolution and color space is going to be smaller, |
941 | go ahead and do the default handler. This occurs only for planar | 937 | go ahead and do the default handler. This occurs only for planar |
942 | devices where if we prerender we will end up doing the fast theshold | 938 | devices where if we prerender we will end up doing the fast theshold |
943 | halftone and going out as copy_planes commands into the clist. | 939 | halftone and going out as copy_planes commands into the clist. |
944 | There is already a test above with regard to the posture so that | 940 | There is already a test above with regard to the posture so that |
945 | we are only doing portrait or landscape cases if we are here. Only | 941 | we are only doing portrait or landscape cases if we are here. Only |
946 | question is penum->image_parent_type == gs_image_type1 */ | 942 | question is penum->image_parent_type == gs_image_type1 */ |
947 | if (dev_profile == NULL) { | 943 | if (dev_profile == NULL) { |
948 | gsicc_rendering_param_t temp_render_cond; | 944 | gsicc_rendering_param_t temp_render_cond; |
949 | code = dev_proc(dev, get_profile)(dev, &dev_profile); | 945 | code = dev_proc(dev, get_profile)(dev, &dev_profile); |
950 | gsicc_extract_profile(dev->graphics_type_tag, dev_profile, | 946 | gsicc_extract_profile(dev->graphics_type_tag, dev_profile, |
951 | &(gs_output_profile), | 947 | &(gs_output_profile), |
952 | &(temp_render_cond)); | 948 | &(temp_render_cond)); |
953 | } | 949 | } |
954 | /* Decide if we need to do any monitoring of the colors. Note that multiple source | 950 | /* Decide if we need to do any monitoring of the colors. Note that multiple source |
955 | (planes) is treated as color */ | 951 | (planes) is treated as color */ |
956 | pie->unpack = NULL; | 952 | pie->unpack = NULL; |
957 | if (dev_profile->pageneutralcolor && pie->color_space.icc_info.data_cs != gsGRAY | 953 | if (dev_profile->pageneutralcolor && pie->color_space.icc_info.data_cs != gsGRAY) { |
958 | && (pie->num_planes == 1)) { | ||
959 | /* If it is an index image, then check the pallete only */ | 954 | /* If it is an index image, then check the pallete only */ |
960 | if (!indexed) { | 955 | if (!indexed) { |
961 | pie->monitor_color = true; | 956 | pie->monitor_color = true; |
@@ -965,7 +960,7 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
965 | if (pie->unpack == NULL) { | 960 | if (pie->unpack == NULL) { |
966 | /* If we cant unpack, then end monitoring now. Treat as has color */ | 961 | /* If we cant unpack, then end monitoring now. Treat as has color */ |
967 | dev_profile->pageneutralcolor = false; | 962 | dev_profile->pageneutralcolor = false; |
968 | gsicc_mcm_end_monitor(pis->icc_link_cache, dev); | 963 | gsicc_mcm_end_monitor(pis->icc_link_cache, dev); |
969 | } else { | 964 | } else { |
970 | /* We need to allocate the buffer for unpacking during monitoring. | 965 | /* We need to allocate the buffer for unpacking during monitoring. |
971 | This is mainly for the 12bit case */ | 966 | This is mainly for the 12bit case */ |
@@ -978,34 +973,29 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
978 | } | 973 | } |
979 | } else { | 974 | } else { |
980 | pie->monitor_color = false; | 975 | pie->monitor_color = false; |
981 | /* Check the Palette here */ | 976 | /* Check the Palette here */ |
982 | if (palette_has_color(pim->ColorSpace, pim)) { | 977 | if (palette_has_color(pim->ColorSpace, pim)) { |
983 | /* Has color. We are done monitoring */ | 978 | /* Has color. We are done monitoring */ |
984 | dev_profile->pageneutralcolor = false; | 979 | dev_profile->pageneutralcolor = false; |
985 | gsicc_mcm_end_monitor(pis->icc_link_cache, dev); | 980 | gsicc_mcm_end_monitor(pis->icc_link_cache, dev); |
986 | } | 981 | } |
987 | } | 982 | } |
988 | } else { | 983 | } else { |
989 | pie->monitor_color = false; | 984 | pie->monitor_color = false; |
990 | } | 985 | } |
991 | if (pie->num_planes > 1 && dev_profile->pageneutralcolor) { | ||
992 | /* We are done monitoring */ | ||
993 | dev_profile->pageneutralcolor = false; | ||
994 | gsicc_mcm_end_monitor(pis->icc_link_cache, dev); | ||
995 | } | ||
996 | if (gx_device_must_halftone(dev) && pim->BitsPerComponent == 8 && !masked && | 986 | if (gx_device_must_halftone(dev) && pim->BitsPerComponent == 8 && !masked && |
997 | (dev->color_info.num_components == 1 || is_planar_dev) && | 987 | (dev->color_info.num_components == 1 || is_planar_dev) && |
998 | dev_profile->prebandthreshold) { | 988 | dev_profile->prebandthreshold) { |
999 | int dev_width = dbox.q.x - dbox.p.x; | 989 | int dev_width = dbox.q.x - dbox.p.x; |
1000 | int dev_height = dbox.q.y - dbox.p.y; | 990 | int dev_height = dbox.q.y - dbox.p.y; |
1001 | 991 | ||
1002 | int src_size = pim->Height * | 992 | int src_size = pim->Height * |
1003 | bitmap_raster(pim->Width * pim->BitsPerComponent * | 993 | bitmap_raster(pim->Width * pim->BitsPerComponent * |
1004 | num_components); | 994 | num_components); |
1005 | int des_size = dev_height * bitmap_raster(dev_width * | 995 | int des_size = dev_height * bitmap_raster(dev_width * |
1006 | dev->color_info.depth); | 996 | dev->color_info.depth); |
1007 | if (src_size > des_size) | 997 | if (src_size > des_size) |
1008 | goto use_default; | 998 | goto use_default; |
1009 | } | 999 | } |
1010 | /* Create the begin_image command. */ | 1000 | /* Create the begin_image command. */ |
1011 | if ((pie->begin_image_command_length = | 1001 | if ((pie->begin_image_command_length = |
@@ -1084,9 +1074,9 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
1084 | * are known at the time of the begin_image command. | 1074 | * are known at the time of the begin_image command. |
1085 | */ | 1075 | */ |
1086 | cmd_clear_known(cdev, clist_image_unknowns(dev, pie) | begin_image_known); | 1076 | cmd_clear_known(cdev, clist_image_unknowns(dev, pie) | begin_image_known); |
1087 | /* Because the rendering intent may be driven by the source color | 1077 | /* Because the rendering intent may be driven by the source color |
1088 | settings we may have needed to overide the intent. Need to break the const | 1078 | settings we may have needed to overide the intent. Need to break the const |
1089 | on the pis here for this and reset back */ | 1079 | on the pis here for this and reset back */ |
1090 | if (intent_changed) | 1080 | if (intent_changed) |
1091 | pis_nonconst->renderingintent = renderingintent; | 1081 | pis_nonconst->renderingintent = renderingintent; |
1092 | if (bp_changed) | 1082 | if (bp_changed) |
@@ -1095,9 +1085,9 @@ clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis, | |||
1095 | cdev->image_enum_id = pie->id; | 1085 | cdev->image_enum_id = pie->id; |
1096 | return 0; | 1086 | return 0; |
1097 | /* | 1087 | /* |
1098 | * We couldn't handle the image. It is up to the caller to use the default | 1088 | * We couldn't handle the image. It is up to the caller to use the default |
1099 | * algorithms, which break the image up into rectangles or small pixmaps. | 1089 | * algorithms, which break the image up into rectangles or small pixmaps. |
1100 | * If we are doing the PDF14 transparency device then we want to make sure we do | 1090 | * If we are doing the PDF14 transparency device then we want to make sure we do |
1101 | * NOT use the target device. In this case we return -1. | 1091 | * NOT use the target device. In this case we return -1. |
1102 | */ | 1092 | */ |
1103 | use_default: | 1093 | use_default: |
@@ -1283,7 +1273,7 @@ clist_image_plane_data(gx_image_enum_common_t * info, | |||
1283 | goto error_in_rect; | 1273 | goto error_in_rect; |
1284 | if (pie->uses_color) { | 1274 | if (pie->uses_color) { |
1285 | do { | 1275 | do { |
1286 | code = cmd_put_drawing_color(cdev, re.pcls, &pie->dcolor, | 1276 | code = cmd_put_drawing_color(cdev, re.pcls, &pie->dcolor, |
1287 | &re, devn_not_tile); | 1277 | &re, devn_not_tile); |
1288 | } while (RECT_RECOVER(code)); | 1278 | } while (RECT_RECOVER(code)); |
1289 | if (code < 0 && SET_BAND_CODE(code)) | 1279 | if (code < 0 && SET_BAND_CODE(code)) |
@@ -1360,14 +1350,14 @@ clist_image_plane_data(gx_image_enum_common_t * info, | |||
1360 | if (!found_color) { | 1350 | if (!found_color) { |
1361 | code = cmd_image_plane_data_mon(cdev, re.pcls, planes, info, | 1351 | code = cmd_image_plane_data_mon(cdev, re.pcls, planes, info, |
1362 | bytes_per_plane, offsets, | 1352 | bytes_per_plane, offsets, |
1363 | xoff - xskip, nrows, | 1353 | xoff - xskip, nrows, |
1364 | &found_color); | 1354 | &found_color); |
1365 | if (found_color) { | 1355 | if (found_color) { |
1366 | /* Has color. We are done monitoring */ | 1356 | /* Has color. We are done monitoring */ |
1367 | cmm_dev_profile_t *dev_profile; | 1357 | cmm_dev_profile_t *dev_profile; |
1368 | code = dev_proc(dev, get_profile)(dev, &dev_profile); | 1358 | code = dev_proc(dev, get_profile)(dev, &dev_profile); |
1369 | dev_profile->pageneutralcolor = false; | 1359 | dev_profile->pageneutralcolor = false; |
1370 | gsicc_mcm_end_monitor(pie->pis->icc_link_cache, dev); | 1360 | gsicc_mcm_end_monitor(pie->pis->icc_link_cache, dev); |
1371 | pie->monitor_color = false; | 1361 | pie->monitor_color = false; |
1372 | } | 1362 | } |
1373 | } else { | 1363 | } else { |
@@ -2177,8 +2167,9 @@ cmd_image_plane_data_mon(gx_device_clist_writer * cldev, gx_clist_state * pcls, | |||
2177 | int plane, i; | 2167 | int plane, i; |
2178 | int code; | 2168 | int code; |
2179 | int width = pie_c->rect.q.x - pie_c->rect.p.x; | 2169 | int width = pie_c->rect.q.x - pie_c->rect.p.x; |
2180 | int dsize = (((width + (planes[0]).data_x) * pie_c->spp * | 2170 | int dsize = (((width + (planes[0]).data_x) * pie_c->spp * |
2181 | pie_c->bps / pie->num_planes + 7) >> 3); | 2171 | pie_c->bps / pie->num_planes + 7) >> 3); |
2172 | int data_size = pie_c->spread / pie->num_planes; | ||
2182 | 2173 | ||
2183 | *found_color = false; | 2174 | *found_color = false; |
2184 | 2175 | ||
@@ -2194,21 +2185,35 @@ cmd_image_plane_data_mon(gx_device_clist_writer * cldev, gx_clist_state * pcls, | |||
2194 | dp++; | 2185 | dp++; |
2195 | 2186 | ||
2196 | cmd_put2w(h, bytes_per_plane, dp); | 2187 | cmd_put2w(h, bytes_per_plane, dp); |
2197 | for (plane = 0; plane < pie->num_planes; ++plane) | 2188 | |
2198 | for (i = 0; i < h; ++i) { | 2189 | for (i = 0; i < h; ++i) { |
2190 | if (!(*found_color)) { | ||
2199 | /* Here we need to unpack and actually look at the image data | 2191 | /* Here we need to unpack and actually look at the image data |
2200 | to see if we have any non-neutral colors */ | 2192 | to see if we have any non-neutral colors */ |
2201 | 2193 | int pdata_x; | |
2202 | byte *data_ptr = planes[plane].data + i * planes[plane].raster + | 2194 | byte *data_ptr = planes[0].data + i * planes[0].raster + offsets[0] + offset; |
2203 | offsets[plane] + offset; | 2195 | byte *buffer = (*pie_c->unpack)(pie_c->buffer, &pdata_x, data_ptr, 0, dsize, pie_c->map, |
2204 | if (!(*found_color) && row_has_color(data_ptr, pie_c, dsize, width)) { | 2196 | pie_c->spread, pie_c->spp); |
2197 | |||
2198 | for (plane = 1; plane < pie->num_planes; ++plane) { | ||
2199 | /* unpack planes after the first (if any), relying on spread to place the */ | ||
2200 | /* data at the correct spacing, with the buffer start adjusted for each plane */ | ||
2201 | data_ptr = planes[plane].data + i * planes[plane].raster + offsets[plane] + offset; | ||
2202 | (*pie_c->unpack)(pie_c->buffer + (data_size * plane), &pdata_x, data_ptr, 0, | ||
2203 | dsize, pie_c->map, pie_c->spread, pie_c->spp); | ||
2204 | } | ||
2205 | if (row_has_color(buffer, pie_c, data_size, width)) { | ||
2205 | /* Has color. We are done monitoring */ | 2206 | /* Has color. We are done monitoring */ |
2206 | *found_color = true; | 2207 | *found_color = true; |
2207 | } | 2208 | } |
2209 | } | ||
2210 | /* Now copy the plane data into the clist buffer */ | ||
2211 | for (plane = 0; plane < pie->num_planes; ++plane) { | ||
2208 | memcpy(dp, planes[plane].data + i * planes[plane].raster + | 2212 | memcpy(dp, planes[plane].data + i * planes[plane].raster + |
2209 | offsets[plane] + offset, bytes_per_plane); | 2213 | offsets[plane] + offset, bytes_per_plane); |
2210 | dp += bytes_per_plane; | 2214 | dp += bytes_per_plane; |
2211 | } | 2215 | } |
2216 | } | ||
2212 | return 0; | 2217 | return 0; |
2213 | } | 2218 | } |
2214 | 2219 | ||