Bug 1339323 - Remove WebRenderCompositorOGL r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Thu, 16 Feb 2017 11:46:31 +0900
changeset 373004 74bf6080eb3a4ac4d34c3304f2bb283e4df4c314
parent 373003 d2b4aa8dde09b73858b7cac79e54868d4ef8b3aa
child 373005 1bb227f80f1902b4d1a12208f1736df2ebb6926c
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1339323
milestone54.0a1
Bug 1339323 - Remove WebRenderCompositorOGL r=nical
gfx/layers/Compositor.h
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/moz.build
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderCompositorOGL.cpp
gfx/layers/wr/WebRenderCompositorOGL.h
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -130,17 +130,16 @@ class CompositingRenderTarget;
 class CompositorBridgeParent;
 class LayerManagerComposite;
 class CompositorOGL;
 class CompositorD3D9;
 class CompositorD3D11;
 class BasicCompositor;
 class TextureHost;
 class TextureReadLock;
-class WebRenderCompositorOGL;
 
 enum SurfaceInitMode
 {
   INIT_MODE_NONE,
   INIT_MODE_CLEAR
 };
 
 /**
@@ -469,17 +468,16 @@ public:
 #endif // MOZ_DUMP_PAINTING
 
   virtual LayersBackend GetBackendType() const = 0;
 
   virtual CompositorOGL* AsCompositorOGL() { return nullptr; }
   virtual CompositorD3D9* AsCompositorD3D9() { return nullptr; }
   virtual CompositorD3D11* AsCompositorD3D11() { return nullptr; }
   virtual BasicCompositor* AsBasicCompositor() { return nullptr; }
-  virtual WebRenderCompositorOGL* AsWebRenderCompositorOGL() { return nullptr; }
 
   /**
    * Each Compositor has a unique ID.
    * This ID is used to keep references to each Compositor in a map accessed
    * from the compositor thread only, so that async compositables can find
    * the right compositor parent and schedule compositing even if the compositor
    * changed.
    */
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -50,17 +50,16 @@
 #include "mozilla/layers/ImageBridgeParent.h"
 #include "mozilla/layers/LayerManagerComposite.h"
 #include "mozilla/layers/LayerTreeOwnerTracker.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/PLayerTransactionParent.h"
 #include "mozilla/layers/RemoteContentController.h"
 #include "mozilla/layers/WebRenderBridgeParent.h"
 #include "mozilla/layers/WebRenderCompositableHolder.h"
-#include "mozilla/layers/WebRenderCompositorOGL.h"
 #include "mozilla/layout/RenderFrameParent.h"
 #include "mozilla/webrender/WebRenderAPI.h"
 #include "mozilla/media/MediaSystemResourceService.h" // for MediaSystemResourceService
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "mozilla/Telemetry.h"
 #ifdef MOZ_WIDGET_GTK
 #include "basic/X11BasicCompositor.h" // for X11BasicCompositor
 #endif
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -205,17 +205,16 @@ EXPORTS.mozilla.layers += [
     'RenderTrace.h',
     'SourceSurfaceSharedData.h',
     'SourceSurfaceVolatileData.h',
     'TextureWrapperImage.h',
     'TransactionIdAllocator.h',
     'wr/WebRenderBridgeChild.h',
     'wr/WebRenderBridgeParent.h',
     'wr/WebRenderCompositableHolder.h',
-    'wr/WebRenderCompositorOGL.h',
     'wr/WebRenderImageHost.h',
     'wr/WebRenderLayerManager.h',
     'wr/WebRenderLayersLogging.h',
     'wr/WebRenderMessageUtils.h',
 ]
 
 if CONFIG['MOZ_X11']:
     EXPORTS.mozilla.layers += [
@@ -392,17 +391,16 @@ UNIFIED_SOURCES += [
     'SourceSurfaceVolatileData.cpp',
     'TextureWrapperImage.cpp',
     'wr/WebRenderBorderLayer.cpp',
     'wr/WebRenderBridgeChild.cpp',
     'wr/WebRenderBridgeParent.cpp',
     'wr/WebRenderCanvasLayer.cpp',
     'wr/WebRenderColorLayer.cpp',
     'wr/WebRenderCompositableHolder.cpp',
-    'wr/WebRenderCompositorOGL.cpp',
     'wr/WebRenderContainerLayer.cpp',
     'wr/WebRenderDisplayItemLayer.cpp',
     'wr/WebRenderImageHost.cpp',
     'wr/WebRenderImageLayer.cpp',
     'wr/WebRenderLayerManager.cpp',
     'wr/WebRenderLayersLogging.cpp',
     'wr/WebRenderPaintedLayer.cpp',
     'wr/WebRenderTextLayer.cpp',
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -13,17 +13,16 @@
 #include "mozilla/layers/Compositor.h"
 #include "mozilla/layers/CompositorBridgeParent.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/layers/CompositorVsyncScheduler.h"
 #include "mozilla/layers/ImageBridgeParent.h"
 #include "mozilla/layers/ImageDataSerializer.h"
 #include "mozilla/layers/TextureHost.h"
 #include "mozilla/layers/WebRenderCompositableHolder.h"
-#include "mozilla/layers/WebRenderCompositorOGL.h"
 #include "mozilla/webrender/RenderThread.h"
 #include "mozilla/widget/CompositorWidget.h"
 
 bool is_in_compositor_thread()
 {
   return mozilla::layers::CompositorThreadHolder::IsInCompositorThread();
 }
 
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderCompositorOGL.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * 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 "WebRenderCompositorOGL.h"
-
-#include "CompositableHost.h"
-#include "GLContext.h"                  // for GLContext
-#include "GLUploadHelpers.h"
-#include "mozilla/layers/CompositorBridgeParent.h"
-#include "mozilla/layers/TextureHost.h"  // for TextureSource, etc
-#include "mozilla/layers/TextureHostOGL.h"  // for TextureSourceOGL, etc
-
-namespace mozilla {
-
-using namespace gfx;
-using namespace gl;
-
-namespace layers {
-
-WebRenderCompositorOGL::WebRenderCompositorOGL(CompositorBridgeParent* aCompositorBridge,
-                                               GLContext* aGLContext)
-  : Compositor(nullptr, nullptr)
-  , mCompositorBridge(aCompositorBridge)
-  , mGLContext(aGLContext)
-  , mDestroyed(false)
-{
-  MOZ_COUNT_CTOR(WebRenderCompositorOGL);
-}
-
-WebRenderCompositorOGL::~WebRenderCompositorOGL()
-{
-  MOZ_COUNT_DTOR(WebRenderCompositorOGL);
-  Destroy();
-}
-
-void
-WebRenderCompositorOGL::Destroy()
-{
-  Compositor::Destroy();
-
-  mCompositableHosts.Clear();
-  mCompositorBridge = nullptr;
-
-  if (!mDestroyed) {
-    mDestroyed = true;
-    CleanupResources();
-  }
-}
-
-void
-WebRenderCompositorOGL::CleanupResources()
-{
-  if (!mGLContext) {
-    return;
-  }
-
-  // On the main thread the Widget will be destroyed soon and calling MakeCurrent
-  // after that could cause a crash (at least with GLX, see bug 1059793), unless
-  // context is marked as destroyed.
-  // There may be some textures still alive that will try to call MakeCurrent on
-  // the context so let's make sure it is marked destroyed now.
-  mGLContext->MarkDestroyed();
-
-  mGLContext = nullptr;
-}
-
-bool
-WebRenderCompositorOGL::Initialize(nsCString* const out_failureReason)
-{
-  MOZ_ASSERT(mGLContext);
-  return true;
-}
-
-already_AddRefed<DataTextureSource>
-WebRenderCompositorOGL::CreateDataTextureSource(TextureFlags aFlags)
-{
-  return nullptr;
-}
-
-bool
-WebRenderCompositorOGL::SupportsPartialTextureUpdate()
-{
-  return CanUploadSubTextures(mGLContext);
-}
-
-int32_t
-WebRenderCompositorOGL::GetMaxTextureSize() const
-{
-  MOZ_ASSERT(mGLContext);
-  GLint texSize = 0;
-  mGLContext->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE,
-                            &texSize);
-  MOZ_ASSERT(texSize != 0);
-  return texSize;
-}
-
-void
-WebRenderCompositorOGL::MakeCurrent(MakeCurrentFlags aFlags) {
-  if (mDestroyed) {
-    NS_WARNING("Call on destroyed layer manager");
-    return;
-  }
-  mGLContext->MakeCurrent(aFlags & ForceMakeCurrent);
-}
-
-void
-WebRenderCompositorOGL::CompositeUntil(TimeStamp aTimeStamp)
-{
-  Compositor::CompositeUntil(aTimeStamp);
-  // We're not really taking advantage of the stored composite-again-time here.
-  // We might be able to skip the next few composites altogether. However,
-  // that's a bit complex to implement and we'll get most of the advantage
-  // by skipping compositing when we detect there's nothing invalid. This is why
-  // we do "composite until" rather than "composite again at".
-  ScheduleComposition();
-}
-
-void
-WebRenderCompositorOGL::AddExternalImageId(uint64_t aExternalImageId, CompositableHost* aHost)
-{
-  MOZ_ASSERT(!mCompositableHosts.Get(aExternalImageId));
-  mCompositableHosts.Put(aExternalImageId, aHost);
-}
-
-void
-WebRenderCompositorOGL::RemoveExternalImageId(uint64_t aExternalImageId)
-{
-  MOZ_ASSERT(mCompositableHosts.Get(aExternalImageId));
-  mCompositableHosts.Remove(aExternalImageId);
-}
-
-void
-WebRenderCompositorOGL::UpdateExternalImages()
-{
-  for (auto iter = mCompositableHosts.Iter(); !iter.Done(); iter.Next()) {
-    RefPtr<CompositableHost>& host = iter.Data();
-    // XXX Change to correct TextrueSource handling here.
-    host->BindTextureSource();
-  }
-}
-
-void
-WebRenderCompositorOGL::ScheduleComposition()
-{
-  MOZ_ASSERT(mCompositorBridge);
-  mCompositorBridge->ScheduleComposition();
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderCompositorOGL.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * 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/. */
-
-#ifndef MOZILLA_GFX_WEBRENDERCOMPOSITOROGL_H
-#define MOZILLA_GFX_WEBRENDERCOMPOSITOROGL_H
-
-#include "GLContextTypes.h"             // for GLContext, etc
-#include "GLDefs.h"                     // for GLuint, LOCAL_GL_TEXTURE_2D, etc
-#include "mozilla/layers/Compositor.h"  // for SurfaceInitMode, Compositor, etc
-#include "nsDataHashtable.h"
-
-namespace mozilla {
-namespace layers {
-
-class CompositableHost;
-class CompositorBridgeParent;
-
-class WebRenderCompositorOGL final : public Compositor
-{
-  typedef mozilla::gl::GLContext GLContext;
-
-public:
-  explicit WebRenderCompositorOGL(CompositorBridgeParent* aCompositorBridge, GLContext* aGLContext);
-
-protected:
-  virtual ~WebRenderCompositorOGL();
-
-public:
-  virtual WebRenderCompositorOGL* AsWebRenderCompositorOGL() override { return this; }
-
-  virtual already_AddRefed<DataTextureSource>
-  CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) override;
-
-  virtual bool Initialize(nsCString* const out_failureReason) override;
-
-  virtual void Destroy() override;
-
-  virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() override
-  {
-    TextureFactoryIdentifier result =
-      TextureFactoryIdentifier(LayersBackend::LAYERS_WR,
-                               XRE_GetProcessType(),
-                               GetMaxTextureSize(),
-                               true,
-                               SupportsPartialTextureUpdate());
-    return result;
-  }
-
-  virtual already_AddRefed<CompositingRenderTarget>
-  CreateRenderTarget(const gfx::IntRect &aRect, SurfaceInitMode aInit) override { return nullptr; }
-
-  virtual already_AddRefed<CompositingRenderTarget>
-  CreateRenderTargetFromSource(const gfx::IntRect &aRect,
-                               const CompositingRenderTarget *aSource,
-                               const gfx::IntPoint &aSourcePoint) override { return nullptr; }
-
-  virtual void SetRenderTarget(CompositingRenderTarget *aSurface) override { }
-
-  virtual CompositingRenderTarget* GetCurrentRenderTarget() const override { return nullptr; }
-
-  virtual void DrawQuad(const gfx::Rect& aRect,
-                        const gfx::IntRect& aClipRect,
-                        const EffectChain &aEffectChain,
-                        gfx::Float aOpacity,
-                        const gfx::Matrix4x4& aTransform,
-                        const gfx::Rect& aVisibleRect) override { }
-
-  virtual void DrawTriangle(const gfx::TexturedTriangle& aTriangle,
-                            const gfx::IntRect& aClipRect,
-                            const EffectChain& aEffectChain,
-                            gfx::Float aOpacity,
-                            const gfx::Matrix4x4& aTransform,
-                            const gfx::Rect& aVisibleRect) override { }
-
-  virtual void ClearRect(const gfx::Rect& aRect) override { }
-
-  virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
-                          const gfx::IntRect *aClipRectIn,
-                          const gfx::IntRect& aRenderBounds,
-                          const nsIntRegion& aOpaqueRegion,
-                          gfx::IntRect *aClipRectOut = nullptr,
-                          gfx::IntRect *aRenderBoundsOut = nullptr) override { }
-
-  virtual void EndFrame() override { }
-
-  virtual bool SupportsPartialTextureUpdate() override;
-
-  virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) override
-  {
-    if (!mGLContext)
-      return false;
-    int32_t maxSize = GetMaxTextureSize();
-    return aSize <= gfx::IntSize(maxSize, maxSize);
-  }
-
-  virtual int32_t GetMaxTextureSize() const override;
-
-  virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) override { }
-  virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) override { }
-
-  virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) override;
-
-#ifdef MOZ_DUMP_PAINTING
-  virtual const char* Name() const override { return "WROGL"; }
-#endif // MOZ_DUMP_PAINTING
-
-  virtual LayersBackend GetBackendType() const override {
-    return LayersBackend::LAYERS_WR;
-  }
-
-  virtual bool IsValid() const override { return true; }
-
-  virtual void CompositeUntil(TimeStamp aTimeStamp) override;
-
-  GLContext* gl() const { return mGLContext; }
-
-  void AddExternalImageId(uint64_t aExternalImageId, CompositableHost* aHost);
-  void RemoveExternalImageId(uint64_t aExternalImageId);
-  void UpdateExternalImages();
-
-  void ScheduleComposition();
-private:
-  void CleanupResources();
-
-  CompositorBridgeParent* MOZ_NON_OWNING_REF mCompositorBridge;
-  RefPtr<GLContext> mGLContext;
-  // Holds CompositableHosts that are bound to external image ids.
-  nsDataHashtable<nsUint64HashKey, RefPtr<CompositableHost> > mCompositableHosts;
-
-  bool mDestroyed;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif /* MOZILLA_GFX_WEBRENDERCOMPOSITOROGL_H */