Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8088198: Exception thrown from snapshot if dimensions are larger than max texture size #68

Closed
wants to merge 7 commits into from
@@ -1300,10 +1300,14 @@ static WritableImage doSnapshot(Scene scene,
height = (int)wimg.getHeight();
}

int maxTextureSize = PrismSettings.maxTextureSize;
if (height > maxTextureSize || width > maxTextureSize) {
// The requested size for the screenshot is too big to fit a single texture,
// so we need to take several snapshot tiles and merge them into single image (fixes JDK-8088198)
// Attempt to capture snapshot
try {
wimg = doSnapshotTile(scene, xMin, yMin, width, height, root, transform, depthBuffer, fill, camera, wimg);
} catch (Exception e) {
// A first attempt to capture a snapshot failed, most likely because it is larger than
// maxTextureSize: retry by taking several snapshot tiles and merge them into single image
// (Addresses JDK-8088198)
int maxTextureSize = PrismSettings.maxTextureSize;
int numVerticalTiles = (int) Math.ceil(height / (double) maxTextureSize);
int numHorizontalTiles = (int) Math.ceil(width / (double) maxTextureSize);
for (int i = 0; i < numHorizontalTiles; i++) {
@@ -1317,10 +1321,6 @@ static WritableImage doSnapshot(Scene scene,
wimg.getPixelWriter().setPixels(xOffset, yOffset, tileWidth, tileHeight, tile.getPixelReader(), 0, 0);
}
}
} else {
// The requested size for the screenshot fits max texture size,
// so we can directly return the one generated tile and avoid the extra pixel copy.
wimg = doSnapshotTile(scene, xMin, yMin, width, height, root, transform, depthBuffer, fill, camera, wimg);
}

// if this scene belongs to some stage
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.