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"
|
2018-04-10 19:29:55 +03:00
|
|
|
|
|
|
|
#include "gfxPrefs.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"
|
2018-01-15 16:22:15 +03:00
|
|
|
#include "mozilla/webrender/RenderCompositor.h"
|
2017-01-10 12:17:30 +03:00
|
|
|
#include "mozilla/widget/CompositorWidget.h"
|
2017-01-11 15:51:27 +03:00
|
|
|
#include "mozilla/layers/SynchronousTask.h"
|
2018-11-26 01:57:04 +03:00
|
|
|
#include "TextDrawTarget.h"
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-05-29 18:40:49 +03:00
|
|
|
#define WRDL_LOG(...)
|
2018-11-28 12:16:55 +03:00
|
|
|
/*
|
|
|
|
#define WRDL_LOG(...) printf_stderr("WRDL(%p): " __VA_ARGS__)
|
|
|
|
#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;
|
|
|
|
|
2018-09-08 02:03:13 +03:00
|
|
|
MOZ_DEFINE_MALLOC_SIZE_OF(WebRenderMallocSizeOf)
|
|
|
|
|
2017-01-10 12:17:30 +03:00
|
|
|
class NewRenderer : public RendererEvent {
|
|
|
|
public:
|
2018-05-28 18:29:41 +03:00
|
|
|
NewRenderer(wr::DocumentHandle** aDocHandle,
|
|
|
|
layers::CompositorBridgeParent* aBridge, int32_t* aMaxTextureSize,
|
2018-11-05 12:58:37 +03:00
|
|
|
bool* aUseANGLE, bool* aUseDComp, bool* aUseTripleBuffering,
|
2017-01-11 15:51:27 +03:00
|
|
|
RefPtr<widget::CompositorWidget>&& aWidget,
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::SynchronousTask* aTask, LayoutDeviceIntSize aSize,
|
2017-08-07 13:15:25 +03:00
|
|
|
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),
|
2018-07-20 16:58:40 +03:00
|
|
|
mUseDComp(aUseDComp),
|
2018-11-05 12:58:37 +03:00
|
|
|
mUseTripleBuffering(aUseTripleBuffering),
|
2017-01-25 00:06:17 +03:00
|
|
|
mBridge(aBridge),
|
2018-05-30 22:15:35 +03:00
|
|
|
mCompositorWidget(std::move(aWidget)),
|
2017-01-25 00:06:17 +03:00
|
|
|
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 {
|
|
|
|
layers::AutoCompleteTask complete(mTask);
|
2017-01-11 15:51:27 +03:00
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
UniquePtr<RenderCompositor> compositor =
|
|
|
|
RenderCompositor::Create(std::move(mCompositorWidget));
|
2018-01-17 03:25:31 +03:00
|
|
|
if (!compositor) {
|
|
|
|
// RenderCompositor::Create puts a message into gfxCriticalNote if it is
|
|
|
|
// nullptr
|
|
|
|
return;
|
|
|
|
}
|
2017-01-11 15:51:27 +03:00
|
|
|
|
2018-01-15 16:22:15 +03:00
|
|
|
*mUseANGLE = compositor->UseANGLE();
|
2018-07-20 16:58:40 +03:00
|
|
|
*mUseDComp = compositor->UseDComp();
|
2018-11-05 12:58:37 +03:00
|
|
|
*mUseTripleBuffering = compositor->UseTripleBuffering();
|
2017-01-18 22:50:00 +03:00
|
|
|
|
2018-09-12 18:30:17 +03:00
|
|
|
bool supportLowPriorityTransactions = true; // TODO only for main windows.
|
2017-07-19 10:28:58 +03:00
|
|
|
wr::Renderer* wrRenderer = nullptr;
|
2018-09-12 18:30:17 +03:00
|
|
|
if (!wr_window_new(
|
|
|
|
aWindowId, mSize.width, mSize.height,
|
2018-12-07 18:03:09 +03:00
|
|
|
supportLowPriorityTransactions, gfxPrefs::WebRenderPictureCaching(),
|
|
|
|
compositor->gl(),
|
2018-10-10 06:20:20 +03:00
|
|
|
aRenderThread.ProgramCache() ? aRenderThread.ProgramCache()->Raw()
|
|
|
|
: nullptr,
|
|
|
|
aRenderThread.Shaders() ? aRenderThread.Shaders()->RawShaders()
|
|
|
|
: nullptr,
|
2017-06-13 18:57:16 +03:00
|
|
|
aRenderThread.ThreadPool().Raw(), &WebRenderMallocSizeOf,
|
2017-08-23 13:00:37 +03:00
|
|
|
mDocHandle, &wrRenderer, 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;
|
2018-05-30 22:15:35 +03:00
|
|
|
auto renderer =
|
|
|
|
MakeUnique<RendererOGL>(std::move(thread), std::move(compositor),
|
2017-01-11 15:51:27 +03:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
aRenderThread.AddRenderer(aWindowId, std::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;
|
2018-11-16 20:13:26 +03:00
|
|
|
int32_t* mMaxTextureSize;
|
2017-02-23 11:46:56 +03:00
|
|
|
bool* mUseANGLE;
|
2018-07-20 16:58:40 +03:00
|
|
|
bool* mUseDComp;
|
2018-11-05 12:58:37 +03:00
|
|
|
bool* mUseTripleBuffering;
|
2018-05-28 18:29:41 +03:00
|
|
|
layers::CompositorBridgeParent* 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) : 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
|
|
|
};
|
|
|
|
|
2018-05-11 16:09:19 +03:00
|
|
|
TransactionBuilder::TransactionBuilder(bool aUseSceneBuilderThread)
|
2018-07-10 15:49:21 +03:00
|
|
|
: mUseSceneBuilderThread(aUseSceneBuilderThread) {
|
2018-05-10 20:05:22 +03:00
|
|
|
mTxn = wr_transaction_new(mUseSceneBuilderThread);
|
2018-01-12 14:23:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
TransactionBuilder::~TransactionBuilder() { wr_transaction_delete(mTxn); }
|
|
|
|
|
2018-09-12 18:30:17 +03:00
|
|
|
void TransactionBuilder::SetLowPriority(bool aIsLowPriority) {
|
|
|
|
wr_transaction_set_low_priority(mTxn, aIsLowPriority);
|
|
|
|
}
|
|
|
|
|
2018-01-12 14:23:59 +03:00
|
|
|
void TransactionBuilder::UpdateEpoch(PipelineId aPipelineId, Epoch aEpoch) {
|
|
|
|
wr_transaction_update_epoch(mTxn, aPipelineId, aEpoch);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransactionBuilder::SetRootPipeline(PipelineId aPipelineId) {
|
|
|
|
wr_transaction_set_root_pipeline(mTxn, aPipelineId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransactionBuilder::RemovePipeline(PipelineId aPipelineId) {
|
|
|
|
wr_transaction_remove_pipeline(mTxn, aPipelineId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransactionBuilder::SetDisplayList(
|
2018-11-29 22:22:37 +03:00
|
|
|
gfx::Color aBgColor, Epoch aEpoch, mozilla::LayerSize aViewportSize,
|
2018-01-12 14:23:59 +03:00
|
|
|
wr::WrPipelineId pipeline_id, const wr::LayoutSize& content_size,
|
|
|
|
wr::BuiltDisplayListDescriptor dl_descriptor, wr::Vec<uint8_t>& dl_data) {
|
|
|
|
wr_transaction_set_display_list(mTxn, aEpoch, ToColorF(aBgColor),
|
|
|
|
aViewportSize.width, aViewportSize.height,
|
|
|
|
pipeline_id, content_size, dl_descriptor,
|
|
|
|
&dl_data.inner);
|
|
|
|
}
|
|
|
|
|
2018-01-12 14:24:07 +03:00
|
|
|
void TransactionBuilder::ClearDisplayList(Epoch aEpoch,
|
|
|
|
wr::WrPipelineId aPipelineId) {
|
|
|
|
wr_transaction_clear_display_list(mTxn, aEpoch, aPipelineId);
|
|
|
|
}
|
|
|
|
|
2018-01-12 14:23:59 +03:00
|
|
|
void TransactionBuilder::GenerateFrame() {
|
|
|
|
wr_transaction_generate_frame(mTxn);
|
|
|
|
}
|
|
|
|
|
2018-10-10 06:20:23 +03:00
|
|
|
void TransactionBuilder::InvalidateRenderedFrame() {
|
|
|
|
wr_transaction_invalidate_rendered_frame(mTxn);
|
|
|
|
}
|
|
|
|
|
2018-01-12 14:23:59 +03:00
|
|
|
void TransactionBuilder::UpdateDynamicProperties(
|
|
|
|
const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
|
|
|
|
const nsTArray<wr::WrTransformProperty>& aTransformArray) {
|
2018-04-11 22:28:00 +03:00
|
|
|
wr_transaction_update_dynamic_properties(
|
|
|
|
mTxn, aOpacityArray.IsEmpty() ? nullptr : aOpacityArray.Elements(),
|
|
|
|
aOpacityArray.Length(),
|
|
|
|
aTransformArray.IsEmpty() ? nullptr : aTransformArray.Elements(),
|
|
|
|
aTransformArray.Length());
|
|
|
|
}
|
|
|
|
|
2018-01-12 14:23:59 +03:00
|
|
|
bool TransactionBuilder::IsEmpty() const {
|
|
|
|
return wr_transaction_is_empty(mTxn);
|
|
|
|
}
|
|
|
|
|
2018-11-26 10:08:49 +03:00
|
|
|
bool TransactionBuilder::IsResourceUpdatesEmpty() const {
|
|
|
|
return wr_transaction_resource_updates_is_empty(mTxn);
|
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:35 +03:00
|
|
|
void TransactionBuilder::SetWindowParameters(
|
|
|
|
const LayoutDeviceIntSize& aWindowSize,
|
|
|
|
const LayoutDeviceIntRect& aDocumentRect) {
|
2018-11-16 20:13:26 +03:00
|
|
|
wr::DeviceIntSize wrWindowSize;
|
2018-01-29 16:33:35 +03:00
|
|
|
wrWindowSize.width = aWindowSize.width;
|
|
|
|
wrWindowSize.height = aWindowSize.height;
|
2018-11-16 20:13:26 +03:00
|
|
|
wr::DeviceIntRect wrDocRect;
|
2018-01-29 16:33:35 +03:00
|
|
|
wrDocRect.origin.x = aDocumentRect.x;
|
|
|
|
wrDocRect.origin.y = aDocumentRect.y;
|
|
|
|
wrDocRect.size.width = aDocumentRect.width;
|
|
|
|
wrDocRect.size.height = aDocumentRect.height;
|
|
|
|
wr_transaction_set_window_parameters(mTxn, &wrWindowSize, &wrDocRect);
|
2018-01-12 14:23:59 +03:00
|
|
|
}
|
|
|
|
|
2018-01-17 19:19:39 +03:00
|
|
|
void TransactionBuilder::UpdateScrollPosition(
|
|
|
|
const wr::WrPipelineId& aPipelineId,
|
2018-11-01 23:15:46 +03:00
|
|
|
const layers::ScrollableLayerGuid::ViewID& aScrollId,
|
2018-01-17 19:19:39 +03:00
|
|
|
const wr::LayoutPoint& aScrollPosition) {
|
|
|
|
wr_transaction_scroll_layer(mTxn, aPipelineId, aScrollId, aScrollPosition);
|
|
|
|
}
|
|
|
|
|
2018-04-17 00:39:26 +03:00
|
|
|
TransactionWrapper::TransactionWrapper(Transaction* aTxn) : mTxn(aTxn) {}
|
|
|
|
|
|
|
|
void TransactionWrapper::AppendTransformProperties(
|
|
|
|
const nsTArray<wr::WrTransformProperty>& aTransformArray) {
|
|
|
|
wr_transaction_append_transform_properties(
|
|
|
|
mTxn, aTransformArray.IsEmpty() ? nullptr : aTransformArray.Elements(),
|
|
|
|
aTransformArray.Length());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransactionWrapper::UpdateScrollPosition(
|
|
|
|
const wr::WrPipelineId& aPipelineId,
|
2018-11-01 23:15:46 +03:00
|
|
|
const layers::ScrollableLayerGuid::ViewID& aScrollId,
|
2018-04-17 00:39:26 +03:00
|
|
|
const wr::LayoutPoint& aScrollPosition) {
|
|
|
|
wr_transaction_scroll_layer(mTxn, aPipelineId, aScrollId, aScrollPosition);
|
|
|
|
}
|
2018-01-12 14:23:59 +03:00
|
|
|
|
2018-10-19 17:24:14 +03:00
|
|
|
void TransactionWrapper::UpdatePinchZoom(float aZoom) {
|
|
|
|
wr_transaction_pinch_zoom(mTxn, aZoom);
|
|
|
|
}
|
|
|
|
|
2017-11-10 15:30:53 +03:00
|
|
|
/*static*/ already_AddRefed<WebRenderAPI> WebRenderAPI::Create(
|
2018-04-10 19:29:55 +03:00
|
|
|
layers::CompositorBridgeParent* aBridge,
|
2017-03-07 02:46:30 +03:00
|
|
|
RefPtr<widget::CompositorWidget>&& aWidget, const wr::WrWindowId& aWindowId,
|
|
|
|
LayoutDeviceIntSize aSize) {
|
2017-01-10 12:17:30 +03:00
|
|
|
MOZ_ASSERT(aBridge);
|
|
|
|
MOZ_ASSERT(aWidget);
|
2018-03-12 23:38:10 +03:00
|
|
|
static_assert(
|
|
|
|
sizeof(size_t) == sizeof(uintptr_t),
|
|
|
|
"The FFI bindings assume size_t is the same size as uintptr_t!");
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-08-09 15:46:24 +03:00
|
|
|
wr::DocumentHandle* docHandle = nullptr;
|
2018-11-16 20:13:26 +03:00
|
|
|
int32_t maxTextureSize = 0;
|
2017-02-23 11:46:56 +03:00
|
|
|
bool useANGLE = false;
|
2018-07-20 16:58:40 +03:00
|
|
|
bool useDComp = false;
|
2018-11-05 12:58:37 +03:00
|
|
|
bool useTripleBuffering = 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
|
2017-01-11 15:51:27 +03:00
|
|
|
// created on the render thread. If need be we could delay waiting on this
|
2017-08-09 15:46:24 +03:00
|
|
|
// task until the next time we need to access the DocumentHandle object.
|
2017-01-17 03:22:09 +03:00
|
|
|
layers::SynchronousTask task("Create Renderer");
|
2018-11-05 12:58:37 +03:00
|
|
|
auto event = MakeUnique<NewRenderer>(
|
|
|
|
&docHandle, aBridge, &maxTextureSize, &useANGLE, &useDComp,
|
2018-05-30 22:15:35 +03:00
|
|
|
&useTripleBuffering, std::move(aWidget), &task, aSize, &syncHandle);
|
|
|
|
RenderThread::Get()->RunEvent(aWindowId, std::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
|
|
|
|
2018-11-05 12:58:37 +03:00
|
|
|
return RefPtr<WebRenderAPI>(
|
|
|
|
new WebRenderAPI(docHandle, aWindowId, maxTextureSize, useANGLE,
|
|
|
|
useDComp, useTripleBuffering, 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);
|
|
|
|
|
2018-11-05 12:58:37 +03:00
|
|
|
RefPtr<WebRenderAPI> renderApi =
|
|
|
|
new WebRenderAPI(docHandle, mId, mMaxTextureSize, mUseANGLE, mUseDComp,
|
|
|
|
mUseTripleBuffering, mSyncHandle);
|
2017-08-09 15:46:25 +03:00
|
|
|
renderApi->mRootApi = this; // Hold root api
|
2018-01-29 16:33:35 +03:00
|
|
|
renderApi->mRootDocumentApi = this;
|
2017-08-09 15:46:25 +03:00
|
|
|
return renderApi.forget();
|
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:35 +03:00
|
|
|
already_AddRefed<WebRenderAPI> WebRenderAPI::CreateDocument(
|
|
|
|
LayoutDeviceIntSize aSize, int8_t aLayerIndex) {
|
2018-11-16 20:13:26 +03:00
|
|
|
wr::DeviceIntSize wrSize;
|
2018-01-29 16:33:35 +03:00
|
|
|
wrSize.width = aSize.width;
|
|
|
|
wrSize.height = aSize.height;
|
|
|
|
wr::DocumentHandle* newDoc;
|
|
|
|
|
|
|
|
wr_api_create_document(mDocHandle, &newDoc, wrSize, aLayerIndex);
|
|
|
|
|
|
|
|
RefPtr<WebRenderAPI> api(new WebRenderAPI(newDoc, mId, mMaxTextureSize,
|
2018-07-20 16:58:40 +03:00
|
|
|
mUseANGLE, mUseDComp,
|
2018-11-05 12:58:37 +03:00
|
|
|
mUseTripleBuffering, mSyncHandle));
|
2018-01-29 16:33:35 +03:00
|
|
|
api->mRootApi = this;
|
|
|
|
return api.forget();
|
|
|
|
}
|
|
|
|
|
2017-02-22 21:19:57 +03:00
|
|
|
wr::WrIdNamespace 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() {
|
2018-01-29 16:33:35 +03:00
|
|
|
if (!mRootDocumentApi) {
|
|
|
|
wr_api_delete_document(mDocHandle);
|
|
|
|
}
|
2017-11-24 12:34:50 +03:00
|
|
|
|
2018-01-29 16:33:35 +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);
|
2018-05-30 22:15:35 +03:00
|
|
|
RunOnRenderThread(std::move(event));
|
2017-08-09 15:46:25 +03:00
|
|
|
task.Wait();
|
2018-01-29 16:33:35 +03:00
|
|
|
|
|
|
|
wr_api_shut_down(mDocHandle);
|
2017-08-09 15:46:25 +03:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2018-11-15 02:10:57 +03:00
|
|
|
void WebRenderAPI::UpdateDebugFlags(uint32_t aFlags) {
|
|
|
|
if (mDebugFlags.mBits != aFlags) {
|
|
|
|
mDebugFlags.mBits = aFlags;
|
|
|
|
wr_api_set_debug_flags(mDocHandle, mDebugFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-12 14:23:59 +03:00
|
|
|
void WebRenderAPI::SendTransaction(TransactionBuilder& aTxn) {
|
2018-11-15 02:10:57 +03:00
|
|
|
UpdateDebugFlags(gfx::gfxVars::WebRenderDebugFlags());
|
2018-05-10 20:05:22 +03:00
|
|
|
wr_api_send_transaction(mDocHandle, aTxn.Raw(), aTxn.UseSceneBuilderThread());
|
2018-01-12 14:23:59 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:39:44 +03:00
|
|
|
bool WebRenderAPI::HitTest(const wr::WorldPoint& aPoint,
|
|
|
|
wr::WrPipelineId& aOutPipelineId,
|
2018-11-01 23:15:46 +03:00
|
|
|
layers::ScrollableLayerGuid::ViewID& aOutScrollId,
|
2017-11-15 19:39:44 +03:00
|
|
|
gfx::CompositorHitTestInfo& aOutHitInfo) {
|
2018-09-25 21:47:55 +03:00
|
|
|
static_assert(DoesCompositorHitTestInfoFitIntoBits<16>(),
|
|
|
|
"CompositorHitTestFlags MAX value has to be less than number "
|
|
|
|
"of bits in uint16_t");
|
|
|
|
|
|
|
|
uint16_t serialized = static_cast<uint16_t>(aOutHitInfo.serialize());
|
|
|
|
const bool result = wr_api_hit_test(mDocHandle, aPoint, &aOutPipelineId,
|
|
|
|
&aOutScrollId, &serialized);
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
aOutHitInfo.deserialize(serialized);
|
|
|
|
}
|
|
|
|
return result;
|
2017-11-15 19:39:44 +03:00
|
|
|
}
|
|
|
|
|
2018-06-26 00:37:35 +03:00
|
|
|
void WebRenderAPI::Readback(const TimeStamp& aStartTime, gfx::IntSize size,
|
2018-10-17 01:54:01 +03:00
|
|
|
const Range<uint8_t>& buffer) {
|
2017-01-25 07:29:34 +03:00
|
|
|
class Readback : public RendererEvent {
|
|
|
|
public:
|
2018-11-04 23:35:36 +03:00
|
|
|
explicit Readback(layers::SynchronousTask* aTask, TimeStamp aStartTime,
|
|
|
|
gfx::IntSize aSize, const Range<uint8_t>& aBuffer)
|
|
|
|
: mTask(aTask), mStartTime(aStartTime), mSize(aSize), mBuffer(aBuffer) {
|
2018-10-17 01:54:01 +03:00
|
|
|
MOZ_COUNT_CTOR(Readback);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2017-03-07 13:37:28 +03:00
|
|
|
|
|
|
|
~Readback() { MOZ_COUNT_DTOR(Readback); }
|
2018-11-15 02:10:57 +03:00
|
|
|
|
2018-08-10 18:14:57 +03:00
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override {
|
2018-12-08 02:28:41 +03:00
|
|
|
aRenderThread.UpdateAndRender(aWindowId, VsyncId(), mStartTime,
|
|
|
|
/* aRender */ true, Some(mSize),
|
|
|
|
Some(mBuffer), false);
|
2017-04-05 17:12:11 +03:00
|
|
|
layers::AutoCompleteTask complete(mTask);
|
|
|
|
}
|
|
|
|
|
2017-01-25 07:29:34 +03:00
|
|
|
layers::SynchronousTask* mTask;
|
2018-06-26 00:37:35 +03:00
|
|
|
TimeStamp mStartTime;
|
2017-01-25 07:29:34 +03:00
|
|
|
gfx::IntSize mSize;
|
2018-10-17 01:54:01 +03:00
|
|
|
const Range<uint8_t>& mBuffer;
|
2018-11-30 13:46:48 +03:00
|
|
|
};
|
|
|
|
|
2018-11-15 02:10:57 +03:00
|
|
|
// Disable debug flags during readback. See bug 1436020.
|
|
|
|
UpdateDebugFlags(0);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-01-25 07:29:34 +03:00
|
|
|
layers::SynchronousTask task("Readback");
|
2018-10-17 01:54:01 +03:00
|
|
|
auto event = MakeUnique<Readback>(&task, aStartTime, size, buffer);
|
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.
|
2018-05-30 22:15:35 +03:00
|
|
|
RunOnRenderThread(std::move(event));
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
task.Wait();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-11-15 02:10:57 +03:00
|
|
|
UpdateDebugFlags(gfx::gfxVars::WebRenderDebugFlags());
|
2017-04-05 17:12:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebRenderAPI::ClearAllCaches() { wr_api_clear_all_caches(mDocHandle); }
|
|
|
|
|
|
|
|
void WebRenderAPI::Pause() {
|
|
|
|
class PauseEvent : public RendererEvent {
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
2017-04-05 17:12:11 +03:00
|
|
|
explicit PauseEvent(layers::SynchronousTask* aTask) : mTask(aTask) {
|
|
|
|
MOZ_COUNT_CTOR(PauseEvent);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
~PauseEvent() { MOZ_COUNT_DTOR(PauseEvent); }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-01-25 07:29:34 +03:00
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override {
|
2017-04-05 17:12:11 +03:00
|
|
|
aRenderThread.Pause(aWindowId);
|
2017-01-25 07:29:34 +03:00
|
|
|
layers::AutoCompleteTask complete(mTask);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2017-01-25 07:29:34 +03:00
|
|
|
layers::SynchronousTask* mTask;
|
2018-11-30 13:46:48 +03:00
|
|
|
};
|
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
layers::SynchronousTask task("Pause");
|
|
|
|
auto event = MakeUnique<PauseEvent>(&task);
|
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
|
|
|
// event.
|
2018-05-30 22:15:35 +03:00
|
|
|
RunOnRenderThread(std::move(event));
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
task.Wait();
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
bool WebRenderAPI::Resume() {
|
|
|
|
class ResumeEvent : public RendererEvent {
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
2017-04-05 17:12:11 +03:00
|
|
|
explicit ResumeEvent(layers::SynchronousTask* aTask, bool* aResult)
|
|
|
|
: mTask(aTask), mResult(aResult) {
|
|
|
|
MOZ_COUNT_CTOR(ResumeEvent);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
~ResumeEvent() { MOZ_COUNT_DTOR(ResumeEvent); }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-01-25 07:29:34 +03:00
|
|
|
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override {
|
2017-04-05 17:12:11 +03:00
|
|
|
*mResult = aRenderThread.Resume(aWindowId);
|
2017-01-25 07:29:34 +03:00
|
|
|
layers::AutoCompleteTask complete(mTask);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2017-01-25 07:29:34 +03:00
|
|
|
layers::SynchronousTask* mTask;
|
2017-04-05 17:12:11 +03:00
|
|
|
bool* mResult;
|
2018-11-30 13:46:48 +03:00
|
|
|
};
|
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
bool result = false;
|
|
|
|
layers::SynchronousTask task("Resume");
|
|
|
|
auto event = MakeUnique<ResumeEvent>(&task, &result);
|
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
|
|
|
// event.
|
2018-05-30 22:15:35 +03:00
|
|
|
RunOnRenderThread(std::move(event));
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-08-09 15:46:25 +03:00
|
|
|
task.Wait();
|
2017-04-05 17:12:11 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-08-20 16:23:54 +03:00
|
|
|
void WebRenderAPI::NotifyMemoryPressure() {
|
|
|
|
wr_api_notify_memory_pressure(mDocHandle);
|
|
|
|
}
|
|
|
|
|
2018-09-08 02:03:13 +03:00
|
|
|
void WebRenderAPI::AccumulateMemoryReport(MemoryReport* aReport) {
|
|
|
|
wr_api_accumulate_memory_report(mDocHandle, aReport);
|
|
|
|
}
|
|
|
|
|
2018-04-10 19:29:55 +03:00
|
|
|
void WebRenderAPI::WakeSceneBuilder() { wr_api_wake_scene_builder(mDocHandle); }
|
|
|
|
|
2018-04-27 17:46:21 +03:00
|
|
|
void WebRenderAPI::FlushSceneBuilder() {
|
|
|
|
wr_api_flush_scene_builder(mDocHandle);
|
|
|
|
}
|
|
|
|
|
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.
|
2018-05-30 22:15:35 +03:00
|
|
|
RunOnRenderThread(std::move(event));
|
2017-01-25 07:29:34 +03:00
|
|
|
|
|
|
|
task.Wait();
|
|
|
|
}
|
|
|
|
|
2018-01-26 18:09:30 +03:00
|
|
|
void WebRenderAPI::Capture() {
|
|
|
|
uint8_t bits = 3; // TODO: get from JavaScript
|
|
|
|
const char* path = "wr-capture"; // TODO: get from JavaScript
|
|
|
|
wr_api_capture(mDocHandle, path, bits);
|
|
|
|
}
|
|
|
|
|
2017-10-06 20:06:10 +03:00
|
|
|
void TransactionBuilder::Clear() { wr_resource_updates_clear(mTxn); }
|
2018-01-26 18:09:30 +03:00
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::Notify(wr::Checkpoint aWhen,
|
|
|
|
UniquePtr<NotificationHandler> aEvent) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_transaction_notify(mTxn, aWhen,
|
|
|
|
reinterpret_cast<uintptr_t>(aEvent.release()));
|
2017-09-04 14:59:36 +03:00
|
|
|
}
|
|
|
|
|
2018-09-24 18:53:36 +03:00
|
|
|
void TransactionBuilder::AddImage(ImageKey key,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
wr::Vec<uint8_t>& aBytes) {
|
|
|
|
wr_resource_updates_add_image(mTxn, key, &aDescriptor, &aBytes.inner);
|
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::AddBlobImage(BlobImageKey key,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
wr::Vec<uint8_t>& aBytes) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_add_blob_image(mTxn, key, &aDescriptor, &aBytes.inner);
|
2017-03-27 14:44:52 +03:00
|
|
|
}
|
|
|
|
|
2018-11-24 02:33:49 +03:00
|
|
|
void TransactionBuilder::AddExternalImage(
|
|
|
|
ImageKey key, const ImageDescriptor& aDescriptor, ExternalImageId aExtID,
|
2018-01-29 16:33:39 +03:00
|
|
|
wr::WrExternalImageBufferType aBufferType, uint8_t aChannelIndex) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_add_external_image(mTxn, key, &aDescriptor, aExtID,
|
2017-09-14 19:48:55 +03:00
|
|
|
aBufferType, aChannelIndex);
|
2017-03-02 04:22:40 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::AddExternalImageBuffer(
|
|
|
|
ImageKey aKey, const ImageDescriptor& aDescriptor,
|
|
|
|
ExternalImageId aHandle) {
|
2017-07-28 15:08:11 +03:00
|
|
|
auto channelIndex = 0;
|
2018-01-29 16:33:39 +03:00
|
|
|
AddExternalImage(aKey, aDescriptor, aHandle,
|
|
|
|
wr::WrExternalImageBufferType::ExternalBuffer, channelIndex);
|
2017-09-04 14:59:12 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::UpdateImageBuffer(ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
wr::Vec<uint8_t>& aBytes) {
|
2017-07-28 15:08:11 +03:00
|
|
|
wr_resource_updates_update_image(mTxn, aKey, &aDescriptor, &aBytes.inner);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2018-11-24 02:33:49 +03:00
|
|
|
void TransactionBuilder::UpdateBlobImage(BlobImageKey aKey,
|
2018-01-29 16:33:39 +03:00
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
wr::Vec<uint8_t>& aBytes,
|
2018-11-24 02:33:49 +03:00
|
|
|
const wr::LayoutIntRect& aDirtyRect) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_update_blob_image(mTxn, aKey, &aDescriptor, &aBytes.inner,
|
2017-08-03 23:38:33 +03:00
|
|
|
aDirtyRect);
|
2017-07-28 15:08:11 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::UpdateExternalImage(
|
|
|
|
ImageKey aKey, const ImageDescriptor& aDescriptor, ExternalImageId aExtID,
|
|
|
|
wr::WrExternalImageBufferType aBufferType, uint8_t aChannelIndex) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_update_external_image(mTxn, aKey, &aDescriptor, aExtID,
|
2017-09-04 14:59:12 +03:00
|
|
|
aBufferType, aChannelIndex);
|
2017-07-28 15:08:11 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-07-12 18:43:09 +03:00
|
|
|
void TransactionBuilder::UpdateExternalImageWithDirtyRect(
|
|
|
|
ImageKey aKey, const ImageDescriptor& aDescriptor, ExternalImageId aExtID,
|
|
|
|
wr::WrExternalImageBufferType aBufferType,
|
2018-11-16 20:13:26 +03:00
|
|
|
const wr::DeviceIntRect& aDirtyRect, uint8_t aChannelIndex) {
|
2018-07-12 18:43:09 +03:00
|
|
|
wr_resource_updates_update_external_image_with_dirty_rect(
|
|
|
|
mTxn, aKey, &aDescriptor, aExtID, aBufferType, aChannelIndex, aDirtyRect);
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-11-24 02:33:49 +03:00
|
|
|
void TransactionBuilder::SetImageVisibleArea(BlobImageKey aKey,
|
2018-11-16 20:13:26 +03:00
|
|
|
const wr::DeviceIntRect& aArea) {
|
2018-11-24 02:33:49 +03:00
|
|
|
wr_resource_updates_set_blob_image_visible_area(mTxn, aKey, &aArea);
|
2018-07-19 23:33:05 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::DeleteImage(ImageKey aKey) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_delete_image(mTxn, aKey);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2018-11-24 02:33:49 +03:00
|
|
|
void TransactionBuilder::DeleteBlobImage(BlobImageKey aKey) {
|
|
|
|
wr_resource_updates_delete_blob_image(mTxn, aKey);
|
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::AddRawFont(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes,
|
|
|
|
uint32_t aIndex) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_add_raw_font(mTxn, aKey, &aBytes.inner, aIndex);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::AddFontDescriptor(wr::FontKey aKey,
|
|
|
|
wr::Vec<uint8_t>& aBytes,
|
|
|
|
uint32_t aIndex) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_add_font_descriptor(mTxn, aKey, &aBytes.inner, aIndex);
|
2017-11-07 04:19:46 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::DeleteFont(wr::FontKey aKey) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_delete_font(mTxn, aKey);
|
2017-01-16 17:22:47 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::AddFontInstance(
|
|
|
|
wr::FontInstanceKey aKey, wr::FontKey aFontKey, float aGlyphSize,
|
|
|
|
const wr::FontInstanceOptions* aOptions,
|
|
|
|
const wr::FontInstancePlatformOptions* aPlatformOptions,
|
|
|
|
wr::Vec<uint8_t>& aVariations) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_add_font_instance(mTxn, aKey, aFontKey, aGlyphSize,
|
2017-09-21 06:18:23 +03:00
|
|
|
aOptions, aPlatformOptions,
|
|
|
|
&aVariations.inner);
|
2017-08-30 20:45:11 +03:00
|
|
|
}
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
void TransactionBuilder::DeleteFontInstance(wr::FontInstanceKey aKey) {
|
2018-05-26 18:09:21 +03:00
|
|
|
wr_resource_updates_delete_font_instance(mTxn, 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);
|
2018-05-30 22:15:35 +03:00
|
|
|
RunOnRenderThread(std::move(event));
|
2017-07-28 02:05:56 +03:00
|
|
|
}
|
|
|
|
|
2017-01-28 00:08:17 +03:00
|
|
|
void 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)
|
Bug 1465935 - Fix hit-testing for fixed-pos items inside iframes. r=mstange
Without this patch, the scrollId for display items inside a fixed-pos
item end as the ASR of the item. In the case of fixed-pos items that are
inside iframes, the ASR is the outer document's root scrollframe. This
means that e.g. wheel-scrolling while over a fixed-pos item inside an
iframe ends up scrolling the outer document's root scrollframe instead
of the iframe's root scrollframe.
In the non-WR codepath, there some APZ machinery that walks up in the
HitTestingTreeNode tree from the hit result, looking to see if that node
has a fixed-pos ancestor, and if so, uses the fixed-pos item's target
APZ as the real hit result. This machinery doesn't exist in WR, because
we don't use the HitTestingTreeNode tree for hit-testing in APZ.
Instead, we need to make sure that the item tag for those display items
already has the appropriate scrollid set.
This patch accomplishes this by introducing a new RAII class that is
pushed into the wr::DisplayListBuilder while we are building display
items inside a nsDisplayFixedPosition, and allows the desired scroll id to
be set on the hit-testing display items.
This behaviour is exercised by test_group_wheelevents, which can now be
enabled with this fix.
MozReview-Commit-ID: L2erPVzJeql
--HG--
extra : rebase_source : 1db630513cb1dc16d4e38649812e81f62c8da99c
2018-06-07 20:06:33 +03:00
|
|
|
: mActiveFixedPosTracker(nullptr) {
|
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); }
|
2018-07-19 22:30:30 +03:00
|
|
|
|
|
|
|
usize DisplayListBuilder::Dump(usize aIndent, const Maybe<usize>& aStart,
|
|
|
|
const Maybe<usize>& aEnd) {
|
|
|
|
return wr_dump_display_list(mWrState, aIndent, aStart.ptrOr(nullptr),
|
|
|
|
aEnd.ptrOr(nullptr));
|
|
|
|
}
|
2017-10-06 20:06:10 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::Finalize(wr::LayoutSize& aOutContentSize,
|
2017-05-15 22:13:31 +03:00
|
|
|
BuiltDisplayList& aOutDisplayList) {
|
2017-03-03 18:45:29 +03:00
|
|
|
wr_api_finalize_builder(mWrState, &aOutContentSize, &aOutDisplayList.dl_desc,
|
2017-05-15 22:13:31 +03:00
|
|
|
&aOutDisplayList.dl.inner);
|
2017-03-01 17:10:53 +03:00
|
|
|
}
|
|
|
|
|
2018-11-29 22:22:37 +03:00
|
|
|
Maybe<wr::WrClipId> DisplayListBuilder::PushStackingContext(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::WrClipId* aClipNodeId,
|
2017-11-15 11:09:21 +03:00
|
|
|
const WrAnimationProperty* aAnimation, const float* aOpacity,
|
2017-07-19 10:28:58 +03:00
|
|
|
const gfx::Matrix4x4* aTransform, wr::TransformStyle aTransformStyle,
|
|
|
|
const gfx::Matrix4x4* aPerspective, const wr::MixBlendMode& aMixBlendMode,
|
2017-09-21 09:41:38 +03:00
|
|
|
const nsTArray<wr::WrFilterOp>& aFilters, bool aIsBackfaceVisible,
|
2018-09-23 04:19:52 +03:00
|
|
|
const wr::RasterSpace& aRasterSpace) {
|
2018-09-14 17:42:20 +03:00
|
|
|
MOZ_ASSERT(mClipChainLeaf.isNothing(),
|
|
|
|
"Non-empty leaf from clip chain given, but not used with SC!");
|
|
|
|
|
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);
|
|
|
|
}
|
2018-11-29 22:22:37 +03:00
|
|
|
|
2017-08-14 12:31:55 +03:00
|
|
|
const wr::LayoutTransform* maybePerspective =
|
|
|
|
aPerspective ? &perspective : nullptr;
|
2018-11-29 22:22:37 +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");
|
2018-05-08 16:16:26 +03:00
|
|
|
|
|
|
|
bool outIsReferenceFrame = false;
|
|
|
|
uintptr_t outReferenceFrameId = 0;
|
2018-11-29 22:22:37 +03:00
|
|
|
wr_dp_push_stacking_context(
|
|
|
|
mWrState, aBounds, aClipNodeId, aAnimation, aOpacity, maybeTransform,
|
2018-05-04 03:38:37 +03:00
|
|
|
aTransformStyle, maybePerspective, aMixBlendMode, aFilters.Elements(),
|
2018-05-08 16:16:26 +03:00
|
|
|
aFilters.Length(), aIsBackfaceVisible, aRasterSpace, &outIsReferenceFrame,
|
|
|
|
&outReferenceFrameId);
|
|
|
|
return outIsReferenceFrame ? Some(wr::WrClipId{outReferenceFrameId})
|
|
|
|
: Nothing();
|
2017-03-29 12:23:08 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-05-16 17:47:08 +03:00
|
|
|
void DisplayListBuilder::PopStackingContext(bool aIsReferenceFrame) {
|
2017-08-28 21:20:25 +03:00
|
|
|
WRDL_LOG("PopStackingContext\n", mWrState);
|
2018-05-16 17:47:08 +03:00
|
|
|
wr_dp_pop_stacking_context(mWrState, aIsReferenceFrame);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2018-05-08 16:08:39 +03:00
|
|
|
wr::WrClipChainId DisplayListBuilder::DefineClipChain(
|
|
|
|
const Maybe<wr::WrClipChainId>& aParent,
|
|
|
|
const nsTArray<wr::WrClipId>& aClips) {
|
|
|
|
uint64_t clipchainId =
|
|
|
|
wr_dp_define_clipchain(mWrState, aParent ? &(aParent->id) : nullptr,
|
2018-11-23 22:49:56 +03:00
|
|
|
aClips.Elements(), aClips.Length());
|
2018-05-08 16:08:39 +03:00
|
|
|
WRDL_LOG("DefineClipChain id=%" PRIu64 " p=%s clips=%zu\n", mWrState,
|
|
|
|
clipchainId, aParent ? Stringify(aParent->id).c_str() : "(nil)",
|
2018-11-26 05:32:15 +03:00
|
|
|
aClips.Length());
|
2018-05-08 16:08:39 +03:00
|
|
|
return wr::WrClipChainId{clipchainId};
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-05-08 16:08:39 +03:00
|
|
|
wr::WrClipId DisplayListBuilder::DefineClip(
|
2017-10-24 22:45:57 +03:00
|
|
|
const Maybe<wr::WrClipId>& aParentId, 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) {
|
2018-03-02 00:49:54 +03:00
|
|
|
size_t clip_id =
|
|
|
|
wr_dp_define_clip(mWrState, aParentId.ptrOr(nullptr), aClipRect,
|
2017-08-08 22:43:17 +03:00
|
|
|
aComplex ? aComplex->Elements() : nullptr,
|
|
|
|
aComplex ? aComplex->Length() : 0, aMask);
|
2018-05-08 16:08:39 +03:00
|
|
|
WRDL_LOG("DefineClip id=%zu p=%s r=%s m=%p b=%s complex=%zu\n", mWrState,
|
|
|
|
clip_id, aParentId ? Stringify(aParentId->id).c_str() : "(nil)",
|
2017-10-24 22:45:57 +03:00
|
|
|
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};
|
|
|
|
}
|
|
|
|
|
2018-05-08 16:08:39 +03:00
|
|
|
void DisplayListBuilder::PushClip(const wr::WrClipId& aClipId) {
|
2018-03-02 00:49:54 +03:00
|
|
|
WRDL_LOG("PushClip id=%zu\n", mWrState, aClipId.id);
|
2018-11-23 22:49:56 +03:00
|
|
|
wr_dp_push_clip(mWrState, aClipId);
|
2017-04-18 18:09:39 +03:00
|
|
|
}
|
|
|
|
|
2018-05-08 16:08:39 +03:00
|
|
|
void DisplayListBuilder::PopClip() {
|
2017-10-24 22:45:58 +03:00
|
|
|
WRDL_LOG("PopClip\n", mWrState);
|
2017-10-25 22:05:20 +03:00
|
|
|
wr_dp_pop_clip(mWrState);
|
|
|
|
}
|
|
|
|
|
2017-09-21 17:11:39 +03:00
|
|
|
wr::WrClipId DisplayListBuilder::DefineStickyFrame(
|
|
|
|
const wr::LayoutRect& aContentRect, const float* aTopMargin,
|
2017-10-31 16:17:22 +03:00
|
|
|
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) {
|
2018-03-02 00:49:54 +03:00
|
|
|
size_t id = wr_dp_define_sticky_frame(
|
|
|
|
mWrState, aContentRect, aTopMargin, aRightMargin, aBottomMargin,
|
2017-11-07 18:16:48 +03:00
|
|
|
aLeftMargin, aVerticalBounds, aHorizontalBounds, aAppliedOffset);
|
2018-03-02 00:49:54 +03:00
|
|
|
WRDL_LOG("DefineSticky id=%zu c=%s t=%s r=%s b=%s l=%s v=%s h=%s a=%s\n",
|
2017-09-21 17:11:39 +03:00
|
|
|
mWrState, id, 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());
|
2018-05-08 16:08:39 +03:00
|
|
|
return wr::WrClipId{id};
|
2017-09-21 17:11:39 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
Maybe<wr::WrClipId> DisplayListBuilder::GetScrollIdForDefinedScrollLayer(
|
|
|
|
layers::ScrollableLayerGuid::ViewID aViewId) const {
|
|
|
|
if (aViewId == layers::ScrollableLayerGuid::NULL_SCROLL_ID) {
|
2018-11-23 22:49:56 +03:00
|
|
|
return Some(wr::RootScrollNode());
|
2018-01-22 21:29:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
auto it = mScrollIds.find(aViewId);
|
|
|
|
if (it == mScrollIds.end()) {
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
|
|
|
return Some(it->second);
|
2017-08-30 21:51:19 +03:00
|
|
|
}
|
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
wr::WrClipId DisplayListBuilder::DefineScrollLayer(
|
|
|
|
const layers::ScrollableLayerGuid::ViewID& aViewId,
|
2018-05-08 16:08:39 +03:00
|
|
|
const Maybe<wr::WrClipId>& aParentId, const wr::LayoutRect& aContentRect,
|
2017-08-30 21:51:19 +03:00
|
|
|
const wr::LayoutRect& aClipRect) {
|
2018-01-22 21:29:06 +03:00
|
|
|
auto it = mScrollIds.find(aViewId);
|
|
|
|
if (it != mScrollIds.end()) {
|
|
|
|
return it->second;
|
2017-06-16 22:12:24 +03:00
|
|
|
}
|
2018-01-22 21:29:06 +03:00
|
|
|
|
|
|
|
// We haven't defined aViewId before, so let's define it now.
|
2018-03-02 00:49:54 +03:00
|
|
|
size_t numericScrollId = wr_dp_define_scroll_layer(
|
2018-11-23 22:49:56 +03:00
|
|
|
mWrState, aViewId, aParentId.ptrOr(nullptr), aContentRect, aClipRect);
|
2017-08-30 21:51:19 +03:00
|
|
|
|
2018-05-08 16:08:39 +03:00
|
|
|
WRDL_LOG("DefineScrollLayer id=%" PRIu64 "/%zu p=%s co=%s cl=%s\n", mWrState,
|
|
|
|
aViewId, numericScrollId,
|
|
|
|
aParentId ? Stringify(aParentId->id).c_str() : "(nil)",
|
|
|
|
Stringify(aContentRect).c_str(), Stringify(aClipRect).c_str());
|
2017-02-14 21:34:15 +03:00
|
|
|
|
2018-05-08 16:08:39 +03:00
|
|
|
auto clipId = wr::WrClipId{numericScrollId};
|
|
|
|
mScrollIds[aViewId] = clipId;
|
|
|
|
return clipId;
|
2017-02-14 21:34:15 +03:00
|
|
|
}
|
|
|
|
|
2018-09-14 17:42:20 +03:00
|
|
|
void DisplayListBuilder::PushClipAndScrollInfo(
|
|
|
|
const wr::WrClipId* aScrollId, const wr::WrClipChainId* aClipChainId,
|
|
|
|
const Maybe<wr::LayoutRect>& aClipChainLeaf) {
|
|
|
|
if (aScrollId) {
|
|
|
|
WRDL_LOG("PushClipAndScroll s=%zu c=%s\n", mWrState, aScrollId->id,
|
|
|
|
aClipChainId ? Stringify(aClipChainId->id).c_str() : "none");
|
2018-11-23 22:49:56 +03:00
|
|
|
wr_dp_push_clip_and_scroll_info(
|
2018-09-14 17:42:20 +03:00
|
|
|
mWrState, *aScrollId, aClipChainId ? &(aClipChainId->id) : nullptr);
|
|
|
|
}
|
|
|
|
mClipChainLeaf = aClipChainLeaf;
|
2017-06-08 18:34:01 +03:00
|
|
|
}
|
|
|
|
|
2018-09-14 17:42:20 +03:00
|
|
|
void DisplayListBuilder::PopClipAndScrollInfo(const wr::WrClipId* aScrollId) {
|
|
|
|
if (aScrollId) {
|
|
|
|
WRDL_LOG("PopClipAndScroll\n", mWrState);
|
|
|
|
wr_dp_pop_clip_and_scroll_info(mWrState);
|
|
|
|
}
|
|
|
|
mClipChainLeaf.reset();
|
2017-06-08 18:34:01 +03:00
|
|
|
}
|
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void 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) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr::LayoutRect clip = MergeClipLeaf(aClip);
|
2017-08-28 21:20:25 +03:00
|
|
|
WRDL_LOG("PushRect b=%s cl=%s c=%s\n", mWrState, Stringify(aBounds).c_str(),
|
2017-05-29 18:40:49 +03:00
|
|
|
Stringify(clip).c_str(), Stringify(aColor).c_str());
|
2018-09-14 17:42:20 +03:00
|
|
|
wr_dp_push_rect(mWrState, aBounds, clip, 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) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr::LayoutRect clip = MergeClipLeaf(aBounds);
|
|
|
|
WRDL_LOG("PushClearRect b=%s c=%s\n", mWrState, Stringify(aBounds).c_str(),
|
|
|
|
Stringify(clip).c_str());
|
|
|
|
wr_dp_push_clear_rect(mWrState, aBounds, clip);
|
2017-10-31 18:31:00 +03:00
|
|
|
}
|
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushLinearGradient(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
|
|
|
bool aIsBackfaceVisible, const wr::LayoutPoint& aStartPoint,
|
2017-07-19 08:47:07 +03:00
|
|
|
const wr::LayoutPoint& aEndPoint, const nsTArray<wr::GradientStop>& aStops,
|
2017-07-19 01:32:46 +03:00
|
|
|
wr::ExtendMode aExtendMode, const wr::LayoutSize aTileSize,
|
|
|
|
const wr::LayoutSize aTileSpacing) {
|
2017-02-17 03:51:32 +03:00
|
|
|
wr_dp_push_linear_gradient(mWrState, aBounds, MergeClipLeaf(aClip),
|
|
|
|
aIsBackfaceVisible, aStartPoint, aEndPoint,
|
|
|
|
aStops.Elements(), aStops.Length(), aExtendMode,
|
2017-04-12 22:20:52 +03:00
|
|
|
aTileSize, aTileSpacing);
|
2017-02-17 03:51:32 +03:00
|
|
|
}
|
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushRadialGradient(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
|
|
|
bool aIsBackfaceVisible, const wr::LayoutPoint& aCenter,
|
2017-07-19 08:47:07 +03:00
|
|
|
const wr::LayoutSize& aRadius, const nsTArray<wr::GradientStop>& aStops,
|
2017-07-19 01:32:46 +03:00
|
|
|
wr::ExtendMode aExtendMode, const wr::LayoutSize aTileSize,
|
|
|
|
const wr::LayoutSize aTileSpacing) {
|
2017-02-17 03:51:32 +03:00
|
|
|
wr_dp_push_radial_gradient(mWrState, aBounds, MergeClipLeaf(aClip),
|
2018-09-14 17:42:20 +03:00
|
|
|
aIsBackfaceVisible, aCenter, aRadius,
|
2017-02-17 03:51:32 +03:00
|
|
|
aStops.Elements(), aStops.Length(), aExtendMode,
|
2017-04-12 22:20:52 +03:00
|
|
|
aTileSize, aTileSpacing);
|
2017-02-17 03:51:32 +03:00
|
|
|
}
|
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushImage(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
2017-02-14 21:34:15 +03:00
|
|
|
bool aIsBackfaceVisible, wr::ImageRendering aFilter, wr::ImageKey aImage,
|
2018-08-21 19:36:48 +03:00
|
|
|
bool aPremultipliedAlpha, const wr::ColorF& aColor) {
|
2017-07-19 01:32:46 +03:00
|
|
|
wr::LayoutSize size;
|
|
|
|
size.width = aBounds.size.width;
|
|
|
|
size.height = aBounds.size.height;
|
2018-09-14 17:42:20 +03:00
|
|
|
PushImage(aBounds, aClip, aIsBackfaceVisible, size, size, aFilter, aImage,
|
|
|
|
aPremultipliedAlpha, aColor);
|
2017-04-07 09:53:16 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushImage(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
|
|
|
bool aIsBackfaceVisible, const wr::LayoutSize& aStretchSize,
|
|
|
|
const wr::LayoutSize& aTileSpacing, wr::ImageRendering aFilter,
|
2018-08-21 19:36:48 +03:00
|
|
|
wr::ImageKey aImage, bool aPremultipliedAlpha, const wr::ColorF& aColor) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr::LayoutRect clip = MergeClipLeaf(aClip);
|
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(), Stringify(clip).c_str(),
|
2018-09-14 17:42:20 +03:00
|
|
|
Stringify(aStretchSize).c_str(), Stringify(aTileSpacing).c_str());
|
|
|
|
wr_dp_push_image(mWrState, aBounds, clip, aIsBackfaceVisible, aStretchSize,
|
|
|
|
aTileSpacing, aFilter, aImage, aPremultipliedAlpha, aColor);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushYCbCrPlanarImage(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
2017-04-29 00:00:57 +03:00
|
|
|
bool aIsBackfaceVisible, wr::ImageKey aImageChannel0,
|
|
|
|
wr::ImageKey aImageChannel1, wr::ImageKey aImageChannel2,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrColorDepth aColorDepth, 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, MergeClipLeaf(aClip),
|
2017-09-21 09:41:38 +03:00
|
|
|
aIsBackfaceVisible, aImageChannel0,
|
2017-04-29 00:00:57 +03:00
|
|
|
aImageChannel1, aImageChannel2, aColorDepth,
|
2017-06-01 15:57:10 +03:00
|
|
|
aColorSpace, aRendering);
|
2017-04-29 00:00:57 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushNV12Image(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
2017-04-29 00:00:57 +03:00
|
|
|
bool aIsBackfaceVisible, wr::ImageKey aImageChannel0,
|
2018-09-26 17:58:25 +03:00
|
|
|
wr::ImageKey aImageChannel1, wr::WrColorDepth aColorDepth,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrYuvColorSpace aColorSpace, wr::ImageRendering aRendering) {
|
2017-04-29 00:00:57 +03:00
|
|
|
wr_dp_push_yuv_NV12_image(mWrState, aBounds, MergeClipLeaf(aClip),
|
2017-09-21 09:41:38 +03:00
|
|
|
aIsBackfaceVisible, aImageChannel0, aImageChannel1,
|
2018-09-26 17:58:25 +03:00
|
|
|
aColorDepth, aColorSpace, aRendering);
|
2017-04-29 00:00:57 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushYCbCrInterleavedImage(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
2017-05-18 17:59:07 +03:00
|
|
|
bool aIsBackfaceVisible, wr::ImageKey aImageChannel0,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrColorDepth aColorDepth, 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, MergeClipLeaf(aClip),
|
2017-09-21 09:41:38 +03:00
|
|
|
aIsBackfaceVisible, aImageChannel0,
|
2018-09-26 17:58:25 +03:00
|
|
|
aColorDepth, aColorSpace, aRendering);
|
2017-05-18 17:59:07 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushIFrame(const wr::LayoutRect& aBounds,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2018-05-18 17:31:18 +03:00
|
|
|
PipelineId aPipeline,
|
|
|
|
bool aIgnoreMissingPipeline) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr_dp_push_iframe(mWrState, aBounds, MergeClipLeaf(aBounds),
|
|
|
|
aIsBackfaceVisible, aPipeline, aIgnoreMissingPipeline);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushBorder(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2018-09-18 16:01:36 +03:00
|
|
|
const wr::LayoutSideOffsets& aWidths,
|
2017-07-19 08:56:20 +03:00
|
|
|
const Range<const wr::BorderSide>& aSides,
|
2018-08-30 01:35:03 +03:00
|
|
|
const wr::BorderRadius& aRadius,
|
|
|
|
wr::AntialiasBorder aAntialias) {
|
2017-07-01 02:22:25 +03:00
|
|
|
MOZ_ASSERT(aSides.length() == 4);
|
|
|
|
if (aSides.length() != 4) {
|
|
|
|
return;
|
|
|
|
}
|
2018-09-14 17:42:20 +03:00
|
|
|
wr_dp_push_border(mWrState, aBounds, MergeClipLeaf(aClip), aIsBackfaceVisible,
|
2018-08-30 01:35:03 +03:00
|
|
|
aAntialias, aWidths, aSides[0], aSides[1], aSides[2],
|
|
|
|
aSides[3], aRadius);
|
2017-03-13 06:46:03 +03:00
|
|
|
}
|
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushBorderImage(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
2018-09-18 16:01:36 +03:00
|
|
|
bool aIsBackfaceVisible, const wr::LayoutSideOffsets& aWidths,
|
2018-11-16 20:13:26 +03:00
|
|
|
wr::ImageKey aImage, const int32_t aWidth, const int32_t aHeight,
|
|
|
|
const wr::SideOffsets2D<int32_t>& aSlice,
|
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) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr_dp_push_border_image(mWrState, aBounds, MergeClipLeaf(aClip),
|
|
|
|
aIsBackfaceVisible, aWidths, aImage, aWidth, aHeight,
|
|
|
|
aSlice, aOutset, aRepeatHorizontal, aRepeatVertical);
|
2017-01-13 13:25:07 +03:00
|
|
|
}
|
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushBorderGradient(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
2018-09-18 16:01:36 +03:00
|
|
|
bool aIsBackfaceVisible, const wr::LayoutSideOffsets& aWidths,
|
2018-11-16 20:13:26 +03:00
|
|
|
const int32_t aWidth, const int32_t aHeight,
|
|
|
|
const wr::SideOffsets2D<int32_t>& aSlice,
|
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) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr_dp_push_border_gradient(mWrState, aBounds, MergeClipLeaf(aClip),
|
|
|
|
aIsBackfaceVisible, aWidths, aWidth, aHeight,
|
|
|
|
aSlice, aStartPoint, aEndPoint, aStops.Elements(),
|
2017-04-10 12:27:30 +03:00
|
|
|
aStops.Length(), aExtendMode, aOutset);
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushBorderRadialGradient(
|
|
|
|
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
2018-09-18 16:01:36 +03:00
|
|
|
bool aIsBackfaceVisible, const wr::LayoutSideOffsets& 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) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr_dp_push_border_radial_gradient(mWrState, aBounds, MergeClipLeaf(aClip),
|
|
|
|
aIsBackfaceVisible, aWidths, aCenter,
|
|
|
|
aRadius, aStops.Elements(), aStops.Length(),
|
2017-04-10 12:27:30 +03:00
|
|
|
aExtendMode, aOutset);
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void 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) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr_dp_push_text(mWrState, aBounds, MergeClipLeaf(aClip), aIsBackfaceVisible,
|
2017-01-13 13:25:07 +03:00
|
|
|
aColor, aFontKey, &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) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr::LayoutRect clip = MergeClipLeaf(aClip);
|
|
|
|
wr_dp_push_line(mWrState, &clip, 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
|
|
|
}
|
|
|
|
|
2017-10-04 21:54:37 +03:00
|
|
|
void DisplayListBuilder::PushShadow(const wr::LayoutRect& aRect,
|
|
|
|
const wr::LayoutRect& aClip,
|
|
|
|
bool aIsBackfaceVisible,
|
|
|
|
const wr::Shadow& aShadow) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr_dp_push_shadow(mWrState, aRect, MergeClipLeaf(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
|
|
|
}
|
|
|
|
|
2017-10-13 19:58:32 +03:00
|
|
|
void DisplayListBuilder::PopAllShadows() { 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-07-19 01:32:46 +03:00
|
|
|
void DisplayListBuilder::PushBoxShadow(
|
|
|
|
const wr::LayoutRect& aRect, const wr::LayoutRect& aClip,
|
|
|
|
bool aIsBackfaceVisible, 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) {
|
2018-09-14 17:42:20 +03:00
|
|
|
wr_dp_push_box_shadow(mWrState, aRect, MergeClipLeaf(aClip),
|
|
|
|
aIsBackfaceVisible, aBoxBounds, aOffset, aColor,
|
2017-02-16 21:23:22 +03:00
|
|
|
aBlurRadius, aSpreadRadius, aBorderRadius, aClipMode);
|
|
|
|
}
|
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
Maybe<layers::ScrollableLayerGuid::ViewID>
|
Bug 1465935 - Fix hit-testing for fixed-pos items inside iframes. r=mstange
Without this patch, the scrollId for display items inside a fixed-pos
item end as the ASR of the item. In the case of fixed-pos items that are
inside iframes, the ASR is the outer document's root scrollframe. This
means that e.g. wheel-scrolling while over a fixed-pos item inside an
iframe ends up scrolling the outer document's root scrollframe instead
of the iframe's root scrollframe.
In the non-WR codepath, there some APZ machinery that walks up in the
HitTestingTreeNode tree from the hit result, looking to see if that node
has a fixed-pos ancestor, and if so, uses the fixed-pos item's target
APZ as the real hit result. This machinery doesn't exist in WR, because
we don't use the HitTestingTreeNode tree for hit-testing in APZ.
Instead, we need to make sure that the item tag for those display items
already has the appropriate scrollid set.
This patch accomplishes this by introducing a new RAII class that is
pushed into the wr::DisplayListBuilder while we are building display
items inside a nsDisplayFixedPosition, and allows the desired scroll id to
be set on the hit-testing display items.
This behaviour is exercised by test_group_wheelevents, which can now be
enabled with this fix.
MozReview-Commit-ID: L2erPVzJeql
--HG--
extra : rebase_source : 1db630513cb1dc16d4e38649812e81f62c8da99c
2018-06-07 20:06:33 +03:00
|
|
|
DisplayListBuilder::GetContainingFixedPosScrollTarget(
|
|
|
|
const ActiveScrolledRoot* aAsr) {
|
|
|
|
return mActiveFixedPosTracker
|
|
|
|
? mActiveFixedPosTracker->GetScrollTargetForASR(aAsr)
|
|
|
|
: Nothing();
|
|
|
|
}
|
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
void DisplayListBuilder::SetHitTestInfo(
|
|
|
|
const layers::ScrollableLayerGuid::ViewID& aScrollId,
|
2017-11-15 19:39:44 +03:00
|
|
|
gfx::CompositorHitTestInfo aHitInfo) {
|
2018-09-25 21:47:55 +03:00
|
|
|
static_assert(DoesCompositorHitTestInfoFitIntoBits<16>(),
|
|
|
|
"CompositorHitTestFlags MAX value has to be less than number "
|
|
|
|
"of bits in uint16_t");
|
|
|
|
|
|
|
|
wr_set_item_tag(mWrState, aScrollId,
|
|
|
|
static_cast<uint16_t>(aHitInfo.serialize()));
|
2017-11-15 19:39:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayListBuilder::ClearHitTestInfo() { wr_clear_item_tag(mWrState); }
|
|
|
|
|
Bug 1465935 - Fix hit-testing for fixed-pos items inside iframes. r=mstange
Without this patch, the scrollId for display items inside a fixed-pos
item end as the ASR of the item. In the case of fixed-pos items that are
inside iframes, the ASR is the outer document's root scrollframe. This
means that e.g. wheel-scrolling while over a fixed-pos item inside an
iframe ends up scrolling the outer document's root scrollframe instead
of the iframe's root scrollframe.
In the non-WR codepath, there some APZ machinery that walks up in the
HitTestingTreeNode tree from the hit result, looking to see if that node
has a fixed-pos ancestor, and if so, uses the fixed-pos item's target
APZ as the real hit result. This machinery doesn't exist in WR, because
we don't use the HitTestingTreeNode tree for hit-testing in APZ.
Instead, we need to make sure that the item tag for those display items
already has the appropriate scrollid set.
This patch accomplishes this by introducing a new RAII class that is
pushed into the wr::DisplayListBuilder while we are building display
items inside a nsDisplayFixedPosition, and allows the desired scroll id to
be set on the hit-testing display items.
This behaviour is exercised by test_group_wheelevents, which can now be
enabled with this fix.
MozReview-Commit-ID: L2erPVzJeql
--HG--
extra : rebase_source : 1db630513cb1dc16d4e38649812e81f62c8da99c
2018-06-07 20:06:33 +03:00
|
|
|
DisplayListBuilder::FixedPosScrollTargetTracker::FixedPosScrollTargetTracker(
|
|
|
|
DisplayListBuilder& aBuilder, const ActiveScrolledRoot* aAsr,
|
2018-11-01 23:15:46 +03:00
|
|
|
layers::ScrollableLayerGuid::ViewID aScrollId)
|
Bug 1465935 - Fix hit-testing for fixed-pos items inside iframes. r=mstange
Without this patch, the scrollId for display items inside a fixed-pos
item end as the ASR of the item. In the case of fixed-pos items that are
inside iframes, the ASR is the outer document's root scrollframe. This
means that e.g. wheel-scrolling while over a fixed-pos item inside an
iframe ends up scrolling the outer document's root scrollframe instead
of the iframe's root scrollframe.
In the non-WR codepath, there some APZ machinery that walks up in the
HitTestingTreeNode tree from the hit result, looking to see if that node
has a fixed-pos ancestor, and if so, uses the fixed-pos item's target
APZ as the real hit result. This machinery doesn't exist in WR, because
we don't use the HitTestingTreeNode tree for hit-testing in APZ.
Instead, we need to make sure that the item tag for those display items
already has the appropriate scrollid set.
This patch accomplishes this by introducing a new RAII class that is
pushed into the wr::DisplayListBuilder while we are building display
items inside a nsDisplayFixedPosition, and allows the desired scroll id to
be set on the hit-testing display items.
This behaviour is exercised by test_group_wheelevents, which can now be
enabled with this fix.
MozReview-Commit-ID: L2erPVzJeql
--HG--
extra : rebase_source : 1db630513cb1dc16d4e38649812e81f62c8da99c
2018-06-07 20:06:33 +03:00
|
|
|
: mParentTracker(aBuilder.mActiveFixedPosTracker),
|
|
|
|
mBuilder(aBuilder),
|
|
|
|
mAsr(aAsr),
|
|
|
|
mScrollId(aScrollId) {
|
|
|
|
aBuilder.mActiveFixedPosTracker = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayListBuilder::FixedPosScrollTargetTracker::
|
|
|
|
~FixedPosScrollTargetTracker() {
|
|
|
|
mBuilder.mActiveFixedPosTracker = mParentTracker;
|
|
|
|
}
|
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
Maybe<layers::ScrollableLayerGuid::ViewID>
|
Bug 1465935 - Fix hit-testing for fixed-pos items inside iframes. r=mstange
Without this patch, the scrollId for display items inside a fixed-pos
item end as the ASR of the item. In the case of fixed-pos items that are
inside iframes, the ASR is the outer document's root scrollframe. This
means that e.g. wheel-scrolling while over a fixed-pos item inside an
iframe ends up scrolling the outer document's root scrollframe instead
of the iframe's root scrollframe.
In the non-WR codepath, there some APZ machinery that walks up in the
HitTestingTreeNode tree from the hit result, looking to see if that node
has a fixed-pos ancestor, and if so, uses the fixed-pos item's target
APZ as the real hit result. This machinery doesn't exist in WR, because
we don't use the HitTestingTreeNode tree for hit-testing in APZ.
Instead, we need to make sure that the item tag for those display items
already has the appropriate scrollid set.
This patch accomplishes this by introducing a new RAII class that is
pushed into the wr::DisplayListBuilder while we are building display
items inside a nsDisplayFixedPosition, and allows the desired scroll id to
be set on the hit-testing display items.
This behaviour is exercised by test_group_wheelevents, which can now be
enabled with this fix.
MozReview-Commit-ID: L2erPVzJeql
--HG--
extra : rebase_source : 1db630513cb1dc16d4e38649812e81f62c8da99c
2018-06-07 20:06:33 +03:00
|
|
|
DisplayListBuilder::FixedPosScrollTargetTracker::GetScrollTargetForASR(
|
|
|
|
const ActiveScrolledRoot* aAsr) {
|
|
|
|
return aAsr == mAsr ? Some(mScrollId) : Nothing();
|
|
|
|
}
|
|
|
|
|
2018-11-26 01:57:04 +03:00
|
|
|
already_AddRefed<gfxContext> DisplayListBuilder::GetTextContext(
|
|
|
|
wr::IpcResourceUpdateQueue& aResources,
|
|
|
|
const layers::StackingContextHelper& aSc,
|
|
|
|
layers::WebRenderLayerManager* aManager, nsDisplayItem* aItem,
|
|
|
|
nsRect& aBounds, const gfx::Point& aDeviceOffset) {
|
|
|
|
if (!mCachedTextDT) {
|
|
|
|
mCachedTextDT = new layout::TextDrawTarget(*this, aResources, aSc, aManager,
|
|
|
|
aItem, aBounds);
|
|
|
|
mCachedContext = gfxContext::CreateOrNull(mCachedTextDT, aDeviceOffset);
|
|
|
|
} else {
|
|
|
|
mCachedTextDT->Reinitialize(aResources, aSc, aManager, aItem, aBounds);
|
|
|
|
mCachedContext->SetDeviceOffset(aDeviceOffset);
|
|
|
|
mCachedContext->SetMatrix(Matrix());
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<gfxContext> tmp = mCachedContext;
|
|
|
|
return tmp.forget();
|
|
|
|
}
|
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|
2018-09-24 18:53:36 +03:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
void wr_transaction_notification_notified(uintptr_t aHandler,
|
|
|
|
mozilla::wr::Checkpoint aWhen) {
|
|
|
|
auto handler = reinterpret_cast<mozilla::wr::NotificationHandler*>(aHandler);
|
|
|
|
handler->Notify(aWhen);
|
|
|
|
// TODO: it would be better to get a callback when the object is destroyed on
|
|
|
|
// the rust side and delete then.
|
|
|
|
delete handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // extern C
|