Skip to content

Commit

Permalink
Moved typed array factory from kit to platform
Browse files Browse the repository at this point in the history
  • Loading branch information
salmonb committed Jan 11, 2024
1 parent ca2552b commit 9a532e4
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 83 deletions.
17 changes: 12 additions & 5 deletions webfx-kit/webfx-kit-webgl-gwt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
<version>0.1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.google.elemental2</groupId>
<artifactId>elemental2-core</artifactId>
</dependency>

<dependency>
<groupId>com.google.elemental2</groupId>
<artifactId>elemental2-dom</artifactId>
Expand Down Expand Up @@ -66,6 +61,18 @@
<version>0.1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>dev.webfx</groupId>
<artifactId>webfx-platform-typedarray</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>dev.webfx</groupId>
<artifactId>webfx-platform-typedarray-gwt</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>

</dependencies>

</project>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import dev.webfx.kit.mapper.peers.javafxgraphics.NodePeer;
import dev.webfx.kit.mapper.peers.javafxgraphics.gwt.html.HtmlCanvasPeer;
import dev.webfx.kit.webgl.ArrayBuffer;
import dev.webfx.kit.webgl.spi.WebGLProvider;
import elemental2.core.Float32Array;
import elemental2.core.Uint16Array;
import elemental2.core.Uint8Array;
import elemental2.dom.HTMLCanvasElement;
import elemental2.webgl.WebGLRenderingContext;
import javafx.scene.Node;
Expand Down Expand Up @@ -68,7 +64,6 @@ public dev.webfx.kit.webgl.WebGLRenderingContext getContext(Node webglNode) {
if (jsContext == null)
return null;
dev.webfx.kit.webgl.WebGLRenderingContext gln = new GwtWebGLRenderingContext(jsContext);
//gln = new WebGLRenderingContextLogger(gln);
webglNode.getProperties().put("webglContext", gln);
return gln;
}
Expand All @@ -84,19 +79,4 @@ private WebGLRenderingContext getWebGLRenderingContext(Canvas canvas) {
return null;
}

@Override
public ArrayBuffer createFloat32Array(double... array) {
Float32Array float32Array = Float32Array.from(array);
return new GwtArrayBuffer(float32Array);
}

@Override
public ArrayBuffer createUint16Array(double... array) {
return new GwtArrayBuffer(new Uint16Array(array));
}

@Override
public ArrayBuffer Uint8Array(double... array) {
return new GwtArrayBuffer(new Uint8Array(array));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import dev.webfx.kit.mapper.peers.javafxgraphics.gwt.html.HtmlGraphicsContext;
import dev.webfx.kit.mapper.peers.javafxmedia.spi.gwt.GwtMediaPlayerPeer;
import dev.webfx.kit.webgl.*;
import dev.webfx.platform.typedarray.TypedArray;
import dev.webfx.platform.typedarray.spi.impl.gwt.GwtTypedArray;
import elemental2.dom.HTMLImageElement;
import elemental2.dom.HTMLVideoElement;
import javafx.scene.image.Image;
Expand Down Expand Up @@ -95,8 +97,8 @@ public void bindBuffer(int target, WebGLBuffer buffer) {
}

@Override
public void bufferData(int target, ArrayBuffer data, int usage) {
GwtArrayBuffer gwtArrayBuffer = (GwtArrayBuffer) data;
public void bufferData(int target, TypedArray data, int usage) {
GwtTypedArray gwtArrayBuffer = (GwtTypedArray) data;
if (gwtArrayBuffer.jsArrayBuffer != null)
gl.bufferData(target, gwtArrayBuffer.jsArrayBuffer, usage);
else
Expand Down Expand Up @@ -180,8 +182,8 @@ public void texImage2D(int target, int level, int internalformat, int format, in
}

@Override
public void texImage2D(int target, int level, int internalformat, int format, int type, int img, int format0, int type0, ArrayBuffer pixels) {
GwtArrayBuffer gwtArrayBuffer = (GwtArrayBuffer) pixels;
public void texImage2D(int target, int level, int internalformat, int format, int type, int img, int format0, int type0, TypedArray pixels) {
GwtTypedArray gwtArrayBuffer = (GwtTypedArray) pixels;
gl.texImage2D(target, level, internalformat, format, type, img, format0, type0, gwtArrayBuffer.jsArrayBufferView);
}

Expand Down
6 changes: 6 additions & 0 deletions webfx-kit/webfx-kit-webgl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
<version>0.1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>dev.webfx</groupId>
<artifactId>webfx-platform-typedarray</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>dev.webfx</groupId>
<artifactId>webfx-platform-util</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.webfx.kit.webgl;

import dev.webfx.platform.util.serviceloader.SingleServiceProvider;
import dev.webfx.kit.webgl.spi.WebGLProvider;
import dev.webfx.platform.util.serviceloader.SingleServiceProvider;
import javafx.scene.Node;

import java.util.ServiceLoader;
Expand Down Expand Up @@ -42,16 +42,4 @@ public static WebGLRenderingContext getContext(Node webglNode) {
return getProvider().getContext(webglNode);
}

public static ArrayBuffer createFloat32Array(double... array) {
return getProvider().createFloat32Array(array);
}

public static ArrayBuffer createUint16Array(double... array) {
return getProvider().createUint16Array(array);
}

public static ArrayBuffer createUint8Array(double... array) {
return getProvider().Uint8Array(array);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.webfx.kit.webgl;

import dev.webfx.platform.typedarray.TypedArray;
import javafx.scene.image.Image;

/**
Expand Down Expand Up @@ -327,7 +328,7 @@ public interface WebGLRenderingContext {
void blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha);
*/
void bufferData(int target, ArrayBuffer data, int usage); /*{
void bufferData(int target, TypedArray data, int usage); /*{
bufferData(
target, Js.<WebGLRenderingContext.BufferDataDataUnionType>uncheckedCast(data), usage);
}*/
Expand Down Expand Up @@ -1026,7 +1027,7 @@ void texImage2D(
int img,
int format0,
int type0,
ArrayBuffer pixels);/* {
TypedArray pixels);/* {
texImage2D(
target,
level,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.webfx.kit.webgl.spi;

import dev.webfx.kit.webgl.ArrayBuffer;
import dev.webfx.kit.webgl.WebGLRenderingContext;
import javafx.scene.Node;

Expand All @@ -21,10 +20,4 @@ public interface WebGLProvider {

WebGLRenderingContext getContext(Node webglNode);

ArrayBuffer createFloat32Array(double... array);

ArrayBuffer createUint16Array(double... array);

ArrayBuffer Uint8Array(double... array);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.webfx.kit.webgl.spi.impl;

import dev.webfx.kit.webgl.*;
import dev.webfx.platform.typedarray.TypedArray;
import javafx.scene.image.Image;
import javafx.scene.media.MediaView;

Expand Down Expand Up @@ -33,7 +34,7 @@ public void bindBuffer(int target, WebGLBuffer buffer) {
}

@Override
public void bufferData(int target, ArrayBuffer data, int usage) {
public void bufferData(int target, TypedArray data, int usage) {
log("bufferData(target = " + target +", data = " + data + ", usage = " + usage + ")");
gl.bufferData(target, data, usage);
}
Expand Down Expand Up @@ -215,7 +216,7 @@ public void texImage2D(int target, int level, int internalformat, int format, in
}

@Override
public void texImage2D(int target, int level, int internalformat, int format, int type, int img, int format0, int type0, ArrayBuffer pixels) {
public void texImage2D(int target, int level, int internalformat, int format, int type, int img, int format0, int type0, TypedArray pixels) {
gl.texImage2D(target, level, internalformat, format, type, img, format0, type0, pixels);
}

Expand Down
1 change: 1 addition & 0 deletions webfx-kit/webfx-kit-webgl/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
requires javafx.graphics;
requires javafx.media;
requires webfx.platform.console;
requires webfx.platform.typedarray;
requires webfx.platform.util;

// Exported packages
Expand Down

0 comments on commit 9a532e4

Please sign in to comment.