@@ -32,13 +32,15 @@ const MAX_ERROR = 128;
32
32
// should be a way faster to create the bitmap.
33
33
34
34
class ImageResizer {
35
+ static #goodSquareLength = MIN_IMAGE_DIM ;
36
+
35
37
constructor ( imgData , isMask ) {
36
38
this . _imgData = imgData ;
37
39
this . _isMask = isMask ;
38
40
}
39
41
40
42
static needsToBeResized ( width , height ) {
41
- if ( width <= this . _goodSquareLength && height <= this . _goodSquareLength ) {
43
+ if ( width <= this . #goodSquareLength && height <= this . #goodSquareLength ) {
42
44
return false ;
43
45
}
44
46
@@ -52,14 +54,14 @@ class ImageResizer {
52
54
return area > this . MAX_AREA ;
53
55
}
54
56
55
- if ( area < this . _goodSquareLength ** 2 ) {
57
+ if ( area < this . #goodSquareLength ** 2 ) {
56
58
return false ;
57
59
}
58
60
59
61
// We try as much as possible to avoid to compute the max area.
60
62
if ( this . _areGoodDims ( width , height ) ) {
61
- this . _goodSquareLength = Math . max (
62
- this . _goodSquareLength ,
63
+ this . #goodSquareLength = Math . max (
64
+ this . #goodSquareLength ,
63
65
Math . floor ( Math . sqrt ( width * height ) )
64
66
) ;
65
67
return false ;
@@ -69,13 +71,13 @@ class ImageResizer {
69
71
// some large canvas, so in the Firefox case this value (and MAX_DIM) can be
70
72
// infered from prefs (MAX_AREA = gfx.max-alloc-size / 4, 4 is because of
71
73
// RGBA).
72
- this . _goodSquareLength = this . _guessMax (
73
- this . _goodSquareLength ,
74
+ this . #goodSquareLength = this . _guessMax (
75
+ this . #goodSquareLength ,
74
76
MAX_DIM ,
75
77
MAX_ERROR ,
76
78
0
77
79
) ;
78
- const maxArea = ( this . MAX_AREA = this . _goodSquareLength ** 2 ) ;
80
+ const maxArea = ( this . MAX_AREA = this . #goodSquareLength ** 2 ) ;
79
81
80
82
return area > maxArea ;
81
83
}
@@ -93,12 +95,7 @@ class ImageResizer {
93
95
return shadow (
94
96
this ,
95
97
"MAX_AREA" ,
96
- this . _guessMax (
97
- ImageResizer . _goodSquareLength ,
98
- this . MAX_DIM ,
99
- MAX_ERROR ,
100
- 0
101
- ) ** 2
98
+ this . _guessMax ( this . #goodSquareLength, this . MAX_DIM , MAX_ERROR , 0 ) ** 2
102
99
) ;
103
100
}
104
101
@@ -393,6 +390,4 @@ class ImageResizer {
393
390
}
394
391
}
395
392
396
- ImageResizer . _goodSquareLength = MIN_IMAGE_DIM ;
397
-
398
393
export { ImageResizer } ;
0 commit comments