--- a/javauis/lcdui_akn/javalcdui/javasrc/javax/microedition/lcdui/Canvas.java Thu Jul 15 18:31:06 2010 +0300
+++ b/javauis/lcdui_akn/javalcdui/javasrc/javax/microedition/lcdui/Canvas.java Thu Aug 19 09:48:13 2010 +0300
@@ -95,6 +95,7 @@
*/
private boolean iHasBackgroundImage;
private boolean iIsGameCanvas;
+ private Object iPaintLock;
protected Canvas()
{
@@ -140,6 +141,7 @@
}
iM3GContent = false;
+ iPaintLock = new Object();
}
}
@@ -281,7 +283,7 @@
public final void serviceRepaints()
{
- paint();
+ paint(false);
}
// Canvas spec'd to have getWidth() method override.
@@ -355,7 +357,7 @@
protected abstract void paint(Graphics aGraphics);
- private void handlePaint(int aX, int aY, int aWidth, int aHeight)
+ private void handlePaint(int aX, int aY, int aWidth, int aHeight, boolean forced)
{
synchronized (iToolkit)
{
@@ -386,10 +388,10 @@
}
}
- paint();
+ paint(forced);
}
- private void paint()
+ private void paint(boolean forced)
{
Graphics graphics;
int x;
@@ -397,55 +399,58 @@
int w;
int h;
- synchronized (iCallbackLock)
+ synchronized (iPaintLock)
{
- final int width;
- final int height;
-
- //
- // Synchronize to protect the update region from concurrent
- // repaint()'s. Note that this is *not* sufficient to ensure
- // that no other callbacks are called by the event thread
- // whilst the current thread is in the repaint routine, for
- // that we use the callbacklock below.
- //
- synchronized (iToolkit)
+ synchronized (iCallbackLock)
{
- width = iWidth;
- height = iHeight;
+ final int width;
+ final int height;
- x = iRepaintX1;
- y = iRepaintY1;
- w = iRepaintX2-iRepaintX1;
- h = iRepaintY2-iRepaintY1;
+ //
+ // Synchronize to protect the update region from concurrent
+ // repaint()'s. Note that this is *not* sufficient to ensure
+ // that no other callbacks are called by the event thread
+ // whilst the current thread is in the repaint routine, for
+ // that we use the callbacklock below.
+ //
+ synchronized (iToolkit)
+ {
+ width = iWidth;
+ height = iHeight;
- iRepaintX1 = 0;
- iRepaintY1 = 0;
- iRepaintX2 = 0;
- iRepaintY2 = 0;
+ x = iRepaintX1;
+ y = iRepaintY1;
+ w = iRepaintX2-iRepaintX1;
+ h = iRepaintY2-iRepaintY1;
- if (!((w>0) && (h>0) && IsShown()))
- {
- return;
+ iRepaintX1 = 0;
+ iRepaintY1 = 0;
+ iRepaintX2 = 0;
+ iRepaintY2 = 0;
+
+ if (!((w>0) && (h>0) && (IsShown() || forced)))
+ {
+ return;
+ }
+
+ graphics = GetPaintGraphics();
}
- graphics = GetPaintGraphics();
+ graphics.reset(width, height);
+ graphics.setClip(x, y, w, h);
+
+ // On a non-full-screen (normal) mode Canvas the background
+ // image must be initially shown, if the value of the iHasBackgroundImage
+ // is true.
+ if (!iFullScreen && iHasBackgroundImage && !iIsGameCanvas)
+ {
+ drawBackground(true);
+ }
+ paint(graphics);
}
- graphics.reset(width, height);
- graphics.setClip(x, y, w, h);
-
- // On a non-full-screen (normal) mode Canvas the background
- // image must be initially shown, if the value of the iHasBackgroundImage
- // is true.
- if (!iFullScreen && iHasBackgroundImage && !iIsGameCanvas)
- {
- drawBackground(true);
- }
- paint(graphics);
+ flush(x, y, w, h);
}
-
- flush(x, y, w, h);
}
void flush(int aX, int aY, int aWidth, int aHeight)
@@ -569,12 +574,14 @@
switch (aEvent)
{
case Toolkit.EVENT_PAINT:
+ case Toolkit.EVENT_FORCED_PAINT:
{
final int x = aData0 >>> 16;
final int y = aData0 & 0xffff;
final int w = aData1 >>> 16;
final int h = aData1 & 0xffff;
- handlePaint(x, y, w, h);
+ boolean forced = (aEvent == Toolkit.EVENT_FORCED_PAINT);
+ handlePaint(x, y, w, h, forced);
}
break;