1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
297 continue;
298
299 if (!(IS_FINITE(slope))) {
300 continue;
301 }
302
303 if (dY1 < 0.0)
304 y1 = 0;
305 else {
306 val0 = dY1 + 1;
307 SAT32(y1);
308 }
309
310 val0 = dY2;
311 SAT32(y2);
312
313 if (y2 >= dstHeight)
314 y2 = (mlib_s32) (dstHeight - 1);
315
316 x += slope * (y1 - dY1);
317 #ifdef __SUNPRO_C
318 #pragma pipeloop(0)
319 #endif /* __SUNPRO_C */
320 for (j = y1; j <= y2; j++) {
321 val0 = x;
322 SAT32(t);
323 leftEdges[j] = (t >= x) ? t : ++t;
324
325 if (x >= MLIB_S32_MAX)
326 leftEdges[j] = MLIB_S32_MAX;
327 x += slope;
328 }
329 }
330
331 for (i = 0; i < 2; i++) {
332 mlib_d64 dY1 = coords[(topIdx + i) & 0x3][1];
333 mlib_d64 dX1 = coords[(topIdx + i) & 0x3][0];
334 mlib_d64 dY2 = coords[(topIdx + i + 1) & 0x3][1];
335 mlib_d64 dX2 = coords[(topIdx + i + 1) & 0x3][0];
336 mlib_d64 x = dX1, slope = (dX2 - dX1) / (dY2 - dY1);
337 mlib_s32 y1;
338 mlib_s32 y2;
339
341 continue;
342
343 if (!(IS_FINITE(slope))) {
344 continue;
345 }
346
347 if (dY1 < 0.0)
348 y1 = 0;
349 else {
350 val0 = dY1 + 1;
351 SAT32(y1);
352 }
353
354 val0 = dY2;
355 SAT32(y2);
356
357 if (y2 >= dstHeight)
358 y2 = (mlib_s32) (dstHeight - 1);
359
360 x += slope * (y1 - dY1);
361 #ifdef __SUNPRO_C
362 #pragma pipeloop(0)
363 #endif /* __SUNPRO_C */
364 for (j = y1; j <= y2; j++) {
365 val0 = x;
366 SAT32(rightEdges[j]);
367 x += slope;
368 }
369
370 bot = y2;
371 }
372
373 {
374 mlib_d64 dxCl = xClip * div;
375 mlib_d64 dyCl = yClip * div;
376 mlib_d64 dwCl = wClip * div;
377 mlib_d64 dhCl = hClip * div;
378
379 mlib_s32 xCl = (mlib_s32) (xClip + delta);
380 mlib_s32 yCl = (mlib_s32) (yClip + delta);
381 mlib_s32 wCl = (mlib_s32) (wClip + delta);
382 mlib_s32 hCl = (mlib_s32) (hClip + delta);
383
385 * mlib_s32 xCl = (mlib_s32)(xClip + delta);
386 * mlib_s32 yCl = (mlib_s32)(yClip + delta);
387 * mlib_s32 wCl = (mlib_s32)(wClip);
388 * mlib_s32 hCl = (mlib_s32)(hClip);
389 */
390
391 if (edge == MLIB_EDGE_SRC_PADDED) {
392 xCl = kw1;
393 yCl = kh1;
394 wCl = (mlib_s32) (srcWidth - ((kw - 1) - kw1));
395 hCl = (mlib_s32) (srcHeight - ((kh - 1) - kh1));
396 }
397
398 div = 1.0 / div;
399
400 sdx = (mlib_s32) (a2 * div * (1 << shiftx));
401 sdy = (mlib_s32) (c2 * div * (1 << shifty));
402
403 if (div > 0) {
404
405 #ifdef __SUNPRO_C
406 #pragma pipeloop(0)
407 #endif /* __SUNPRO_C */
408 for (i = top; i <= bot; i++) {
409 mlib_s32 xLeft = leftEdges[i];
410 mlib_s32 xRight = rightEdges[i];
411 mlib_s32 xs, ys, x_e, y_e, x_s, y_s;
412 mlib_d64 dxs, dys, dxe, dye;
413 mlib_d64 xl, ii, xr;
414
415 xLeft = (xLeft < 0) ? 0 : xLeft;
416 xRight = (xRight >= dstWidth) ? (mlib_s32) (dstWidth - 1) : xRight;
417
418 xl = xLeft + 0.5;
419 ii = i + 0.5;
420 xr = xRight + 0.5;
421 dxs = xl * a2 + ii * b2 + tx2;
422 dys = xl * c2 + ii * d2 + ty2;
423
424 if ((dxs < dxCl) || (dxs >= dwCl) || (dys < dyCl) || (dys >= dhCl)) {
425 dxs += dx;
426 dys += dy;
427 xLeft++;
471
472 if ((y_e < yCl) || (y_e >= hCl)) {
473 if (sdy > 0)
474 sdy -= 1;
475 else
476 sdy += 1;
477 }
478 }
479
480 leftEdges[i] = xLeft;
481 rightEdges[i] = xRight;
482 xStarts[i] = xs;
483 yStarts[i] = ys;
484
485 if ((xRight - xLeft + 1) > max_xsize)
486 max_xsize = (xRight - xLeft + 1);
487 }
488 }
489 else {
490
491 #ifdef __SUNPRO_C
492 #pragma pipeloop(0)
493 #endif /* __SUNPRO_C */
494 for (i = top; i <= bot; i++) {
495 mlib_s32 xLeft = leftEdges[i];
496 mlib_s32 xRight = rightEdges[i];
497 mlib_s32 xs, ys, x_e, y_e, x_s, y_s;
498 mlib_d64 dxs, dys, dxe, dye;
499 mlib_d64 xl, ii, xr;
500
501 xLeft = (xLeft < 0) ? 0 : xLeft;
502 xRight = (xRight >= dstWidth) ? (mlib_s32) (dstWidth - 1) : xRight;
503
504 xl = xLeft + 0.5;
505 ii = i + 0.5;
506 xr = xRight + 0.5;
507 dxs = xl * a2 + ii * b2 + tx2;
508 dys = xl * c2 + ii * d2 + ty2;
509
510 if ((dxs > dxCl) || (dxs <= dwCl) || (dys > dyCl) || (dys <= dhCl)) {
511 dxs += dx;
512 dys += dy;
513 xLeft++;
|
1 /*
2 * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
297 continue;
298
299 if (!(IS_FINITE(slope))) {
300 continue;
301 }
302
303 if (dY1 < 0.0)
304 y1 = 0;
305 else {
306 val0 = dY1 + 1;
307 SAT32(y1);
308 }
309
310 val0 = dY2;
311 SAT32(y2);
312
313 if (y2 >= dstHeight)
314 y2 = (mlib_s32) (dstHeight - 1);
315
316 x += slope * (y1 - dY1);
317 for (j = y1; j <= y2; j++) {
318 val0 = x;
319 SAT32(t);
320 leftEdges[j] = (t >= x) ? t : ++t;
321
322 if (x >= MLIB_S32_MAX)
323 leftEdges[j] = MLIB_S32_MAX;
324 x += slope;
325 }
326 }
327
328 for (i = 0; i < 2; i++) {
329 mlib_d64 dY1 = coords[(topIdx + i) & 0x3][1];
330 mlib_d64 dX1 = coords[(topIdx + i) & 0x3][0];
331 mlib_d64 dY2 = coords[(topIdx + i + 1) & 0x3][1];
332 mlib_d64 dX2 = coords[(topIdx + i + 1) & 0x3][0];
333 mlib_d64 x = dX1, slope = (dX2 - dX1) / (dY2 - dY1);
334 mlib_s32 y1;
335 mlib_s32 y2;
336
338 continue;
339
340 if (!(IS_FINITE(slope))) {
341 continue;
342 }
343
344 if (dY1 < 0.0)
345 y1 = 0;
346 else {
347 val0 = dY1 + 1;
348 SAT32(y1);
349 }
350
351 val0 = dY2;
352 SAT32(y2);
353
354 if (y2 >= dstHeight)
355 y2 = (mlib_s32) (dstHeight - 1);
356
357 x += slope * (y1 - dY1);
358 for (j = y1; j <= y2; j++) {
359 val0 = x;
360 SAT32(rightEdges[j]);
361 x += slope;
362 }
363
364 bot = y2;
365 }
366
367 {
368 mlib_d64 dxCl = xClip * div;
369 mlib_d64 dyCl = yClip * div;
370 mlib_d64 dwCl = wClip * div;
371 mlib_d64 dhCl = hClip * div;
372
373 mlib_s32 xCl = (mlib_s32) (xClip + delta);
374 mlib_s32 yCl = (mlib_s32) (yClip + delta);
375 mlib_s32 wCl = (mlib_s32) (wClip + delta);
376 mlib_s32 hCl = (mlib_s32) (hClip + delta);
377
379 * mlib_s32 xCl = (mlib_s32)(xClip + delta);
380 * mlib_s32 yCl = (mlib_s32)(yClip + delta);
381 * mlib_s32 wCl = (mlib_s32)(wClip);
382 * mlib_s32 hCl = (mlib_s32)(hClip);
383 */
384
385 if (edge == MLIB_EDGE_SRC_PADDED) {
386 xCl = kw1;
387 yCl = kh1;
388 wCl = (mlib_s32) (srcWidth - ((kw - 1) - kw1));
389 hCl = (mlib_s32) (srcHeight - ((kh - 1) - kh1));
390 }
391
392 div = 1.0 / div;
393
394 sdx = (mlib_s32) (a2 * div * (1 << shiftx));
395 sdy = (mlib_s32) (c2 * div * (1 << shifty));
396
397 if (div > 0) {
398
399 for (i = top; i <= bot; i++) {
400 mlib_s32 xLeft = leftEdges[i];
401 mlib_s32 xRight = rightEdges[i];
402 mlib_s32 xs, ys, x_e, y_e, x_s, y_s;
403 mlib_d64 dxs, dys, dxe, dye;
404 mlib_d64 xl, ii, xr;
405
406 xLeft = (xLeft < 0) ? 0 : xLeft;
407 xRight = (xRight >= dstWidth) ? (mlib_s32) (dstWidth - 1) : xRight;
408
409 xl = xLeft + 0.5;
410 ii = i + 0.5;
411 xr = xRight + 0.5;
412 dxs = xl * a2 + ii * b2 + tx2;
413 dys = xl * c2 + ii * d2 + ty2;
414
415 if ((dxs < dxCl) || (dxs >= dwCl) || (dys < dyCl) || (dys >= dhCl)) {
416 dxs += dx;
417 dys += dy;
418 xLeft++;
462
463 if ((y_e < yCl) || (y_e >= hCl)) {
464 if (sdy > 0)
465 sdy -= 1;
466 else
467 sdy += 1;
468 }
469 }
470
471 leftEdges[i] = xLeft;
472 rightEdges[i] = xRight;
473 xStarts[i] = xs;
474 yStarts[i] = ys;
475
476 if ((xRight - xLeft + 1) > max_xsize)
477 max_xsize = (xRight - xLeft + 1);
478 }
479 }
480 else {
481
482 for (i = top; i <= bot; i++) {
483 mlib_s32 xLeft = leftEdges[i];
484 mlib_s32 xRight = rightEdges[i];
485 mlib_s32 xs, ys, x_e, y_e, x_s, y_s;
486 mlib_d64 dxs, dys, dxe, dye;
487 mlib_d64 xl, ii, xr;
488
489 xLeft = (xLeft < 0) ? 0 : xLeft;
490 xRight = (xRight >= dstWidth) ? (mlib_s32) (dstWidth - 1) : xRight;
491
492 xl = xLeft + 0.5;
493 ii = i + 0.5;
494 xr = xRight + 0.5;
495 dxs = xl * a2 + ii * b2 + tx2;
496 dys = xl * c2 + ii * d2 + ty2;
497
498 if ((dxs > dxCl) || (dxs <= dwCl) || (dys > dyCl) || (dys <= dhCl)) {
499 dxs += dx;
500 dys += dy;
501 xLeft++;
|