3737import 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 }
0 commit comments