Revision: 2495
http://sourceforge.net/p/swingme/code/2495
Author: yuranet
Date: 2021-07-01 12:37:22 +0000 (Thu, 01 Jul 2021)
Log Message:
-----------
null pointer in context check fix and direct graphics work
Modified Paths:
--------------
iOSME/proguard.append.cfg
iOSME/src/com/nokia/mid/ui/DirectGraphics.java
iOSME/src/com/nokia/mid/ui/DirectUtils.java
iOSME/src/javax/microedition/lcdui/Graphics.java
iOSME/src/javax/microedition/lcdui/Image.java
Modified: iOSME/proguard.append.cfg
===================================================================
--- iOSME/proguard.append.cfg 2021-07-01 10:04:33 UTC (rev 2494)
+++ iOSME/proguard.append.cfg 2021-07-01 12:37:22 UTC (rev 2495)
@@ -1,3 +1,3 @@
-keep public class * extends javax.microedition.midlet.MIDlet
--keep public class net.yura.**
+-keep public class net.yura.** { *; }
Modified: iOSME/src/com/nokia/mid/ui/DirectGraphics.java
===================================================================
--- iOSME/src/com/nokia/mid/ui/DirectGraphics.java 2021-07-01 10:04:33 UTC (rev 2494)
+++ iOSME/src/com/nokia/mid/ui/DirectGraphics.java 2021-07-01 12:37:22 UTC (rev 2495)
@@ -1,38 +1,10 @@
package com.nokia.mid.ui;
-import javax.microedition.lcdui.Graphics;
-import apple.coregraphics.opaque.CGContextRef;
-import apple.coregraphics.c.CoreGraphics;
-import apple.uikit.UIColor;
+/**
+ * this is a interface in other libs, so needs to still be an interface or it will not run correctly
+ */
+public interface DirectGraphics {
-public class DirectGraphics {
-
- private Graphics g;
-
- public DirectGraphics(Graphics graphics) {
- g = graphics;
- }
-
- public void fillPolygon(int[] xPoints, int xOffset, int[] yPoints, int yOffset, int nPoints, int argbColor) {
- int tx = g.getTranslateX();
- int ty = g.getTranslateY();
- CGContextRef context = g.getContext();
-
- if (nPoints > 0) {
- CoreGraphics.CGContextSetLineWidth(context, 1.0);
- CoreGraphics.CGContextMoveToPoint(context, tx + xPoints[xOffset++], ty + yPoints[yOffset++]);
- for (int i = 1; i < nPoints; ++i) {
- CoreGraphics.CGContextAddLineToPoint(context, tx + xPoints[xOffset++], ty + yPoints[yOffset++]);
- }
- CoreGraphics.CGContextClosePath(context);
- CoreGraphics.CGContextSetFillColorWithColor(context, Graphics.getColor(argbColor).CGColor());
- CoreGraphics.CGContextFillPath(context);
- }
- }
-
- public void setARGBColor(int rgb) {
- UIColor color = Graphics.getColor(rgb);
- CoreGraphics.CGContextSetStrokeColorWithColor(g.getContext(), color.CGColor());
- CoreGraphics.CGContextSetFillColorWithColor(g.getContext(), color.CGColor());
- }
+ void fillPolygon(int[] xPoints, int xOffset, int[] yPoints, int yOffset, int nPoints, int argbColor);
+ void setARGBColor(int rgb);
}
Modified: iOSME/src/com/nokia/mid/ui/DirectUtils.java
===================================================================
--- iOSME/src/com/nokia/mid/ui/DirectUtils.java 2021-07-01 10:04:33 UTC (rev 2494)
+++ iOSME/src/com/nokia/mid/ui/DirectUtils.java 2021-07-01 12:37:22 UTC (rev 2495)
@@ -1,9 +1,38 @@
package com.nokia.mid.ui;
import javax.microedition.lcdui.Graphics;
+import apple.coregraphics.c.CoreGraphics;
+import apple.coregraphics.opaque.CGContextRef;
+import apple.uikit.UIColor;
public class DirectUtils {
- public static DirectGraphics getDirectGraphics(Graphics graphics) {
- return new DirectGraphics(graphics);
+ public static DirectGraphics getDirectGraphics(Graphics g) {
+ return new DirectGraphics() {
+
+ @Override
+ public void fillPolygon(int[] xPoints, int xOffset, int[] yPoints, int yOffset, int nPoints, int argbColor) {
+ int tx = g.getTranslateX();
+ int ty = g.getTranslateY();
+ CGContextRef context = g.getContext();
+
+ if (nPoints > 0) {
+ CoreGraphics.CGContextSetLineWidth(context, 1.0);
+ CoreGraphics.CGContextMoveToPoint(context, tx + xPoints[xOffset++], ty + yPoints[yOffset++]);
+ for (int i = 1; i < nPoints; ++i) {
+ CoreGraphics.CGContextAddLineToPoint(context, tx + xPoints[xOffset++], ty + yPoints[yOffset++]);
+ }
+ CoreGraphics.CGContextClosePath(context);
+ CoreGraphics.CGContextSetFillColorWithColor(context, Graphics.getColor(argbColor).CGColor());
+ CoreGraphics.CGContextFillPath(context);
+ }
+ }
+
+ @Override
+ public void setARGBColor(int rgb) {
+ UIColor color = Graphics.getColor(rgb);
+ CoreGraphics.CGContextSetStrokeColorWithColor(g.getContext(), color.CGColor());
+ CoreGraphics.CGContextSetFillColorWithColor(g.getContext(), color.CGColor());
+ }
+ };
}
}
Modified: iOSME/src/javax/microedition/lcdui/Graphics.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Graphics.java 2021-07-01 10:04:33 UTC (rev 2494)
+++ iOSME/src/javax/microedition/lcdui/Graphics.java 2021-07-01 12:37:22 UTC (rev 2495)
@@ -384,13 +384,16 @@
// we get the image first, this may close a current bitmap context
UIImage uiImageToDraw = image.getUIImage();
- CGContextRef current = UIKit.UIGraphicsGetCurrentContext();
- boolean same = current.getPeer().equals(context.getPeer());
+ boolean same = myContextIsCurrent();
if (!same) UIKit.UIGraphicsPushContext(context);
uiImageToDraw.drawInRect(imageRect);
if (!same) UIKit.UIGraphicsPopContext();
+ }
+ private boolean myContextIsCurrent() {
+ CGContextRef current = UIKit.UIGraphicsGetCurrentContext();
+ return current != null && current.getPeer().equals(context.getPeer());
}
public void drawRegion(Image src, int xSrc, int ySrc, int width, int height, int transform, int x_dst, int y_dst, int anchor) {
@@ -465,8 +468,7 @@
UIImage transformed = src.getUIImage(xSrc, ySrc, width, height, transform);
- CGContextRef current = UIKit.UIGraphicsGetCurrentContext();
- boolean same = current.getPeer().equals(context.getPeer());
+ boolean same = myContextIsCurrent();
if (!same) UIKit.UIGraphicsPushContext(context);
transformed.drawInRect(getDestRect(anchorX, anchorY, destWidth, destHeight));
Modified: iOSME/src/javax/microedition/lcdui/Image.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Image.java 2021-07-01 10:04:33 UTC (rev 2494)
+++ iOSME/src/javax/microedition/lcdui/Image.java 2021-07-01 12:37:22 UTC (rev 2495)
@@ -224,7 +224,7 @@
if (uiImage == null) {
CGContextRef current = UIKit.UIGraphicsGetCurrentContext();
- boolean same = current.getPeer().equals(context.getPeer());
+ boolean same = current != null && current.getPeer().equals(context.getPeer());
if (!same) UIKit.UIGraphicsPushContext(context);
uiImage = UIKit.UIGraphicsGetImageFromCurrentImageContext();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|