2017-01-06 21:10:15 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 sts=2 ts=8 et tw=99 : */
|
|
|
|
/* 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_LAYERS_RENDEREROGL_H
|
|
|
|
#define MOZILLA_LAYERS_RENDEREROGL_H
|
|
|
|
|
2017-08-07 13:15:25 +03:00
|
|
|
#include "mozilla/layers/CompositorTypes.h"
|
|
|
|
#include "mozilla/layers/SyncObject.h"
|
2017-01-17 03:21:52 +03:00
|
|
|
#include "mozilla/webrender/RenderThread.h"
|
|
|
|
#include "mozilla/webrender/WebRenderTypes.h"
|
2017-01-17 03:22:01 +03:00
|
|
|
#include "mozilla/webrender/webrender_ffi.h"
|
2017-01-06 21:10:15 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace gfx {
|
|
|
|
class DrawTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace layers {
|
2017-01-11 15:49:02 +03:00
|
|
|
class CompositorBridgeParentBase;
|
2017-01-17 03:22:09 +03:00
|
|
|
}
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
namespace widget {
|
|
|
|
class CompositorWidget;
|
|
|
|
}
|
|
|
|
|
2017-01-17 03:22:09 +03:00
|
|
|
namespace wr {
|
2017-01-06 21:10:15 +03:00
|
|
|
|
2017-03-07 13:37:28 +03:00
|
|
|
class RenderTextureHost;
|
|
|
|
|
2017-01-06 21:10:20 +03:00
|
|
|
/// Owns the WebRender renderer and GL context.
|
|
|
|
///
|
|
|
|
/// There is one renderer per window, all owned by the render thread.
|
|
|
|
/// This class is a similar abstraction to CompositorOGL except that it is used
|
|
|
|
/// on the render thread instead of the compositor thread.
|
2017-01-06 21:10:15 +03:00
|
|
|
class RendererOGL
|
|
|
|
{
|
2017-06-28 02:20:36 +03:00
|
|
|
friend wr::WrExternalImage LockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex);
|
|
|
|
friend void UnlockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex);
|
2017-03-01 12:08:56 +03:00
|
|
|
|
2017-01-06 21:10:15 +03:00
|
|
|
public:
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrExternalImageHandler GetExternalImageHandler();
|
2017-03-01 12:08:56 +03:00
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
/// This can be called on the render thread only.
|
2017-01-06 21:10:15 +03:00
|
|
|
void Update();
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
/// This can be called on the render thread only.
|
2017-01-27 23:30:18 +03:00
|
|
|
bool Render();
|
2017-01-06 21:10:15 +03:00
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
/// This can be called on the render thread only.
|
2017-01-06 21:10:15 +03:00
|
|
|
bool RenderToTarget(gfx::DrawTarget& aTarget);
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
/// This can be called on the render thread only.
|
2017-01-16 17:22:47 +03:00
|
|
|
void SetProfilerEnabled(bool aEnabled);
|
|
|
|
|
2017-07-28 02:05:56 +03:00
|
|
|
/// This can be called on the render thread only.
|
|
|
|
void SetFrameStartTime(const TimeStamp& aTime);
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
/// This can be called on the render thread only.
|
2017-01-06 21:10:15 +03:00
|
|
|
~RendererOGL();
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
/// This can be called on the render thread only.
|
2017-01-11 15:51:27 +03:00
|
|
|
RendererOGL(RefPtr<RenderThread>&& aThread,
|
|
|
|
RefPtr<gl::GLContext>&& aGL,
|
|
|
|
RefPtr<widget::CompositorWidget>&&,
|
2017-01-17 03:22:09 +03:00
|
|
|
wr::WindowId aWindowId,
|
2017-07-19 10:28:58 +03:00
|
|
|
wr::Renderer* aRenderer,
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::CompositorBridgeParentBase* aBridge);
|
2017-01-25 00:06:17 +03:00
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
/// This can be called on the render thread only.
|
|
|
|
void Pause();
|
|
|
|
|
|
|
|
/// This can be called on the render thread only.
|
|
|
|
bool Resume();
|
|
|
|
|
2017-08-07 13:15:25 +03:00
|
|
|
layers::SyncObjectHost* GetSyncObject() const { return mSyncObject.get(); }
|
|
|
|
|
2017-01-27 23:30:18 +03:00
|
|
|
layers::CompositorBridgeParentBase* GetCompositorBridge() { return mBridge; }
|
|
|
|
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrRenderedEpochs* FlushRenderedEpochs();
|
2017-01-27 23:30:18 +03:00
|
|
|
|
2017-06-28 02:20:36 +03:00
|
|
|
RenderTextureHost* GetRenderTexture(wr::WrExternalImageId aExternalImageId);
|
2017-03-07 13:37:28 +03:00
|
|
|
|
2017-07-19 10:28:58 +03:00
|
|
|
wr::Renderer* GetRenderer() { return mRenderer; }
|
2017-03-20 19:10:40 +03:00
|
|
|
|
2017-01-11 15:51:27 +03:00
|
|
|
protected:
|
2017-01-06 21:10:15 +03:00
|
|
|
RefPtr<RenderThread> mThread;
|
|
|
|
RefPtr<gl::GLContext> mGL;
|
|
|
|
RefPtr<widget::CompositorWidget> mWidget;
|
2017-07-19 10:28:58 +03:00
|
|
|
wr::Renderer* mRenderer;
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::CompositorBridgeParentBase* mBridge;
|
|
|
|
wr::WindowId mWindowId;
|
2017-07-28 02:05:56 +03:00
|
|
|
TimeStamp mFrameStartTime;
|
2017-08-07 13:15:25 +03:00
|
|
|
RefPtr<layers::SyncObjectHost> mSyncObject;
|
2017-08-23 13:00:37 +03:00
|
|
|
wr::DebugFlags mDebugFlags;
|
2017-01-06 21:10:15 +03:00
|
|
|
};
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|
2017-01-06 21:10:15 +03:00
|
|
|
|
|
|
|
#endif
|