2017-01-10 12:17:30 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; 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 "WebRenderAPI.h"
|
2017-01-17 03:21:52 +03:00
|
|
|
#include "mozilla/webrender/RendererOGL.h"
|
2017-01-10 12:17:30 +03:00
|
|
|
#include "mozilla/layers/CompositorThread.h"
|
|
|
|
#include "mozilla/widget/CompositorWidget.h"
|
2017-01-11 15:51:27 +03:00
|
|
|
#include "mozilla/widget/CompositorWidget.h"
|
|
|
|
#include "mozilla/layers/SynchronousTask.h"
|
2017-01-10 12:17:30 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
2017-01-17 03:22:09 +03:00
|
|
|
namespace wr {
|
2017-01-10 12:17:30 +03:00
|
|
|
|
|
|
|
class NewRenderer : public RendererEvent
|
|
|
|
{
|
|
|
|
public:
|
2017-01-17 03:22:09 +03:00
|
|
|
NewRenderer(WrAPI** aApi, layers::CompositorBridgeParentBase* aBridge,
|
2017-01-18 22:50:00 +03:00
|
|
|
GLint* aMaxTextureSize,
|
2017-02-23 11:46:56 +03:00
|
|
|
bool* aUseANGLE,
|
2017-01-11 15:51:27 +03:00
|
|
|
RefPtr<widget::CompositorWidget>&& aWidget,
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::SynchronousTask* aTask,
|
2017-03-07 02:46:30 +03:00
|
|
|
bool aEnableProfiler,
|
|
|
|
LayoutDeviceIntSize aSize)
|
2017-01-25 00:06:17 +03:00
|
|
|
: mWrApi(aApi)
|
|
|
|
, mMaxTextureSize(aMaxTextureSize)
|
2017-02-23 11:46:56 +03:00
|
|
|
, mUseANGLE(aUseANGLE)
|
2017-01-25 00:06:17 +03:00
|
|
|
, mBridge(aBridge)
|
|
|
|
, mCompositorWidget(Move(aWidget))
|
|
|
|
, mTask(aTask)
|
|
|
|
, mEnableProfiler(aEnableProfiler)
|
2017-03-07 02:46:30 +03:00
|
|
|
, mSize(aSize)
|
2017-01-10 12:17:30 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(NewRenderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
~NewRenderer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(NewRenderer);
|
|
|
|
}
|
|
|
|
|
2017-01-17 03:22:09 +03:00
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
|
2017-01-10 12:17:30 +03:00
|
|
|
{
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::AutoCompleteTask complete(mTask);
|
2017-01-11 15:51:27 +03:00
|
|
|
|
|
|
|
RefPtr<gl::GLContext> gl = gl::GLContextProvider::CreateForCompositorWidget(mCompositorWidget, true);
|
|
|
|
if (!gl || !gl->MakeCurrent()) {
|
|
|
|
return;
|
2017-01-10 12:17:30 +03:00
|
|
|
}
|
2017-01-11 15:51:27 +03:00
|
|
|
|
2017-01-18 22:50:00 +03:00
|
|
|
gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, mMaxTextureSize);
|
2017-02-23 11:46:56 +03:00
|
|
|
*mUseANGLE = gl->IsANGLE();
|
2017-01-18 22:50:00 +03:00
|
|
|
|
2017-01-11 15:51:27 +03:00
|
|
|
WrRenderer* wrRenderer = nullptr;
|
2017-03-07 02:46:30 +03:00
|
|
|
if (!wr_window_new(aWindowId, mSize.width, mSize.height, gl.get(),
|
|
|
|
this->mEnableProfiler, mWrApi, &wrRenderer)) {
|
2017-02-14 21:34:15 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-01-11 15:51:27 +03:00
|
|
|
MOZ_ASSERT(wrRenderer);
|
|
|
|
|
|
|
|
RefPtr<RenderThread> thread = &aRenderThread;
|
|
|
|
auto renderer = MakeUnique<RendererOGL>(Move(thread),
|
|
|
|
Move(gl),
|
|
|
|
Move(mCompositorWidget),
|
|
|
|
aWindowId,
|
|
|
|
wrRenderer,
|
|
|
|
mBridge);
|
2017-03-01 12:08:56 +03:00
|
|
|
if (wrRenderer && renderer) {
|
|
|
|
WrExternalImageHandler handler = renderer->GetExternalImageHandler();
|
|
|
|
wr_renderer_set_external_image_handler(wrRenderer, &handler);
|
|
|
|
}
|
2017-01-11 15:51:27 +03:00
|
|
|
|
|
|
|
aRenderThread.AddRenderer(aWindowId, Move(renderer));
|
2017-01-10 12:17:30 +03:00
|
|
|
}
|
|
|
|
|
2017-01-25 00:20:54 +03:00
|
|
|
private:
|
2017-01-17 22:48:00 +03:00
|
|
|
WrAPI** mWrApi;
|
2017-01-18 22:50:00 +03:00
|
|
|
GLint* mMaxTextureSize;
|
2017-02-23 11:46:56 +03:00
|
|
|
bool* mUseANGLE;
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::CompositorBridgeParentBase* mBridge;
|
2017-01-10 12:17:30 +03:00
|
|
|
RefPtr<widget::CompositorWidget> mCompositorWidget;
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::SynchronousTask* mTask;
|
2017-01-11 15:51:27 +03:00
|
|
|
bool mEnableProfiler;
|
2017-03-07 02:46:30 +03:00
|
|
|
LayoutDeviceIntSize mSize;
|
2017-01-10 12:17:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class RemoveRenderer : public RendererEvent
|
|
|
|
{
|
|
|
|
public:
|
2017-01-17 03:22:09 +03:00
|
|
|
explicit RemoveRenderer(layers::SynchronousTask* aTask)
|
2017-01-25 00:06:17 +03:00
|
|
|
: mTask(aTask)
|
2017-01-11 15:51:27 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(RemoveRenderer);
|
|
|
|
}
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-11 15:51:27 +03:00
|
|
|
~RemoveRenderer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(RemoveRenderer);
|
|
|
|
}
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-17 03:22:09 +03:00
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
|
2017-01-10 12:17:30 +03:00
|
|
|
{
|
|
|
|
aRenderThread.RemoveRenderer(aWindowId);
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::AutoCompleteTask complete(mTask);
|
2017-01-10 12:17:30 +03:00
|
|
|
}
|
2017-01-11 15:51:27 +03:00
|
|
|
|
2017-01-25 00:20:54 +03:00
|
|
|
private:
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::SynchronousTask* mTask;
|
2017-01-10 12:17:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//static
|
|
|
|
already_AddRefed<WebRenderAPI>
|
|
|
|
WebRenderAPI::Create(bool aEnableProfiler,
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::CompositorBridgeParentBase* aBridge,
|
2017-03-07 02:46:30 +03:00
|
|
|
RefPtr<widget::CompositorWidget>&& aWidget,
|
|
|
|
LayoutDeviceIntSize aSize)
|
2017-01-10 12:17:30 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aBridge);
|
|
|
|
MOZ_ASSERT(aWidget);
|
|
|
|
|
|
|
|
static uint64_t sNextId = 1;
|
2017-02-14 21:34:15 +03:00
|
|
|
auto id = NewWindowId(sNextId++);
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-11 15:51:27 +03:00
|
|
|
WrAPI* wrApi = nullptr;
|
2017-01-18 22:50:00 +03:00
|
|
|
GLint maxTextureSize = 0;
|
2017-02-23 11:46:56 +03:00
|
|
|
bool useANGLE = false;
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-11 15:51:27 +03:00
|
|
|
// Dispatch a synchronous task because the WrApi object needs to be created
|
|
|
|
// on the render thread. If need be we could delay waiting on this task until
|
|
|
|
// the next time we need to access the WrApi object.
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::SynchronousTask task("Create Renderer");
|
2017-02-23 11:46:56 +03:00
|
|
|
auto event = MakeUnique<NewRenderer>(&wrApi, aBridge, &maxTextureSize, &useANGLE,
|
2017-03-07 02:46:30 +03:00
|
|
|
Move(aWidget), &task, aEnableProfiler, aSize);
|
2017-01-11 15:51:27 +03:00
|
|
|
RenderThread::Get()->RunEvent(id, Move(event));
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-11 15:51:27 +03:00
|
|
|
task.Wait();
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-11 15:51:27 +03:00
|
|
|
if (!wrApi) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-02-23 11:46:56 +03:00
|
|
|
return RefPtr<WebRenderAPI>(new WebRenderAPI(wrApi, id, maxTextureSize, useANGLE)).forget();
|
2017-01-10 12:17:30 +03:00
|
|
|
}
|
|
|
|
|
2017-02-22 21:19:57 +03:00
|
|
|
WrIdNamespace
|
|
|
|
WebRenderAPI::GetNamespace() {
|
|
|
|
return wr_api_get_namespace(mWrApi);
|
|
|
|
}
|
|
|
|
|
2017-01-10 12:17:30 +03:00
|
|
|
WebRenderAPI::~WebRenderAPI()
|
|
|
|
{
|
2017-01-17 22:46:31 +03:00
|
|
|
layers::SynchronousTask task("Destroy WebRenderAPI");
|
|
|
|
auto event = MakeUnique<RemoveRenderer>(&task);
|
|
|
|
RunOnRenderThread(Move(event));
|
|
|
|
task.Wait();
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-17 22:48:00 +03:00
|
|
|
wr_api_delete(mWrApi);
|
2017-01-10 12:17:30 +03:00
|
|
|
}
|
|
|
|
|
2017-02-27 03:27:04 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::GenerateFrame()
|
|
|
|
{
|
|
|
|
wr_api_generate_frame(mWrApi);
|
|
|
|
}
|
|
|
|
|
2017-01-16 17:22:47 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::SetRootDisplayList(gfx::Color aBgColor,
|
2017-01-17 03:22:09 +03:00
|
|
|
Epoch aEpoch,
|
2017-01-16 17:22:47 +03:00
|
|
|
LayerSize aViewportSize,
|
2017-03-01 17:10:53 +03:00
|
|
|
WrPipelineId pipeline_id,
|
|
|
|
WrBuiltDisplayListDescriptor dl_descriptor,
|
|
|
|
uint8_t *dl_data,
|
|
|
|
size_t dl_size,
|
|
|
|
WrAuxiliaryListsDescriptor aux_descriptor,
|
|
|
|
uint8_t *aux_data,
|
|
|
|
size_t aux_size)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-03-01 17:10:53 +03:00
|
|
|
wr_api_set_root_display_list(mWrApi,
|
|
|
|
aEpoch,
|
|
|
|
aViewportSize.width, aViewportSize.height,
|
|
|
|
pipeline_id,
|
|
|
|
dl_descriptor,
|
|
|
|
dl_data,
|
|
|
|
dl_size,
|
|
|
|
aux_descriptor,
|
|
|
|
aux_data,
|
|
|
|
aux_size);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-03-06 04:42:17 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::ClearRootDisplayList(Epoch aEpoch,
|
|
|
|
WrPipelineId pipeline_id)
|
|
|
|
{
|
|
|
|
wr_api_clear_root_display_list(mWrApi, aEpoch, pipeline_id);
|
|
|
|
}
|
|
|
|
|
2017-01-16 17:22:47 +03:00
|
|
|
void
|
2017-01-25 07:29:34 +03:00
|
|
|
WebRenderAPI::Readback(gfx::IntSize size,
|
|
|
|
uint8_t *buffer,
|
|
|
|
uint32_t buffer_size)
|
|
|
|
{
|
|
|
|
class Readback : public RendererEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit Readback(layers::SynchronousTask* aTask,
|
|
|
|
gfx::IntSize aSize, uint8_t *aBuffer, uint32_t aBufferSize)
|
|
|
|
: mTask(aTask)
|
|
|
|
, mSize(aSize)
|
|
|
|
, mBuffer(aBuffer)
|
|
|
|
, mBufferSize(aBufferSize)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(Readback);
|
|
|
|
}
|
|
|
|
|
|
|
|
~Readback()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(Readback);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
|
|
|
|
{
|
|
|
|
aRenderThread.UpdateAndRender(aWindowId);
|
2017-02-08 04:28:37 +03:00
|
|
|
wr_renderer_readback(mSize.width, mSize.height, mBuffer, mBufferSize);
|
2017-01-25 07:29:34 +03:00
|
|
|
layers::AutoCompleteTask complete(mTask);
|
|
|
|
}
|
|
|
|
|
|
|
|
layers::SynchronousTask* mTask;
|
|
|
|
gfx::IntSize mSize;
|
|
|
|
uint8_t *mBuffer;
|
|
|
|
uint32_t mBufferSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
layers::SynchronousTask task("Readback");
|
|
|
|
auto event = MakeUnique<Readback>(&task, size, buffer, buffer_size);
|
2017-02-16 06:32:34 +03:00
|
|
|
// This event will be passed from wr_backend thread to renderer thread. That
|
|
|
|
// implies that all frame data have been processed when the renderer runs this
|
|
|
|
// read-back event. Then, we could make sure this read-back event gets the
|
|
|
|
// latest result.
|
2017-01-25 07:29:34 +03:00
|
|
|
RunOnRenderThread(Move(event));
|
|
|
|
|
|
|
|
task.Wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-17 03:22:09 +03:00
|
|
|
WebRenderAPI::SetRootPipeline(PipelineId aPipeline)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-02-14 21:34:15 +03:00
|
|
|
wr_api_set_root_pipeline(mWrApi, aPipeline);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-02-22 21:19:57 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::AddImage(ImageKey key, const ImageDescriptor& aDescritptor,
|
|
|
|
Range<uint8_t> aBytes)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-02-22 21:19:57 +03:00
|
|
|
wr_api_add_image(mWrApi,
|
|
|
|
key,
|
|
|
|
&aDescritptor,
|
|
|
|
&aBytes[0], aBytes.length());
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-03-02 04:22:40 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::AddExternalImageHandle(ImageKey key,
|
|
|
|
gfx::IntSize aSize,
|
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
uint64_t aHandle)
|
|
|
|
{
|
|
|
|
auto format = SurfaceFormatToWrImageFormat(aFormat).value();
|
|
|
|
wr_api_add_external_image_handle(mWrApi,
|
|
|
|
key,
|
|
|
|
aSize.width, aSize.height, format,
|
|
|
|
aHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebRenderAPI::AddExternalImageBuffer(ImageKey key,
|
|
|
|
gfx::IntSize aSize,
|
2017-01-16 17:22:47 +03:00
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
uint64_t aHandle)
|
|
|
|
{
|
2017-01-17 17:53:57 +03:00
|
|
|
auto format = SurfaceFormatToWrImageFormat(aFormat).value();
|
2017-03-02 04:22:40 +03:00
|
|
|
wr_api_add_external_image_buffer(mWrApi,
|
|
|
|
key,
|
|
|
|
aSize.width, aSize.height, format,
|
|
|
|
aHandle);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-17 03:22:09 +03:00
|
|
|
WebRenderAPI::UpdateImageBuffer(ImageKey aKey,
|
2017-02-14 21:34:15 +03:00
|
|
|
const ImageDescriptor& aDescritptor,
|
2017-01-16 17:22:47 +03:00
|
|
|
Range<uint8_t> aBytes)
|
|
|
|
{
|
2017-01-17 22:48:00 +03:00
|
|
|
wr_api_update_image(mWrApi,
|
2017-02-14 21:34:15 +03:00
|
|
|
aKey,
|
|
|
|
&aDescritptor,
|
2017-01-16 17:22:47 +03:00
|
|
|
&aBytes[0], aBytes.length());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-17 03:22:09 +03:00
|
|
|
WebRenderAPI::DeleteImage(ImageKey aKey)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-02-14 21:34:15 +03:00
|
|
|
wr_api_delete_image(mWrApi, aKey);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-02-22 21:19:57 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::AddRawFont(wr::FontKey key, Range<uint8_t> aBytes)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-02-22 21:19:57 +03:00
|
|
|
wr_api_add_raw_font(mWrApi, key, &aBytes[0], aBytes.length());
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-17 03:22:09 +03:00
|
|
|
WebRenderAPI::DeleteFont(wr::FontKey aKey)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
|
|
|
printf("XXX - WebRender does not seem to implement deleting a font! Leaking it...\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
class EnableProfiler : public RendererEvent
|
|
|
|
{
|
|
|
|
public:
|
2017-01-25 00:06:17 +03:00
|
|
|
explicit EnableProfiler(bool aEnabled)
|
|
|
|
: mEnabled(aEnabled)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(EnableProfiler);
|
|
|
|
}
|
|
|
|
|
|
|
|
~EnableProfiler()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(EnableProfiler);
|
|
|
|
}
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2017-01-17 03:22:09 +03:00
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
|
|
|
auto renderer = aRenderThread.GetRenderer(aWindowId);
|
|
|
|
if (renderer) {
|
|
|
|
renderer->SetProfilerEnabled(mEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-25 00:20:54 +03:00
|
|
|
private:
|
2017-01-16 17:22:47 +03:00
|
|
|
bool mEnabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
WebRenderAPI::SetProfilerEnabled(bool aEnabled)
|
|
|
|
{
|
|
|
|
auto event = MakeUnique<EnableProfiler>(aEnabled);
|
2017-01-17 22:46:31 +03:00
|
|
|
RunOnRenderThread(Move(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-28 00:08:17 +03:00
|
|
|
WebRenderAPI::RunOnRenderThread(UniquePtr<RendererEvent> aEvent)
|
2017-01-17 22:46:31 +03:00
|
|
|
{
|
|
|
|
auto event = reinterpret_cast<uintptr_t>(aEvent.release());
|
2017-01-17 22:48:00 +03:00
|
|
|
wr_api_send_external_event(mWrApi, event);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-02-24 00:12:40 +03:00
|
|
|
DisplayListBuilder::DisplayListBuilder(PipelineId aId)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DisplayListBuilder);
|
2017-02-24 00:12:40 +03:00
|
|
|
mWrState = wr_state_new(aId);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayListBuilder::~DisplayListBuilder()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DisplayListBuilder);
|
2017-01-17 17:32:25 +03:00
|
|
|
wr_state_delete(mWrState);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::Begin(const LayerIntSize& aSize)
|
|
|
|
{
|
2017-01-17 17:32:25 +03:00
|
|
|
wr_dp_begin(mWrState, aSize.width, aSize.height);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-02-24 00:12:40 +03:00
|
|
|
DisplayListBuilder::End()
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-02-24 00:12:40 +03:00
|
|
|
wr_dp_end(mWrState);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2017-03-01 17:10:53 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::Finalize(WrBuiltDisplayListDescriptor& dl_descriptor,
|
|
|
|
wr::VecU8& dl_data,
|
|
|
|
WrAuxiliaryListsDescriptor& aux_descriptor,
|
|
|
|
wr::VecU8& aux_data)
|
|
|
|
{
|
|
|
|
wr_api_finalize_builder(mWrState,
|
|
|
|
dl_descriptor,
|
|
|
|
dl_data.inner,
|
|
|
|
aux_descriptor,
|
|
|
|
aux_data.inner);
|
|
|
|
}
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushStackingContext(const WrRect& aBounds,
|
|
|
|
const WrRect& aOverflow,
|
2017-01-17 17:53:57 +03:00
|
|
|
const WrImageMask* aMask,
|
2017-02-02 10:09:09 +03:00
|
|
|
const float aOpacity,
|
2017-01-20 02:57:18 +03:00
|
|
|
const gfx::Matrix4x4& aTransform,
|
|
|
|
const WrMixBlendMode& aMixBlendMode)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-02-02 10:09:09 +03:00
|
|
|
wr_dp_push_stacking_context(mWrState, aBounds, aOverflow, aMask, aOpacity,
|
2017-01-20 02:57:18 +03:00
|
|
|
&aTransform.components[0], aMixBlendMode);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PopStackingContext()
|
|
|
|
{
|
2017-01-17 17:32:25 +03:00
|
|
|
wr_dp_pop_stacking_context(mWrState);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushScrollLayer(const WrRect& aBounds,
|
|
|
|
const WrRect& aOverflow,
|
|
|
|
const WrImageMask* aMask)
|
|
|
|
{
|
|
|
|
wr_dp_push_scroll_layer(mWrState, aBounds, aOverflow, aMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PopScrollLayer()
|
|
|
|
{
|
|
|
|
wr_dp_pop_scroll_layer(mWrState);
|
|
|
|
}
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushRect(const WrRect& aBounds,
|
|
|
|
const WrRect& aClip,
|
2017-02-09 11:49:38 +03:00
|
|
|
const WrColor& aColor)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-02-09 11:49:38 +03:00
|
|
|
wr_dp_push_rect(mWrState, aBounds, aClip, aColor);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2017-02-17 03:51:32 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushLinearGradient(const WrRect& aBounds,
|
|
|
|
const WrRect& aClip,
|
|
|
|
const WrPoint& aStartPoint,
|
|
|
|
const WrPoint& aEndPoint,
|
|
|
|
const nsTArray<WrGradientStop>& aStops,
|
|
|
|
wr::GradientExtendMode aExtendMode)
|
|
|
|
{
|
|
|
|
wr_dp_push_linear_gradient(mWrState,
|
|
|
|
aBounds, aClip,
|
|
|
|
aStartPoint, aEndPoint,
|
|
|
|
aStops.Elements(), aStops.Length(),
|
|
|
|
aExtendMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
|
|
|
|
const WrRect& aClip,
|
|
|
|
const WrPoint& aStartCenter,
|
|
|
|
const WrPoint& aEndCenter,
|
|
|
|
float aStartRadius,
|
|
|
|
float aEndRadius,
|
|
|
|
const nsTArray<WrGradientStop>& aStops,
|
|
|
|
wr::GradientExtendMode aExtendMode)
|
|
|
|
{
|
|
|
|
wr_dp_push_radial_gradient(mWrState,
|
|
|
|
aBounds, aClip,
|
|
|
|
aStartCenter, aEndCenter,
|
|
|
|
aStartRadius, aEndRadius,
|
|
|
|
aStops.Elements(), aStops.Length(),
|
|
|
|
aExtendMode);
|
|
|
|
}
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushImage(const WrRect& aBounds,
|
|
|
|
const WrRect& aClip,
|
2017-01-17 17:53:57 +03:00
|
|
|
const WrImageMask* aMask,
|
2017-02-14 21:34:15 +03:00
|
|
|
wr::ImageRendering aFilter,
|
2017-01-17 22:48:00 +03:00
|
|
|
wr::ImageKey aImage)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-02-14 21:34:15 +03:00
|
|
|
wr_dp_push_image(mWrState, aBounds, aClip, aMask, aFilter, aImage);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushIFrame(const WrRect& aBounds,
|
|
|
|
const WrRect& aClip,
|
2017-01-17 03:22:09 +03:00
|
|
|
PipelineId aPipeline)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-02-14 21:34:15 +03:00
|
|
|
wr_dp_push_iframe(mWrState, aBounds, aClip, aPipeline);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushBorder(const WrRect& aBounds,
|
|
|
|
const WrRect& aClip,
|
2017-01-17 17:53:57 +03:00
|
|
|
const WrBorderSide& aTop,
|
|
|
|
const WrBorderSide& aRight,
|
|
|
|
const WrBorderSide& aBottom,
|
|
|
|
const WrBorderSide& aLeft,
|
2017-02-09 11:49:37 +03:00
|
|
|
const WrBorderRadius& aRadius)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-01-17 17:32:25 +03:00
|
|
|
wr_dp_push_border(mWrState, aBounds, aClip,
|
2017-01-13 13:25:07 +03:00
|
|
|
aTop, aRight, aBottom, aLeft,
|
2017-02-09 11:49:37 +03:00
|
|
|
aRadius);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushText(const WrRect& aBounds,
|
|
|
|
const WrRect& aClip,
|
2017-01-13 13:25:07 +03:00
|
|
|
const gfx::Color& aColor,
|
2017-01-17 03:22:09 +03:00
|
|
|
wr::FontKey aFontKey,
|
2017-01-24 16:44:23 +03:00
|
|
|
Range<const WrGlyphInstance> aGlyphBuffer,
|
2017-01-13 13:25:07 +03:00
|
|
|
float aGlyphSize)
|
|
|
|
{
|
2017-01-17 17:32:25 +03:00
|
|
|
wr_dp_push_text(mWrState, aBounds, aClip,
|
2017-01-17 17:44:07 +03:00
|
|
|
ToWrColor(aColor),
|
2017-02-14 21:34:15 +03:00
|
|
|
aFontKey,
|
2017-01-13 13:25:07 +03:00
|
|
|
&aGlyphBuffer[0], aGlyphBuffer.length(),
|
|
|
|
aGlyphSize);
|
|
|
|
}
|
|
|
|
|
2017-02-16 21:23:22 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushBoxShadow(const WrRect& aRect,
|
|
|
|
const WrRect& aClip,
|
|
|
|
const WrRect& aBoxBounds,
|
|
|
|
const WrPoint& aOffset,
|
|
|
|
const WrColor& aColor,
|
|
|
|
const float& aBlurRadius,
|
|
|
|
const float& aSpreadRadius,
|
|
|
|
const float& aBorderRadius,
|
|
|
|
const WrBoxShadowClipMode& aClipMode)
|
|
|
|
{
|
|
|
|
wr_dp_push_box_shadow(mWrState, aRect, aClip,
|
|
|
|
aBoxBounds, aOffset, aColor,
|
|
|
|
aBlurRadius, aSpreadRadius, aBorderRadius,
|
|
|
|
aClipMode);
|
|
|
|
}
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|