2003/11/13 05:04:23
[org.ibex.core.git] / src / org / xwt / plat / OpenGL.java
index 68ed8c1..8ed60c2 100644 (file)
@@ -28,7 +28,7 @@ abstract class OpenGL {
         }
     }
     
-    // This MUST be called after OpenGL is instansiated (and activateSharedContext is functioning)
+    // This MUST be called after OpenGL is instansiated (and activateSharedJSContext is functioning)
     public void init() throws NotSupportedException {
         natInit();
         glVersion = parseVersion(version);
@@ -46,7 +46,7 @@ abstract class OpenGL {
         Log.log(this,"Max rectangular texture size: " + maxRectTexSize);
     }
     
-    protected abstract void activateSharedContext();
+    protected abstract void activateSharedJSContext();
 
     public static class NotSupportedException extends Exception {
         public NotSupportedException(String s) { super(s); }
@@ -66,7 +66,7 @@ abstract class OpenGL {
         }
         
         // This should activate the drawing context and prepare the double buffer for drawing
-        protected abstract void activateContext();
+        protected abstract void activateJSContext();
         
         protected static native void drawableInit(int w, int h);
         
@@ -74,7 +74,7 @@ abstract class OpenGL {
         
         public native void setClip(int x, int y, int x2, int y2);
         public native void resetClip();
-        public native void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color);
+        public native void fillJSTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int color);
             
         public void drawString(String font, String text, int x, int y, int color) {
             //System.out.println("drawString(): " + text);
@@ -88,7 +88,7 @@ abstract class OpenGL {
         }
 
         private void drawPicture_(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int color) {
-            activateContext();
+            activateJSContext();
             setColor(color);
             GLPicture p = (GLPicture) source;
             p.draw(dx,dy,cx1,cy1,cx2,cy2);
@@ -120,9 +120,7 @@ abstract class OpenGL {
     public void deleteTexture(final int tex) {
         // CHECKME: Is this safe to do from finalize()?
         // natDeleteTexture MUST be run from the message queue thread
-        Message.Q.add(new Message() { public void perform() {
-            natDeleteTexture(tex);
-        }});
+        Scheduler.add(new Scheduler.Task() { public void perform() { natDeleteTexture(tex); }});
     }
     
     private static abstract class GLPicture extends Picture {
@@ -247,16 +245,9 @@ abstract class OpenGL {
             // *{x,y}{1,2} key: d=dest s=src, p=bounds of this picture, i=intersection of s and p, pd = dest of this pic
             for(int i=0;i<pics.length;i++) {
                 for(int j=0;j<pics[i].length;j++) {
-                    int px1 = j*psize;
-                    int py1 = i*psize;
-                    int px2 = min(px1+psize,totalWidth);
-                    int py2 = min(py1+psize,totalHeight);
-                    int ix1 = max(px1,cx1);
-                    int iy1 = max(py1,cy1);
-                    int ix2 = min(px2,cx2);
-                    int iy2 = min(py2,cy2);
-                    if (ix1 >= ix2 || iy1 >= iy2) continue; // no intersection
-                    pics[i][j].draw(px1, py1, ix1, iy1, ix2, iy2);
+                    int px1 = j*psize + dx;
+                    int py1 = i*psize + dy;
+                    pics[i][j].draw(px1, py1, cx1, cy1, cx2, cy2);
                 }
             }
         }