Skip to content

Commit

Permalink
gapic: Don’t consider NaN and ∞ in tone mapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-clayton committed Oct 11, 2017
1 parent 71a8a9b commit f6638c5
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions gapic/src/main/com/google/gapid/image/ArrayImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,21 +435,29 @@ public static PixelInfo compute(FloatBuffer buffer, boolean isRGBA) {
if (isRGBA) {
for (int i = 0, end = buffer.remaining() - 3; i <= end; ) {
float value = buffer.get(i++);
min = Math.min(min, value);
max = Math.max(max, value);
if (!Float.isNaN(value) && !Float.isInfinite(value)) {
min = Math.min(min, value);
max = Math.max(max, value);
}
value = buffer.get(i++);
min = Math.min(min, value);
max = Math.max(max, value);
if (!Float.isNaN(value) && !Float.isInfinite(value)) {
min = Math.min(min, value);
max = Math.max(max, value);
}
value = buffer.get(i++);
min = Math.min(min, value);
max = Math.max(max, value);
if (!Float.isNaN(value) && !Float.isInfinite(value)) {
min = Math.min(min, value);
max = Math.max(max, value);
}
i++; // skip alpha
}
} else {
for (int i = 0; i < buffer.remaining(); i++) {
float value = buffer.get(i);
min = Math.min(min, value);
max = Math.max(max, value);
if (!Float.isNaN(value) && !Float.isInfinite(value)) {
min = Math.min(min, value);
max = Math.max(max, value);
}
}
}
return new FloatPixelInfo(min, max);
Expand Down

0 comments on commit f6638c5

Please sign in to comment.