=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2016-04-21 17:01:43 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2016-04-22 19:47:01 +0000 @@ -49,6 +49,7 @@ ** into the converted code (i.e. invoke external programs, procedures or ** functions). Can be used only when the P2J client runs embedded in a ** customer-specific application. +** SBI 20160422 The resize drawing operations must not be cached. */ package com.goldencode.p2j.ui.client.gui.driver.web; @@ -87,6 +88,9 @@ /** The maximum cache size. */ private static final int MAX_DRAW_CACHE_SIZE = 1000; + /** The magic hash sum indicates that the batch of drawing operations mustn't be cached. */ + private static byte[] MAGIC = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + /** The provider for MD5 hashes. */ private MessageDigest MD5 = null; @@ -109,6 +113,9 @@ /** Accumulator to track the total number of pending bytes on the drawing ops list. */ private int pendingBytes = 0; + /** Pending resize operations counter */ + private int resizeOps = 0; + /** * Accumulator to track the total number of pending bytes on the drawing ops list, including * the operations which were replaced with a hash code (as the resulted image is already @@ -606,6 +613,8 @@ public void resizeWindow(int width, int height) { allocateAndSend(PaintPrimitives.RESIZE_WINDOW, width, height); + + resizeOps++; } /** @@ -619,6 +628,8 @@ public void setWindowLocation(int x, int y) { allocateAndSend(PaintPrimitives.SET_LOCATION, x, y); + + resizeOps++; } /** @@ -636,6 +647,8 @@ public void setWindowBounds(int x, int y, int width, int height) { allocateAndSend(PaintPrimitives.SET_WINDOW_BOUNDS, x, y, width, height); + + resizeOps++; } /** @@ -1035,7 +1048,11 @@ pendingNoCacheBytes)); if (drawHash != null) { - if (Arrays.equals(drawHash, lastHash)) + if (resizeOps > 0) + { + System.arraycopy(MAGIC, 0, total, 1, HASH_LENGTH); + } + else if (Arrays.equals(drawHash, lastHash)) { // do not send if duplicated message doSend = false; @@ -1071,7 +1088,7 @@ } lastHash = drawHash; } - + if (doSend) { // send it to the javascript side @@ -1083,6 +1100,7 @@ pendingBytes = 0; drawingNoCacheOps.clear(); pendingNoCacheBytes = 0; + resizeOps = 0; } /** === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2016-04-20 19:06:19 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2016-04-22 16:44:54 +0000 @@ -46,6 +46,7 @@ ** fixed TypedArray.slice is unsupported by IE. ** 011 HC 20160406 Overhaul of window-activation logic. ** 012 SBI 20160414 Fixed doWindowActivationChange(...) and activateTopVisibleWindow(...). +** SBI 20160422 The resize drawing operations must not be cached. */ "use strict"; @@ -422,6 +423,9 @@ this.drawCache = {}; + /** Indicates that drawing operations can be cached */ + this.canBeCached = true; + /** The off screen canvas to be used to make batch drawing. */ this.offscreenCanvas = document.createElement('canvas'); this.offscreenContext = this.offscreenCanvas.getContext('2d', {alpha : true}); @@ -1734,7 +1738,7 @@ { this.ctx.drawImage(this.offscreenCanvas, 0, 0); // if this is the end of a drawing bracket (clip and translate are zero), save the canvas - if (this.clips == 0 && this.trans == 0) + if (this.clips == 0 && this.trans == 0 && this.canBeCached) { // save the offscreen canvas var img = new Image(); @@ -1744,6 +1748,7 @@ // clear the offscreen canvas for next drawing this.canvasRenderer.clear(); } + } p2j.logger.log("END DRAWING CYCLE FOR WINDOW " + this.id); @@ -3164,7 +3169,24 @@ var oldMouse = win.processMouse; win.processMouse = false; - if (win.hasCachedDraw(md5)) + // if hash sum are filled with zeros, then don't cache drawing operations + var magic = true; + for (var i = 0; i < 16; i++) + { + if (md5a[i] != 0) + { + magic = false; + break; + } + } + + if (magic) + { + win.canBeCached = false; + win.draw(message, md5); + win.canBeCached = true; + } + else if (win.hasCachedDraw(md5)) { var cachedDraw = win.getCachedDraw(md5); @@ -3181,7 +3203,7 @@ win.processMouse = oldMouse; }; - + /** * The method performs a layout operation on the supplied text and returns the resulting * paragraph height while maintaining the supplied maximum width.