From 081e4e44516937a6139fad5823dd5ec3200cc343 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 16 Dec 2015 14:05:54 -0800 Subject: Revert "[ios] Custom style layer" ec9a4cd3285da280d43c7ddd0ca96fe37d9c5278 --- gyp/platform-ios.gypi | 1 - .../ios/MGLMapView+MGLCustomStyleLayerAdditions.h | 22 -------- include/mbgl/ios/Mapbox.h | 1 - ios/app/MBXViewController.mm | 59 ------------------- platform/ios/MGLMapView.mm | 66 ---------------------- 5 files changed, 149 deletions(-) delete mode 100644 include/mbgl/ios/MGLMapView+MGLCustomStyleLayerAdditions.h diff --git a/gyp/platform-ios.gypi b/gyp/platform-ios.gypi index 22a44dd31a..d510d25c03 100644 --- a/gyp/platform-ios.gypi +++ b/gyp/platform-ios.gypi @@ -50,7 +50,6 @@ '../platform/ios/MGLMapboxEvents.m', '../include/mbgl/ios/MGLMapView.h', '../include/mbgl/ios/MGLMapView+IBAdditions.h', - '../include/mbgl/ios/MGLMapView+MGLCustomStyleLayerAdditions.h', '../platform/ios/MGLMapView.mm', '../include/mbgl/ios/MGLAccountManager.h', '../platform/ios/MGLAccountManager_Private.h', diff --git a/include/mbgl/ios/MGLMapView+MGLCustomStyleLayerAdditions.h b/include/mbgl/ios/MGLMapView+MGLCustomStyleLayerAdditions.h deleted file mode 100644 index 4785a36cfa..0000000000 --- a/include/mbgl/ios/MGLMapView+MGLCustomStyleLayerAdditions.h +++ /dev/null @@ -1,22 +0,0 @@ -#import "MGLMapView.h" - -NS_ASSUME_NONNULL_BEGIN - -typedef void (^MGLCustomStyleLayerPreparationHandler)(void); - -typedef void (^MGLCustomStyleLayerDrawingHandler)(CGSize size, - CLLocationCoordinate2D centerCoordinate, - double zoomLevel, - CLLocationDirection direction, - CGFloat pitch, - CGFloat perspectiveSkew); - -typedef void (^MGLCustomStyleLayerCompletionHandler)(void); - -@interface MGLMapView (MGLCustomStyleLayerAdditions) - -- (void)insertCustomStyleLayerWithIdentifier:(NSString *)identifier preparationHandler:(MGLCustomStyleLayerPreparationHandler)preparation drawingHandler:(MGLCustomStyleLayerDrawingHandler)drawing completionHandler:(MGLCustomStyleLayerCompletionHandler)completion belowStyleLayerWithIdentifier:(nullable NSString *)otherIdentifier; - -@end - -NS_ASSUME_NONNULL_END diff --git a/include/mbgl/ios/Mapbox.h b/include/mbgl/ios/Mapbox.h index e8b3ead1d9..004839059f 100644 --- a/include/mbgl/ios/Mapbox.h +++ b/include/mbgl/ios/Mapbox.h @@ -5,7 +5,6 @@ #import "MGLGeometry.h" #import "MGLMapView.h" #import "MGLMapView+IBAdditions.h" -#import "MGLMapView+MGLCustomStyleLayerAdditions.h" #import "MGLMultiPoint.h" #import "MGLOverlay.h" #import "MGLPointAnnotation.h" diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm index d5ef815351..7e19382f9a 100644 --- a/ios/app/MBXViewController.mm +++ b/ios/app/MBXViewController.mm @@ -4,7 +4,6 @@ #import #import -#import static UIColor *const kTintColor = [UIColor colorWithRed:0.120 green:0.550 blue:0.670 alpha:1.000]; @@ -151,7 +150,6 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { @"Add Test Shapes", @"Start World Tour", @"Remove Annotations", - @"Insert Custom Style Layer", nil]; [sheet showFromBarButtonItem:self.navigationItem.leftBarButtonItem animated:YES]; @@ -262,10 +260,6 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { { [self.mapView removeAnnotations:self.mapView.annotations]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 9) - { - [self insertCustomStyleLayer]; - } } - (void)parseFeaturesAddingCount:(NSUInteger)featuresCount @@ -308,59 +302,6 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { }); } -- (void)insertCustomStyleLayer -{ - static const GLchar *vertexShaderSource = "attribute vec2 a_pos; void main() { gl_Position = vec4(a_pos, 0, 1); }"; - static const GLchar *fragmentShaderSource = "void main() { gl_FragColor = vec4(0, 1, 0, 1); }"; - - __block GLuint program = 0; - __block GLuint vertexShader = 0; - __block GLuint fragmentShader = 0; - __block GLuint buffer = 0; - __block GLuint a_pos = 0; - [self.mapView insertCustomStyleLayerWithIdentifier:@"mbx-custom" preparationHandler:^{ - program = glCreateProgram(); - vertexShader = glCreateShader(GL_VERTEX_SHADER); - fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - - glShaderSource(vertexShader, 1, &vertexShaderSource, nullptr); - glCompileShader(vertexShader); - glAttachShader(program, vertexShader); - glShaderSource(fragmentShader, 1, &fragmentShaderSource, nullptr); - glCompileShader(fragmentShader); - glAttachShader(program, fragmentShader); - glLinkProgram(program); - a_pos = glGetAttribLocation(program, "a_pos"); - - GLfloat background[] = { -1,-1, 1,-1, -1,1, 1,1 }; - glGenBuffers(1, &buffer); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), background, GL_STATIC_DRAW); - } drawingHandler:^(__unused CGSize size, - __unused CLLocationCoordinate2D centerCoordinate, - __unused double zoomLevel, - __unused CLLocationDirection direction, - __unused CGFloat pitch, - __unused CGFloat perspectiveSkew) { - glUseProgram(program); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glEnableVertexAttribArray(a_pos); - glVertexAttribPointer(a_pos, 2, GL_FLOAT, GL_FALSE, 0, NULL); - glDisable(GL_STENCIL_TEST); - glDisable(GL_DEPTH_TEST); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } completionHandler:^{ - if (program) { - glDeleteBuffers(1, &buffer); - glDetachShader(program, vertexShader); - glDetachShader(program, fragmentShader); - glDeleteShader(vertexShader); - glDeleteShader(fragmentShader); - glDeleteProgram(program); - } - } belowStyleLayerWithIdentifier:@"housenum-label"]; -} - - (void)handleLongPress:(UILongPressGestureRecognizer *)longPress { if (longPress.state == UIGestureRecognizerStateBegan) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index e9657f5616..5d944e81fe 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1,6 +1,5 @@ #import "MGLMapView.h" #import "MGLMapView+IBAdditions.h" -#import "MGLMapView+MGLCustomStyleLayerAdditions.h" #import #import @@ -3473,8 +3472,6 @@ class MBGLView : public mbgl::View @end -#pragma mark - IBAdditions methods - @implementation MGLMapView (IBAdditions) + (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyleURL__ @@ -3613,66 +3610,3 @@ class MBGLView : public mbgl::View } @end - -#pragma mark - MGLCustomStyleLayerAdditions methods - -class MGLCustomStyleLayerHandlers -{ -public: - MGLCustomStyleLayerHandlers(MGLCustomStyleLayerPreparationHandler p, - MGLCustomStyleLayerDrawingHandler d, - MGLCustomStyleLayerCompletionHandler f) - : prepare(p), draw(d), finish(f) {} - - MGLCustomStyleLayerPreparationHandler prepare; - MGLCustomStyleLayerDrawingHandler draw; - MGLCustomStyleLayerCompletionHandler finish; -}; - -void MGLPrepareCustomStyleLayer(void *context) -{ - MGLCustomStyleLayerPreparationHandler prepare = reinterpret_cast(context)->prepare; - if (prepare) - { - prepare(); - } -} - -void MGLDrawCustomStyleLayer(void *context, const mbgl::CustomLayerRenderParameters ¶ms) -{ - CGSize size = CGSizeMake(params.width, params.height); - CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(params.latitude, params.longitude); - double zoomLevel = params.zoom; - CLLocationDirection direction = mbgl::util::wrap(params.bearing, 0., 360.); - CGFloat pitch = params.pitch; - CGFloat perspectiveSkew = params.altitude; - MGLCustomStyleLayerDrawingHandler draw = reinterpret_cast(context)->draw; - if (draw) - { - draw(size, centerCoordinate, zoomLevel, direction, pitch, perspectiveSkew); - } -} - -void MGLFinishCustomStyleLayer(void *context) -{ - MGLCustomStyleLayerHandlers *handlers = reinterpret_cast(context); - MGLCustomStyleLayerCompletionHandler finish = handlers->finish; - if (finish) - { - finish(); - } - delete handlers; -} - -@implementation MGLMapView (MGLCustomStyleLayerAdditions) - -- (void)insertCustomStyleLayerWithIdentifier:(NSString *)identifier preparationHandler:(void (^)())preparation drawingHandler:(MGLCustomStyleLayerDrawingHandler)drawing completionHandler:(void (^)())completion belowStyleLayerWithIdentifier:(nullable NSString *)otherIdentifier -{ - NSAssert(identifier, @"Style layer needs an identifier"); - MGLCustomStyleLayerHandlers *context = new MGLCustomStyleLayerHandlers(preparation, drawing, completion); - _mbglMap->addCustomLayer(identifier.UTF8String, MGLPrepareCustomStyleLayer, - MGLDrawCustomStyleLayer, MGLFinishCustomStyleLayer, - context, otherIdentifier.UTF8String); -} - -@end -- cgit v1.2.1