Bug 1318066 - Provide WR with the path to the resources directory. r=jrmuizel?

MozReview-Commit-ID: JSatfZmk6Fh
This commit is contained in:
Kartikaya Gupta 2016-11-16 13:54:13 -05:00
Родитель ce0d4d9e10
Коммит df4c374ed9
12 изменённых файлов: 44 добавлений и 17 удалений

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

@ -1146,7 +1146,8 @@ CompositorBridgeChild::HandleFatalError(const char* aName, const char* aMsg) con
}
PWebRenderBridgeChild*
CompositorBridgeChild::AllocPWebRenderBridgeChild(const uint64_t& aPipelineId)
CompositorBridgeChild::AllocPWebRenderBridgeChild(const uint64_t& aPipelineId,
const nsString& aResourcePath)
{
WebRenderBridgeChild* child = new WebRenderBridgeChild(aPipelineId);
child->AddRef();

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

@ -228,7 +228,8 @@ public:
void WillEndTransaction();
PWebRenderBridgeChild* AllocPWebRenderBridgeChild(const uint64_t& aPipelineId) override;
PWebRenderBridgeChild* AllocPWebRenderBridgeChild(const uint64_t& aPipelineId,
const nsString& aResourcePath) override;
bool DeallocPWebRenderBridgeChild(PWebRenderBridgeChild* aActor) override;
private:

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

@ -1841,7 +1841,8 @@ CompositorBridgeParent::RecvAdoptChild(const uint64_t& child)
}
PWebRenderBridgeParent*
CompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId)
CompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId,
const nsString& aResourcePath)
{
#ifndef MOZ_ENABLE_WEBRENDER
// Extra guard since this in the parent process and we don't want a malicious
@ -1851,7 +1852,8 @@ CompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId)
MOZ_ASSERT(aPipelineId == mRootLayerTreeID);
RefPtr<gl::GLContext> glc(gl::GLContextProvider::CreateForCompositorWidget(mWidget, true));
WebRenderBridgeParent* parent = new WebRenderBridgeParent(aPipelineId, mWidget, glc.get(), nullptr);
WebRenderBridgeParent* parent = new WebRenderBridgeParent(aPipelineId,
&aResourcePath, mWidget, glc.get(), nullptr);
parent->AddRef(); // IPDL reference
MonitorAutoLock lock(*sIndirectLayerTreesLock);
MOZ_ASSERT(sIndirectLayerTrees[aPipelineId].mWRBridge == nullptr);

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

@ -539,7 +539,8 @@ public:
return !!mApzcTreeManager;
}
PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const uint64_t& aPipelineId) override;
PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const uint64_t& aPipelineId,
const nsString& aResourcePath) override;
bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
private:

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

@ -248,7 +248,8 @@ CrossProcessCompositorBridgeParent::DeallocPAPZParent(PAPZParent* aActor)
}
PWebRenderBridgeParent*
CrossProcessCompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId)
CrossProcessCompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId,
const nsString& aResourcePath)
{
#ifndef MOZ_ENABLE_WEBRENDER
// Extra guard since this in the parent process and we don't want a malicious
@ -268,7 +269,7 @@ CrossProcessCompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t&
WebRenderBridgeParent* root = sIndirectLayerTrees[cbp->RootLayerTreeId()].mWRBridge.get();
WebRenderBridgeParent* parent = new WebRenderBridgeParent(
aPipelineId, nullptr, root->GLContext(), root->WindowState());
aPipelineId, nullptr, nullptr, root->GLContext(), root->WindowState());
parent->AddRef(); // IPDL reference
sIndirectLayerTrees[aPipelineId].mWRBridge = parent;

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

@ -153,7 +153,8 @@ public:
virtual void UpdatePaintTime(LayerTransactionParent* aLayerTree, const TimeDuration& aPaintTime) override;
PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const uint64_t& aPipelineId) override;
PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const uint64_t& aPipelineId,
const nsString& aResourcePath) override;
bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
protected:

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

@ -231,7 +231,7 @@ parent:
sync SyncWithCompositor();
// The pipelineId is the same as the layersId
async PWebRenderBridge(uint64_t pipelineId);
async PWebRenderBridge(uint64_t pipelineId, nsString resourcePath);
child:
// Send back Compositor Frame Metrics from APZCs so tiled layers can

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

@ -14,6 +14,7 @@ namespace mozilla {
namespace layers {
WebRenderBridgeParent::WebRenderBridgeParent(const uint64_t& aPipelineId,
const nsString* aResourcePath,
widget::CompositorWidget* aWidget,
gl::GLContext* aGlContext,
wrwindowstate* aWrWindowState)
@ -29,7 +30,9 @@ WebRenderBridgeParent::WebRenderBridgeParent(const uint64_t& aPipelineId,
// i.e. the one created by the CompositorBridgeParent as opposed to the
// CrossProcessCompositorBridgeParent
MOZ_ASSERT(mWidget);
mWRWindowState = wr_init_window(mPipelineId);
MOZ_ASSERT(aResourcePath);
mWRWindowState = wr_init_window(mPipelineId,
NS_ConvertUTF16toUTF8(*aResourcePath).get());
}
}

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

@ -29,6 +29,7 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent
public:
WebRenderBridgeParent(const uint64_t& aPipelineId,
const nsString* aResourcePath,
widget::CompositorWidget* aWidget,
gl::GLContext* aGlContext,
wrwindowstate* aWrWindowState);

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

@ -11,6 +11,8 @@
#include "mozilla/layers/AsyncCompositionManager.h"
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "mozilla/widget/PlatformWidgetTypes.h"
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsThreadUtils.h"
#include "TreeTraversal.h"
#include "WebRenderCanvasLayer.h"
@ -142,7 +144,20 @@ WebRenderLayerManager::Initialize(PCompositorBridgeChild* aCBChild, uint64_t aLa
{
MOZ_ASSERT(mWRChild == nullptr);
PWebRenderBridgeChild* bridge = aCBChild->SendPWebRenderBridgeConstructor(aLayersId);
// Since the WebRenderBridgeParent might be in the compositor process with
// no access to the directory service, we have to get the directory here and
// send it over. We only need to do this for the parent process; the content
// processes ignore it anyway since they don't initialize new WR renderer
// instances.
nsAutoString resourcePath;
if (XRE_IsParentProcess()) {
nsCOMPtr<nsIFile> greDir;
nsDirectoryService::gService->Get(NS_GRE_DIR, NS_GET_IID(nsIFile), getter_AddRefs(greDir));
greDir->Append(NS_LITERAL_STRING("webrender"));
greDir->GetPath(resourcePath);
}
PWebRenderBridgeChild* bridge = aCBChild->SendPWebRenderBridgeConstructor(aLayersId, resourcePath);
MOZ_ASSERT(bridge);
mWRChild = static_cast<WebRenderBridgeChild*>(bridge);
LayoutDeviceIntSize size = mWidget->GetClientSize();

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

@ -11,7 +11,7 @@ use webrender_traits::{Epoch, ColorF};
use webrender_traits::{ImageFormat, ImageKey, ImageMask, ImageRendering, RendererKind};
use std::mem;
use std::slice;
use std::os::raw::c_uchar;
use std::os::raw::{c_char, c_uchar};
#[cfg(target_os = "linux")]
mod linux {
@ -238,9 +238,10 @@ pub struct WrState {
}
#[no_mangle]
pub extern fn wr_init_window(root_pipeline_id: u64) -> *mut WrWindowState {
// hack to find the directory for the shaders
let res_path = concat!(env!("CARGO_MANIFEST_DIR"),"/res");
pub extern fn wr_init_window(root_pipeline_id: u64, path_utf8: *const c_char) -> *mut WrWindowState {
let res_path = unsafe {
CStr::from_ptr(path_utf8).to_string_lossy().into_owned()
};
let library = GlLibrary::new();
gl::load_with(|symbol| library.query(symbol));
@ -556,4 +557,4 @@ pub extern fn wr_free_buffer(vec_ptr: *mut c_uchar, length: u32, capacity: u32)
unsafe {
let rebuilt = Vec::from_raw_parts(vec_ptr, length as usize, capacity as usize);
}
}
}

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

@ -47,7 +47,7 @@ struct wrstate;
#endif
WR_INLINE wrwindowstate*
wr_init_window(uint64_t root_pipeline_id)
wr_init_window(uint64_t root_pipeline_id, const char* path_utf8)
WR_FUNC;
WR_INLINE wrstate*