On Fri, 24 Jan 2020 15:55:50 GMT, Frederic Thevenet 
<github.com+7450507+ftheve...@openjdk.org> wrote:

>> I haven't done any testing yet, but I have two comments on the patch:
>> 
>> 1. Using the clamped texture size as the upper limit is the right thing to 
>> do, but `Prism.maxTexture` isn't guaranteed to be that size. The 
>> `Prism.maxTexture` constant represents the value to clamp the texture size 
>> to. In the event that D3D or OpenGL were to report a maximum less than the 
>> value of `Prism.maxTexture` (unlikely, but maybe on some low-end embedded 
>> systems?), then that value is what should be used. The way to get the 
>> clamped texture size is to call 
>> [`ResourceFactory::getMaximumTextureSize`](https://github.com/openjdk/jfx/blob/jfx14/modules/javafx.graphics/src/main/java/com/sun/prism/ResourceFactory.java#L222),
>>  but you can't do that directly from the scene graph code.
>> 
>> 2. Allocating multiple `WritableImage` objects and using 
>> `PixelWriter::setPixels` to stitch them together will take more temporary 
>> memory, and is likely to be slower, than having the snapshot code write into 
>> a subimage of the larger allocated image directly.
>> 
>> Having said that, the current proposed solution is still better than the 
>> current behavior is almost all cases, although there could be a performance 
>> hit in the case of an 8K x 8K image, which will now be tiled. I want to do a 
>> more careful review and some testing. If any other users of snapshot have 
>> any comments or concerns, they would be welcome.
>> 
>> I think the best long-term solution might be to modify the 
>> [`QuantumToolkit::renderToImage`](https://github.com/openjdk/jfx/blob/jfx14/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java#L1490)
>>  method, although that would certainly be out of scope for JavaFX 14.
> 
> I've put together a small benchmark to measure the time it takes to snapshots 
> into images of sizes varying from 1024*1024 to 8192*8192, by increment of 
> 1024 in each dimension, which you can find here: 
> https://github.com/fthevenet/snapshot-perf-meter/blob/master/src/main/java/eu/fthevenet/SnapshotPerfMeter.java

Here are the results when running JavaFX 14-ea+7. 
The columns of the table correspond the width of the target snapshot, while the 
rows correspond to the height and the content of the cells is the average time* 
spent (in ms) in `Node::snapshot`
(*) each test is ran 10 times and the elapsed time is averaged after pruning 
outliers, using Grubbs' test.

|    | 1024 |2048 |3072 |4096 |5120 |6144 |7168 |8192 |
|---|---|---|---|---|---|---|---|---|
| 1024 | 6.304272 | 10.303935 | 15.052336 | 35.929304 | 23.860095 | 28.828812 | 
35.315288 | 27.867205 |
| 2048 | 11.544367 | 21.156326 | 28.368750 | 28.887164 | 47.134738 | 54.354708 
| 55.480251 | 56.722649 |
| 3072 | 15.503187 | 30.215269 | 41.304645 | 39.789648 | 82.255091 | 82.576379 
| 96.618722 | 106.586547 |
| 4096 | 20.928336 | 38.768648 | 64.255423 | 52.608217 | 101.797347 | 
132.516816 | 158.525192 | 166.872889 |
| 5120 | 28.693431 | 67.275306 | 68.090280 | 76.208412 | 133.974510 | 
157.120373 | 182.329784 | 210.069066 |
| 6144 | 29.972591 | 54.751002 | 88.171906 | 104.489291 | 147.788597 | 
185.185643 | 213.562819 | 228.643761 |
| 7168 | 33.668398 | 63.088490 | 98.756212 | 130.502678 | 196.367121 | 
225.166481 | 239.328794 | 260.162501 |
| 8192 | 40.961901 | 87.067460 | 128.230351 | 178.127225 | 198.479068 | 
225.806211 | 266.170239 | 325.967840 |

-------------

PR: https://git.openjdk.java.net/jfx/pull/68

Reply via email to