equal
deleted
inserted
replaced
41 private com.nokia.mj.impl.rt.support.Finalizer finalizer; |
41 private com.nokia.mj.impl.rt.support.Finalizer finalizer; |
42 |
42 |
43 // buffer has package visibility so that it can be used as |
43 // buffer has package visibility so that it can be used as |
44 // a lock in other classes |
44 // a lock in other classes |
45 ImageBuffer graphicsBuffer; |
45 ImageBuffer graphicsBuffer; |
|
46 |
|
47 // Graphics for transferring instance |
|
48 // between application and UI thread |
|
49 Graphics tempGraphics; |
46 |
50 |
47 /** |
51 /** |
48 * Constructor. |
52 * Constructor. |
49 */ |
53 */ |
50 Image(org.eclipse.swt.graphics.Image eswtImage, boolean isMutable) |
54 Image(org.eclipse.swt.graphics.Image eswtImage, boolean isMutable) |
645 } |
649 } |
646 return ret; |
650 return ret; |
647 } |
651 } |
648 |
652 |
649 /** |
653 /** |
650 * Synchronizes any pending draw commands to this image |
654 * Synchronizes any pending draw commands to this image. The buffer sync |
651 */ |
655 * must be executed in UI thread and if this method is not requested to switch to |
652 void sync() |
656 * UI thread, the caller must take care of serializing the call over the graphicsBuffer |
653 { |
657 * of this instance. |
654 synchronized(graphicsBuffer) |
658 * |
655 { |
659 * @param switchToUIThread If true the sync is run in UI thread, oherwise |
656 graphicsBuffer.sync(); |
660 * caller must take care of switching to UI thread |
657 } |
661 */ |
|
662 void sync(boolean switchToUIThread) |
|
663 { |
|
664 if(switchToUIThread) |
|
665 { |
|
666 synchronized(graphicsBuffer) |
|
667 { |
|
668 ESWTUIThreadRunner.safeSyncExec(new Runnable() |
|
669 { |
|
670 public void run() |
|
671 { |
|
672 graphicsBuffer.sync(); |
|
673 } |
|
674 }); |
|
675 } |
|
676 } |
|
677 else |
|
678 { |
|
679 graphicsBuffer.sync(); |
|
680 } |
658 } |
681 } |
659 |
682 |
660 /** |
683 /** |
661 * Creates new image from specified RGB array data. |
684 * Creates new image from specified RGB array data. |
662 * |
685 * |
760 MsgRepository.IMAGE_EXCEPTION_INVALID_SCANLENGTH); |
783 MsgRepository.IMAGE_EXCEPTION_INVALID_SCANLENGTH); |
761 } |
784 } |
762 |
785 |
763 synchronized(graphicsBuffer) |
786 synchronized(graphicsBuffer) |
764 { |
787 { |
765 graphicsBuffer.sync(); |
|
766 final int[] localRgbData = rgbData; |
788 final int[] localRgbData = rgbData; |
767 final int localOffset = offset; |
789 final int localOffset = offset; |
768 final int localLength = length; |
790 final int localLength = length; |
769 final int localX = xPos; |
791 final int localX = xPos; |
770 final int localY = yPos; |
792 final int localY = yPos; |
772 final int localH = height; |
794 final int localH = height; |
773 ESWTUIThreadRunner.safeSyncExec(new Runnable() |
795 ESWTUIThreadRunner.safeSyncExec(new Runnable() |
774 { |
796 { |
775 public void run() |
797 public void run() |
776 { |
798 { |
|
799 graphicsBuffer.sync(); |
777 org.eclipse.swt.internal.qt.graphics.Image cgImage = Internal_GfxPackageSupport.getImage(eswtImage); |
800 org.eclipse.swt.internal.qt.graphics.Image cgImage = Internal_GfxPackageSupport.getImage(eswtImage); |
778 cgImage.getRGB(localRgbData, localOffset, localLength, |
801 cgImage.getRGB(localRgbData, localOffset, localLength, |
779 localX, localY, localW, localH); |
802 localX, localY, localW, localH); |
780 } |
803 } |
781 }); |
804 }); |
789 * @throws IllegalStateException if image is immutable. |
812 * @throws IllegalStateException if image is immutable. |
790 */ |
813 */ |
791 public Graphics getGraphics() |
814 public Graphics getGraphics() |
792 { |
815 { |
793 if(mutable) |
816 if(mutable) |
794 { |
817 { |
795 return graphicsBuffer.getGraphics(); |
818 tempGraphics = null; |
|
819 ESWTUIThreadRunner.safeSyncExec(new Runnable() |
|
820 { |
|
821 public void run() |
|
822 { |
|
823 tempGraphics = graphicsBuffer.getGraphics(); |
|
824 } |
|
825 }); |
|
826 return tempGraphics; |
796 } |
827 } |
797 throw new IllegalStateException(MsgRepository.IMAGE_EXCEPTION_IMMUTABLE); |
828 throw new IllegalStateException(MsgRepository.IMAGE_EXCEPTION_IMMUTABLE); |
798 } |
829 } |
799 |
830 |
800 /** |
831 /** |