@aguacerowx/react-native 0.0.35 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build/.transforms/8f329a9571a96a1c1c0869d49784e448/results.bin +1 -0
- package/android/build/.transforms/8f329a9571a96a1c1c0869d49784e448/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/f95abdfc98a7a06fc247f75cdd74def9/results.bin +1 -0
- package/android/build/.transforms/f95abdfc98a7a06fc247f75cdd74def9/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_fragment_shader.glsl.flat +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
- package/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/fragment_shader.glsl +7 -15
- package/android/src/main/res/raw/fragment_shader.glsl +7 -15
- package/ios/GridRenderLayer.swift +191 -58
- package/ios/GridRenderLayerBridge.swift +8 -0
- package/ios/GridRenderLayerView.m +1 -17
- package/ios/Shaders.metal +7 -15
- package/ios/compiled-shaders/Shaders-device.metallib +0 -0
- package/ios/compiled-shaders/Shaders-simulator.metallib +0 -0
- package/lib/commonjs/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_fragment_shader.glsl.flat +0 -0
- package/lib/commonjs/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
- package/lib/commonjs/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/fragment_shader.glsl +7 -15
- package/lib/commonjs/android/src/main/res/raw/fragment_shader.glsl +7 -15
- package/lib/commonjs/ios/GridRenderLayer.swift +191 -58
- package/lib/commonjs/ios/GridRenderLayerBridge.swift +8 -0
- package/lib/commonjs/ios/GridRenderLayerView.m +1 -17
- package/lib/commonjs/ios/Shaders.metal +7 -15
- package/lib/commonjs/ios/compiled-shaders/Shaders-device.metallib +0 -0
- package/lib/commonjs/ios/compiled-shaders/Shaders-simulator.metallib +0 -0
- package/lib/commonjs/package.json +1 -1
- package/lib/commonjs/src/WeatherLayerManager.js +34 -12
- package/lib/commonjs/src/WeatherLayerManager.js.map +1 -1
- package/lib/module/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_fragment_shader.glsl.flat +0 -0
- package/lib/module/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
- package/lib/module/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/fragment_shader.glsl +7 -15
- package/lib/module/android/src/main/res/raw/fragment_shader.glsl +7 -15
- package/lib/module/ios/GridRenderLayer.swift +191 -58
- package/lib/module/ios/GridRenderLayerBridge.swift +8 -0
- package/lib/module/ios/GridRenderLayerView.m +1 -17
- package/lib/module/ios/Shaders.metal +7 -15
- package/lib/module/ios/compiled-shaders/Shaders-device.metallib +0 -0
- package/lib/module/ios/compiled-shaders/Shaders-simulator.metallib +0 -0
- package/lib/module/lib/commonjs/ios/GridRenderLayer.swift +191 -58
- package/lib/module/lib/commonjs/ios/GridRenderLayerBridge.swift +8 -0
- package/lib/module/lib/commonjs/ios/GridRenderLayerView.m +1 -17
- package/lib/module/lib/commonjs/ios/Shaders.metal +7 -15
- package/lib/module/lib/commonjs/ios/compiled-shaders/Shaders-device.metallib +0 -0
- package/lib/module/lib/commonjs/ios/compiled-shaders/Shaders-simulator.metallib +0 -0
- package/lib/module/lib/commonjs/ios/generated/AguaceroWxReactNativeSpec.h +0 -0
- package/lib/module/lib/commonjs/package.json +1 -1
- package/lib/module/lib/commonjs/src/WeatherLayerManager.js +34 -12
- package/lib/module/lib/commonjs/src/WeatherLayerManager.js.map +1 -1
- package/lib/module/package.json +1 -1
- package/lib/module/src/WeatherLayerManager.js +35 -13
- package/lib/module/src/WeatherLayerManager.js.map +1 -1
- package/lib/typescript/src/WeatherLayerManager.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/WeatherLayerManager.js +151 -121
|
@@ -66,6 +66,7 @@ public class GridRenderLayer: NSObject {
|
|
|
66
66
|
)
|
|
67
67
|
private var isVisible = false
|
|
68
68
|
private var pendingActiveFrameKey: String?
|
|
69
|
+
private var lastRequestedCacheKey: String?
|
|
69
70
|
private let inspectorCache = InspectorDataCache.shared
|
|
70
71
|
private struct FrameMetadata {
|
|
71
72
|
let scale: Float
|
|
@@ -77,8 +78,10 @@ public class GridRenderLayer: NSObject {
|
|
|
77
78
|
let filePath: String
|
|
78
79
|
let originalScale: Float
|
|
79
80
|
let originalOffset: Float
|
|
81
|
+
var processedData: Data? // Cache the final transformed bytes
|
|
80
82
|
}
|
|
81
83
|
private var frameCache: [String: FrameMetadata] = [:]
|
|
84
|
+
private let frameCacheQueue = DispatchQueue(label: "com.aguacero.frame-cache-queue")
|
|
82
85
|
private let frameProcessingQueue = DispatchQueue(label: "com.aguacero.frame-processing", qos: .userInitiated, attributes: .concurrent)
|
|
83
86
|
private let semaphore = DispatchSemaphore(value: 8)
|
|
84
87
|
|
|
@@ -177,8 +180,12 @@ public class GridRenderLayer: NSObject {
|
|
|
177
180
|
|
|
178
181
|
@objc(clearGpuCache)
|
|
179
182
|
public func clearGpuCache() {
|
|
183
|
+
print("ℹ️ [GridRenderLayer] clearGpuCache called")
|
|
180
184
|
frameProcessingQueue.async { [weak self] in
|
|
181
|
-
self
|
|
185
|
+
guard let self = self else { return }
|
|
186
|
+
self.frameCacheQueue.async {
|
|
187
|
+
self.frameCache.removeAll()
|
|
188
|
+
}
|
|
182
189
|
}
|
|
183
190
|
}
|
|
184
191
|
|
|
@@ -210,24 +217,29 @@ public class GridRenderLayer: NSObject {
|
|
|
210
217
|
return texture
|
|
211
218
|
}
|
|
212
219
|
|
|
213
|
-
private func updateInspectorCache(filePath: String, nx: Int, ny: Int, scale: Float, offset: Float, missing: Float, scaleType: Int) {
|
|
220
|
+
private func updateInspectorCache(filePath: String, reconstructedData: Data?, nx: Int, ny: Int, scale: Float, offset: Float, missing: Float, scaleType: Int) {
|
|
214
221
|
// This is now called from frameProcessingQueue, so we can do the work synchronously
|
|
215
|
-
guard let fileData = try? Data(contentsOf: URL(fileURLWithPath: filePath)) else {
|
|
216
|
-
print("❌ [Inspector] FATAL: Failed to read file data from path.")
|
|
217
|
-
self.inspectorCache.clear()
|
|
218
|
-
return
|
|
219
|
-
}
|
|
220
222
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
let finalReconstructedData: Data
|
|
224
|
+
if let data = reconstructedData {
|
|
225
|
+
finalReconstructedData = data
|
|
226
|
+
} else {
|
|
227
|
+
guard let fileData = try? Data(contentsOf: URL(fileURLWithPath: filePath)) else {
|
|
228
|
+
print("❌ [Inspector] FATAL: Failed to read file data from path.")
|
|
229
|
+
self.inspectorCache.clear()
|
|
230
|
+
return
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
guard let decompressedDeltas = self.decompressZstd(data: fileData) else {
|
|
234
|
+
print("❌ [Inspector] FATAL: Failed to decompress Zstd data.")
|
|
235
|
+
self.inspectorCache.clear()
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
finalReconstructedData = self.reconstructData(decompressedDeltas: decompressedDeltas)
|
|
225
239
|
}
|
|
226
|
-
|
|
227
|
-
let reconstructedData = self.reconstructData(decompressedDeltas: decompressedDeltas)
|
|
228
240
|
|
|
229
241
|
self.inspectorCache.update(
|
|
230
|
-
data:
|
|
242
|
+
data: finalReconstructedData,
|
|
231
243
|
nx: nx,
|
|
232
244
|
ny: ny,
|
|
233
245
|
scale: scale,
|
|
@@ -239,23 +251,78 @@ public class GridRenderLayer: NSObject {
|
|
|
239
251
|
|
|
240
252
|
@objc(setActiveFrameWithCacheKey:)
|
|
241
253
|
public func setActiveFrame(cacheKey: String) {
|
|
242
|
-
|
|
254
|
+
setActiveFrameInternal(cacheKey: cacheKey, isExternalRequest: true)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
private func setActiveFrameInternal(cacheKey: String, isExternalRequest: Bool) {
|
|
258
|
+
if isExternalRequest {
|
|
259
|
+
lastRequestedCacheKey = cacheKey
|
|
260
|
+
} else {
|
|
261
|
+
// If it's an internal retry (from primeGpuCache),
|
|
262
|
+
// only proceed if it's still the frame the user wants.
|
|
263
|
+
if lastRequestedCacheKey != cacheKey {
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
var frameResult: FrameMetadata?
|
|
269
|
+
frameCacheQueue.sync {
|
|
270
|
+
frameResult = frameCache[cacheKey]
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if let frame = frameResult {
|
|
243
274
|
frameProcessingQueue.async { [weak self] in
|
|
244
275
|
guard let self = self else { return }
|
|
245
276
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
277
|
+
// Check if this frame is still the one we want
|
|
278
|
+
if self.lastRequestedCacheKey != cacheKey { return }
|
|
279
|
+
|
|
280
|
+
let finalTextureBytes: Data
|
|
281
|
+
if let cachedData = frame.processedData {
|
|
282
|
+
finalTextureBytes = cachedData
|
|
283
|
+
} else {
|
|
284
|
+
guard let fileData = try? Data(contentsOf: URL(fileURLWithPath: frame.filePath)),
|
|
285
|
+
let processed = self.processRawData(fileData: fileData)
|
|
286
|
+
else {
|
|
287
|
+
print("❌ [GridRenderLayer] Failed to load/process data for: \(cacheKey)")
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
finalTextureBytes = processed
|
|
291
|
+
self.frameCacheQueue.async {
|
|
292
|
+
self.frameCache[cacheKey]?.processedData = finalTextureBytes
|
|
293
|
+
}
|
|
251
294
|
}
|
|
252
295
|
|
|
296
|
+
// Final check before jumping to main thread
|
|
297
|
+
if self.lastRequestedCacheKey != cacheKey { return }
|
|
298
|
+
|
|
253
299
|
DispatchQueue.main.async { [weak self] in
|
|
254
|
-
guard let self = self
|
|
255
|
-
|
|
256
|
-
|
|
300
|
+
guard let self = self else { return }
|
|
301
|
+
|
|
302
|
+
// Final check on main thread
|
|
303
|
+
if self.lastRequestedCacheKey != cacheKey {
|
|
304
|
+
return
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
let nx = Int(frame.nx)
|
|
308
|
+
let ny = Int(frame.ny)
|
|
309
|
+
|
|
310
|
+
if let existingTexture = self.dataTexture,
|
|
311
|
+
existingTexture.width == nx,
|
|
312
|
+
existingTexture.height == ny {
|
|
313
|
+
existingTexture.replace(
|
|
314
|
+
region: MTLRegionMake2D(0, 0, nx, ny),
|
|
315
|
+
mipmapLevel: 0,
|
|
316
|
+
withBytes: (finalTextureBytes as NSData).bytes,
|
|
317
|
+
bytesPerRow: nx
|
|
318
|
+
)
|
|
319
|
+
} else {
|
|
320
|
+
guard let texture = self.createTextureFromBytes(bytes: finalTextureBytes, nx: nx, ny: ny) else {
|
|
321
|
+
return
|
|
322
|
+
}
|
|
323
|
+
self.dataTexture = texture
|
|
324
|
+
}
|
|
257
325
|
|
|
258
|
-
self.dataTexture = texture
|
|
259
326
|
self.uniforms.scale = frame.scale
|
|
260
327
|
self.uniforms.offset = frame.offset
|
|
261
328
|
self.uniforms.missingQuantized = frame.missing
|
|
@@ -266,12 +333,12 @@ public class GridRenderLayer: NSObject {
|
|
|
266
333
|
self.pendingActiveFrameKey = nil
|
|
267
334
|
NotificationCenter.default.post(name: NSNotification.Name("TriggerMapRepaint"), object: nil)
|
|
268
335
|
|
|
269
|
-
// Update inspector cache
|
|
270
336
|
self.frameProcessingQueue.async { [weak self] in
|
|
271
337
|
self?.updateInspectorCache(
|
|
272
338
|
filePath: frame.filePath,
|
|
273
|
-
|
|
274
|
-
|
|
339
|
+
reconstructedData: nil,
|
|
340
|
+
nx: nx,
|
|
341
|
+
ny: ny,
|
|
275
342
|
scale: frame.scale,
|
|
276
343
|
offset: frame.offset,
|
|
277
344
|
missing: frame.missing,
|
|
@@ -280,16 +347,16 @@ public class GridRenderLayer: NSObject {
|
|
|
280
347
|
}
|
|
281
348
|
}
|
|
282
349
|
}
|
|
283
|
-
|
|
284
350
|
} else {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
351
|
+
if isExternalRequest {
|
|
352
|
+
self.pendingActiveFrameKey = cacheKey
|
|
353
|
+
}
|
|
288
354
|
}
|
|
289
355
|
}
|
|
290
356
|
|
|
291
357
|
@objc(primeGpuCacheWithFrameInfo:)
|
|
292
358
|
public func primeGpuCache(frameInfo: [String: [String: Any]]) {
|
|
359
|
+
print("ℹ️ [GridRenderLayer] primeGpuCache called with \(frameInfo.count) items")
|
|
293
360
|
let group = DispatchGroup()
|
|
294
361
|
|
|
295
362
|
for (cacheKey, info) in frameInfo {
|
|
@@ -307,7 +374,13 @@ public class GridRenderLayer: NSObject {
|
|
|
307
374
|
group.leave()
|
|
308
375
|
}
|
|
309
376
|
|
|
310
|
-
|
|
377
|
+
let alreadyExists: Bool = self.frameCacheQueue.sync {
|
|
378
|
+
return self.frameCache[cacheKey] != nil
|
|
379
|
+
}
|
|
380
|
+
if alreadyExists {
|
|
381
|
+
print("ℹ️ [GridRenderLayer] Frame already cached: \(cacheKey)")
|
|
382
|
+
return
|
|
383
|
+
}
|
|
311
384
|
|
|
312
385
|
guard let filePath = info["filePath"] as? String,
|
|
313
386
|
let nx = info["nx"] as? NSNumber,
|
|
@@ -319,7 +392,7 @@ public class GridRenderLayer: NSObject {
|
|
|
319
392
|
let originalScale = info["originalScale"] as? NSNumber,
|
|
320
393
|
let originalOffset = info["originalOffset"] as? NSNumber
|
|
321
394
|
else {
|
|
322
|
-
print("❌ [GridRenderLayer] Skipping prime for \(cacheKey), missing data.")
|
|
395
|
+
print("❌ [GridRenderLayer] Skipping prime for \(cacheKey), missing data. Info keys: \(info.keys)")
|
|
323
396
|
return
|
|
324
397
|
}
|
|
325
398
|
|
|
@@ -332,13 +405,35 @@ public class GridRenderLayer: NSObject {
|
|
|
332
405
|
ny: ny.floatValue,
|
|
333
406
|
filePath: filePath,
|
|
334
407
|
originalScale: originalScale.floatValue,
|
|
335
|
-
originalOffset: originalOffset.floatValue
|
|
408
|
+
originalOffset: originalOffset.floatValue,
|
|
409
|
+
processedData: nil
|
|
336
410
|
)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
411
|
+
|
|
412
|
+
// Add to cache immediately so setActiveFrame can see it
|
|
413
|
+
self.frameCacheQueue.async {
|
|
414
|
+
self.frameCache[cacheKey] = metadata
|
|
415
|
+
print("ℹ️ [GridRenderLayer] Primed cache key: \(cacheKey)")
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// PERFORMANCE: Pre-process the data in the background
|
|
419
|
+
if let fileData = try? Data(contentsOf: URL(fileURLWithPath: filePath)) {
|
|
420
|
+
if let processedData = self.processRawData(fileData: fileData) {
|
|
421
|
+
self.frameCacheQueue.async {
|
|
422
|
+
self.frameCache[cacheKey]?.processedData = processedData
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
DispatchQueue.main.async {
|
|
428
|
+
if let pendingKey = self.pendingActiveFrameKey, pendingKey == cacheKey {
|
|
429
|
+
if self.lastRequestedCacheKey == cacheKey {
|
|
430
|
+
print("ℹ️ [GridRenderLayer] Applying pending frame: \(cacheKey)")
|
|
431
|
+
self.setActiveFrameInternal(cacheKey: pendingKey, isExternalRequest: false)
|
|
432
|
+
}
|
|
433
|
+
// Clear pending key if it matches what we just processed
|
|
434
|
+
if self.pendingActiveFrameKey == cacheKey {
|
|
435
|
+
self.pendingActiveFrameKey = nil
|
|
436
|
+
}
|
|
342
437
|
}
|
|
343
438
|
}
|
|
344
439
|
}
|
|
@@ -359,12 +454,30 @@ public class GridRenderLayer: NSObject {
|
|
|
359
454
|
}
|
|
360
455
|
|
|
361
456
|
DispatchQueue.main.async { [weak self] in
|
|
362
|
-
guard let self = self
|
|
363
|
-
|
|
364
|
-
|
|
457
|
+
guard let self = self else { return }
|
|
458
|
+
|
|
459
|
+
let nxInt = nx.intValue
|
|
460
|
+
let nyInt = ny.intValue
|
|
461
|
+
|
|
462
|
+
// REUSE TEXTURE if dimensions match
|
|
463
|
+
if let existingTexture = self.dataTexture,
|
|
464
|
+
existingTexture.width == nxInt,
|
|
465
|
+
existingTexture.height == nyInt {
|
|
466
|
+
existingTexture.replace(
|
|
467
|
+
region: MTLRegionMake2D(0, 0, nxInt, nyInt),
|
|
468
|
+
mipmapLevel: 0,
|
|
469
|
+
withBytes: (finalTextureBytes as NSData).bytes,
|
|
470
|
+
bytesPerRow: nxInt
|
|
471
|
+
)
|
|
472
|
+
} else {
|
|
473
|
+
// Create new texture only if needed
|
|
474
|
+
guard let texture = self.createTextureFromBytes(bytes: finalTextureBytes, nx: nxInt, ny: nyInt) else {
|
|
475
|
+
print("❌ [GridRenderLayer] FAST LANE: Failed to create texture")
|
|
476
|
+
return
|
|
477
|
+
}
|
|
478
|
+
self.dataTexture = texture
|
|
365
479
|
}
|
|
366
480
|
|
|
367
|
-
self.dataTexture = texture
|
|
368
481
|
self.uniforms.scale = scale.floatValue
|
|
369
482
|
self.uniforms.offset = offset.floatValue
|
|
370
483
|
self.uniforms.missingQuantized = missing.floatValue
|
|
@@ -376,6 +489,7 @@ public class GridRenderLayer: NSObject {
|
|
|
376
489
|
|
|
377
490
|
self.updateInspectorCache(
|
|
378
491
|
filePath: filePath,
|
|
492
|
+
reconstructedData: nil,
|
|
379
493
|
nx: nx.intValue,
|
|
380
494
|
ny: ny.intValue,
|
|
381
495
|
scale: scale.floatValue,
|
|
@@ -799,19 +913,35 @@ internal func internalRenderingWillStart(_ metalDevice: MTLDevice, colorPixelFor
|
|
|
799
913
|
#endif
|
|
800
914
|
|
|
801
915
|
// Try to load pre-compiled metallib for the current platform
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
916
|
+
var defaultLibrary: MTLLibrary?
|
|
917
|
+
|
|
918
|
+
// 1. Look in the main bundle level
|
|
919
|
+
if let metallibUrl = bundle.url(forResource: metallibName, withExtension: "metallib") {
|
|
920
|
+
print("ℹ️ [GridRenderLayer] Found pre-compiled shaders at: \(metallibUrl.lastPathComponent)")
|
|
921
|
+
defaultLibrary = try? metalDevice.makeLibrary(URL: metallibUrl)
|
|
806
922
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
923
|
+
|
|
924
|
+
// 2. Fall back to compiled-shaders subdirectory
|
|
925
|
+
if defaultLibrary == nil {
|
|
926
|
+
if let metallibUrl = bundle.url(forResource: metallibName, withExtension: "metallib", subdirectory: "compiled-shaders") {
|
|
927
|
+
print("ℹ️ [GridRenderLayer] Found pre-compiled shaders in subdirectory: \(metallibUrl.lastPathComponent)")
|
|
928
|
+
defaultLibrary = try? metalDevice.makeLibrary(URL: metallibUrl)
|
|
929
|
+
}
|
|
812
930
|
}
|
|
931
|
+
|
|
932
|
+
// 3. Fall back to compiling from .metal source (for development with npm link)
|
|
933
|
+
if defaultLibrary == nil {
|
|
934
|
+
if let metalUrl = bundle.url(forResource: "Shaders", withExtension: "metal") {
|
|
935
|
+
print("⚠️ [GridRenderLayer] Pre-compiled shaders not found. Compiling from source: \(metalUrl.lastPathComponent)")
|
|
936
|
+
if let source = try? String(contentsOf: metalUrl),
|
|
937
|
+
let library = try? metalDevice.makeLibrary(source: source, options: nil) {
|
|
938
|
+
defaultLibrary = library
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
813
943
|
// Neither worked
|
|
814
|
-
|
|
944
|
+
if defaultLibrary == nil {
|
|
815
945
|
print("❌ [GridRenderLayer] Could not find or compile Metal shaders")
|
|
816
946
|
print(" Bundle path: \(bundle.bundlePath)")
|
|
817
947
|
return
|
|
@@ -967,7 +1097,9 @@ internal func internalRenderingWillStart(_ metalDevice: MTLDevice, colorPixelFor
|
|
|
967
1097
|
print("🔴 [GridRenderLayer] deinit called for layer: \(id)")
|
|
968
1098
|
|
|
969
1099
|
// Clean up all resources
|
|
970
|
-
|
|
1100
|
+
frameCacheQueue.sync {
|
|
1101
|
+
frameCache.removeAll()
|
|
1102
|
+
}
|
|
971
1103
|
vertexBuffer = nil
|
|
972
1104
|
indexBuffer = nil
|
|
973
1105
|
dataTexture = nil
|
|
@@ -983,10 +1115,11 @@ internal func internalRenderingWillStart(_ metalDevice: MTLDevice, colorPixelFor
|
|
|
983
1115
|
}
|
|
984
1116
|
|
|
985
1117
|
internal func internalRenderingWillEnd() {
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1118
|
+
// DO NOT clear these here, otherwise the layer disappears during map transitions/resizing
|
|
1119
|
+
// vertexBuffer = nil
|
|
1120
|
+
// indexBuffer = nil
|
|
1121
|
+
// dataTexture = nil
|
|
1122
|
+
// colormapTexture = nil
|
|
990
1123
|
}
|
|
991
1124
|
}
|
|
992
1125
|
|
|
@@ -34,4 +34,12 @@ import Foundation
|
|
|
34
34
|
return false
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
@objc public static func removeCustomLayer(from mapView: MapView, layerId: String) {
|
|
39
|
+
do {
|
|
40
|
+
try mapView.mapboxMap.removeLayer(withId: layerId)
|
|
41
|
+
} catch {
|
|
42
|
+
print("❌ [GridRenderLayerBridge] Failed to remove layer \(layerId): \(error)")
|
|
43
|
+
}
|
|
44
|
+
}
|
|
37
45
|
}
|
|
@@ -178,23 +178,7 @@
|
|
|
178
178
|
|
|
179
179
|
- (void)removeFromSuperview {
|
|
180
180
|
if (self.mapView && self.isLayerAdded) {
|
|
181
|
-
|
|
182
|
-
id style = [mapboxMap valueForKey:@"style"];
|
|
183
|
-
|
|
184
|
-
SEL removeLayerSelector = NSSelectorFromString(@"removeStyleLayerWithIdentifier:completion:");
|
|
185
|
-
if ([style respondsToSelector:removeLayerSelector]) {
|
|
186
|
-
NSMethodSignature *signature = [style methodSignatureForSelector:removeLayerSelector];
|
|
187
|
-
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
|
188
|
-
[invocation setTarget:style];
|
|
189
|
-
[invocation setSelector:removeLayerSelector];
|
|
190
|
-
|
|
191
|
-
NSString *layerId = self.layerId;
|
|
192
|
-
[invocation setArgument:&layerId atIndex:2];
|
|
193
|
-
|
|
194
|
-
id nilCompletion = nil;
|
|
195
|
-
[invocation setArgument:&nilCompletion atIndex:3];
|
|
196
|
-
[invocation invoke];
|
|
197
|
-
}
|
|
181
|
+
[GridRenderLayerBridge removeCustomLayerFrom:self.mapView layerId:self.layerId];
|
|
198
182
|
}
|
|
199
183
|
[super removeFromSuperview];
|
|
200
184
|
}
|
|
@@ -68,21 +68,13 @@ float get_value(texture2d<float, access::sample> dataTexture, sampler dataSample
|
|
|
68
68
|
// Maps a physical value to a precipitation type category
|
|
69
69
|
float get_ptype_from_physical(float val, constant FragmentUniforms &uniforms) { // ADD uniforms parameter
|
|
70
70
|
if (val < 0.0) return -1.0;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} else {
|
|
79
|
-
// Models: 0-100 rain, 100-200 snow, 200-300 freezing rain, 300-400 ice pellets
|
|
80
|
-
if (val < 100.0) return 0.0;
|
|
81
|
-
if (val < 200.0) return 1.0;
|
|
82
|
-
if (val < 300.0) return 2.0;
|
|
83
|
-
if (val < 400.0) return 3.0;
|
|
84
|
-
return -1.0;
|
|
85
|
-
}
|
|
71
|
+
|
|
72
|
+
// Models: 0-100 rain, 100-200 snow, 200-300 freezing rain, 300-400 ice pellets
|
|
73
|
+
if (val < 100.0) return 0.0;
|
|
74
|
+
if (val < 200.0) return 1.0;
|
|
75
|
+
if (val < 300.0) return 2.0;
|
|
76
|
+
if (val < 400.0) return 3.0;
|
|
77
|
+
return -1.0;
|
|
86
78
|
}
|
|
87
79
|
|
|
88
80
|
// --- Main Fragment Shader ---
|
|
Binary file
|
|
Binary file
|