Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[CP] #16249 and #16255 to v1.3.0 #16257

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

## master

## maps-v1.3.0 (2020.02-relvanillashake)
## maps-v1.3.1 (2020.02-release-vanillashake)

### 🐞 Bug fixes

- [core] Fix iterators in addRegularDash() ([#16249](https://github.com/mapbox/mapbox-gl-native/pull/16249))

Fixes possible crashes when using styles with line patterns.

- [default] Fix possible crash at RunLoop::wake() ([#16255](https://github.com/mapbox/mapbox-gl-native/pull/16255))

## maps-v1.3.0 (2020.02-release-vanillashake)

### 🐞 Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion platform/default/src/mbgl/util/run_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ LOOP_HANDLE RunLoop::getLoopHandle() {
}

void RunLoop::wake() {
impl->async->send();
if (impl->async) impl->async->send();
}

void RunLoop::run() {
Expand Down
24 changes: 14 additions & 10 deletions src/mbgl/geometry/line_atlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ void addRoundDash(
const std::vector<DashRange>& ranges, uint32_t yOffset, float stretch, const int n, AlphaImage& image) {
const float halfStretch = stretch * 0.5f;

if (ranges.empty()) return;

for (int y = -n; y <= n; y++) {
int row = yOffset + n + y;
const uint32_t index = image.size.width * row;
uint32_t currIndex = 0;
DashRange range = ranges[currIndex];

for (uint32_t x = 0; x < image.size.width; x++) {
if (x / range.right > 1.0f) {
range = ranges[++currIndex];
for (uint32_t x = 0; x < image.size.width; ++x) {
if (x / range.right > 1.0f && ++currIndex < ranges.size()) {
range = ranges[currIndex];
}

float distLeft = fabsf(x - range.left);
Expand All @@ -84,22 +86,24 @@ void addRegularDash(std::vector<DashRange>& ranges, uint32_t yOffset, AlphaImage
// Collapse any zero-length range
for (auto it = ranges.begin(); it != ranges.end();) {
if (it->isZeroLength) {
ranges.erase(it);
it = ranges.erase(it);
} else {
++it;
}
}

if (ranges.size() >= 2) {
if (ranges.empty()) return;

if (ranges.size() > 1) {
// Collapse neighbouring same-type parts into a single part
for (auto curr = ranges.begin(), next = ranges.begin() + 1; curr != ranges.end() && next != ranges.end();) {
for (auto curr = ranges.begin(), next = ranges.begin() + 1; next != ranges.end();) {
if (next->isDash == curr->isDash) {
next->left = curr->left;
ranges.erase(curr);
curr = ranges.erase(curr);
} else {
++curr;
++next;
}
next = curr + 1;
}
}

Expand All @@ -115,8 +119,8 @@ void addRegularDash(std::vector<DashRange>& ranges, uint32_t yOffset, AlphaImage
DashRange range = ranges[currIndex];

for (uint32_t x = 0; x < image.size.width; ++x) {
if (x / range.right > 1.0f) {
range = ranges[++currIndex];
if (x / range.right > 1.0f && ++currIndex < ranges.size()) {
range = ranges[currIndex];
}

float distLeft = fabsf(x - range.left);
Expand Down