< prev index next >
modules/graphics/src/main/java/com/sun/prism/impl/paint/MultipleGradientContext.java
Print this page
*** 200,218 ****
--- 200,222 ----
for (int i = 0; i < normalizedIntervals.length; i++) {
Imin = (Imin > normalizedIntervals[i]) ?
normalizedIntervals[i] : Imin;
}
+ // Is Imin zero?
+ final boolean canDivideByImin = Float.isFinite(1.0f/Imin);
// Estimate the size of the entire gradients array.
// This is to prevent a tiny interval from causing the size of array
// to explode. If the estimated size is too large, break to using
// separate arrays for each interval, and using an indexing scheme at
// look-up time.
int estimatedSize = 0;
+ if (canDivideByImin) {
for (int i = 0; i < normalizedIntervals.length; i++) {
estimatedSize += (normalizedIntervals[i]/Imin) * GRADIENT_SIZE;
}
+ }
if (estimatedSize > MAX_GRADIENT_ARRAY_SIZE) {
// slow method
calculateMultipleArrayGradient(normalizedColors);
} else {
*** 252,266 ****
int rgb1, rgb2;
//the eventual size of the single array
int gradientsTot = 1;
// for every interval (transition between 2 colors)
for (int i = 0; i < gradients.length; i++) {
// create an array whose size is based on the ratio to the
// smallest interval
! int nGradients = (int)((normalizedIntervals[i]/Imin)*255f);
gradientsTot += nGradients;
gradients[i] = new int[nGradients];
// the 2 colors (keyframes) to interpolate between
rgb1 = colors[i].getIntArgbPre();
--- 256,273 ----
int rgb1, rgb2;
//the eventual size of the single array
int gradientsTot = 1;
+ // Is Imin zero?
+ final boolean canDivideByImin = Float.isFinite(1.0f/Imin);
// for every interval (transition between 2 colors)
for (int i = 0; i < gradients.length; i++) {
// create an array whose size is based on the ratio to the
// smallest interval
! int nGradients = canDivideByImin
! ? (int)((normalizedIntervals[i]/Imin)*255f) : 0;
gradientsTot += nGradients;
gradients[i] = new int[nGradients];
// the 2 colors (keyframes) to interpolate between
rgb1 = colors[i].getIntArgbPre();
< prev index next >