Bug 1500233 - Re-vendor rust dependencies. r=kats

Depends on D9268

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
WR Updater Bot 2018-10-19 15:57:43 +00:00
Родитель 87117a44b1
Коммит b8831a6d42
6 изменённых файлов: 51 добавлений и 31 удалений

10
Cargo.lock сгенерированный
Просмотреть файл

@ -767,7 +767,7 @@ dependencies = [
[[package]]
name = "dwrote"
version = "0.5.1"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2932,7 +2932,7 @@ dependencies = [
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2960,7 +2960,7 @@ dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2976,7 +2976,7 @@ dependencies = [
"bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3185,7 +3185,7 @@ dependencies = [
"checksum docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d8acd393692c503b168471874953a2531df0e9ab77d0b6bbc582395743300a4a"
"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
"checksum dtoa-short 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "068d4026697c1a18f0b0bb8cfcad1b0c151b90d8edb9bf4c235ad68128920d1d"
"checksum dwrote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30a998e9ff70cd208ccdc4f864e998688bf61d7b897dccec8e17a884d17358bf"
"checksum dwrote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f5472f94ba0d9e65b4fefb8c1661ad5b253455eec42cb0702cf0189526321034"
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
"checksum ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dc8393b3c7352f94092497f6b52019643e493b6b890eb417cdb7c46117e621"
"checksum encoding_c 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "769ecb8b33323998e482b218c0d13cd64c267609023b4b7ec3ee740714c318ee"

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

@ -1 +1 @@
{"files":{"Cargo.toml":"76ab5c65a983292b55154defbe54d6d18661e4f0addc237873b8333a6f5f3c05","README.md":"d69d75705e2582721cbfb2d3b4b2af052c71679057a0b2ac53a22c03f1755bba","appveyor.yml":"7c1e0718a363d3567cecd1ef772d4e17c2a17f18906dc464dce8a2411adff6be","src/bitmap_render_target.rs":"fc13525d7459515e4bf9769c8a8961b046b4d1ba4042591aaf0925dd5edebf64","src/com_helpers.rs":"02535b27bfb0cee6e4d8db3abd22f2d2e8137a4ce3ab3504beaf4fa3ca9370df","src/comptr.rs":"84794cf04b772398e75fdb5d55fd8fa015abf26c61b1f9c761a597133682b2e1","src/font.rs":"a79b944f2f5125bbef9e24921355dc6996f073e3742ddd410b8efaa0df3a3ee2","src/font_collection.rs":"df3767b305e9981fbe9398d9982123c668fb2a38cd92f5bdbaf574353005378d","src/font_collection_impl.rs":"a585a6ce62083b3346d67619ea47fec46423a7fb04cc11372828389ab26c5a05","src/font_face.rs":"55d3ddef22be160b9b9a0ffd677993290b0df0f847e7dbcce4014a222490205e","src/font_family.rs":"4e948542dba0c158187d0cb2d72343c443380480cacd12894070d0ef1351dd0a","src/font_file.rs":"913c5dd428028fb3c870b70f4ef2ac2ac357c7ae02cc2c7fb075eb675dcc97b4","src/font_file_loader_impl.rs":"42d23dd036bd2ec7c76de6fffd34a675949f5f881fba553f53351f2ac96da003","src/gdi_interop.rs":"04dbef7c34bb0fe62c4f2c2ceca62ca94c75a964d744b29b3322a6c3bbb4eabd","src/geometry_sink_impl.rs":"d615de212e55b8b8d95c8d605fc5d78044b4ae4dfd846f706911a16cc3afc049","src/glyph_run_analysis.rs":"3b2a351422098a19e8f490421e5b19227fc14a41a0df97d488c536fd1d4b552c","src/helpers.rs":"2f3c57642b24b80c45bbd012e7d6ca1fc524b1b42a8be004cb9b52ea13f4166d","src/lib.rs":"b634e62dd088d804429f451ba9f14aaab0b6a1179042d70fed825f3253ffacfb","src/outline_builder.rs":"0f5c842b2ffe75e21d68f93be6a3834c120bd43303d4e490fdfee9f4f964cdc4","src/rendering_params.rs":"850a51143790f5d29422dc49cbceddc232d814ecd0e6933434ad644e6eec539b","src/test.rs":"120f63cd638b2195caeec8c74a06985103abc6e720275a7f80ffdf130474a8a0","src/types.rs":"587aea2e50720e85b28efe237c8ea10bc45b52049ca724447a0fc9b0e6672b11"},"package":"30a998e9ff70cd208ccdc4f864e998688bf61d7b897dccec8e17a884d17358bf"}
{"files":{"Cargo.toml":"0fde468a4a83f83c7dddf49edc2e6f3730700b268c55b6a721a4938cd2b82478","README.md":"d69d75705e2582721cbfb2d3b4b2af052c71679057a0b2ac53a22c03f1755bba","appveyor.yml":"7c1e0718a363d3567cecd1ef772d4e17c2a17f18906dc464dce8a2411adff6be","src/bitmap_render_target.rs":"fc13525d7459515e4bf9769c8a8961b046b4d1ba4042591aaf0925dd5edebf64","src/com_helpers.rs":"02535b27bfb0cee6e4d8db3abd22f2d2e8137a4ce3ab3504beaf4fa3ca9370df","src/comptr.rs":"84794cf04b772398e75fdb5d55fd8fa015abf26c61b1f9c761a597133682b2e1","src/font.rs":"a79b944f2f5125bbef9e24921355dc6996f073e3742ddd410b8efaa0df3a3ee2","src/font_collection.rs":"df3767b305e9981fbe9398d9982123c668fb2a38cd92f5bdbaf574353005378d","src/font_collection_impl.rs":"a585a6ce62083b3346d67619ea47fec46423a7fb04cc11372828389ab26c5a05","src/font_face.rs":"55d3ddef22be160b9b9a0ffd677993290b0df0f847e7dbcce4014a222490205e","src/font_family.rs":"4e948542dba0c158187d0cb2d72343c443380480cacd12894070d0ef1351dd0a","src/font_file.rs":"1c012d0b436c2831d31cd76f77a59dab1edc5d63881c495eb486cd4febe23031","src/font_file_loader_impl.rs":"71c4153971dbfc21d42ba2e33f159fcb145f7dcfbd17e856e9fd75f0571d41e0","src/gdi_interop.rs":"04dbef7c34bb0fe62c4f2c2ceca62ca94c75a964d744b29b3322a6c3bbb4eabd","src/geometry_sink_impl.rs":"d615de212e55b8b8d95c8d605fc5d78044b4ae4dfd846f706911a16cc3afc049","src/glyph_run_analysis.rs":"3b2a351422098a19e8f490421e5b19227fc14a41a0df97d488c536fd1d4b552c","src/helpers.rs":"2f3c57642b24b80c45bbd012e7d6ca1fc524b1b42a8be004cb9b52ea13f4166d","src/lib.rs":"b634e62dd088d804429f451ba9f14aaab0b6a1179042d70fed825f3253ffacfb","src/outline_builder.rs":"0f5c842b2ffe75e21d68f93be6a3834c120bd43303d4e490fdfee9f4f964cdc4","src/rendering_params.rs":"850a51143790f5d29422dc49cbceddc232d814ecd0e6933434ad644e6eec539b","src/test.rs":"158aa4d03655f4efef00327fe72a03dfb504659176aa0eef976ca2485b2c1d74","src/types.rs":"587aea2e50720e85b28efe237c8ea10bc45b52049ca724447a0fc9b0e6672b11"},"package":"f5472f94ba0d9e65b4fefb8c1661ad5b253455eec42cb0702cf0189526321034"}

2
third_party/rust/dwrote/Cargo.toml поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
[package]
name = "dwrote"
version = "0.5.1"
version = "0.5.2"
authors = ["Vladimir Vukicevic <vladimir@pobox.com>"]
description = "Lightweight binding to DirectWrite."
license = "MPL-2.0"

22
third_party/rust/dwrote/src/font_file.rs поставляемый
Просмотреть файл

@ -11,6 +11,7 @@ use std::fs::File;
use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::os::windows::io::IntoRawHandle;
use std::path::Path;
use std::sync::Arc;
use comptr::ComPtr;
@ -27,6 +28,7 @@ use super::DWriteFactory;
pub struct FontFile {
native: UnsafeCell<ComPtr<IDWriteFontFile>>,
stream: UnsafeCell<Option<ComPtr<IDWriteFontFileStream>>>,
data_key: usize,
face_type: DWRITE_FONT_FACE_TYPE,
}
@ -47,34 +49,36 @@ impl FontFile {
Some(FontFile {
native: UnsafeCell::new(font_file),
stream: UnsafeCell::new(None),
data_key: 0,
face_type: DWRITE_FONT_FACE_TYPE_UNKNOWN,
})
}
}
pub fn new_from_data(data: &[u8]) -> Option<FontFile> {
let (font_file, key) = DataFontHelper::register_font_data(data);
pub fn new_from_data(data: Arc<Vec<u8>>) -> Option<FontFile> {
let (font_file, font_file_stream, key) = DataFontHelper::register_font_data(data);
let mut ff = FontFile {
native: UnsafeCell::new(font_file),
stream: UnsafeCell::new(Some(font_file_stream)),
data_key: key,
face_type: DWRITE_FONT_FACE_TYPE_UNKNOWN,
};
if ff.analyze() == 0 {
DataFontHelper::unregister_font_data(key);
return None;
None
} else {
Some(ff)
}
Some(ff)
}
pub fn analyze_data(data: &[u8]) -> u32 {
let (font_file, key) = DataFontHelper::register_font_data(data);
pub fn analyze_data(data: Arc<Vec<u8>>) -> u32 {
let (font_file, font_file_stream, key) = DataFontHelper::register_font_data(data);
let mut ff = FontFile {
native: UnsafeCell::new(font_file),
stream: UnsafeCell::new(Some(font_file_stream)),
data_key: key,
face_type: DWRITE_FONT_FACE_TYPE_UNKNOWN,
};
@ -104,6 +108,7 @@ impl FontFile {
pub fn take(native: ComPtr<IDWriteFontFile>) -> FontFile {
let mut ff = FontFile {
native: UnsafeCell::new(native),
stream: UnsafeCell::new(None),
data_key: 0,
face_type: DWRITE_FONT_FACE_TYPE_UNKNOWN,
};
@ -216,6 +221,7 @@ impl Clone for FontFile {
unsafe {
FontFile {
native: UnsafeCell::new((*self.native.get()).clone()),
stream: UnsafeCell::new((*self.stream.get()).clone()),
data_key: self.data_key,
face_type: self.face_type,
}

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

@ -3,7 +3,7 @@
use std::{mem, ptr};
use std::collections::HashMap;
use std::sync::atomic::AtomicUsize;
use std::sync::{Mutex, atomic};
use std::sync::{Arc, Mutex, atomic};
use std::marker::Send;
use winapi::ctypes::c_void;
use winapi::shared::basetsd::{UINT32, UINT64};
@ -39,13 +39,13 @@ const FontFileLoaderVtbl: &'static IDWriteFontFileLoaderVtbl = &IDWriteFontFileL
}
assert!(fontFileReferenceKeySize == mem::size_of::<usize>() as UINT32);
let key = *(fontFileReferenceKey as *const usize);
let stream = match FONT_FILE_STREAM_MAP.lock().unwrap().get_mut(&key) {
let stream = match FONT_FILE_STREAM_MAP.lock().unwrap().get(&key) {
None => {
*fontFileStream = ptr::null_mut();
return E_FAIL
}
Some(file_stream) => {
file_stream.as_ptr()
Some(&FontFileStreamPtr(file_stream)) => {
file_stream
}
};
@ -80,7 +80,8 @@ unsafe impl Sync for FontFileLoader {}
struct FontFileStream {
refcount: atomic::AtomicUsize,
data: Vec<u8>,
key: usize,
data: Arc<Vec<u8>>,
}
const FontFileStreamVtbl: &'static IDWriteFontFileStreamVtbl = &IDWriteFontFileStreamVtbl {
@ -99,7 +100,7 @@ const FontFileStreamVtbl: &'static IDWriteFontFileStreamVtbl = &IDWriteFontFileS
return E_INVALIDARG
}
let index = fileOffset as usize;
*fragmentStart = this.data[index..].as_mut_ptr() as *const c_void;
*fragmentStart = this.data[index..].as_ptr() as *const c_void;
S_OK
}
ReadFileFragment
@ -135,14 +136,21 @@ const FontFileStreamVtbl: &'static IDWriteFontFileStreamVtbl = &IDWriteFontFileS
};
impl FontFileStream {
pub fn new(data: &[u8]) -> FontFileStream {
pub fn new(key: usize, data: Arc<Vec<u8>>) -> FontFileStream {
FontFileStream {
refcount: AtomicUsize::new(1),
data: data.to_vec(),
key,
data,
}
}
}
impl Drop for FontFileStream {
fn drop(&mut self) {
DataFontHelper::unregister_font_data(self.key);
}
}
impl Com<IDWriteFontFileStream> for FontFileStream {
type Vtbl = IDWriteFontFileStreamVtbl;
fn vtbl() -> &'static IDWriteFontFileStreamVtbl { FontFileStreamVtbl }
@ -153,10 +161,14 @@ impl Com<IUnknown> for FontFileStream {
fn vtbl() -> &'static IUnknownVtbl { &FontFileStreamVtbl.parent }
}
struct FontFileStreamPtr(*mut IDWriteFontFileStream);
unsafe impl Send for FontFileStreamPtr {}
static mut FONT_FILE_KEY: atomic::AtomicUsize = atomic::ATOMIC_USIZE_INIT;
lazy_static! {
static ref FONT_FILE_STREAM_MAP: Mutex<HashMap<usize, ComPtr<IDWriteFontFileStream>>> = {
static ref FONT_FILE_STREAM_MAP: Mutex<HashMap<usize, FontFileStreamPtr>> = {
Mutex::new(HashMap::new())
};
@ -174,16 +186,17 @@ lazy_static! {
pub struct DataFontHelper;
impl DataFontHelper {
pub fn register_font_data(font_data: &[u8]) -> (ComPtr<IDWriteFontFile>, usize) {
pub fn register_font_data(font_data: Arc<Vec<u8>>)
-> (ComPtr<IDWriteFontFile>, ComPtr<IDWriteFontFileStream>, usize) {
unsafe {
let key = FONT_FILE_KEY.fetch_add(1, atomic::Ordering::Relaxed);
let font_file_stream_native = FontFileStream::new(font_data);
let font_file_stream_native = FontFileStream::new(key, font_data);
let font_file_stream: ComPtr<IDWriteFontFileStream> =
ComPtr::from_ptr(font_file_stream_native.into_interface());
ComPtr::already_addrefed(font_file_stream_native.into_interface());
{
let mut map = FONT_FILE_STREAM_MAP.lock().unwrap();
map.insert(key, font_file_stream);
map.insert(key, FontFileStreamPtr(font_file_stream.as_ptr()));
}
let mut font_file: ComPtr<IDWriteFontFile> = ComPtr::new();
@ -197,11 +210,11 @@ impl DataFontHelper {
assert!(hr == S_OK);
}
(font_file, key)
(font_file, font_file_stream, key)
}
}
pub fn unregister_font_data(key: usize) {
fn unregister_font_data(key: usize) {
let mut map = FONT_FILE_STREAM_MAP.lock().unwrap();
if map.remove(&key).is_none() {
panic!("unregister_font_data: trying to unregister key that is no longer registered");

3
third_party/rust/dwrote/src/test.rs поставляемый
Просмотреть файл

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use super::*;
use std::sync::Arc;
#[test]
fn test_system_family_iter() {
@ -79,7 +80,7 @@ fn test_create_font_file_from_bytes() {
assert!(bytes.len() > 0);
// now go back
let new_font = FontFile::new_from_data(&bytes);
let new_font = FontFile::new_from_data(Arc::new(bytes));
assert!(new_font.is_some());
let new_font = new_font.unwrap();