1 7 8 package java.awt; 9 10 import java.awt.image.BufferedImage ; 11 import java.awt.image.Raster ; 12 import java.awt.image.WritableRaster ; 13 import java.awt.image.ColorModel ; 14 import java.awt.image.DirectColorModel ; 15 import java.awt.image.IndexColorModel ; 16 import java.awt.geom.AffineTransform ; 17 import java.awt.geom.NoninvertibleTransformException ; 18 import java.lang.ref.WeakReference ; 19 import sun.awt.image.IntegerInterleavedRaster; 20 import sun.awt.image.ByteInterleavedRaster; 21 22 abstract class TexturePaintContext implements PaintContext { 23 public static ColorModel xrgbmodel = 24 new DirectColorModel (24, 0xff0000, 0xff00, 0xff); 25 public static ColorModel argbmodel = ColorModel.getRGBdefault(); 26 27 ColorModel colorModel; 28 int bWidth; 29 int bHeight; 30 int maxWidth; 31 32 WritableRaster outRas; 33 34 double xOrg; 35 double yOrg; 36 double incXAcross; 37 double incYAcross; 38 double incXDown; 39 double incYDown; 40 41 int colincx; 42 int colincy; 43 int colincxerr; 44 int colincyerr; 45 int rowincx; 46 int rowincy; 47 int rowincxerr; 48 int rowincyerr; 49 50 public static PaintContext getContext(BufferedImage bufImg, 51 AffineTransform xform, 52 RenderingHints hints, 53 Rectangle devBounds) { 54 WritableRaster raster = bufImg.getRaster(); 55 ColorModel cm = bufImg.getColorModel(); 56 int maxw = devBounds.width; 57 Object val = hints.get(hints.KEY_INTERPOLATION); 58 boolean filter = 59 (val == null 60 ? (hints.get(hints.KEY_RENDERING) == hints.VALUE_RENDER_QUALITY) 61 : (val != hints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)); 62 if (raster instanceof IntegerInterleavedRaster && 63 (!filter || isFilterableDCM(cm))) 64 { 65 IntegerInterleavedRaster iir = (IntegerInterleavedRaster) raster; 66 if (iir.getNumDataElements() == 1 && iir.getPixelStride() == 1) { 67 return new Int(iir, cm, xform, maxw, filter); 68 } 69 } else if (raster instanceof ByteInterleavedRaster) { 70 ByteInterleavedRaster bir = (ByteInterleavedRaster) raster; 71 if (bir.getNumDataElements() == 1 && bir.getPixelStride() == 1) { 72 if (filter) { 73 if (isFilterableICM(cm)) { 74 return new ByteFilter(bir, cm, xform, maxw); 75 } 76 } else { 77 return new Byte (bir, cm, xform, maxw); 78 } 79 } 80 } 81 return new Any(raster, cm, xform, maxw, filter); 82 } 83 84 public static boolean isFilterableICM(ColorModel cm) { 85 if (cm instanceof IndexColorModel ) { 86 IndexColorModel icm = (IndexColorModel ) cm; 87 if (icm.getMapSize() <= 256) { 88 return true; 89 } 90 } 91 return false; 92 } 93 94 public static boolean isFilterableDCM(ColorModel cm) { 95 if (cm instanceof DirectColorModel ) { 96 DirectColorModel dcm = (DirectColorModel ) cm; 97 return (isMaskOK(dcm.getAlphaMask(), true) && 98 isMaskOK(dcm.getRedMask(), false) && 99 isMaskOK(dcm.getGreenMask(), false) && 100 isMaskOK(dcm.getBlueMask(), false)); 101 } 102 return false; 103 } 104 105 public static boolean isMaskOK(int mask, boolean canbezero) { 106 if (canbezero && mask == 0) { 107 return true; 108 } 109 return (mask == 0xff || 110 mask == 0xff00 || 111 mask == 0xff0000 || 112 mask == 0xff000000); 113 } 114 115 public static ColorModel getInternedColorModel(ColorModel cm) { 116 if (xrgbmodel == cm || xrgbmodel.equals(cm)) { 117 return xrgbmodel; 118 } 119 if (argbmodel == cm || argbmodel.equals(cm)) { 120 return argbmodel; 121 } 122 return cm; 123 } 124 125 TexturePaintContext(ColorModel cm, AffineTransform xform, 126 int bWidth, int bHeight, int maxw) { 127 this.colorModel = getInternedColorModel(cm); 128 this.bWidth = bWidth; 129 this.bHeight = bHeight; 130 this.maxWidth = maxw; 131 132 try { 133 xform = xform.createInverse(); 134 } catch (NoninvertibleTransformException e) { 135 xform.setToScale(0, 0); 136 } 137 this.incXAcross = mod(xform.getScaleX(), bWidth); 138 this.incYAcross = mod(xform.getShearY(), bHeight); 139 this.incXDown = mod(xform.getShearX(), bWidth); 140 this.incYDown = mod(xform.getScaleY(), bHeight); 141 this.xOrg = xform.getTranslateX(); 142 this.yOrg = xform.getTranslateY(); 143 this.colincx = (int) incXAcross; 144 this.colincy = (int) incYAcross; 145 this.colincxerr = fractAsInt(incXAcross); 146 this.colincyerr = fractAsInt(incYAcross); 147 this.rowincx = (int) incXDown; 148 this.rowincy = (int) incYDown; 149 this.rowincxerr = fractAsInt(incXDown); 150 this.rowincyerr = fractAsInt(incYDown); 151 152 } 153 154 static int fractAsInt(double d) { 155 return (int) ((d % 1.0) * Integer.MAX_VALUE); 156 } 157 158 static double mod(double num, double den) { 159 num = num % den; 160 if (num < 0) { 161 num += den; 162 if (num >= den) { 163 num = 0; 170 } 171 } 172 return num; 173 } 174 175 178 public void dispose() { 179 dropRaster(colorModel, outRas); 180 } 181 182 185 public ColorModel getColorModel() { 186 return colorModel; 187 } 188 189 195 public Raster getRaster(int x, int y, int w, int h) { 196 if (outRas == null || 197 outRas.getWidth() < w || 198 outRas.getHeight() < h) 199 { 200 outRas = makeRaster((h == 1 ? Math.max(w, maxWidth) : w), h); 202 } 203 double X = mod(xOrg + x * incXAcross + y * incXDown, bWidth); 204 double Y = mod(yOrg + x * incYAcross + y * incYDown, bHeight); 205 206 setRaster((int) X, (int) Y, fractAsInt(X), fractAsInt(Y), 207 w, h, bWidth, bHeight, 208 colincx, colincxerr, 209 colincy, colincyerr, 210 rowincx, rowincxerr, 211 rowincy, rowincyerr); 212 213 return outRas; 214 } 215 216 private static WeakReference xrgbRasRef; 217 private static WeakReference argbRasRef; 218 219 synchronized static WritableRaster makeRaster(ColorModel cm, 220 Raster srcRas, 221 int w, int h) 222 { 223 if (xrgbmodel == cm) { 224 if (xrgbRasRef != null) { 225 WritableRaster wr = (WritableRaster ) xrgbRasRef.get(); 226 if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) { 227 xrgbRasRef = null; 228 return wr; 229 } 230 } 231 if (w <= 32 && h <= 32) { 233 w = h = 32; 234 } 235 } else if (argbmodel == cm) { 236 if (argbRasRef != null) { 237 WritableRaster wr = (WritableRaster ) argbRasRef.get(); 238 if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) { 239 argbRasRef = null; 240 return wr; 241 } 242 } 243 if (w <= 32 && h <= 32) { 245 w = h = 32; 246 } 247 } 248 if (srcRas != null) { 249 return srcRas.createCompatibleWritableRaster(w, h); 250 } else { 251 return cm.createCompatibleWritableRaster(w, h); 252 } 253 } 254 255 synchronized static void dropRaster(ColorModel cm, Raster outRas) { 256 if (outRas == null) { 257 return; 258 } 259 if (xrgbmodel == cm) { 260 xrgbRasRef = new WeakReference (outRas); 261 } else if (argbmodel == cm) { 262 argbRasRef = new WeakReference (outRas); 263 } 264 } 265 266 private static WeakReference byteRasRef; 267 268 synchronized static WritableRaster makeByteRaster(Raster srcRas, 269 int w, int h) 270 { 271 if (byteRasRef != null) { 272 WritableRaster wr = (WritableRaster ) byteRasRef.get(); 273 if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) { 274 byteRasRef = null; 275 return wr; 276 } 277 } 278 if (w <= 32 && h <= 32) { 280 w = h = 32; 281 } 282 return srcRas.createCompatibleWritableRaster(w, h); 283 } 284 285 synchronized static void dropByteRaster(Raster outRas) { 286 if (outRas == null) { 287 return; 288 } 289 byteRasRef = new WeakReference (outRas); 290 } 291 292 public abstract WritableRaster makeRaster(int w, int h); 293 public abstract void setRaster(int x, int y, int xerr, int yerr, 294 int w, int h, int bWidth, int bHeight, 295 int colincx, int colincxerr, 296 int colincy, int colincyerr, 297 int rowincx, int rowincxerr, 298 int rowincy, int rowincyerr); 299 300 317 public static int blend(int rgbs[], int xmul, int ymul) { 318 xmul = (xmul >>> 19); 321 ymul = (ymul >>> 19); 322 int accumA, accumR, accumG, accumB; 323 accumA = accumR = accumG = accumB = 0; 324 for (int i = 0; i < 4; i++) { 325 int rgb = rgbs[i]; 326 xmul = (1<<12) - xmul; 330 if ((i & 1) == 0) { 331 ymul = (1<<12) - ymul; 332 } 333 int factor = xmul * ymul; 336 if (factor != 0) { 337 accumA += (((rgb >>> 24) ) * factor); 341 accumR += (((rgb >>> 16) & 0xff) * factor); 342 accumG += (((rgb >>> 8) & 0xff) * factor); 343 accumB += (((rgb ) & 0xff) * factor); 344 } 345 } 346 return ((((accumA + (1<<23)) >>> 24) << 24) | 347 (((accumR + (1<<23)) >>> 24) << 16) | 348 (((accumG + (1<<23)) >>> 24) << 8) | 349 (((accumB + (1<<23)) >>> 24) )); 350 } 351 352 static class Int extends TexturePaintContext { 353 IntegerInterleavedRaster srcRas; 354 int inData[]; 355 int inOff; 356 int inSpan; 357 int outData[]; 358 int outOff; 359 int outSpan; 360 boolean filter; 361 362 public Int(IntegerInterleavedRaster srcRas, ColorModel cm, 363 AffineTransform xform, int maxw, boolean filter) 364 { 365 super(cm, xform, srcRas.getWidth(), srcRas.getHeight(), maxw); 366 this.srcRas = srcRas; 367 this.inData = srcRas.getDataStorage(); 368 this.inSpan = srcRas.getScanlineStride(); 369 this.inOff = srcRas.getDataOffset(0); 370 this.filter = filter; 371 } 372 373 public WritableRaster makeRaster(int w, int h) { 374 WritableRaster ras = makeRaster(colorModel, srcRas, w, h); 375 IntegerInterleavedRaster iiRas = (IntegerInterleavedRaster) ras; 376 outData = iiRas.getDataStorage(); 377 outSpan = iiRas.getScanlineStride(); 378 outOff = iiRas.getDataOffset(0); 379 return ras; 380 } 381 382 public void setRaster(int x, int y, int xerr, int yerr, 383 int w, int h, int bWidth, int bHeight, 384 int colincx, int colincxerr, 385 int colincy, int colincyerr, 386 int rowincx, int rowincxerr, 387 int rowincy, int rowincyerr) { 388 int[] inData = this.inData; 389 int[] outData = this.outData; 390 int out = outOff; 391 int inSpan = this.inSpan; 392 int inOff = this.inOff; 393 int outSpan = this.outSpan; 394 boolean filter = this.filter; 395 boolean normalx = (colincx == 1 && colincxerr == 0 && 396 colincy == 0 && colincyerr == 0) && !filter; 397 int rowx = x; 398 int rowy = y; 399 int rowxerr = xerr; 400 int rowyerr = yerr; 401 if (normalx) { 402 outSpan -= w; 403 } 404 int rgbs[] = filter ? new int[4] : null; 405 for (int j = 0; j < h; j++) { 406 if (normalx) { 407 int in = inOff + rowy * inSpan + bWidth; 408 x = bWidth - rowx; 409 out += w; 410 if (bWidth >= 32) { 411 int i = w; 412 while (i > 0) { 413 int copyw = (i < x) ? i : x; 414 System.arraycopy(inData, in - x, 415 outData, out - i, 416 copyw); 417 i -= copyw; 418 if ((x -= copyw) == 0) { 419 x = bWidth; 420 } 421 } 422 } else { 423 for (int i = w; i > 0; i--) { 424 outData[out - i] = inData[in - x]; 425 if (--x == 0) { 426 x = bWidth; 427 } 428 } 429 } 430 } else { 431 x = rowx; 432 y = rowy; 433 xerr = rowxerr; 434 yerr = rowyerr; 435 for (int i = 0; i < w; i++) { 436 if (filter) { 437 int nextx, nexty; 438 if ((nextx = x + 1) >= bWidth) { 439 nextx = 0; 440 } 441 if ((nexty = y + 1) >= bHeight) { 442 nexty = 0; 443 } 444 rgbs[0] = inData[inOff + y * inSpan + x]; 445 rgbs[1] = inData[inOff + y * inSpan + nextx]; 446 rgbs[2] = inData[inOff + nexty * inSpan + x]; 447 rgbs[3] = inData[inOff + nexty * inSpan + nextx]; 448 outData[out + i] = 449 TexturePaintContext.blend(rgbs, xerr, yerr); 450 } else { 451 outData[out + i] = inData[inOff + y * inSpan + x]; 452 } 453 if ((xerr += colincxerr) < 0) { 454 xerr &= Integer.MAX_VALUE; 455 x++; 456 } 457 if ((x += colincx) >= bWidth) { 458 x -= bWidth; 459 } 460 if ((yerr += colincyerr) < 0) { 461 yerr &= Integer.MAX_VALUE; 462 y++; 463 } 464 if ((y += colincy) >= bHeight) { 465 y -= bHeight; 466 } 467 } 468 } 469 if ((rowxerr += rowincxerr) < 0) { 470 rowxerr &= Integer.MAX_VALUE; 471 rowx++; 472 } 473 if ((rowx += rowincx) >= bWidth) { 474 rowx -= bWidth; 475 } 476 if ((rowyerr += rowincyerr) < 0) { 477 rowyerr &= Integer.MAX_VALUE; 478 rowy++; 479 } 480 if ((rowy += rowincy) >= bHeight) { 481 rowy -= bHeight; 482 } 483 out += outSpan; 484 } 485 } 486 } 487 488 static class Byte extends TexturePaintContext { 489 ByteInterleavedRaster srcRas; 490 byte inData[]; 491 int inOff; 492 int inSpan; 493 byte outData[]; 494 int outOff; 495 int outSpan; 496 497 public Byte(ByteInterleavedRaster srcRas, ColorModel cm, 498 AffineTransform xform, int maxw) 499 { 500 super(cm, xform, srcRas.getWidth(), srcRas.getHeight(), maxw); 501 this.srcRas = srcRas; 502 this.inData = srcRas.getDataStorage(); 503 this.inSpan = srcRas.getScanlineStride(); 504 this.inOff = srcRas.getDataOffset(0); 505 } 506 507 public WritableRaster makeRaster(int w, int h) { 508 WritableRaster ras = makeByteRaster(srcRas, w, h); 509 ByteInterleavedRaster biRas = (ByteInterleavedRaster) ras; 510 outData = biRas.getDataStorage(); 511 outSpan = biRas.getScanlineStride(); 512 outOff = biRas.getDataOffset(0); 513 return ras; 514 } 515 516 public void dispose() { 517 dropByteRaster(outRas); 518 } 519 520 public void setRaster(int x, int y, int xerr, int yerr, 521 int w, int h, int bWidth, int bHeight, 522 int colincx, int colincxerr, 523 int colincy, int colincyerr, 524 int rowincx, int rowincxerr, 525 int rowincy, int rowincyerr) { 526 byte[] inData = this.inData; 527 byte[] outData = this.outData; 528 int out = outOff; 529 int inSpan = this.inSpan; 530 int inOff = this.inOff; 531 int outSpan = this.outSpan; 532 boolean normalx = (colincx == 1 && colincxerr == 0 && 533 colincy == 0 && colincyerr == 0); 534 int rowx = x; 535 int rowy = y; 536 int rowxerr = xerr; 537 int rowyerr = yerr; 538 if (normalx) { 539 outSpan -= w; 540 } 541 for (int j = 0; j < h; j++) { 542 if (normalx) { 543 int in = inOff + rowy * inSpan + bWidth; 544 x = bWidth - rowx; 545 out += w; 546 if (bWidth >= 32) { 547 int i = w; 548 while (i > 0) { 549 int copyw = (i < x) ? i : x; 550 System.arraycopy(inData, in - x, 551 outData, out - i, 552 copyw); 553 i -= copyw; 554 if ((x -= copyw) == 0) { 555 x = bWidth; 556 } 557 } 558 } else { 559 for (int i = w; i > 0; i--) { 560 outData[out - i] = inData[in - x]; 561 if (--x == 0) { 562 x = bWidth; 563 } 564 } 565 } 566 } else { 567 x = rowx; 568 y = rowy; 569 xerr = rowxerr; 570 yerr = rowyerr; 571 for (int i = 0; i < w; i++) { 572 outData[out + i] = inData[inOff + y * inSpan + x]; 573 if ((xerr += colincxerr) < 0) { 574 xerr &= Integer.MAX_VALUE; 575 x++; 576 } 577 if ((x += colincx) >= bWidth) { 578 x -= bWidth; 579 } 580 if ((yerr += colincyerr) < 0) { 581 yerr &= Integer.MAX_VALUE; 582 y++; 583 } 584 if ((y += colincy) >= bHeight) { 585 y -= bHeight; 586 } 587 } 588 } 589 if ((rowxerr += rowincxerr) < 0) { 590 rowxerr &= Integer.MAX_VALUE; 591 rowx++; 592 } 593 if ((rowx += rowincx) >= bWidth) { 594 rowx -= bWidth; 595 } 596 if ((rowyerr += rowincyerr) < 0) { 597 rowyerr &= Integer.MAX_VALUE; 598 rowy++; 599 } 600 if ((rowy += rowincy) >= bHeight) { 601 rowy -= bHeight; 602 } 603 out += outSpan; 604 } 605 } 606 } 607 608 static class ByteFilter extends TexturePaintContext { 609 ByteInterleavedRaster srcRas; 610 int inPalette[]; 611 byte inData[]; 612 int inOff; 613 int inSpan; 614 int outData[]; 615 int outOff; 616 int outSpan; 617 618 public ByteFilter(ByteInterleavedRaster srcRas, ColorModel cm, 619 AffineTransform xform, int maxw) 620 { 621 super((cm.getTransparency() == Transparency.OPAQUE 622 ? xrgbmodel : argbmodel), 623 xform, srcRas.getWidth(), srcRas.getHeight(), maxw); 624 this.inPalette = new int[256]; 625 ((IndexColorModel ) cm).getRGBs(this.inPalette); 626 this.srcRas = srcRas; 627 this.inData = srcRas.getDataStorage(); 628 this.inSpan = srcRas.getScanlineStride(); 629 this.inOff = srcRas.getDataOffset(0); 630 } 631 632 public WritableRaster makeRaster(int w, int h) { 633 WritableRaster ras = makeRaster(colorModel, null, w, h); 636 IntegerInterleavedRaster iiRas = (IntegerInterleavedRaster) ras; 637 outData = iiRas.getDataStorage(); 638 outSpan = iiRas.getScanlineStride(); 639 outOff = iiRas.getDataOffset(0); 640 return ras; 641 } 642 643 public void setRaster(int x, int y, int xerr, int yerr, 644 int w, int h, int bWidth, int bHeight, 645 int colincx, int colincxerr, 646 int colincy, int colincyerr, 647 int rowincx, int rowincxerr, 648 int rowincy, int rowincyerr) { 649 byte[] inData = this.inData; 650 int[] outData = this.outData; 651 int out = outOff; 652 int inSpan = this.inSpan; 653 int inOff = this.inOff; 654 int outSpan = this.outSpan; 655 int rowx = x; 656 int rowy = y; 657 int rowxerr = xerr; 658 int rowyerr = yerr; 659 int rgbs[] = new int[4]; 660 for (int j = 0; j < h; j++) { 661 x = rowx; 662 y = rowy; 663 xerr = rowxerr; 664 yerr = rowyerr; 665 for (int i = 0; i < w; i++) { 666 int nextx, nexty; 667 if ((nextx = x + 1) >= bWidth) { 668 nextx = 0; 669 } 670 if ((nexty = y + 1) >= bHeight) { 671 nexty = 0; 672 } 673 rgbs[0] = inPalette[0xff & inData[inOff + x + 674 inSpan * y]]; 675 rgbs[1] = inPalette[0xff & inData[inOff + nextx + 676 inSpan * y]]; 677 rgbs[2] = inPalette[0xff & inData[inOff + x + 678 inSpan * nexty]]; 679 rgbs[3] = inPalette[0xff & inData[inOff + nextx + 680 inSpan * nexty]]; 681 outData[out + i] = 682 TexturePaintContext.blend(rgbs, xerr, yerr); 683 if ((xerr += colincxerr) < 0) { 684 xerr &= Integer.MAX_VALUE; 685 x++; 686 } 687 if ((x += colincx) >= bWidth) { 688 x -= bWidth; 689 } 690 if ((yerr += colincyerr) < 0) { 691 yerr &= Integer.MAX_VALUE; 692 y++; 693 } 694 if ((y += colincy) >= bHeight) { 695 y -= bHeight; 696 } 697 } 698 if ((rowxerr += rowincxerr) < 0) { 699 rowxerr &= Integer.MAX_VALUE; 700 rowx++; 701 } 702 if ((rowx += rowincx) >= bWidth) { 703 rowx -= bWidth; 704 } 705 if ((rowyerr += rowincyerr) < 0) { 706 rowyerr &= Integer.MAX_VALUE; 707 rowy++; 708 } 709 if ((rowy += rowincy) >= bHeight) { 710 rowy -= bHeight; 711 } 712 out += outSpan; 713 } 714 } 715 } 716 717 static class Any extends TexturePaintContext { 718 WritableRaster srcRas; 719 boolean filter; 720 721 public Any(WritableRaster srcRas, ColorModel cm, 722 AffineTransform xform, int maxw, boolean filter) 723 { 724 super(cm, xform, srcRas.getWidth(), srcRas.getHeight(), maxw); 725 this.srcRas = srcRas; 726 this.filter = filter; 727 } 728 729 public WritableRaster makeRaster(int w, int h) { 730 return makeRaster(colorModel, srcRas, w, h); 731 } 732 733 public void setRaster(int x, int y, int xerr, int yerr, 734 int w, int h, int bWidth, int bHeight, 735 int colincx, int colincxerr, 736 int colincy, int colincyerr, 737 int rowincx, int rowincxerr, 738 int rowincy, int rowincyerr) { 739 Object data = null; 740 int rowx = x; 741 int rowy = y; 742 int rowxerr = xerr; 743 int rowyerr = yerr; 744 WritableRaster srcRas = this.srcRas; 745 WritableRaster outRas = this.outRas; 746 int rgbs[] = filter ? new int[4] : null; 747 for (int j = 0; j < h; j++) { 748 x = rowx; 749 y = rowy; 750 xerr = rowxerr; 751 yerr = rowyerr; 752 for (int i = 0; i < w; i++) { 753 data = srcRas.getDataElements(x, y, data); 754 if (filter) { 755 int nextx, nexty; 756 if ((nextx = x + 1) >= bWidth) { 757 nextx = 0; 758 } 759 if ((nexty = y + 1) >= bHeight) { 760 nexty = 0; 761 } 762 rgbs[0] = colorModel.getRGB(data); 763 data = srcRas.getDataElements(nextx, y, data); 764 rgbs[1] = colorModel.getRGB(data); 765 data = srcRas.getDataElements(x, nexty, data); 766 rgbs[2] = colorModel.getRGB(data); 767 data = srcRas.getDataElements(nextx, nexty, data); 768 rgbs[3] = colorModel.getRGB(data); 769 int rgb = 770 TexturePaintContext.blend(rgbs, xerr, yerr); 771 data = colorModel.getDataElements(rgb, data); 772 } 773 outRas.setDataElements(i, j, data); 774 if ((xerr += colincxerr) < 0) { 775 xerr &= Integer.MAX_VALUE; 776 x++; 777 } 778 if ((x += colincx) >= bWidth) { 779 x -= bWidth; 780 } 781 if ((yerr += colincyerr) < 0) { 782 yerr &= Integer.MAX_VALUE; 783 y++; 784 } 785 if ((y += colincy) >= bHeight) { 786 y -= bHeight; 787 } 788 } 789 if ((rowxerr += rowincxerr) < 0) { 790 rowxerr &= Integer.MAX_VALUE; 791 rowx++; 792 } 793 if ((rowx += rowincx) >= bWidth) { 794 rowx -= bWidth; 795 } 796 if ((rowyerr += rowincyerr) < 0) { 797 rowyerr &= Integer.MAX_VALUE; 798 rowy++; 799 } 800 if ((rowy += rowincy) >= bHeight) { 801 rowy -= bHeight; 802 } 803 } 804 } 805 } 806 } 807 | Popular Tags |