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-08-09 15:46:24 +03:00
|
|
|
NewRenderer(wr::DocumentHandle** aDocHandle, 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,
|
2017-08-07 13:15:25 +03:00
|
|
|
LayoutDeviceIntSize aSize,
|
|
|
|
layers::SyncHandle* aHandle)
|
2017-08-09 15:46:24 +03:00
|
|
|
: mDocHandle(aDocHandle)
|
2017-01-25 00:06:17 +03:00
|
|
|
, 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-08-07 13:15:25 +03:00
|
|
|
, mSyncHandle(aHandle)
|
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-07-19 10:28:58 +03:00
|
|
|
wr::Renderer* wrRenderer = nullptr;
|
2017-03-07 02:46:30 +03:00
|
|
|
if (!wr_window_new(aWindowId, mSize.width, mSize.height, gl.get(),
|
2017-06-13 18:57:16 +03:00
|
|
|
aRenderThread.ThreadPool().Raw(),
|
2017-08-09 15:46:24 +03:00
|
|
|
this->mEnableProfiler, mDocHandle, &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) {
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrExternalImageHandler handler = renderer->GetExternalImageHandler();
|
2017-03-01 12:08:56 +03:00
|
|
|
wr_renderer_set_external_image_handler(wrRenderer, &handler);
|
|
|
|
}
|
2017-01-11 15:51:27 +03:00
|
|
|
|
2017-08-07 13:15:25 +03:00
|
|
|
if (renderer) {
|
|
|
|
layers::SyncObjectHost* syncObj = renderer->GetSyncObject();
|
|
|
|
if (syncObj) {
|
|
|
|
*mSyncHandle = syncObj->GetSyncHandle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-08-09 15:46:24 +03:00
|
|
|
wr::DocumentHandle** mDocHandle;
|
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-08-07 13:15:25 +03:00
|
|
|
layers::SyncHandle* mSyncHandle;
|
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-08-09 15:46:24 +03:00
|
|
|
wr::DocumentHandle* docHandle = nullptr;
|
2017-01-18 22:50:00 +03:00
|
|
|
GLint maxTextureSize = 0;
|
2017-02-23 11:46:56 +03:00
|
|
|
bool useANGLE = false;
|
2017-08-07 13:15:25 +03:00
|
|
|
layers::SyncHandle syncHandle = 0;
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-08-09 15:46:24 +03:00
|
|
|
// Dispatch a synchronous task because the DocumentHandle object needs to be created
|
2017-01-11 15:51:27 +03:00
|
|
|
// on the render thread. If need be we could delay waiting on this task until
|
2017-08-09 15:46:24 +03:00
|
|
|
// the next time we need to access the DocumentHandle object.
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::SynchronousTask task("Create Renderer");
|
2017-08-09 15:46:24 +03:00
|
|
|
auto event = MakeUnique<NewRenderer>(&docHandle, aBridge, &maxTextureSize, &useANGLE,
|
2017-08-07 13:15:25 +03:00
|
|
|
Move(aWidget), &task, aEnableProfiler, aSize,
|
|
|
|
&syncHandle);
|
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-08-09 15:46:24 +03:00
|
|
|
if (!docHandle) {
|
2017-01-11 15:51:27 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-08-09 15:46:24 +03:00
|
|
|
return RefPtr<WebRenderAPI>(new WebRenderAPI(docHandle, id, maxTextureSize, useANGLE, syncHandle)).forget();
|
2017-01-10 12:17:30 +03:00
|
|
|
}
|
|
|
|
|
2017-08-09 15:46:25 +03:00
|
|
|
already_AddRefed<WebRenderAPI>
|
|
|
|
WebRenderAPI::Clone()
|
|
|
|
{
|
|
|
|
wr::DocumentHandle* docHandle = nullptr;
|
|
|
|
wr_api_clone(mDocHandle, &docHandle);
|
|
|
|
|
|
|
|
RefPtr<WebRenderAPI> renderApi = new WebRenderAPI(docHandle, mId, mMaxTextureSize, mUseANGLE, mSyncHandle);
|
|
|
|
renderApi->mRootApi = this; // Hold root api
|
|
|
|
return renderApi.forget();
|
|
|
|
}
|
|
|
|
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrIdNamespace
|
2017-02-22 21:19:57 +03:00
|
|
|
WebRenderAPI::GetNamespace() {
|
2017-08-09 15:46:24 +03:00
|
|
|
return wr_api_get_namespace(mDocHandle);
|
2017-02-22 21:19:57 +03:00
|
|
|
}
|
|
|
|
|
2017-01-10 12:17:30 +03:00
|
|
|
WebRenderAPI::~WebRenderAPI()
|
|
|
|
{
|
2017-08-09 15:46:25 +03:00
|
|
|
if (!mRootApi) {
|
|
|
|
layers::SynchronousTask task("Destroy WebRenderAPI");
|
|
|
|
auto event = MakeUnique<RemoveRenderer>(&task);
|
|
|
|
RunOnRenderThread(Move(event));
|
|
|
|
task.Wait();
|
|
|
|
}
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_delete(mDocHandle);
|
2017-01-10 12:17:30 +03:00
|
|
|
}
|
|
|
|
|
2017-05-12 20:58:20 +03:00
|
|
|
void
|
2017-06-28 02:20:36 +03:00
|
|
|
WebRenderAPI::UpdateScrollPosition(const wr::WrPipelineId& aPipelineId,
|
2017-05-12 20:58:20 +03:00
|
|
|
const layers::FrameMetrics::ViewID& aScrollId,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutPoint& aScrollPosition)
|
2017-05-12 20:58:20 +03:00
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_scroll_layer_with_id(mDocHandle, aPipelineId, aScrollId, aScrollPosition);
|
2017-05-12 20:58:20 +03:00
|
|
|
}
|
|
|
|
|
2017-02-27 03:27:04 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::GenerateFrame()
|
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_generate_frame(mDocHandle);
|
2017-02-27 03:27:04 +03:00
|
|
|
}
|
|
|
|
|
2017-03-29 12:23:08 +03:00
|
|
|
void
|
2017-06-28 02:20:36 +03:00
|
|
|
WebRenderAPI::GenerateFrame(const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
|
|
|
|
const nsTArray<wr::WrTransformProperty>& aTransformArray)
|
2017-03-29 12:23:08 +03:00
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_generate_frame_with_properties(mDocHandle,
|
2017-03-29 12:23:08 +03:00
|
|
|
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-07-21 19:39:25 +03:00
|
|
|
mozilla::LayerSize aViewportSize,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrPipelineId pipeline_id,
|
2017-07-19 01:32:46 +03:00
|
|
|
const LayoutSize& content_size,
|
2017-07-19 10:28:58 +03:00
|
|
|
wr::BuiltDisplayListDescriptor dl_descriptor,
|
2017-05-12 00:21:11 +03:00
|
|
|
uint8_t *dl_data,
|
|
|
|
size_t dl_size)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_set_root_display_list(mDocHandle,
|
2017-07-19 01:32:46 +03:00
|
|
|
ToColorF(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,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrPipelineId pipeline_id)
|
2017-03-06 04:42:17 +03:00
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_clear_root_display_list(mDocHandle, aEpoch, pipeline_id);
|
2017-03-06 04:42:17 +03:00
|
|
|
}
|
|
|
|
|
2017-03-07 01:41:51 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::SetWindowParameters(LayoutDeviceIntSize size)
|
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_set_window_parameters(mDocHandle, size.width, size.height);
|
2017-03-07 01:41:51 +03:00
|
|
|
}
|
|
|
|
|
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-07-19 10:28:58 +03:00
|
|
|
wr_renderer_readback(aRenderThread.GetRenderer(aWindowId)->GetRenderer(),
|
2017-03-20 19:10:40 +03:00
|
|
|
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-08-09 15:46:24 +03:00
|
|
|
wr_api_set_root_pipeline(mDocHandle, 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-08-09 15:46:24 +03:00
|
|
|
wr_api_add_image(mDocHandle,
|
2017-02-22 21:19:57 +03:00
|
|
|
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)
|
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_add_blob_image(mDocHandle,
|
2017-03-27 14:44:52 +03:00
|
|
|
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,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrExternalImageBufferType aBufferType,
|
2017-05-18 17:59:07 +03:00
|
|
|
uint8_t aChannelIndex)
|
2017-03-02 04:22:40 +03:00
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_add_external_image(mDocHandle,
|
2017-05-18 17:59:07 +03:00
|
|
|
key,
|
|
|
|
&aDescriptor,
|
|
|
|
aExtID,
|
|
|
|
aBufferType,
|
|
|
|
aChannelIndex);
|
2017-03-02 04:22:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-28 15:08:11 +03:00
|
|
|
WebRenderAPI::AddExternalImageBuffer(ImageKey aKey,
|
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-07-28 15:08:11 +03:00
|
|
|
auto channelIndex = 0;
|
|
|
|
AddExternalImage(aKey, aDescriptor, aHandle,
|
|
|
|
wr::WrExternalImageBufferType::ExternalBuffer,
|
|
|
|
channelIndex);
|
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-08-09 15:46:24 +03:00
|
|
|
wr_api_update_image(mDocHandle,
|
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
|
|
|
}
|
|
|
|
|
2017-07-28 15:08:11 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::UpdateBlobImage(ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
Range<uint8_t> aBytes)
|
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_update_blob_image(mDocHandle,
|
2017-07-28 15:08:11 +03:00
|
|
|
aKey,
|
|
|
|
&aDescriptor,
|
|
|
|
RangeToByteSlice(aBytes));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebRenderAPI::UpdateExternalImage(ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
ExternalImageId aExtID,
|
|
|
|
wr::WrExternalImageBufferType aBufferType,
|
|
|
|
uint8_t aChannelIndex)
|
|
|
|
{
|
2017-08-09 15:46:24 +03:00
|
|
|
wr_api_update_external_image(mDocHandle,
|
2017-07-28 15:08:11 +03:00
|
|
|
aKey,
|
|
|
|
&aDescriptor,
|
|
|
|
aExtID,
|
|
|
|
aBufferType,
|
|
|
|
aChannelIndex);
|
|
|
|
}
|
|
|
|
|
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-08-09 15:46:24 +03:00
|
|
|
wr_api_delete_image(mDocHandle, 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-08-09 15:46:24 +03:00
|
|
|
wr_api_add_raw_font(mDocHandle, 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-08-09 15:46:24 +03:00
|
|
|
wr_api_delete_font(mDocHandle, 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));
|
|
|
|
}
|
|
|
|
|
2017-07-28 02:05:56 +03:00
|
|
|
class FrameStartTime : public RendererEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit FrameStartTime(const TimeStamp& aTime)
|
|
|
|
: mTime(aTime)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(FrameStartTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
~FrameStartTime()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(FrameStartTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
|
|
|
|
{
|
|
|
|
auto renderer = aRenderThread.GetRenderer(aWindowId);
|
|
|
|
if (renderer) {
|
|
|
|
renderer->SetFrameStartTime(mTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
TimeStamp mTime;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
WebRenderAPI::SetFrameStartTime(const TimeStamp& aTime)
|
|
|
|
{
|
|
|
|
auto event = MakeUnique<FrameStartTime>(aTime);
|
|
|
|
RunOnRenderThread(Move(event));
|
|
|
|
}
|
|
|
|
|
2017-01-17 22:46:31 +03:00
|
|
|
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-08-09 15:46:24 +03:00
|
|
|
wr_api_send_external_event(mDocHandle, event);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-05-15 22:13:31 +03:00
|
|
|
DisplayListBuilder::DisplayListBuilder(PipelineId aId,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutSize& 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
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::Finalize(wr::LayoutSize& aOutContentSize,
|
2017-05-15 22:13:31 +03:00
|
|
|
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
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushStackingContext(const wr::LayoutRect& aBounds,
|
2017-03-29 12:23:08 +03:00
|
|
|
const uint64_t& aAnimationId,
|
|
|
|
const float* aOpacity,
|
|
|
|
const gfx::Matrix4x4* aTransform,
|
2017-07-19 10:28:58 +03:00
|
|
|
wr::TransformStyle aTransformStyle,
|
|
|
|
const wr::MixBlendMode& aMixBlendMode,
|
2017-06-28 02:20:36 +03:00
|
|
|
const nsTArray<wr::WrFilterOp>& aFilters)
|
2017-03-29 12:23:08 +03:00
|
|
|
{
|
2017-07-19 01:32:46 +03:00
|
|
|
wr::LayoutTransform matrix;
|
2017-03-29 12:23:08 +03:00
|
|
|
if (aTransform) {
|
2017-07-19 01:32:46 +03:00
|
|
|
matrix = ToLayoutTransform(*aTransform);
|
2017-03-29 12:23:08 +03:00
|
|
|
}
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutTransform* 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-22 17:53:47 +03:00
|
|
|
maybeTransform, aTransformStyle, aMixBlendMode,
|
2017-06-06 13:28:00 +03:00
|
|
|
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
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushClip(const wr::LayoutRect& aClipRect,
|
2017-06-28 02:20:36 +03:00
|
|
|
const wr::WrImageMask* aMask)
|
2017-04-18 18:09:39 +03:00
|
|
|
{
|
2017-07-10 14:22:39 +03:00
|
|
|
uint64_t clip_id = wr_dp_push_clip(mWrState, aClipRect, nullptr, 0, aMask);
|
2017-06-13 15:42:39 +03:00
|
|
|
WRDL_LOG("PushClip id=%" PRIu64 " r=%s m=%p b=%s\n", clip_id,
|
|
|
|
Stringify(aClipRect).c_str(), aMask,
|
|
|
|
aMask ? Stringify(aMask->rect).c_str() : "none");
|
2017-06-28 02:20:36 +03:00
|
|
|
mClipIdStack.push_back(wr::WrClipId { clip_id });
|
2017-04-18 18:09:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PopClip()
|
|
|
|
{
|
2017-06-16 00:02:20 +03:00
|
|
|
WRDL_LOG("PopClip id=%" PRIu64 "\n", mClipIdStack.back().id);
|
2017-06-08 18:34:00 +03:00
|
|
|
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
|
2017-06-22 01:39:21 +03:00
|
|
|
DisplayListBuilder::PushBuiltDisplayList(BuiltDisplayList &dl)
|
2017-03-03 18:45:29 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_built_display_list(mWrState,
|
|
|
|
dl.dl_desc,
|
2017-06-22 01:39:21 +03:00
|
|
|
&dl.dl.inner);
|
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,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutRect& aContentRect,
|
|
|
|
const wr::LayoutRect& 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-16 22:12:24 +03:00
|
|
|
if (!mScrollIdStack.empty()) {
|
|
|
|
auto it = mScrollParents.insert({aScrollId, mScrollIdStack.back()});
|
|
|
|
if (!it.second) { // aScrollId was already a key in mScrollParents
|
|
|
|
// so check that the parent value is the same.
|
|
|
|
MOZ_ASSERT(it.first->second == mScrollIdStack.back());
|
|
|
|
}
|
|
|
|
}
|
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,
|
2017-06-28 02:20:36 +03:00
|
|
|
const wr::WrClipId* aClipId)
|
2017-06-08 18:34:01 +03:00
|
|
|
{
|
|
|
|
WRDL_LOG("PushClipAndScroll s=%" PRIu64 " c=%s\n", aScrollId,
|
2017-06-16 00:02:20 +03:00
|
|
|
aClipId ? Stringify(aClipId->id).c_str() : "none");
|
|
|
|
wr_dp_push_clip_and_scroll_info(mWrState, aScrollId,
|
|
|
|
aClipId ? &(aClipId->id) : nullptr);
|
2017-06-08 18:34:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushRect(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
|
|
|
const wr::ColorF& aColor)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-06-26 14:49:52 +03:00
|
|
|
WRDL_LOG("PushRect b=%s cl=%s c=%s\n",
|
2017-05-29 18:40:49 +03:00
|
|
|
Stringify(aBounds).c_str(),
|
2017-06-26 14:49:52 +03:00
|
|
|
Stringify(aClip).c_str(),
|
2017-05-29 18:40:49 +03:00
|
|
|
Stringify(aColor).c_str());
|
2017-07-10 14:22:39 +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
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushLinearGradient(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
|
|
|
const wr::LayoutPoint& aStartPoint,
|
|
|
|
const wr::LayoutPoint& aEndPoint,
|
2017-07-19 08:47:07 +03:00
|
|
|
const nsTArray<wr::GradientStop>& aStops,
|
|
|
|
wr::ExtendMode aExtendMode,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutSize aTileSize,
|
|
|
|
const wr::LayoutSize aTileSpacing)
|
2017-02-17 03:51:32 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_linear_gradient(mWrState,
|
2017-07-10 14:22:39 +03:00
|
|
|
aBounds, aClip,
|
2017-02-17 03:51:32 +03:00
|
|
|
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
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushRadialGradient(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
|
|
|
const wr::LayoutPoint& aCenter,
|
|
|
|
const wr::LayoutSize& aRadius,
|
2017-07-19 08:47:07 +03:00
|
|
|
const nsTArray<wr::GradientStop>& aStops,
|
|
|
|
wr::ExtendMode aExtendMode,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutSize aTileSize,
|
|
|
|
const wr::LayoutSize aTileSpacing)
|
2017-02-17 03:51:32 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_radial_gradient(mWrState,
|
2017-07-10 14:22:39 +03:00
|
|
|
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-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& 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-07-19 01:32:46 +03:00
|
|
|
wr::LayoutSize size;
|
|
|
|
size.width = aBounds.size.width;
|
|
|
|
size.height = aBounds.size.height;
|
2017-04-07 09:53:16 +03:00
|
|
|
PushImage(aBounds, aClip, size, size, aFilter, aImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
|
|
|
const wr::LayoutSize& aStretchSize,
|
|
|
|
const wr::LayoutSize& aTileSpacing,
|
2017-04-07 09:53:16 +03:00
|
|
|
wr::ImageRendering aFilter,
|
|
|
|
wr::ImageKey aImage)
|
|
|
|
{
|
2017-06-26 14:49:52 +03:00
|
|
|
WRDL_LOG("PushImage b=%s cl=%s s=%s t=%s\n", Stringify(aBounds).c_str(),
|
|
|
|
Stringify(aClip).c_str(), Stringify(aStretchSize).c_str(),
|
|
|
|
Stringify(aTileSpacing).c_str());
|
2017-07-10 14:22:39 +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
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushYCbCrPlanarImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-04-29 00:00:57 +03:00
|
|
|
wr::ImageKey aImageChannel0,
|
|
|
|
wr::ImageKey aImageChannel1,
|
|
|
|
wr::ImageKey aImageChannel2,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrYuvColorSpace aColorSpace,
|
2017-06-01 15:57:10 +03:00
|
|
|
wr::ImageRendering aRendering)
|
2017-04-29 00:00:57 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_yuv_planar_image(mWrState,
|
|
|
|
aBounds,
|
2017-07-10 14:22:39 +03:00
|
|
|
aClip,
|
2017-04-29 00:00:57 +03:00
|
|
|
aImageChannel0,
|
|
|
|
aImageChannel1,
|
|
|
|
aImageChannel2,
|
2017-06-01 15:57:10 +03:00
|
|
|
aColorSpace,
|
|
|
|
aRendering);
|
2017-04-29 00:00:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushNV12Image(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-04-29 00:00:57 +03:00
|
|
|
wr::ImageKey aImageChannel0,
|
|
|
|
wr::ImageKey aImageChannel1,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrYuvColorSpace aColorSpace,
|
2017-06-01 15:57:10 +03:00
|
|
|
wr::ImageRendering aRendering)
|
2017-04-29 00:00:57 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_yuv_NV12_image(mWrState,
|
|
|
|
aBounds,
|
2017-07-10 14:22:39 +03:00
|
|
|
aClip,
|
2017-04-29 00:00:57 +03:00
|
|
|
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
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushYCbCrInterleavedImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-05-18 17:59:07 +03:00
|
|
|
wr::ImageKey aImageChannel0,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrYuvColorSpace aColorSpace,
|
2017-06-01 15:57:10 +03:00
|
|
|
wr::ImageRendering aRendering)
|
2017-05-18 17:59:07 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_yuv_interleaved_image(mWrState,
|
|
|
|
aBounds,
|
2017-07-10 14:22:39 +03:00
|
|
|
aClip,
|
2017-05-18 17:59:07 +03:00
|
|
|
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-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushIFrame(const wr::LayoutRect& aBounds,
|
2017-01-17 03:22:09 +03:00
|
|
|
PipelineId aPipeline)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-07-10 14:22:39 +03:00
|
|
|
wr_dp_push_iframe(mWrState, aBounds, aPipeline);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushBorder(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::BorderWidths& aWidths,
|
|
|
|
const Range<const wr::BorderSide>& aSides,
|
|
|
|
const wr::BorderRadius& aRadius)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-07-01 02:22:25 +03:00
|
|
|
MOZ_ASSERT(aSides.length() == 4);
|
|
|
|
if (aSides.length() != 4) {
|
|
|
|
return;
|
|
|
|
}
|
2017-07-10 14:22:39 +03:00
|
|
|
wr_dp_push_border(mWrState, aBounds, aClip,
|
2017-07-01 02:22:25 +03:00
|
|
|
aWidths, aSides[0], aSides[1], aSides[2], aSides[3], aRadius);
|
2017-03-13 06:46:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushBorderImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::BorderWidths& aWidths,
|
2017-03-13 06:46:03 +03:00
|
|
|
wr::ImageKey aImage,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::NinePatchDescriptor& aPatch,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::SideOffsets2D_f32& aOutset,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::RepeatMode& aRepeatHorizontal,
|
|
|
|
const wr::RepeatMode& aRepeatVertical)
|
2017-03-13 06:46:03 +03:00
|
|
|
{
|
2017-07-10 14:22:39 +03:00
|
|
|
wr_dp_push_border_image(mWrState, aBounds, aClip,
|
2017-03-13 06:46:03 +03:00
|
|
|
aWidths, aImage, aPatch, aOutset,
|
|
|
|
aRepeatHorizontal, aRepeatVertical);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushBorderGradient(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::BorderWidths& aWidths,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutPoint& aStartPoint,
|
|
|
|
const wr::LayoutPoint& aEndPoint,
|
2017-07-19 08:47:07 +03:00
|
|
|
const nsTArray<wr::GradientStop>& aStops,
|
|
|
|
wr::ExtendMode aExtendMode,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::SideOffsets2D_f32& aOutset)
|
2017-04-10 12:27:30 +03:00
|
|
|
{
|
2017-07-10 14:22:39 +03:00
|
|
|
wr_dp_push_border_gradient(mWrState, aBounds, aClip,
|
2017-04-10 12:27:30 +03:00
|
|
|
aWidths, aStartPoint, aEndPoint,
|
|
|
|
aStops.Elements(), aStops.Length(),
|
|
|
|
aExtendMode, aOutset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushBorderRadialGradient(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::BorderWidths& aWidths,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutPoint& aCenter,
|
|
|
|
const wr::LayoutSize& aRadius,
|
2017-07-19 08:47:07 +03:00
|
|
|
const nsTArray<wr::GradientStop>& aStops,
|
|
|
|
wr::ExtendMode aExtendMode,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::SideOffsets2D_f32& aOutset)
|
2017-04-10 12:27:30 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_border_radial_gradient(
|
2017-07-10 14:22:39 +03:00
|
|
|
mWrState, aBounds, aClip, aWidths, aCenter,
|
2017-04-10 12:27:30 +03:00
|
|
|
aRadius, aStops.Elements(), aStops.Length(),
|
|
|
|
aExtendMode, aOutset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushText(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& 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-07-19 01:53:09 +03:00
|
|
|
Range<const wr::GlyphInstance> aGlyphBuffer,
|
2017-01-13 13:25:07 +03:00
|
|
|
float aGlyphSize)
|
|
|
|
{
|
2017-07-10 14:22:39 +03:00
|
|
|
wr_dp_push_text(mWrState, aBounds, aClip,
|
2017-07-19 01:32:46 +03:00
|
|
|
ToColorF(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
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushBoxShadow(const wr::LayoutRect& aRect,
|
|
|
|
const wr::LayoutRect& aClip,
|
|
|
|
const wr::LayoutRect& aBoxBounds,
|
|
|
|
const wr::LayoutVector2D& aOffset,
|
|
|
|
const wr::ColorF& aColor,
|
2017-02-16 21:23:22 +03:00
|
|
|
const float& aBlurRadius,
|
|
|
|
const float& aSpreadRadius,
|
|
|
|
const float& aBorderRadius,
|
2017-07-19 10:28:58 +03:00
|
|
|
const wr::BoxShadowClipMode& aClipMode)
|
2017-02-16 21:23:22 +03:00
|
|
|
{
|
2017-07-10 14:22:39 +03:00
|
|
|
wr_dp_push_box_shadow(mWrState, aRect, aClip,
|
2017-02-16 21:23:22 +03:00
|
|
|
aBoxBounds, aOffset, aColor,
|
|
|
|
aBlurRadius, aSpreadRadius, aBorderRadius,
|
|
|
|
aClipMode);
|
|
|
|
}
|
|
|
|
|
2017-06-28 02:20:36 +03:00
|
|
|
Maybe<wr::WrClipId>
|
2017-06-08 18:34:00 +03:00
|
|
|
DisplayListBuilder::TopmostClipId()
|
|
|
|
{
|
|
|
|
if (mClipIdStack.empty()) {
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
return Some(mClipIdStack.back());
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<layers::FrameMetrics::ViewID>
|
|
|
|
DisplayListBuilder::ParentScrollIdFor(layers::FrameMetrics::ViewID aScrollId)
|
|
|
|
{
|
2017-06-16 22:12:24 +03:00
|
|
|
auto it = mScrollParents.find(aScrollId);
|
|
|
|
return (it == mScrollParents.end() ? Nothing() : Some(it->second));
|
2017-06-08 18:34:00 +03:00
|
|
|
}
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|