Skip to content

Commit

Permalink
Bug 1687829 - Add composite surface locking to MappableCompositor tra…
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmuizel committed Feb 7, 2021
1 parent 9ed8c49 commit 4633e58
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions webrender/src/composite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use api::{ColorF, YuvColorSpace, YuvFormat, ImageRendering, ExternalImageId, ImageBufferKind};
use api::units::*;
use api::ColorDepth;
use crate::batch::{resolve_image};
use euclid::Transform3D;
use crate::gpu_cache::GpuCache;
Expand Down Expand Up @@ -1065,6 +1066,22 @@ pub struct MappedTileInfo {
pub stride: i32,
}

/// Descriptor for a locked surface that will be directly composited by SWGL.
#[repr(C)]
pub struct SWGLCompositeSurfaceInfo {
/// The number of YUV planes in the surface. 0 indicates non-YUV BGRA.
/// 1 is interleaved YUV. 2 is NV12. 3 is planar YUV.
pub yuv_planes: u32,
/// Textures for planes of the surface, or 0 if not applicable.
pub textures: [u32; 3],
/// Color space of surface if using a YUV format.
pub color_space: YuvColorSpace,
/// Color depth of surface if using a YUV format.
pub color_depth: ColorDepth,
/// The actual source surface size before transformation.
pub size: DeviceIntSize,
}

/// A Compositor variant that supports mapping tiles into CPU memory.
pub trait MappableCompositor: Compositor {
/// Map a tile's underlying buffer so it can be used as the backing for
Expand All @@ -1081,6 +1098,14 @@ pub trait MappableCompositor: Compositor {
/// Unmap a tile that was was previously mapped via map_tile to signal
/// that SWGL is done rendering to the buffer.
fn unmap_tile(&mut self);

fn lock_composite_surface(
&mut self,
ctx: *mut c_void,
external_image_id: ExternalImageId,
composite_info: *mut SWGLCompositeSurfaceInfo,
) -> bool;
fn unlock_composite_surface(&mut self, ctx: *mut c_void, external_image_id: ExternalImageId);
}

/// Defines an interface to a non-native (application-level) Compositor which handles
Expand Down
2 changes: 1 addition & 1 deletion webrender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ extern crate webrender_build;
#[doc(hidden)]
pub use crate::composite::{CompositorConfig, Compositor, CompositorCapabilities, CompositorSurfaceTransform};
pub use crate::composite::{NativeSurfaceId, NativeTileId, NativeSurfaceInfo, PartialPresentCompositor};
pub use crate::composite::{MappableCompositor, MappedTileInfo};
pub use crate::composite::{MappableCompositor, MappedTileInfo, SWGLCompositeSurfaceInfo};
pub use crate::device::{UploadMethod, VertexUsageHint, get_gl_target, get_unoptimized_shader_source};
pub use crate::device::{ProgramBinary, ProgramCache, ProgramCacheObserver, FormatDesc};
pub use crate::device::Device;
Expand Down

0 comments on commit 4633e58

Please sign in to comment.