From 97dffeb03dba6ae949ca9ce2e054ceab3acb99b7 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 20 Jun 2016 13:18:16 +0300 Subject: [PATCH] [core] s/Wireframe/Overdraw/g --- include/mbgl/map/mode.hpp | 2 +- platform/ios/CHANGELOG.md | 2 +- platform/ios/app/MBXViewController.m | 8 ++++---- platform/ios/src/MGLMapView.h | 5 ++--- platform/ios/src/MGLMapView.mm | 8 ++++---- platform/macos/CHANGELOG.md | 1 + platform/macos/app/Base.lproj/MainMenu.xib | 4 ++-- platform/macos/app/MapDocument.m | 10 +++++----- platform/macos/src/MGLMapView.h | 5 ++--- platform/macos/src/MGLMapView.mm | 8 ++++---- src/mbgl/map/map.cpp | 6 +++--- src/mbgl/renderer/painter.cpp | 4 ++-- src/mbgl/renderer/painter.hpp | 2 +- src/mbgl/renderer/painter_background.cpp | 4 ++-- src/mbgl/renderer/painter_circle.cpp | 2 +- src/mbgl/renderer/painter_fill.cpp | 10 +++++----- src/mbgl/renderer/painter_line.cpp | 6 +++--- src/mbgl/renderer/painter_raster.cpp | 2 +- src/mbgl/renderer/painter_symbol.cpp | 4 ++-- src/mbgl/style/style.cpp | 4 ++-- 20 files changed, 48 insertions(+), 49 deletions(-) diff --git a/include/mbgl/map/mode.hpp b/include/mbgl/map/mode.hpp index 80ba4d756..c9b9f6095 100644 --- a/include/mbgl/map/mode.hpp +++ b/include/mbgl/map/mode.hpp @@ -43,7 +43,7 @@ enum class MapDebugOptions : EnumType { ParseStatus = 1 << 2, Timestamps = 1 << 3, Collision = 1 << 4, - Wireframe = 1 << 5, + Overdraw = 1 << 5, // FIXME: https://github.com/mapbox/mapbox-gl-native/issues/5117 #ifndef GL_ES_VERSION_2_0 StencilClip = 1 << 6, diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 63bd5b964..b98819b10 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -33,7 +33,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CON - Removed unused SVG files from the SDK’s resource bundle. ([#4641](https://github.com/mapbox/mapbox-gl-native/pull/4641)) - Deprecated `-[MGLMapView emptyMemoryCache]`. ([#4725](https://github.com/mapbox/mapbox-gl-native/pull/4725)) - Added `MGLCoordinateInCoordinateBounds()`, a function that tests whether or not a coordinate is in a given bounds. ([#5053](https://github.com/mapbox/mapbox-gl-native/pull/5053)) -- Added a new option to `MGLMapDebugMaskOptions`, `MGLMapDebugWireframesMask`, that shows wireframes instead of the usual rendered output. ([#4359](https://github.com/mapbox/mapbox-gl-native/pull/4359)) +- Added a new option to `MGLMapDebugMaskOptions`, `MGLMapDebugOverdrawsMask`, that shows wireframes for overdraw inspection instead of the usual rendered output. ([#4359](https://github.com/mapbox/mapbox-gl-native/pull/4359)) ## 3.2.3 diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 8317aee1d..7bdc023c4 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -181,9 +181,9 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie ((debugMask & MGLMapDebugCollisionBoxesMask) ? @"Hide Collision Boxes" : @"Show Collision Boxes"), - ((debugMask & MGLMapDebugWireframesMask) - ? @"Hide Wireframes" - : @"Show Wireframes"), + ((debugMask & MGLMapDebugOverdrawsMask) + ? @"Hide Overdraws" + : @"Show Overdraws"), @"Add 100 Points", @"Add 1,000 Points", @"Add 10,000 Points", @@ -226,7 +226,7 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 5) { - self.mapView.debugMask ^= MGLMapDebugWireframesMask; + self.mapView.debugMask ^= MGLMapDebugOverdrawsMask; } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 6) { diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index 1319228c1..5fffc4323 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -43,9 +43,8 @@ typedef NS_OPTIONS(NSUInteger, MGLMapDebugMaskOptions) { /** Edges of glyphs and symbols are shown as faint, green lines to help diagnose collision and label placement issues. */ MGLMapDebugCollisionBoxesMask = 1 << 4, - /** Line widths, backgrounds, and fill colors are ignored to create a - wireframe effect. */ - MGLMapDebugWireframesMask = 1 << 5, + /** Overdraw inspector. */ + MGLMapDebugOverdrawsMask = 1 << 5, }; /** diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index b9d44a9a0..8a255a391 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1829,9 +1829,9 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) { mask |= MGLMapDebugCollisionBoxesMask; } - if (options & mbgl::MapDebugOptions::Wireframe) + if (options & mbgl::MapDebugOptions::Overdraw) { - mask |= MGLMapDebugWireframesMask; + mask |= MGLMapDebugOverdrawsMask; } return mask; } @@ -1855,9 +1855,9 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) { options |= mbgl::MapDebugOptions::Collision; } - if (debugMask & MGLMapDebugWireframesMask) + if (debugMask & MGLMapDebugOverdrawsMask) { - options |= mbgl::MapDebugOptions::Wireframe; + options |= mbgl::MapDebugOptions::Overdraw; } _mbglMap->setDebug(options); } diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index bf7333bc5..f41ca3ce9 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog for Mapbox macOS SDK ## master +* Refactor wireframe mode to match GL JS overdraw implementation. ([#5403](https://github.com/mapbox/mapbox-gl-native/pull/5403)). ## 0.2.0 diff --git a/platform/macos/app/Base.lproj/MainMenu.xib b/platform/macos/app/Base.lproj/MainMenu.xib index 74cfb2638..ae10fe5d3 100644 --- a/platform/macos/app/Base.lproj/MainMenu.xib +++ b/platform/macos/app/Base.lproj/MainMenu.xib @@ -461,10 +461,10 @@ - + - + diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index a6c9e6282..8c3922e2d 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -276,8 +276,8 @@ NS_ARRAY_OF(id ) *MBXFlattenedShapes(NS_ARRAY_OF(id ) *MBXFlattenedShapes(NS_ARRAY_OF(id debugOptions & MapDebugOptions::StencilClip) impl->debugOptions = MapDebugOptions::NoDebug; - else if (impl->debugOptions & MapDebugOptions::Wireframe) + else if (impl->debugOptions & MapDebugOptions::Overdraw) impl->debugOptions = MapDebugOptions::StencilClip; #else - if (impl->debugOptions & MapDebugOptions::Wireframe) + if (impl->debugOptions & MapDebugOptions::Overdraw) impl->debugOptions = MapDebugOptions::NoDebug; #endif // GL_ES_VERSION_2_0 else if (impl->debugOptions & MapDebugOptions::Collision) - impl->debugOptions = MapDebugOptions::Wireframe; + impl->debugOptions = MapDebugOptions::Overdraw; else if (impl->debugOptions & MapDebugOptions::Timestamps) impl->debugOptions = impl->debugOptions | MapDebugOptions::Collision; else if (impl->debugOptions & MapDebugOptions::ParseStatus) diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index fae5c74d7..56276c26c 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -145,7 +145,7 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a config.depthMask = GL_TRUE; config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; - if (isWireframe()) { + if (isOverdraw()) { config.blend = GL_TRUE; config.blendFunc = { GL_CONSTANT_COLOR, GL_ONE }; const float overdraw = 1.0f / 8.0f; @@ -248,7 +248,7 @@ void Painter::renderPass(RenderPass pass_, if (!layer.baseImpl->hasRenderPass(pass)) continue; - if (isWireframe()) { + if (isOverdraw()) { config.blend = GL_TRUE; } else if (pass == RenderPass::Translucent) { config.blendFunc.reset(); diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index d2d722ef7..1f511467d 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -156,7 +156,7 @@ private: void setDepthSublayer(int n); - bool isWireframe() const { return frame.debugOptions & MapDebugOptions::Wireframe; } + bool isOverdraw() const { return frame.debugOptions & MapDebugOptions::Overdraw; } mat4 projMatrix; mat4 nativeMatrix; diff --git a/src/mbgl/renderer/painter_background.cpp b/src/mbgl/renderer/painter_background.cpp index f9a67ee59..7ced6a5c4 100644 --- a/src/mbgl/renderer/painter_background.cpp +++ b/src/mbgl/renderer/painter_background.cpp @@ -28,7 +28,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) { if (!imagePosA || !imagePosB) return; - config.program = isWireframe() ? patternShader->getOverdrawID() : patternShader->getID(); + config.program = isOverdraw() ? patternShader->getOverdrawID() : patternShader->getID(); patternShader->u_matrix = identityMatrix; patternShader->u_pattern_tl_a = imagePosA->tl; patternShader->u_pattern_br_a = imagePosA->br; @@ -44,7 +44,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) { plainShader->u_color = properties.backgroundColor; plainShader->u_opacity = properties.backgroundOpacity; - config.program = isWireframe() ? plainShader->getOverdrawID() : plainShader->getID(); + config.program = isOverdraw() ? plainShader->getOverdrawID() : plainShader->getID(); backgroundArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0), store); } diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp index d92ca1ae9..e72f8a994 100644 --- a/src/mbgl/renderer/painter_circle.cpp +++ b/src/mbgl/renderer/painter_circle.cpp @@ -27,7 +27,7 @@ void Painter::renderCircle(CircleBucket& bucket, mat4 vtxMatrix = translatedMatrix(matrix, properties.circleTranslate, tileID, properties.circleTranslateAnchor); - config.program = isWireframe() ? circleShader->getOverdrawID() : circleShader->getID(); + config.program = isOverdraw() ? circleShader->getOverdrawID() : circleShader->getID(); circleShader->u_matrix = vtxMatrix; circleShader->u_extrude_scale = extrudeScale; diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp index 62e808614..44cdbe741 100644 --- a/src/mbgl/renderer/painter_fill.cpp +++ b/src/mbgl/renderer/painter_fill.cpp @@ -46,7 +46,7 @@ void Painter::renderFill(FillBucket& bucket, // Because we're drawing top-to-bottom, and we update the stencil mask // befrom, we have to draw the outline first (!) if (outline && pass == RenderPass::Translucent) { - config.program = isWireframe() ? outlineShader->getOverdrawID() : outlineShader->getID(); + config.program = isOverdraw() ? outlineShader->getOverdrawID() : outlineShader->getID(); outlineShader->u_matrix = vertexMatrix; outlineShader->u_outline_color = strokeColor; @@ -76,7 +76,7 @@ void Painter::renderFill(FillBucket& bucket, // Image fill. if (pass == RenderPass::Translucent && imagePosA && imagePosB) { - config.program = isWireframe() ? patternShader->getOverdrawID() : patternShader->getID(); + config.program = isOverdraw() ? patternShader->getOverdrawID() : patternShader->getID(); patternShader->u_matrix = vertexMatrix; patternShader->u_pattern_tl_a = imagePosA->tl; patternShader->u_pattern_br_a = imagePosA->br; @@ -105,7 +105,7 @@ void Painter::renderFill(FillBucket& bucket, bucket.drawElements(*patternShader, store); if (properties.fillAntialias && !isOutlineColorDefined) { - config.program = isWireframe() ? outlinePatternShader->getOverdrawID() : outlinePatternShader->getID(); + config.program = isOverdraw() ? outlinePatternShader->getOverdrawID() : outlinePatternShader->getID(); outlinePatternShader->u_matrix = vertexMatrix; // Draw the entire line @@ -140,7 +140,7 @@ void Painter::renderFill(FillBucket& bucket, // fragments or when it's translucent and we're drawing translucent // fragments // Draw filling rectangle. - config.program = isWireframe() ? plainShader->getOverdrawID() : plainShader->getID(); + config.program = isOverdraw() ? plainShader->getOverdrawID() : plainShader->getID(); plainShader->u_matrix = vertexMatrix; plainShader->u_color = fillColor; plainShader->u_opacity = opacity; @@ -154,7 +154,7 @@ void Painter::renderFill(FillBucket& bucket, // Because we're drawing top-to-bottom, and we update the stencil mask // below, we have to draw the outline first (!) if (fringeline && pass == RenderPass::Translucent) { - config.program = isWireframe() ? outlineShader->getOverdrawID() : outlineShader->getID(); + config.program = isOverdraw() ? outlineShader->getOverdrawID() : outlineShader->getID(); outlineShader->u_matrix = vertexMatrix; outlineShader->u_outline_color = fillColor; diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp index 447e3f740..206255095 100644 --- a/src/mbgl/renderer/painter_line.cpp +++ b/src/mbgl/renderer/painter_line.cpp @@ -57,7 +57,7 @@ void Painter::renderLine(LineBucket& bucket, if (!properties.lineDasharray.value.from.empty()) { - config.program = isWireframe() ? linesdfShader->getOverdrawID() : linesdfShader->getID(); + config.program = isOverdraw() ? linesdfShader->getOverdrawID() : linesdfShader->getID(); linesdfShader->u_matrix = vtxMatrix; linesdfShader->u_linewidth = properties.lineWidth / 2; @@ -102,7 +102,7 @@ void Painter::renderLine(LineBucket& bucket, if (!imagePosA || !imagePosB) return; - config.program = isWireframe() ? linepatternShader->getOverdrawID() : linepatternShader->getID(); + config.program = isOverdraw() ? linepatternShader->getOverdrawID() : linepatternShader->getID(); linepatternShader->u_matrix = vtxMatrix; linepatternShader->u_linewidth = properties.lineWidth / 2; @@ -138,7 +138,7 @@ void Painter::renderLine(LineBucket& bucket, bucket.drawLinePatterns(*linepatternShader, store); } else { - config.program = isWireframe() ? lineShader->getOverdrawID() : lineShader->getID(); + config.program = isOverdraw() ? lineShader->getOverdrawID() : lineShader->getID(); lineShader->u_matrix = vtxMatrix; lineShader->u_linewidth = properties.lineWidth / 2; diff --git a/src/mbgl/renderer/painter_raster.cpp b/src/mbgl/renderer/painter_raster.cpp index 6394d61dc..783879892 100644 --- a/src/mbgl/renderer/painter_raster.cpp +++ b/src/mbgl/renderer/painter_raster.cpp @@ -18,7 +18,7 @@ void Painter::renderRaster(RasterBucket& bucket, const RasterPaintProperties& properties = layer.impl->paint; if (bucket.hasData()) { - config.program = isWireframe() ? rasterShader->getOverdrawID() : rasterShader->getID(); + config.program = isOverdraw() ? rasterShader->getOverdrawID() : rasterShader->getID(); rasterShader->u_matrix = matrix; rasterShader->u_buffer = 0; rasterShader->u_opacity = properties.rasterOpacity; diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index 374500986..7eb4e6fce 100644 --- a/src/mbgl/renderer/painter_symbol.cpp +++ b/src/mbgl/renderer/painter_symbol.cpp @@ -58,7 +58,7 @@ void Painter::renderSDF(SymbolBucket &bucket, exScale = {{ exScale[0] * scale, exScale[1] * scale }}; } - config.program = isWireframe() ? sdfShader.getOverdrawID() : sdfShader.getID(); + config.program = isOverdraw() ? sdfShader.getOverdrawID() : sdfShader.getID(); sdfShader.u_matrix = vtxMatrix; sdfShader.u_extrude_scale = exScale; sdfShader.u_texsize = texsize; @@ -199,7 +199,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, exScale = {{ exScale[0] * scale, exScale[1] * scale }}; } - config.program = isWireframe() ? iconShader->getOverdrawID() : iconShader->getID(); + config.program = isOverdraw() ? iconShader->getOverdrawID() : iconShader->getID(); iconShader->u_matrix = vtxMatrix; iconShader->u_extrude_scale = exScale; iconShader->u_texsize = {{ float(activeSpriteAtlas->getWidth()) / 4.0f, float(activeSpriteAtlas->getHeight()) / 4.0f }}; diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index c3bc5d73a..cb48790c9 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -272,8 +272,8 @@ RenderData Style::getRenderData(MapDebugOptions debugOptions) const { continue; if (const BackgroundLayer* background = layer->as()) { - if (debugOptions & MapDebugOptions::Wireframe) { - // We want to skip glClear optimization in wireframe mode. + if (debugOptions & MapDebugOptions::Overdraw) { + // We want to skip glClear optimization in overdraw mode. result.order.emplace_back(*layer); continue; }