diff options
Diffstat (limited to 'platform/darwin/src/MGLStyle.mm')
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index f6fc5533be..695f8b55e7 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -85,6 +85,10 @@ @property (readonly, copy, nullable) NSURL *URL; @property (nonatomic) NS_MUTABLE_DICTIONARY_OF(NSString *, NS_DICTIONARY_OF(NSObject *, MGLTextLanguage *) *) *localizedLayersByIdentifier; +// Used for retain/release management +@property (nonatomic) NSMutableSet *layersForUpdating; +@property (nonatomic) NSSet *layersForRendering; + @end @implementation MGLStyle @@ -172,6 +176,8 @@ static NSURL *MGLStyleURL_trafficNight; - (instancetype)initWithRawStyle:(mbgl::style::Style *)rawStyle mapView:(MGLMapView *)mapView { if (self = [super init]) { + _layersForUpdating = [NSMutableSet set]; + _mapView = mapView; _rawStyle = rawStyle; _localizedLayersByIdentifier = [NSMutableDictionary dictionary]; @@ -534,6 +540,25 @@ static NSURL *MGLStyleURL_trafficNight; [self didChangeValueForKey:@"layers"]; } +#pragma mark - Layer retain/release management + +- (void)addToManagedLayers:(MGLStyleLayer*)layer { + [self.layersForUpdating addObject:layer]; +} + +- (void)removeFromManagedLayers:(MGLStyleLayer*)layer { + [self.layersForUpdating removeObject:layer]; +} + +- (void)retainLayersUsedDuringRendering { + self.layersForRendering = [self.layersForUpdating copy]; +} + +- (void)releaseLayersUsedDuringRendering { + self.layersForRendering = nil; +} + + #pragma mark Style classes - (NS_ARRAY_OF(NSString *) *)styleClasses |