Search code examples
javagraphics2djava-2d

Does java graphics render only the window size or everything?


I am making a 2d path-geometry based game in java. If I have a bunch of large shapes (Path2D's) that I am rendering every frame, is java taking the time to process the whole thing, or is it only processing the parts actually in the window?

For example say I have an rectangle that is 1000 by 1000 with the top left corner at 10, 10. My window is only 100 by 100. Is java processing the whole thing, or only the part smaller than 100, 100?

Thanks in advance!


Solution

  • After receiving some information, I decided to test it myself.

    I made a complex shape using Path2D and rendered with the whole shape inside the window. Then, I rendered the same thing 90% outside the window, with only a small part of the shape showing.

    The one that was outside the window showed much higher performance (260 FPS) than the one entirely in the window (50 FPS).

    This suggests that java only processes the part of the shape actually within the window boundaries.