2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2017-01-10 12:17:30 +03:00
|
|
|
/* 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-10-25 22:05:20 +03:00
|
|
|
#include "DisplayItemClipChain.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/layers/SynchronousTask.h"
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-05-29 18:40:49 +03:00
|
|
|
#define WRDL_LOG(...)
|
2017-08-28 21:20:25 +03:00
|
|
|
//#define WRDL_LOG(...) printf_stderr("WRDL(%p): " __VA_ARGS__)
|
2018-01-06 17:52:57 +03:00
|
|
|
//#define WRDL_LOG(...) if (XRE_IsContentProcess()) printf_stderr("WRDL(%p): " __VA_ARGS__)
|
2017-05-29 18:40:49 +03:00
|
|
|
|
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-08-12 08:41:56 +03:00
|
|
|
uint32_t* 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-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)
|
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-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-23 13:00:37 +03:00
|
|
|
mDocHandle, &wrRenderer,
|
2017-08-12 08:41:56 +03:00
|
|
|
mMaxTextureSize)) {
|
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-11-24 14:58:24 +03:00
|
|
|
if (gfx::gfxVars::UseWebRenderProgramBinary()) {
|
|
|
|
wr_renderer_update_program_cache(wrRenderer, aRenderThread.ProgramCache()->Raw());
|
|
|
|
}
|
2017-03-01 12:08:56 +03:00
|
|
|
}
|
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-08-12 08:41:56 +03:00
|
|
|
uint32_t* 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-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
|
|
|
};
|
|
|
|
|
2017-11-10 15:30:53 +03:00
|
|
|
/*static*/ void
|
|
|
|
WebRenderAPI::InitExternalLogHandler()
|
|
|
|
{
|
|
|
|
// Redirect the webrender's log to gecko's log system.
|
|
|
|
// The current log level is "error".
|
|
|
|
mozilla::wr::wr_init_external_log_handler(wr::LogLevelFilter::Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
WebRenderAPI::ShutdownExternalLogHandler()
|
|
|
|
{
|
|
|
|
mozilla::wr::wr_shutdown_external_log_handler();
|
|
|
|
}
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-11-10 15:30:53 +03:00
|
|
|
/*static*/ already_AddRefed<WebRenderAPI>
|
2017-08-23 13:00:37 +03:00
|
|
|
WebRenderAPI::Create(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-08-12 08:41:56 +03:00
|
|
|
uint32_t 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-23 13:00:37 +03:00
|
|
|
Move(aWidget), &task, aSize,
|
2017-08-07 13:15:25 +03:00
|
|
|
&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) {
|
2017-11-24 12:34:50 +03:00
|
|
|
|
|
|
|
RenderThread::Get()->SetDestroyed(GetId());
|
|
|
|
|
2017-08-09 15:46:25 +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-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-11-15 19:39:44 +03:00
|
|
|
bool
|
|
|
|
WebRenderAPI::HitTest(const wr::WorldPoint& aPoint,
|
|
|
|
wr::WrPipelineId& aOutPipelineId,
|
|
|
|
layers::FrameMetrics::ViewID& aOutScrollId,
|
|
|
|
gfx::CompositorHitTestInfo& aOutHitInfo)
|
|
|
|
{
|
2017-11-23 17:40:00 +03:00
|
|
|
static_assert(sizeof(gfx::CompositorHitTestInfo) == sizeof(uint16_t),
|
|
|
|
"CompositorHitTestInfo should be u16-sized");
|
2017-11-15 19:39:44 +03:00
|
|
|
return wr_api_hit_test(mDocHandle, aPoint,
|
2017-11-23 17:40:00 +03:00
|
|
|
&aOutPipelineId, &aOutScrollId, (uint16_t*)&aOutHitInfo);
|
2017-11-15 19:39:44 +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
|
2017-09-04 14:59:12 +03:00
|
|
|
WebRenderAPI::SetDisplayList(gfx::Color aBgColor,
|
|
|
|
Epoch aEpoch,
|
|
|
|
mozilla::LayerSize aViewportSize,
|
|
|
|
wr::WrPipelineId pipeline_id,
|
|
|
|
const LayoutSize& content_size,
|
|
|
|
wr::BuiltDisplayListDescriptor dl_descriptor,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& dl_data,
|
2017-09-04 14:59:42 +03:00
|
|
|
ResourceUpdateQueue& aResources)
|
2017-09-04 14:59:12 +03:00
|
|
|
{
|
2017-09-04 14:59:26 +03:00
|
|
|
wr_api_set_display_list(mDocHandle,
|
|
|
|
ToColorF(aBgColor),
|
|
|
|
aEpoch,
|
|
|
|
aViewportSize.width, aViewportSize.height,
|
|
|
|
pipeline_id,
|
|
|
|
content_size,
|
|
|
|
dl_descriptor,
|
2017-11-30 23:12:14 +03:00
|
|
|
&dl_data.inner,
|
2017-09-04 14:59:42 +03:00
|
|
|
aResources.Raw());
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-03-06 04:42:17 +03:00
|
|
|
void
|
2017-09-04 14:59:42 +03:00
|
|
|
WebRenderAPI::ClearDisplayList(Epoch aEpoch, wr::WrPipelineId pipeline_id)
|
2017-03-06 04:42:17 +03:00
|
|
|
{
|
2017-09-04 14:59:42 +03:00
|
|
|
wr_api_clear_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-11-13 12:32:23 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::RemovePipeline(PipelineId aPipeline)
|
|
|
|
{
|
|
|
|
wr_api_remove_pipeline(mDocHandle, aPipeline);
|
|
|
|
}
|
|
|
|
|
2017-02-22 21:19:57 +03:00
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
WebRenderAPI::UpdateResources(ResourceUpdateQueue& aUpdates)
|
|
|
|
{
|
|
|
|
wr_api_update_resources(mDocHandle, aUpdates.Raw());
|
|
|
|
}
|
|
|
|
|
2017-10-20 17:42:53 +03:00
|
|
|
void
|
|
|
|
WebRenderAPI::UpdatePipelineResources(ResourceUpdateQueue& aUpdates, PipelineId aPipeline, Epoch aEpoch)
|
|
|
|
{
|
|
|
|
wr_api_update_pipeline_resources(mDocHandle, aPipeline, aEpoch, aUpdates.Raw());
|
|
|
|
}
|
|
|
|
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::ResourceUpdateQueue()
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
mUpdates = wr_resource_updates_new();
|
|
|
|
}
|
|
|
|
|
2017-09-04 14:59:17 +03:00
|
|
|
ResourceUpdateQueue::ResourceUpdateQueue(ResourceUpdateQueue&& aFrom)
|
|
|
|
{
|
|
|
|
mUpdates = aFrom.mUpdates;
|
|
|
|
aFrom.mUpdates = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResourceUpdateQueue&
|
|
|
|
ResourceUpdateQueue::operator=(ResourceUpdateQueue&& aFrom)
|
|
|
|
{
|
|
|
|
mUpdates = aFrom.mUpdates;
|
|
|
|
aFrom.mUpdates = nullptr;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::~ResourceUpdateQueue()
|
|
|
|
{
|
2017-09-04 14:59:17 +03:00
|
|
|
if (mUpdates) {
|
|
|
|
wr_resource_updates_delete(mUpdates);
|
|
|
|
}
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-09-04 14:59:36 +03:00
|
|
|
void
|
|
|
|
ResourceUpdateQueue::Clear()
|
|
|
|
{
|
|
|
|
wr_resource_updates_clear(mUpdates);
|
|
|
|
}
|
|
|
|
|
2017-03-27 14:44:52 +03:00
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::AddImage(ImageKey key, const ImageDescriptor& aDescriptor,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aBytes)
|
2017-03-27 14:44:52 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
wr_resource_updates_add_image(mUpdates,
|
|
|
|
key,
|
|
|
|
&aDescriptor,
|
2017-09-14 19:48:55 +03:00
|
|
|
&aBytes.inner);
|
2017-03-27 14:44:52 +03:00
|
|
|
}
|
|
|
|
|
2017-03-02 04:22:40 +03:00
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::AddBlobImage(ImageKey key, const ImageDescriptor& aDescriptor,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aBytes)
|
2017-03-02 04:22:40 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
wr_resource_updates_add_blob_image(mUpdates,
|
|
|
|
key,
|
|
|
|
&aDescriptor,
|
2017-09-14 19:48:55 +03:00
|
|
|
&aBytes.inner);
|
2017-03-02 04:22:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::AddExternalImage(ImageKey key,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
ExternalImageId aExtID,
|
|
|
|
wr::WrExternalImageBufferType aBufferType,
|
|
|
|
uint8_t aChannelIndex)
|
|
|
|
{
|
|
|
|
wr_resource_updates_add_external_image(mUpdates,
|
|
|
|
key,
|
|
|
|
&aDescriptor,
|
|
|
|
aExtID,
|
|
|
|
aBufferType,
|
|
|
|
aChannelIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ResourceUpdateQueue::AddExternalImageBuffer(ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
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-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::UpdateImageBuffer(ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aBytes)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
wr_resource_updates_update_image(mUpdates,
|
|
|
|
aKey,
|
|
|
|
&aDescriptor,
|
2017-09-14 19:48:55 +03:00
|
|
|
&aBytes.inner);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-07-28 15:08:11 +03:00
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::UpdateBlobImage(ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aBytes,
|
2017-08-03 23:38:33 +03:00
|
|
|
const wr::DeviceUintRect& aDirtyRect)
|
2017-07-28 15:08:11 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
wr_resource_updates_update_blob_image(mUpdates,
|
|
|
|
aKey,
|
|
|
|
&aDescriptor,
|
2017-08-03 23:38:33 +03:00
|
|
|
&aBytes.inner,
|
|
|
|
aDirtyRect);
|
2017-07-28 15:08:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::UpdateExternalImage(ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
ExternalImageId aExtID,
|
|
|
|
wr::WrExternalImageBufferType aBufferType,
|
|
|
|
uint8_t aChannelIndex)
|
2017-07-28 15:08:11 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
wr_resource_updates_update_external_image(mUpdates,
|
|
|
|
aKey,
|
|
|
|
&aDescriptor,
|
|
|
|
aExtID,
|
|
|
|
aBufferType,
|
|
|
|
aChannelIndex);
|
2017-07-28 15:08:11 +03:00
|
|
|
}
|
|
|
|
|
2017-01-16 17:22:47 +03:00
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::DeleteImage(ImageKey aKey)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
wr_resource_updates_delete_image(mUpdates, aKey);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-02-22 21:19:57 +03:00
|
|
|
void
|
2018-01-04 21:23:34 +03:00
|
|
|
ResourceUpdateQueue::AddRawFont(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes, uint32_t aIndex)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-09-14 19:48:55 +03:00
|
|
|
wr_resource_updates_add_raw_font(mUpdates, aKey, &aBytes.inner, aIndex);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-11-07 04:19:46 +03:00
|
|
|
void
|
2018-01-04 21:23:34 +03:00
|
|
|
ResourceUpdateQueue::AddFontDescriptor(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes, uint32_t aIndex)
|
2017-11-07 04:19:46 +03:00
|
|
|
{
|
|
|
|
wr_resource_updates_add_font_descriptor(mUpdates, aKey, &aBytes.inner, aIndex);
|
|
|
|
}
|
|
|
|
|
2017-01-16 17:22:47 +03:00
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::DeleteFont(wr::FontKey aKey)
|
2017-01-16 17:22:47 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
wr_resource_updates_delete_font(mUpdates, aKey);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2017-08-30 20:45:11 +03:00
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::AddFontInstance(wr::FontInstanceKey aKey,
|
|
|
|
wr::FontKey aFontKey,
|
|
|
|
float aGlyphSize,
|
|
|
|
const wr::FontInstanceOptions* aOptions,
|
2017-09-21 06:18:23 +03:00
|
|
|
const wr::FontInstancePlatformOptions* aPlatformOptions,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aVariations)
|
2017-08-30 20:45:11 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
wr_resource_updates_add_font_instance(mUpdates, aKey, aFontKey, aGlyphSize,
|
2017-09-21 06:18:23 +03:00
|
|
|
aOptions, aPlatformOptions,
|
|
|
|
&aVariations.inner);
|
2017-08-30 20:45:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-04 14:59:12 +03:00
|
|
|
ResourceUpdateQueue::DeleteFontInstance(wr::FontInstanceKey aKey)
|
2017-08-30 20:45:11 +03:00
|
|
|
{
|
2017-09-04 14:59:12 +03:00
|
|
|
wr_resource_updates_delete_font_instance(mUpdates, aKey);
|
2017-08-30 20:45:11 +03:00
|
|
|
}
|
|
|
|
|
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-10-05 05:31:51 +03:00
|
|
|
const wr::LayoutSize& aContentSize,
|
|
|
|
size_t aCapacity)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DisplayListBuilder);
|
2017-10-05 05:31:51 +03:00
|
|
|
mWrState = wr_state_new(aId, aContentSize, aCapacity);
|
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
|
|
|
}
|
|
|
|
|
2017-10-06 20:06:10 +03:00
|
|
|
void DisplayListBuilder::Save() { wr_dp_save(mWrState); }
|
|
|
|
void DisplayListBuilder::Restore() { wr_dp_restore(mWrState); }
|
|
|
|
void DisplayListBuilder::ClearSave() { wr_dp_clear_save(mWrState); }
|
2017-11-28 23:28:08 +03:00
|
|
|
void DisplayListBuilder::Dump() { wr_dump_display_list(mWrState); }
|
2017-10-06 20:06:10 +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-11-15 11:09:21 +03:00
|
|
|
const WrAnimationProperty* aAnimation,
|
2017-03-29 12:23:08 +03:00
|
|
|
const float* aOpacity,
|
|
|
|
const gfx::Matrix4x4* aTransform,
|
2017-07-19 10:28:58 +03:00
|
|
|
wr::TransformStyle aTransformStyle,
|
2017-08-14 12:31:55 +03:00
|
|
|
const gfx::Matrix4x4* aPerspective,
|
2017-07-19 10:28:58 +03:00
|
|
|
const wr::MixBlendMode& aMixBlendMode,
|
2017-09-21 09:41:38 +03:00
|
|
|
const nsTArray<wr::WrFilterOp>& aFilters,
|
|
|
|
bool aIsBackfaceVisible)
|
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-08-14 12:31:55 +03:00
|
|
|
wr::LayoutTransform perspective;
|
|
|
|
if (aPerspective) {
|
|
|
|
perspective = ToLayoutTransform(*aPerspective);
|
|
|
|
}
|
|
|
|
const wr::LayoutTransform* maybePerspective = aPerspective ? &perspective : nullptr;
|
2017-08-28 21:20:25 +03:00
|
|
|
WRDL_LOG("PushStackingContext b=%s t=%s\n", mWrState, Stringify(aBounds).c_str(),
|
2017-05-29 18:40:49 +03:00
|
|
|
aTransform ? Stringify(*aTransform).c_str() : "none");
|
2017-11-15 11:09:21 +03:00
|
|
|
wr_dp_push_stacking_context(mWrState, aBounds, aAnimation, aOpacity,
|
2017-08-14 12:31:55 +03:00
|
|
|
maybeTransform, aTransformStyle, maybePerspective,
|
2017-09-21 09:41:38 +03:00
|
|
|
aMixBlendMode, aFilters.Elements(), aFilters.Length(), aIsBackfaceVisible);
|
2017-03-29 12:23:08 +03:00
|
|
|
}
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PopStackingContext()
|
|
|
|
{
|
2017-08-28 21:20:25 +03:00
|
|
|
WRDL_LOG("PopStackingContext\n", mWrState);
|
2017-01-17 17:32:25 +03:00
|
|
|
wr_dp_pop_stacking_context(mWrState);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2017-08-08 22:43:17 +03:00
|
|
|
wr::WrClipId
|
2017-10-24 22:45:57 +03:00
|
|
|
DisplayListBuilder::DefineClip(const Maybe<layers::FrameMetrics::ViewID>& aAncestorScrollId,
|
|
|
|
const Maybe<wr::WrClipId>& aAncestorClipId,
|
|
|
|
const wr::LayoutRect& aClipRect,
|
2017-10-04 00:51:49 +03:00
|
|
|
const nsTArray<wr::ComplexClipRegion>* aComplex,
|
2017-08-08 22:43:17 +03:00
|
|
|
const wr::WrImageMask* aMask)
|
|
|
|
{
|
2017-10-24 22:45:57 +03:00
|
|
|
const uint64_t* ancestorClipId = nullptr;
|
|
|
|
if (aAncestorClipId) {
|
|
|
|
ancestorClipId = &(aAncestorClipId.ref().id);
|
|
|
|
}
|
|
|
|
uint64_t clip_id = wr_dp_define_clip(mWrState,
|
|
|
|
aAncestorScrollId.ptrOr(nullptr), ancestorClipId,
|
|
|
|
aClipRect,
|
2017-08-08 22:43:17 +03:00
|
|
|
aComplex ? aComplex->Elements() : nullptr,
|
|
|
|
aComplex ? aComplex->Length() : 0,
|
|
|
|
aMask);
|
2017-10-24 22:45:57 +03:00
|
|
|
WRDL_LOG("DefineClip id=%" PRIu64 " as=%s ac=%s r=%s m=%p b=%s complex=%zu\n", mWrState,
|
|
|
|
clip_id,
|
|
|
|
aAncestorScrollId ? Stringify(aAncestorScrollId.ref()).c_str() : "(nil)",
|
|
|
|
aAncestorClipId ? Stringify(aAncestorClipId.ref().id).c_str() : "(nil)",
|
|
|
|
Stringify(aClipRect).c_str(), aMask,
|
2017-08-08 22:43:17 +03:00
|
|
|
aMask ? Stringify(aMask->rect).c_str() : "none",
|
|
|
|
aComplex ? aComplex->Length() : 0);
|
|
|
|
return wr::WrClipId { clip_id };
|
|
|
|
}
|
|
|
|
|
2017-04-18 18:09:39 +03:00
|
|
|
void
|
2017-10-24 22:45:59 +03:00
|
|
|
DisplayListBuilder::PushClip(const wr::WrClipId& aClipId,
|
|
|
|
const DisplayItemClipChain* aParent)
|
2017-04-18 18:09:39 +03:00
|
|
|
{
|
2017-08-08 22:43:17 +03:00
|
|
|
wr_dp_push_clip(mWrState, aClipId.id);
|
2017-08-28 21:20:25 +03:00
|
|
|
WRDL_LOG("PushClip id=%" PRIu64 "\n", mWrState, aClipId.id);
|
2017-10-24 22:45:59 +03:00
|
|
|
if (!aParent) {
|
2017-10-24 22:45:58 +03:00
|
|
|
mClipStack.push_back(wr::ScrollOrClipId(aClipId));
|
2017-09-19 12:05:22 +03:00
|
|
|
} else {
|
2017-10-25 22:05:20 +03:00
|
|
|
PushCacheOverride(aParent, aClipId);
|
2017-08-17 20:54:25 +03:00
|
|
|
}
|
2017-04-18 18:09:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-24 22:45:59 +03:00
|
|
|
DisplayListBuilder::PopClip(const DisplayItemClipChain* aParent)
|
2017-04-18 18:09:39 +03:00
|
|
|
{
|
2017-10-24 22:45:58 +03:00
|
|
|
WRDL_LOG("PopClip\n", mWrState);
|
2017-10-24 22:45:59 +03:00
|
|
|
if (!aParent) {
|
2017-10-24 22:45:58 +03:00
|
|
|
MOZ_ASSERT(mClipStack.back().is<wr::WrClipId>());
|
|
|
|
mClipStack.pop_back();
|
2017-09-19 12:05:22 +03:00
|
|
|
} else {
|
2017-10-25 22:05:20 +03:00
|
|
|
PopCacheOverride(aParent);
|
|
|
|
}
|
|
|
|
wr_dp_pop_clip(mWrState);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PushCacheOverride(const DisplayItemClipChain* aParent,
|
|
|
|
const wr::WrClipId& aClipId)
|
|
|
|
{
|
|
|
|
// We need to walk the entire clip chain from aParent up and install aClipId
|
|
|
|
// as an override for all of them. This is so that nested display items end up
|
|
|
|
// with the correct parent clip regardless of which outside clip their clip
|
|
|
|
// chains are attached to. Example:
|
|
|
|
// nsDisplayStickyPosition with clipChain D -> C -> B -> A -> nullptr
|
|
|
|
// nsDisplayItem with clipChain F -> E -> B -> A -> nullptr
|
|
|
|
// In this case the sticky clip that is generated by the sticky display item
|
|
|
|
// is defined as a child of D, which is a child of C and so on. When we go
|
|
|
|
// to define E for the nested display item, we want to make sure that it
|
|
|
|
// is defined as a child of sticky clip, regardless of which of {D, C, B, A}
|
|
|
|
// it has as a parent. {D, C, B, A} are what I refer to as the "outside clips"
|
|
|
|
// because they are "outside" the sticky clip, and if we define E as a child
|
|
|
|
// of any of those clips directly, then we end up losing the sticky clip from
|
|
|
|
// the WR clip chain of the nested item. This is why we install cache
|
|
|
|
// overrides for all of them so that when we walk the nested item's clip chain
|
|
|
|
// from E to B we discover that really we want to use the sticky clip as E's
|
|
|
|
// parent.
|
|
|
|
for (const DisplayItemClipChain* i = aParent; i; i = i->mParent) {
|
|
|
|
auto it = mCacheOverride.insert({ i, std::vector<wr::WrClipId>() });
|
|
|
|
it.first->second.push_back(aClipId);
|
|
|
|
WRDL_LOG("Pushing override %p -> %" PRIu64 "\n", mWrState, i, aClipId.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PopCacheOverride(const DisplayItemClipChain* aParent)
|
|
|
|
{
|
|
|
|
for (const DisplayItemClipChain* i = aParent; i; i = i->mParent) {
|
|
|
|
auto it = mCacheOverride.find(i);
|
2017-10-24 22:45:59 +03:00
|
|
|
MOZ_ASSERT(it != mCacheOverride.end());
|
|
|
|
MOZ_ASSERT(!(it->second.empty()));
|
2017-10-25 22:05:20 +03:00
|
|
|
WRDL_LOG("Popping override %p -> %" PRIu64 "\n", mWrState, i, it->second.back().id);
|
2017-10-24 22:45:59 +03:00
|
|
|
it->second.pop_back();
|
|
|
|
if (it->second.empty()) {
|
|
|
|
mCacheOverride.erase(it);
|
|
|
|
}
|
2017-08-17 20:54:25 +03:00
|
|
|
}
|
2017-04-18 18:09:39 +03:00
|
|
|
}
|
|
|
|
|
2017-10-24 22:45:59 +03:00
|
|
|
Maybe<wr::WrClipId>
|
|
|
|
DisplayListBuilder::GetCacheOverride(const DisplayItemClipChain* aParent)
|
|
|
|
{
|
|
|
|
auto it = mCacheOverride.find(aParent);
|
|
|
|
return it == mCacheOverride.end() ? Nothing() : Some(it->second.back());
|
|
|
|
}
|
|
|
|
|
2017-09-21 17:11:39 +03:00
|
|
|
wr::WrStickyId
|
|
|
|
DisplayListBuilder::DefineStickyFrame(const wr::LayoutRect& aContentRect,
|
2017-10-31 16:17:22 +03:00
|
|
|
const float* aTopMargin,
|
|
|
|
const float* aRightMargin,
|
|
|
|
const float* aBottomMargin,
|
|
|
|
const float* aLeftMargin,
|
|
|
|
const StickyOffsetBounds& aVerticalBounds,
|
2017-11-07 18:16:48 +03:00
|
|
|
const StickyOffsetBounds& aHorizontalBounds,
|
|
|
|
const wr::LayoutVector2D& aAppliedOffset)
|
2017-10-31 16:17:22 +03:00
|
|
|
{
|
|
|
|
uint64_t id = wr_dp_define_sticky_frame(mWrState, aContentRect, aTopMargin,
|
2017-11-07 18:16:48 +03:00
|
|
|
aRightMargin, aBottomMargin, aLeftMargin, aVerticalBounds, aHorizontalBounds,
|
|
|
|
aAppliedOffset);
|
|
|
|
WRDL_LOG("DefineSticky id=%" PRIu64 " c=%s t=%s r=%s b=%s l=%s v=%s h=%s a=%s\n",
|
2017-10-31 16:17:22 +03:00
|
|
|
mWrState, id,
|
2017-09-21 17:11:39 +03:00
|
|
|
Stringify(aContentRect).c_str(),
|
2017-10-31 16:17:22 +03:00
|
|
|
aTopMargin ? Stringify(*aTopMargin).c_str() : "none",
|
|
|
|
aRightMargin ? Stringify(*aRightMargin).c_str() : "none",
|
|
|
|
aBottomMargin ? Stringify(*aBottomMargin).c_str() : "none",
|
|
|
|
aLeftMargin ? Stringify(*aLeftMargin).c_str() : "none",
|
|
|
|
Stringify(aVerticalBounds).c_str(),
|
2017-11-07 18:16:48 +03:00
|
|
|
Stringify(aHorizontalBounds).c_str(),
|
|
|
|
Stringify(aAppliedOffset).c_str());
|
2017-09-21 17:11:39 +03:00
|
|
|
return wr::WrStickyId { id };
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-24 22:46:00 +03:00
|
|
|
DisplayListBuilder::PushStickyFrame(const wr::WrStickyId& aStickyId,
|
|
|
|
const DisplayItemClipChain* aParent)
|
2017-09-21 17:11:39 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_clip(mWrState, aStickyId.id);
|
|
|
|
WRDL_LOG("PushSticky id=%" PRIu64 "\n", mWrState, aStickyId.id);
|
2017-10-24 22:46:00 +03:00
|
|
|
// inside WR, a sticky id is just a regular clip id. so we can do some
|
|
|
|
// handwaving here and turn the WrStickyId into a WrclipId and treat it
|
|
|
|
// like any other out-of-band clip.
|
|
|
|
wr::WrClipId stickyIdAsClipId;
|
|
|
|
stickyIdAsClipId.id = aStickyId.id;
|
2017-10-25 22:05:20 +03:00
|
|
|
PushCacheOverride(aParent, stickyIdAsClipId);
|
2017-09-21 17:11:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-24 22:46:00 +03:00
|
|
|
DisplayListBuilder::PopStickyFrame(const DisplayItemClipChain* aParent)
|
2017-09-21 17:11:39 +03:00
|
|
|
{
|
|
|
|
WRDL_LOG("PopSticky\n", mWrState);
|
2017-10-25 22:05:20 +03:00
|
|
|
PopCacheOverride(aParent);
|
2017-09-21 17:11:39 +03:00
|
|
|
wr_dp_pop_clip(mWrState);
|
|
|
|
}
|
|
|
|
|
2017-08-30 21:51:19 +03:00
|
|
|
bool
|
|
|
|
DisplayListBuilder::IsScrollLayerDefined(layers::FrameMetrics::ViewID aScrollId) const
|
|
|
|
{
|
2017-10-24 22:45:58 +03:00
|
|
|
return mScrollIdsDefined.find(aScrollId) != mScrollIdsDefined.end();
|
2017-08-30 21:51:19 +03:00
|
|
|
}
|
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
void
|
2017-08-30 21:51:19 +03:00
|
|
|
DisplayListBuilder::DefineScrollLayer(const layers::FrameMetrics::ViewID& aScrollId,
|
2017-10-24 22:45:57 +03:00
|
|
|
const Maybe<layers::FrameMetrics::ViewID>& aAncestorScrollId,
|
|
|
|
const Maybe<wr::WrClipId>& aAncestorClipId,
|
2017-08-30 21:51:19 +03:00
|
|
|
const wr::LayoutRect& aContentRect,
|
|
|
|
const wr::LayoutRect& aClipRect)
|
2017-02-14 21:34:15 +03:00
|
|
|
{
|
2017-10-24 22:45:57 +03:00
|
|
|
WRDL_LOG("DefineScrollLayer id=%" PRIu64 " as=%s ac=%s co=%s cl=%s\n", mWrState,
|
|
|
|
aScrollId,
|
|
|
|
aAncestorScrollId ? Stringify(aAncestorScrollId.ref()).c_str() : "(nil)",
|
|
|
|
aAncestorClipId ? Stringify(aAncestorClipId.ref().id).c_str() : "(nil)",
|
|
|
|
Stringify(aContentRect).c_str(), Stringify(aClipRect).c_str());
|
2017-08-30 21:51:19 +03:00
|
|
|
|
2017-10-24 22:45:58 +03:00
|
|
|
auto it = mScrollIdsDefined.insert(aScrollId);
|
2017-08-30 21:51:19 +03:00
|
|
|
if (it.second) {
|
|
|
|
// An insertion took place, which means we haven't defined aScrollId before.
|
|
|
|
// So let's define it now.
|
2017-10-24 22:45:57 +03:00
|
|
|
const uint64_t* ancestorClipId = nullptr;
|
|
|
|
if (aAncestorClipId) {
|
|
|
|
ancestorClipId = &(aAncestorClipId.ref().id);
|
|
|
|
}
|
|
|
|
wr_dp_define_scroll_layer(mWrState, aScrollId, aAncestorScrollId.ptrOr(nullptr),
|
|
|
|
ancestorClipId, aContentRect, aClipRect);
|
2017-06-16 22:12:24 +03:00
|
|
|
}
|
2017-08-30 21:51:19 +03:00
|
|
|
}
|
2017-08-30 21:51:19 +03:00
|
|
|
|
2017-08-30 21:51:19 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushScrollLayer(const layers::FrameMetrics::ViewID& aScrollId)
|
|
|
|
{
|
|
|
|
WRDL_LOG("PushScrollLayer id=%" PRIu64 "\n", mWrState, aScrollId);
|
2017-08-30 21:51:19 +03:00
|
|
|
wr_dp_push_scroll_layer(mWrState, aScrollId);
|
2017-10-24 22:45:58 +03:00
|
|
|
mClipStack.push_back(wr::ScrollOrClipId(aScrollId));
|
2017-02-14 21:34:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PopScrollLayer()
|
|
|
|
{
|
2017-10-24 22:45:58 +03:00
|
|
|
MOZ_ASSERT(mClipStack.back().is<layers::FrameMetrics::ViewID>());
|
|
|
|
WRDL_LOG("PopScrollLayer id=%" PRIu64 "\n", mWrState, mClipStack.back().as<layers::FrameMetrics::ViewID>());
|
|
|
|
mClipStack.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
|
|
|
{
|
2017-08-28 21:20:25 +03:00
|
|
|
WRDL_LOG("PushClipAndScroll s=%" PRIu64 " c=%s\n", mWrState, 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-10-24 22:45:58 +03:00
|
|
|
mClipStack.push_back(wr::ScrollOrClipId(aScrollId));
|
2017-06-08 18:34:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::PopClipAndScrollInfo()
|
|
|
|
{
|
2017-10-24 22:45:58 +03:00
|
|
|
MOZ_ASSERT(mClipStack.back().is<layers::FrameMetrics::ViewID>());
|
2017-08-28 21:20:25 +03:00
|
|
|
WRDL_LOG("PopClipAndScroll\n", mWrState);
|
2017-10-24 22:45:58 +03:00
|
|
|
mClipStack.pop_back();
|
2017-06-08 18:34:01 +03:00
|
|
|
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,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::ColorF& aColor)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-08-28 21:20:25 +03:00
|
|
|
WRDL_LOG("PushRect b=%s cl=%s c=%s\n", mWrState,
|
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-09-21 09:41:38 +03:00
|
|
|
wr_dp_push_rect(mWrState, aBounds, aClip, aIsBackfaceVisible, aColor);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2017-10-31 18:31:00 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushClearRect(const wr::LayoutRect& aBounds)
|
|
|
|
{
|
|
|
|
WRDL_LOG("PushClearRect b=%s\n", mWrState,
|
|
|
|
Stringify(aBounds).c_str());
|
|
|
|
wr_dp_push_clear_rect(mWrState, aBounds);
|
|
|
|
}
|
|
|
|
|
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,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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::LayoutSize aTileSize,
|
|
|
|
const wr::LayoutSize aTileSpacing)
|
2017-02-17 03:51:32 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_linear_gradient(mWrState,
|
2017-09-21 09:41:38 +03:00
|
|
|
aBounds, aClip, aIsBackfaceVisible,
|
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,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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::LayoutSize aTileSize,
|
|
|
|
const wr::LayoutSize aTileSpacing)
|
2017-02-17 03:51:32 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_radial_gradient(mWrState,
|
2017-09-21 09:41:38 +03:00
|
|
|
aBounds, aClip, aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
PushImage(aBounds, aClip, aIsBackfaceVisible, size, size, aFilter, aImage);
|
2017-04-07 09:53:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-19 01:32:46 +03:00
|
|
|
DisplayListBuilder::PushImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutSize& aStretchSize,
|
|
|
|
const wr::LayoutSize& aTileSpacing,
|
2017-04-07 09:53:16 +03:00
|
|
|
wr::ImageRendering aFilter,
|
|
|
|
wr::ImageKey aImage)
|
|
|
|
{
|
2017-08-28 21:20:25 +03:00
|
|
|
WRDL_LOG("PushImage b=%s cl=%s s=%s t=%s\n", mWrState,
|
|
|
|
Stringify(aBounds).c_str(),
|
2017-06-26 14:49:52 +03:00
|
|
|
Stringify(aClip).c_str(), Stringify(aStretchSize).c_str(),
|
|
|
|
Stringify(aTileSpacing).c_str());
|
2017-09-21 09:41:38 +03:00
|
|
|
wr_dp_push_image(mWrState, aBounds, aClip, aIsBackfaceVisible, 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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-01-17 03:22:09 +03:00
|
|
|
PipelineId aPipeline)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-09-21 09:41:38 +03:00
|
|
|
wr_dp_push_iframe(mWrState, aBounds, aIsBackfaceVisible, 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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
wr_dp_push_border(mWrState, aBounds, aClip, aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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,
|
2018-01-04 21:23:34 +03:00
|
|
|
const wr::SideOffsets2D<float>& 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-09-21 09:41:38 +03:00
|
|
|
wr_dp_push_border_image(mWrState, aBounds, aClip, aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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,
|
2018-01-04 21:23:34 +03:00
|
|
|
const wr::SideOffsets2D<float>& aOutset)
|
2017-04-10 12:27:30 +03:00
|
|
|
{
|
2017-09-21 09:41:38 +03:00
|
|
|
wr_dp_push_border_gradient(mWrState, aBounds, aClip, aIsBackfaceVisible,
|
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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
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,
|
2018-01-04 21:23:34 +03:00
|
|
|
const wr::SideOffsets2D<float>& aOutset)
|
2017-04-10 12:27:30 +03:00
|
|
|
{
|
|
|
|
wr_dp_push_border_radial_gradient(
|
2017-09-21 09:41:38 +03:00
|
|
|
mWrState, aBounds, aClip, aIsBackfaceVisible, 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-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-10-04 20:49:51 +03:00
|
|
|
const wr::ColorF& aColor,
|
2017-08-30 20:45:11 +03:00
|
|
|
wr::FontInstanceKey aFontKey,
|
2017-07-19 01:53:09 +03:00
|
|
|
Range<const wr::GlyphInstance> aGlyphBuffer,
|
2017-08-30 20:45:11 +03:00
|
|
|
const wr::GlyphOptions* aGlyphOptions)
|
2017-01-13 13:25:07 +03:00
|
|
|
{
|
2017-09-21 09:41:38 +03:00
|
|
|
wr_dp_push_text(mWrState, aBounds, aClip, aIsBackfaceVisible,
|
2017-10-04 20:49:51 +03:00
|
|
|
aColor,
|
2017-02-14 21:34:15 +03:00
|
|
|
aFontKey,
|
2017-01-13 13:25:07 +03:00
|
|
|
&aGlyphBuffer[0], aGlyphBuffer.length(),
|
2017-08-30 20:45:11 +03:00
|
|
|
aGlyphOptions);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::PushLine(const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
const wr::Line& aLine)
|
|
|
|
{
|
2017-10-24 19:44:38 +03:00
|
|
|
wr_dp_push_line(mWrState, &aClip, aIsBackfaceVisible,
|
|
|
|
&aLine.bounds, aLine.wavyLineThickness, aLine.orientation,
|
|
|
|
&aLine.color, aLine.style);
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-04 21:54:37 +03:00
|
|
|
DisplayListBuilder::PushShadow(const wr::LayoutRect& aRect,
|
|
|
|
const wr::LayoutRect& aClip,
|
|
|
|
bool aIsBackfaceVisible,
|
|
|
|
const wr::Shadow& aShadow)
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
{
|
2017-10-04 21:54:37 +03:00
|
|
|
wr_dp_push_shadow(mWrState, aRect, aClip, aIsBackfaceVisible, aShadow);
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-13 19:58:32 +03:00
|
|
|
DisplayListBuilder::PopAllShadows()
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
{
|
2017-10-13 19:58:32 +03:00
|
|
|
wr_dp_pop_all_shadows(mWrState);
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
}
|
|
|
|
|
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,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 01:32:46 +03:00
|
|
|
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,
|
2017-10-24 09:44:29 +03:00
|
|
|
const wr::BorderRadius& aBorderRadius,
|
2017-07-19 10:28:58 +03:00
|
|
|
const wr::BoxShadowClipMode& aClipMode)
|
2017-02-16 21:23:22 +03:00
|
|
|
{
|
2017-09-21 09:41:38 +03:00
|
|
|
wr_dp_push_box_shadow(mWrState, aRect, aClip, aIsBackfaceVisible,
|
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()
|
|
|
|
{
|
2017-10-24 22:45:58 +03:00
|
|
|
for (auto it = mClipStack.crbegin(); it != mClipStack.crend(); it++) {
|
|
|
|
if (it->is<wr::WrClipId>()) {
|
|
|
|
return Some(it->as<wr::WrClipId>());
|
|
|
|
}
|
2017-06-08 18:34:00 +03:00
|
|
|
}
|
2017-10-24 22:45:58 +03:00
|
|
|
return Nothing();
|
2017-06-08 18:34:00 +03:00
|
|
|
}
|
|
|
|
|
2017-08-23 09:46:38 +03:00
|
|
|
layers::FrameMetrics::ViewID
|
2017-08-17 18:06:51 +03:00
|
|
|
DisplayListBuilder::TopmostScrollId()
|
|
|
|
{
|
2017-10-24 22:45:58 +03:00
|
|
|
for (auto it = mClipStack.crbegin(); it != mClipStack.crend(); it++) {
|
|
|
|
if (it->is<layers::FrameMetrics::ViewID>()) {
|
|
|
|
return it->as<layers::FrameMetrics::ViewID>();
|
|
|
|
}
|
2017-08-17 18:06:51 +03:00
|
|
|
}
|
2017-10-24 22:45:58 +03:00
|
|
|
return layers::FrameMetrics::NULL_SCROLL_ID;
|
2017-08-17 18:06:51 +03:00
|
|
|
}
|
|
|
|
|
2017-10-24 22:46:00 +03:00
|
|
|
bool
|
|
|
|
DisplayListBuilder::TopmostIsClip()
|
|
|
|
{
|
|
|
|
if (mClipStack.empty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return mClipStack.back().is<wr::WrClipId>();
|
|
|
|
}
|
|
|
|
|
2017-11-15 19:39:44 +03:00
|
|
|
void
|
|
|
|
DisplayListBuilder::SetHitTestInfo(const layers::FrameMetrics::ViewID& aScrollId,
|
|
|
|
gfx::CompositorHitTestInfo aHitInfo)
|
|
|
|
{
|
2017-11-23 17:40:00 +03:00
|
|
|
static_assert(sizeof(gfx::CompositorHitTestInfo) == sizeof(uint16_t),
|
|
|
|
"CompositorHitTestInfo should be u16-sized");
|
|
|
|
wr_set_item_tag(mWrState, aScrollId, static_cast<uint16_t>(aHitInfo));
|
2017-11-15 19:39:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisplayListBuilder::ClearHitTestInfo()
|
|
|
|
{
|
|
|
|
wr_clear_item_tag(mWrState);
|
|
|
|
}
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|