javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItem.java
changeset 35 85266cc22c7f
parent 26 dc7c549001d5
child 47 f40128debb5d
child 57 59b3b4473dc8
equal deleted inserted replaced
26:dc7c549001d5 35:85266cc22c7f
    65     private boolean widgetDisposed;
    65     private boolean widgetDisposed;
    66 
    66 
    67     private com.nokia.mj.impl.rt.support.Finalizer finalizer;
    67     private com.nokia.mj.impl.rt.support.Finalizer finalizer;
    68 
    68 
    69     // Graphics command buffer for this instance
    69     // Graphics command buffer for this instance
    70     CustomItemBuffer graphicsBuffer;
    70     Buffer graphicsBuffer;
    71     Graphics CustomItemGraphics;
    71     Graphics CustomItemGraphics;
    72 
    72 
    73     CustomItemLayouter layouter;
    73     CustomItemLayouter layouter;
    74 
    74 
    75 
    75 
   550                     widgetDisposed = true;
   550                     widgetDisposed = true;
   551                     return;
   551                     return;
   552                 }
   552                 }
   553                 if(CustomItemGraphics == null)
   553                 if(CustomItemGraphics == null)
   554                 {
   554                 {
   555                     graphicsBuffer = new CustomItemBuffer(self, (Control)event.widget);
   555                     graphicsBuffer = Buffer.createInstance(self, (Control)event.widget);
   556                     CustomItemGraphics = graphicsBuffer.getGraphics();
   556                     CustomItemGraphics = graphicsBuffer.getGraphics();
       
   557                     CustomItemGraphics.setSyncStrategy(Graphics.SYNC_LEAVE_SURFACE_SESSION_OPEN);
   557                 }
   558                 }
   558                 else
   559                 else
   559                 {
   560                 {
   560                     graphicsBuffer.setControlBounds((Control)event.widget);
   561                     graphicsBuffer.setControlBounds((Control)event.widget);
   561                 }
   562                 }
   602             {
   603             {
   603                 if(event.widget.isDisposed())
   604                 if(event.widget.isDisposed())
   604                 {
   605                 {
   605                     return;
   606                     return;
   606                 }
   607                 }
   607                 // Transform invalid area to Display coordinates
       
   608                 // as the CustomItem is rendered directly to the
       
   609                 // window surface
       
   610                 Point topleft = ((Control)event.widget).toDisplay(redrawNowX, redrawNowY);
       
   611 
       
   612                 synchronized(graphicsBuffer)
       
   613                 {
       
   614                     flushGraphicsBuffer(topleft.x, topleft.y, redrawNowW, redrawNowH);
       
   615                 }
       
   616             }
       
   617         });
       
   618     }
       
   619 
       
   620     private void flushGraphicsBuffer(final int redrawNowX, final int redrawNowY, final int redrawNowW, final int redrawNowH)
       
   621     {
       
   622         ESWTUIThreadRunner.safeSyncExec(new Runnable()
       
   623         {
       
   624             public void run()
       
   625             {
       
   626                 graphicsBuffer.setupWindowSurface();
       
   627                 Rectangle rect = graphicsBuffer.toWindowCoordinates(redrawNowX, redrawNowY, redrawNowW, redrawNowH);
       
   628                 graphicsBuffer.windowSurface.beginPaint(rect.x, rect.y, rect.width, rect.height);
       
   629                 graphicsBuffer.sync();
   608                 graphicsBuffer.sync();
   630                 graphicsBuffer.windowSurface.endPaint();
   609                 graphicsBuffer.blitToDisplay(null, event.widget);
   631                 graphicsBuffer.windowSurface.flush();
       
   632             }
   610             }
   633         });
   611         });
   634     }
   612     }
   635 
   613 
   636     /**
   614     /**