From 2df1c36ab82af663c6f612da2ffda1fdc13531c2 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 19 Apr 2016 10:12:23 -0700 Subject: [PATCH] =?UTF-8?q?[core]=20JoinType=20=E2=87=A2=20LineJoinType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/mbgl/style/types.hpp | 14 ++++----- src/mbgl/annotation/shape_annotation_impl.cpp | 2 +- src/mbgl/layer/line_layer.hpp | 2 +- src/mbgl/renderer/line_bucket.cpp | 30 +++++++++---------- src/mbgl/style/function.cpp | 4 +-- src/mbgl/style/property_parsing.cpp | 8 ++--- src/mbgl/util/interpolate.hpp | 2 +- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp index 31be19cdc..56821c32b 100644 --- a/include/mbgl/style/types.hpp +++ b/include/mbgl/style/types.hpp @@ -70,7 +70,7 @@ MBGL_DEFINE_ENUM_CLASS(LineCapTypeClass, LineCapType, { // ------------------------------------------------------------------------------------------------- -enum class JoinType : uint8_t { +enum class LineJoinType : uint8_t { Miter, Bevel, Round, @@ -79,12 +79,12 @@ enum class JoinType : uint8_t { FlipBevel }; -MBGL_DEFINE_ENUM_CLASS(JoinTypeClass, JoinType, { - { JoinType::Miter, "miter" }, - { JoinType::Bevel, "bevel" }, - { JoinType::Round, "round" }, - { JoinType::FakeRound, "fakeround" }, - { JoinType::FlipBevel, "flipbevel" }, +MBGL_DEFINE_ENUM_CLASS(LineJoinTypeClass, LineJoinType, { + { LineJoinType::Miter, "miter" }, + { LineJoinType::Bevel, "bevel" }, + { LineJoinType::Round, "round" }, + { LineJoinType::FakeRound, "fakeround" }, + { LineJoinType::FlipBevel, "flipbevel" }, }); // ------------------------------------------------------------------------------------------------- diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index cac5fa072..380a5b774 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -31,7 +31,7 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { type = geojsonvt::ProjectedFeatureType::LineString; std::unique_ptr layer = std::make_unique(); - layer->layout.join = JoinType::Round; + layer->layout.join = LineJoinType::Round; const LineAnnotationProperties& properties = shape.properties.get(); layer->paint.opacity = properties.opacity; diff --git a/src/mbgl/layer/line_layer.hpp b/src/mbgl/layer/line_layer.hpp index 0aa8d3af8..f7f5abdbf 100644 --- a/src/mbgl/layer/line_layer.hpp +++ b/src/mbgl/layer/line_layer.hpp @@ -10,7 +10,7 @@ namespace mbgl { class LineLayoutProperties { public: LayoutProperty cap { LineCapType::Butt }; - LayoutProperty join { JoinType::Miter }; + LayoutProperty join { LineJoinType::Miter }; LayoutProperty miterLimit { 2.0f }; LayoutProperty roundLimit { 1.0f }; }; diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index 2ae2998b9..3d8ef6900 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -67,7 +67,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) { return; } - const float miterLimit = layout.join == JoinType::Bevel ? 1.05f : float(layout.miterLimit); + const float miterLimit = layout.join == LineJoinType::Bevel ? 1.05f : float(layout.miterLimit); const double sharpCornerOffset = SHARP_CORNER_OFFSET * (float(util::EXTENT) / (util::tileSize * overscaling)); @@ -172,33 +172,33 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) { // The join if a middle vertex, otherwise the cap const bool middleVertex = prevVertex && nextVertex; - JoinType currentJoin = layout.join; + LineJoinType currentJoin = layout.join; const LineCapType currentCap = nextVertex ? beginCap : endCap; if (middleVertex) { - if (currentJoin == JoinType::Round) { + if (currentJoin == LineJoinType::Round) { if (miterLength < layout.roundLimit) { - currentJoin = JoinType::Miter; + currentJoin = LineJoinType::Miter; } else if (miterLength <= 2) { - currentJoin = JoinType::FakeRound; + currentJoin = LineJoinType::FakeRound; } } - if (currentJoin == JoinType::Miter && miterLength > miterLimit) { - currentJoin = JoinType::Bevel; + if (currentJoin == LineJoinType::Miter && miterLength > miterLimit) { + currentJoin = LineJoinType::Bevel; } - if (currentJoin == JoinType::Bevel) { + if (currentJoin == LineJoinType::Bevel) { // The maximum extrude length is 128 / 63 = 2 times the width of the line // so if miterLength >= 2 we need to draw a different type of bevel where. if (miterLength > 2) { - currentJoin = JoinType::FlipBevel; + currentJoin = LineJoinType::FlipBevel; } // If the miterLength is really small and the line bevel wouldn't be visible, // just draw a miter join to save a triangle. if (miterLength < miterLimit) { - currentJoin = JoinType::Miter; + currentJoin = LineJoinType::Miter; } } } @@ -207,12 +207,12 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) { if (prevVertex) distance += util::dist(currentVertex, prevVertex); - if (middleVertex && currentJoin == JoinType::Miter) { + if (middleVertex && currentJoin == LineJoinType::Miter) { joinNormal = joinNormal * miterLength; addCurrentVertex(currentVertex, distance, joinNormal, 0, 0, false, startVertex, triangleStore); - } else if (middleVertex && currentJoin == JoinType::FlipBevel) { + } else if (middleVertex && currentJoin == LineJoinType::FlipBevel) { // miter is too big, flip the direction to make a beveled join if (miterLength > 100) { @@ -230,7 +230,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) { addCurrentVertex(currentVertex, distance, joinNormal * -1.0, 0, 0, false, startVertex, triangleStore); - } else if (middleVertex && (currentJoin == JoinType::Bevel || currentJoin == JoinType::FakeRound)) { + } else if (middleVertex && (currentJoin == LineJoinType::Bevel || currentJoin == LineJoinType::FakeRound)) { const bool lineTurnsLeft = (prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x) > 0; const float offset = -std::sqrt(miterLength * miterLength - 1); float offsetA; @@ -250,7 +250,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) { startVertex, triangleStore); } - if (currentJoin == JoinType::FakeRound) { + if (currentJoin == LineJoinType::FakeRound) { // The join angle is sharp enough that a round join would be visible. // Bevel joins fill the gap between segments with a single pie slice triangle. // Create a round join by adding multiple pie slices. The join isn't actually round, but @@ -308,7 +308,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) { startVertex, triangleStore); } - } else if (middleVertex ? currentJoin == JoinType::Round : currentCap == LineCapType::Round) { + } else if (middleVertex ? currentJoin == LineJoinType::Round : currentCap == LineCapType::Round) { if (!startOfLine) { // Close previous segment with a butt addCurrentVertex(currentVertex, distance, prevNormal, 0, 0, false, diff --git a/src/mbgl/style/function.cpp b/src/mbgl/style/function.cpp index 501f27fca..a3427fd4d 100644 --- a/src/mbgl/style/function.cpp +++ b/src/mbgl/style/function.cpp @@ -20,7 +20,7 @@ template <> inline std:: string defaultStopsValue() { return {}; } template <> inline TranslateAnchorType defaultStopsValue() { return {}; }; template <> inline RotateAnchorType defaultStopsValue() { return {}; }; template <> inline LineCapType defaultStopsValue() { return {}; }; -template <> inline JoinType defaultStopsValue() { return {}; }; +template <> inline LineJoinType defaultStopsValue() { return {}; }; template <> inline PlacementType defaultStopsValue() { return {}; }; template <> inline TextAnchorType defaultStopsValue() { return {}; }; template <> inline TextJustifyType defaultStopsValue() { return {}; }; @@ -85,7 +85,7 @@ template class Function; template class Function; template class Function; template class Function; -template class Function; +template class Function; template class Function; template class Function; template class Function; diff --git a/src/mbgl/style/property_parsing.cpp b/src/mbgl/style/property_parsing.cpp index 056c78bcf..d1f3fb350 100644 --- a/src/mbgl/style/property_parsing.cpp +++ b/src/mbgl/style/property_parsing.cpp @@ -111,13 +111,13 @@ optional parseProperty(const char* name, const JSValue } template <> -optional parseProperty(const char* name, const JSValue& value) { +optional parseProperty(const char* name, const JSValue& value) { if (!value.IsString()) { Log::Warning(Event::ParseStyle, "value of '%s' must be a string", name); return {}; } - return { JoinTypeClass({ value.GetString(), value.GetStringLength() }) }; + return { LineJoinTypeClass({ value.GetString(), value.GetStringLength() }) }; } template <> @@ -326,8 +326,8 @@ template <> optional> parseProperty(const char* name, cons return parseFunction(name, value); } -template <> optional> parseProperty(const char* name, const JSValue& value) { - return parseFunction(name, value); +template <> optional> parseProperty(const char* name, const JSValue& value) { + return parseFunction(name, value); } template <> optional> parseProperty(const char* name, const JSValue& value) { diff --git a/src/mbgl/util/interpolate.hpp b/src/mbgl/util/interpolate.hpp index 499783342..7d8627e7d 100644 --- a/src/mbgl/util/interpolate.hpp +++ b/src/mbgl/util/interpolate.hpp @@ -39,7 +39,7 @@ template<> inline std::string interpolate(const std::string a, const std::string 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 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 LineJoinType interpolate(const LineJoinType a, const LineJoinType, 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; } template<> inline TextJustifyType interpolate(const TextJustifyType a, const TextJustifyType, const double) { return a; }