Project

General

Profile

disablePixelManipulation.patch

Sergey Ivanovskiy, 10/12/2020 05:20 PM

Download (6.81 KB)

View differences:

src/com/goldencode/p2j/main/WebClientBuilder.java 2020-10-12 17:53:07 +0000
136 136
         command.add("client:gui:desktopWidth=" + options.get("desktopWidth"));
137 137
         command.add("client:gui:taskbar=" + options.get("taskbar"));
138 138
         command.add("client:gui:graphicsCached=" + options.get("graphicsCached"));
139
         command.add("client:gui:disablePixelManipulation=" + options.get("disablePixelManipulation"));
139 140
      }
140 141
      else
141 142
      {
......
171 172
         // do not send this parameter on remote spawn, let the remote web server select the IP
172 173
         if (!remote)
173 174
         {
174
            command.add("client:web:host=" + options.get("host"));            
175
            command.add("client:web:host=" + options.get("host"));
175 176
         }
176 177
      }
177 178
      
src/com/goldencode/p2j/main/WebClientBuilderOptions.java 2020-10-12 17:53:07 +0000
280 280
      options.put("embedded", embedded ? "true" : "false");
281 281
      // sets true if the web client uses a buffer to cache drawings, otherwise false.
282 282
      options.put("graphicsCached", graphicsCached ? "true" : "false");
283
      // Read webClient/disablePixelManipulation value 
284
      boolean disablePixelManipulation = cbo.getNode(DIRECTORY_NODE_ID, "disablePixelManipulation", false);
285
      options.put("disablePixelManipulation", disablePixelManipulation ? "true" : "false");
283 286
      
284 287
      // in trusted mode, we must authenticate by using the NativeSecureConnection
285 288
      // to access the P2J server and get our temporary account; this requires some
src/com/goldencode/p2j/ui/client/driver/web/index.html 2020-10-12 17:53:07 +0000
166 166
               'container' : 'cont',
167 167
               'embedded'  : ${embedded},
168 168
               'graphicsCached' : ${graphicsCached},
169
               'disablePixelManipulation' : ${disablePixelManipulation},
169 170
               'webRoot'   : '${webRoot}'
170 171
            });
171 172
         });
src/com/goldencode/p2j/ui/client/driver/web/res/p2j.js 2020-10-12 20:13:16 +0000
343 343
               queryCommandSupported[cmd] = false;
344 344
            }
345 345
         });
346
      
346 347
      Object.defineProperty(
347 348
         p2j,
348 349
         "commandSupported",
......
366 367
               }
367 368
            });
368 369
      
370
      Object.defineProperty(
371
            p2j,
372
            "disablePixelManipulation",
373
            {
374
               get: function ()
375
               {
376
                  return cfg.disablePixelManipulation;
377
               }
378
            });
379
      
369 380
      /** Set up callback to store the client IP. */
370 381
      getUserIP(setIP);
371 382
      
......
1108 1119
       *  Canvas created with document.createElement is very slow in Chrome, use OffscreenCanvas instead.
1109 1120
       *  Chrome version 79 is known to have drawing issues with OffscreenCanvas, see #4473.
1110 1121
       */
1111
      if (p2j.isChrome && typeof OffscreenCanvas != "undefined" && p2j.chromeVersion.major != 79)
1122
      if (p2j.isChrome && typeof OffscreenCanvas != "undefined" && p2j.chromeVersion.major != 79 &&
1123
            !p2j.disablePixelManipulation)
1112 1124
      {
1113 1125
         return new OffscreenCanvas(1, 1);
1114 1126
      }
src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebPageHandler.java 2020-10-12 17:53:07 +0000
191 191
            boolean graphicsCached = config.getBoolean("client", "gui", "graphicsCached", true);
192 192
            return graphicsCached ? "true" : "false";
193 193
         });
194
         
195
         add("disablePixelManipulation", () ->
196
         {
197
            boolean disablePixelManipulation = config.getBoolean("client", "gui", "disablePixelManipulation", true);
198
            return disablePixelManipulation ? "true" : "false";
199
         });
194 200
      }
195 201
   }
196 202
}
src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js 2020-10-12 21:02:55 +0000
951 951
      var dx = x2 - x1;
952 952
      var dy = y2 - y1;
953 953

  
954
      // vertical and horizontal lines are handled by the current stroke renderer (optimization)
955
      // if dx == 0, then a line (x1, y1, x2, y2) is a vertical
956
      // if dy == 0, then a line (x1, y1, x2, y2) is a horizontal
957
      if (dx === 0 || dy === 0)
954
      if (p2j.disablePixelManipulation)
958 955
      {
959
         // to draw a line as an image for the default stroke and widen stroke styles
960
         // we have x2 >= x1 and y2 >= y1 and dx or dy equals zero.
961
         strokeRenderer.strokeLine(x1, y1, x2, y2);//optimization
956
         this.offscreenCtx.beginPath();
957
         this.offscreenCtx.moveTo(x1 - this.origin.x, y1 - this.origin.y);
958
         this.offscreenCtx.lineTo(x2 - this.origin.x, y2 - this.origin.y);
959
         this.offscreenCtx.stroke();
962 960
      }
963 961
      else
964 962
      {
965
         this.drawSlopedLineSegment(x1, y1, x2, y2, strokeRenderer);
963
         // vertical and horizontal lines are handled by the current stroke renderer (optimization)
964
         // if dx == 0, then a line (x1, y1, x2, y2) is a vertical
965
         // if dy == 0, then a line (x1, y1, x2, y2) is a horizontal
966
         if (dx === 0 || dy === 0)
967
         {
968
            // to draw a line as an image for the default stroke and widen stroke styles
969
            // we have x2 >= x1 and y2 >= y1 and dx or dy equals zero.
970
            strokeRenderer.strokeLine(x1, y1, x2, y2);//optimization
971
         }
972
         else
973
         {
974
            this.drawSlopedLineSegment(x1, y1, x2, y2, strokeRenderer);
975
         }
966 976
      }
967 977
   }
968 978
};
......
1585 1595
CanvasRenderer.prototype.drawPolygon = function(xPoints, yPoints, num, color, fill)
1586 1596
{
1587 1597
   var i;
1588

  
1598
   
1589 1599
   // use vector operations for the interior of the polygon
1590 1600
   if (fill)
1591 1601
   {
......
1598 1608
      this.offscreenCtx.closePath();
1599 1609
      this.renderClosedPath(fill);
1600 1610
   }
1611
   
1601 1612
   var renderer = this.strokesManager.getStrokePathRenderer(this, this.strokeStyleId,
1602 1613
         this.strokeWidth, color);
1603 1614
   renderer.beginStroke();