## src/java.desktop/share/classes/sun/java2d/pipe/Region.java

```*** 28,37 ****
--- 28,39 ----
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.RectangularShape;

+ import sun.java2d.loops.TransformHelper;
+
/**
* This class encapsulates a definition of a two dimensional region which
* consists of a number of Y ranges each containing multiple X bands.
* <p>
* A rectangular Region is allowed to have a null band list in which
*** 158,167 ****
--- 160,178 ----
this.loy = loy;
this.hix = hix;
this.hiy = hiy;
}

+     private Region(int lox, int loy, int hix, int hiy, int[] bands, int end) {
+         this.lox = lox;
+         this.loy = loy;
+         this.hix = hix;
+         this.hiy = hiy;
+         this.bands = bands;
+         this.endIndex = end;
+     }
+
/**
* Returns a Region object covering the pixels which would be
* touched by a fill or clip operation on a Graphics implementation
* on the specified Shape object under the optionally specified
* AffineTransform object.
*** 254,263 ****
--- 265,306 ----
sr.dispose();
}
}

/**
+      * Returns a Region object with a rectangle of interest specified by the
+      * indicated rectangular area in lox, loy, hix, hiy and edges array, which
+      * is located relative to the rectangular area. Edges array - 0,1 are y
+      * range, 2N,2N+1 are x ranges, 1 per y range.
+      * <p>
+      * Note that we trust to the edges array, which means that edges should be:
+      * {@code edges + (lox, loy) < (hix, hiy)}, otherwise result is undefined
+      *
+      * @see TransformHelper
+      */
+     static Region getInstance(final int lox, final int loy, final int hix,
+                               final int hiy, final int edges[]) {
+         // rowsNum * (3 + 1 * 2), plus one byte for endIndex
+         final int[] bands = new int[(edges[1] - edges[0]) * 5 + 1];
+         int end = 0;
+         int index = 2;
+         for (int y = edges[0]; end < bands.length && y < edges[1]; ++y) {
+             final int x1 = edges[index++];
+             final int x2 = edges[index++];
+             if (x1 < x2) {
+                 bands[end++] = loy + y;     // spanloy
+                 bands[end++] = loy + y + 1; // spanhiy
+                 bands[end++] = 1;           // 1 span per row
+                 bands[end++] = lox + x1;    // spanlox
+                 bands[end++] = lox + x2;    // spanhix
+             }
+         }
+         return end != 0 ? new Region(lox, loy, hix, hiy, bands, end)
+                         : EMPTY_REGION;
+     }
+
+     /**
* Returns a Region object with a rectangle of interest specified
* by the indicated Rectangle object.
* <p>
* This method can also be used to create a simple rectangular
* region.
```