File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
src/core/text-rendering/renderers Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -85,12 +85,18 @@ export interface CanvasTextRendererState extends TextRendererState {
8585}
8686
8787export class CanvasTextRenderer extends TextRenderer < CanvasTextRendererState > {
88- protected canvas : OffscreenCanvas ;
89- protected context : OffscreenCanvasRenderingContext2D ;
88+ protected canvas : OffscreenCanvas | HTMLCanvasElement ;
89+ protected context :
90+ | OffscreenCanvasRenderingContext2D
91+ | CanvasRenderingContext2D ;
9092
9193 constructor ( stage : Stage ) {
9294 super ( stage ) ;
93- this . canvas = new OffscreenCanvas ( 0 , 0 ) ;
95+ if ( typeof OffscreenCanvas !== 'undefined' ) {
96+ this . canvas = new OffscreenCanvas ( 0 , 0 ) ;
97+ } else {
98+ this . canvas = document . createElement ( 'canvas' ) ;
99+ }
94100 const context = this . canvas . getContext ( '2d' ) ;
95101 assertTruthy ( context ) ;
96102 this . context = context ;
Original file line number Diff line number Diff line change @@ -126,14 +126,16 @@ export interface RenderInfo {
126126}
127127
128128export class LightningTextTextureRenderer {
129- private _canvas : OffscreenCanvas ;
130- private _context : OffscreenCanvasRenderingContext2D ;
129+ private _canvas : OffscreenCanvas | HTMLCanvasElement ;
130+ private _context :
131+ | OffscreenCanvasRenderingContext2D
132+ | CanvasRenderingContext2D ;
131133 private _settings : Settings ;
132134 private renderInfo : RenderInfo | undefined ;
133135
134136 constructor (
135- canvas : OffscreenCanvas ,
136- context : OffscreenCanvasRenderingContext2D ,
137+ canvas : OffscreenCanvas | HTMLCanvasElement ,
138+ context : OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D ,
137139 ) {
138140 this . _canvas = canvas ;
139141 this . _context = context ;
You can’t perform that action at this time.
0 commit comments