Bug 1418315 - Use foreign_types to access CGFontRef from mac NativeFontHandle. r?kats
MozReview-Commit-ID: K9hyixeTAsz
--- a/gfx/webrender_bindings/Cargo.toml
+++ b/gfx/webrender_bindings/Cargo.toml
@@ -19,9 +19,10 @@ version = "0.54.0"
default-features = false
[target.'cfg(target_os = "windows")'.dependencies]
dwrote = "0.4"
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.4"
core-graphics = "0.12.2"
+foreign-types = "0.3.0"
--- a/gfx/webrender_bindings/src/lib.rs
+++ b/gfx/webrender_bindings/src/lib.rs
@@ -15,12 +15,14 @@ extern crate log;
#[cfg(target_os = "windows")]
extern crate dwrote;
#[cfg(target_os = "macos")]
extern crate core_foundation;
#[cfg(target_os = "macos")]
extern crate core_graphics;
+#[cfg(target_os = "macos")]
+extern crate foreign_types;
#[allow(non_snake_case)]
pub mod bindings;
pub mod moz2d_renderer;
--- a/gfx/webrender_bindings/src/moz2d_renderer.rs
+++ b/gfx/webrender_bindings/src/moz2d_renderer.rs
@@ -9,17 +9,17 @@ use std::os::raw::c_void;
use std::ptr;
use std::sync::mpsc::{channel, Sender, Receiver};
use std::sync::Arc;
#[cfg(target_os = "windows")]
use dwrote;
#[cfg(target_os = "macos")]
-use core_foundation::base::TCFType;
+use foreign_types::ForeignType;
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
use std::ffi::CString;
pub struct Moz2dImageRenderer {
blob_commands: HashMap<ImageKey, (Arc<BlobImageData>, Option<TileSize>)>,
// The images rendered in the current frame (not kept here between frames)
@@ -119,17 +119,17 @@ impl BlobImageRenderer for Moz2dImageRen
let system_fc = dwrote::FontCollection::system();
let font = system_fc.get_font_from_descriptor(handle).unwrap();
let face = font.create_font_face();
unsafe { AddNativeFontHandle(key, face.as_ptr() as *mut c_void, 0) };
}
#[cfg(target_os = "macos")]
fn process_native_font_handle(key: FontKey, handle: &NativeFontHandle) {
- unsafe { AddNativeFontHandle(key, handle.0.as_concrete_TypeRef() as *mut c_void, 0) };
+ unsafe { AddNativeFontHandle(key, handle.0.as_ptr() as *mut c_void, 0) };
}
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
fn process_native_font_handle(key: FontKey, handle: &NativeFontHandle) {
let cstr = CString::new(handle.pathname.clone()).unwrap();
unsafe { AddNativeFontHandle(key, cstr.as_ptr() as *mut c_void, handle.index) };
}