@@ -13,8 +13,6 @@ class RendererMessageHandler {
13
13
14
14
static #tasks = new Map ( ) ;
15
15
16
- static #canvases = new Map ( ) ;
17
-
18
16
static #fontLoader = new FontLoader ( {
19
17
ownerDocument : self ,
20
18
} ) ;
@@ -62,7 +60,7 @@ class RendererMessageHandler {
62
60
if ( terminated ) {
63
61
throw new Error ( "Renderer worker has been terminated." ) ;
64
62
}
65
- this . handleCommonObj ( id , type , data , workerHandler , this . #commonObjs ) ;
63
+ this . handleCommonObj ( id , type , data , workerHandler ) ;
66
64
} ) ;
67
65
68
66
workerHandler . on ( "obj" , ( [ id , pageIndex , type , data ] ) => {
@@ -75,7 +73,18 @@ class RendererMessageHandler {
75
73
76
74
mainHandler . on (
77
75
"init" ,
78
- ( { pageIndex, canvas, drawingParams, map, colors, taskID } ) => {
76
+ ( {
77
+ pageIndex,
78
+ canvas,
79
+ map,
80
+ colors,
81
+ taskID,
82
+ transform,
83
+ viewport,
84
+ transparency,
85
+ background,
86
+ optionalContentConfig,
87
+ } ) => {
79
88
assert ( ! this . #tasks. has ( taskID ) , "Task already initialized" ) ;
80
89
const ctx = canvas . getContext ( "2d" , {
81
90
alpha : false ,
@@ -88,13 +97,12 @@ class RendererMessageHandler {
88
97
objs ,
89
98
this . #canvasFactory,
90
99
this . #filterFactory,
91
- { } ,
100
+ { optionalContentConfig } ,
92
101
map ,
93
102
colors
94
103
) ;
95
- gfx . beginDrawing ( drawingParams ) ;
104
+ gfx . beginDrawing ( { transform , viewport , transparency , background } ) ;
96
105
this . #tasks. set ( taskID , { canvas, gfx } ) ;
97
- this . #canvases. set ( pageIndex , canvas ) ;
98
106
}
99
107
) ;
100
108
@@ -123,12 +131,13 @@ class RendererMessageHandler {
123
131
task . gfx . endDrawing ( ) ;
124
132
} ) ;
125
133
126
- mainHandler . on ( "resetCanvas" , ( { pageIndex } ) => {
134
+ mainHandler . on ( "resetCanvas" , ( { taskID } ) => {
127
135
if ( terminated ) {
128
136
throw new Error ( "Renderer worker has been terminated." ) ;
129
137
}
130
- const canvas = this . #canvases. get ( pageIndex ) ;
131
- assert ( canvas !== undefined , "Page not initialized" ) ;
138
+ const task = this . #tasks. get ( taskID ) ;
139
+ assert ( task !== undefined , "Task not initialized" ) ;
140
+ const canvas = task . canvas ;
132
141
canvas . width = canvas . height = 0 ;
133
142
} ) ;
134
143
@@ -141,7 +150,6 @@ class RendererMessageHandler {
141
150
this . #objsMap. clear ( ) ;
142
151
this . #tasks. clear ( ) ;
143
152
this . #fontLoader. clear ( ) ;
144
- this . #canvases. clear ( ) ;
145
153
mainHandler . destroy ( ) ;
146
154
mainHandler = null ;
147
155
} ) ;
0 commit comments