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-22 16:44:54 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2016-04-22 19:22:27 +0000
|
4
|
@@ -57,6 +57,7 @@
|
5
|
import java.io.*;
|
6
|
import java.security.*;
|
7
|
import java.util.*;
|
8
|
+import java.util.concurrent.atomic.AtomicInteger;
|
9
|
|
10
|
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
11
|
|
12
|
@@ -110,11 +111,8 @@
|
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
|
+ /** Pending resize operations counter */
|
22
|
+ private AtomicInteger resizeOps = new AtomicInteger(0);
|
23
|
|
24
|
/**
|
25
|
* Accumulator to track the total number of pending bytes on the drawing ops list, including
|
26
|
@@ -614,14 +612,7 @@
|
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
|
+ resizeOps.incrementAndGet();
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
@@ -635,6 +626,8 @@
|
43
|
public void setWindowLocation(int x, int y)
|
44
|
{
|
45
|
allocateAndSend(PaintPrimitives.SET_LOCATION, x, y);
|
46
|
+
|
47
|
+ resizeOps.incrementAndGet();
|
48
|
}
|
49
|
|
50
|
/**
|
51
|
@@ -653,16 +646,7 @@
|
52
|
{
|
53
|
allocateAndSend(PaintPrimitives.SET_WINDOW_BOUNDS, x, y, width, height);
|
54
|
|
55
|
- byte[] message = new byte[17];
|
56
|
- message[0] = (byte) PaintPrimitives.SET_WINDOW_BOUNDS.ordinal();
|
57
|
-
|
58
|
- writeMessageInt32(message, 1, x);
|
59
|
- writeMessageInt32(message, 5, y);
|
60
|
- writeMessageInt32(message, 9, width);
|
61
|
- writeMessageInt32(message, 13, height);
|
62
|
-
|
63
|
- resizeOps.add(message);
|
64
|
- resizeOpsBytes += message.length;
|
65
|
+ resizeOps.incrementAndGet();
|
66
|
}
|
67
|
|
68
|
/**
|
69
|
@@ -1062,7 +1046,12 @@
|
70
|
pendingNoCacheBytes));
|
71
|
if (drawHash != null)
|
72
|
{
|
73
|
- if (Arrays.equals(drawHash, lastHash))
|
74
|
+ if (resizeOps.getAndSet(0) > 0)
|
75
|
+ {
|
76
|
+ byte[] magic = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
77
|
+ System.arraycopy(magic, 0, total, 1, HASH_LENGTH);
|
78
|
+ }
|
79
|
+ else if (Arrays.equals(drawHash, lastHash))
|
80
|
{
|
81
|
// do not send if duplicated message
|
82
|
doSend = false;
|
83
|
@@ -1099,17 +1088,6 @@
|
84
|
lastHash = drawHash;
|
85
|
}
|
86
|
|
87
|
- if (!resizeOps.isEmpty())
|
88
|
- {
|
89
|
- byte[] resize = buildDrawingMessage(windowId, resizeOps, resizeOpsBytes);
|
90
|
- // the magic value indicates that resize operations must not be cached
|
91
|
- byte[] magic = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
92
|
- System.arraycopy(magic, 0, resize, 1, HASH_LENGTH);
|
93
|
- sendBinaryMessage(resize);
|
94
|
- resizeOps.clear();
|
95
|
- resizeOpsBytes = 0;
|
96
|
- }
|
97
|
-
|
98
|
if (doSend)
|
99
|
{
|
100
|
// send it to the javascript side
|
101
|
|