1
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java'
|
2
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2016-04-21 17:01:43 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2016-04-22 16:40:02 +0000
|
4
|
@@ -49,6 +49,7 @@
|
5
|
** into the converted code (i.e. invoke external programs, procedures or
|
6
|
** functions). Can be used only when the P2J client runs embedded in a
|
7
|
** customer-specific application.
|
8
|
+** SBI 20160422 The resize drawing operations must not be cached.
|
9
|
*/
|
10
|
|
11
|
package com.goldencode.p2j.ui.client.gui.driver.web;
|
12
|
@@ -109,6 +110,12 @@
|
13
|
/** Accumulator to track the total number of pending bytes on the drawing ops list. */
|
14
|
private int pendingBytes = 0;
|
15
|
|
16
|
+ /** Pending resize operations must not be cached */
|
17
|
+ private List<byte[]> resizeOps = new ArrayList<byte[]>();
|
18
|
+
|
19
|
+ /** Pending resize operations in bytes */
|
20
|
+ private int resizeOpsBytes = 0;
|
21
|
+
|
22
|
/**
|
23
|
* Accumulator to track the total number of pending bytes on the drawing ops list, including
|
24
|
* the operations which were replaced with a hash code (as the resulted image is already
|
25
|
@@ -606,6 +613,15 @@
|
26
|
public void resizeWindow(int width, int height)
|
27
|
{
|
28
|
allocateAndSend(PaintPrimitives.RESIZE_WINDOW, width, height);
|
29
|
+
|
30
|
+ byte[] message = new byte[9];
|
31
|
+ message[0] = (byte) PaintPrimitives.RESIZE_WINDOW.ordinal();
|
32
|
+
|
33
|
+ writeMessageInt32(message, 1, width);
|
34
|
+ writeMessageInt32(message, 5, height);
|
35
|
+
|
36
|
+ resizeOps.add(message);
|
37
|
+ resizeOpsBytes += message.length;
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
@@ -636,6 +652,17 @@
|
42
|
public void setWindowBounds(int x, int y, int width, int height)
|
43
|
{
|
44
|
allocateAndSend(PaintPrimitives.SET_WINDOW_BOUNDS, x, y, width, height);
|
45
|
+
|
46
|
+ byte[] message = new byte[17];
|
47
|
+ message[0] = (byte) PaintPrimitives.SET_WINDOW_BOUNDS.ordinal();
|
48
|
+
|
49
|
+ writeMessageInt32(message, 1, x);
|
50
|
+ writeMessageInt32(message, 5, y);
|
51
|
+ writeMessageInt32(message, 9, width);
|
52
|
+ writeMessageInt32(message, 13, height);
|
53
|
+
|
54
|
+ resizeOps.add(message);
|
55
|
+ resizeOpsBytes += message.length;
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
@@ -1071,7 +1098,18 @@
|
60
|
}
|
61
|
lastHash = drawHash;
|
62
|
}
|
63
|
-
|
64
|
+
|
65
|
+ if (!resizeOps.isEmpty())
|
66
|
+ {
|
67
|
+ byte[] resize = buildDrawingMessage(windowId, resizeOps, resizeOpsBytes);
|
68
|
+ // the magic value indicates that resize operations must not be cached
|
69
|
+ byte[] magic = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
70
|
+ System.arraycopy(magic, 0, resize, 1, HASH_LENGTH);
|
71
|
+ sendBinaryMessage(resize);
|
72
|
+ resizeOps.clear();
|
73
|
+ resizeOpsBytes = 0;
|
74
|
+ }
|
75
|
+
|
76
|
if (doSend)
|
77
|
{
|
78
|
// send it to the javascript side
|
79
|
|
80
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
|
81
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2016-04-20 19:06:19 +0000
|
82
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2016-04-22 16:37:18 +0000
|
83
|
@@ -46,6 +46,7 @@
|
84
|
** fixed TypedArray.slice is unsupported by IE.
|
85
|
** 011 HC 20160406 Overhaul of window-activation logic.
|
86
|
** 012 SBI 20160414 Fixed doWindowActivationChange(...) and activateTopVisibleWindow(...).
|
87
|
+** SBI 20160422 The resize drawing operations must not be cached.
|
88
|
*/
|
89
|
|
90
|
"use strict";
|
91
|
@@ -422,6 +423,9 @@
|
92
|
|
93
|
this.drawCache = {};
|
94
|
|
95
|
+ /** Indicates that drawing operations can be cached */
|
96
|
+ this.canBeCached = true;
|
97
|
+
|
98
|
/** The off screen canvas to be used to make batch drawing. */
|
99
|
this.offscreenCanvas = document.createElement('canvas');
|
100
|
this.offscreenContext = this.offscreenCanvas.getContext('2d', {alpha : true});
|
101
|
@@ -1734,7 +1738,7 @@
|
102
|
{
|
103
|
this.ctx.drawImage(this.offscreenCanvas, 0, 0);
|
104
|
// if this is the end of a drawing bracket (clip and translate are zero), save the canvas
|
105
|
- if (this.clips == 0 && this.trans == 0)
|
106
|
+ if (this.clips == 0 && this.trans == 0 && this.canBeCached)
|
107
|
{
|
108
|
// save the offscreen canvas
|
109
|
var img = new Image();
|
110
|
@@ -1744,6 +1748,7 @@
|
111
|
// clear the offscreen canvas for next drawing
|
112
|
this.canvasRenderer.clear();
|
113
|
}
|
114
|
+
|
115
|
}
|
116
|
|
117
|
p2j.logger.log("END DRAWING CYCLE FOR WINDOW " + this.id);
|
118
|
@@ -3164,7 +3169,24 @@
|
119
|
var oldMouse = win.processMouse;
|
120
|
win.processMouse = false;
|
121
|
|
122
|
- if (win.hasCachedDraw(md5))
|
123
|
+ // if hash sum are filled with zeros, then don't cache drawing operations
|
124
|
+ var magic = true;
|
125
|
+ for (var i = 0; i < 16; i++)
|
126
|
+ {
|
127
|
+ if (md5a[i] != 0)
|
128
|
+ {
|
129
|
+ magic = false;
|
130
|
+ break;
|
131
|
+ }
|
132
|
+ }
|
133
|
+
|
134
|
+ if (magic)
|
135
|
+ {
|
136
|
+ win.canBeCached = false;
|
137
|
+ win.draw(message, md5);
|
138
|
+ win.canBeCached = true;
|
139
|
+ }
|
140
|
+ else if (win.hasCachedDraw(md5))
|
141
|
{
|
142
|
var cachedDraw = win.getCachedDraw(md5);
|
143
|
|
144
|
@@ -3181,7 +3203,7 @@
|
145
|
|
146
|
win.processMouse = oldMouse;
|
147
|
};
|
148
|
-
|
149
|
+
|
150
|
/**
|
151
|
* The method performs a layout operation on the supplied text and returns the resulting
|
152
|
* paragraph height while maintaining the supplied maximum width.
|
153
|
|