예제 #1
0
static void dl_forall_test(void) {
    printsln((String)__func__);
    List a = dl_of_string("1, 2, 3, 4, 5, 6");
    check_expect_b(dl_forall(a, dl_gt, 0), true);
    check_expect_b(dl_forall(a, dl_gt, 1), false);
    check_expect_b(dl_forall(a, dl_lt, 7), true);
    l_free(a);
}
예제 #2
0
/**
 * Create a region map and mark it according to the DL.  If LCM is enabled then
 * overprinted process colorants may need compositing for correct results.
 */
Bool dlregion_mark(DL_STATE *page)
{
  Bool result = FALSE;
  RegionMarkingData data = {0};
  DL_FORALL_INFO info = {0};

  HQASSERT(page->regionMap == NULL, "Region map already exists");
  HQASSERT(page->region_width > 0 && page->region_height > 0,
           "Region dimensions not set");
  if ( !region_map_create(page, &page->regionMap) )
    return FALSE;
#define return USE_goto_cleanup

  /* Do not mark the region map for pattern DL objects, only patterned objects.
     The pattern DL objects are defined in pattern space and could also be
     tiled. */
  info.page = page;
  info.inflags = DL_FORALL_USEMARKER|DL_FORALL_GROUP;
  /** \todo Vignette detection fails to unify KO flags through the vignette
      elements and therefore we need to mark elements individually. Don't need
      to do this for shfills, and once vignette detection is removed we can also
      remove this hack (also remove include "vndetect.h"). */
  if ( vd_detect() )
    info.inflags |= DL_FORALL_SHFILL;
  info.hdl = dlPageHDL(page);
  info.data = &data;

#if defined( DEBUG_BUILD )
  /* Decide whether to force the whole page to be composited. */
  if ( (backdrop_render_debug & BR_DEBUG_ALL_TO_BACKDROP) != 0 ) {
    dbbox_t pageFrame;
    bbox_store(&pageFrame, 0, 0, page->page_w - 1, page->page_h - 1);
    bitGridSetBoxMapped(page->regionMap, &pageFrame, TRUE);
  } else
#endif
  if ( pclGstateIsEnabled() ) {
    /* PCL uses a single region info to track the background. */
    if ( !region_info_create(page, &data.regionInfo, COLORANTINDEX_UNKNOWN,
                             TRUE, FALSE) )
      goto cleanup;

    /* Do region marking according to PCL rules. */
    if ( !dl_forall(&info, dlregion_pcl_callback) )
      goto cleanup;
  } else {
    /* Do region marking for transparency and overprinting. */
    if ( !dl_forall(&info, dlregion_callback) )
      goto cleanup;
  }

#ifdef METRICS_BUILD
  {
    dl_metrics_t *dlmetrics = dl_metrics();
    Size2d size = bitGridSize(page->regionMap);
    uint32 x, y;

    for ( y = 0; y < size.height; ++y ) {
      for ( x = 0; x < size.width; ++x ) {
        ++dlmetrics->regions.total;
        if ( bitGridGet(page->regionMap, x, y) )
          ++dlmetrics->regions.backdropRendered;
        else
          ++dlmetrics->regions.directRendered;
      }
    }
  }
#endif

  result = TRUE;
 cleanup:
  region_info_destroy(&data.regionInfo);
  /* Don't need regionMap if error or all clear. */
  if ( page->regionMap != NULL &&
       (!result || bitGridGetAll(page->regionMap) == BGAllClear) )
    bitGridDestroy(&page->regionMap);
#undef return
  return result;
}