javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GScalableGraphics.java
changeset 87 1627c337e51e
parent 80 d6dafc5d983f
equal deleted inserted replaced
80:d6dafc5d983f 87:1627c337e51e
     1 /*
     1 /*
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    27 import org.eclipse.swt.graphics.Rectangle;
    27 import org.eclipse.swt.graphics.Rectangle;
    28 import com.nokia.mj.impl.utils.Logger;
    28 import com.nokia.mj.impl.utils.Logger;
    29 import com.nokia.mj.impl.nokialcdui.LCDUIInvoker;
    29 import com.nokia.mj.impl.nokialcdui.LCDUIInvoker;
    30 import org.eclipse.swt.internal.qt.GCData;
    30 import org.eclipse.swt.internal.qt.GCData;
    31 import org.eclipse.swt.internal.qt.graphics.GraphicsContext;
    31 import org.eclipse.swt.internal.qt.graphics.GraphicsContext;
    32 import org.eclipse.swt.internal.extension.GraphicsUtil; 
    32 import org.eclipse.swt.internal.extension.GraphicsUtil;
    33 
    33 
    34 /*
    34 /*
    35  * ScalableGraphics
    35  * ScalableGraphics
    36  */
    36  */
    37 public class M2GScalableGraphics
    37 public class M2GScalableGraphics
    38         extends M2GObject
    38         extends M2GObject
    39 {
    39 {
    40     //--------------------------------------------------
    40     //--------------------------------------------------
    41     // STATIC CONSTANTS
    41     // STATIC CONSTANTS
    42     //--------------------------------------------------
    42     //--------------------------------------------------
    43     // Exception text
    43 
    44     /* Optimization: static finals changed to local variables
       
    45     private static final String ALPHA_OUT_OF_RANGE_ESTR =
       
    46         "The alpha is out of range";
       
    47     private static final String INVALID_TARGET_ESTR =
       
    48         "The target is invalid";
       
    49     private static final String MODE_INVALID_ESTR =
       
    50         "The mode is invalid";
       
    51     private static final String NULL_IMAGE_ESTR =
       
    52         "The image is null";
       
    53     private static final String NULL_TARGET_ESTR =
       
    54         "The target is null";
       
    55     private static final String TARGET_ALREADY_BOUND_ESTR =
       
    56         "Target is already bound";
       
    57     private static final String TARGET_NOT_BOUND_ESTR =
       
    58         "Target is not bound";
       
    59     */
       
    60     // Transparency alpha max and min limits
    44     // Transparency alpha max and min limits
    61     private static final float MAX_TRANSPARENCY_ALPHA = 1.0f;
    45     private static final float MAX_TRANSPARENCY_ALPHA = 1.0f;
    62     private static final float MIN_TRANSPARENCY_ALPHA = 0.0f;
    46     private static final float MIN_TRANSPARENCY_ALPHA = 0.0f;
    63 
    47 
    64     //--------------------------------------------------
    48     //--------------------------------------------------
    67     private GC        iTargetGC      = null;
    51     private GC        iTargetGC      = null;
    68     private int iUseNativeClear = 0;
    52     private int iUseNativeClear = 0;
    69     private Graphics iTargetGraphics;
    53     private Graphics iTargetGraphics;
    70     private Rectangle iSurfaceRectangle;
    54     private Rectangle iSurfaceRectangle;
    71     private Rectangle iFinalESWTSurfaceRectangle;
    55     private Rectangle iFinalESWTSurfaceRectangle;
    72     
    56 
    73      int iSurfaceHandle;
    57     int iSurfaceHandle;
    74 
    58 
    75     //--------------------------------------------------
    59     //--------------------------------------------------
    76     // METHODS
    60     // METHODS
    77     //--------------------------------------------------
    61     //--------------------------------------------------
    78     /**
    62     /**
    79      * Constructor
    63      * Constructor
    80      */
    64      */
    81     public M2GScalableGraphics()
    65     public M2GScalableGraphics()
    82     {
    66     {
    83         super();
    67         super();
    84         
    68 
    85         doConstruct();
    69         doConstruct();
    86     }
    70     }
    87     /**
    71     /**
    88      * @see javax.microedition.m2g.ScalableGraphics#bindTarget()
    72      * @see javax.microedition.m2g.ScalableGraphics#bindTarget()
    89      */
    73      */
    90     public synchronized void bindTarget(Object target)
    74     public synchronized void bindTarget(Object target)
    91     {
    75     {
    92     	
    76         if (target == null)
    93     	if (target == null )
    77         {
    94     	{
    78             throw new NullPointerException(/*SF*/"The target is null"/*SF*/);
    95     		throw new NullPointerException(/*SF*/"The target is null"/*SF*/);
    79         }
    96     	}
    80 
    97     	
    81         if (target instanceof org.eclipse.swt.graphics.GC)
    98     	if (target instanceof org.eclipse.swt.graphics.GC)
    82         {
    99         	{
    83             final GC finalGc = (GC)target;
   100     		
    84 
   101 			final GC finalGc = (GC)target;
    85             // Execute in UI thread
   102 
    86             Platform.executeInUIThread(
   103         	// Execute in UI thread     
    87                 new M2GRunnableQt()
   104         	Platform.executeInUIThread(
    88             {
   105                 new M2GRunnableQt() {
    89                 public void doRun()
   106                     public void doRun() {
    90                 {
   107                     	iFinalESWTSurfaceRectangle = GraphicsUtil.startExternalRendering(finalGc);
    91                     iFinalESWTSurfaceRectangle = GraphicsUtil.startExternalRendering(finalGc);
   108                     	
    92 
   109                     	// Get GCData from GC
    93                     // Get GCData from GC
   110                     	/*TODO check for this cahnge GCData gcData = ((org.eclipse.swt.graphics.GC)finalGc).getGCData();    
    94                     iSurfaceHandle = GraphicsUtil.getWindowSurface(finalGc).getHandle();
   111                     	// Get internalGC (Graphicscontext), WindowSurface and the WindowSurface handle for native access
    95                     _bind(getHandle(), iSurfaceHandle);
   112                         iSurfaceHandle = gcData.internalGc.getWindowSurface().getHandle();*/
    96                 }
   113                     	iSurfaceHandle = GraphicsUtil.getWindowSurface(finalGc).getHandle();
    97             });
   114                         
    98 
   115                         _bind(getHandle(), iSurfaceHandle);
    99             iTargetGC = (GC)finalGc;
   116                         
   100             // Handling for LCDUI Graphics
   117                       }
   101         }
   118                       });
   102         else if (target instanceof javax.microedition.lcdui.Graphics)
   119                     //  currentTarget = target;
   103         {
   120         		iTargetGC = (GC)finalGc;
   104             Graphics g = (Graphics)target;
   121 		    // Handling for LCDUI Graphics
   105             final Graphics finalG = g;
   122 		    //
   106             iSurfaceRectangle = LCDUIInvoker.startExternalRendering(finalG);
   123 		    }
   107             // Execute in UI thread
   124 //Change accordingly to M3G not as site content.		    
   108             Platform.executeInUIThread(
   125 		    else if (target instanceof javax.microedition.lcdui.Graphics)
   109                 new M2GRunnableQt()
   126 		    {
   110             {
   127 		    	Graphics g = (Graphics)target;
   111                 public void doRun()
   128 		    	final Graphics finalG = g;
   112                 {
   129 		    	iSurfaceRectangle = LCDUIInvoker.startExternalRendering( finalG );
   113 
   130 		    	 // Execute in UI thread     
   114                     iSurfaceHandle = LCDUIInvoker.getWindowSurface(finalG).getHandle();
   131 			        Platform.executeInUIThread(
   115 
   132 			                new M2GRunnableQt() {
   116                     // Flush Canvas
   133 			                    public void doRun() {
   117                     //M2GManager.flushDisplayBuffer();
   134 														
   118                     _bind(getHandle(), iSurfaceHandle);
   135 			                    	  
   119                 }
   136 			                    	
   120             });
   137                         		iSurfaceHandle = LCDUIInvoker.getWindowSurface(finalG).getHandle();
   121 
   138                         		
   122             iTargetGraphics  = (Graphics)finalG;
   139                         		// Flush Canvas
   123         }
   140 								            //M2GManager.flushDisplayBuffer();
   124 
   141 		                        _bind(getHandle(), iSurfaceHandle);
   125         else
   142 		                        
   126         {
   143 
   127             throw new IllegalArgumentException();
   144 			                    }
   128         }
   145 			                  });
   129     }
   146 			                  
       
   147 			                  iTargetGraphics  = (Graphics)finalG;
       
   148 		    	}
       
   149 			         
       
   150 	         else {
       
   151 			        throw new IllegalArgumentException();
       
   152 			    }
       
   153     	
       
   154     	//TODO Check for : when to give this exception java.lang.IllegalStateException - if target is already bound.
       
   155     
       
   156   }
       
   157     	
       
   158 
       
   159 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
   160 
   130 
   161     /**
   131     /**
   162      * @see com.nokia.microedition.m2g.M2GObject#doConstruct()
   132      * @see com.nokia.microedition.m2g.M2GObject#doConstruct()
   163      */
   133      */
   164     public void doConstruct()
   134     public void doConstruct()
   165     {
   135     {
   166       super.doConstruct();
   136         super.doConstruct();
   167       
   137 
   168     	 // Execute in UI thread     
   138         // Execute in UI thread
   169 	    Platform.executeInUIThread(
   139         Platform.executeInUIThread(
   170             new M2GRunnableQt() {
   140             new M2GRunnableQt()
   171                 public void doRun() {
   141         {
   172 										        setHandle(_createRenderContext(
   142             public void doRun()
   173 										                      getNativeSVGProxyHandle() ));
   143             {
   174 										        // Add object to the live objects container
   144                 setHandle(_createRenderContext(
   175 										      }
   145                               getNativeSVGProxyHandle()));
   176 										    });
   146                 // Add object to the live objects container
       
   147             }
       
   148         });
   177         register(this);
   149         register(this);
   178     }
   150     }
   179 
   151 
   180     /**
   152     /**
   181      * @see com.nokia.microedition.m2g.M2GObject#doCleanup()
   153      * @see com.nokia.microedition.m2g.M2GObject#doCleanup()
   182      */
   154      */
   183     public synchronized void doCleanup()
   155     public synchronized void doCleanup()
   184     {
   156     {
   185     	
   157 
   186  		    	 // Execute in UI thread     
   158         // Execute in UI thread
   187 			        Platform.executeInUIThread(
   159         Platform.executeInUIThread(
   188 			                new M2GRunnableQt() {
   160             new M2GRunnableQt()
   189 			                    public void doRun() {  	
   161         {
   190 																			        _deleteRenderContext(
   162             public void doRun()
   191 																			            getHandle() );
   163             {
   192 																			          }
   164                 _deleteRenderContext(
   193 																			       }
   165                     getHandle());
   194 																			    );      
   166             }
       
   167         }
       
   168         );
   195         resetHandles();
   169         resetHandles();
   196         iTargetGC = null;
   170         iTargetGC = null;
   197         iTargetGraphics = null;
   171         iTargetGraphics = null;
   198     }
   172     }
   199 
   173 
   200     /**
   174     /**
   201      * @see javax.microedition.m2g.ScalableGraphics#releaseTarget()
   175      * @see javax.microedition.m2g.ScalableGraphics#releaseTarget()
   202      */
   176      */
   203     public synchronized void releaseTarget()
   177     public synchronized void releaseTarget()
   204     {
   178     {
   205     	
   179         if (iTargetGC != null)
   206       if (iTargetGC != null)
   180         {
   207       {
   181 
   208       
   182             Platform.executeInUIThread(
   209 			Platform.executeInUIThread(
   183                 new M2GRunnableQt()
   210             new M2GRunnableQt() {
   184             {
   211              public void doRun() {
   185                 public void doRun()
   212             	 						   GraphicsUtil.endExternalRendering(iTargetGC);
   186                 {
   213             	      				      _release(iSurfaceHandle, getHandle());
   187                     GraphicsUtil.endExternalRendering(iTargetGC);
   214             	      				    }
   188                     _release(iSurfaceHandle, getHandle());
   215             	      				  });
   189                 }
       
   190             });
   216             iTargetGC = null;
   191             iTargetGC = null;
   217         }
   192         }
   218 			else if (iTargetGraphics != null )
   193         else if (iTargetGraphics != null)
   219 		    {
   194         {
   220 				
   195             final Graphics finalG = iTargetGraphics;
   221 				
   196             Platform.executeInUIThread(
   222 				final Graphics finalG = iTargetGraphics;
   197                 new M2GRunnableQt()
   223 				Platform.executeInUIThread(
   198             {
   224 	            new M2GRunnableQt() {
   199                 public void doRun()
   225 	             public void doRun() {
   200                 {
   226 	            			_release(iSurfaceHandle, getHandle());
   201                     _release(iSurfaceHandle, getHandle());
   227 	            		}
   202                 }
   228 	            	});
   203             });
   229 				LCDUIInvoker.endExternalRendering( iTargetGraphics );
   204             LCDUIInvoker.endExternalRendering(iTargetGraphics);
   230 				
   205 
   231         iTargetGraphics = null;
   206             iTargetGraphics = null;
   232         }
   207         }
   233       else 
   208         else
   234       	{
   209         {
   235   			
       
   236   		   // check for invalid Graphics TODO this exception is getting trough when we trying to bind.s
       
   237             throw new IllegalStateException(/*SF*/"Target is not bound"/*SF*/);
   210             throw new IllegalStateException(/*SF*/"Target is not bound"/*SF*/);
   238       	}
   211         }
   239 
   212 
   240     }
   213     }
       
   214 
   241     public synchronized void render(
   215     public synchronized void render(
   242         int x, int y, ScalableImage image, boolean aUseNativeClear)
   216         int x, int y, ScalableImage image, boolean aUseNativeClear)
   243     {
   217     {
   244 				
       
   245 
       
   246         iUseNativeClear = aUseNativeClear ? 1 : 0;
   218         iUseNativeClear = aUseNativeClear ? 1 : 0;
   247         render(x, y, image);
   219         render(x, y, image);
   248         iUseNativeClear = 0;
   220         iUseNativeClear = 0;
   249         
   221 
   250         
       
   251         
       
   252     }
   222     }
   253 
   223 
   254     /**
   224     /**
   255      * @see javax.microedition.m2g.ScalableGraphics#render()
   225      * @see javax.microedition.m2g.ScalableGraphics#render()
   256      */
   226      */
   257     public synchronized void render(int x, int y, ScalableImage image)
   227     public synchronized void render(int x, int y, ScalableImage image)
   258     {
   228     {
   259     		
   229 
   260         if (image == null)
   230         if (image == null)
   261         {
   231         {
   262             Logger.ELOG(Logger.EJavaUI, "render() - exception: "
   232             Logger.ELOG(Logger.EJavaUI, "render() - exception: "
   263                         + /*SF*/"The target is null"/*SF*/);
   233                         + /*SF*/"The target is null"/*SF*/);
   264             throw new NullPointerException(/*SF*/"The target is null"/*SF*/);
   234             throw new NullPointerException(/*SF*/"The target is null"/*SF*/);
   265         }
   235         }
   266        if (iTargetGC != null)
   236         if (iTargetGC != null)
   267         {
   237         {
   268             final M2GDocument finalDoc = (M2GDocument)((SVGImage)image).getDocument();
   238             final M2GDocument finalDoc = (M2GDocument)((SVGImage)image).getDocument();
   269             // Get synchronized svg image data
   239             // Get synchronized svg image data
   270             final int finalSvgW  = image.getViewportWidth();
   240             final int finalSvgW  = image.getViewportWidth();
   271             final int finalSvgH = image.getViewportHeight();
   241             final int finalSvgH = image.getViewportHeight();
   272             if ((finalSvgW == 0) || (finalSvgW == 0))
   242             if ((finalSvgW == 0) || (finalSvgW == 0))
   273             {
   243             {
   274                 return;
   244                 return;
   275             }
   245             }
   276             // Calculate clip dimensions TODO check the new clipping rect provided from StartExternalRendering API.s
   246 
   277             //Rectangle clipRect = iTargetGC.getClipping();
       
   278             Rectangle clipRect = iFinalESWTSurfaceRectangle;
   247             Rectangle clipRect = iFinalESWTSurfaceRectangle;
   279             
   248 
   280             final int finalClipX = clipRect.x;
   249             final int finalClipX = clipRect.x;
   281             final int finalClipY = clipRect.y;
   250             final int finalClipY = clipRect.y;
   282             final int finalClipW = clipRect.width;
   251             final int finalClipW = clipRect.width;
   283             final int finalClipH = clipRect.height;
   252             final int finalClipH = clipRect.height;
   284             
   253 
   285             
   254 
   286             // if none of the svg image is visible due to clipping then don't
   255             // if none of the svg image is visible due to clipping then don't
   287             // bother to call render
   256             // bother to call render
   288             if ((x >= (finalClipX + finalClipW)) || (y >= (finalClipY + finalClipH)))
   257             if ((x >= (finalClipX + finalClipW)) || (y >= (finalClipY + finalClipH)))
   289             {
   258             {
   290                 Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   259                 Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   295             {
   264             {
   296                 Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   265                 Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   297                            "render() - svg image isn't visible due to clipping");
   266                            "render() - svg image isn't visible due to clipping");
   298                 return;
   267                 return;
   299             }
   268             }
   300             
   269 
   301 
   270 
   302 						final int finalX = x;            
   271             final int finalX = x;
   303 						final int finalY = y; 
   272             final int finalY = y;
   304 						         
   273 
   305         		    	 // Execute in UI thread   
   274             // Execute in UI thread
   306 	        Platform.executeInUIThread(
   275             Platform.executeInUIThread(
   307 	                new M2GRunnableQt() {
   276                 new M2GRunnableQt()
   308 	                    public void doRun() {         
   277             {
   309 	                    	
   278                 public void doRun()
   310 	                    								
   279                 {
   311 	                    									
   280 
   312 																			final int[] finalData = _renderESWT(getHandle(),
   281                     final int[] finalData = _renderESWT(getHandle(),
   313 											                                     finalDoc.getHandle(), finalX, finalY,
   282                                                         finalDoc.getHandle(), finalX, finalY,
   314 											                                     finalClipX, finalClipY, finalClipW, finalClipH, finalSvgW, finalSvgW,
   283                                                         finalClipX, finalClipY, finalClipW, finalClipH, finalSvgW, finalSvgW,
   315 											                                     finalDoc.getRootElement().getCurrentTime(),
   284                                                         finalDoc.getRootElement().getCurrentTime(),
   316 											                                     iUseNativeClear);
   285                                                         iUseNativeClear);
   317 																									                                     
   286 
   318 																				int[] bitmapHandles;
   287                     int[] bitmapHandles;
   319 														            bitmapHandles = new int[4];
   288                     bitmapHandles = new int[4];
   320 														            for (int i = 0; i < 4; i++)
   289                     for (int i = 0; i < 4; i++)
   321 														            {
   290                     {
   322 														                bitmapHandles[i] = finalData[i];
   291                         bitmapHandles[i] = finalData[i];
   323 														            }
   292                     }
   324 														            int[] renderData;
   293                     int[] renderData;
   325 														            renderData = new int[6];
   294                     renderData = new int[6];
   326 														            for (int i = 0; i < 6; i++)
   295                     for (int i = 0; i < 6; i++)
   327 														            {
   296                     {
   328 														                renderData[i] = finalData[i+4];
   297                         renderData[i] = finalData[i+4];
   329 														            }
   298                     }
   330 														            //iTargetGC.internal_drawM2GImage(bitmapHandles, renderData, iUseNativeClear);
   299 
   331 
   300                 }
   332 																					}});											                                     
   301             });
   333             
   302 
   334         }//if(true)
   303         }//if(true)
   335 		else if (iTargetGraphics != null)
   304         else if (iTargetGraphics != null)
   336 		    {
   305         {
   337 		    	
   306 
   338    	    		
   307 
   339             final M2GDocument finalDoc = (M2GDocument)((SVGImage)image).getDocument();
   308             final M2GDocument finalDoc = (M2GDocument)((SVGImage)image).getDocument();
   340             // Get synchronized svg image data
   309             // Get synchronized svg image data
   341             final int finalSvgW  = image.getViewportWidth();
   310             final int finalSvgW  = image.getViewportWidth();
   342             final int finalSvgH = image.getViewportHeight();
   311             final int finalSvgH = image.getViewportHeight();
   343             if ((finalSvgW == 0) || (finalSvgH == 0))
   312             if ((finalSvgW == 0) || (finalSvgH == 0))
   344             {	
   313             {
   345             	
   314 
   346                 return;
   315                 return;
   347             }
   316             }
   348             
   317 
   349             
       
   350             //TODO as we are using Surface rectangle provided by StartExternalRendering as Clip Rectangle.
       
   351             final int finalClipX = iSurfaceRectangle.x;
   318             final int finalClipX = iSurfaceRectangle.x;
   352             final int finalClipY = iSurfaceRectangle.y;
   319             final int finalClipY = iSurfaceRectangle.y;
   353             final int finalClipW  = iSurfaceRectangle.width;
   320             final int finalClipW  = iSurfaceRectangle.width;
   354             final int finalClipH = iSurfaceRectangle.height;
   321             final int finalClipH = iSurfaceRectangle.height;
   355 
   322 
   356             // Calculate clip dimensions
       
   357             /*final int finalClipX = iTargetGraphics.getClipX() + iTargetGraphics.getTranslateX();
       
   358             final int finalClipY = iTargetGraphics.getClipY() + iTargetGraphics.getTranslateY();
       
   359             final int finalClipW  = iTargetGraphics.getClipWidth();
       
   360             final int finalClipH = iTargetGraphics.getClipHeight();*/
       
   361             // if none of the svg image is visible due to clipping then don't
   323             // if none of the svg image is visible due to clipping then don't
   362             // bother to call render
   324             // bother to call render
   363             if ((x >= (finalClipX + finalClipW)) || (y >= (finalClipY + finalClipH)))
   325             if ((x >= (finalClipX + finalClipW)) || (y >= (finalClipY + finalClipH)))
   364             {
   326             {
   365                 Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   327                 Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   370             {
   332             {
   371                 Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   333                 Logger.LOG(Logger.EJavaUI, Logger.EInfo,
   372                            "render() - svg image isn't visible due to clipping");
   334                            "render() - svg image isn't visible due to clipping");
   373                 return;
   335                 return;
   374             }
   336             }
   375             
   337 
   376 				final int finalX = x;            
   338             final int finalX = x;
   377 				final int finalY = y;
   339             final int finalY = y;
   378 				
   340 
   379 				
   341             // Execute in UI thread
   380 
   342             Platform.executeInUIThread(
   381       		    	 // Execute in UI thread     
   343                 new M2GRunnableQt()
   382         Platform.executeInUIThread(
   344             {
   383                 new M2GRunnableQt() {
   345                 public void doRun()
   384                     public void doRun() {
   346                 {
   385 								            _renderLCDUI(getHandle(), finalDoc.getHandle(), finalX, finalY,
   347                     _renderLCDUI(getHandle(), finalDoc.getHandle(), finalX, finalY,
   386 								                         finalClipX, finalClipY, finalClipW, finalClipH, finalSvgW, finalSvgH,
   348                                  finalClipX, finalClipY, finalClipW, finalClipH, finalSvgW, finalSvgH,
   387 								                         finalDoc.getRootElement().getCurrentTime());
   349                                  finalDoc.getRootElement().getCurrentTime());
   388 								                       }});
   350                 }
   389 								                       
   351             });
   390 				
   352         }
   391         }
   353 
   392 
   354         else
   393        else 
   355         {
   394         	{
   356             Logger.ELOG(Logger.EJavaUI, "render() - exception: "
   395                 Logger.ELOG(Logger.EJavaUI, "render() - exception: "
   357                         + /*SF*/"Target is not bound"/*SF*/);
   396                 + /*SF*/"Target is not bound"/*SF*/);//TODO for time being commented.s
   358             throw new IllegalStateException(/*SF*/"Target is not bound"/*SF*/);
   397                 throw new IllegalStateException(/*SF*/"Target is not bound"/*SF*/);
   359         }
   398         	}
   360 
   399         	
       
   400     }
   361     }
   401 
   362 
   402     /**
   363     /**
   403      * @see javax.microedition.m2g.ScalableGraphics#setRenderingQuality(int)
   364      * @see javax.microedition.m2g.ScalableGraphics#setRenderingQuality(int)
   404      */
   365      */
   405     public synchronized void setRenderingQuality(int mode)
   366     public synchronized void setRenderingQuality(int mode)
   406     {
   367     {
   407         if ((mode == ScalableGraphics.RENDERING_QUALITY_LOW) ||
   368         if ((mode == ScalableGraphics.RENDERING_QUALITY_LOW) ||
   408                 (mode == ScalableGraphics.RENDERING_QUALITY_HIGH))
   369                 (mode == ScalableGraphics.RENDERING_QUALITY_HIGH))
   409         {
   370         {
   410         	final int finalMode = mode;
   371             final int finalMode = mode;
   411         			    	 // Execute in UI thread     
   372             // Execute in UI thread
   412 			        Platform.executeInUIThread(
   373             Platform.executeInUIThread(
   413 			                new M2GRunnableQt() {
   374                 new M2GRunnableQt()
   414 			                    public void doRun() {
   375             {
   415 											            _setRenderingQuality(getHandle(), finalMode);
   376                 public void doRun()
   416 											          }
   377                 {
   417 											        });
   378                     _setRenderingQuality(getHandle(), finalMode);
       
   379                 }
       
   380             });
   418         }
   381         }
   419         else
   382         else
   420         {
   383         {
   421             Logger.ELOG(Logger.EJavaUI,
   384             Logger.ELOG(Logger.EJavaUI,
   422                         "setRenderingQuality() - exception: " + /*SF*/"The mode is invalid"/*SF*/);
   385                         "setRenderingQuality() - exception: " + /*SF*/"The mode is invalid"/*SF*/);
   429      */
   392      */
   430     public synchronized void setTransparency(float alpha)
   393     public synchronized void setTransparency(float alpha)
   431     {
   394     {
   432         if (alpha >= MIN_TRANSPARENCY_ALPHA && alpha <= MAX_TRANSPARENCY_ALPHA)
   395         if (alpha >= MIN_TRANSPARENCY_ALPHA && alpha <= MAX_TRANSPARENCY_ALPHA)
   433         {
   396         {
   434         	final float finalAlpha = alpha;
   397             final float finalAlpha = alpha;
   435         			    	 // Execute in UI thread     
   398             // Execute in UI thread
   436 			        Platform.executeInUIThread(
   399             Platform.executeInUIThread(
   437 			                new M2GRunnableQt() {
   400                 new M2GRunnableQt()
   438 			                    public void doRun() {
   401             {
   439             															_setTransparency(getHandle(), finalAlpha);
   402                 public void doRun()
   440             														}
   403                 {
   441             													}
   404                     _setTransparency(getHandle(), finalAlpha);
   442             													);
   405                 }
       
   406             }
       
   407             );
   443         }
   408         }
   444         else
   409         else
   445         {
   410         {
   446             Logger.ELOG(Logger.EJavaUI,
   411             Logger.ELOG(Logger.EJavaUI,
   447                         "setTransparency() - exception: " + /*SF*/"The alpha is out of range"/*SF*/);
   412                         "setTransparency() - exception: " + /*SF*/"The alpha is out of range"/*SF*/);
   458     private native int _createRenderContext(
   423     private native int _createRenderContext(
   459         int aSVGProxyHandle);
   424         int aSVGProxyHandle);
   460     private native void _deleteRenderContext(
   425     private native void _deleteRenderContext(
   461         int aRenderContextHandle);
   426         int aRenderContextHandle);
   462     private native int _release(
   427     private native int _release(
   463        int aSurfaceHandle ,int aRenderContextHandle);
   428         int aSurfaceHandle ,int aRenderContextHandle);
   464     private native int _renderLCDUI(
   429     private native int _renderLCDUI(
   465        int aRenderContextHandle, int aDocumentHandle,
   430         int aRenderContextHandle, int aDocumentHandle,
   466         int aX, int aY, int aClipX, int aClipY, int aClipW, int aClipH,
   431         int aX, int aY, int aClipX, int aClipY, int aClipW, int aClipH,
   467         int aSvgW, int aSvgH, float aCurrentTime);
   432         int aSvgW, int aSvgH, float aCurrentTime);
   468     private native int[] _renderESWT(
   433     private native int[] _renderESWT(
   469        int aRenderContextHandle, int aDocumentHandle,
   434         int aRenderContextHandle, int aDocumentHandle,
   470         int aX, int aY, int aClipX, int aClipY, int aClipW, int aClipH,
   435         int aX, int aY, int aClipX, int aClipY, int aClipW, int aClipH,
   471         int aSvgW, int aSvgH, float aCurrentTime, int iUseNativeClear);
   436         int aSvgW, int aSvgH, float aCurrentTime, int iUseNativeClear);
   472     private native void _setRenderingQuality(
   437     private native void _setRenderingQuality(
   473        int aRenderContextHandle, int aMode);
   438         int aRenderContextHandle, int aMode);
   474     private native void _setTransparency(
   439     private native void _setTransparency(
   475        int aRenderContextHandle, float aAlpha);
   440         int aRenderContextHandle, float aAlpha);
   476 }
   441 }