void trace_copy_rop(const char *cname, gx_device * dev, const byte * sdata, int sourcex, uint sraster, gx_bitmap_id id, const gx_color_index * scolors, const gx_strip_bitmap * textures, const gx_color_index * tcolors, int x, int y, int width, int height, int phase_x, int phase_y, gs_logical_operation_t lop) { dlprintf4("%s: dev=0x%lx(%s) depth=%d\n", cname, (ulong) dev, dev->dname, dev->color_info.depth); dlprintf4(" source data=0x%lx x=%d raster=%u id=%lu colors=", (ulong) sdata, sourcex, sraster, (ulong) id); if (scolors) dprintf2("(%lu,%lu);\n", scolors[0], scolors[1]); else dputs("none;\n"); if (textures) dlprintf8(" textures=0x%lx size=%dx%d(%dx%d) raster=%u shift=%d(%d)", (ulong) textures, textures->size.x, textures->size.y, textures->rep_width, textures->rep_height, textures->raster, textures->shift, textures->rep_shift); else dlputs(" textures=none"); if (tcolors) dprintf2(" colors=(%lu,%lu)\n", tcolors[0], tcolors[1]); else dputs(" colors=none\n"); dlprintf7(" rect=(%d,%d),(%d,%d) phase=(%d,%d) op=0x%x\n", x, y, x + width, y + height, phase_x, phase_y, (uint) lop); if (gs_debug_c('B')) { if (sdata) debug_dump_bitmap(sdata, sraster, height, "source bits"); if (textures && textures->data) debug_dump_bitmap(textures->data, textures->raster, textures->size.y, "textures bits"); } }
/* Print a path */ void gx_path_print(const gx_path * ppath) { const segment *pseg = (const segment *)ppath->first_subpath; dlprintf5(" %% state_flags=%d subpaths=%d, curves=%d, point=(%f,%f)\n", ppath->state_flags, ppath->subpath_count, ppath->curve_count, fixed2float(ppath->position.x), fixed2float(ppath->position.y)); dlprintf5(" %% box=(%f,%f),(%f,%f) last=0x%lx\n", fixed2float(ppath->bbox.p.x), fixed2float(ppath->bbox.p.y), fixed2float(ppath->bbox.q.x), fixed2float(ppath->bbox.q.y), (ulong) ppath->box_last); dlprintf4(" %% segments=0x%lx (refct=%ld, first=0x%lx, current=0x%lx)\n", (ulong) ppath->segments, (long)ppath->segments->rc.ref_count, (ulong) ppath->segments->contents.subpath_first, (ulong) ppath->segments->contents.subpath_current); while (pseg) { dlputs(""); gx_print_segment(pseg); pseg = pseg->next; } }
/* * Look up a name on the dictionary stack. * Return the pointer to the value if found, 0 if not. */ ref * dstack_find_name_by_index(dict_stack_t * pds, uint nidx) { ds_ptr pdref = pds->stack.p; /* Since we know the hash function is the identity function, */ /* there's no point in allocating a separate variable for it. */ #define hash dict_name_index_hash(nidx) ref_packed kpack = packed_name_key(nidx); do { dict *pdict = pdref->value.pdict; uint size = npairs(pdict); const gs_memory_t *mem = dict_mem(pdict); #ifdef DEBUG if (gs_debug_c('D')) { ref dnref; name_index_ref(mem, nidx, &dnref); dlputs("[D]lookup "); debug_print_name(mem, &dnref); dprintf3(" in 0x%lx(%u/%u)\n", (ulong) pdict, dict_length(pdref), dict_maxlength(pdref)); } #endif #define INCR_DEPTH(pdref)\ INCR(depth[min(MAX_STATS_DEPTH, pds->stack.p - pdref)]) if (dict_is_packed(pdict)) { packed_search_1(INCR_DEPTH(pdref), return packed_search_value_pointer, DO_NOTHING, goto miss); packed_search_2(INCR_DEPTH(pdref), return packed_search_value_pointer, DO_NOTHING, break); miss:; } else { ref *kbot = pdict->keys.value.refs; register ref *kp; int wrap = 0; /* Search the dictionary */ for (kp = kbot + dict_hash_mod(hash, size) + 2;;) { --kp; if (r_has_type(kp, t_name)) { if (name_index(mem, kp) == nidx) { INCR_DEPTH(pdref); return pdict->values.value.refs + (kp - kbot); } } else if (r_has_type(kp, t_null)) { /* Empty, deleted, or wraparound. */ /* Figure out which. */ if (!r_has_attr(kp, a_executable)) break; if (kp == kbot) { /* wrap */ if (wrap++) break; /* 2 wraps */ kp += size + 1; } } } } #undef INCR_DEPTH }
/* Process the next piece of an ImageType 1 image. */ int gx_image1_plane_data(gx_image_enum_common_t * info, const gx_image_plane_t * planes, int height, int *rows_used) { gx_image_enum *penum = (gx_image_enum *) info; gx_device *dev; const int y = penum->y; int y_end = min(y + height, penum->rect.h); int width_spp = penum->rect.w * penum->spp; int num_planes = penum->num_planes; int num_components_per_plane = 1; #define BCOUNT(plane) /* bytes per data row */\ (((penum->rect.w + (plane).data_x) * penum->spp * penum->bps / num_planes\ + 7) >> 3) fixed adjust = penum->adjust; ulong offsets[GS_IMAGE_MAX_COMPONENTS]; int ignore_data_x; bool bit_planar = penum->num_planes > penum->spp; int code; if (height == 0) { *rows_used = 0; return 0; } dev = setup_image_device(penum); /* Now render complete rows. */ if (penum->used.y) { /* * Processing was interrupted by an error. Skip over rows * already processed. */ int px; for (px = 0; px < num_planes; ++px) offsets[px] = planes[px].raster * penum->used.y; penum->used.y = 0; } else memset(offsets, 0, num_planes * sizeof(offsets[0])); if (num_planes == 1 && penum->plane_depths[0] != penum->bps) { /* A single plane with multiple components. */ num_components_per_plane = penum->plane_depths[0] / penum->bps; } for (; penum->y < y_end; penum->y++) { int px; const byte *buffer; int sourcex; int x_used = penum->used.x; if (bit_planar) { /* Repack the bit planes into byte-wide samples. */ buffer = penum->buffer; sourcex = 0; for (px = 0; px < num_planes; px += penum->bps) repack_bit_planes(planes, offsets, penum->bps, penum->buffer, penum->rect.w, &penum->map[px].table, penum->spread); for (px = 0; px < num_planes; ++px) offsets[px] += planes[px].raster; } else { /* * Normally, we unpack the data into the buffer, but if * there is only one plane and we don't need to expand the * input samples, we may use the data directly. */ sourcex = planes[0].data_x; buffer = (*penum->unpack)(penum->buffer, &sourcex, planes[0].data + offsets[0], planes[0].data_x, BCOUNT(planes[0]), &penum->map[0], penum->spread, num_components_per_plane); offsets[0] += planes[0].raster; for (px = 1; px < num_planes; ++px) { (*penum->unpack)(penum->buffer + (px << penum->log2_xbytes), &ignore_data_x, planes[px].data + offsets[px], planes[px].data_x, BCOUNT(planes[px]), &penum->map[px], penum->spread, 1); offsets[px] += planes[px].raster; } } #ifdef DEBUG if (gs_debug_c('b')) dprintf1("[b]image1 y=%d\n", y); if (gs_debug_c('B')) { int i, n = width_spp; if (penum->bps > 8) n *= 2; else if (penum->bps == 1 && penum->unpack_bps == 8) n = (n + 7) / 8; dlputs("[B]row:"); for (i = 0; i < n; i++) dprintf1(" %02x", buffer[i]); dputs("\n"); } #endif penum->cur.x = dda_current(penum->dda.row.x); dda_next(penum->dda.row.x); penum->cur.y = dda_current(penum->dda.row.y); dda_next(penum->dda.row.y); if (!penum->interpolate) switch (penum->posture) { case image_portrait: { /* Precompute integer y and height, */ /* and check for clipping. */ fixed yc = penum->cur.y, yn = dda_current(penum->dda.row.y); if (yn < yc) { fixed temp = yn; yn = yc; yc = temp; } yc -= adjust; if (yc >= penum->clip_outer.q.y) goto mt; yn += adjust; if (yn <= penum->clip_outer.p.y) goto mt; penum->yci = fixed2int_pixround_perfect(yc); penum->hci = fixed2int_pixround_perfect(yn) - penum->yci; if (penum->hci == 0) goto mt; if_debug2('b', "[b]yci=%d, hci=%d\n", penum->yci, penum->hci); } break; case image_landscape: { /* Check for no pixel centers in x. */ fixed xc = penum->cur.x, xn = dda_current(penum->dda.row.x); if (xn < xc) { fixed temp = xn; xn = xc; xc = temp; } xc -= adjust; if (xc >= penum->clip_outer.q.x) goto mt; xn += adjust; if (xn <= penum->clip_outer.p.x) goto mt; penum->xci = fixed2int_pixround_perfect(xc); penum->wci = fixed2int_pixround_perfect(xn) - penum->xci; if (penum->wci == 0) goto mt; if_debug2('b', "[b]xci=%d, wci=%d\n", penum->xci, penum->wci); } break; case image_skewed: ; } update_strip(penum); if (x_used) { /* * Processing was interrupted by an error. Skip over pixels * already processed. */ dda_advance(penum->dda.pixel0.x, x_used); dda_advance(penum->dda.pixel0.y, x_used); penum->used.x = 0; } if_debug2('b', "[b]pixel0 x=%g, y=%g\n", fixed2float(dda_current(penum->dda.pixel0.x)), fixed2float(dda_current(penum->dda.pixel0.y))); code = (*penum->render)(penum, buffer, sourcex + x_used, width_spp - x_used * penum->spp, 1, dev); if (code < 0) { /* Error or interrupt, restore original state. */ penum->used.x += x_used; if (!penum->used.y) { dda_previous(penum->dda.row.x); dda_previous(penum->dda.row.y); dda_translate(penum->dda.strip.x, penum->prev.x - penum->cur.x); dda_translate(penum->dda.strip.y, penum->prev.y - penum->cur.y); } goto out; } penum->prev = penum->cur; mt:; } if (penum->y < penum->rect.h) { code = 0; } else { /* End of input data. Render any left-over buffered data. */ code = gx_image1_flush(info); if (code >= 0) code = 1; } out: /* Note that caller must call end_image */ /* for both error and normal termination. */ *rows_used = penum->y - y; return code; }