This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new da6ade3 Move the provider of empty tiles in a location where it can
be shared with other operations.
da6ade3 is described below
commit da6ade3d07fa0c82b90167821c3ba57d5eb27d67
Author: Martin Desruisseaux
AuthorDate: Wed Oct 20 17:47:09 2021 +0200
Move the provider of empty tiles in a location where it can be shared with
other operations.
---
.../java/org/apache/sis/image/PrefetchedImage.java | 107 +---
.../sis/internal/coverage/j2d/TilePlaceholder.java | 302 +
2 files changed, 310 insertions(+), 99 deletions(-)
diff --git
a/core/sis-feature/src/main/java/org/apache/sis/image/PrefetchedImage.java
b/core/sis-feature/src/main/java/org/apache/sis/image/PrefetchedImage.java
index b5ac0ac..fd15bb9 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/PrefetchedImage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/PrefetchedImage.java
@@ -16,25 +16,20 @@
*/
package org.apache.sis.image;
-import java.util.Arrays;
import java.util.Vector;
import java.awt.Point;
import java.awt.Rectangle;
-import java.awt.color.ColorSpace;
import java.awt.image.ColorModel;
-import java.awt.image.DataBuffer;
import java.awt.image.SampleModel;
import java.awt.image.RenderedImage;
import java.awt.image.Raster;
-import java.awt.image.WritableRaster;
import java.awt.image.RasterFormatException;
import org.apache.sis.internal.coverage.j2d.ImageUtilities;
import org.apache.sis.internal.coverage.j2d.TileErrorHandler;
import org.apache.sis.internal.coverage.j2d.TileOpExecutor;
-import org.apache.sis.internal.util.Numerics;
+import org.apache.sis.internal.coverage.j2d.TilePlaceholder;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Workaround;
/**
@@ -51,24 +46,6 @@ import org.apache.sis.util.Workaround;
*/
final class PrefetchedImage extends PlanarImage implements
TileErrorHandler.Executor {
/**
- * Identifies workaround for a JDK bug: call to {@code
Graphics2D.drawRenderedImage(…)}
- * fails if the image contains more than one tile (or a single tile not
located at 0,0)
- * and the tiles are not instances of {@link WritableRaster} (i.e. are
instances of the
- * read-only {@link Raster} parent class). The exception thrown is:
- *
- * {@preformat text
- * Exception in thread "main" java.awt.image.RasterFormatException:
(parentX + width) is outside raster
- * at
java.desktop/java.awt.image.WritableRaster.createWritableChild(WritableRaster.java:228)
- * at
java.desktop/sun.java2d.SunGraphics2D.drawTranslatedRenderedImage(SunGraphics2D.java:2852)
- * at
java.desktop/sun.java2d.SunGraphics2D.drawRenderedImage(SunGraphics2D.java:2711)
- * }
- *
- * @see https://bugs.openjdk.java.net/browse/JDK-8275345;>JDK-8275345
- */
-@Workaround(library="JDK", version="17")
-private static final boolean PENDING_JDK_FIX = false;
-
-/**
* The source image from which to prefetch tiles.
*/
final RenderedImage source;
@@ -99,7 +76,7 @@ final class PrefetchedImage extends PlanarImage implements
TileErrorHandler.Exec
*
* @see #createPlaceholder(int, int)
*/
-private DataBuffer placeholderPixels;
+private volatile TilePlaceholder placeholderPixels;
/**
* Non-null if errors should be handled during {@link #getTile(int, int)}
execution for tiles outside
@@ -304,80 +281,12 @@ final class PrefetchedImage extends PlanarImage
implements TileErrorHandler.Exec
* @return placeholder for the tile at given indices.
*/
private Raster createPlaceholder(final int tileX, final int tileY) {
-final SampleModel model = getSampleModel();
-final Point location = new Point(ImageUtilities.tileToPixelX(source,
tileX),
- ImageUtilities.tileToPixelY(source,
tileY));
-if (placeholderPixels != null) {
-if (!PENDING_JDK_FIX) {
-return Raster.createWritableRaster(model, placeholderPixels,
location);
-}
-// Reuse same `DataBuffer` with only a different location.
-return Raster.createRaster(model, placeholderPixels, location);
-}
-final double[] samples = new double[model.getNumBands()];
-if (ImageUtilities.isIntegerType(model)) {
-final boolean isUnsigned = ImageUtilities.isUnsignedType(model);
-for (int i=0; i=0;) {
-samples[i] = cs.getMaxValue(i);
-}
-} else {
-Arrays.fill(samples, 1);
-}
-}
-/*
- * Draw borders around the tile as