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

Server: fix label opacity when OPACITIES is set #53438

Conversation

elpaso
Copy link
Contributor

@elpaso elpaso commented Jun 12, 2023

Fix #48020

Implement multiplyOpacity() for QgsTextFormat and use it to alter labeling opacity during server rendering.

@elpaso elpaso added Bug Either a bug report, or a bug fix. Let's hope for the latter! Server Related to QGIS server labels Jun 12, 2023
@github-actions github-actions bot added this to the 3.32.0 milestone Jun 12, 2023
@elpaso elpaso force-pushed the bugfix-gh48020-server-opacities-parameter-does-not-apply-to-labels branch from ebcdb86 to b396f11 Compare June 13, 2023 10:48
This is used to change the labeling opacity in the server.
@elpaso elpaso force-pushed the bugfix-gh48020-server-opacities-parameter-does-not-apply-to-labels branch from c4b8af6 to a7c803e Compare June 13, 2023 10:55
src/core/textrenderer/qgstextformat.h Outdated Show resolved Hide resolved
src/core/textrenderer/qgstextformat.cpp Show resolved Hide resolved
Comment on lines 2183 to 2189
image.save('/tmp/img.png')
# Text
self.assertEqual(image.pixelColor(105, 84).name(), '#5f5f5f')
# Buffer
self.assertEqual(image.pixelColor(92, 84).name(), '#bfbfbf')
# Shadow
self.assertEqual(image.pixelColor(169, 136).name(), '#f0f0f0')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we use the standard render checker approach here? I'm concerned that these tests will be tricky to debug if they start failing in future (eg due to qt rendering changes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping to skip the mask dance and spare a few hours. This kind of test is much more robust and less prone to false negatives because by checking a pixel in the middle of the rendered object there is no way that aliasing and other small rendering differences will step in the way.

I agree that if that fails it could be harder to visually inspect the differences.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no way that aliasing and other small rendering differences will step in the way.

That sounds reasonable in theory, but I've seen numerous times were a Qt update has changed something in how qt handles alpha composition resulting in different overlaid color results 🙃

@@ -56,6 +57,7 @@ class QgsLayerRestorer
{
QString name;
double mOpacity;
QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unique ptr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tricky, because the settings struct is copied.

Technically the settings never owns the resource, it just keeps it for the duration of its lifetime and transfers it back to the layer when the destructor is called.

Also , the struct is private and it's not exposed to API, given the (non-copyable) complications of turning this into a unique_ptr I'd rather not follow your advice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW here is an attempt: ae23847

src/core/labeling/qgsvectorlayerlabeling.h Outdated Show resolved Hide resolved
@elpaso elpaso added the backport queued_ltr_backports Queued Backports label Jun 19, 2023
@elpaso
Copy link
Contributor Author

elpaso commented Jun 19, 2023

ping @rldhont @pblottiere can you please review so that I can merge in time for the next release ?

@elpaso elpaso merged commit 8b8d5d9 into qgis:master Jun 21, 2023
32 checks passed
@elpaso elpaso deleted the bugfix-gh48020-server-opacities-parameter-does-not-apply-to-labels branch June 21, 2023 14:32
@qgis-bot
Copy link
Collaborator

The backport to queued_ltr_backports failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply fb427d17df... Server: fix label opacity when OPACITIES is set
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

stdout
Auto-merging src/server/services/wms/qgswmsrenderer.cpp
Auto-merging src/server/services/wms/qgswmsrestorer.cpp
Auto-merging tests/src/python/test_qgsserver_wms_getmap.py
CONFLICT (content): Merge conflict in tests/src/python/test_qgsserver_wms_getmap.py

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-queued_ltr_backports queued_ltr_backports
# Navigate to the new working tree
cd .worktrees/backport-queued_ltr_backports
# Create a new branch
git switch --create backport-53438-to-queued_ltr_backports
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick fb427d17dff9f88e03eda60ce4eaf8a27f7c97ed,a7c803e6c0b8fe30e8fa84917168cbdd532e236a,b9ce813edd027cae7da3d5d7d2a8f19683a6e44d,b1b8fb8e159775c378ce94ab7099a24573cfd3ed,9a81957d3927b1ce899582e22c3afec583f9597c,ae23847c5998208d22343ef89bb0b8dbbaa8fe14,7b89a398f73375cc948962bb34440743814b06b9
# Push it to GitHub
git push --set-upstream origin backport-53438-to-queued_ltr_backports
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-queued_ltr_backports

Then, create a pull request where the base branch is queued_ltr_backports and the compare/head branch is backport-53438-to-queued_ltr_backports.

@qgis-bot qgis-bot added the failed backport The automated backport attempt failed, needs a manual backport label Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport queued_ltr_backports Queued Backports Bug Either a bug report, or a bug fix. Let's hope for the latter! failed backport The automated backport attempt failed, needs a manual backport Server Related to QGIS server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opacities parameter doesn't apply to labels in GetMap requests
3 participants