|
1
|
|
package com.rox.ppu.debug; |
|
2
|
|
|
|
3
|
|
import java.awt.image.BufferedImage; |
|
4
|
|
import java.util.function.IntUnaryOperator; |
|
5
|
|
|
|
6
|
|
/** |
|
7
|
|
* A {@link BufferedImage} with an 8x8-tile blit helper: takes a {@link TileDecoder}-shaped pixel grid |
|
8
|
|
* (values 0-3) and paints each pixel through a caller-supplied value-to-colour mapping - either one of |
|
9
|
|
* 4 evenly-spaced gray shades (before {@code NesPalette} existed, still used where no real palette |
|
10
|
|
* group applies) or 4 real {@code NesPalette} colours resolved from actual palette RAM. Optionally |
|
11
|
|
* flips the source horizontally/vertically (for OAM sprite attribute bits), can treat pixel value 0 as |
|
12
|
|
* transparent instead of painted (the NES sprite convention - lets whatever was drawn underneath show |
|
13
|
|
* through), and always clips against the image's own bounds - callers don't need to know/pass the |
|
14
|
|
* canvas size themselves. |
|
15
|
|
*/ |
|
16
|
|
final class PixelGridBufferedImage extends BufferedImage { |
|
17
|
|
private static final int GRAY_STEP = 85; //0/85/170/255 - 4 evenly-spaced shades for a 2-bit value |
|
18
|
|
static final int TILE_PX = 8; |
|
19
|
|
|
|
20
|
|
PixelGridBufferedImage(final int width, final int height, final int imageType){ |
|
21
|
|
super(width, height, imageType); |
|
22
|
|
} |
|
23
|
|
|
|
24
|
|
void drawTile(final int[][] pixels, final int fromX, final int fromY){ |
|
25
|
1
1. drawTile : removed call to com/rox/ppu/debug/PixelGridBufferedImage::drawTile → KILLED
|
drawTile(pixels, fromX, fromY, false, false); |
|
26
|
|
} |
|
27
|
|
|
|
28
|
|
void drawTile(final int[][] pixels, final int fromX, final int fromY, |
|
29
|
|
final boolean flipH, final boolean flipV){ |
|
30
|
1
1. drawTile : removed call to com/rox/ppu/debug/PixelGridBufferedImage::drawTile → KILLED
|
drawTile(pixels, fromX, fromY, flipH, flipV, false); |
|
31
|
|
} |
|
32
|
|
|
|
33
|
|
/** |
|
34
|
|
* @param transparentZero when true, pixel value 0 is skipped entirely instead of painted - |
|
35
|
|
* the NES sprite convention, so overlapping lower-priority sprites don't |
|
36
|
|
* erase a higher-priority sprite already drawn underneath. |
|
37
|
|
*/ |
|
38
|
|
void drawTile(final int[][] pixels, final int fromX, final int fromY, |
|
39
|
|
final boolean flipH, final boolean flipV, final boolean transparentZero){ |
|
40
|
1
1. drawTile : removed call to com/rox/ppu/debug/PixelGridBufferedImage::drawTile → KILLED
|
drawTile(pixels, fromX, fromY, flipH, flipV, transparentZero, |
|
41
|
|
value -> { |
|
42
|
1
1. lambda$drawTile$0 : Replaced integer multiplication with division → KILLED
|
final int gray = value * GRAY_STEP; |
|
43
|
5
1. lambda$drawTile$0 : Replaced Shift Left with Shift Right → KILLED
2. lambda$drawTile$0 : replaced int return with 0 for com/rox/ppu/debug/PixelGridBufferedImage::lambda$drawTile$0 → KILLED
3. lambda$drawTile$0 : Replaced bitwise OR with AND → KILLED
4. lambda$drawTile$0 : Replaced bitwise OR with AND → KILLED
5. lambda$drawTile$0 : Replaced Shift Left with Shift Right → KILLED
|
return (gray << 16) | (gray << 8) | gray; |
|
44
|
|
}); |
|
45
|
|
} |
|
46
|
|
|
|
47
|
|
/** |
|
48
|
|
* @param paletteColors this tile's 4 real colours (one per 2-bit pixel value 0-3), each a packed |
|
49
|
|
* {@code 0xRRGGBB} value already resolved from palette RAM through |
|
50
|
|
* {@code NesPalette} - unlike the grayscale overloads, which always map a |
|
51
|
|
* fixed 0-3 range, the caller picks which 4 colours a given tile actually uses. |
|
52
|
|
*/ |
|
53
|
|
void drawTile(final int[][] pixels, final int fromX, final int fromY, |
|
54
|
|
final boolean flipH, final boolean flipV, final boolean transparentZero, |
|
55
|
|
final int[] paletteColors){ |
|
56
|
2
1. lambda$drawTile$1 : replaced int return with 0 for com/rox/ppu/debug/PixelGridBufferedImage::lambda$drawTile$1 → KILLED
2. drawTile : removed call to com/rox/ppu/debug/PixelGridBufferedImage::drawTile → KILLED
|
drawTile(pixels, fromX, fromY, flipH, flipV, transparentZero, value -> paletteColors[value]); |
|
57
|
|
} |
|
58
|
|
|
|
59
|
|
private void drawTile(final int[][] pixels, final int fromX, final int fromY, |
|
60
|
|
final boolean flipH, final boolean flipV, final boolean transparentZero, |
|
61
|
|
final IntUnaryOperator colorOf){ |
|
62
|
2
1. drawTile : negated conditional → KILLED
2. drawTile : changed conditional boundary → KILLED
|
for (int row = 0; row < TILE_PX; row++){ |
|
63
|
2
1. drawTile : changed conditional boundary → KILLED
2. drawTile : negated conditional → KILLED
|
for (int col = 0; col < TILE_PX; col++){ |
|
64
|
|
final int value = pixels[row][col]; |
|
65
|
2
1. drawTile : negated conditional → KILLED
2. drawTile : negated conditional → KILLED
|
if (transparentZero && value == 0){ |
|
66
|
|
continue; |
|
67
|
|
} |
|
68
|
3
1. drawTile : Replaced integer addition with subtraction → KILLED
2. drawTile : negated conditional → KILLED
3. drawTile : Replaced integer subtraction with addition → KILLED
|
final int px = fromX + (flipH ? TILE_PX - 1 - col : col); |
|
69
|
3
1. drawTile : negated conditional → KILLED
2. drawTile : Replaced integer subtraction with addition → KILLED
3. drawTile : Replaced integer addition with subtraction → KILLED
|
final int py = fromY + (flipV ? TILE_PX - 1 - row : row); |
|
70
|
8
1. drawTile : changed conditional boundary → KILLED
2. drawTile : negated conditional → KILLED
3. drawTile : negated conditional → KILLED
4. drawTile : negated conditional → KILLED
5. drawTile : changed conditional boundary → KILLED
6. drawTile : changed conditional boundary → KILLED
7. drawTile : negated conditional → KILLED
8. drawTile : changed conditional boundary → KILLED
|
if (px < 0 || px >= getWidth() || py < 0 || py >= getHeight()){ |
|
71
|
|
continue; //partially/fully off-canvas - a debug view, just clip it |
|
72
|
|
} |
|
73
|
1
1. drawTile : removed call to com/rox/ppu/debug/PixelGridBufferedImage::setRGB → KILLED
|
setRGB(px, py, colorOf.applyAsInt(value)); |
|
74
|
|
} |
|
75
|
|
} |
|
76
|
|
} |
|
77
|
|
} |
| | Mutations |
| 25 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] removed call to com/rox/ppu/debug/PixelGridBufferedImage::drawTile → KILLED
|
| 30 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] removed call to com/rox/ppu/debug/PixelGridBufferedImage::drawTile → KILLED
|
| 40 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] removed call to com/rox/ppu/debug/PixelGridBufferedImage::drawTile → KILLED
|
| 42 |
|
1.1 Location : lambda$drawTile$0 Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] Replaced integer multiplication with division → KILLED
|
| 43 |
|
1.1 Location : lambda$drawTile$0 Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] Replaced Shift Left with Shift Right → KILLED
2.2 Location : lambda$drawTile$0 Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] replaced int return with 0 for com/rox/ppu/debug/PixelGridBufferedImage::lambda$drawTile$0 → KILLED
3.3 Location : lambda$drawTile$0 Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] Replaced bitwise OR with AND → KILLED
4.4 Location : lambda$drawTile$0 Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] Replaced bitwise OR with AND → KILLED
5.5 Location : lambda$drawTile$0 Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] Replaced Shift Left with Shift Right → KILLED
|
| 56 |
|
1.1 Location : lambda$drawTile$1 Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] replaced int return with 0 for com/rox/ppu/debug/PixelGridBufferedImage::lambda$drawTile$1 → KILLED
2.2 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] removed call to com/rox/ppu/debug/PixelGridBufferedImage::drawTile → KILLED
|
| 62 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] negated conditional → KILLED
2.2 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:withTransparentZeroValueZeroLeavesExistingContentUntouched()] changed conditional boundary → KILLED
|
| 63 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:withTransparentZeroValueZeroLeavesExistingContentUntouched()] changed conditional boundary → KILLED
2.2 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] negated conditional → KILLED
|
| 65 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:withTransparentZeroValueZeroLeavesExistingContentUntouched()] negated conditional → KILLED
2.2 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:withTransparentZeroValueZeroLeavesExistingContentUntouched()] negated conditional → KILLED
|
| 68 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] Replaced integer addition with subtraction → KILLED
2.2 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] negated conditional → KILLED
3.3 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] Replaced integer subtraction with addition → KILLED
|
| 69 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] negated conditional → KILLED
2.2 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:flippingBothAxesMirrorsRowsAndColumns()] Replaced integer subtraction with addition → KILLED
3.3 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] Replaced integer addition with subtraction → KILLED
|
| 70 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:pixelsPastTheImagesFarEdgeAreClippedWithoutThrowing()] changed conditional boundary → KILLED
2.2 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] negated conditional → KILLED
3.3 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] negated conditional → KILLED
4.4 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] negated conditional → KILLED
5.5 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] changed conditional boundary → KILLED
6.6 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:pixelsPastTheImagesFarEdgeAreClippedWithoutThrowing()] changed conditional boundary → KILLED
7.7 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] negated conditional → KILLED
8.8 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:drawTileWithoutFlipArgumentsBehavesLikeNoFlip()] changed conditional boundary → KILLED
|
| 73 |
|
1.1 Location : drawTile Killed by : com.rox.ppu.debug.PixelGridBufferedImageTest.[engine:junit-jupiter]/[class:com.rox.ppu.debug.PixelGridBufferedImageTest]/[method:paletteColorDrawTileHonoursFlipAndOffset()] removed call to com/rox/ppu/debug/PixelGridBufferedImage::setRGB → KILLED
|