[core] CapType ⇢ LineCapType

This commit is contained in:
John Firebaugh
2016-04-19 10:10:48 -07:00
parent 4e04a107e8
commit a14f0d2edd
7 changed files with 21 additions and 21 deletions

View File

@@ -56,16 +56,16 @@ MBGL_DEFINE_ENUM_CLASS(VisibilityTypeClass, VisibilityType, {
// -------------------------------------------------------------------------------------------------
enum class CapType : uint8_t {
enum class LineCapType : uint8_t {
Round,
Butt,
Square,
};
MBGL_DEFINE_ENUM_CLASS(CapTypeClass, CapType, {
{ CapType::Round, "round" },
{ CapType::Butt, "butt" },
{ CapType::Square, "square" },
MBGL_DEFINE_ENUM_CLASS(LineCapTypeClass, LineCapType, {
{ LineCapType::Round, "round" },
{ LineCapType::Butt, "butt" },
{ LineCapType::Square, "square" },
});
// -------------------------------------------------------------------------------------------------

View File

@@ -9,7 +9,7 @@ namespace mbgl {
class LineLayoutProperties {
public:
LayoutProperty<CapType> cap { CapType::Butt };
LayoutProperty<LineCapType> cap { LineCapType::Butt };
LayoutProperty<JoinType> join { JoinType::Miter };
LayoutProperty<float> miterLimit { 2.0f };
LayoutProperty<float> roundLimit { 1.0f };

View File

@@ -80,8 +80,8 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
return;
}
const CapType beginCap = layout.cap;
const CapType endCap = closed ? CapType::Butt : CapType(layout.cap);
const LineCapType beginCap = layout.cap;
const LineCapType endCap = closed ? LineCapType::Butt : LineCapType(layout.cap);
double distance = 0;
bool startOfLine = true;
@@ -173,7 +173,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
// The join if a middle vertex, otherwise the cap
const bool middleVertex = prevVertex && nextVertex;
JoinType currentJoin = layout.join;
const CapType currentCap = nextVertex ? beginCap : endCap;
const LineCapType currentCap = nextVertex ? beginCap : endCap;
if (middleVertex) {
if (currentJoin == JoinType::Round) {
@@ -279,7 +279,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
false, startVertex, triangleStore);
}
} else if (!middleVertex && currentCap == CapType::Butt) {
} else if (!middleVertex && currentCap == LineCapType::Butt) {
if (!startOfLine) {
// Close previous segment with a butt
addCurrentVertex(currentVertex, distance, prevNormal, 0, 0, false,
@@ -292,7 +292,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
startVertex, triangleStore);
}
} else if (!middleVertex && currentCap == CapType::Square) {
} else if (!middleVertex && currentCap == LineCapType::Square) {
if (!startOfLine) {
// Close previous segment with a square cap
addCurrentVertex(currentVertex, distance, prevNormal, 1, 1, false,
@@ -308,7 +308,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
startVertex, triangleStore);
}
} else if (middleVertex ? currentJoin == JoinType::Round : currentCap == CapType::Round) {
} else if (middleVertex ? currentJoin == JoinType::Round : currentCap == LineCapType::Round) {
if (!startOfLine) {
// Close previous segment with a butt
addCurrentVertex(currentVertex, distance, prevNormal, 0, 0, false,

View File

@@ -78,8 +78,8 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
linesdfShader->u_blur = blur;
linesdfShader->u_color = color;
LinePatternPos posA = lineAtlas->getDashPosition(properties.dasharray.value.from, layout.cap == CapType::Round, glObjectStore);
LinePatternPos posB = lineAtlas->getDashPosition(properties.dasharray.value.to, layout.cap == CapType::Round, glObjectStore);
LinePatternPos posA = lineAtlas->getDashPosition(properties.dasharray.value.from, layout.cap == LineCapType::Round, glObjectStore);
LinePatternPos posB = lineAtlas->getDashPosition(properties.dasharray.value.to, layout.cap == LineCapType::Round, glObjectStore);
const float widthA = posA.width * properties.dasharray.value.fromScale * properties.dashLineWidth;
const float widthB = posB.width * properties.dasharray.value.toScale * properties.dashLineWidth;

View File

@@ -19,7 +19,7 @@ template <> inline std::array<float, 2> defaultStopsValue() { return {{ 0, 0 }};
template <> inline std:: string defaultStopsValue() { return {}; }
template <> inline TranslateAnchorType defaultStopsValue() { return {}; };
template <> inline RotateAnchorType defaultStopsValue() { return {}; };
template <> inline CapType defaultStopsValue() { return {}; };
template <> inline LineCapType defaultStopsValue() { return {}; };
template <> inline JoinType defaultStopsValue() { return {}; };
template <> inline PlacementType defaultStopsValue() { return {}; };
template <> inline TextAnchorType defaultStopsValue() { return {}; };
@@ -84,7 +84,7 @@ template class Function<std::array<float, 2>>;
template class Function<std::string>;
template class Function<TranslateAnchorType>;
template class Function<RotateAnchorType>;
template class Function<CapType>;
template class Function<LineCapType>;
template class Function<JoinType>;
template class Function<PlacementType>;
template class Function<TextAnchorType>;

View File

@@ -101,13 +101,13 @@ optional<RotateAnchorType> parseProperty<RotateAnchorType>(const char* name, con
}
template <>
optional<CapType> parseProperty<CapType>(const char* name, const JSValue& value) {
optional<LineCapType> parseProperty<LineCapType>(const char* name, const JSValue& value) {
if (!value.IsString()) {
Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name);
return {};
}
return { CapTypeClass({ value.GetString(), value.GetStringLength() }) };
return { LineCapTypeClass({ value.GetString(), value.GetStringLength() }) };
}
template <>
@@ -322,8 +322,8 @@ template <> optional<Function<RotateAnchorType>> parseProperty(const char* name,
return parseFunction<RotateAnchorType>(name, value);
}
template <> optional<Function<CapType>> parseProperty(const char* name, const JSValue& value) {
return parseFunction<CapType>(name, value);
template <> optional<Function<LineCapType>> parseProperty(const char* name, const JSValue& value) {
return parseFunction<LineCapType>(name, value);
}
template <> optional<Function<JoinType>> parseProperty(const char* name, const JSValue& value) {

View File

@@ -38,7 +38,7 @@ template<> inline std::vector<float> interpolate(const std::vector<float> a, con
template<> inline std::string interpolate(const std::string a, const std::string, const double) { return a; }
template<> inline TranslateAnchorType interpolate(const TranslateAnchorType a, const TranslateAnchorType, const double) { return a; }
template<> inline RotateAnchorType interpolate(const RotateAnchorType a, const RotateAnchorType, const double) { return a; }
template<> inline CapType interpolate(const CapType a, const CapType, const double) { return a; }
template<> inline LineCapType interpolate(const LineCapType a, const LineCapType, const double) { return a; }
template<> inline JoinType interpolate(const JoinType a, const JoinType, const double) { return a; }
template<> inline PlacementType interpolate(const PlacementType a, const PlacementType, const double) { return a; }
template<> inline TextAnchorType interpolate(const TextAnchorType a, const TextAnchorType, const double) { return a; }