gfx/webrender_bindings/RenderCompositor.cpp
author Ehsan Akhgari <ehsan@mozilla.com>
Fri, 22 Feb 2019 14:25:04 +0000
changeset 460581 045d790ca417fc6e827b57eef8ec5aea2beef81a
parent 459395 a031c9dd9dd5d0d90ca56bfbe6c6ded1a2fadf44
child 461889 5b5e6a9942777d6faee07db57fd6b14d465b3ab3
permissions -rw-r--r--
Bug 1529780 - Compute ImageCacheKey's hash number lazily; r=tnikkel Differential Revision: https://phabricator.services.mozilla.com/D20746

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "RenderCompositor.h"

#include "GLContext.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/layers/SyncObject.h"
#include "mozilla/webrender/RenderCompositorOGL.h"
#include "mozilla/widget/CompositorWidget.h"

#ifdef XP_WIN
#  include "mozilla/webrender/RenderCompositorANGLE.h"
#endif

#ifdef MOZ_WAYLAND
#  include "mozilla/webrender/RenderCompositorEGL.h"
#endif

namespace mozilla {
namespace wr {

/* static */ UniquePtr<RenderCompositor> RenderCompositor::Create(
    RefPtr<widget::CompositorWidget>&& aWidget) {
#ifdef XP_WIN
  if (gfx::gfxVars::UseWebRenderANGLE()) {
    return RenderCompositorANGLE::Create(std::move(aWidget));
  }
#endif

#ifdef MOZ_WAYLAND
  UniquePtr<RenderCompositor> eglCompositor =
      RenderCompositorEGL::Create(aWidget);
  if (eglCompositor) {
    return eglCompositor;
  }
#endif

  return RenderCompositorOGL::Create(std::move(aWidget));
}

RenderCompositor::RenderCompositor(RefPtr<widget::CompositorWidget>&& aWidget)
    : mWidget(aWidget) {}

RenderCompositor::~RenderCompositor() {}

bool RenderCompositor::MakeCurrent() { return gl()->MakeCurrent(); }

}  // namespace wr
}  // namespace mozilla