Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

Commit a4e83d2

Browse files
committed
Ready for release
1 parent e5cfc21 commit a4e83d2

File tree

11 files changed

+128
-96
lines changed

11 files changed

+128
-96
lines changed

example/lwjgl3-opengl/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import org.apache.tools.ant.taskdefs.condition.Os
22
import groovy.json.JsonOutput
33

4-
54
plugins {
65
id 'application'
76
}
@@ -22,7 +21,6 @@ def lwjglClassifier = {
2221

2322
repositories {
2423
mavenCentral()
25-
mavenLocal()
2624
}
2725

2826
dependencies {

example/lwjgl3-opengl/src/main/java/com/labymedia/ultralight/lwjgl3/opengl/ExampleApplication.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
*/
4343
public class ExampleApplication {
4444
private final long window;
45-
private InputAdapter inputAdapter;
4645
private final CursorAdapter cursorManager;
4746
private final WebController webController;
4847

@@ -160,7 +159,7 @@ public void run() {
160159

161160
webController.initGPUDriver();
162161

163-
this.inputAdapter = webController.getInputAdapter();
162+
InputAdapter inputAdapter = webController.getInputAdapter();
164163

165164
// Register all the GLFW callbacks required by this application
166165
setCallback(GLFW::glfwSetWindowContentScaleCallback, inputAdapter::windowContentScaleCallback);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

ultralight-java-base/src/main/java/com/labymedia/ultralight/UltralightPlatform.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ private UltralightPlatform(long handle) {
8282
public native void setFileSystem(UltralightFileSystem fileSystem);
8383

8484
/**
85-
* Set the GPU driver implementation
85+
* Set the GPU driver implementation.
8686
*
8787
* @param gpuDriver The GPU driver implementation to use
8888
*/
8989
public native void setGPUDriver(UltralightGPUDriver gpuDriver);
9090

9191
/**
92-
* Set the GPU driver implementation
92+
* Set the GPU driver implementation.
9393
*
9494
* @param handle The pointer to the GPU driver
9595
*/

ultralight-java-base/src/main/java/com/labymedia/ultralight/UltralightView.java

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
import java.util.Objects;
3838

3939
/**
40-
* A View is similar to a tab in a browser-- you load web content into
41-
* it and display it however you want. @see Renderer::CreateView
40+
* A View is similar to a tab in a browser-- you load web content into it and display it however you want. @see
41+
* Renderer::CreateView
4242
* <p>
4343
* <b>The API is currently not thread-safe, all calls must be made on the
4444
* main thread.</b>
@@ -49,8 +49,7 @@ public class UltralightView implements ObjectWithHandle {
4949
private final RefPtr<UltralightView> ptr;
5050

5151
/**
52-
* Constructs a new {@link UltralightView} from the given native
53-
* {@link RefPtr}.
52+
* Constructs a new {@link UltralightView} from the given native {@link RefPtr}.
5453
*
5554
* @param ptr The pointer managing the view instance
5655
*/
@@ -98,7 +97,18 @@ private UltralightView(RefPtr<UltralightView> ptr) {
9897
*/
9998
public native boolean isLoading();
10099

101-
// TODO: render_target()
100+
/**
101+
* Get the offscreen {@link UltralightRenderTarget} for the View.
102+
* <p>
103+
* Only valid when the {@link com.labymedia.ultralight.config.UltralightViewConfig#isAccelerated(boolean)} is {@code
104+
* true}.
105+
* <p>
106+
* You can use this with your GPUDriver implementation to bind and display the corresponding texture in your
107+
* application.
108+
*
109+
* @return The offscreen render target
110+
*/
111+
public native UltralightRenderTarget renderTarget();
102112

103113
/**
104114
* Get the Surface for the View (native pixel buffer container).
@@ -124,9 +134,8 @@ public void loadHTML(String html) {
124134

125135
/**
126136
* @param html The raw HTML string to load.
127-
* @param url An optional URL for this load (to make it appear as if we
128-
* we loaded this HTML from a certain URL). Can be used for
129-
* resolving relative URLs and cross-origin rules.
137+
* @param url An optional URL for this load (to make it appear as if we we loaded this HTML from a certain URL).
138+
* Can be used for resolving relative URLs and cross-origin rules.
130139
*/
131140
public void loadHTML(String html, String url) {
132141
loadHTML(html, url, false);
@@ -136,19 +145,17 @@ public void loadHTML(String html, String url) {
136145
* Load a raw string of HTML, the View will navigate to it as a new page.
137146
*
138147
* @param html The raw HTML string to load.
139-
* @param url An optional URL for this load (to make it appear as if we
140-
* we loaded this HTML from a certain URL). Can be used for
141-
* resolving relative URLs and cross-origin rules.
142-
* @param addToHistory Whether or not this load should be added to the
143-
* session's history (back/forward list).
148+
* @param url An optional URL for this load (to make it appear as if we we loaded this HTML from a certain
149+
* URL). Can be used for resolving relative URLs and cross-origin rules.
150+
* @param addToHistory Whether or not this load should be added to the session's history (back/forward list).
144151
*/
145152
public native void loadHTML(String html, String url, boolean addToHistory);
146153

147154
/**
148155
* Load a URL, the View will navigate to it as a new page.
149156
* <p>
150-
* you can use File URLs (eg, file:///page.html) but you must define
151-
* your own FileSystem implementation if you are not using AppCore.
157+
* you can use File URLs (eg, file:///page.html) but you must define your own FileSystem implementation if you are
158+
* not using AppCore.
152159
*
153160
* @param url The url to load
154161
* @see UltralightPlatform#usePlatformFileSystem(String)
@@ -161,24 +168,24 @@ public void loadHTML(String html, String url) {
161168
* @param width The initial width, in pixels.
162169
* @param height The initial height, in pixels.
163170
*/
164-
public native void resize(@NativeType("uint32_t") @Unsigned long width, @NativeType("uint32_t") @Unsigned long height);
171+
public native void resize(@NativeType("uint32_t") @Unsigned long width, @NativeType(
172+
"uint32_t") @Unsigned long height);
165173

166174
/**
167175
* Acquire the page's JSContext for use with the JavaScriptCore API.
168176
* <p>
169177
* While the lock is being hold no script will be executed by the web engine.
170178
* <p>
171-
* The context gets reset every time the view navigates, to populate it with
172-
* custom values the {@link UltralightLoadListener#onWindowObjectReady(long, boolean, String)}
173-
* and {@link UltralightLoadListener#onDOMReady(long, boolean, String)} methods are recommended.
179+
* The context gets reset every time the view navigates, to populate it with custom values the {@link
180+
* UltralightLoadListener#onWindowObjectReady(long, boolean, String)} and {@link
181+
* UltralightLoadListener#onDOMReady(long, boolean, String)} methods are recommended.
174182
*
175183
* @return The script context of the view
176184
*/
177185
public native JavascriptContextLock lockJavascriptContext();
178186

179187
/**
180-
* Helper function to evaluate a raw string of JavaScript and return the
181-
* result as a String.
188+
* Helper function to evaluate a raw string of JavaScript and return the result as a String.
182189
* <p>
183190
* You do not need to lock the JS context, it is done automatically.
184191
*
@@ -232,16 +239,15 @@ public void loadHTML(String html, String url) {
232239
/**
233240
* Give focus to the View.
234241
* <p>
235-
* You should call this to give visual indication that the View has input
236-
* focus (changes active text selection colors, for example).
242+
* You should call this to give visual indication that the View has input focus (changes active text selection
243+
* colors, for example).
237244
*/
238245
public native void focus();
239246

240247
/**
241248
* Remove focus from the View and unfocus any focused input elements.
242249
* <p>
243-
* You should call this to give visual indication that the View has lost
244-
* input focus.
250+
* You should call this to give visual indication that the View has lost input focus.
245251
*/
246252
public native void unfocus();
247253

@@ -253,20 +259,18 @@ public void loadHTML(String html, String url) {
253259
public native boolean hasFocus();
254260

255261
/**
256-
* Whether or not the View has an input element with visible keyboard focus
257-
* (indicated by a blinking caret).
262+
* Whether or not the View has an input element with visible keyboard focus (indicated by a blinking caret).
258263
* <p>
259-
* You can use this to decide whether or not the View should consume
260-
* keyboard input events (useful in games with mixed UI and key handling).
264+
* You can use this to decide whether or not the View should consume keyboard input events (useful in games with
265+
* mixed UI and key handling).
261266
*
262267
* @return Whether the view has input focus
263268
*/
264269
public native boolean hasInputFocus();
265270

266271
/**
267-
* Fire a keyboard event.
268-
* Only {@link UltralightKeyEventType#CHAR CHAR}
269-
* events actually generate text in input fields.
272+
* Fire a keyboard event. Only {@link UltralightKeyEventType#CHAR CHAR} events actually generate text in input
273+
* fields.
270274
*
271275
* @param event The event to fire
272276
*/
@@ -301,50 +305,47 @@ public void loadHTML(String html, String url) {
301305
public native void setLoadListener(UltralightLoadListener listener);
302306

303307
/**
304-
* Set whether or not this View should be repainted during the next
305-
* call to {@link UltralightRenderer#render()}.
308+
* Set whether or not this View should be repainted during the next call to {@link UltralightRenderer#render()}.
306309
* <p>
307-
* This flag is automatically set whenever the page content changes
308-
* but you can set it directly in case you need to force a repaint.
310+
* This flag is automatically set whenever the page content changes but you can set it directly in case you need to
311+
* force a repaint.
309312
*
310313
* @param needsPaint Whether the needs a re paint
311314
*/
312315
public native void setNeedsPaint(boolean needsPaint);
313316

314317
/**
315-
* Whether or not this View should be repainted during the next call to
316-
* {@link UltralightRenderer#render()}.
318+
* Whether or not this View should be repainted during the next call to {@link UltralightRenderer#render()}.
317319
*
318320
* @return Whether the view needs a re paint during the next render
319321
*/
320322
public native boolean needsPaint();
321323

322324
/**
323-
* Get the inspector for this View, this is useful for debugging and
324-
* inspecting pages locally. This will only succeed if you have the
325-
* inspector assets in your filesystem-- the inspector will look for
325+
* Get the inspector for this View, this is useful for debugging and inspecting pages locally. This will only
326+
* succeed if you have the inspector assets in your filesystem-- the inspector will look for
326327
* file:///inspector/Main.html when it first loads.
327328
* <p>
328-
* The inspector View is owned by the View and lazily-created on
329-
* first call. The initial dimensions are 10x10, you should call
330-
* {@link #resize(long, long)} on the returned View to resize it to your desired
331-
* dimensions.
329+
* The inspector View is owned by the View and lazily-created on first call. The initial dimensions are 10x10, you
330+
* should call {@link #resize(long, long)} on the returned View to resize it to your desired dimensions.
332331
*
333332
* @return An inspector view for the current view
334333
*/
335334
public native UltralightView inspector();
336335

337-
public native UltralightRenderTarget renderTarget();
338-
339336
@Override
340337
public long getHandle() {
341338
return ptr.getHandle();
342339
}
343340

344341
@Override
345342
public boolean equals(Object o) {
346-
if (this == o) return true;
347-
if (!(o instanceof UltralightView)) return false;
343+
if (this == o) {
344+
return true;
345+
}
346+
if (!(o instanceof UltralightView)) {
347+
return false;
348+
}
348349
UltralightView that = (UltralightView) o;
349350
return ptr.getHandle() == that.ptr.getHandle();
350351
}

ultralight-java-base/src/main/java/com/labymedia/ultralight/math/IntRect.java

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -245,35 +245,55 @@ public IntRect intersect(IntRect other) {
245245
);
246246
}
247247

248-
@Override
249-
public boolean equals(Object o) {
250-
if (this == o) return true;
251-
if (!(o instanceof IntRect)) return false;
252-
IntRect intRect = (IntRect) o;
253-
return left == intRect.left &&
254-
top == intRect.top &&
255-
right == intRect.right &&
256-
bottom == intRect.bottom;
257-
}
258-
259-
@Override
260-
public int hashCode() {
261-
return Objects.hash(left, top, right, bottom);
262-
}
263-
248+
/**
249+
* Retrieves the left position of this rect.
250+
*
251+
* @return The left position
252+
*/
264253
public int getLeft() {
265254
return left;
266255
}
267256

257+
/**
258+
* Retrieves the top position of this rect.
259+
*
260+
* @return The top position
261+
*/
268262
public int getTop() {
269263
return top;
270264
}
271265

266+
/**
267+
* Retrieves the right position of this rect.
268+
*
269+
* @return The right position
270+
*/
272271
public int getRight() {
273272
return right;
274273
}
275274

275+
/**
276+
* Retrieves the bottom position of this rect.
277+
*
278+
* @return The bottom position
279+
*/
276280
public int getBottom() {
277281
return bottom;
278282
}
283+
284+
@Override
285+
public boolean equals(Object o) {
286+
if (this == o) return true;
287+
if (!(o instanceof IntRect)) return false;
288+
IntRect intRect = (IntRect) o;
289+
return left == intRect.left &&
290+
top == intRect.top &&
291+
right == intRect.right &&
292+
bottom == intRect.bottom;
293+
}
294+
295+
@Override
296+
public int hashCode() {
297+
return Objects.hash(left, top, right, bottom);
298+
}
279299
}

ultralight-java-native/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ task build(type: CMakeBuildTask) {
6161
println "Building using JDK at ${javaHome.absolutePath}"
6262
variable "JAVA_HOME", javaHome.absolutePath.replace('\\', '/')
6363
}
64-
6564
}
6665
}
6766

0 commit comments

Comments
 (0)