=== 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 16:40:02 +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; @@ -109,6 +110,12 @@ /** Accumulator to track the total number of pending bytes on the drawing ops list. */ private int pendingBytes = 0; + /** Pending resize operations must not be cached */ + private List resizeOps = new ArrayList(); + + /** Pending resize operations in bytes */ + private int resizeOpsBytes = 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,15 @@ public void resizeWindow(int width, int height) { allocateAndSend(PaintPrimitives.RESIZE_WINDOW, width, height); + + byte[] message = new byte[9]; + message[0] = (byte) PaintPrimitives.RESIZE_WINDOW.ordinal(); + + writeMessageInt32(message, 1, width); + writeMessageInt32(message, 5, height); + + resizeOps.add(message); + resizeOpsBytes += message.length; } /** @@ -636,6 +652,17 @@ public void setWindowBounds(int x, int y, int width, int height) { allocateAndSend(PaintPrimitives.SET_WINDOW_BOUNDS, x, y, width, height); + + byte[] message = new byte[17]; + message[0] = (byte) PaintPrimitives.SET_WINDOW_BOUNDS.ordinal(); + + writeMessageInt32(message, 1, x); + writeMessageInt32(message, 5, y); + writeMessageInt32(message, 9, width); + writeMessageInt32(message, 13, height); + + resizeOps.add(message); + resizeOpsBytes += message.length; } /** @@ -1071,7 +1098,18 @@ } lastHash = drawHash; } - + + if (!resizeOps.isEmpty()) + { + byte[] resize = buildDrawingMessage(windowId, resizeOps, resizeOpsBytes); + // the magic value indicates that resize operations must not be cached + byte[] magic = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + System.arraycopy(magic, 0, resize, 1, HASH_LENGTH); + sendBinaryMessage(resize); + resizeOps.clear(); + resizeOpsBytes = 0; + } + if (doSend) { // send it to the javascript side === 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:37:18 +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.