Bug 1448703 - clear blob image resources from clear_namespace hook. r=jrmuizel

MozReview-Commit-ID: 8DinL2bE64O
This commit is contained in:
Lee Salzman 2018-04-23 21:46:55 -04:00
Родитель 1940af33ec
Коммит d8e6c45ef2
4 изменённых файлов: 6 добавлений и 21 удалений

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

@ -94,6 +94,7 @@ static struct FontDeleteLog {
}
} sFontDeleteLog;
extern "C" {
void
ClearBlobImageResources(WrIdNamespace aNamespace) {
StaticMutexAutoLock lock(sFontDataTableLock);
@ -110,7 +111,6 @@ ClearBlobImageResources(WrIdNamespace aNamespace) {
}
}
extern "C" {
void
AddFontData(WrFontKey aKey, const uint8_t *aData, size_t aSize, uint32_t aIndex, const ArcVecU8 *aVec) {
StaticMutexAutoLock lock(sFontDataTableLock);

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

@ -357,8 +357,6 @@ WebRenderAPI::GetNamespace() {
return wr_api_get_namespace(mDocHandle);
}
extern void ClearBlobImageResources(WrIdNamespace aNamespace);
WebRenderAPI::~WebRenderAPI()
{
if (!mRootDocumentApi) {
@ -376,21 +374,6 @@ WebRenderAPI::~WebRenderAPI()
wr_api_shut_down(mDocHandle);
}
// wr_api_get_namespace cannot be marked destructor-safe because it has a
// return value, and we can't call it if MOZ_BUILD_WEBRENDER is not defined
// because it's not destructor-safe. So let's just ifdef around it. This is
// basically a hack to get around compile-time warnings, this code never runs
// unless MOZ_BUILD_WEBRENDER is defined anyway.
#ifdef MOZ_BUILD_WEBRENDER
wr::WrIdNamespace ns = GetNamespace();
#else
wr::WrIdNamespace ns{0};
#endif
// Clean up any resources the blob image renderer is holding onto that
// can no longer be used once this WR API instance goes away.
ClearBlobImageResources(ns);
wr_api_delete(mDocHandle);
}

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

@ -63,7 +63,7 @@ type WrEpoch = Epoch;
/// cbindgen:derive-lt=true
/// cbindgen:derive-lte=true
/// cbindgen:derive-neq=true
type WrIdNamespace = IdNamespace;
pub type WrIdNamespace = IdNamespace;
/// cbindgen:field-names=[mNamespace, mHandle]
type WrPipelineId = PipelineId;

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

@ -494,17 +494,19 @@ impl BlobImageRenderer for Moz2dImageRenderer {
fn delete_font_instance(&mut self, _key: FontInstanceKey) {
}
fn clear_namespace(&mut self, _namespace: IdNamespace) {
fn clear_namespace(&mut self, namespace: IdNamespace) {
unsafe { ClearBlobImageResources(namespace); }
}
}
use bindings::WrFontKey;
use bindings::{WrFontKey, WrIdNamespace};
#[allow(improper_ctypes)] // this is needed so that rustc doesn't complain about passing the &Arc<Vec> to an extern function
extern "C" {
fn AddFontData(key: WrFontKey, data: *const u8, size: usize, index: u32, vec: &ArcVecU8);
fn AddNativeFontHandle(key: WrFontKey, handle: *mut c_void, index: u32);
fn DeleteFontData(key: WrFontKey);
fn ClearBlobImageResources(namespace: WrIdNamespace);
}
impl Moz2dImageRenderer {