Support defining a custom style layer from iOS Swift (#3154)
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
}
|
||||
|
||||
- (void)didMoveToMapView:(MLNMapView *)mapView {
|
||||
MLNBackendResource resource = [mapView backendResource];
|
||||
MLNBackendResource* resource = [mapView backendResource];
|
||||
|
||||
NSString *shaderSource = @
|
||||
" #include <metal_stdlib>\n"
|
||||
@@ -140,7 +140,7 @@
|
||||
id<MTLRenderCommandEncoder> renderEncoder = self.renderEncoder;
|
||||
if(renderEncoder != nil)
|
||||
{
|
||||
MLNBackendResource resource = [mapView backendResource];
|
||||
MLNBackendResource* resource = [mapView backendResource];
|
||||
|
||||
vector_uint2 _viewportSize;
|
||||
_viewportSize.x = resource.mtkView.drawableSize.width;
|
||||
|
||||
@@ -161,6 +161,7 @@ MLN_DARWIN_PRIVATE_HEADERS = [
|
||||
|
||||
MLN_DARWIN_PUBLIC_OBJCPP_SOURCE = [
|
||||
"src/MLNAttributionInfo.mm",
|
||||
"src/MLNBackendResource.mm",
|
||||
"src/MLNComputedShapeSource.mm",
|
||||
"src/MLNCustomStyleLayer.mm",
|
||||
"src/MLNDefaultStyle.mm",
|
||||
|
||||
@@ -2,16 +2,28 @@
|
||||
|
||||
#import <MetalKit/MetalKit.h>
|
||||
|
||||
typedef struct {
|
||||
MTKView *mtkView;
|
||||
id<MTLDevice> device;
|
||||
MTLRenderPassDescriptor *renderPassDescriptor;
|
||||
id<MTLCommandBuffer> commandBuffer;
|
||||
} MLNBackendResource;
|
||||
@interface MLNBackendResource : NSObject
|
||||
|
||||
@property (nonatomic, strong) MTKView *mtkView;
|
||||
@property (nonatomic, strong) id<MTLDevice> device;
|
||||
@property (nonatomic, strong) MTLRenderPassDescriptor *renderPassDescriptor;
|
||||
@property (nonatomic, strong) id<MTLCommandBuffer> commandBuffer;
|
||||
|
||||
- (instancetype)initWithMTKView:(MTKView *)mtkView
|
||||
device:(id<MTLDevice>)device
|
||||
renderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor
|
||||
commandBuffer:(id<MTLCommandBuffer>)commandBuffer;
|
||||
|
||||
@end
|
||||
|
||||
#else
|
||||
|
||||
typedef struct {
|
||||
} MLNBackendResource;
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MLNFoundation.h"
|
||||
|
||||
MLN_EXPORT
|
||||
@interface MLNBackendResource : NSObject
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
36
platform/darwin/src/MLNBackendResource.mm
Normal file
36
platform/darwin/src/MLNBackendResource.mm
Normal file
@@ -0,0 +1,36 @@
|
||||
#if MLN_RENDER_BACKEND_METAL
|
||||
|
||||
#import "MLNBackendResource.h"
|
||||
|
||||
@implementation MLNBackendResource
|
||||
|
||||
- (instancetype)initWithMTKView:(MTKView *)mtkView
|
||||
device:(id<MTLDevice>)device
|
||||
renderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor
|
||||
commandBuffer:(id<MTLCommandBuffer>)commandBuffer {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_mtkView = mtkView;
|
||||
_device = device;
|
||||
_renderPassDescriptor = renderPassDescriptor;
|
||||
_commandBuffer = commandBuffer;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#else
|
||||
|
||||
#import "MLNBackendResource.h"
|
||||
|
||||
@implementation MLNBackendResource
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user