added OptimizeCore
[org.ibex.core.git] / src / org / ibex / graphics / Polygon.java
index c99797c..8dc4bfd 100644 (file)
@@ -100,12 +100,13 @@ public final class Polygon {
     public void xor(Polygon p2) { clip(GPC_XOR, this, p2); }\r
     public void subtract(Polygon p2) { clip(GPC_DIFF, this, p2); }\r
     private static Polygon rectclipper = new Polygon();\r
-    public void addrect(float x1, float y1, float x2, float y2, Affine a) {\r
+    public Polygon addrect(float x1, float y1, float x2, float y2, Affine a) {\r
         add(a.multiply_px(x1, y1), a.multiply_py(x1, y1));\r
         add(a.multiply_px(x2, y1), a.multiply_py(x2, y1));\r
         add(a.multiply_px(x2, y2), a.multiply_py(x2, y2));\r
         add(a.multiply_px(x1, y2), a.multiply_py(x1, y2));\r
         closepath();\r
+        return this;\r
     }\r
     public void clipto(float x1, float y1, float x2, float y2, Affine a) {\r
         rectclipper.clear();\r
@@ -170,7 +171,7 @@ public final class Polygon {
             add(a.multiply_px(x, y), a.multiply_py(x, y));\r
         }\r
     }\r
-    public void transform(Affine a) {\r
+    public Polygon transform(Affine a) {\r
         maxx = Float.MIN_VALUE; maxy = Float.MIN_VALUE; minx = Float.MAX_VALUE; miny = Float.MIN_VALUE;\r
         int s = 0;\r
         for(int i=0; i<numvertices; i++) {\r
@@ -188,6 +189,7 @@ public final class Polygon {
             if (y > maxy) maxy = y;\r
             if (y < miny) miny = y;\r
         }\r
+        return this;\r
     }\r
 \r
     public void stroke(PixelBuffer buf, int color) {\r
@@ -198,9 +200,7 @@ public final class Polygon {
             float y1 = p.y[p.edges[i]];\r
             float x2 = p.x[p.edges[i]+1];\r
             float y2 = p.y[p.edges[i]+1];\r
-            long start = System.currentTimeMillis(); try {\r
-                buf.drawLine((int)Math.floor(x1), (int)Math.floor(y1), (int)Math.ceil(x2), (int)Math.ceil(y2), color);\r
-            } finally { Scheduler.drawing += System.currentTimeMillis() - start; }\r
+            buf.drawLine((int)Math.floor(x1), (int)Math.floor(y1), (int)Math.ceil(x2), (int)Math.ceil(y2), color);\r
         }\r
     }\r
 \r
@@ -260,9 +260,7 @@ public final class Polygon {
                         int tx1b = intercept(p.edges[rightSegment], y0, true, true);\r
                         int tx2a = intercept(p.edges[leftSegment], y1, true, true);\r
                         int tx2b = intercept(p.edges[rightSegment], y1, true, true);\r
-                        long start = System.currentTimeMillis(); try {\r
-                            buf.fillTrapezoid(tx1a, tx1b, (int)y0, tx2a, tx2b, (int)y1, ((Paint.SingleColorPaint)paint).color);\r
-                        } finally { Scheduler.drawing += System.currentTimeMillis() - start; }\r
+                        buf.fillTrapezoid(tx1a, tx1b, (int)y0, tx2a, tx2b, (int)y1, ((Paint.SingleColorPaint)paint).color);\r
                     }\r
                 if (useEvenOdd) count++;\r
                 else count += (p.y[p.edges[rightSegment]] < p.y[p.edges[rightSegment]+1]) ? -1 : 1;\r
@@ -349,9 +347,7 @@ public final class Polygon {
 \r
     private static Polygon clip(byte op, Polygon subj, Polygon clip) {\r
         try {\r
-            long start = System.currentTimeMillis(); try {\r
             return clip_(op, subj, clip);\r
-            } finally { Scheduler.clipping += System.currentTimeMillis() - start; }\r
         } catch (Exception npe) {\r
             npe.printStackTrace();\r
             return null;\r