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

Optimize drawing solid backgrounds #3521

Merged
merged 3 commits into from
Nov 3, 2016
Merged

Optimize drawing solid backgrounds #3521

merged 3 commits into from
Nov 3, 2016

Conversation

mourner
Copy link
Member

@mourner mourner commented Nov 3, 2016

Closes #2773, closes #2925. There seems to be no FPS difference for me, but it might help on devices with weaker GPUs (e.g. phones).

👀 @ansis @brunoabinader

@mourner mourner added the performance ⚡ Speed, stability, CPU usage, memory usage, or power usage label Nov 3, 2016
Copy link
Contributor

@ansis ansis left a comment

Choose a reason for hiding this comment

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

Looks good!

@@ -6,14 +6,16 @@ module.exports = drawBackground;

function drawBackground(painter, sourceCache, layer) {
const gl = painter.gl;
const transform = painter.transform;
const tileSize = transform.tileSize;
const color = layer.paint['background-color'];
const image = layer.paint['background-pattern'];
const opacity = layer.paint['background-opacity'];

if (painter.isOpaquePass !== (!image && color[3] === 1)) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not related to your changes, but it looks like this doesn't consider opacity when it should. If it's convenient it would nice to squeeze that in here

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoa, you're right! Fixing this also fixes #2925 🎉

@mourner mourner merged commit 68887b2 into master Nov 3, 2016
@mourner mourner deleted the optimize-background branch November 3, 2016 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
2 participants