@@ -124,6 +124,10 @@ enum DocumentOp {
124
124
Rendered ( RendererFrame ) ,
125
125
}
126
126
127
+ /// The unique id for WR resource identification. This id is not thread safe.
128
+ /// The RenderBackend should be created in the same thread.
129
+ static mut NEXT_NAMESPACE_ID : IdNamespace = IdNamespace ( 1 ) ;
130
+
127
131
/// The render backend is responsible for transforming high level display lists into
128
132
/// GPU-friendly work which is then submitted to the renderer in the form of a frame::Frame.
129
133
///
@@ -133,7 +137,6 @@ pub struct RenderBackend {
133
137
payload_rx : PayloadReceiver ,
134
138
payload_tx : PayloadSender ,
135
139
result_tx : Sender < ResultMsg > ,
136
- next_namespace_id : IdNamespace ,
137
140
default_device_pixel_ratio : f32 ,
138
141
139
142
gpu_cache : GpuCache ,
@@ -177,7 +180,6 @@ impl RenderBackend {
177
180
gpu_cache : GpuCache :: new ( ) ,
178
181
frame_config,
179
182
documents : FastHashMap :: default ( ) ,
180
- next_namespace_id : IdNamespace ( 1 ) ,
181
183
notifier,
182
184
recorder,
183
185
@@ -452,9 +454,11 @@ impl RenderBackend {
452
454
tx. send ( glyph_indices) . unwrap ( ) ;
453
455
}
454
456
ApiMsg :: CloneApi ( sender) => {
455
- let namespace = self . next_namespace_id ;
456
- self . next_namespace_id = IdNamespace ( namespace. 0 + 1 ) ;
457
- sender. send ( namespace) . unwrap ( ) ;
457
+ unsafe {
458
+ let namespace = NEXT_NAMESPACE_ID ;
459
+ NEXT_NAMESPACE_ID = IdNamespace ( NEXT_NAMESPACE_ID . 0 + 1 ) ;
460
+ sender. send ( namespace) . unwrap ( ) ;
461
+ }
458
462
}
459
463
ApiMsg :: AddDocument ( document_id, initial_size) => {
460
464
let document = Document :: new (
0 commit comments