[sis] branch geoapi-4.0 updated: Move the provider of empty tiles in a location where it can be shared with other operations.

2021-10-20 Thread desruisseaux
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 

[jira] [Updated] (SIS-524) Image masking based on a geometry

2021-10-20 Thread Martin Desruisseaux (Jira)


 [ 
https://issues.apache.org/jira/browse/SIS-524?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Desruisseaux updated SIS-524:

Summary: Image masking based on a geometry  (was: Image mask based on a 
geometry)

> Image masking based on a geometry
> -
>
> Key: SIS-524
> URL: https://issues.apache.org/jira/browse/SIS-524
> Project: Spatial Information Systems
>  Issue Type: New Feature
>  Components: Coverage
>Reporter: Martin Desruisseaux
>Assignee: Martin Desruisseaux
>Priority: Major
> Fix For: 1.2
>
>
> Add an image operator for applying a mask on a `GridCoverage`: all pixel 
> values outside a geometry would be replaced by a fill value. The coverage and 
> the geometry are in arbitrary CRS, not necessarily the same.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (SIS-524) Image mask based on a geometry

2021-10-20 Thread Martin Desruisseaux (Jira)
Martin Desruisseaux created SIS-524:
---

 Summary: Image mask based on a geometry
 Key: SIS-524
 URL: https://issues.apache.org/jira/browse/SIS-524
 Project: Spatial Information Systems
  Issue Type: New Feature
  Components: Coverage
Reporter: Martin Desruisseaux
Assignee: Martin Desruisseaux
 Fix For: 1.2


Add an image operator for applying a mask on a `GridCoverage`: all pixel values 
outside a geometry would be replaced by a fill value. The coverage and the 
geometry are in arbitrary CRS, not necessarily the same.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)