Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Backed out changeset 42781c597745 (bug 1448703) cpu process leakcchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreeaPavel committed Apr 24, 2018
1 parent 1abd17c commit 7f3fb07
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gfx/webrender_bindings/Moz2DImageRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ static struct FontDeleteLog {
}
} sFontDeleteLog;

extern "C" {
void
ClearBlobImageResources(WrIdNamespace aNamespace) {
StaticMutexAutoLock lock(sFontDataTableLock);
Expand All @@ -111,6 +110,7 @@ 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);
Expand Down
17 changes: 17 additions & 0 deletions gfx/webrender_bindings/WebRenderAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ WebRenderAPI::GetNamespace() {
return wr_api_get_namespace(mDocHandle);
}

extern void ClearBlobImageResources(WrIdNamespace aNamespace);

WebRenderAPI::~WebRenderAPI()
{
if (!mRootDocumentApi) {
Expand All @@ -374,6 +376,21 @@ 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);
}

Expand Down
2 changes: 1 addition & 1 deletion gfx/webrender_bindings/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type WrEpoch = Epoch;
/// cbindgen:derive-lt=true
/// cbindgen:derive-lte=true
/// cbindgen:derive-neq=true
pub type WrIdNamespace = IdNamespace;
type WrIdNamespace = IdNamespace;

/// cbindgen:field-names=[mNamespace, mHandle]
type WrPipelineId = PipelineId;
Expand Down
6 changes: 2 additions & 4 deletions gfx/webrender_bindings/src/moz2d_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,19 +494,17 @@ impl BlobImageRenderer for Moz2dImageRenderer {
fn delete_font_instance(&mut self, _key: FontInstanceKey) {
}

fn clear_namespace(&mut self, namespace: IdNamespace) {
unsafe { ClearBlobImageResources(namespace); }
fn clear_namespace(&mut self, _namespace: IdNamespace) {
}
}

use bindings::{WrFontKey, WrIdNamespace};
use bindings::WrFontKey;

#[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 {
Expand Down

0 comments on commit 7f3fb07

Please sign in to comment.