m85: update gpu/context.rs
#[cfg(feature = "gl")]
use super::gl;
#[cfg(feature = "vulkan")]
-use super::vk;
+use super::{vk, BackendRenderTarget, BackendSurfaceMutableState, BackendTexture};
use crate::gpu::{BackendFormat, MipMapped, Renderable};
use crate::prelude::*;
use crate::{image, ColorType, Data, Image};
use skia_bindings as sb;
use skia_bindings::{GrContext, SkRefCntBase};
-use std::time::Duration;
+use std::{ptr, time::Duration};
pub type Context = RCHandle<GrContext>;
@@ -86,6 +86,11 @@ impl RCHandle<GrContext> {
unsafe { sb::C_GrContext_abandoned(self.native_mut()) }
}
+ // TODO: is_...?
+ pub fn oomed(&mut self) -> bool {
+ unsafe { self.native_mut().oomed() }
+ }
+
pub fn release_resources_and_abandon(&mut self) -> &mut Self {
unsafe { sb::GrContext_releaseResourcesAndAbandonContext(self.native_mut() as *mut _ as _) }
self
@@ -205,24 +210,20 @@ impl RCHandle<GrContext> {
// TODO: wait()
- pub fn flush_and_submit(&mut self) -> &mut Self {
- unsafe { sb::C_GrContext_flushAndSubmit(self.native_mut()) }
- self
- }
-
#[deprecated(since = "0.30.0", note = "use flush_and_submit()")]
pub fn flush(&mut self) -> &mut Self {
self.flush_and_submit()
}
- // TODO: flush(GrFlushInfo, ..) two variants.
- // TODO: flushAndSignalSemaphores
-
- pub fn submit(&mut self, sync_to_cpu: impl Into<Option<bool>>) -> bool {
- unsafe {
- self.native_mut()
- .submit(sync_to_cpu.into().unwrap_or(false))
+ pub fn flush_and_submit(&mut self) -> &mut Self {
+ unsafe { sb::C_GrContext_flushAndSubmit(self.native_mut()) }
+ self
}
+
+ // TODO: flush(GrFlushInfo, ..)
+
+ pub fn submit(&mut self, sync_cpu: impl Into<Option<bool>>) -> bool {
+ unsafe { self.native_mut().submit(sync_cpu.into().unwrap_or(false)) }
}
pub fn check_async_work_completion(&mut self) {
@@ -291,6 +292,38 @@ impl RCHandle<GrContext> {
// introduced in m81
// extended in m84 with finishedProc and finishedContext
+ // TODO: add variant with GpuFinishedProc / GpuFinishedContext
+ pub fn set_backend_texture_state(
+ &mut self,
+ backend_texture: &BackendTexture,
+ state: &BackendSurfaceMutableState,
+ ) -> bool {
+ unsafe {
+ self.native_mut().setBackendTextureState(
+ backend_texture.native(),
+ state.native(),
+ None,
+ ptr::null_mut(),
+ )
+ }
+ }
+
+ // TODO: add variant with GpuFinishedProc / GpuFinishedContext
+ pub fn set_backend_render_target_state(
+ &mut self,
+ target: &BackendRenderTarget,
+ state: &BackendSurfaceMutableState,
+ ) -> bool {
+ unsafe {
+ self.native_mut().setBackendRenderTargetState(
+ target.native(),
+ state.native(),
+ None,
+ ptr::null_mut(),
+ )
+ }
+ }
+
// TODO: wrap deleteBackendTexture(),
pub fn precompile_shader(&mut self, key: &Data, data: &Data) -> bool {
