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.
Fix undefined memory access in getCoveringRanges() (#9227)
* Add simple unit tests for SymbolSizeBinder * Fix bug in symbol size uniform value calculation For camera functions we were setting the zoom levels in "covering ranges" to `[(zoom stop <= tile zoom), (zoom stop >= 1 + tile zoom)]`, but then evaluating the function at `[tile_zoom, tile_zoom + 1]`. * Check for it != end() before accessing it->first
- Loading branch information
1 parent
66c2a2a
commit f59eb82
Showing
4 changed files
with
67 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <mbgl/test/util.hpp> | ||
|
||
#include <mbgl/programs/symbol_program.hpp> | ||
|
||
using namespace mbgl; | ||
|
||
TEST(SymbolProgram, SymbolSizeBinder) { | ||
auto binder = SymbolSizeBinder::create(5.0f, 12.0f, 0.0f); | ||
auto uniformValues = binder->uniformValues(5.5f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, true); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, true); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_size>().t, 12.0f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_layout_size>().t, 12.0f); | ||
|
||
binder = SymbolSizeBinder::create(1.0f, style::CameraFunction<float>(style::ExponentialStops<float>({ | ||
{0.0f, 8.0f}, | ||
{10.0f, 18.0f} | ||
}, 1.0f)), 0.0f); | ||
uniformValues = binder->uniformValues(1.5f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, false); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, true); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_size>().t, 9.5f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_layout_size>().t, 10.0f); | ||
|
||
binder = SymbolSizeBinder::create(0.0f, style::CameraFunction<float>(style::ExponentialStops<float>({ | ||
{1.0f, 8.0f}, | ||
{11.0f, 18.0f} | ||
}, 1.0f)), 0.0f); | ||
uniformValues = binder->uniformValues(0.5f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, false); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, true); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_size>().t, 8.0f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_layout_size>().t, 8.0f); | ||
|
||
binder = SymbolSizeBinder::create(12.0f, style::CameraFunction<float>(style::ExponentialStops<float>({ | ||
{1.0f, 8.0f}, | ||
{11.0f, 18.0f} | ||
}, 1.0f)), 0.0f); | ||
uniformValues = binder->uniformValues(12.5f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, false); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, true); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_size>().t, 18.0f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_layout_size>().t, 18.0f); | ||
|
||
binder = SymbolSizeBinder::create(0.0f, style::SourceFunction<float>("x", style::ExponentialStops<float>({ | ||
{1.0f, 8.0f}, | ||
{11.0f, 18.0f} | ||
}, 1.0f)), 0.0f); | ||
uniformValues = binder->uniformValues(12.5f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, true); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, false); | ||
|
||
binder = SymbolSizeBinder::create(5.0f, style::CompositeFunction<float>("x", style::CompositeExponentialStops<float>({ | ||
{1.0f, {{0.0f, 8.0f}, {100.0f, 18.0f}}}, | ||
{11.0f, {{0.0f, 12.0f}, {100.0f, 24.9f}}} | ||
}, 1.0f)), 0.0f); | ||
uniformValues = binder->uniformValues(5.5f); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, false); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, false); | ||
EXPECT_EQ(uniformValues.get<uniforms::u_size_t>().t, 0.45f); | ||
} |