From 45890ff674b7d2184192a820db79cf7c2be20d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Mon, 23 May 2016 15:07:59 -0700 Subject: [PATCH] [osx] Added stencil buffer option Added an option to display the stencil buffer instead of the color buffer in osxapp. --- platform/osx/CHANGELOG.md | 2 +- platform/osx/app/Base.lproj/MainMenu.xib | 13 +++++++++++++ platform/osx/app/MapDocument.m | 18 ++++++++++++++++++ platform/osx/src/MGLMapView.h | 3 +++ platform/osx/src/MGLMapView.mm | 6 ++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/platform/osx/CHANGELOG.md b/platform/osx/CHANGELOG.md index 6dd7b5bb3..df26619ba 100644 --- a/platform/osx/CHANGELOG.md +++ b/platform/osx/CHANGELOG.md @@ -4,7 +4,7 @@ * Fixed an issue in which Mapbox.framework was nested inside another folder named Mapbox.framework. ([#4998](https://github.com/mapbox/mapbox-gl-native/pull/4998)) * Fixed a crash passing a mixture of point and shape annotations into `-[MGLMapView addAnnotations:]`. ([#5097](https://github.com/mapbox/mapbox-gl-native/pull/5097)) -* 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 new options to `MGLMapDebugMaskOptions` that show wireframes and the stencil buffer instead of the color buffer. ([#4359](https://github.com/mapbox/mapbox-gl-native/pull/4359)) ## 0.1.0 diff --git a/platform/osx/app/Base.lproj/MainMenu.xib b/platform/osx/app/Base.lproj/MainMenu.xib index b37d1e154..4afb3b244 100644 --- a/platform/osx/app/Base.lproj/MainMenu.xib +++ b/platform/osx/app/Base.lproj/MainMenu.xib @@ -467,6 +467,19 @@ + + + + + + + + + + + + + diff --git a/platform/osx/app/MapDocument.m b/platform/osx/app/MapDocument.m index df6aa98c3..9bff4603e 100644 --- a/platform/osx/app/MapDocument.m +++ b/platform/osx/app/MapDocument.m @@ -248,6 +248,14 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { self.mapView.debugMask ^= MGLMapDebugWireframesMask; } +- (IBAction)showColorBuffer:(id)sender { + self.mapView.debugMask &= ~MGLMapDebugStencilBufferMask; +} + +- (IBAction)showStencilBuffer:(id)sender { + self.mapView.debugMask |= MGLMapDebugStencilBufferMask; +} + - (IBAction)toggleShowsToolTipsOnDroppedPins:(id)sender { _showsToolTipsOnDroppedPins = !_showsToolTipsOnDroppedPins; } @@ -529,6 +537,16 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { menuItem.title = isShown ? @"Hide Wireframes" : @"Show Wireframes"; return YES; } + if (menuItem.action == @selector(showColorBuffer:)) { + BOOL enabled = self.mapView.debugMask & MGLMapDebugStencilBufferMask; + menuItem.state = enabled ? NSOffState : NSOnState; + return YES; + } + if (menuItem.action == @selector(showStencilBuffer:)) { + BOOL enabled = self.mapView.debugMask & MGLMapDebugStencilBufferMask; + menuItem.state = enabled ? NSOnState : NSOffState; + return YES; + } if (menuItem.action == @selector(toggleShowsToolTipsOnDroppedPins:)) { BOOL isShown = _showsToolTipsOnDroppedPins; menuItem.title = isShown ? @"Hide Tooltips on Dropped Pins" : @"Show Tooltips on Dropped Pins"; diff --git a/platform/osx/src/MGLMapView.h b/platform/osx/src/MGLMapView.h index a98853f6c..749b3561d 100644 --- a/platform/osx/src/MGLMapView.h +++ b/platform/osx/src/MGLMapView.h @@ -24,6 +24,9 @@ typedef NS_OPTIONS(NSUInteger, MGLMapDebugMaskOptions) { /** Line widths, backgrounds, and fill colors are ignored to create a wireframe effect. */ MGLMapDebugWireframesMask = 1 << 5, + + /** The stencil buffer is shown instead of the color buffer. */ + MGLMapDebugStencilBufferMask = 1 << 6, }; @class MGLAnnotationImage; diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index cdac60dd8..5b85ff7ec 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -2369,6 +2369,9 @@ public: if (options & mbgl::MapDebugOptions::Wireframe) { mask |= MGLMapDebugWireframesMask; } + if (options & mbgl::MapDebugOptions::StencilClip) { + mask |= MGLMapDebugStencilBufferMask; + } return mask; } @@ -2389,6 +2392,9 @@ public: if (debugMask & MGLMapDebugWireframesMask) { options |= mbgl::MapDebugOptions::Wireframe; } + if (debugMask & MGLMapDebugStencilBufferMask) { + options |= mbgl::MapDebugOptions::StencilClip; + } _mbglMap->setDebug(options); }