2017-01-10 09:17:30 +00: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_WEBRENDERAPI_H
|
|
|
|
#define MOZILLA_LAYERS_WEBRENDERAPI_H
|
|
|
|
|
|
|
|
#include "mozilla/AlreadyAddRefed.h"
|
2017-01-13 10:25:07 +00:00
|
|
|
#include "mozilla/Range.h"
|
2017-01-17 00:22:01 +00:00
|
|
|
#include "mozilla/webrender/webrender_ffi.h"
|
2017-01-17 00:21:52 +00:00
|
|
|
#include "mozilla/webrender/WebRenderTypes.h"
|
2017-01-16 14:22:47 +00:00
|
|
|
#include "Units.h"
|
2017-01-10 09:17:30 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace widget {
|
|
|
|
class CompositorWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace layers {
|
|
|
|
|
2017-01-13 10:25:07 +00:00
|
|
|
class DisplayListBuilder;
|
2017-01-11 12:49:02 +00:00
|
|
|
class CompositorBridgeParentBase;
|
2017-01-10 09:17:30 +00:00
|
|
|
class RendererOGL;
|
2017-01-11 12:51:27 +00:00
|
|
|
class NewRenderer;
|
2017-01-10 09:17:30 +00:00
|
|
|
|
|
|
|
class WebRenderAPI
|
|
|
|
{
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(WebRenderAPI);
|
|
|
|
public:
|
|
|
|
/// Compositor thread only.
|
|
|
|
static already_AddRefed<WebRenderAPI> Create(bool aEnableProfiler,
|
2017-01-11 12:49:02 +00:00
|
|
|
CompositorBridgeParentBase* aBridge,
|
2017-01-10 09:17:30 +00:00
|
|
|
RefPtr<widget::CompositorWidget>&& aWidget);
|
|
|
|
|
|
|
|
gfx::WindowId GetId() const { return mId; }
|
|
|
|
|
2017-01-16 14:22:47 +00:00
|
|
|
void SetRootDisplayList(gfx::Color aBgColor,
|
|
|
|
gfx::Epoch aEpoch,
|
|
|
|
LayerSize aViewportSize,
|
|
|
|
DisplayListBuilder& aBuilder);
|
|
|
|
|
|
|
|
void SetRootPipeline(gfx::PipelineId aPipeline);
|
|
|
|
|
|
|
|
gfx::ImageKey AddImageBuffer(gfx::IntSize aSize,
|
|
|
|
uint32_t aStride,
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
Range<uint8_t> aBytes);
|
|
|
|
|
|
|
|
gfx::ImageKey AddExternalImageHandle(gfx::IntSize aSize,
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
uint64_t aHandle);
|
|
|
|
|
|
|
|
void UpdateImageBuffer(gfx::ImageKey aKey,
|
|
|
|
gfx::IntSize aSize,
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
Range<uint8_t> aBytes);
|
|
|
|
|
|
|
|
void DeleteImage(gfx::ImageKey aKey);
|
|
|
|
|
|
|
|
gfx::FontKey AddRawFont(Range<uint8_t> aBytes);
|
|
|
|
|
|
|
|
void DeleteFont(gfx::FontKey aKey);
|
|
|
|
|
|
|
|
void SetProfilerEnabled(bool aEnabled);
|
|
|
|
|
2017-01-10 09:17:30 +00:00
|
|
|
protected:
|
|
|
|
WebRenderAPI(WrAPI* aRawApi, gfx::WindowId aId)
|
2017-01-16 14:22:47 +00:00
|
|
|
: mWRApi(aRawApi)
|
2017-01-10 09:17:30 +00:00
|
|
|
, mId(aId)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~WebRenderAPI();
|
|
|
|
|
2017-01-16 14:22:47 +00:00
|
|
|
WrAPI* mWRApi;
|
2017-01-10 09:17:30 +00:00
|
|
|
gfx::WindowId mId;
|
2017-01-11 12:51:27 +00:00
|
|
|
|
|
|
|
friend class NewRenderer;
|
2017-01-13 10:25:07 +00:00
|
|
|
friend class DisplayListBuilder;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// This is a simple C++ wrapper around WRState defined in the rust bindings.
|
|
|
|
/// We may want to turn this into a direct wrapper on top of WebRenderFrameBuilder
|
|
|
|
/// instead, so the interface may change a bit.
|
|
|
|
class DisplayListBuilder {
|
|
|
|
public:
|
|
|
|
DisplayListBuilder(const LayerIntSize& aSize, gfx::PipelineId aId);
|
|
|
|
DisplayListBuilder(DisplayListBuilder&&) = default;
|
|
|
|
|
|
|
|
~DisplayListBuilder();
|
|
|
|
|
|
|
|
void Begin(const LayerIntSize& aSize);
|
|
|
|
|
|
|
|
void End(WebRenderAPI& aApi, gfx::Epoch aEpoch);
|
|
|
|
|
|
|
|
void PushStackingContext(const WRRect& aBounds, // TODO: We should work with strongly typed rects
|
|
|
|
const WRRect& aOverflow,
|
|
|
|
const WRImageMask* aMask, // TODO: needs a wrapper.
|
|
|
|
const gfx::Matrix4x4& aTransform);
|
|
|
|
|
|
|
|
void PopStackingContext();
|
|
|
|
|
|
|
|
void PushRect(const WRRect& aBounds,
|
|
|
|
const WRRect& aClip,
|
|
|
|
const gfx::Color& aColor);
|
|
|
|
|
|
|
|
void PushImage(const WRRect& aBounds,
|
|
|
|
const WRRect& aClip,
|
|
|
|
const WRImageMask* aMask,
|
2017-01-13 17:59:07 +00:00
|
|
|
const WRTextureFilter aFilter,
|
2017-01-13 10:25:07 +00:00
|
|
|
WRImageKey aImage);
|
|
|
|
|
|
|
|
void PushIFrame(const WRRect& aBounds,
|
|
|
|
const WRRect& aClip,
|
|
|
|
gfx::PipelineId aPipeline);
|
|
|
|
|
|
|
|
void PushBorder(const WRRect& bounds,
|
|
|
|
const WRRect& clip,
|
|
|
|
const WRBorderSide& top,
|
|
|
|
const WRBorderSide& right,
|
|
|
|
const WRBorderSide& bottom,
|
|
|
|
const WRBorderSide& left,
|
|
|
|
const WRLayoutSize& top_left_radius,
|
|
|
|
const WRLayoutSize& top_right_radius,
|
|
|
|
const WRLayoutSize& bottom_left_radius,
|
|
|
|
const WRLayoutSize& bottom_right_radius);
|
|
|
|
|
|
|
|
void PushText(const WRRect& aBounds,
|
|
|
|
const WRRect& aClip,
|
|
|
|
const gfx::Color& aColor,
|
|
|
|
gfx::FontKey aFontKey,
|
|
|
|
Range<const WRGlyphInstance> aGlyphBuffer,
|
|
|
|
float aGlyphSize);
|
|
|
|
|
|
|
|
// Try to avoid using this when possible.
|
|
|
|
WRState* Raw() { return mWRState; }
|
|
|
|
protected:
|
|
|
|
WRState* mWRState;
|
2017-01-16 14:22:47 +00:00
|
|
|
|
|
|
|
friend class WebRenderAPI;
|
2017-01-10 09:17:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|