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

Commit 8b35c89

Browse files
authored
Merge pull request #45 from LabyMod/develop
Release 1.3 support, version 0.4.0
2 parents fef8029 + b451583 commit 8b35c89

File tree

15 files changed

+620
-516
lines changed

15 files changed

+620
-516
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.6
1+
0.4.0

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
import com.labymedia.ultralight.bitmap.UltralightBitmapSurface;
2727
import com.labymedia.ultralight.config.FontHinting;
2828
import com.labymedia.ultralight.config.UltralightConfig;
29+
import com.labymedia.ultralight.config.UltralightViewConfig;
2930
import com.labymedia.ultralight.javascript.JavascriptContextLock;
31+
import com.labymedia.ultralight.lwjgl3.opengl.input.ClipboardAdapter;
3032
import com.labymedia.ultralight.lwjgl3.opengl.input.CursorAdapter;
3133
import com.labymedia.ultralight.lwjgl3.opengl.input.InputAdapter;
32-
import com.labymedia.ultralight.lwjgl3.opengl.input.ClipboardAdapter;
3334
import com.labymedia.ultralight.lwjgl3.opengl.listener.ExampleLoadListener;
3435
import com.labymedia.ultralight.lwjgl3.opengl.listener.ExampleViewListener;
3536
import com.labymedia.ultralight.math.IntRect;
@@ -64,7 +65,6 @@ public WebController(CursorAdapter cursorManager) {
6465
new UltralightConfig()
6566
.resourcePath("./resources/")
6667
.fontHinting(FontHinting.NORMAL)
67-
.deviceScale(1.0)
6868
);
6969
this.platform.usePlatformFontLoader();
7070
this.platform.setFileSystem(new ExampleFileSystem());
@@ -74,7 +74,10 @@ public WebController(CursorAdapter cursorManager) {
7474
this.renderer = UltralightRenderer.create();
7575
this.renderer.logMemoryUsage();
7676

77-
this.view = renderer.createView(300, 300, true);
77+
this.view = renderer.createView(300, 300,
78+
new UltralightViewConfig()
79+
.initialDeviceScale(1.0)
80+
.isTransparent(true));
7881
this.viewListener = new ExampleViewListener(cursorManager);
7982
this.view.setViewListener(viewListener);
8083
this.loadListener = new ExampleLoadListener(view);
@@ -111,11 +114,11 @@ public void update() {
111114
this.renderer.update();
112115
this.renderer.render();
113116

114-
if(lastJavascriptGarbageCollections == 0) {
117+
if (lastJavascriptGarbageCollections == 0) {
115118
lastJavascriptGarbageCollections = System.currentTimeMillis();
116-
} else if(System.currentTimeMillis() - lastJavascriptGarbageCollections > 1000) {
119+
} else if (System.currentTimeMillis() - lastJavascriptGarbageCollections > 1000) {
117120
System.out.println("Garbage collecting Javascript...");
118-
try(JavascriptContextLock lock = this.view.lockJavascriptContext()) {
121+
try (JavascriptContextLock lock = this.view.lockJavascriptContext()) {
119122
lock.getContext().garbageCollect();
120123
}
121124
lastJavascriptGarbageCollections = System.currentTimeMillis();
@@ -136,7 +139,7 @@ public void resize(int width, int height) {
136139
* Render the current image using OpenGL
137140
*/
138141
public void render() {
139-
if(glTexture == -1) {
142+
if (glTexture == -1) {
140143
createGLTexture();
141144
}
142145

@@ -153,11 +156,11 @@ public void render() {
153156

154157
IntRect dirtyBounds = surface.dirtyBounds();
155158

156-
if(dirtyBounds.isValid()) {
159+
if (dirtyBounds.isValid()) {
157160
ByteBuffer imageData = bitmap.lockPixels();
158161

159162
glPixelStorei(GL_UNPACK_ROW_LENGTH, (int) bitmap.rowBytes() / 4);
160-
if(dirtyBounds.width() == width && dirtyBounds.height() == height) {
163+
if (dirtyBounds.width() == width && dirtyBounds.height() == height) {
161164
// Update full image
162165
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, imageData);
163166
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.labymedia.ultralight.annotation.NativeCall;
2323
import com.labymedia.ultralight.annotation.NativeType;
2424
import com.labymedia.ultralight.annotation.Unsigned;
25+
import com.labymedia.ultralight.config.UltralightViewConfig;
2526
import com.labymedia.ultralight.ffi.ObjectWithHandle;
2627
import com.labymedia.ultralight.ffi.RefPtr;
2728

@@ -71,34 +72,16 @@ private UltralightRenderer(RefPtr<UltralightRenderer> ptr) {
7172
/**
7273
* Create a new View.
7374
*
74-
* @param width The initial width, in pixels.
75-
* @param height The initial height, in pixels.
76-
* @param transparent Whether or not the view background is transparent.
77-
* @return The created view
78-
*/
79-
public UltralightView createView(
80-
@NativeType("uint32_t") @Unsigned long width,
81-
@NativeType("uint32_t") @Unsigned long height,
82-
boolean transparent
83-
) {
84-
return createView(width, height, transparent, false);
85-
}
86-
87-
/**
88-
* Create a new View.
89-
*
90-
* @param width The initial width, in pixels.
91-
* @param height The initial height, in pixels.
92-
* @param transparent Whether or not the view background is transparent.
93-
* @param forceCpuRenderer Whether or not the view should always use the CPU renderer.
75+
* @param width The initial width, in pixels.
76+
* @param height The initial height, in pixels.
77+
* @param config Configuration details for the View.
9478
*
9579
* @return The created view
9680
*/
9781
public native UltralightView createView(
9882
@NativeType("uint32_t") @Unsigned long width,
9983
@NativeType("uint32_t") @Unsigned long height,
100-
boolean transparent,
101-
boolean forceCpuRenderer
84+
UltralightViewConfig config
10285
);
10386

10487
/**

ultralight-java-base/src/main/java/com/labymedia/ultralight/config/UltralightConfig.java

Lines changed: 0 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,6 @@ public class UltralightConfig {
5050
@Native
5151
private String cachePath;
5252

53-
/**
54-
* When enabled, each View will be rendered to an offscreen GPU texture
55-
* using the GPU driver set in Platform::set_gpu_driver. You can fetch
56-
* details for the texture via View::render_target.
57-
* <p>
58-
* When disabled (the default), each View will be rendered to an offscreen
59-
* pixel buffer. This pixel buffer can optionally be provided by the user--
60-
* for more info see <Ultralight/platform/Surface.h> and View::surface.
61-
*/
62-
@Native
63-
private boolean useGpuRenderer = false;
64-
65-
/**
66-
* The amount that the application DPI has been scaled (200% = 2.0).
67-
* This should match the device scale set for the current monitor.
68-
* <p>
69-
* Note: Device scales are rounded to nearest 1/8th (eg, 0.125).
70-
*/
71-
@Native
72-
private double deviceScale = 1.0;
73-
7453
/**
7554
* The winding order for front-facing triangles. @see FaceWinding
7655
* <p>
@@ -79,18 +58,6 @@ public class UltralightConfig {
7958
@Native
8059
private FaceWinding faceWinding = FaceWinding.COUNTER_CLOCKWISE;
8160

82-
/**
83-
* Whether or not images should be enabled.
84-
*/
85-
@Native
86-
private boolean enableImages = true;
87-
88-
/**
89-
* Whether or not JavaScript should be enabled.
90-
*/
91-
@Native
92-
private boolean enableJavascript = true;
93-
9461
/**
9562
* The hinting algorithm to use when rendering fonts.
9663
*
@@ -106,43 +73,6 @@ public class UltralightConfig {
10673
@Native
10774
private double fontGamma = 1.8;
10875

109-
/**
110-
* Default font-family to use.
111-
*/
112-
@NativeType("ultralight::String16")
113-
@Native
114-
private String fontFamilyStandard = "Times New Roman";
115-
116-
/**
117-
* Default font-family to use for fixed fonts. (pre/code)
118-
*/
119-
@NativeType("ultralight::String16")
120-
@Native
121-
private String fontFamilyFixed = "Courier New";
122-
123-
/**
124-
* Default font-family to use for serif fonts.
125-
*/
126-
@NativeType("ultralight::String16")
127-
@Native
128-
private String fontFamilySerif = "Times New Roman";
129-
130-
/**
131-
* Default font-family to use for sans-serif fonts.
132-
*/
133-
@NativeType("ultralight::String16")
134-
@Native
135-
private String fontFamilySansSerif = "Arial";
136-
137-
/**
138-
* Default user-agent string.
139-
*/
140-
@NativeType("ultralight::String16")
141-
@Native
142-
private String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
143-
"AppleWebKit/608.3.10 (KHTML, like Gecko) " +
144-
"Ultralight/1.2.0 Safari/608.3.10";
145-
14676
/**
14777
* Default user stylesheet. You should set this to your own custom CSS
14878
* string to define default styles for various DOM elements, scrollbars,
@@ -259,30 +189,6 @@ public UltralightConfig cachePath(String cachePath) {
259189
return this;
260190
}
261191

262-
/**
263-
* Sets the useGpuRenderer field of this instance.
264-
*
265-
* @param useGpuRenderer The new value of the field
266-
* @return this
267-
* @see #useGpuRenderer
268-
*/
269-
public UltralightConfig useGpuRenderer(boolean useGpuRenderer) {
270-
this.useGpuRenderer = useGpuRenderer;
271-
return this;
272-
}
273-
274-
/**
275-
* Sets the deviceScale field of this instance.
276-
*
277-
* @param deviceScale The new value of the field
278-
* @return this
279-
* @see #deviceScale
280-
*/
281-
public UltralightConfig deviceScale(double deviceScale) {
282-
this.deviceScale = deviceScale;
283-
return this;
284-
}
285-
286192
/**
287193
* Sets the faceWinding field of this instance.
288194
*
@@ -295,30 +201,6 @@ public UltralightConfig faceWinding(FaceWinding faceWinding) {
295201
return this;
296202
}
297203

298-
/**
299-
* Sets the enableImages field of this instance.
300-
*
301-
* @param enableImages The new value of the field
302-
* @return this
303-
* @see #enableImages
304-
*/
305-
public UltralightConfig enableImages(boolean enableImages) {
306-
this.enableImages = enableImages;
307-
return this;
308-
}
309-
310-
/**
311-
* Sets the enableJavascript field of this instance.
312-
*
313-
* @param enableJavascript The new value of the field
314-
* @return this
315-
* @see #enableJavascript
316-
*/
317-
public UltralightConfig enableJavascript(boolean enableJavascript) {
318-
this.enableJavascript = enableJavascript;
319-
return this;
320-
}
321-
322204
/**
323205
* Sets the fontHinting field of this instance.
324206
*
@@ -343,66 +225,6 @@ public UltralightConfig fontGamma(double fontGamma) {
343225
return this;
344226
}
345227

346-
/**
347-
* Sets the fontFamilyStandard field of this instance.
348-
*
349-
* @param fontFamilyStandard The new value of the field
350-
* @return this
351-
* @see #fontFamilyStandard
352-
*/
353-
public UltralightConfig fontFamilyStandard(String fontFamilyStandard) {
354-
this.fontFamilyStandard = fontFamilyStandard;
355-
return this;
356-
}
357-
358-
/**
359-
* Sets the fontFamilyFixed field of this instance.
360-
*
361-
* @param fontFamilyFixed The new value of the field
362-
* @return this
363-
* @see #fontFamilyFixed
364-
*/
365-
public UltralightConfig fontFamilyFixed(String fontFamilyFixed) {
366-
this.fontFamilyFixed = fontFamilyFixed;
367-
return this;
368-
}
369-
370-
/**
371-
* Sets the fontFamilySerif field of this instance.
372-
*
373-
* @param fontFamilySerif The new value of the field
374-
* @return this
375-
* @see #fontFamilySerif
376-
*/
377-
public UltralightConfig fontFamilySerif(String fontFamilySerif) {
378-
this.fontFamilySerif = fontFamilySerif;
379-
return this;
380-
}
381-
382-
/**
383-
* Sets the fontFamilySansSerif field of this instance.
384-
*
385-
* @param fontFamilySansSerif The new value of the field
386-
* @return this
387-
* @see #fontFamilySansSerif
388-
*/
389-
public UltralightConfig fontFamilySansSerif(String fontFamilySansSerif) {
390-
this.fontFamilySansSerif = fontFamilySansSerif;
391-
return this;
392-
}
393-
394-
/**
395-
* Sets the userAgent field of this instance.
396-
*
397-
* @param userAgent The new value of the field
398-
* @return this
399-
* @see #userAgent
400-
*/
401-
public UltralightConfig userAgent(String userAgent) {
402-
this.userAgent = userAgent;
403-
return this;
404-
}
405-
406228
/**
407229
* Sets the userStylesheet field of this instance.
408230
*

0 commit comments

Comments
 (0)