Commit 9cc90612 authored by Mozilla Graphics Team's avatar Mozilla Graphics Team
Browse files

Bug 1317774 - Add non-gfx code needed to use WebRender in gecko. r=gfx

This completes the migration of code from the github branch to the graphics
project repo. At this point all webrender-related code should be disabled
unless --enable-webrender is provided in the mozconfig.

MozReview-Commit-ID: Dea8rxM6UPL
parent e82d29b9
Loading
Loading
Loading
Loading

README.webrender

0 → 100644
+35 −0
Original line number Diff line number Diff line
Step 1: Install/switch to Rust Nightly
    If you don't have it installed, you can install it from https://www.rust-lang.org/en-US/downloads.html
    For Linux/Mac you can do this using rustup, see the curl command at the bottom of the page
    For Windows you can use the MSVC ABI Nightly installer linked to from that download page
    Note: do NOT install rust using ./mach bootstrap, as that will install the stable version and we need Nightly.
          If you have already installed stable rust, make sure it is not in your $PATH

Step 2: Install cmake (required to build servo-freetype-sys)
    For Linux/Mac use your package manager of choice (apt-get/brew/whatever)
    For Windows download the installer from https://cmake.org/download/ (3.6.3 stable confirmed working)

Step 3: Set up environment
    Add the following two lines to your mozconfig:
        ac_add_options --enable-rust
        ac_add_options --enable-webrender
    Ensure rustc, cargo, and cmake are in your $PATH.
        On Windows in the MozillaBuild shell you can run:
            export PATH="$PATH:/c/Program Files/Rust nightly MSVC 1.14/bin:/c/Program Files/CMake/bin"
        to add them to your path assuming you used the default installation options when installing.
        You can also add the export statement to your mozconfig
    The first time you do a build with these changes, you should also run |mach clobber|

Step 4:
    Build using |mach build|


When making changes:
    - Make the changes you want.
    - Run |mach build| or |mach build binaries| as desired.


For a debug webrender build:
    Use a debug mozconfig (ac_add_options --enable-debug)
    You can also use an opt build but make webrender less optimized by putting opt-level=0 in the [profile.release] section of your gfx/webrender/Cargo.toml file
    See also https://groups.google.com/forum/#!topic/mozilla.dev.servo/MbeMcqqO1fs
+8 −5
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/InputAPZContext.h"
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layout/RenderFrameChild.h"
#include "mozilla/layout/RenderFrameParent.h"
#include "mozilla/LookAndFeel.h"
@@ -2417,8 +2418,8 @@ TabChild::RecvSetDocShellIsActive(const bool& aIsActive,

  MOZ_ASSERT(mPuppetWidget);
  MOZ_ASSERT(mPuppetWidget->GetLayerManager());
  MOZ_ASSERT(mPuppetWidget->GetLayerManager()->GetBackendType() ==
             LayersBackend::LAYERS_CLIENT);
  MOZ_ASSERT(mPuppetWidget->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT
          || mPuppetWidget->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_WR);

  auto clearForcePaint = MakeScopeExit([&] {
    // We might force a paint, or we might already have painted and this is a
@@ -2613,9 +2614,11 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden
        mPuppetWidget->GetLayerManager(
            nullptr, mTextureFactoryIdentifier.mParentBackend)
                ->AsShadowForwarder();
    // As long as we are creating a ClientLayerManager for the puppet widget,
    // lf must be non-null here.
    MOZ_ASSERT(lf);

    LayerManager* lm = mPuppetWidget->GetLayerManager();
    if (lm->AsWebRenderLayerManager()) {
      lm->AsWebRenderLayerManager()->Initialize(compositorChild, aLayersId);
    }

    if (lf) {
      nsTArray<LayersBackend> backends;
+5 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/layers/LayerManagerComposite.h"
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "ClientLayerManager.h"
#include "FrameLayerBuilder.h"

@@ -123,6 +124,10 @@ RenderFrameParent::Init(nsFrameLoader* aFrameLoader)
      if (!lm->AsClientLayerManager()->GetRemoteRenderer()->SendNotifyChildCreated(mLayersId)) {
        return false;
      }
    } else if (lm && lm->AsWebRenderLayerManager()) {
      if (!lm->AsWebRenderLayerManager()->GetCompositorBridgeChild()->SendNotifyChildCreated(mLayersId)) {
        return false;
      }
    }
  } else if (XRE_IsContentProcess()) {
    ContentChild::GetSingleton()->SendAllocateLayerTreeId(browser->Manager()->ChildID(), browser->GetTabId(), &mLayersId);
+9 −2
Original line number Diff line number Diff line
@@ -16,8 +16,12 @@ class nsBaseWidget;

namespace mozilla {
class VsyncObserver;
namespace gl {
class GLContext;
} // namespace gl
namespace layers {
class Compositor;
class LayerManager;
class LayerManagerComposite;
class Compositor;
class Composer2D;
@@ -57,8 +61,11 @@ class WidgetRenderingContext
{
public:
#if defined(XP_MACOSX)
  WidgetRenderingContext() : mLayerManager(nullptr) {}
  WidgetRenderingContext()
    : mLayerManager(nullptr)
    , mGL(nullptr) {}
  layers::LayerManagerComposite* mLayerManager;
  gl::GLContext* mGL;
#elif defined(MOZ_WIDGET_ANDROID)
  WidgetRenderingContext() : mCompositor(nullptr) {}
  layers::Compositor* mCompositor;
@@ -71,7 +78,7 @@ public:
class CompositorWidget
{
public:
  NS_INLINE_DECL_REFCOUNTING(mozilla::widget::CompositorWidget)
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::widget::CompositorWidget)

  /**
   * Create an in-process compositor widget. aWidget may be ignored if the
+2 −0
Original line number Diff line number Diff line
@@ -1165,6 +1165,8 @@ GetLayersBackendName(layers::LayersBackend aBackend)
      return "d3d11";
    case layers::LayersBackend::LAYERS_CLIENT:
      return "client";
    case layers::LayersBackend::LAYERS_WR:
      return "webrender";
    case layers::LayersBackend::LAYERS_BASIC:
      return "basic";
    default:
Loading