Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions core/src/main/java/app/photofox/vipsffm/Vips.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,26 @@
/// Blocks untrusted operations by default
public class Vips {

private static boolean isInitialized = false;

public static void init() {
init(false, false);
}

public static void init(boolean allowUntrusted, boolean detectLeaks) {
if (isInitialized) {
throw new IllegalStateException("Vips has already been initialized!");
}
var arena = Arena.global();
VipsHelper.init(arena, allowUntrusted);
VipsHelper.leak_set(detectLeaks);
isInitialized = true;
}

public static void checkWasInitialized() {
if (!isInitialized) {
throw new IllegalStateException("Vips has not been initialized. Call Vips.init() first!");
}
}

/// Provides a scoped arena to provide a memory boundary for running libvips operations
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/app/photofox/vipsffm/VipsInvoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static void invokeOperation(
String stringOptions,
List<? extends VipsOption> args
) throws VipsError {
Vips.checkWasInitialized();
// https://www.libvips.org/API/current/binding.html
var operation = VipsRaw.vips_operation_new(arena.allocateFrom(nickname));
if (!VipsValidation.isValidPointer(operation)) {
Expand Down
36 changes: 24 additions & 12 deletions docs/app.photofox.vipsffm/app/photofox/vipsffm/Vips.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<ol class="toc-list">
<li><a href="#init()" tabindex="0">init()</a></li>
<li><a href="#init(boolean,boolean)" tabindex="0">init(boolean, boolean)</a></li>
<li><a href="#checkWasInitialized()" tabindex="0">checkWasInitialized()</a></li>
<li><a href="#run(app.photofox.vipsffm.VipsRunnable)" tabindex="0">run(VipsRunnable)</a></li>
<li><a href="#shutdown()" tabindex="0">shutdown()</a></li>
<li><a href="#allowUntrustedOperations()" tabindex="0">allowUntrustedOperations()</a></li>
Expand Down Expand Up @@ -130,25 +131,28 @@ <h2>Method Summary</h2>
<div class="block">Permits untrusted operations, such as loading PDFs</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#disableOperationCache()" class="member-name-link">disableOperationCache</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#checkWasInitialized()" class="member-name-link">checkWasInitialized</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#disableOperationCache()" class="member-name-link">disableOperationCache</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="block">Disables the libvips operations cache</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#init()" class="member-name-link">init</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#init(boolean,boolean)" class="member-name-link">init</a><wbr>(boolean&nbsp;allowUntrusted,
boolean&nbsp;detectLeaks)</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#init()" class="member-name-link">init</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#run(app.photofox.vipsffm.VipsRunnable)" class="member-name-link">run</a><wbr>(<a href="VipsRunnable.html" title="interface in app.photofox.vipsffm">VipsRunnable</a>&nbsp;runnable)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#init(boolean,boolean)" class="member-name-link">init</a><wbr>(boolean&nbsp;allowUntrusted,
boolean&nbsp;detectLeaks)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#run(app.photofox.vipsffm.VipsRunnable)" class="member-name-link">run</a><wbr>(<a href="VipsRunnable.html" title="interface in app.photofox.vipsffm">VipsRunnable</a>&nbsp;runnable)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="block">Provides a scoped arena to provide a memory boundary for running libvips operations</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#shutdown()" class="member-name-link">shutdown</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#shutdown()" class="member-name-link">shutdown</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">&nbsp;</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -200,6 +204,14 @@ <h3>init</h3>
</section>
</li>
<li>
<section class="detail" id="checkWasInitialized()">
<h3>checkWasInitialized</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">checkWasInitialized</span>()</div>
</div>
</section>
</li>
<li>
<section class="detail" id="run(app.photofox.vipsffm.VipsRunnable)">
<h3>run</h3>
<div class="horizontal-scroll">
Expand Down
Loading