Skip to content

Commit e9708cf

Browse files
committed
Initial Simd API
1 parent 7beaad1 commit e9708cf

14 files changed

Lines changed: 1385 additions & 0 deletions

File tree

CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
import com.codename1.ui.util.ImageIO;
8585
import com.codename1.util.AsyncResource;
8686
import com.codename1.util.FailureCallback;
87+
import com.codename1.util.Simd;
8788
import com.codename1.util.StringUtil;
8889
import com.codename1.util.SuccessCallback;
8990

@@ -8395,6 +8396,12 @@ public ImageIO getImageIO() {
83958396
return null;
83968397
}
83978398

8399+
/// Creates the SIMD implementation for this platform.
8400+
/// Ports may override this to provide accelerated SIMD behavior.
8401+
public Simd createSimd() {
8402+
return new Simd();
8403+
}
8404+
83988405
/// Workaround for XMLVM bug
83998406
public boolean instanceofObjArray(Object o) {
84008407
return o instanceof Object[];

CodenameOne/src/com/codename1/ui/CN.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.codename1.ui.events.WindowEvent;
3737
import com.codename1.ui.geom.Dimension;
3838
import com.codename1.ui.geom.Rectangle;
39+
import com.codename1.util.Simd;
3940
import com.codename1.util.RunnableWithResultSync;
4041

4142
import java.io.IOException;
@@ -1032,6 +1033,11 @@ public static String getPlatformName() {
10321033
return Display.impl.getPlatformName();
10331034
}
10341035

1036+
/// Returns the SIMD API for the current platform.
1037+
public static Simd getSimd() {
1038+
return Display.getInstance().getSimd();
1039+
}
1040+
10351041

10361042
/// Opens the device Dialer application with the given phone number
10371043
///

CodenameOne/src/com/codename1/ui/Display.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import com.codename1.ui.util.EventDispatcher;
6161
import com.codename1.ui.util.ImageIO;
6262
import com.codename1.util.AsyncResource;
63+
import com.codename1.util.Simd;
6364
import com.codename1.util.RunnableWithResultSync;
6465
import com.codename1.util.SuccessCallback;
6566

@@ -216,6 +217,7 @@ public final class Display extends CN1Constants {
216217
long time;
217218
private int transitionDelay = -1;
218219
private String selectedVirtualKeyboard = null;
220+
private Simd simd;
219221
private CrashReport crashReporter;
220222
private EventDispatcher errorHandler;
221223
private boolean inNativeUI;
@@ -343,6 +345,7 @@ public static void init(Object m) {
343345
commandBehaviour = impl.getCommandBehavior();
344346
}
345347
impl = (CodenameOneImplementation) ImplementationFactory.getInstance().createImplementation();
348+
INSTANCE.simd = null;
346349

347350
impl.setDisplayLock(lock);
348351
impl.initImpl(m);
@@ -493,6 +496,18 @@ CodenameOneImplementation getImplementation() {
493496
return impl;
494497
}
495498

499+
/// Returns the SIMD API instance bound to the current implementation.
500+
public Simd getSimd() {
501+
if (simd == null) {
502+
Simd created = impl.createSimd();
503+
if (created == null) {
504+
created = new Simd();
505+
}
506+
simd = created;
507+
}
508+
return simd;
509+
}
510+
496511
/// Indicates the maximum frames the API will try to draw every second
497512
/// by default this is set to 10. The advantage of limiting
498513
/// framerate is to allow the CPU to perform other tasks besides drawing.

0 commit comments

Comments
 (0)