ol 10.7.1-dev.1764736468522 → 10.7.1-dev.1764759764381
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/package.json +1 -1
- package/render/canvas/ExecutorGroup.d.ts.map +1 -1
- package/render/canvas/ExecutorGroup.js +41 -5
- package/util.js +1 -1
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExecutorGroup.d.ts","sourceRoot":"","sources":["ExecutorGroup.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExecutorGroup.d.ts","sourceRoot":"","sources":["ExecutorGroup.js"],"names":[],"mappings":"AAqfA;;;;;;GAMG;AACH,2CAHW,MAAM,GACL,KAAK,CAAC,MAAM,CAAC,CA2CxB;AAthBD;;;GAGG;AACH,kBAFU,KAAK,CAAC,OAAO,cAAc,EAAE,WAAW,CAAC,CASjD;AAEF;;;GAGG;AACH,wBAFU,KAAK,CAAC,OAAO,cAAc,EAAE,WAAW,CAAC,CAER;AAE3C;;;GAGG;AACH,4BAFU,KAAK,CAAC,OAAO,cAAc,EAAE,WAAW,CAAC,CAIjD;;AAqCF;IACE;;;;;;;;;;;;OAYG;IACH,uBAZW,OAAO,iBAAiB,EAAE,MAAM,cAIhC,MAAM,cACN,MAAM,YACN,OAAO,mBACP;YAAQ,MAAM,GAAE,GAA4F;KAAC,iBAE7G,MAAM,sBACN,OAAO,EAwEjB;IA7DC;;;OAGG;IACH,mBAA2B;IAE3B;;;OAGG;IACH,kBAAyB;IAEzB;;;OAGG;IACH,oBAA6B;IAE7B;;;OAGG;IACH,oBAA6B;IAE7B;;;OAGG;IACH,sBAAiC;IAEjC;;;OAGG;IACH,2BAA4B;IAE5B;;;OAGG;IACH,6BAAgC;IAEhC;;;OAGG;IACH,+BAA+C;IAE/C;;;OAGG;IACH,yBAA4B;IAE5B;;;OAGG;IACH,gCAAiC;IAKnC;;;OAGG;IACH,cAHW,wBAAwB,GAAC,iCAAiC,aAC1D,OAAO,oBAAoB,EAAE,SAAS,QAUhD;IAED;;;;;OAKG;IACH,yBAmBC;IAED;;;OAGG;IACH,wBAHW,KAAK,CAAC,OAAO,cAAc,EAAE,WAAW,CAAC,GACxC,OAAO,CAYlB;IAED;;;;;;;;;OASG;IACH,2BAFa,CAAC,cAPH,OAAO,qBAAqB,EAAE,UAAU,cACxC,MAAM,YACN,MAAM,gBACN,MAAM,YACN,CAAS,IAAsC,EAAtC,OAAO,kBAAkB,EAAE,WAAW,EAAE,IAA8C,EAA9C,OAAO,8BAA8B,EAAE,OAAO,EAAE,IAAM,EAAN,MAAM,KAAG,CAAC,uBAC3G,KAAK,CAAC,OAAO,kBAAkB,EAAE,WAAW,CAAC,GAC5C,CAAC,GAAC,SAAS,CAgItB;IAED;;;OAGG;IACH,yBAHW,OAAO,oBAAoB,EAAE,SAAS,GACrC,KAAK,CAAC,MAAM,CAAC,GAAC,IAAI,CAc7B;IAED;;OAEG;IACH,WAFY,OAAO,CAIlB;IAED;;;;;;;;;;OAUG;IACH,uBAVW,wBAAwB,GAAC,iCAAiC,oBAC1D,OAAO,eAAe,EAAE,IAAI,aAC5B,OAAO,oBAAoB,EAAE,SAAS,gBACtC,MAAM,eACN,OAAO,iBACP,KAAK,CAAC,OAAO,cAAc,EAAE,WAAW,CAAC,kBAEzC,OAAO,OAAO,EAAE,OAAO,CAAC,OAAO,eAAe,EAAE,cAAc,CAAC,GAAC,IAAI,QAgF9E;IAED;;MAEC;IAED,mFAEC;IAED,uBAUC;CACF"}
|
|
@@ -40,6 +40,41 @@ export const NON_DECLUTTER = ALL.filter(
|
|
|
40
40
|
(builderType) => !DECLUTTER.includes(builderType),
|
|
41
41
|
);
|
|
42
42
|
|
|
43
|
+
/** @type {boolean|undefined} */
|
|
44
|
+
let willReadFrequently = false;
|
|
45
|
+
|
|
46
|
+
/** @type {boolean|undefined} */
|
|
47
|
+
let canvasReadsBenchmarked = false;
|
|
48
|
+
|
|
49
|
+
/** Determine if canvas read operations are faster with willReadFrequently set to true or false */
|
|
50
|
+
function benchmarkCanvasReads() {
|
|
51
|
+
let bestResult = 0;
|
|
52
|
+
/**
|
|
53
|
+
* @param {boolean} willReadFrequently Will read frequently.
|
|
54
|
+
* @return {number} Operation count.
|
|
55
|
+
*/
|
|
56
|
+
const measure = (willReadFrequently) => {
|
|
57
|
+
const context = createCanvasContext2D(1, 1, null, {willReadFrequently});
|
|
58
|
+
let count = 0;
|
|
59
|
+
const start = performance.now();
|
|
60
|
+
for (; performance.now() - start < 50; ++count) {
|
|
61
|
+
context.fillStyle = `rgba(255,0,${count % 256},1)`;
|
|
62
|
+
context.fillRect(0, 0, 1, 1);
|
|
63
|
+
context.getImageData(0, 0, 1, 1);
|
|
64
|
+
}
|
|
65
|
+
bestResult = count > bestResult ? count : bestResult;
|
|
66
|
+
return count;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const measures = {
|
|
70
|
+
[measure(true)]: true,
|
|
71
|
+
[measure(false)]: false,
|
|
72
|
+
[measure(undefined)]: undefined,
|
|
73
|
+
};
|
|
74
|
+
willReadFrequently = measures[bestResult];
|
|
75
|
+
canvasReadsBenchmarked = true;
|
|
76
|
+
}
|
|
77
|
+
|
|
43
78
|
class ExecutorGroup {
|
|
44
79
|
/**
|
|
45
80
|
* @param {import("../../extent.js").Extent} maxExtent Max extent for clipping. When a
|
|
@@ -201,6 +236,10 @@ class ExecutorGroup {
|
|
|
201
236
|
callback,
|
|
202
237
|
declutteredFeatures,
|
|
203
238
|
) {
|
|
239
|
+
if (canvasReadsBenchmarked === false) {
|
|
240
|
+
benchmarkCanvasReads();
|
|
241
|
+
}
|
|
242
|
+
|
|
204
243
|
hitTolerance = Math.round(hitTolerance);
|
|
205
244
|
const contextSize = hitTolerance * 2 + 1;
|
|
206
245
|
const transform = composeTransform(
|
|
@@ -216,14 +255,11 @@ class ExecutorGroup {
|
|
|
216
255
|
|
|
217
256
|
const newContext = !this.hitDetectionContext_;
|
|
218
257
|
if (newContext) {
|
|
219
|
-
// Refrain from adding a 'willReadFrequently' hint in the options here.
|
|
220
|
-
// While it will remove the "Canvas2D: Multiple readback operations using
|
|
221
|
-
// getImageData are faster with the willReadFrequently attribute set
|
|
222
|
-
// to true" warnings in the console, it makes hitDetection extremely
|
|
223
|
-
// slow in Chrome when there are many features on the map
|
|
224
258
|
this.hitDetectionContext_ = createCanvasContext2D(
|
|
225
259
|
contextSize,
|
|
226
260
|
contextSize,
|
|
261
|
+
null,
|
|
262
|
+
{willReadFrequently},
|
|
227
263
|
);
|
|
228
264
|
}
|
|
229
265
|
const context = this.hitDetectionContext_;
|
package/util.js
CHANGED