-
Notifications
You must be signed in to change notification settings - Fork 18
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
ignore animations that are only cached symbols #571
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -541,7 +541,9 @@ void Tiled2dMapVectorLayer::update() { | |
auto now = DateHelper::currentTimeMillis(); | ||
bool newIsAnimating = false; | ||
bool tilesChanged = !tilesStillValid.test_and_set(); | ||
if (abs(newZoom-lastDataManagerZoom) / std::max(newZoom, 1.0) > 0.001 || now - lastDataManagerUpdate > 1000 || isAnimating || tilesChanged) { | ||
double zoomChange = abs(newZoom-lastDataManagerZoom) / std::max(newZoom, 1.0); | ||
double timeDiff = now - lastDataManagerUpdate; | ||
if (zoomChange > 0.001 || timeDiff > 2000 || isAnimating || tilesChanged) { | ||
Comment on lines
+544
to
+546
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The calculation of const double ZOOM_CHANGE_THRESHOLD = 0.001;
...
double zoomChange = abs(newZoom - lastDataManagerZoom) / std::max(newZoom, 1.0);
double timeDiff = now - lastDataManagerUpdate;
if (zoomChange > ZOOM_CHANGE_THRESHOLD || timeDiff > 2000 || isAnimating || tilesChanged) {
...
} |
||
lastDataManagerUpdate = now; | ||
lastDataManagerZoom = newZoom; | ||
|
||
|
@@ -556,7 +558,7 @@ void Tiled2dMapVectorLayer::update() { | |
newIsAnimating |= a; | ||
} | ||
isAnimating = newIsAnimating; | ||
if (now - lastCollitionCheck > 2000 || tilesChanged) { | ||
if (now - lastCollitionCheck > 3000 || tilesChanged) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The time threshold for const long long COLLISION_CHECK_THRESHOLD = 3000;
...
if (now - lastCollitionCheck > COLLISION_CHECK_THRESHOLD || tilesChanged) {
...
} |
||
lastCollitionCheck = now; | ||
bool enforceUpdate = !prevCollisionStillValid.test_and_set(); | ||
collisionManager.syncAccess([&vpMatrix, &viewportSize, viewportRotation, enforceUpdate](const auto &manager) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,17 @@ class SymbolAnimationCoordinator { | |
} | ||
|
||
bool isAnimating() { | ||
return isIconAnimating() || isStretchIconAnimating() || isTextAnimating(); | ||
if (cacheCount >= usageCount) { | ||
return false; | ||
|
||
} | ||
if (isIconAnimating() || isStretchIconAnimating() || isTextAnimating()) { | ||
// printf("Animate %p: %d, %d, %d, %d: %f|%f\n", static_cast<void*>(this), isIconAnimating(), isStretchIconAnimating(), isTextAnimating(), isUsed(), coordinate.x, coordinate.y); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. debug log |
||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The int decreaseCache() {
if (cacheCount <= 0) {
// Handle error or prevent decrement
return cacheCount;
}
return --cacheCount;
} |
||
} | ||
|
||
bool isIconAnimating() { | ||
|
@@ -83,6 +93,14 @@ class SymbolAnimationCoordinator { | |
return --usageCount; | ||
} | ||
|
||
int increaseCache() {; | ||
return ++cacheCount; | ||
} | ||
|
||
int decreaseCache() { | ||
return --cacheCount; | ||
} | ||
Comment on lines
+95
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The output from the Based on the information provided, it appears that there are no safeguards within the Given the evidence from the codebase, the review comment is consistent with the implementation of the Analysis chainTwo new methods, Scripts ExecutedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Verify that cacheCount is not decremented below zero
ast-grep --lang cpp --pattern $'int decreaseCache() {
return --cacheCount;
}'
Length of output: 80 Script: #!/bin/bash
# Search for the decreaseCache method within the SymbolAnimationCoordinator class
ast-grep --lang cpp --pattern $'class $_ {
$$$
int decreaseCache() {
$$$
}
$$$
}'
Length of output: 439 Script: #!/bin/bash
# Use ripgrep to search for the decreaseCache method within the codebase
rg "int decreaseCache\(\)"
Length of output: 125 Script: #!/bin/bash
# Extract the implementation details of the decreaseCache method
rg -A 3 -B 3 "int decreaseCache\(\)" shared/src/map/layers/tiled/vector/symbol/SymbolAnimationCoordinator.h
Length of output: 207 |
||
|
||
std::atomic_flag isOwned = ATOMIC_FLAG_INIT; | ||
|
||
// returns true if the value was changed | ||
|
@@ -112,6 +130,7 @@ class SymbolAnimationCoordinator { | |
float lastTextAlpha = 0; | ||
|
||
std::atomic_int usageCount = 0; | ||
std::atomic_int cacheCount = 0; | ||
|
||
bool collides = true; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diese Änderung ist nötig, weil die GeoJson-Source sonst immer onVisibletilesChanged auslöst.