1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700
|
/* Copyright (C) 2001-2012 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
implied.
This software is distributed under license and may not be copied,
modified or distributed except as expressly authorized under the terms
of the license contained in the file LICENSE in this distribution.
Refer to licensing information at http://www.artifex.com or contact
Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael,
CA 94903, U.S.A., +1(415)492-9861, for further information.
*/
/* PostScript language interface to shading */
#include "memory_.h"
#include "ghost.h"
#include "oper.h"
#include "gscolor3.h"
#include "gscspace.h"
#include "gscolor2.h" /* requires gscspace.h */
#include "gsfunc3.h"
#include "gsptype2.h"
#include "gsstruct.h" /* must precede gsshade.h */
#include "gsshade.h"
#include "gsuid.h"
#include "gscie.h"
#include "stream.h" /* for files.h */
#include "files.h"
#include "ialloc.h"
#include "idict.h"
#include "idparam.h"
#include "ifunc.h"
#include "igstate.h"
#include "ipcolor.h"
#include "store.h"
/* Forward references */
static int shading_param(const_os_ptr op, const gs_shading_t ** ppsh);
/* ---------------- Standard operators ---------------- */
/* - currentsmoothness <smoothness> */
static int
zcurrentsmoothness(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
push(1);
make_real(op, gs_currentsmoothness(igs));
return 0;
}
/* <smoothness> setsmoothness - */
static int
zsetsmoothness(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
double smoothness;
int code;
if (real_param(op, &smoothness) < 0)
return_op_typecheck(op);
if ((code = gs_setsmoothness(igs, smoothness)) < 0)
return code;
pop(1);
return 0;
}
/* <shading> .shfill - */
static int
zshfill(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
const gs_shading_t *psh;
int code = shading_param(op, &psh);
if (code < 0 || (code = gs_shfill(igs, psh)) < 0)
return code;
pop(1);
return 0;
}
/* ------ Non-standard operators ------ */
/* <pattern> <matrix> <shading> .buildshadingpattern <pattern> <instance> */
static int
zbuildshadingpattern(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
os_ptr op2 = op - 2;
gs_matrix mat;
gs_pattern2_template_t templat;
int_pattern *pdata;
gs_client_color cc_instance;
int code;
check_type(*op2, t_dictionary);
check_dict_read(*op2);
gs_pattern2_init(&templat);
if ((code = read_matrix(imemory, op - 1, &mat)) < 0 ||
(code = dict_uid_param(op2, &templat.uid, 1, imemory, i_ctx_p)) != 1 ||
(code = shading_param(op, &templat.Shading)) < 0 ||
(code = int_pattern_alloc(&pdata, op2, imemory)) < 0
)
return_error((code < 0 ? code : e_rangecheck));
templat.client_data = pdata;
code = gs_make_pattern(&cc_instance,
(const gs_pattern_template_t *)&templat,
&mat, igs, imemory);
if (code < 0) {
ifree_object(pdata, "int_pattern");
return code;
}
make_istruct(op - 1, a_readonly, cc_instance.pattern);
pop(1);
return code;
}
/* ------ Internal procedures ------ */
/* Get a shading parameter. */
static int
shading_param(const_os_ptr op, const gs_shading_t ** ppsh)
{ /*
* Since shadings form a subclass hierarchy, we currently have
* no way to check whether a structure is actually a shading.
*/
if (!r_is_struct(op) ||
r_has_masked_attrs(op, a_executable | a_execute, a_all)
)
return_error(e_typecheck);
*ppsh = (gs_shading_t *) op->value.pstruct;
return 0;
}
/* ---------------- Shading dictionaries ---------------- */
/* ------ Common code ------ */
extern_st(st_color_space);
typedef int (*build_shading_proc_t)
(i_ctx_t *i_ctx_p, const ref *op, const gs_shading_params_t *params,
gs_shading_t **ppsh, gs_memory_t *mem);
/* Operators */
/* Common framework for building shadings. */
static int
build_shading(i_ctx_t *i_ctx_p, build_shading_proc_t proc)
{
os_ptr op = osp;
int code;
float box[4];
gs_shading_params_t params;
gs_shading_t *psh;
ref *pvalue;
check_type(*op, t_dictionary);
params.ColorSpace = 0;
params.cie_joint_caches = 0;
params.Background = 0;
/* Collect parameters common to all shading types. */
{
gs_color_space *pcs = gs_currentcolorspace(igs);
int num_comp = gs_color_space_num_components(pcs);
if (num_comp < 0) { /* Pattern color space */
gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "ColorSpace");
return_error(e_typecheck);
}
params.ColorSpace = pcs;
rc_increment_cs(pcs);
if (dict_find_string(op, "Background", &pvalue) > 0) {
gs_client_color *pcc =
ialloc_struct(gs_client_color, &st_client_color,
"build_shading");
if (pcc == 0) {
code = gs_note_error(e_VMerror);
goto fail;
}
pcc->pattern = 0;
params.Background = pcc;
code = dict_floats_param(imemory, op, "Background",
gs_color_space_num_components(pcs),
pcc->paint.values, NULL);
if (code < 0) {
gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "Background");
goto fail;
}
}
}
if (dict_find_string(op, "BBox", &pvalue) <= 0)
params.have_BBox = false;
else if ((code = dict_floats_param(imemory, op, "BBox",
4, box, NULL)) == 4) {
/* Adobe Interpreters accept denormalised BBox - bug 688937 */
if (box[0] <= box[2]) {
params.BBox.p.x = box[0];
params.BBox.q.x = box[2];
} else {
params.BBox.p.x = box[2];
params.BBox.q.x = box[0];
}
if (box[1] <= box[3]) {
params.BBox.p.y = box[1];
params.BBox.q.y = box[3];
} else {
params.BBox.p.y = box[3];
params.BBox.q.y = box[1];
}
params.have_BBox = true;
} else {
gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "BBox");
goto fail;
}
code = dict_bool_param(op, "AntiAlias", false, ¶ms.AntiAlias);
if (code < 0) {
gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "AntiAlias");
goto fail;
}
/* Finish building the shading. */
code = (*proc)(i_ctx_p, op, ¶ms, &psh, imemory);
if (code < 0)
goto fail;
if (gx_color_space_needs_cie_caches(psh->params.ColorSpace)) {
rc_decrement(psh->params.cie_joint_caches, "build_shading");
psh->params.cie_joint_caches = gx_currentciecaches(igs);
rc_increment(psh->params.cie_joint_caches);
}
make_istruct_new(op, 0, psh);
return code;
fail:
gs_free_object(imemory, params.Background, "Background");
if (params.ColorSpace) {
rc_decrement_only_cs(params.ColorSpace, "build_shading");
}
return (code < 0 ? code : gs_note_error(e_rangecheck));
}
/* Collect a Function value. */
static int
build_shading_function(i_ctx_t *i_ctx_p, const ref * op, gs_function_t ** ppfn,
int num_inputs, gs_memory_t *mem, const float *shading_domain)
{
ref *pFunction;
int code;
*ppfn = 0;
if (dict_find_string(op, "Function", &pFunction) <= 0)
return 0;
if (r_is_array(pFunction)) {
uint size = r_size(pFunction);
gs_function_t **Functions;
uint i;
gs_function_AdOt_params_t params;
check_read(*pFunction);
if (size == 0)
return_error(e_rangecheck);
code = alloc_function_array(size, &Functions, mem);
if (code < 0)
return code;
for (i = 0; i < size; ++i) {
ref rsubfn;
array_get(imemory, pFunction, (long)i, &rsubfn);
code = fn_build_function(i_ctx_p, &rsubfn, &Functions[i], mem,
shading_domain, num_inputs);
if (code < 0)
break;
}
params.m = num_inputs;
params.Domain = 0;
params.n = size;
params.Range = 0;
params.Functions = (const gs_function_t * const *)Functions;
if (code >= 0)
code = gs_function_AdOt_init(ppfn, ¶ms, mem);
if (code < 0)
gs_function_AdOt_free_params(¶ms, mem);
} else {
code = fn_build_function(i_ctx_p, pFunction, ppfn, mem,
shading_domain, num_inputs);
if (code < 0)
return code;
if ((*ppfn)->params.m != num_inputs) {
gs_function_free(*ppfn, true, mem);
return_error(e_rangecheck);
}
}
return code;
}
/* According to PLRM 3rd ed, p. 264 "indexed color space is not
* allowed in any shading whose color values are generated by a function;
* this applies to any shading dictionary that contains a Function entry."
* Adobe interpreters follow PLRM in this respect and we follow them.
*/
static int
check_indexed_vs_function(i_ctx_t *i_ctx_p, const ref *op,
const gs_color_space *pcs, const gs_function_t *funct)
{ if (funct && gs_color_space_get_index(pcs) == gs_color_space_index_Indexed) {
static const char fn[] = "Function";
ref *f;
if (dict_find_string(op, fn, &f) > 0)
gs_errorinfo_put_pair(i_ctx_p, fn, sizeof(fn) - 1, f);
return_error(e_typecheck); /* CET 12-14a */
}
return 0;
}
/* ------ Build shadings ------ */
/* Build a ShadingType 1 (Function-based) shading. */
static int
build_shading_1(i_ctx_t *i_ctx_p, const ref * op, const gs_shading_params_t * pcommon,
gs_shading_t ** ppsh, gs_memory_t *mem)
{
gs_shading_Fb_params_t params;
int code;
static const float default_Domain[4] = {0, 1, 0, 1};
ref *pmatrix;
*(gs_shading_params_t *)¶ms = *pcommon;
gs_make_identity(¶ms.Matrix);
params.Function = 0;
code = dict_floats_param_errorinfo(i_ctx_p, op, "Domain",
4, params.Domain, default_Domain);
if (code < 0)
goto out;
if (params.Domain[0] > params.Domain[1] || params.Domain[2] > params.Domain[3]) {
gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "Domain");
code = gs_note_error(e_rangecheck);
goto out; /* CPSI 3017 and CET 12-14b reject un-normalised domain */
}
if (dict_find_string(op, "Matrix", &pmatrix) > 0 ) {
code = read_matrix(imemory, pmatrix, ¶ms.Matrix);
if (code < 0) {
gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "Matrix");
goto out;
}
}
code = build_shading_function(i_ctx_p, op, ¶ms.Function, 2, mem, params.Domain);
if (code < 0)
goto out;
if (params.Function == 0) { /* Function is required */
code = gs_note_error(e_undefined);
gs_errorinfo_put_pair_from_dict(i_ctx_p, op, "Function");
goto out;
}
code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function);
if (code < 0)
goto out;
code = gs_shading_Fb_init(ppsh, ¶ms, mem);
out:;
if (code < 0 && params.Function)
gs_free_object(mem, params.Function, "Function");
return code;
}
/* <dict> .buildshading1 <shading_struct> */
static int
zbuildshading1(i_ctx_t *i_ctx_p)
{
return build_shading(i_ctx_p, build_shading_1);
}
/* Collect parameters for an Axial or Radial shading. */
static int
build_directional_shading(i_ctx_t *i_ctx_p, const ref * op, float *Coords, int num_Coords,
float Domain[2], gs_function_t ** pFunction,
bool Extend[2], gs_memory_t *mem)
{
int code = dict_floats_param(imemory, op, "Coords",
num_Coords, Coords, NULL);
static const float default_Domain[2] = {0, 1};
ref *pExtend;
*pFunction = 0;
if (code < 0 ||
(code = dict_floats_param_errorinfo(i_ctx_p, op, "Domain", 2, Domain,
default_Domain)) < 0 ||
(code = build_shading_function(i_ctx_p, op, pFunction, 1, mem, Domain)) < 0
)
return code;
if (!*pFunction)
return_error(e_undefined);
if (dict_find_string(op, "Extend", &pExtend) <= 0)
Extend[0] = Extend[1] = false;
else {
ref E0, E1;
if (!r_is_array(pExtend))
return_error(e_typecheck);
else if (r_size(pExtend) != 2)
return_error(e_rangecheck);
else if ((array_get(imemory, pExtend, 0L, &E0),
!r_has_type(&E0, t_boolean)) ||
(array_get(imemory, pExtend, 1L, &E1),
!r_has_type(&E1, t_boolean))
)
return_error(e_typecheck);
Extend[0] = E0.value.boolval, Extend[1] = E1.value.boolval;
}
return 0;
}
/* Build a ShadingType 2 (Axial) shading. */
static int
build_shading_2(i_ctx_t *i_ctx_p, const ref * op, const gs_shading_params_t * pcommon,
gs_shading_t ** ppsh, gs_memory_t *mem)
{
gs_shading_A_params_t params;
int code;
*(gs_shading_params_t *)¶ms = *pcommon;
if ((code = build_directional_shading(i_ctx_p, op, params.Coords, 4,
params.Domain, ¶ms.Function,
params.Extend, mem)) < 0 ||
(code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = gs_shading_A_init(ppsh, ¶ms, mem)) < 0
) {
gs_free_object(mem, params.Function, "Function");
}
return code;
}
/* <dict> .buildshading2 <shading_struct> */
static int
zbuildshading2(i_ctx_t *i_ctx_p)
{
return build_shading(i_ctx_p, build_shading_2);
}
/* Build a ShadingType 3 (Radial) shading. */
static int
build_shading_3(i_ctx_t *i_ctx_p, const ref * op, const gs_shading_params_t * pcommon,
gs_shading_t ** ppsh, gs_memory_t *mem)
{
gs_shading_R_params_t params;
int code;
*(gs_shading_params_t *)¶ms = *pcommon;
if ((code = build_directional_shading(i_ctx_p, op, params.Coords, 6,
params.Domain, ¶ms.Function,
params.Extend, mem)) < 0 ||
(code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = gs_shading_R_init(ppsh, ¶ms, mem)) < 0
) {
gs_free_object(mem, params.Function, "Function");
}
if (params.Function == 0) /* Function is required */
return_error(e_undefined);
return code;
}
/* <dict> .buildshading3 <shading_struct> */
static int
zbuildshading3(i_ctx_t *i_ctx_p)
{
return build_shading(i_ctx_p, build_shading_3);
}
/* Collect parameters for a mesh shading. */
static int
build_mesh_shading(i_ctx_t *i_ctx_p, const ref * op,
gs_shading_mesh_params_t * params,
float **pDecode, gs_function_t ** pFunction,
gs_memory_t *mem)
{
int code;
float *data = 0;
ref *pDataSource;
*pDecode = 0;
*pFunction = 0;
if (dict_find_string(op, "DataSource", &pDataSource) <= 0)
return_error(e_rangecheck);
if (r_is_array(pDataSource)) {
uint size = r_size(pDataSource);
data = (float *)gs_alloc_byte_array(mem, size, sizeof(float),
"build_mesh_shading");
if (data == 0)
return_error(e_VMerror);
code = process_float_array(mem, pDataSource, size, data);
if (code < 0) {
gs_free_object(mem, data, "build_mesh_shading");
return code;
}
data_source_init_floats(¶ms->DataSource, data, size);
} else
switch (r_type(pDataSource)) {
case t_file: {
stream *s;
check_read_file(i_ctx_p, s, pDataSource);
data_source_init_stream(¶ms->DataSource, s);
break;
}
case t_string:
check_read(*pDataSource);
data_source_init_string2(¶ms->DataSource,
pDataSource->value.bytes,
r_size(pDataSource));
break;
default:
return_error(e_typecheck);
}
code = build_shading_function(i_ctx_p, op, pFunction, 1, mem, NULL);
if (code < 0) {
gs_free_object(mem, data, "build_mesh_shading");
return code;
}
if (data_source_is_array(params->DataSource)) {
params->BitsPerCoordinate = 0;
params->BitsPerComponent = 0;
} else {
int num_decode = 4 +
(*pFunction != 0 ? 1 :
gs_color_space_num_components(params->ColorSpace)) * 2;
if ((code = dict_int_param(op, "BitsPerCoordinate", 1, 32, 0,
¶ms->BitsPerCoordinate)) >= 0 &&
(code = dict_int_param(op, "BitsPerComponent", 1, 16, 0,
¶ms->BitsPerComponent)) >= 0
) {
*pDecode = (float *)
gs_alloc_byte_array(mem, num_decode, sizeof(float),
"build_mesh_shading");
if (*pDecode == 0)
code = gs_note_error(e_VMerror);
else {
code = dict_floats_param(mem, op, "Decode", num_decode, *pDecode, NULL);
if (code < 0) {
gs_free_object(mem, *pDecode, "build_mesh_shading");
*pDecode = 0;
}
}
}
}
if (code < 0) {
if (*pFunction != 0) {
gs_function_free(*pFunction, true, mem);
*pFunction = 0;
}
gs_free_object(mem, data, "build_mesh_shading");
}
return code;
}
/* Collect the BitsPerFlag parameter, if relevant. */
static int
flag_bits_param(const ref * op, const gs_shading_mesh_params_t * params,
int *pBitsPerFlag)
{
if (data_source_is_array(params->DataSource)) {
*pBitsPerFlag = 0;
return 0;
} else {
return dict_int_param(op, "BitsPerFlag", 2, 8, 0, pBitsPerFlag);
}
}
/* Build a ShadingType 4 (Free-form Gouraud triangle mesh) shading. */
static int
build_shading_4(i_ctx_t *i_ctx_p, const ref * op, const gs_shading_params_t * pcommon,
gs_shading_t ** ppsh, gs_memory_t *mem)
{
gs_shading_FfGt_params_t params;
int code;
*(gs_shading_params_t *)¶ms = *pcommon;
if ((code =
build_mesh_shading(i_ctx_p, op, (gs_shading_mesh_params_t *)¶ms,
¶ms.Decode, ¶ms.Function, mem)) < 0 ||
(code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = flag_bits_param(op, (gs_shading_mesh_params_t *)¶ms,
¶ms.BitsPerFlag)) < 0 ||
(code = gs_shading_FfGt_init(ppsh, ¶ms, mem)) < 0
) {
gs_free_object(mem, params.Function, "Function");
gs_free_object(mem, params.Decode, "Decode");
}
return code;
}
/* <dict> .buildshading4 <shading_struct> */
static int
zbuildshading4(i_ctx_t *i_ctx_p)
{
return build_shading(i_ctx_p, build_shading_4);
}
/* Build a ShadingType 5 (Lattice-form Gouraud triangle mesh) shading. */
static int
build_shading_5(i_ctx_t *i_ctx_p, const ref * op, const gs_shading_params_t * pcommon,
gs_shading_t ** ppsh, gs_memory_t *mem)
{
gs_shading_LfGt_params_t params;
int code;
*(gs_shading_params_t *)¶ms = *pcommon;
if ((code =
build_mesh_shading(i_ctx_p, op, (gs_shading_mesh_params_t *)¶ms,
¶ms.Decode, ¶ms.Function, mem)) < 0 ||
(code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = dict_int_param(op, "VerticesPerRow", 2, max_int, 0,
¶ms.VerticesPerRow)) < 0 ||
(code = gs_shading_LfGt_init(ppsh, ¶ms, mem)) < 0
) {
gs_free_object(mem, params.Function, "Function");
gs_free_object(mem, params.Decode, "Decode");
}
return code;
}
/* <dict> .buildshading5 <shading_struct> */
static int
zbuildshading5(i_ctx_t *i_ctx_p)
{
return build_shading(i_ctx_p, build_shading_5);
}
/* Build a ShadingType 6 (Coons patch mesh) shading. */
static int
build_shading_6(i_ctx_t *i_ctx_p, const ref * op, const gs_shading_params_t * pcommon,
gs_shading_t ** ppsh, gs_memory_t *mem)
{
gs_shading_Cp_params_t params;
int code;
*(gs_shading_params_t *)¶ms = *pcommon;
if ((code =
build_mesh_shading(i_ctx_p, op, (gs_shading_mesh_params_t *)¶ms,
¶ms.Decode, ¶ms.Function, mem)) < 0 ||
(code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = flag_bits_param(op, (gs_shading_mesh_params_t *)¶ms,
¶ms.BitsPerFlag)) < 0 ||
(code = gs_shading_Cp_init(ppsh, ¶ms, mem)) < 0
) {
gs_free_object(mem, params.Function, "Function");
gs_free_object(mem, params.Decode, "Decode");
}
return code;
}
/* <dict> .buildshading6 <shading_struct> */
static int
zbuildshading6(i_ctx_t *i_ctx_p)
{
return build_shading(i_ctx_p, build_shading_6);
}
/* Build a ShadingType 7 (Tensor product patch mesh) shading. */
static int
build_shading_7(i_ctx_t *i_ctx_p, const ref * op, const gs_shading_params_t * pcommon,
gs_shading_t ** ppsh, gs_memory_t *mem)
{
gs_shading_Tpp_params_t params;
int code;
*(gs_shading_params_t *)¶ms = *pcommon;
if ((code =
build_mesh_shading(i_ctx_p, op, (gs_shading_mesh_params_t *)¶ms,
¶ms.Decode, ¶ms.Function, mem)) < 0 ||
(code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = flag_bits_param(op, (gs_shading_mesh_params_t *)¶ms,
¶ms.BitsPerFlag)) < 0 ||
(code = gs_shading_Tpp_init(ppsh, ¶ms, mem)) < 0
) {
gs_free_object(mem, params.Function, "Function");
gs_free_object(mem, params.Decode, "Decode");
}
return code;
}
/* <dict> .buildshading7 <shading_struct> */
static int
zbuildshading7(i_ctx_t *i_ctx_p)
{
return build_shading(i_ctx_p, build_shading_7);
}
/* ------ Initialization procedure ------ */
const op_def zshade_op_defs[] =
{
op_def_begin_ll3(),
{"0currentsmoothness", zcurrentsmoothness},
{"1setsmoothness", zsetsmoothness},
{"1.shfill", zshfill},
{"1.buildshading1", zbuildshading1},
{"1.buildshading2", zbuildshading2},
{"1.buildshading3", zbuildshading3},
{"1.buildshading4", zbuildshading4},
{"1.buildshading5", zbuildshading5},
{"1.buildshading6", zbuildshading6},
{"1.buildshading7", zbuildshading7},
{"3.buildshadingpattern", zbuildshadingpattern},
op_def_end(0)
};
|