mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
webgpu: Sync GPUBuffer
(#33154)
* More helpers on `Promise` Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Sync `GPUBuffer` Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Set some good expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Some bad expect also on firefox Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Extract DataBlock, DataView impl from GPUBuffer Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Fix size check to work on 32bit platforms Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
bb5926b329
commit
7fce24f9d5
12 changed files with 690 additions and 1163 deletions
|
@ -52,6 +52,12 @@ pub struct Promise {
|
|||
permanent_js_root: Heap<JSVal>,
|
||||
}
|
||||
|
||||
impl PartialEq for Promise {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.reflector == other.reflector
|
||||
}
|
||||
}
|
||||
|
||||
/// Private helper to enable adding new methods to `Rc<Promise>`.
|
||||
trait PromiseHelper {
|
||||
fn initialize(&self, cx: SafeJSContext);
|
||||
|
@ -231,6 +237,18 @@ impl Promise {
|
|||
matches!(state, PromiseState::Rejected | PromiseState::Fulfilled)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn is_rejected(&self) -> bool {
|
||||
let state = unsafe { GetPromiseState(self.promise_obj()) };
|
||||
matches!(state, PromiseState::Rejected)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn is_pending(&self) -> bool {
|
||||
let state = unsafe { GetPromiseState(self.promise_obj()) };
|
||||
matches!(state, PromiseState::Pending)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn promise_obj(&self) -> HandleObject {
|
||||
let obj = self.reflector().get_jsobject();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue