|
3536 | 3536 | <a href="#3535" id="3535">3535</a> |
3537 | 3537 | <a href="#3536" id="3536">3536</a> |
3538 | 3538 | <a href="#3537" id="3537">3537</a> |
| 3539 | +<a href="#3538" id="3538">3538</a> |
| 3540 | +<a href="#3539" id="3539">3539</a> |
| 3541 | +<a href="#3540" id="3540">3540</a> |
| 3542 | +<a href="#3541" id="3541">3541</a> |
| 3543 | +<a href="#3542" id="3542">3542</a> |
| 3544 | +<a href="#3543" id="3543">3543</a> |
| 3545 | +<a href="#3544" id="3544">3544</a> |
| 3546 | +<a href="#3545" id="3545">3545</a> |
| 3547 | +<a href="#3546" id="3546">3546</a> |
| 3548 | +<a href="#3547" id="3547">3547</a> |
| 3549 | +<a href="#3548" id="3548">3548</a> |
| 3550 | +<a href="#3549" id="3549">3549</a> |
| 3551 | +<a href="#3550" id="3550">3550</a> |
| 3552 | +<a href="#3551" id="3551">3551</a> |
| 3553 | +<a href="#3552" id="3552">3552</a> |
| 3554 | +<a href="#3553" id="3553">3553</a> |
| 3555 | +<a href="#3554" id="3554">3554</a> |
3539 | 3556 | </pre></div><pre class="rust"><code><span class="kw">use crate</span>::{ |
3540 | 3557 | api, |
3541 | 3558 | dispatch::{<span class="self">self</span>, BufferMappedRangeInterface, InterfaceTypes}, |
|
3980 | 3997 | <span class="doccomment">/// Configured device is needed to know which backend |
3981 | 3998 | /// code to execute when acquiring a new frame. |
3982 | 3999 | </span>configured_device: Mutex<<span class="prelude-ty">Option</span><wgc::id::DeviceId>>, |
| 4000 | + <span class="doccomment">/// The error sink with which to report errors. |
| 4001 | + /// `None` if the surface has not been configured. |
| 4002 | + </span>error_sink: Mutex<<span class="prelude-ty">Option</span><ErrorSink>>, |
3983 | 4003 | } |
3984 | 4004 |
|
3985 | 4005 | <span class="attr">#[derive(Debug)] |
|
4365 | 4385 | context: <span class="self">self</span>.clone(), |
4366 | 4386 | id, |
4367 | 4387 | configured_device: Mutex::default(), |
| 4388 | + error_sink: Mutex::default(), |
4368 | 4389 | })) |
4369 | 4390 | } |
4370 | 4391 |
|
|
6973 | 6994 |
|
6974 | 6995 | <span class="kw">let </span>error = <span class="self">self</span>.context.<span class="number">0</span>.surface_configure(<span class="self">self</span>.id, device.id, config); |
6975 | 6996 | <span class="kw">if let </span><span class="prelude-val">Some</span>(e) = error { |
6976 | | - <span class="self">self</span>.context.handle_error_fatal(e, <span class="string">"Surface::configure"</span>); |
| 6997 | + <span class="self">self</span>.context |
| 6998 | + .handle_error_nolabel(<span class="kw-2">&</span>device.error_sink, e, <span class="string">"Surface::configure"</span>); |
6977 | 6999 | } <span class="kw">else </span>{ |
6978 | 7000 | <span class="kw-2">*</span><span class="self">self</span>.configured_device.lock() = <span class="prelude-val">Some</span>(device.id); |
| 7001 | + <span class="kw-2">*</span><span class="self">self</span>.error_sink.lock() = <span class="prelude-val">Some</span>(device.error_sink.clone()); |
6979 | 7002 | } |
6980 | 7003 | } |
6981 | 7004 |
|
|
6986 | 7009 | <span class="kw">crate</span>::SurfaceStatus, |
6987 | 7010 | dispatch::DispatchSurfaceOutputDetail, |
6988 | 7011 | ) { |
| 7012 | + <span class="kw">let </span>output_detail = CoreSurfaceOutputDetail { |
| 7013 | + context: <span class="self">self</span>.context.clone(), |
| 7014 | + surface_id: <span class="self">self</span>.id, |
| 7015 | + } |
| 7016 | + .into(); |
| 7017 | + |
6989 | 7018 | <span class="kw">match </span><span class="self">self</span>.context.<span class="number">0</span>.surface_get_current_texture(<span class="self">self</span>.id, <span class="prelude-val">None</span>) { |
6990 | 7019 | <span class="prelude-val">Ok</span>(wgc::present::SurfaceOutput { status, texture_id }) => { |
6991 | 7020 | <span class="kw">let </span>data = texture_id |
|
6996 | 7025 | }) |
6997 | 7026 | .map(Into::into); |
6998 | 7027 |
|
6999 | | - ( |
7000 | | - data, |
7001 | | - status, |
7002 | | - CoreSurfaceOutputDetail { |
7003 | | - context: <span class="self">self</span>.context.clone(), |
7004 | | - surface_id: <span class="self">self</span>.id, |
| 7028 | + (data, status, output_detail) |
| 7029 | + } |
| 7030 | + <span class="prelude-val">Err</span>(err) => { |
| 7031 | + <span class="kw">let </span>error_sink = <span class="self">self</span>.error_sink.lock(); |
| 7032 | + <span class="kw">match </span>error_sink.as_ref() { |
| 7033 | + <span class="prelude-val">Some</span>(error_sink) => { |
| 7034 | + <span class="self">self</span>.context.handle_error_nolabel( |
| 7035 | + error_sink, |
| 7036 | + err, |
| 7037 | + <span class="string">"Surface::get_current_texture_view"</span>, |
| 7038 | + ); |
| 7039 | + (<span class="prelude-val">None</span>, <span class="kw">crate</span>::SurfaceStatus::Unknown, output_detail) |
7005 | 7040 | } |
7006 | | - .into(), |
7007 | | - ) |
| 7041 | + <span class="prelude-val">None </span>=> <span class="self">self |
| 7042 | + </span>.context |
| 7043 | + .handle_error_fatal(err, <span class="string">"Surface::get_current_texture_view"</span>), |
| 7044 | + } |
7008 | 7045 | } |
7009 | | - <span class="prelude-val">Err</span>(err) => <span class="self">self |
7010 | | - </span>.context |
7011 | | - .handle_error_fatal(err, <span class="string">"Surface::get_current_texture_view"</span>), |
7012 | 7046 | } |
7013 | 7047 | } |
7014 | 7048 | } |
|
0 commit comments