Handle renderer-specific image drawing.
(PImage who,
float x1, float y1, float x2, float y2,
int u1, int v1, int u2, int v2)
| 1557 | * Handle renderer-specific image drawing. |
| 1558 | */ |
| 1559 | @Override |
| 1560 | protected void imageImpl(PImage who, |
| 1561 | float x1, float y1, float x2, float y2, |
| 1562 | int u1, int v1, int u2, int v2) { |
| 1563 | // Image not ready yet, or an error |
| 1564 | if (who.width <= 0 || who.height <= 0) return; |
| 1565 | |
| 1566 | ImageCache cash = (ImageCache) getCache(who); |
| 1567 | |
| 1568 | // Nuke the cache if the image was resized |
| 1569 | if (cash != null) { |
| 1570 | if (who.pixelWidth != cash.image.getWidth() || |
| 1571 | who.pixelHeight != cash.image.getHeight()) { |
| 1572 | cash = null; |
| 1573 | } |
| 1574 | } |
| 1575 | |
| 1576 | if (cash == null) { |
| 1577 | //System.out.println("making new image cache"); |
| 1578 | cash = new ImageCache(); //who); |
| 1579 | setCache(who, cash); |
| 1580 | who.updatePixels(); // mark the whole thing for update |
| 1581 | who.setModified(); |
| 1582 | } |
| 1583 | |
| 1584 | // If image previously was tinted, or the color changed |
| 1585 | // or the image was tinted, and tint is now disabled |
| 1586 | if ((tint && !cash.tinted) || |
| 1587 | (tint && (cash.tintedColor != tintColor)) || |
| 1588 | (!tint && cash.tinted)) { |
| 1589 | // For tint change, mark all pixels as needing update. |
| 1590 | who.updatePixels(); |
| 1591 | } |
| 1592 | |
| 1593 | if (who.isModified()) { |
| 1594 | if (who.pixels == null) { |
| 1595 | // This might be a PGraphics that hasn't been drawn to yet. |
| 1596 | // Can't just bail because the cache has been created above. |
| 1597 | // https://github.com/processing/processing/issues/2208 |
| 1598 | who.pixels = new int[who.pixelWidth * who.pixelHeight]; |
| 1599 | } |
| 1600 | cash.update(who, tint, tintColor); |
| 1601 | who.setModified(false); |
| 1602 | } |
| 1603 | |
| 1604 | u1 *= who.pixelDensity; |
| 1605 | v1 *= who.pixelDensity; |
| 1606 | u2 *= who.pixelDensity; |
| 1607 | v2 *= who.pixelDensity; |
| 1608 | |
| 1609 | g2.drawImage(((ImageCache) getCache(who)).image, |
| 1610 | (int) x1, (int) y1, (int) x2, (int) y2, |
| 1611 | u1, v1, u2, v2, null); |
| 1612 | |
| 1613 | // Every few years I think "nah, Java2D couldn't possibly be that f*king |
| 1614 | // slow, why are we doing this by hand?" then comes the affirmation: |
| 1615 | // Composite oldComp = null; |
| 1616 | // if (false && tint) { |
nothing calls this directly
no test coverage detected