This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick arabic text to release branch v3.6.0 (#9071)
* [core] Throttle tiles to redo symbol placement at most once every 300ms. Fixes issue #8435 and prepares for pitch-scaling changes in issue #8967. * [core] Disable letter-spacing for Arabic labels (issue #9057)
- Loading branch information
1 parent
71b6865
commit fe17f7e
Showing
8 changed files
with
94 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <mbgl/util/throttler.hpp> | ||
|
||
namespace mbgl { | ||
namespace util { | ||
|
||
Throttler::Throttler(Duration frequency_, std::function<void()>&& function_) | ||
: frequency(frequency_) | ||
, function(std::move(function_)) | ||
, pendingInvocation(false) | ||
, lastInvocation(TimePoint::min()) | ||
{} | ||
|
||
void Throttler::invoke() { | ||
if (pendingInvocation) { | ||
return; | ||
} | ||
|
||
Duration timeToNextInvocation = lastInvocation == TimePoint::min() | ||
? Duration::zero() | ||
: (lastInvocation + frequency) - Clock::now(); | ||
|
||
if (timeToNextInvocation <= Duration::zero()) { | ||
lastInvocation = Clock::now(); | ||
function(); | ||
} else { | ||
pendingInvocation = true; | ||
timer.start(timeToNextInvocation, Duration::zero(), [this]{ | ||
pendingInvocation = false; | ||
lastInvocation = Clock::now(); | ||
function(); | ||
}); | ||
} | ||
} | ||
|
||
} // namespace util | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <mbgl/util/chrono.hpp> | ||
#include <mbgl/util/timer.hpp> | ||
|
||
namespace mbgl { | ||
namespace util { | ||
|
||
class Throttler { | ||
public: | ||
Throttler(Duration frequency, std::function<void()>&& function); | ||
|
||
void invoke(); | ||
private: | ||
Duration frequency; | ||
std::function<void()> function; | ||
|
||
Timer timer; | ||
bool pendingInvocation; | ||
TimePoint lastInvocation; | ||
}; | ||
|
||
} // namespace util | ||
} // namespace mbgl |