@@ -1059,10 +1059,6 @@ class CanvasGraphics {
1059
1059
// Vertical or horizontal scaling shall not be more than 2 to not lose the
1060
1060
// pixels during drawImage operation, painting on the temporary canvas(es)
1061
1061
// that are twice smaller in size.
1062
-
1063
- // displayWidth and displayHeight are used for VideoFrame.
1064
- const width = img . width ?? img . displayWidth ;
1065
- const height = img . height ?? img . displayHeight ;
1066
1062
let widthScale = Math . max (
1067
1063
Math . hypot ( inverseTransform [ 0 ] , inverseTransform [ 1 ] ) ,
1068
1064
1
@@ -1498,7 +1494,6 @@ class CanvasGraphics {
1498
1494
let maskY = layerOffsetY - maskOffsetY ;
1499
1495
1500
1496
if ( backdrop ) {
1501
- const backdropRGB = Util . makeHexColor ( ...backdrop ) ;
1502
1497
if (
1503
1498
maskX < 0 ||
1504
1499
maskY < 0 ||
@@ -1512,22 +1507,23 @@ class CanvasGraphics {
1512
1507
) ;
1513
1508
const ctx = canvas . context ;
1514
1509
ctx . drawImage ( maskCanvas , - maskX , - maskY ) ;
1515
- ctx . globalCompositeOperation = "destination-atop" ;
1516
- ctx . fillStyle = backdropRGB ;
1517
- ctx . fillRect ( 0 , 0 , width , height ) ;
1518
- ctx . globalCompositeOperation = "source-over" ;
1519
-
1510
+ if ( backdrop . some ( c => c !== 0 ) ) {
1511
+ ctx . globalCompositeOperation = "destination-atop" ;
1512
+ ctx . fillStyle = Util . makeHexColor ( ...backdrop ) ;
1513
+ ctx . fillRect ( 0 , 0 , width , height ) ;
1514
+ ctx . globalCompositeOperation = "source-over" ;
1515
+ }
1520
1516
maskCanvas = canvas . canvas ;
1521
1517
maskX = maskY = 0 ;
1522
- } else {
1518
+ } else if ( backdrop . some ( c => c !== 0 ) ) {
1523
1519
maskCtx . save ( ) ;
1524
1520
maskCtx . globalAlpha = 1 ;
1525
1521
maskCtx . setTransform ( 1 , 0 , 0 , 1 , 0 , 0 ) ;
1526
1522
const clip = new Path2D ( ) ;
1527
1523
clip . rect ( maskX , maskY , width , height ) ;
1528
1524
maskCtx . clip ( clip ) ;
1529
1525
maskCtx . globalCompositeOperation = "destination-atop" ;
1530
- maskCtx . fillStyle = backdropRGB ;
1526
+ maskCtx . fillStyle = Util . makeHexColor ( ... backdrop ) ;
1531
1527
maskCtx . fillRect ( maskX , maskY , width , height ) ;
1532
1528
maskCtx . restore ( ) ;
1533
1529
}
0 commit comments