Bug 1318066 - Revert the changes for packing the webrender shaders. r=kats?
authorJerryShih <hshih@mozilla.com>
Fri, 18 Nov 2016 21:56:47 +0800
changeset 459789 d17759dd3b74426235447bb7ffc3a91b614828b5
parent 459788 c85e2d8dc8df963eb0750cac566f5e91dea17a10
child 459790 977ed2d3eb0b54141d25f209d71f72b8a5170d92
push id41343
push userkgupta@mozilla.com
push dateThu, 12 Jan 2017 20:13:44 +0000
reviewerskats
bugs1318066
milestone53.0a1
Bug 1318066 - Revert the changes for packing the webrender shaders. r=kats? Revert "Bug 1318066 - Provide WR with the path to the resources directory. r=jrmuizel?" This reverts commit 6aeb295d19b80c368cb3a31a096ac76b745797df Revert "Bug 1318066 - Ensure webrender resources are bundled into the Firefox installation. r=jrmuizel?" This reverts commit fdfd418626ad2bedc33a6bd813a3472617a9b1e3 MozReview-Commit-ID: FXSAXK5qsmr
browser/installer/allowed-dupes.mn
browser/installer/package-manifest.in
gfx/layers/ipc/CompositorBridgeChild.cpp
gfx/layers/ipc/CompositorBridgeChild.h
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/CompositorBridgeParent.h
gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
gfx/layers/ipc/CrossProcessCompositorBridgeParent.h
gfx/layers/ipc/PCompositorBridge.ipdl
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderBridgeParent.h
gfx/layers/wr/WebRenderLayerManager.cpp
gfx/moz.build
gfx/webrender/src/bindings.rs
gfx/webrender/webrender.h
--- a/browser/installer/allowed-dupes.mn
+++ b/browser/installer/allowed-dupes.mn
@@ -219,11 +219,8 @@ res/table-remove-column-hover.gif
 res/table-remove-column.gif
 res/table-remove-row-active.gif
 res/table-remove-row-hover.gif
 res/table-remove-row.gif
 # Aurora branding
 browser/chrome/browser/content/browser/defaultthemes/devedition.icon.png
 browser/chrome/browser/content/branding/icon64.png
 browser/chrome/devtools/content/framework/dev-edition-promo/dev-edition-logo.png
-webrender/ps_clear.glsl
-webrender/ps_gradient.glsl
-webrender/ps_gradient_clip.glsl
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -814,16 +814,11 @@ bin/libfreebl_32int64_3.so
 @RESPATH@/gmp-clearkey/0.1/clearkey.info
 
 ; gfx
 #ifdef XP_WIN
 @RESPATH@/components/GfxSanityTest.manifest
 @RESPATH@/components/SanityTest.js
 #endif
 
-; webrender
-#ifdef MOZ_ENABLE_WEBRENDER
-@RESPATH@/webrender/*
-#endif
-
 #ifdef MOZ_MULET
 #include ../../b2g/installer/package-manifest.in
 #endif
--- a/gfx/layers/ipc/CompositorBridgeChild.cpp
+++ b/gfx/layers/ipc/CompositorBridgeChild.cpp
@@ -1141,18 +1141,17 @@ CompositorBridgeChild::WillEndTransactio
 
 void
 CompositorBridgeChild::HandleFatalError(const char* aName, const char* aMsg) const
 {
   dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aName, aMsg, OtherPid());
 }
 
 PWebRenderBridgeChild*
-CompositorBridgeChild::AllocPWebRenderBridgeChild(const uint64_t& aPipelineId,
-                                                  const nsString& aResourcePath)
+CompositorBridgeChild::AllocPWebRenderBridgeChild(const uint64_t& aPipelineId)
 {
   WebRenderBridgeChild* child = new WebRenderBridgeChild(aPipelineId);
   child->AddRef();
   return child;
 }
 
 bool
 CompositorBridgeChild::DeallocPWebRenderBridgeChild(PWebRenderBridgeChild* aActor)
--- a/gfx/layers/ipc/CompositorBridgeChild.h
+++ b/gfx/layers/ipc/CompositorBridgeChild.h
@@ -223,18 +223,17 @@ public:
 
   PAPZChild* AllocPAPZChild(const uint64_t& aLayersId) override;
   bool DeallocPAPZChild(PAPZChild* aActor) override;
 
   void ProcessingError(Result aCode, const char* aReason) override;
 
   void WillEndTransaction();
 
-  PWebRenderBridgeChild* AllocPWebRenderBridgeChild(const uint64_t& aPipelineId,
-                                                    const nsString& aResourcePath) override;
+  PWebRenderBridgeChild* AllocPWebRenderBridgeChild(const uint64_t& aPipelineId) override;
   bool DeallocPWebRenderBridgeChild(PWebRenderBridgeChild* aActor) override;
 
 private:
   // Private destructor, to discourage deletion outside of Release():
   virtual ~CompositorBridgeChild();
 
   void InitIPDL();
   void DeallocPCompositorBridgeChild() override;
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -1837,30 +1837,29 @@ CompositorBridgeParent::RecvAdoptChild(c
 
   if (mApzcTreeManager && parent) {
     parent->ChildAdopted(mApzcTreeManager);
   }
   return IPC_OK();
 }
 
 PWebRenderBridgeParent*
-CompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId,
-                                                    const nsString& aResourcePath)
+CompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId)
 {
 #ifndef MOZ_ENABLE_WEBRENDER
   // Extra guard since this in the parent process and we don't want a malicious
   // child process invoking this codepath before it's ready
   MOZ_RELEASE_ASSERT(false);
 #endif
   MOZ_ASSERT(aPipelineId == mRootLayerTreeID);
 
   RefPtr<gl::GLContext> glc(gl::GLContextProvider::CreateForCompositorWidget(mWidget, true));
   RefPtr<Compositor> compositor = new WebRenderCompositorOGL(glc.get());
   WebRenderBridgeParent* parent = new WebRenderBridgeParent(aPipelineId,
-        &aResourcePath, mWidget, glc.get(), nullptr, compositor.get());
+        mWidget, glc.get(), nullptr, compositor.get());
   parent->AddRef(); // IPDL reference
   MonitorAutoLock lock(*sIndirectLayerTreesLock);
   MOZ_ASSERT(sIndirectLayerTrees[aPipelineId].mWRBridge == nullptr);
   sIndirectLayerTrees[aPipelineId].mWRBridge = parent;
   return parent;
 }
 
 bool
--- a/gfx/layers/ipc/CompositorBridgeParent.h
+++ b/gfx/layers/ipc/CompositorBridgeParent.h
@@ -534,18 +534,17 @@ public:
   mozilla::ipc::IPCResult RecvAsyncPanZoomEnabled(const uint64_t& aLayersId, bool* aHasAPZ) override;
 
   RefPtr<APZCTreeManager> GetAPZCTreeManager();
 
   bool AsyncPanZoomEnabled() const {
     return !!mApzcTreeManager;
   }
 
-  PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const uint64_t& aPipelineId,
-                                                      const nsString& aResourcePath) override;
+  PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const uint64_t& aPipelineId) override;
   bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
 
 private:
 
   void Initialize();
 
   /**
    * Called during destruction in order to release resources as early as possible.
--- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
@@ -243,18 +243,17 @@ bool
 CrossProcessCompositorBridgeParent::DeallocPAPZParent(PAPZParent* aActor)
 {
   RemoteContentController* controller = static_cast<RemoteContentController*>(aActor);
   controller->Release();
   return true;
 }
 
 PWebRenderBridgeParent*
-CrossProcessCompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId,
-                                                                const nsString& aResourcePath)
+CrossProcessCompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId)
 {
 #ifndef MOZ_ENABLE_WEBRENDER
   // Extra guard since this in the parent process and we don't want a malicious
   // child process invoking this codepath before it's ready
   MOZ_RELEASE_ASSERT(false);
 #endif
   // Check to see if this child process has access to this layer tree.
   if (!LayerTreeOwnerTracker::Get()->IsMapped(aPipelineId, OtherPid())) {
@@ -264,17 +263,17 @@ CrossProcessCompositorBridgeParent::Allo
 
   MonitorAutoLock lock(*sIndirectLayerTreesLock);
   MOZ_ASSERT(sIndirectLayerTrees.find(aPipelineId) != sIndirectLayerTrees.end());
   MOZ_ASSERT(sIndirectLayerTrees[aPipelineId].mWRBridge == nullptr);
   CompositorBridgeParent* cbp = sIndirectLayerTrees[aPipelineId].mParent;
   WebRenderBridgeParent* root = sIndirectLayerTrees[cbp->RootLayerTreeId()].mWRBridge.get();
 
   WebRenderBridgeParent* parent = new WebRenderBridgeParent(
-    aPipelineId, nullptr, nullptr, root->GLContext(), root->WindowState(), root->Compositor());
+    aPipelineId, nullptr, root->GLContext(), root->WindowState(), root->Compositor());
   parent->AddRef(); // IPDL reference
   sIndirectLayerTrees[aPipelineId].mWRBridge = parent;
 
   return parent;
 }
 
 bool
 CrossProcessCompositorBridgeParent::DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor)
--- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h
+++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h
@@ -148,18 +148,17 @@ public:
   virtual PAPZCTreeManagerParent* AllocPAPZCTreeManagerParent(const uint64_t& aLayersId) override;
   virtual bool DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor) override;
 
   virtual PAPZParent* AllocPAPZParent(const uint64_t& aLayersId) override;
   virtual bool DeallocPAPZParent(PAPZParent* aActor) override;
 
   virtual void UpdatePaintTime(LayerTransactionParent* aLayerTree, const TimeDuration& aPaintTime) override;
 
-  PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const uint64_t& aPipelineId,
-                                                      const nsString& aResourcePath) override;
+  PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const uint64_t& aPipelineId) override;
   bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
 
 protected:
   void OnChannelConnected(int32_t pid) override {
     mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
   }
 private:
   // Private destructor, to discourage deletion outside of Release():
--- a/gfx/layers/ipc/PCompositorBridge.ipdl
+++ b/gfx/layers/ipc/PCompositorBridge.ipdl
@@ -226,17 +226,17 @@ parent:
    */
   async AllPluginsCaptured();
 
   async PTexture(SurfaceDescriptor aSharedData, LayersBackend aBackend, TextureFlags aTextureFlags, uint64_t id, uint64_t aSerial);
 
   sync SyncWithCompositor();
 
   // The pipelineId is the same as the layersId
-  async PWebRenderBridge(uint64_t pipelineId, nsString resourcePath);
+  async PWebRenderBridge(uint64_t pipelineId);
 
 child:
   // Send back Compositor Frame Metrics from APZCs so tiled layers can
   // update progressively.
   async SharedCompositorFrameMetrics(Handle metrics, CrossProcessMutexHandle mutex, uint64_t aLayersId, uint32_t aAPZCId);
   async ReleaseSharedCompositorFrameMetrics(ViewID aId, uint32_t aAPZCId);
 };
 
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -10,17 +10,16 @@
 #include "GLContextProvider.h"
 #include "mozilla/layers/Compositor.h"
 #include "mozilla/widget/CompositorWidget.h"
 
 namespace mozilla {
 namespace layers {
 
 WebRenderBridgeParent::WebRenderBridgeParent(const uint64_t& aPipelineId,
-                                             const nsString* aResourcePath,
                                              widget::CompositorWidget* aWidget,
                                              gl::GLContext* aGlContext,
                                              wrwindowstate* aWrWindowState,
                                              layers::Compositor* aCompositor)
   : mPipelineId(aPipelineId)
   , mWidget(aWidget)
   , mWRState(nullptr)
   , mGLContext(aGlContext)
@@ -29,19 +28,17 @@ WebRenderBridgeParent::WebRenderBridgePa
 {
   MOZ_ASSERT(mGLContext);
   MOZ_ASSERT(mCompositor);
   if (!mWRWindowState) {
     // mWRWindowState should only be null for the root WRBP of a layers tree,
     // i.e. the one created by the CompositorBridgeParent as opposed to the
     // CrossProcessCompositorBridgeParent
     MOZ_ASSERT(mWidget);
-    MOZ_ASSERT(aResourcePath);
-    mWRWindowState = wr_init_window(mPipelineId,
-                                    NS_ConvertUTF16toUTF8(*aResourcePath).get());
+    mWRWindowState = wr_init_window(mPipelineId);
   }
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvCreate(const uint32_t& aWidth,
                                   const uint32_t& aHeight)
 {
   if (mWRState) {
--- a/gfx/layers/wr/WebRenderBridgeParent.h
+++ b/gfx/layers/wr/WebRenderBridgeParent.h
@@ -26,17 +26,16 @@ namespace layers {
 class Compositor;
 
 class WebRenderBridgeParent final : public PWebRenderBridgeParent
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebRenderBridgeParent)
 
 public:
   WebRenderBridgeParent(const uint64_t& aPipelineId,
-                        const nsString* aResourcePath,
                         widget::CompositorWidget* aWidget,
                         gl::GLContext* aGlContext,
                         wrwindowstate* aWrWindowState,
                         layers::Compositor* aCompositor);
   uint64_t PipelineId() { return mPipelineId; }
   gl::GLContext* GLContext() { return mGLContext.get(); }
   wrwindowstate* WindowState() { return mWRWindowState; }
   layers::Compositor* Compositor() { return mCompositor.get(); }
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -6,18 +6,16 @@
 #include "WebRenderLayerManager.h"
 
 #include "apz/src/AsyncPanZoomController.h"
 #include "LayersLogging.h"
 #include "mozilla/layers/APZCTreeManager.h"
 #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"
 #include "WebRenderColorLayer.h"
 #include "WebRenderContainerLayer.h"
 #include "WebRenderImageLayer.h"
 #include "WebRenderPaintedLayer.h"
 #include "webrender.h"
@@ -140,30 +138,17 @@ WebRenderLayerManager::WebRenderLayerMan
 {
 }
 
 void
 WebRenderLayerManager::Initialize(PCompositorBridgeChild* aCBChild, uint64_t aLayersId)
 {
   MOZ_ASSERT(mWRChild == nullptr);
 
-  // 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);
+  PWebRenderBridgeChild* bridge = aCBChild->SendPWebRenderBridgeConstructor(aLayersId);
   MOZ_ASSERT(bridge);
   mWRChild = static_cast<WebRenderBridgeChild*>(bridge);
   LayoutDeviceIntSize size = mWidget->GetClientSize();
   WRBridge()->SendCreate(size.width, size.height);
 }
 
 void
 WebRenderLayerManager::Destroy()
--- a/gfx/moz.build
+++ b/gfx/moz.build
@@ -21,72 +21,16 @@ DIRS += [
     'thebes',
     'ipc',
     'vr',
     'config',
 ]
 
 EXPORTS += ['webrender/webrender.h']
 
-if CONFIG['MOZ_ENABLE_WEBRENDER']:
-    FINAL_TARGET_FILES.webrender += [
-        'webrender/res/blur.fs.glsl',
-        'webrender/res/blur.vs.glsl',
-        'webrender/res/clip_shared.glsl',
-        'webrender/res/cs_box_shadow.fs.glsl',
-        'webrender/res/cs_box_shadow.glsl',
-        'webrender/res/cs_box_shadow.vs.glsl',
-        'webrender/res/debug_color.fs.glsl',
-        'webrender/res/debug_color.vs.glsl',
-        'webrender/res/debug_font.fs.glsl',
-        'webrender/res/debug_font.vs.glsl',
-        'webrender/res/prim_shared.glsl',
-        'webrender/res/ps_angle_gradient.fs.glsl',
-        'webrender/res/ps_angle_gradient.glsl',
-        'webrender/res/ps_angle_gradient.vs.glsl',
-        'webrender/res/ps_blend.fs.glsl',
-        'webrender/res/ps_blend.glsl',
-        'webrender/res/ps_blend.vs.glsl',
-        'webrender/res/ps_border.fs.glsl',
-        'webrender/res/ps_border.glsl',
-        'webrender/res/ps_border.vs.glsl',
-        'webrender/res/ps_box_shadow.fs.glsl',
-        'webrender/res/ps_box_shadow.glsl',
-        'webrender/res/ps_box_shadow.vs.glsl',
-        'webrender/res/ps_clear.fs.glsl',
-        'webrender/res/ps_clear.glsl',
-        'webrender/res/ps_clear.vs.glsl',
-        'webrender/res/ps_composite.fs.glsl',
-        'webrender/res/ps_composite.glsl',
-        'webrender/res/ps_composite.vs.glsl',
-        'webrender/res/ps_gradient.fs.glsl',
-        'webrender/res/ps_gradient.glsl',
-        'webrender/res/ps_gradient.vs.glsl',
-        'webrender/res/ps_gradient_clip.fs.glsl',
-        'webrender/res/ps_gradient_clip.glsl',
-        'webrender/res/ps_gradient_clip.vs.glsl',
-        'webrender/res/ps_image.fs.glsl',
-        'webrender/res/ps_image.glsl',
-        'webrender/res/ps_image.vs.glsl',
-        'webrender/res/ps_image_clip.fs.glsl',
-        'webrender/res/ps_image_clip.glsl',
-        'webrender/res/ps_image_clip.vs.glsl',
-        'webrender/res/ps_rectangle.fs.glsl',
-        'webrender/res/ps_rectangle.glsl',
-        'webrender/res/ps_rectangle.vs.glsl',
-        'webrender/res/ps_rectangle_clip.fs.glsl',
-        'webrender/res/ps_rectangle_clip.glsl',
-        'webrender/res/ps_rectangle_clip.vs.glsl',
-        'webrender/res/ps_text_run.fs.glsl',
-        'webrender/res/ps_text_run.glsl',
-        'webrender/res/ps_text_run.vs.glsl',
-        'webrender/res/shared.glsl',
-        'webrender/res/shared_other.glsl',
-    ]
-
 if CONFIG['MOZ_ENABLE_SKIA']:
     DIRS += ['skia']
 
 if CONFIG['ENABLE_TESTS']:
     DIRS += ['tests/gtest']
 
 TEST_DIRS += ['tests']
 
--- a/gfx/webrender/src/bindings.rs
+++ b/gfx/webrender/src/bindings.rs
@@ -6,17 +6,17 @@ extern crate webrender_traits;
 use euclid::{Size2D, Point2D, Rect, Matrix4D};
 use gleam::gl;
 use std::ffi::CStr;
 use webrender_traits::{ServoScrollRootId};
 use webrender_traits::{Epoch, ColorF};
 use webrender_traits::{ImageFormat, ImageKey, ImageMask, ImageRendering, RendererKind};
 use std::mem;
 use std::slice;
-use std::os::raw::{c_char, c_uchar};
+use std::os::raw::c_uchar;
 
 #[cfg(target_os = "linux")]
 mod linux {
     use std::mem;
     use std::os::raw::{c_void, c_char, c_int};
     use std::ffi::CString;
 
     //pub const RTLD_LAZY: c_int = 0x001;
@@ -210,20 +210,19 @@ pub struct WrWindowState {
 pub struct WrState {
     size: (u32, u32),
     pipeline_id: PipelineId,
     z_index: i32,
     frame_builder: WebRenderFrameBuilder,
 }
 
 #[no_mangle]
-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()
-    };
+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");
 
     let library = GlLibrary::new();
     gl::load_with(|symbol| library.query(symbol));
     gl::clear_color(0.3, 0.0, 0.0, 1.0);
 
     let version = unsafe {
         let data = CStr::from_ptr(gl::GetString(gl::VERSION) as *const _).to_bytes().to_vec();
         String::from_utf8(data).unwrap()
@@ -525,9 +524,9 @@ pub extern fn wr_readback_buffer(width: 
 
 #[no_mangle]
 pub extern fn wr_free_buffer(vec_ptr: *mut c_uchar, length: u32, capacity: u32)
 {
     // note that vec_ptr loses its const here because we're doing unsafe things.
     unsafe {
         let rebuilt = Vec::from_raw_parts(vec_ptr, length as usize, capacity as usize);
     }
-}
+}
\ No newline at end of file
--- a/gfx/webrender/webrender.h
+++ b/gfx/webrender/webrender.h
@@ -55,17 +55,17 @@ struct wrstate;
 #  define WR_INLINE
 #  define WR_FUNC
 #else
 #  define WR_INLINE inline
 #  define WR_FUNC { MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("WebRender disabled"); }
 #endif
 
 WR_INLINE wrwindowstate*
-wr_init_window(uint64_t root_pipeline_id, const char* path_utf8)
+wr_init_window(uint64_t root_pipeline_id)
 WR_FUNC;
 
 WR_INLINE wrstate*
 wr_create(wrwindowstate* wrWindow, uint32_t width, uint32_t height, uint64_t layers_id)
 WR_FUNC;
 
 WR_INLINE void
 wr_destroy(wrstate* wrstate)