Bug 1554952 - Remove function pointers from WrExternalImageHandler r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D32813

--HG--
extra : moz-landing-system : lando
This commit is contained in:
sotaro 2019-05-29 20:50:13 +00:00
Родитель 325e222d30
Коммит 5e274cc3e6
2 изменённых файлов: 21 добавлений и 24 удалений

Просмотреть файл

@ -20,9 +20,9 @@
namespace mozilla {
namespace wr {
wr::WrExternalImage LockExternalImage(void* aObj, wr::WrExternalImageId aId,
uint8_t aChannelIndex,
wr::ImageRendering aRendering) {
wr::WrExternalImage wr_renderer_lock_external_image(
void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex,
wr::ImageRendering aRendering) {
RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj);
RenderTextureHost* texture = renderer->GetRenderTexture(aId);
MOZ_ASSERT(texture);
@ -34,8 +34,8 @@ wr::WrExternalImage LockExternalImage(void* aObj, wr::WrExternalImageId aId,
return texture->Lock(aChannelIndex, renderer->gl(), aRendering);
}
void UnlockExternalImage(void* aObj, wr::WrExternalImageId aId,
uint8_t aChannelIndex) {
void wr_renderer_unlock_external_image(void* aObj, wr::WrExternalImageId aId,
uint8_t aChannelIndex) {
RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj);
RenderTextureHost* texture = renderer->GetRenderTexture(aId);
MOZ_ASSERT(texture);
@ -75,8 +75,6 @@ RendererOGL::~RendererOGL() {
wr::WrExternalImageHandler RendererOGL::GetExternalImageHandler() {
return wr::WrExternalImageHandler{
this,
LockExternalImage,
UnlockExternalImage,
};
}

Просмотреть файл

@ -405,14 +405,22 @@ struct WrExternalImage {
size: usize,
}
type LockExternalImageCallback = unsafe extern "C" fn(*mut c_void, WrExternalImageId, u8, ImageRendering) -> WrExternalImage;
type UnlockExternalImageCallback = unsafe extern "C" fn(*mut c_void, WrExternalImageId, u8);
extern "C" {
fn wr_renderer_lock_external_image(
renderer: *mut c_void,
external_image_id: WrExternalImageId,
channel_index: u8,
rendering: ImageRendering) -> WrExternalImage;
fn wr_renderer_unlock_external_image(
renderer: *mut c_void,
external_image_id: WrExternalImageId,
channel_index: u8);
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct WrExternalImageHandler {
external_image_obj: *mut c_void,
lock_func: LockExternalImageCallback,
unlock_func: UnlockExternalImageCallback,
}
impl ExternalImageHandler for WrExternalImageHandler {
@ -422,7 +430,7 @@ impl ExternalImageHandler for WrExternalImageHandler {
rendering: ImageRendering)
-> ExternalImage {
let image = unsafe { (self.lock_func)(self.external_image_obj, id.into(), channel_index, rendering) };
let image = unsafe { wr_renderer_lock_external_image(self.external_image_obj, id.into(), channel_index, rendering) };
ExternalImage {
uv: TexelRect::new(image.u0, image.v0, image.u1, image.v1),
source: match image.image_type {
@ -437,7 +445,7 @@ impl ExternalImageHandler for WrExternalImageHandler {
id: ExternalImageId,
channel_index: u8) {
unsafe {
(self.unlock_func)(self.external_image_obj, id.into(), channel_index);
wr_renderer_unlock_external_image(self.external_image_obj, id.into(), channel_index);
}
}
}
@ -607,17 +615,8 @@ impl RenderNotifier for CppNotifier {
#[no_mangle]
pub extern "C" fn wr_renderer_set_external_image_handler(renderer: &mut Renderer,
external_image_handler: *mut WrExternalImageHandler) {
if !external_image_handler.is_null() {
renderer.set_external_image_handler(Box::new(unsafe {
WrExternalImageHandler {
external_image_obj:
(*external_image_handler).external_image_obj,
lock_func: (*external_image_handler).lock_func,
unlock_func: (*external_image_handler).unlock_func,
}
}));
}
external_image_handler: &mut WrExternalImageHandler) {
renderer.set_external_image_handler(Box::new(external_image_handler.clone()));
}
#[no_mangle]