Project

General

Profile

3069_3.txt

Sergey Ivanovskiy, 04/22/2016 03:54 PM

Download (5.21 KB)

 
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 19:47:01 +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
@@ -87,6 +88,9 @@
13
    /** The maximum cache size. */
14
    private static final int MAX_DRAW_CACHE_SIZE = 1000;
15
 
16
+   /** The magic hash sum indicates that the batch of drawing operations mustn't be cached. */
17
+   private static byte[] MAGIC = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
18
+
19
    /** The provider for MD5 hashes. */
20
    private MessageDigest MD5 = null; 
21
    
22
@@ -109,6 +113,9 @@
23
    /** Accumulator to track the total number of pending bytes on the drawing ops list. */
24
    private int pendingBytes = 0;
25
    
26
+   /** Pending resize operations counter */
27
+   private int resizeOps = 0;
28
+
29
    /**
30
     * Accumulator to track the total number of pending bytes on the drawing ops list, including  
31
     * the operations which were replaced with a hash code (as the resulted image is already 
32
@@ -606,6 +613,8 @@
33
    public void resizeWindow(int width, int height)
34
    {
35
       allocateAndSend(PaintPrimitives.RESIZE_WINDOW, width, height);
36
+      
37
+      resizeOps++;
38
    }
39
    
40
    /**
41
@@ -619,6 +628,8 @@
42
    public void setWindowLocation(int x, int y)
43
    {
44
       allocateAndSend(PaintPrimitives.SET_LOCATION, x, y);
45
+      
46
+      resizeOps++;
47
    }
48
    
49
    /**
50
@@ -636,6 +647,8 @@
51
    public void setWindowBounds(int x, int y, int width, int height)
52
    {
53
       allocateAndSend(PaintPrimitives.SET_WINDOW_BOUNDS, x, y, width, height);
54
+      
55
+      resizeOps++;
56
    }
57
    
58
    /**
59
@@ -1035,7 +1048,11 @@
60
                                                     pendingNoCacheBytes));
61
       if (drawHash != null)
62
       {
63
-         if (Arrays.equals(drawHash, lastHash))
64
+         if (resizeOps > 0)
65
+         {
66
+            System.arraycopy(MAGIC, 0, total, 1, HASH_LENGTH);
67
+         }
68
+         else if (Arrays.equals(drawHash, lastHash))
69
          {
70
             // do not send if duplicated message
71
             doSend = false;
72
@@ -1071,7 +1088,7 @@
73
          }
74
          lastHash = drawHash;
75
       }
76
-      
77
+
78
       if (doSend)
79
       {
80
          // send it to the javascript side
81
@@ -1083,6 +1100,7 @@
82
       pendingBytes = 0;
83
       drawingNoCacheOps.clear();
84
       pendingNoCacheBytes = 0;
85
+      resizeOps = 0;
86
    }
87
    
88
    /**
89

    
90
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
91
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-04-20 19:06:19 +0000
92
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-04-22 16:44:54 +0000
93
@@ -46,6 +46,7 @@
94
 **                  fixed TypedArray.slice is unsupported by IE. 
95
 ** 011 HC  20160406 Overhaul of window-activation logic.
96
 ** 012 SBI 20160414 Fixed  doWindowActivationChange(...) and activateTopVisibleWindow(...).
97
+**     SBI 20160422 The resize drawing operations must not be cached.
98
 */
99
 
100
 "use strict";
101
@@ -422,6 +423,9 @@
102
 
103
       this.drawCache = {};
104
 
105
+      /** Indicates that drawing operations can be cached */
106
+      this.canBeCached = true;
107
+
108
       /** The off screen canvas to be used to make batch drawing. */
109
       this.offscreenCanvas = document.createElement('canvas');
110
       this.offscreenContext = this.offscreenCanvas.getContext('2d', {alpha : true});
111
@@ -1734,7 +1738,7 @@
112
       {
113
          this.ctx.drawImage(this.offscreenCanvas, 0, 0);
114
          // if this is the end of a drawing bracket (clip and translate are zero), save the canvas
115
-         if (this.clips == 0 && this.trans == 0)
116
+         if (this.clips == 0 && this.trans == 0 && this.canBeCached)
117
          {
118
             // save the offscreen canvas
119
             var img = new Image();
120
@@ -1744,6 +1748,7 @@
121
             // clear the offscreen canvas for next drawing
122
             this.canvasRenderer.clear();
123
          }
124
+         
125
       }
126
       
127
       p2j.logger.log("END DRAWING CYCLE FOR WINDOW " + this.id);
128
@@ -3164,7 +3169,24 @@
129
       var oldMouse = win.processMouse;
130
       win.processMouse = false;
131
 
132
-      if (win.hasCachedDraw(md5))
133
+      // if hash sum are filled with zeros, then don't cache drawing operations
134
+      var magic = true;
135
+      for (var i = 0; i < 16; i++)
136
+      {
137
+         if (md5a[i] != 0)
138
+         {
139
+            magic = false;
140
+            break;
141
+         }
142
+      }
143
+
144
+      if (magic)
145
+      {
146
+         win.canBeCached = false;
147
+         win.draw(message, md5);
148
+         win.canBeCached = true;
149
+      }
150
+      else if (win.hasCachedDraw(md5))
151
       {
152
          var cachedDraw = win.getCachedDraw(md5);
153
          
154
@@ -3181,7 +3203,7 @@
155
       
156
       win.processMouse = oldMouse;
157
    };
158
-
159
+   
160
    /**
161
     * The method performs a layout operation on the supplied text and returns the resulting 
162
     * paragraph height while maintaining the supplied maximum width.
163