()
| 60 | } |
| 61 | |
| 62 | public static synchronized void load() { |
| 63 | if (_loaded) return; |
| 64 | |
| 65 | String version = readResource(_resourcePath + "skija.version"); |
| 66 | File tempDir = new File(System.getProperty("java.io.tmpdir"), "skija_" + (version == null ? "" + System.nanoTime() : version)); |
| 67 | File library; |
| 68 | |
| 69 | switch (Platform.CURRENT) { |
| 70 | case WINDOWS: |
| 71 | _extract(_resourcePath, "icudtl.dat", tempDir); |
| 72 | library = _extract(_resourcePath, "skija.dll", tempDir); |
| 73 | System.load(library.getAbsolutePath()); |
| 74 | break; |
| 75 | case LINUX: |
| 76 | library = _extract(_resourcePath, "libskija.so", tempDir); |
| 77 | System.load(library.getAbsolutePath()); |
| 78 | break; |
| 79 | case MACOS_X64: |
| 80 | library = _extract(_resourcePath, "libskija_x64.dylib", tempDir); |
| 81 | System.load(library.getAbsolutePath()); |
| 82 | break; |
| 83 | case MACOS_ARM64: |
| 84 | library = _extract(_resourcePath, "libskija_arm64.dylib", tempDir); |
| 85 | System.load(library.getAbsolutePath()); |
| 86 | break; |
| 87 | default: |
| 88 | throw new RuntimeException("Unexpected Platform.CURRENT = " + Platform.CURRENT); |
| 89 | } |
| 90 | |
| 91 | if (tempDir.exists() && version == null) { |
| 92 | Runtime.getRuntime().addShutdownHook(new Thread(() -> { |
| 93 | try { |
| 94 | Files.walk(tempDir.toPath()) |
| 95 | .map(Path::toFile) |
| 96 | .sorted(Comparator.reverseOrder()) |
| 97 | .forEach((f) -> { |
| 98 | Log.debug("Deleting " + f); |
| 99 | f.delete(); |
| 100 | }); |
| 101 | } catch (IOException ex) { |
| 102 | ex.printStackTrace(); |
| 103 | } |
| 104 | })); |
| 105 | } |
| 106 | |
| 107 | _loaded = true; |
| 108 | _nAfterLoad(); |
| 109 | } |
| 110 | |
| 111 | @ApiStatus.Internal |
| 112 | @SneakyThrows |
no test coverage detected