javauis/m3g_qt/javasrc/javax/microedition/m3g/Graphics3D.java
changeset 78 71ad690e91f5
parent 35 85266cc22c7f
equal deleted inserted replaced
72:1f0034e370aa 78:71ad690e91f5
    21 import javax.microedition.lcdui.Graphics;
    21 import javax.microedition.lcdui.Graphics;
    22 import java.util.Hashtable;
    22 import java.util.Hashtable;
    23 import java.util.Vector;
    23 import java.util.Vector;
    24 import org.eclipse.swt.widgets.*;
    24 import org.eclipse.swt.widgets.*;
    25 import org.eclipse.swt.graphics.*;
    25 import org.eclipse.swt.graphics.*;
    26 import org.eclipse.swt.internal.qt.graphics.*;
    26 import org.eclipse.swt.internal.extension.GraphicsUtil;
    27 import org.eclipse.swt.internal.qt.GCData;
       
    28 import com.nokia.mj.impl.rt.support.ShutdownListener;
    27 import com.nokia.mj.impl.rt.support.ShutdownListener;
    29 import com.nokia.mj.impl.rt.support.ApplicationUtils;
    28 import com.nokia.mj.impl.rt.support.ApplicationUtils;
    30 import com.nokia.mj.impl.nokialcdui.LCDUIInvoker;
    29 import com.nokia.mj.impl.nokialcdui.LCDUIInvoker;
    31 
    30 
    32 
    31 
   148         integrityCheck();
   147         integrityCheck();
   149         if (currentTarget != null)
   148         if (currentTarget != null)
   150         {
   149         {
   151             throw new IllegalStateException();
   150             throw new IllegalStateException();
   152         }
   151         }
   153 
       
   154         if (target == null)
   152         if (target == null)
   155         {
   153         {
   156             throw new NullPointerException();
   154             throw new NullPointerException();
   157         }
   155         }
   158 
   156 
   159         final int finalFlags = flags;
   157         final int finalFlags = flags;
   160         final boolean finalDepth = depth;
   158         final boolean finalDepth = depth;
   161 
   159 
   162         if (target instanceof org.eclipse.swt.graphics.GC)
   160         if (target instanceof org.eclipse.swt.graphics.GC)
   163         {
   161         {
   164             Rectangle clip = ((org.eclipse.swt.graphics.GC)target).getClipping();
   162             final GC finalGc = (GC)target;
   165             final int clipW = clip.width;
   163             Rectangle clip = finalGc.getClipping();
   166             final int clipH = clip.height;
   164             if (clip.width > Defs.MAX_VIEWPORT_WIDTH ||
   167             final int clipX = clip.x;
   165                     clip.height > Defs.MAX_VIEWPORT_HEIGHT)
   168             final int clipY = clip.y;
       
   169 
       
   170             if (clipW > Defs.MAX_VIEWPORT_WIDTH ||
       
   171                     clipH > Defs.MAX_VIEWPORT_HEIGHT)
       
   172             {
   166             {
   173                 throw new IllegalArgumentException();
   167                 throw new IllegalArgumentException();
   174             }
   168             }
   175 
   169 
   176             final Object finalTarget = target;
       
   177             Platform.executeInUIThread(
   170             Platform.executeInUIThread(
   178                 new M3gRunnable()
   171                 new M3gRunnable()
   179             {
   172             {
   180                 public void doRun()
   173                 public void doRun()
   181                 {
   174                 {
   182                     GCData gcData = ((org.eclipse.swt.graphics.GC)finalTarget).getGCData();
   175                     Rectangle windowClip = GraphicsUtil.startExternalRendering(finalGc);
   183                     iSurfaceHandle = gcData.internalGc.getWindowSurface().getHandle();
   176                     iSurfaceHandle = GraphicsUtil.getWindowSurface(finalGc).getHandle();
   184                     iIsImageTarget = _bindGraphics(
   177                     iIsImageTarget = _bindGraphics(
   185                                          handle,
   178                                          handle,
   186                                          iSurfaceHandle,
   179                                          iSurfaceHandle,
   187                                          clipX, clipY,
   180                                          windowClip.x, windowClip.y,
   188                                          clipW, clipH,
   181                                          windowClip.width, windowClip.height,
   189                                          finalDepth, finalFlags,
   182                                          finalDepth, finalFlags,
   190                                          iIsProperRenderer);
   183                                          iIsProperRenderer);
   191                 }
   184                 }
   192             });
   185             });
   193             currentTarget = target;
   186             currentTarget = finalGc;
   194         }
   187         }
   195 
       
   196         else if (target instanceof Graphics)
   188         else if (target instanceof Graphics)
   197         {
   189         {
   198 
   190             final Graphics finalG = (Graphics) target;
   199             Graphics g = (Graphics) target;
   191             if (finalG.getClipWidth() > Defs.MAX_VIEWPORT_WIDTH ||
   200             //Platform.sync(g);
   192                     finalG.getClipHeight() > Defs.MAX_VIEWPORT_HEIGHT)
   201 
       
   202             if (g.getClipWidth() > Defs.MAX_VIEWPORT_WIDTH ||
       
   203                     g.getClipHeight() > Defs.MAX_VIEWPORT_HEIGHT)
       
   204             {
   193             {
   205                 throw new IllegalArgumentException();
   194                 throw new IllegalArgumentException();
   206             }
   195             }
   207 
   196 
   208             offsetX = g.getTranslateX();
   197             final Rectangle windowClip = LCDUIInvoker.startExternalRendering(finalG);            
   209             offsetY = g.getTranslateY();
   198             iSurfaceHandle = LCDUIInvoker.getWindowSurface(finalG).getHandle();
   210 
       
   211             final Graphics finalG = g;
       
   212 
   199 
   213             Platform.executeInUIThread(
   200             Platform.executeInUIThread(
   214                 new M3gRunnable()
   201                 new M3gRunnable()
   215             {
   202             {
   216                 public void doRun()
   203                 public void doRun()
   217                 {
   204                 {
   218                     LCDUIInvoker.startExternalRendering( finalG );
       
   219                     iSurfaceHandle = LCDUIInvoker.getWindowSurface(finalG).getHandle();
       
   220                     iIsImageTarget = _bindGraphics(
   205                     iIsImageTarget = _bindGraphics(
   221                                          handle,
   206                                          handle,
   222                                          iSurfaceHandle,
   207                                          iSurfaceHandle,
   223                                          finalG.getClipX() + offsetX, finalG.getClipY() + offsetY,
   208                                          windowClip.x, windowClip.y,
   224                                          finalG.getClipWidth(), finalG.getClipHeight(),
   209                                          windowClip.width, windowClip.height,
   225                                          finalDepth, finalFlags,
   210                                          finalDepth, finalFlags,
   226                                          iIsProperRenderer);
   211                                          iIsProperRenderer);
   227                 }
   212                 }
   228             });
   213             });
   229             currentTarget = g;
   214             currentTarget = finalG;
   230         }
   215         }
   231         else if (target instanceof Image2D)
   216         else if (target instanceof Image2D)
   232         {
   217         {
   233             Image2D img = (Image2D) target;
   218             Image2D img = (Image2D) target;
   234 
   219 
   272             {
   257             {
   273                 public void doRun()
   258                 public void doRun()
   274                 {
   259                 {
   275                     _releaseGraphics(handle,
   260                     _releaseGraphics(handle,
   276                                      iSurfaceHandle, iIsImageTarget, iIsProperRenderer);
   261                                      iSurfaceHandle, iIsImageTarget, iIsProperRenderer);
       
   262                     GraphicsUtil.endExternalRendering((GC)currentTarget);
   277                 }
   263                 }
   278             });
   264             });
   279         }
   265         }
   280         else if (currentTarget instanceof Graphics)
   266         else if (currentTarget instanceof Graphics)
   281         {
   267         {
   284                     new M3gRunnable()
   270                     new M3gRunnable()
   285                 {
   271                 {
   286                     public void doRun()
   272                     public void doRun()
   287                     {
   273                     {
   288                         _releaseGraphics(handle,
   274                         _releaseGraphics(handle,
   289                                          iSurfaceHandle, iIsImageTarget, iIsProperRenderer);
   275                                          iSurfaceHandle, iIsImageTarget, iIsProperRenderer);                        
   290                         LCDUIInvoker.endExternalRendering( finalG );
       
   291                     }
   276                     }
   292                 });
   277                 });
   293             /*
   278                 LCDUIInvoker.endExternalRendering( finalG );
   294             Graphics g = (Graphics) currentTarget;
       
   295 
       
   296             //ToolkitInvoker invoker = ToolkitInvoker.getToolkitInvoker();
       
   297 
       
   298             Platform.getUIThread().syncExec(
       
   299                     new Runnable() {
       
   300                         public void run() {
       
   301                                         _releaseGraphics( handle,
       
   302                                         invoker.graphicsGetHandle(g), iIsImageTarget, iIsProperRenderer );
       
   303                                 }
       
   304                         });
       
   305                         */
       
   306         }
   279         }
   307         else if (currentTarget instanceof Image2D)
   280         else if (currentTarget instanceof Image2D)
   308         {
   281         {
   309             Platform.executeInUIThread(
   282             Platform.executeInUIThread(
   310                 new M3gRunnable()
   283                 new M3gRunnable()