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

Smarter Map Redraws [grant 2020] #40960

Merged
merged 5 commits into from
Jan 14, 2021
Merged

Conversation

PeterPetrik
Copy link
Contributor

@PeterPetrik PeterPetrik commented Jan 12, 2021

qgis/QGIS-Enhancement-Proposals#181

  • only for RasterLayers so far, should be easily extensible for other types
  • there is developer define in QgsMapRendererParallelJob SIMULATE_SLOW_RENDERER, line 338, you can uncomment it to force very slow renderers (for testing)

general overview of the implementation: The QgsMapLayerRenderer has flag mReadyToCompose. To use the "smart map redraws" for the particular renderer, the flag must be set to false in the constructor and set to true once there is something to show to user (so the renderer actually drawn some data to resulting/destination image already). The rule now is that whenever the flag is set to false, the rendering job tries to fetch the cached image from the QgsMapRenderingCache for particular layer and transform it to the current drawn extent instead of showing QImage with all transparent pixels

Work funded by QGIS grant 2020.

…ached layer image before the new rendering is done
@roya0045
Copy link
Contributor

This makes me want to improve expression evaluation...

@github-actions github-actions bot added this to the 3.18.0 milestone Jan 12, 2021
python/core/auto_generated/qgsmaplayerrenderer.sip.in Outdated Show resolved Hide resolved
python/core/auto_generated/qgsmaplayerrenderer.sip.in Outdated Show resolved Hide resolved
python/core/auto_generated/qgsmaprenderercache.sip.in Outdated Show resolved Hide resolved
python/core/auto_generated/qgsmaprenderercache.sip.in Outdated Show resolved Hide resolved
src/core/qgsmaprendererjob.cpp Outdated Show resolved Hide resolved
src/core/qgsmaprendererjob.cpp Outdated Show resolved Hide resolved
@nyalldawson
Copy link
Collaborator

@PeterPetrik
This doesn't actually seem to have any effect for me -- see the screencast below. It doesn't show so well in the screencast, but even the pan operations results in a ~0.25 second white canvas flash for me

Peek 2021-01-13 12-10

@PeterPetrik
Copy link
Contributor Author

@PeterPetrik
This doesn't actually seem to have any effect for me -- see the screencast below. It doesn't show so well in the screencast, but even the pan operations results in a ~0.25 second white canvas flash for me

Peek 2021-01-13 12-10

Screen Shot 2021-01-13 at 8 16 58

actually removed the mReadyToCompose=false from raster renderer contructor when doing "final" changes for official PR... will fix ASAP

@PeterPetrik PeterPetrik added Changelog Items that are queued to appear in the visual changelog - remove after harvesting Squash! Remember to squash this PR, instead of merging or rebasing labels Jan 13, 2021
@nyalldawson
Copy link
Collaborator

Ok, that's certainly MUCH nicer now! Great stuff!

A few suggestions:

  1. I think we should implement this for vector layers too, by setting mReadyToCompose only after the first feature is rendered. I've tested and this helps with some semi-common situations like a inverted polygon using the shapeburst renderer, which can be rather slow to draw.
  2. It's actually possible for us to have multiple rendered versions of a single layer covering different extents, because the "preview job" functionality in the canvas automatically draws neighbouring tiles after the main job finishes. If we allowed the render cache to store more than one image for a layer, then potentially we could draw ALL of these during the intermediate compositing. This would mean that zooming out would nicely show the data from the surrounding areas while the redraw occurs. What do you think?

@saberraz
Copy link
Contributor

saberraz commented Jan 14, 2021

Before:
ezgif com-resize(1)

After:
ezgif com-resize

@wonder-sk wonder-sk merged commit 4b9f82d into qgis:master Jan 14, 2021
@vincentschut
Copy link

A HUGE thank you for this! This makes qgis feel so much better for me!

@PeterPetrik
Copy link
Contributor Author

Best to thanks to QGIS grant scheme and all the QGIS sponsors :)

@zacharlie zacharlie added ChangelogHarvested This PR description has been harvested in the Changelog already. and removed Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Jan 17, 2021
@PeterPetrik PeterPetrik deleted the smartredraw branch October 19, 2021 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ChangelogHarvested This PR description has been harvested in the Changelog already. Squash! Remember to squash this PR, instead of merging or rebasing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants