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-05-29 18:40:49 +03:00
|
|
|
#include "LayersLogging.h"
|
2017-01-17 03:21:52 +03:00
|
|
|
#include "mozilla/webrender/RendererOGL.h"
|
2017-03-29 17:14:19 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.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
|
|
|
|
2017-05-29 18:40:49 +03:00
|
|
|
#define WRDL_LOG(...)
|
|
|
|
//#define WRDL_LOG(...) printf_stderr("WRDL: " __VA_ARGS__)
|
|
|
|
|
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
|
|
|
|
2017-05-29 18:40:49 +03:00
|
|
|
using layers::Stringify;
|
|
|
|
|
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
|
|
|
|
2017-03-29 17:14:19 +03:00
|
|
|
RefPtr<gl::GLContext> gl;
|
2017-03-31 17:29:14 +03:00
|
|
|
if (gfx::gfxVars::UseWebRenderANGLE()) {
|
2017-03-29 17:14:19 +03:00
|
|
|
gl = gl::GLContextProviderEGL::CreateForCompositorWidget(mCompositorWidget, true);
|
|
|
|
if (!gl || !gl->IsANGLE()) {
|
2017-03-31 17:29:14 +03:00
|
|
|
gfxCriticalNote << "Failed ANGLE GL context creation for WebRender: " << gfx::hexa(gl.get());
|
2017-03-29 17:14:19 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!gl) {
|
|
|
|
gl = gl::GLContextProvider::CreateForCompositorWidget(mCompositorWidget, true);
|
|
|
|
}
|
2017-01-11 15:51:27 +03:00
|
|
|
if (!gl || !gl->MakeCurrent()) {
|
2017-03-31 17:29:14 +03:00
|
|
|
gfxCriticalNote << "Failed GL context creation for WebRender: " << gfx::hexa(gl.get());
|
2017-01-11 15:51:27 +03:00
|
|
|
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-03-27 21:32:39 +03:00
|
|
|
// wr_window_new puts a message into gfxCriticalNote if it returns false
|
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-05-12 20:58:20 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::UpdateScrollPosition(const WrPipelineId& aPipelineId,
|
|
|
|
const layers::FrameMetrics::ViewID& aScrollId,
|
|
|
|
const WrPoint& aScrollPosition)
|
|
|
|
{
|
|
|
|
wr_scroll_layer_with_id(mWrApi, aPipelineId, aScrollId, aScrollPosition);
|
|
|
|
}
|
|
|
|
|
2017-02-27 03:27:04 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::GenerateFrame()
|
|
|
|
{
|
|
|
|
wr_api_generate_frame(mWrApi);
|
|
|
|
}
|
|
|
|
|
2017-03-29 12:23:08 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::GenerateFrame(const nsTArray<WrOpacityProperty>& aOpacityArray,
|
|
|
|
const nsTArray<WrTransformProperty>& aTransformArray)
|
|
|
|
{
|
|
|
|
wr_api_generate_frame_with_properties(mWrApi,
|
|
|
|
aOpacityArray.IsEmpty() ?
|
|
|
|
nullptr : aOpacityArray.Elements(),
|
|
|
|
aOpacityArray.Length(),
|
|
|
|
aTransformArray.IsEmpty() ?
|
|
|
|
nullptr : aTransformArray.Elements(),
|
|
|
|
aTransformArray.Length());
|
|
|
|
}
|
|
|
|
|
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-05-12 00:21:11 +03:00
|
|
|
WrPipelineId pipeline_id,
|
2017-05-15 22:13:31 +03:00
|
|
|
const WrSize& content_size,
|
2017-05-12 00:21:11 +03:00
|
|
|
WrBuiltDisplayListDescriptor dl_descriptor,
|
|
|
|
uint8_t *dl_data,
|
|
|
|
size_t dl_size)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-03-01 17:10:53 +03:00
|
|
|
wr_api_set_root_display_list(mWrApi,
|
2017-06-01 03:53:58 +03:00
|
|
|
ToWrColor(aBgColor),
|
2017-05-12 00:21:11 +03:00
|
|
|
aEpoch,
|
|
|
|
aViewportSize.width, aViewportSize.height,
|
2017-03-01 17:10:53 +03:00
|
|
|
pipeline_id,
|
2017-05-15 22:13:31 +03:00
|
|
|
content_size,
|
2017-03-01 17:10:53 +03:00
|
|
|
dl_descriptor,
|
|
|
|
dl_data,
|
2017-05-08 20:52:16 +03:00
|
|
|
dl_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-03-07 01:41:51 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::SetWindowParameters(LayoutDeviceIntSize size)
|
|
|
|
{
|
|
|
|
wr_api_set_window_parameters(mWrApi, size.width, size.height);
|
|
|
|
}
|
|
|
|
|
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-03-20 19:10:40 +03:00
|
|
|
wr_renderer_readback(aRenderThread.GetRenderer(aWindowId)->GetWrRenderer(),
|
|
|
|
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
|
2017-03-07 13:37:28 +03:00
|
|
|
// read-back event. Then, we could make sure this read-back event gets the
|
|
|
|
// latest result.
|
|
|
|
RunOnRenderThread(Move(event));
|
|
|
|
|
|
|
|
task.Wait();
|
|
|
|
}
|
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::Pause()
|
|
|
|
{
|
|
|
|
class PauseEvent : public RendererEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit PauseEvent(layers::SynchronousTask* aTask)
|
|
|
|
: mTask(aTask)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(PauseEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
~PauseEvent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(PauseEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
|
|
|
|
{
|
|
|
|
aRenderThread.Pause(aWindowId);
|
|
|
|
layers::AutoCompleteTask complete(mTask);
|
|
|
|
}
|
|
|
|
|
|
|
|
layers::SynchronousTask* mTask;
|
|
|
|
};
|
|
|
|
|
|
|
|
layers::SynchronousTask task("Pause");
|
|
|
|
auto event = MakeUnique<PauseEvent>(&task);
|
|
|
|
// 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 event.
|
|
|
|
RunOnRenderThread(Move(event));
|
|
|
|
|
|
|
|
task.Wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
WebRenderAPI::Resume()
|
|
|
|
{
|
|
|
|
class ResumeEvent : public RendererEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit ResumeEvent(layers::SynchronousTask* aTask, bool* aResult)
|
|
|
|
: mTask(aTask)
|
|
|
|
, mResult(aResult)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ResumeEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
~ResumeEvent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ResumeEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
|
|
|
|
{
|
|
|
|
*mResult = aRenderThread.Resume(aWindowId);
|
|
|
|
layers::AutoCompleteTask complete(mTask);
|
|
|
|
}
|
|
|
|
|
|
|
|
layers::SynchronousTask* mTask;
|
|
|
|
bool* mResult;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool result = false;
|
|
|
|
layers::SynchronousTask task("Resume");
|
|
|
|
auto event = MakeUnique<ResumeEvent>(&task, &result);
|
|
|
|
// 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 event.
|
|
|
|
RunOnRenderThread(Move(event));
|
|
|
|
|
|
|
|
task.Wait();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-03-07 13:37:28 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::WaitFlushed()
|
|
|
|
{
|
|
|
|
class WaitFlushedEvent : public RendererEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit WaitFlushedEvent(layers::SynchronousTask* aTask)
|
|
|
|
: mTask(aTask)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(WaitFlushedEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
~WaitFlushedEvent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(WaitFlushedEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
|
|
|
|
{
|
|
|
|
layers::AutoCompleteTask complete(mTask);
|
|
|
|
}
|
|
|
|
|
|
|
|
layers::SynchronousTask* mTask;
|
|
|
|
};
|
|
|
|
|
|
|
|
layers::SynchronousTask task("WaitFlushed");
|
|
|
|
auto event = MakeUnique<WaitFlushedEvent>(&task);
|
|
|
|
// This event will be passed from wr_backend thread to renderer thread. That
|
2017-04-05 17:12:11 +03:00
|
|
|
// implies that all frame data have been processed when the renderer runs this event.
|
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
|
2017-03-09 05:10:09 +03:00
|
|
|
WebRenderAPI::AddImage(ImageKey key, const ImageDescriptor& aDescriptor,
|
2017-02-22 21:19:57 +03:00
|
|
|
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,
|
2017-03-09 05:10:09 +03:00
|
|
|
&aDescriptor,
|
2017-03-27 14:44:22 +03:00
|
|
|
RangeToByteSlice(aBytes));
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-03-27 14:44:52 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::AddBlobImage(ImageKey key, const ImageDescriptor& aDescriptor,
|
|
|
|
Range<uint8_t> aBytes)
|
|
|
|
{
|
|
|
|
wr_api_add_blob_image(mWrApi,
|
|
|
|
key,
|
|
|
|
&aDescriptor,
|
|
|
|
RangeToByteSlice(aBytes));
|
|
|
|
}
|
|
|
|
|
2017-03-02 04:22:40 +03:00
|
|
|
void
|
2017-05-18 17:59:07 +03:00
|
|
|
WebRenderAPI::AddExternalImage(ImageKey key,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
ExternalImageId aExtID,
|
|
|
|
WrExternalImageBufferType aBufferType,
|
|
|
|
uint8_t aChannelIndex)
|
2017-03-02 04:22:40 +03:00
|
|
|
{
|
2017-05-18 17:59:07 +03:00
|
|
|
wr_api_add_external_image(mWrApi,
|
|
|
|
key,
|
|
|
|
&aDescriptor,
|
|
|
|
aExtID,
|
|
|
|
aBufferType,
|
|
|
|
aChannelIndex);
|
2017-03-02 04:22:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebRenderAPI::AddExternalImageBuffer(ImageKey key,
|
2017-03-09 05:10:09 +03:00
|
|
|
const ImageDescriptor& aDescriptor,
|
2017-04-19 12:59:53 +03:00
|
|
|
ExternalImageId aHandle)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-03-02 04:22:40 +03:00
|
|
|
wr_api_add_external_image_buffer(mWrApi,
|
|
|
|
key,
|
2017-03-09 05:10:09 +03:00
|
|
|
&aDescriptor,
|
2017-03-02 04:22:40 +03:00
|
|
|
aHandle);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-17 03:22:09 +03:00
|
|
|
WebRenderAPI::UpdateImageBuffer(ImageKey aKey,
|
2017-03-09 05:10:09 +03:00
|
|
|
const ImageDescriptor& aDescriptor,
|
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,
|
2017-03-09 05:10:09 +03:00
|
|
|
&aDescriptor,
|
2017-03-27 14:44:22 +03:00
|
|
|
RangeToByteSlice(aBytes));
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2017-04-21 18:50:21 +03:00
|
|
|
WebRenderAPI::AddRawFont(wr::FontKey aKey, Range<uint8_t> aBytes, uint32_t aIndex)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-04-21 18:50:21 +03:00
|
|
|
wr_api_add_raw_font(mWrApi, aKey, &aBytes[0], aBytes.length(), aIndex);
|
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
|
|
|
{
|
2017-04-07 00:41:24 +03:00
|
|
|
wr_api_delete_font(mWrApi, aKey);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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-05-15 22:13:31 +03:00
|
|
|
DisplayListBuilder::DisplayListBuilder(PipelineId aId,
|
|
|
|
const WrSize& aContentSize)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DisplayListBuilder);
|
2017-05-15 22:13:31 +03:00
|
|
|
mWrState = wr_state_new(aId, aContentSize);
|
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-05-15 22:13:31 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::Finalize(WrSize& aOutContentSize,
|
|
|
|
BuiltDisplayList& aOutDisplayList)
|
2017-03-01 17:10:53 +03:00
|
|
|
{
|
2017-03-03 18:45:29 +03:00
|
|
|
wr_api_finalize_builder(mWrState,
|
2017-05-15 22:13:31 +03:00
|
|
|
&aOutContentSize,
|
|
|
|
&aOutDisplayList.dl_desc,
|
|
|
|
&aOutDisplayList.dl.inner);
|
2017-03-01 17:10:53 +03:00
|
|
|
}
|
|
|
|
|
2017-03-29 12:23:08 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushStackingContext(const WrRect& aBounds,
|
|
|
|
const uint64_t& aAnimationId,
|
|
|
|
const float* aOpacity,
|
|
|
|
const gfx::Matrix4x4* aTransform,
|
2017-06-06 13:28:00 +03:00
|
|
|
const WrMixBlendMode& aMixBlendMode,
|
|
|
|
const nsTArray<WrFilterOp>& aFilters)
|
2017-03-29 12:23:08 +03:00
|
|
|
{
|
|
|
|
WrMatrix matrix;
|
|
|
|
if (aTransform) {
|
|
|
|
matrix = ToWrMatrix(*aTransform);
|
|
|
|
}
|
|
|
|
const WrMatrix* maybeTransform = aTransform ? &matrix : nullptr;
|
2017-05-29 18:40:49 +03:00
|
|
|
WRDL_LOG("PushStackingContext b=%s t=%s\n", Stringify(aBounds).c_str(),
|
|
|
|
aTransform ? Stringify(*aTransform).c_str() : "none");
|
2017-03-29 12:23:08 +03:00
|
|
|
wr_dp_push_stacking_context(mWrState, aBounds, aAnimationId, aOpacity,
|
2017-06-06 13:28:00 +03:00
|
|
|
maybeTransform, aMixBlendMode,
|
|
|
|
aFilters.Elements(), aFilters.Length());
|
2017-03-29 12:23:08 +03:00
|
|
|
}
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PopStackingContext()
|
|
|
|
{
|
2017-05-29 18:40:49 +03:00
|
|
|
WRDL_LOG("PopStackingContext\n");
|
2017-01-17 17:32:25 +03:00
|
|
|
wr_dp_pop_stacking_context(mWrState);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2017-04-18 18:09:39 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushClip(const WrRect& aClipRect,
|
|
|
|
const WrImageMask* aMask)
|
|
|
|
{
|
2017-06-08 18:34:00 +03:00
|
|
|
uint64_t clip_id = wr_dp_push_clip(mWrState, aClipRect, aMask);
|
|
|
|
WRDL_LOG("PushClip id=%" PRIu64 " r=%s m=%p\n", clip_id,
|
|
|
|
Stringify(aClipRect).c_str(), aMask);
|
|
|
|
mClipIdStack.push_back(clip_id);
|
2017-04-18 18:09:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PopClip()
|
|
|
|
{
|
2017-06-08 18:34:00 +03:00
|
|
|
WRDL_LOG("PopClip id=%" PRIu64 "\n", mClipIdStack.back());
|
|
|
|
mClipIdStack.pop_back();
|
2017-05-12 20:58:09 +03:00
|
|
|
wr_dp_pop_clip(mWrState);
|
2017-04-18 18:09:39 +03:00
|
|
|
}
|
|
|
|
|
2017-03-03 18:45:29 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushBuiltDisplayList(BuiltDisplayList dl)
|
|
|
|
{
|
|
|
|
wr_dp_push_built_display_list(mWrState,
|
|
|
|
dl.dl_desc,
|
2017-05-08 20:52:16 +03:00
|
|
|
dl.dl.Extract());
|
2017-03-03 18:45:29 +03:00
|
|
|
}
|
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
void
|
2017-05-12 20:58:09 +03:00
|
|
|
DisplayListBuilder::PushScrollLayer(const layers::FrameMetrics::ViewID& aScrollId,
|
|
|
|
const WrRect& aContentRect,
|
|
|
|
const WrRect& aClipRect)
|
2017-02-14 21:34:15 +03:00
|
|
|
{
|
2017-05-29 18:40:49 +03:00
|
|
|
WRDL_LOG("PushScrollLayer id=%" PRIu64 " co=%s cl=%s\n",
|
|
|
|
aScrollId, Stringify(aContentRect).c_str(), Stringify(aClipRect).c_str());
|
2017-05-12 20:58:09 +03:00
|
|
|
wr_dp_push_scroll_layer(mWrState, aScrollId, aContentRect, aClipRect);
|
2017-06-08 18:34:00 +03:00
|
|
|
mScrollIdStack.push_back(aScrollId);
|
2017-02-14 21:34:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PopScrollLayer()
|
|
|
|
{
|
2017-06-08 18:34:00 +03:00
|
|
|
WRDL_LOG("PopScrollLayer id=%" PRIu64 "\n", mScrollIdStack.back());
|
|
|
|
mScrollIdStack.pop_back();
|
2017-02-14 21:34:15 +03:00
|
|
|
wr_dp_pop_scroll_layer(mWrState);
|
|
|
|
}
|
|
|
|
|
2017-06-08 18:34:01 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushClipAndScrollInfo(const layers::FrameMetrics::ViewID& aScrollId,
|
|
|
|
const uint64_t* aClipId)
|
|
|
|
{
|
|
|
|
WRDL_LOG("PushClipAndScroll s=%" PRIu64 " c=%s\n", aScrollId,
|
|
|
|
aClipId ? Stringify(*aClipId).c_str() : "none");
|
|
|
|
wr_dp_push_clip_and_scroll_info(mWrState, aScrollId, aClipId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PopClipAndScrollInfo()
|
|
|
|
{
|
|
|
|
WRDL_LOG("PopClipAndScroll\n");
|
|
|
|
wr_dp_pop_clip_and_scroll_info(mWrState);
|
|
|
|
}
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushRect(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-02-09 11:49:38 +03:00
|
|
|
const WrColor& aColor)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-05-29 18:40:49 +03:00
|
|
|
WRDL_LOG("PushRect b=%s c=%s\n",
|
|
|
|
Stringify(aBounds).c_str(),
|
|
|
|
Stringify(aColor).c_str());
|
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,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-02-17 03:51:32 +03:00
|
|
|
const WrPoint& aStartPoint,
|
|
|
|
const WrPoint& aEndPoint,
|
|
|
|
const nsTArray<WrGradientStop>& aStops,
|
2017-04-12 22:20:52 +03:00
|
|
|
wr::GradientExtendMode aExtendMode,
|
|
|
|
const WrSize aTileSize,
|
|
|
|
const WrSize aTileSpacing)
|
2017-02-17 03:51:32 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_linear_gradient(mWrState,
|
|
|
|
aBounds, aClip,
|
|
|
|
aStartPoint, aEndPoint,
|
|
|
|
aStops.Elements(), aStops.Length(),
|
2017-04-12 22:20:52 +03:00
|
|
|
aExtendMode,
|
|
|
|
aTileSize, aTileSpacing);
|
2017-02-17 03:51:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-04-01 02:18:44 +03:00
|
|
|
const WrPoint& aCenter,
|
|
|
|
const WrSize& aRadius,
|
2017-02-17 03:51:32 +03:00
|
|
|
const nsTArray<WrGradientStop>& aStops,
|
2017-04-12 22:20:52 +03:00
|
|
|
wr::GradientExtendMode aExtendMode,
|
|
|
|
const WrSize aTileSize,
|
|
|
|
const WrSize aTileSpacing)
|
2017-02-17 03:51:32 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_radial_gradient(mWrState,
|
|
|
|
aBounds, aClip,
|
2017-04-01 02:18:44 +03:00
|
|
|
aCenter, aRadius,
|
2017-02-17 03:51:32 +03:00
|
|
|
aStops.Elements(), aStops.Length(),
|
2017-04-12 22:20:52 +03:00
|
|
|
aExtendMode,
|
|
|
|
aTileSize, aTileSpacing);
|
2017-02-17 03:51:32 +03:00
|
|
|
}
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushImage(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
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-04-07 09:53:16 +03:00
|
|
|
WrSize size;
|
|
|
|
size.width = aBounds.width;
|
|
|
|
size.height = aBounds.height;
|
|
|
|
PushImage(aBounds, aClip, size, size, aFilter, aImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PushImage(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-04-07 09:53:16 +03:00
|
|
|
const WrSize& aStretchSize,
|
|
|
|
const WrSize& aTileSpacing,
|
|
|
|
wr::ImageRendering aFilter,
|
|
|
|
wr::ImageKey aImage)
|
|
|
|
{
|
2017-05-29 18:40:49 +03:00
|
|
|
WRDL_LOG("PushImage b=%s s=%s t=%s\n", Stringify(aBounds).c_str(),
|
|
|
|
Stringify(aStretchSize).c_str(), Stringify(aTileSpacing).c_str());
|
2017-04-07 09:53:16 +03:00
|
|
|
wr_dp_push_image(mWrState, aBounds, aClip, aStretchSize, aTileSpacing, aFilter, aImage);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2017-04-29 00:00:57 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushYCbCrPlanarImage(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-04-29 00:00:57 +03:00
|
|
|
wr::ImageKey aImageChannel0,
|
|
|
|
wr::ImageKey aImageChannel1,
|
|
|
|
wr::ImageKey aImageChannel2,
|
2017-06-01 15:57:10 +03:00
|
|
|
WrYuvColorSpace aColorSpace,
|
|
|
|
wr::ImageRendering aRendering)
|
2017-04-29 00:00:57 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_yuv_planar_image(mWrState,
|
|
|
|
aBounds,
|
|
|
|
aClip,
|
|
|
|
aImageChannel0,
|
|
|
|
aImageChannel1,
|
|
|
|
aImageChannel2,
|
2017-06-01 15:57:10 +03:00
|
|
|
aColorSpace,
|
|
|
|
aRendering);
|
2017-04-29 00:00:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PushNV12Image(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-04-29 00:00:57 +03:00
|
|
|
wr::ImageKey aImageChannel0,
|
|
|
|
wr::ImageKey aImageChannel1,
|
2017-06-01 15:57:10 +03:00
|
|
|
WrYuvColorSpace aColorSpace,
|
|
|
|
wr::ImageRendering aRendering)
|
2017-04-29 00:00:57 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_yuv_NV12_image(mWrState,
|
|
|
|
aBounds,
|
|
|
|
aClip,
|
|
|
|
aImageChannel0,
|
|
|
|
aImageChannel1,
|
2017-06-01 15:57:10 +03:00
|
|
|
aColorSpace,
|
|
|
|
aRendering);
|
2017-04-29 00:00:57 +03:00
|
|
|
}
|
|
|
|
|
2017-05-18 17:59:07 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushYCbCrInterleavedImage(const WrRect& aBounds,
|
|
|
|
const WrClipRegionToken aClip,
|
|
|
|
wr::ImageKey aImageChannel0,
|
2017-06-01 15:57:10 +03:00
|
|
|
WrYuvColorSpace aColorSpace,
|
|
|
|
wr::ImageRendering aRendering)
|
2017-05-18 17:59:07 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_yuv_interleaved_image(mWrState,
|
|
|
|
aBounds,
|
|
|
|
aClip,
|
|
|
|
aImageChannel0,
|
2017-06-01 15:57:10 +03:00
|
|
|
aColorSpace,
|
|
|
|
aRendering);
|
2017-05-18 17:59:07 +03:00
|
|
|
}
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushIFrame(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken 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,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-03-13 06:46:03 +03:00
|
|
|
const WrBorderWidths& aWidths,
|
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-03-13 06:46:03 +03:00
|
|
|
aWidths, aTop, aRight, aBottom, aLeft, aRadius);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PushBorderImage(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-03-13 06:46:03 +03:00
|
|
|
const WrBorderWidths& aWidths,
|
|
|
|
wr::ImageKey aImage,
|
|
|
|
const WrNinePatchDescriptor& aPatch,
|
|
|
|
const WrSideOffsets2Df32& aOutset,
|
|
|
|
const WrRepeatMode& aRepeatHorizontal,
|
|
|
|
const WrRepeatMode& aRepeatVertical)
|
|
|
|
{
|
|
|
|
wr_dp_push_border_image(mWrState, aBounds, aClip,
|
|
|
|
aWidths, aImage, aPatch, aOutset,
|
|
|
|
aRepeatHorizontal, aRepeatVertical);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-04-10 12:27:30 +03:00
|
|
|
DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-04-10 12:27:30 +03:00
|
|
|
const WrBorderWidths& aWidths,
|
|
|
|
const WrPoint& aStartPoint,
|
|
|
|
const WrPoint& aEndPoint,
|
|
|
|
const nsTArray<WrGradientStop>& aStops,
|
|
|
|
wr::GradientExtendMode aExtendMode,
|
|
|
|
const WrSideOffsets2Df32& aOutset)
|
|
|
|
{
|
|
|
|
wr_dp_push_border_gradient(mWrState, aBounds, aClip,
|
|
|
|
aWidths, aStartPoint, aEndPoint,
|
|
|
|
aStops.Elements(), aStops.Length(),
|
|
|
|
aExtendMode, aOutset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PushBorderRadialGradient(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-04-10 12:27:30 +03:00
|
|
|
const WrBorderWidths& aWidths,
|
|
|
|
const WrPoint& aCenter,
|
|
|
|
const WrSize& aRadius,
|
|
|
|
const nsTArray<WrGradientStop>& aStops,
|
|
|
|
wr::GradientExtendMode aExtendMode,
|
|
|
|
const WrSideOffsets2Df32& aOutset)
|
|
|
|
{
|
|
|
|
wr_dp_push_border_radial_gradient(
|
|
|
|
mWrState, aBounds, aClip, aWidths, aCenter,
|
|
|
|
aRadius, aStops.Elements(), aStops.Length(),
|
|
|
|
aExtendMode, aOutset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-17 17:32:16 +03:00
|
|
|
DisplayListBuilder::PushText(const WrRect& aBounds,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken 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,
|
2017-05-08 20:52:16 +03:00
|
|
|
const WrClipRegionToken aClip,
|
2017-02-16 21:23:22 +03:00
|
|
|
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-05-08 20:52:16 +03:00
|
|
|
WrClipRegionToken
|
|
|
|
DisplayListBuilder::PushClipRegion(const WrRect& aMain,
|
|
|
|
const WrImageMask* aMask)
|
2017-03-09 19:54:16 +03:00
|
|
|
{
|
2017-05-29 18:40:49 +03:00
|
|
|
WRDL_LOG("PushClipRegion r=%s m=%p\n", Stringify(aMain).c_str(), aMask);
|
2017-05-08 20:52:16 +03:00
|
|
|
return wr_dp_push_clip_region(mWrState,
|
|
|
|
aMain,
|
|
|
|
nullptr, 0,
|
|
|
|
aMask);
|
2017-03-09 19:54:16 +03:00
|
|
|
}
|
|
|
|
|
2017-05-08 20:52:16 +03:00
|
|
|
WrClipRegionToken
|
|
|
|
DisplayListBuilder::PushClipRegion(const WrRect& aMain,
|
|
|
|
const nsTArray<WrComplexClipRegion>& aComplex,
|
|
|
|
const WrImageMask* aMask)
|
2017-03-09 19:54:16 +03:00
|
|
|
{
|
2017-05-29 18:40:49 +03:00
|
|
|
WRDL_LOG("PushClipRegion r=%s cl=%d m=%p\n", Stringify(aMain).c_str(),
|
|
|
|
(int)aComplex.Length(), aMask);
|
2017-05-08 20:52:16 +03:00
|
|
|
return wr_dp_push_clip_region(mWrState,
|
|
|
|
aMain,
|
|
|
|
aComplex.Elements(), aComplex.Length(),
|
|
|
|
aMask);
|
2017-03-09 19:54:16 +03:00
|
|
|
}
|
|
|
|
|
2017-06-08 18:34:00 +03:00
|
|
|
Maybe<uint64_t>
|
|
|
|
DisplayListBuilder::TopmostClipId()
|
|
|
|
{
|
|
|
|
if (mClipIdStack.empty()) {
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
return Some(mClipIdStack.back());
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<layers::FrameMetrics::ViewID>
|
|
|
|
DisplayListBuilder::ParentScrollIdFor(layers::FrameMetrics::ViewID aScrollId)
|
|
|
|
{
|
|
|
|
// Finds the scrollId in mScrollIdStack immediately before aScrollId, or
|
|
|
|
// returns Nothing() if it can't find one
|
|
|
|
for (auto it = mScrollIdStack.rbegin(); it != mScrollIdStack.rend(); it++) {
|
|
|
|
if (*it == aScrollId) {
|
|
|
|
it++;
|
|
|
|
return (it == mScrollIdStack.rend() ? Nothing() : Some(*it));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|