2016-11-16 16:54:51 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2017-10-28 02:10:06 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2016-11-16 16:54:51 +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 "mozilla/layers/WebRenderBridgeParent.h"
|
|
|
|
|
2016-11-24 09:48:01 +03:00
|
|
|
#include "CompositableHost.h"
|
2017-07-29 03:17:19 +03:00
|
|
|
#include "gfxEnv.h"
|
2017-04-27 19:04:25 +03:00
|
|
|
#include "gfxPrefs.h"
|
2017-07-28 15:08:05 +03:00
|
|
|
#include "gfxEnv.h"
|
2017-06-09 06:56:13 +03:00
|
|
|
#include "GeckoProfiler.h"
|
2016-11-16 16:54:51 +03:00
|
|
|
#include "GLContext.h"
|
|
|
|
#include "GLContextProvider.h"
|
2018-12-19 12:03:27 +03:00
|
|
|
#include "nsExceptionHandler.h"
|
2017-01-13 13:25:07 +03:00
|
|
|
#include "mozilla/Range.h"
|
2019-03-05 22:31:49 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2017-03-28 12:11:03 +03:00
|
|
|
#include "mozilla/layers/AnimationHelper.h"
|
2018-03-06 18:25:37 +03:00
|
|
|
#include "mozilla/layers/APZSampler.h"
|
2018-03-29 01:36:42 +03:00
|
|
|
#include "mozilla/layers/APZUpdater.h"
|
2016-11-17 12:02:56 +03:00
|
|
|
#include "mozilla/layers/Compositor.h"
|
2016-11-30 05:59:14 +03:00
|
|
|
#include "mozilla/layers/CompositorBridgeParent.h"
|
2016-12-02 01:10:10 +03:00
|
|
|
#include "mozilla/layers/CompositorThread.h"
|
2016-11-22 05:56:38 +03:00
|
|
|
#include "mozilla/layers/CompositorVsyncScheduler.h"
|
2017-01-05 18:03:17 +03:00
|
|
|
#include "mozilla/layers/ImageBridgeParent.h"
|
2016-11-28 05:39:42 +03:00
|
|
|
#include "mozilla/layers/ImageDataSerializer.h"
|
2017-09-14 19:48:55 +03:00
|
|
|
#include "mozilla/layers/IpcResourceUpdateQueue.h"
|
2017-10-30 20:10:29 +03:00
|
|
|
#include "mozilla/layers/SharedSurfacesParent.h"
|
2016-11-28 05:39:42 +03:00
|
|
|
#include "mozilla/layers/TextureHost.h"
|
2017-07-25 11:54:36 +03:00
|
|
|
#include "mozilla/layers/AsyncImagePipelineManager.h"
|
2017-04-27 19:34:54 +03:00
|
|
|
#include "mozilla/layers/WebRenderImageHost.h"
|
2017-03-07 13:37:28 +03:00
|
|
|
#include "mozilla/layers/WebRenderTextureHost.h"
|
2018-06-26 21:43:14 +03:00
|
|
|
#include "mozilla/Telemetry.h"
|
2017-04-27 19:34:54 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2017-06-30 04:06:11 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2017-01-17 03:21:52 +03:00
|
|
|
#include "mozilla/webrender/RenderThread.h"
|
2016-11-28 05:39:42 +03:00
|
|
|
#include "mozilla/widget/CompositorWidget.h"
|
2016-11-16 16:54:51 +03:00
|
|
|
|
2018-11-09 02:06:30 +03:00
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
|
|
|
# include "ProfilerMarkerPayload.h"
|
|
|
|
#endif
|
|
|
|
|
2017-03-02 04:36:27 +03:00
|
|
|
bool is_in_main_thread() { return NS_IsMainThread(); }
|
|
|
|
|
2016-12-02 01:10:10 +03:00
|
|
|
bool is_in_compositor_thread() {
|
|
|
|
return mozilla::layers::CompositorThreadHolder::IsInCompositorThread();
|
|
|
|
}
|
|
|
|
|
2017-01-06 21:10:15 +03:00
|
|
|
bool is_in_render_thread() {
|
2017-01-17 03:22:09 +03:00
|
|
|
return mozilla::wr::RenderThread::IsInRenderThread();
|
2017-01-06 21:10:15 +03:00
|
|
|
}
|
|
|
|
|
2018-11-15 02:21:23 +03:00
|
|
|
void gecko_profiler_start_marker(const char* name) {
|
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
2019-02-16 20:37:43 +03:00
|
|
|
profiler_tracing("WebRender", name, JS::ProfilingCategoryPair::GRAPHICS,
|
2019-01-18 18:40:15 +03:00
|
|
|
TRACING_INTERVAL_START);
|
2018-11-15 02:21:23 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void gecko_profiler_end_marker(const char* name) {
|
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
2019-02-16 20:37:43 +03:00
|
|
|
profiler_tracing("WebRender", name, JS::ProfilingCategoryPair::GRAPHICS,
|
2019-01-18 18:40:15 +03:00
|
|
|
TRACING_INTERVAL_END);
|
2018-11-15 02:21:23 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-03-13 12:19:06 +03:00
|
|
|
void gecko_profiler_add_text_marker(const char* name, const char* text_bytes,
|
|
|
|
size_t text_len, uint64_t microseconds) {
|
2019-03-05 22:31:49 +03:00
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
|
|
|
if (profiler_thread_is_being_profiled()) {
|
|
|
|
auto now = mozilla::TimeStamp::Now();
|
|
|
|
auto start = now - mozilla::TimeDuration::FromMicroseconds(microseconds);
|
2019-03-20 02:51:22 +03:00
|
|
|
profiler_add_text_marker(name, nsDependentCSubstring(text_bytes, text_len),
|
2019-03-13 12:19:06 +03:00
|
|
|
JS::ProfilingCategoryPair::GRAPHICS, start, now);
|
2019-03-05 22:31:49 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gecko_profiler_thread_is_being_profiled() {
|
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
|
|
|
return profiler_thread_is_being_profiled();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-03-20 19:10:40 +03:00
|
|
|
bool is_glcontext_egl(void* glcontext_ptr) {
|
|
|
|
MOZ_ASSERT(glcontext_ptr);
|
|
|
|
|
|
|
|
mozilla::gl::GLContext* glcontext =
|
|
|
|
reinterpret_cast<mozilla::gl::GLContext*>(glcontext_ptr);
|
|
|
|
if (!glcontext) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return glcontext->GetContextType() == mozilla::gl::GLContextType::EGL;
|
|
|
|
}
|
|
|
|
|
2017-12-06 23:06:40 +03:00
|
|
|
bool is_glcontext_angle(void* glcontext_ptr) {
|
|
|
|
MOZ_ASSERT(glcontext_ptr);
|
|
|
|
|
|
|
|
mozilla::gl::GLContext* glcontext =
|
|
|
|
reinterpret_cast<mozilla::gl::GLContext*>(glcontext_ptr);
|
|
|
|
if (!glcontext) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return glcontext->IsANGLE();
|
|
|
|
}
|
|
|
|
|
2017-07-17 08:38:22 +03:00
|
|
|
bool gfx_use_wrench() { return gfxEnv::EnableWebRenderRecording(); }
|
|
|
|
|
2017-10-06 21:38:56 +03:00
|
|
|
const char* gfx_wr_resource_path_override() {
|
2017-10-08 05:11:13 +03:00
|
|
|
const char* resourcePath = PR_GetEnv("WR_RESOURCE_PATH");
|
2017-10-06 21:38:56 +03:00
|
|
|
if (!resourcePath || resourcePath[0] == '\0') {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return resourcePath;
|
|
|
|
}
|
|
|
|
|
2017-03-27 21:32:39 +03:00
|
|
|
void gfx_critical_note(const char* msg) { gfxCriticalNote << msg; }
|
|
|
|
|
2017-10-30 06:31:38 +03:00
|
|
|
void gfx_critical_error(const char* msg) { gfxCriticalError() << msg; }
|
|
|
|
|
|
|
|
void gecko_printf_stderr_output(const char* msg) { printf_stderr("%s\n", msg); }
|
|
|
|
|
2016-12-21 07:22:04 +03:00
|
|
|
void* get_proc_address_from_glcontext(void* glcontext_ptr,
|
|
|
|
const char* procname) {
|
|
|
|
mozilla::gl::GLContext* glcontext =
|
|
|
|
reinterpret_cast<mozilla::gl::GLContext*>(glcontext_ptr);
|
2019-02-23 00:17:28 +03:00
|
|
|
MOZ_ASSERT(glcontext);
|
2016-12-21 07:22:04 +03:00
|
|
|
if (!glcontext) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-02-23 00:17:28 +03:00
|
|
|
const auto& loader = glcontext->GetSymbolLoader();
|
|
|
|
MOZ_ASSERT(loader);
|
|
|
|
|
|
|
|
const auto ret = loader->GetProcAddress(procname);
|
|
|
|
return reinterpret_cast<void*>(ret);
|
2016-12-21 07:22:04 +03:00
|
|
|
}
|
|
|
|
|
2017-11-11 13:57:31 +03:00
|
|
|
void gecko_profiler_register_thread(const char* name) {
|
2017-11-12 17:21:22 +03:00
|
|
|
PROFILER_REGISTER_THREAD(name);
|
2017-11-11 13:57:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gecko_profiler_unregister_thread() { PROFILER_UNREGISTER_THREAD(); }
|
|
|
|
|
2018-07-04 14:52:22 +03:00
|
|
|
void record_telemetry_time(mozilla::wr::TelemetryProbe aProbe,
|
|
|
|
uint64_t aTimeNs) {
|
|
|
|
uint32_t time_ms = (uint32_t)(aTimeNs / 1000000);
|
|
|
|
switch (aProbe) {
|
|
|
|
case mozilla::wr::TelemetryProbe::SceneBuildTime:
|
|
|
|
mozilla::Telemetry::Accumulate(mozilla::Telemetry::WR_SCENEBUILD_TIME,
|
|
|
|
time_ms);
|
|
|
|
break;
|
|
|
|
case mozilla::wr::TelemetryProbe::SceneSwapTime:
|
|
|
|
mozilla::Telemetry::Accumulate(mozilla::Telemetry::WR_SCENESWAP_TIME,
|
|
|
|
time_ms);
|
|
|
|
break;
|
|
|
|
case mozilla::wr::TelemetryProbe::RenderTime:
|
|
|
|
mozilla::Telemetry::Accumulate(mozilla::Telemetry::WR_RENDER_TIME,
|
|
|
|
time_ms);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-16 16:54:51 +03:00
|
|
|
namespace mozilla {
|
2017-12-01 02:14:41 +03:00
|
|
|
|
2016-11-16 16:54:51 +03:00
|
|
|
namespace layers {
|
|
|
|
|
2016-11-28 05:39:42 +03:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2018-09-21 19:47:18 +03:00
|
|
|
class ScheduleObserveLayersUpdate : public wr::NotificationHandler {
|
|
|
|
public:
|
|
|
|
ScheduleObserveLayersUpdate(RefPtr<CompositorBridgeParentBase> aBridge,
|
|
|
|
LayersId aLayersId, LayersObserverEpoch aEpoch,
|
|
|
|
bool aIsActive)
|
|
|
|
: mBridge(aBridge),
|
|
|
|
mLayersId(aLayersId),
|
|
|
|
mObserverEpoch(aEpoch),
|
|
|
|
mIsActive(aIsActive) {}
|
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void Notify(wr::Checkpoint) override {
|
2018-09-21 19:47:18 +03:00
|
|
|
CompositorThreadHolder::Loop()->PostTask(
|
|
|
|
NewRunnableMethod<LayersId, LayersObserverEpoch, int>(
|
|
|
|
"ObserveLayersUpdate", mBridge,
|
|
|
|
&CompositorBridgeParentBase::ObserveLayersUpdate, mLayersId,
|
|
|
|
mObserverEpoch, mIsActive));
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-09-21 19:47:18 +03:00
|
|
|
protected:
|
|
|
|
RefPtr<CompositorBridgeParentBase> mBridge;
|
|
|
|
LayersId mLayersId;
|
|
|
|
LayersObserverEpoch mObserverEpoch;
|
|
|
|
bool mIsActive;
|
|
|
|
};
|
|
|
|
|
2018-11-16 08:26:10 +03:00
|
|
|
class SceneBuiltNotification : public wr::NotificationHandler {
|
|
|
|
public:
|
2019-04-11 15:36:51 +03:00
|
|
|
SceneBuiltNotification(WebRenderBridgeParent* aParent, wr::Epoch aEpoch,
|
|
|
|
TimeStamp aTxnStartTime)
|
2018-11-16 05:13:56 +03:00
|
|
|
: mParent(aParent), mEpoch(aEpoch), mTxnStartTime(aTxnStartTime) {}
|
2018-11-16 08:26:10 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void Notify(wr::Checkpoint) override {
|
2018-11-16 08:26:10 +03:00
|
|
|
auto startTime = this->mTxnStartTime;
|
2018-11-16 05:13:56 +03:00
|
|
|
RefPtr<WebRenderBridgeParent> parent = mParent;
|
|
|
|
wr::Epoch epoch = mEpoch;
|
2018-11-16 08:26:10 +03:00
|
|
|
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction(
|
2018-11-16 05:13:56 +03:00
|
|
|
"SceneBuiltNotificationRunnable", [parent, epoch, startTime]() {
|
2018-11-16 08:26:10 +03:00
|
|
|
auto endTime = TimeStamp::Now();
|
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
|
|
|
if (profiler_is_active()) {
|
|
|
|
class ContentFullPaintPayload : public ProfilerMarkerPayload {
|
|
|
|
public:
|
|
|
|
ContentFullPaintPayload(const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime)
|
|
|
|
: ProfilerMarkerPayload(aStartTime, aEndTime) {}
|
2019-04-11 15:36:51 +03:00
|
|
|
void StreamPayload(SpliceableJSONWriter& aWriter,
|
|
|
|
const TimeStamp& aProcessStartTime,
|
|
|
|
UniqueStacks& aUniqueStacks) override {
|
2018-11-16 08:26:10 +03:00
|
|
|
StreamCommonProps("CONTENT_FULL_PAINT_TIME", aWriter,
|
|
|
|
aProcessStartTime, aUniqueStacks);
|
|
|
|
}
|
|
|
|
};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-11-16 08:26:10 +03:00
|
|
|
profiler_add_marker_for_thread(
|
2019-01-18 18:40:15 +03:00
|
|
|
profiler_current_thread_id(),
|
2019-02-16 20:37:43 +03:00
|
|
|
JS::ProfilingCategoryPair::GRAPHICS, "CONTENT_FULL_PAINT_TIME",
|
2018-11-16 08:26:10 +03:00
|
|
|
MakeUnique<ContentFullPaintPayload>(startTime, endTime));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
Telemetry::Accumulate(
|
|
|
|
Telemetry::CONTENT_FULL_PAINT_TIME,
|
|
|
|
static_cast<uint32_t>((endTime - startTime).ToMilliseconds()));
|
2018-11-16 05:13:56 +03:00
|
|
|
parent->NotifySceneBuiltForEpoch(epoch, endTime);
|
2018-11-16 08:26:10 +03:00
|
|
|
}));
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-11-16 08:26:10 +03:00
|
|
|
protected:
|
2018-11-16 05:13:56 +03:00
|
|
|
RefPtr<WebRenderBridgeParent> mParent;
|
|
|
|
wr::Epoch mEpoch;
|
2018-11-16 08:26:10 +03:00
|
|
|
TimeStamp mTxnStartTime;
|
|
|
|
};
|
|
|
|
|
2018-10-02 20:28:04 +03:00
|
|
|
class WebRenderBridgeParent::ScheduleSharedSurfaceRelease final
|
|
|
|
: public wr::NotificationHandler {
|
|
|
|
public:
|
2018-09-28 22:11:15 +03:00
|
|
|
explicit ScheduleSharedSurfaceRelease(WebRenderBridgeParent* aWrBridge)
|
|
|
|
: mWrBridge(aWrBridge), mSurfaces(20) {}
|
2018-10-02 20:28:04 +03:00
|
|
|
|
2018-09-28 22:11:15 +03:00
|
|
|
void Add(const wr::ImageKey& aKey, const wr::ExternalImageId& aId) {
|
|
|
|
mSurfaces.AppendElement(wr::ExternalImageKeyPair{aKey, aId});
|
2018-10-02 20:28:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Notify(wr::Checkpoint) override {
|
2018-09-28 22:11:15 +03:00
|
|
|
CompositorThreadHolder::Loop()->PostTask(
|
|
|
|
NewRunnableMethod<nsTArray<wr::ExternalImageKeyPair>>(
|
|
|
|
"ObserveSharedSurfaceRelease", mWrBridge,
|
|
|
|
&WebRenderBridgeParent::ObserveSharedSurfaceRelease,
|
|
|
|
std::move(mSurfaces)));
|
2018-10-02 20:28:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-09-28 22:11:15 +03:00
|
|
|
RefPtr<WebRenderBridgeParent> mWrBridge;
|
|
|
|
nsTArray<wr::ExternalImageKeyPair> mSurfaces;
|
2018-10-02 20:28:04 +03:00
|
|
|
};
|
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
class MOZ_STACK_CLASS AutoWebRenderBridgeParentAsyncMessageSender final {
|
2016-12-07 13:02:04 +03:00
|
|
|
public:
|
|
|
|
explicit AutoWebRenderBridgeParentAsyncMessageSender(
|
|
|
|
WebRenderBridgeParent* aWebRenderBridgeParent,
|
|
|
|
InfallibleTArray<OpDestroy>* aDestroyActors = nullptr)
|
|
|
|
: mWebRenderBridgeParent(aWebRenderBridgeParent),
|
|
|
|
mActorsToDestroy(aDestroyActors) {
|
|
|
|
mWebRenderBridgeParent->SetAboutToSendAsyncMessages();
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoWebRenderBridgeParentAsyncMessageSender() {
|
|
|
|
mWebRenderBridgeParent->SendPendingAsyncMessages();
|
|
|
|
if (mActorsToDestroy) {
|
|
|
|
// Destroy the actors after sending the async messages because the latter
|
|
|
|
// may contain references to some actors.
|
|
|
|
for (const auto& op : *mActorsToDestroy) {
|
|
|
|
mWebRenderBridgeParent->DestroyActor(op);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-12-07 13:02:04 +03:00
|
|
|
private:
|
|
|
|
WebRenderBridgeParent* mWebRenderBridgeParent;
|
|
|
|
InfallibleTArray<OpDestroy>* mActorsToDestroy;
|
|
|
|
};
|
|
|
|
|
2017-01-11 15:51:27 +03:00
|
|
|
WebRenderBridgeParent::WebRenderBridgeParent(
|
|
|
|
CompositorBridgeParentBase* aCompositorBridge,
|
|
|
|
const wr::PipelineId& aPipelineId, widget::CompositorWidget* aWidget,
|
2019-03-22 21:28:42 +03:00
|
|
|
CompositorVsyncScheduler* aScheduler,
|
|
|
|
nsTArray<RefPtr<wr::WebRenderAPI>>&& aApis,
|
2017-07-25 11:54:36 +03:00
|
|
|
RefPtr<AsyncImagePipelineManager>&& aImageMgr,
|
2018-06-26 21:43:14 +03:00
|
|
|
RefPtr<CompositorAnimationStorage>&& aAnimStorage, TimeDuration aVsyncRate)
|
2017-01-11 15:51:27 +03:00
|
|
|
: mCompositorBridge(aCompositorBridge),
|
|
|
|
mPipelineId(aPipelineId),
|
|
|
|
mWidget(aWidget),
|
2017-07-25 11:54:36 +03:00
|
|
|
mAsyncImageManager(aImageMgr),
|
2017-02-27 03:27:04 +03:00
|
|
|
mCompositorScheduler(aScheduler),
|
2017-06-15 10:36:03 +03:00
|
|
|
mAnimStorage(aAnimStorage),
|
2018-06-26 21:43:14 +03:00
|
|
|
mVsyncRate(aVsyncRate),
|
2018-07-30 16:24:50 +03:00
|
|
|
mChildLayersObserverEpoch{0},
|
|
|
|
mParentLayersObserverEpoch{0},
|
2018-04-10 19:29:56 +03:00
|
|
|
mWrEpoch{0},
|
2019-03-22 21:28:42 +03:00
|
|
|
mIdNamespace(aApis[0]->GetNamespace()),
|
|
|
|
mRenderRootRectMutex("WebRenderBridgeParent::mRenderRootRectMutex"),
|
|
|
|
mRenderRoot(wr::RenderRoot::Default),
|
2017-04-05 17:12:11 +03:00
|
|
|
mPaused(false),
|
2017-01-11 15:51:27 +03:00
|
|
|
mDestroyed(false),
|
2018-03-06 22:20:56 +03:00
|
|
|
mReceivedDisplayList(false),
|
2018-10-19 16:48:04 +03:00
|
|
|
mIsFirstPaint(true),
|
2018-11-29 21:30:06 +03:00
|
|
|
mSkippedComposite(false) {
|
2017-07-25 11:54:36 +03:00
|
|
|
MOZ_ASSERT(mAsyncImageManager);
|
2017-06-15 10:36:03 +03:00
|
|
|
MOZ_ASSERT(mAnimStorage);
|
2018-11-17 06:27:54 +03:00
|
|
|
mAsyncImageManager->AddPipeline(mPipelineId, this);
|
2018-06-26 21:37:31 +03:00
|
|
|
if (IsRootWebRenderBridgeParent()) {
|
2017-02-27 03:27:04 +03:00
|
|
|
MOZ_ASSERT(!mCompositorScheduler);
|
2017-01-11 15:51:27 +03:00
|
|
|
mCompositorScheduler = new CompositorVsyncScheduler(this, mWidget);
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
|
|
|
|
if (!IsRootWebRenderBridgeParent() && gfxPrefs::WebRenderSplitRenderRoots()) {
|
|
|
|
mRenderRoot = wr::RenderRoot::Content;
|
|
|
|
}
|
2019-04-05 18:42:50 +03:00
|
|
|
|
|
|
|
for (auto& api : aApis) {
|
|
|
|
MOZ_ASSERT(api);
|
|
|
|
mApis[api->GetRenderRoot()] = api;
|
|
|
|
}
|
2017-01-11 15:51:27 +03:00
|
|
|
}
|
|
|
|
|
2017-08-29 16:41:53 +03:00
|
|
|
WebRenderBridgeParent::WebRenderBridgeParent(const wr::PipelineId& aPipelineId)
|
2017-06-30 04:06:11 +03:00
|
|
|
: mCompositorBridge(nullptr),
|
2017-08-29 16:41:53 +03:00
|
|
|
mPipelineId(aPipelineId),
|
2018-07-30 16:24:50 +03:00
|
|
|
mChildLayersObserverEpoch{0},
|
|
|
|
mParentLayersObserverEpoch{0},
|
2018-04-10 19:29:56 +03:00
|
|
|
mWrEpoch{0},
|
2017-07-31 21:21:18 +03:00
|
|
|
mIdNamespace{0},
|
2019-03-22 21:28:42 +03:00
|
|
|
mRenderRootRectMutex("WebRenderBridgeParent::mRenderRootRectMutex"),
|
|
|
|
mRenderRoot(wr::RenderRoot::Default),
|
2017-06-30 04:06:11 +03:00
|
|
|
mPaused(false),
|
|
|
|
mDestroyed(true),
|
2018-03-06 22:20:56 +03:00
|
|
|
mReceivedDisplayList(false),
|
2018-10-19 16:48:04 +03:00
|
|
|
mIsFirstPaint(false),
|
2018-11-29 21:30:06 +03:00
|
|
|
mSkippedComposite(false) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
WebRenderBridgeParent* WebRenderBridgeParent::CreateDestroyed(
|
2017-08-29 16:41:53 +03:00
|
|
|
const wr::PipelineId& aPipelineId) {
|
|
|
|
return new WebRenderBridgeParent(aPipelineId);
|
2017-06-30 04:06:11 +03:00
|
|
|
}
|
|
|
|
|
2018-10-05 10:35:29 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvEnsureConnected(
|
|
|
|
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
|
|
|
MaybeIdNamespace* aMaybeIdNamespace) {
|
|
|
|
if (mDestroyed) {
|
|
|
|
*aTextureFactoryIdentifier =
|
|
|
|
TextureFactoryIdentifier(LayersBackend::LAYERS_NONE);
|
|
|
|
*aMaybeIdNamespace = Nothing();
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(mIdNamespace.mHandle != 0);
|
|
|
|
*aTextureFactoryIdentifier = GetTextureFactoryIdentifier();
|
|
|
|
*aMaybeIdNamespace = Some(mIdNamespace);
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2016-11-25 04:36:37 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvShutdown() {
|
2017-06-29 21:46:36 +03:00
|
|
|
return HandleShutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvShutdownSync() {
|
|
|
|
return HandleShutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::HandleShutdown() {
|
2016-11-28 04:21:33 +03:00
|
|
|
Destroy();
|
2017-05-18 03:31:46 +03:00
|
|
|
IProtocol* mgr = Manager();
|
2016-11-25 04:36:37 +03:00
|
|
|
if (!Send__delete__(this)) {
|
2017-05-18 03:31:46 +03:00
|
|
|
return IPC_FAIL_NO_REASON(mgr);
|
2016-11-25 04:36:37 +03:00
|
|
|
}
|
2016-11-16 16:54:51 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2016-11-28 04:21:33 +03:00
|
|
|
void WebRenderBridgeParent::Destroy() {
|
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mDestroyed = true;
|
|
|
|
ClearResources();
|
|
|
|
}
|
|
|
|
|
2017-09-14 19:48:55 +03:00
|
|
|
bool WebRenderBridgeParent::UpdateResources(
|
|
|
|
const nsTArray<OpUpdateResource>& aResourceUpdates,
|
2018-01-12 17:11:28 +03:00
|
|
|
const nsTArray<RefCountedShmem>& aSmallShmems,
|
2017-09-20 14:39:19 +03:00
|
|
|
const nsTArray<ipc::Shmem>& aLargeShmems,
|
2018-01-29 16:33:39 +03:00
|
|
|
wr::TransactionBuilder& aUpdates) {
|
2017-09-20 14:39:19 +03:00
|
|
|
wr::ShmSegmentsReader reader(aSmallShmems, aLargeShmems);
|
2018-10-02 20:28:04 +03:00
|
|
|
UniquePtr<ScheduleSharedSurfaceRelease> scheduleRelease;
|
2017-09-14 19:48:55 +03:00
|
|
|
|
|
|
|
for (const auto& cmd : aResourceUpdates) {
|
|
|
|
switch (cmd.type()) {
|
|
|
|
case OpUpdateResource::TOpAddImage: {
|
|
|
|
const auto& op = cmd.get_OpAddImage();
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t> bytes;
|
2017-09-14 19:48:55 +03:00
|
|
|
if (!reader.Read(op.bytes(), bytes)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aUpdates.AddImage(op.key(), op.descriptor(), bytes);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OpUpdateResource::TOpUpdateImage: {
|
|
|
|
const auto& op = cmd.get_OpUpdateImage();
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t> bytes;
|
2017-09-14 19:48:55 +03:00
|
|
|
if (!reader.Read(op.bytes(), bytes)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aUpdates.UpdateImageBuffer(op.key(), op.descriptor(), bytes);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OpUpdateResource::TOpAddBlobImage: {
|
|
|
|
const auto& op = cmd.get_OpAddBlobImage();
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t> bytes;
|
2017-09-14 19:48:55 +03:00
|
|
|
if (!reader.Read(op.bytes(), bytes)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aUpdates.AddBlobImage(op.key(), op.descriptor(), bytes);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OpUpdateResource::TOpUpdateBlobImage: {
|
|
|
|
const auto& op = cmd.get_OpUpdateBlobImage();
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t> bytes;
|
2017-09-14 19:48:55 +03:00
|
|
|
if (!reader.Read(op.bytes(), bytes)) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-24 02:33:49 +03:00
|
|
|
aUpdates.UpdateBlobImage(op.key(), op.descriptor(), bytes,
|
|
|
|
wr::ToLayoutIntRect(op.dirtyRect()));
|
2017-09-14 19:48:55 +03:00
|
|
|
break;
|
|
|
|
}
|
2018-07-19 23:33:05 +03:00
|
|
|
case OpUpdateResource::TOpSetImageVisibleArea: {
|
|
|
|
const auto& op = cmd.get_OpSetImageVisibleArea();
|
2018-11-16 20:13:26 +03:00
|
|
|
wr::DeviceIntRect area;
|
2018-07-19 23:33:05 +03:00
|
|
|
area.origin.x = op.area().x;
|
|
|
|
area.origin.y = op.area().y;
|
|
|
|
area.size.width = op.area().width;
|
|
|
|
area.size.height = op.area().height;
|
|
|
|
aUpdates.SetImageVisibleArea(op.key(), area);
|
|
|
|
break;
|
|
|
|
}
|
2017-09-20 11:56:09 +03:00
|
|
|
case OpUpdateResource::TOpAddExternalImage: {
|
|
|
|
const auto& op = cmd.get_OpAddExternalImage();
|
|
|
|
if (!AddExternalImage(op.externalImageId(), op.key(), aUpdates)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2018-07-11 11:45:28 +03:00
|
|
|
case OpUpdateResource::TOpPushExternalImageForTexture: {
|
|
|
|
const auto& op = cmd.get_OpPushExternalImageForTexture();
|
2018-07-06 15:25:33 +03:00
|
|
|
CompositableTextureHostRef texture;
|
|
|
|
texture = TextureHost::AsTextureHost(op.textureParent());
|
2018-07-11 11:45:28 +03:00
|
|
|
if (!PushExternalImageForTexture(op.externalImageId(), op.key(),
|
|
|
|
texture, op.isUpdate(), aUpdates)) {
|
2018-07-06 15:25:33 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2018-07-12 18:43:09 +03:00
|
|
|
case OpUpdateResource::TOpUpdateExternalImage: {
|
|
|
|
const auto& op = cmd.get_OpUpdateExternalImage();
|
2018-10-02 20:28:04 +03:00
|
|
|
if (!UpdateExternalImage(op.externalImageId(), op.key(), op.dirtyRect(),
|
|
|
|
aUpdates, scheduleRelease)) {
|
2018-07-12 18:43:09 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-09-14 19:48:55 +03:00
|
|
|
case OpUpdateResource::TOpAddRawFont: {
|
|
|
|
const auto& op = cmd.get_OpAddRawFont();
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t> bytes;
|
2017-09-14 19:48:55 +03:00
|
|
|
if (!reader.Read(op.bytes(), bytes)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aUpdates.AddRawFont(op.key(), bytes, op.fontIndex());
|
|
|
|
break;
|
|
|
|
}
|
2017-11-07 04:19:46 +03:00
|
|
|
case OpUpdateResource::TOpAddFontDescriptor: {
|
|
|
|
const auto& op = cmd.get_OpAddFontDescriptor();
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t> bytes;
|
2017-11-07 04:19:46 +03:00
|
|
|
if (!reader.Read(op.bytes(), bytes)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aUpdates.AddFontDescriptor(op.key(), bytes, op.fontIndex());
|
|
|
|
break;
|
|
|
|
}
|
2017-09-14 19:48:55 +03:00
|
|
|
case OpUpdateResource::TOpAddFontInstance: {
|
|
|
|
const auto& op = cmd.get_OpAddFontInstance();
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t> variations;
|
2017-09-21 06:18:23 +03:00
|
|
|
if (!reader.Read(op.variations(), variations)) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-09-14 19:48:55 +03:00
|
|
|
aUpdates.AddFontInstance(op.instanceKey(), op.fontKey(), op.glyphSize(),
|
|
|
|
op.options().ptrOr(nullptr),
|
2017-09-21 06:18:23 +03:00
|
|
|
op.platformOptions().ptrOr(nullptr),
|
|
|
|
variations);
|
2017-09-14 19:48:55 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OpUpdateResource::TOpDeleteImage: {
|
|
|
|
const auto& op = cmd.get_OpDeleteImage();
|
2018-10-02 20:27:52 +03:00
|
|
|
DeleteImage(op.key(), aUpdates);
|
2017-09-14 19:48:55 +03:00
|
|
|
break;
|
|
|
|
}
|
2018-11-24 02:33:49 +03:00
|
|
|
case OpUpdateResource::TOpDeleteBlobImage: {
|
|
|
|
const auto& op = cmd.get_OpDeleteBlobImage();
|
|
|
|
aUpdates.DeleteBlobImage(op.key());
|
|
|
|
break;
|
|
|
|
}
|
2017-09-14 19:48:55 +03:00
|
|
|
case OpUpdateResource::TOpDeleteFont: {
|
|
|
|
const auto& op = cmd.get_OpDeleteFont();
|
|
|
|
aUpdates.DeleteFont(op.key());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OpUpdateResource::TOpDeleteFontInstance: {
|
|
|
|
const auto& op = cmd.get_OpDeleteFontInstance();
|
|
|
|
aUpdates.DeleteFontInstance(op.key());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OpUpdateResource::T__None:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-02 20:28:04 +03:00
|
|
|
if (scheduleRelease) {
|
2018-09-28 22:11:15 +03:00
|
|
|
aUpdates.Notify(wr::Checkpoint::FrameTexturesUpdated,
|
|
|
|
std::move(scheduleRelease));
|
2018-10-02 20:28:04 +03:00
|
|
|
}
|
2017-09-14 19:48:55 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-09-20 11:56:09 +03:00
|
|
|
bool WebRenderBridgeParent::AddExternalImage(
|
|
|
|
wr::ExternalImageId aExtId, wr::ImageKey aKey,
|
2018-01-29 16:33:39 +03:00
|
|
|
wr::TransactionBuilder& aResources) {
|
2017-09-26 16:30:51 +03:00
|
|
|
Range<wr::ImageKey> keys(&aKey, 1);
|
2017-09-20 11:56:09 +03:00
|
|
|
// Check if key is obsoleted.
|
|
|
|
if (keys[0].mNamespace != mIdNamespace) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-10-02 20:27:52 +03:00
|
|
|
auto key = wr::AsUint64(aKey);
|
|
|
|
auto it = mSharedSurfaceIds.find(key);
|
|
|
|
if (it != mSharedSurfaceIds.end()) {
|
|
|
|
gfxCriticalNote << "Readding known shared surface: " << key;
|
|
|
|
return false;
|
|
|
|
}
|
2018-04-23 14:57:15 +03:00
|
|
|
|
2018-10-02 20:27:52 +03:00
|
|
|
RefPtr<DataSourceSurface> dSurf = SharedSurfacesParent::Acquire(aExtId);
|
|
|
|
if (!dSurf) {
|
2018-07-06 15:25:33 +03:00
|
|
|
gfxCriticalNote
|
|
|
|
<< "DataSourceSurface of SharedSurfaces does not exist for extId:"
|
|
|
|
<< wr::AsUint64(aExtId);
|
|
|
|
return false;
|
|
|
|
}
|
2017-10-30 20:10:29 +03:00
|
|
|
|
2018-10-02 20:27:52 +03:00
|
|
|
mSharedSurfaceIds.insert(std::make_pair(key, aExtId));
|
|
|
|
|
|
|
|
if (!gfxEnv::EnableWebRenderRecording()) {
|
|
|
|
wr::ImageDescriptor descriptor(dSurf->GetSize(), dSurf->Stride(),
|
|
|
|
dSurf->GetFormat());
|
|
|
|
aResources.AddExternalImage(aKey, descriptor, aExtId,
|
|
|
|
wr::WrExternalImageBufferType::ExternalBuffer,
|
|
|
|
0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-06 15:25:33 +03:00
|
|
|
DataSourceSurface::MappedSurface map;
|
|
|
|
if (!dSurf->Map(gfx::DataSourceSurface::MapType::READ, &map)) {
|
|
|
|
gfxCriticalNote << "DataSourceSurface failed to map for Image for extId:"
|
|
|
|
<< wr::AsUint64(aExtId);
|
|
|
|
return false;
|
2017-09-20 11:56:09 +03:00
|
|
|
}
|
2017-10-30 20:10:29 +03:00
|
|
|
|
2018-07-06 15:25:33 +03:00
|
|
|
IntSize size = dSurf->GetSize();
|
|
|
|
wr::ImageDescriptor descriptor(size, map.mStride, dSurf->GetFormat());
|
|
|
|
wr::Vec<uint8_t> data;
|
|
|
|
data.PushBytes(Range<uint8_t>(map.mData, size.height * map.mStride));
|
|
|
|
aResources.AddImage(keys[0], descriptor, data);
|
|
|
|
dSurf->Unmap();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-11 11:45:28 +03:00
|
|
|
bool WebRenderBridgeParent::PushExternalImageForTexture(
|
|
|
|
wr::ExternalImageId aExtId, wr::ImageKey aKey, TextureHost* aTexture,
|
|
|
|
bool aIsUpdate, wr::TransactionBuilder& aResources) {
|
|
|
|
auto op = aIsUpdate ? TextureHost::UPDATE_IMAGE : TextureHost::ADD_IMAGE;
|
2018-07-06 15:25:33 +03:00
|
|
|
Range<wr::ImageKey> keys(&aKey, 1);
|
|
|
|
// Check if key is obsoleted.
|
|
|
|
if (keys[0].mNamespace != mIdNamespace) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aTexture) {
|
|
|
|
gfxCriticalNote << "TextureHost does not exist for extId:"
|
|
|
|
<< wr::AsUint64(aExtId);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gfxEnv::EnableWebRenderRecording()) {
|
|
|
|
WebRenderTextureHost* wrTexture = aTexture->AsWebRenderTextureHost();
|
|
|
|
if (wrTexture) {
|
2018-07-11 11:45:28 +03:00
|
|
|
wrTexture->PushResourceUpdates(aResources, op, keys,
|
2018-07-06 15:25:33 +03:00
|
|
|
wrTexture->GetExternalImageKey());
|
2018-07-11 11:45:28 +03:00
|
|
|
auto it = mTextureHosts.find(wr::AsUint64(aKey));
|
|
|
|
MOZ_ASSERT((it == mTextureHosts.end() && !aIsUpdate) ||
|
|
|
|
(it != mTextureHosts.end() && aIsUpdate));
|
|
|
|
if (it != mTextureHosts.end()) {
|
|
|
|
// Release Texture if it exists.
|
|
|
|
ReleaseTextureOfImage(aKey);
|
|
|
|
}
|
2018-07-10 05:06:08 +03:00
|
|
|
mTextureHosts.emplace(wr::AsUint64(aKey),
|
|
|
|
CompositableTextureHostRef(aTexture));
|
2018-07-06 15:25:33 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RefPtr<DataSourceSurface> dSurf = aTexture->GetAsSurface();
|
2017-09-20 11:56:09 +03:00
|
|
|
if (!dSurf) {
|
2018-01-11 15:44:00 +03:00
|
|
|
gfxCriticalNote
|
|
|
|
<< "TextureHost does not return DataSourceSurface for extId:"
|
|
|
|
<< wr::AsUint64(aExtId);
|
2017-09-20 11:56:09 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataSourceSurface::MappedSurface map;
|
|
|
|
if (!dSurf->Map(gfx::DataSourceSurface::MapType::READ, &map)) {
|
2018-01-11 15:44:00 +03:00
|
|
|
gfxCriticalNote << "DataSourceSurface failed to map for Image for extId:"
|
|
|
|
<< wr::AsUint64(aExtId);
|
2017-09-20 11:56:09 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
IntSize size = dSurf->GetSize();
|
|
|
|
wr::ImageDescriptor descriptor(size, map.mStride, dSurf->GetFormat());
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t> data;
|
2017-09-20 11:56:09 +03:00
|
|
|
data.PushBytes(Range<uint8_t>(map.mData, size.height * map.mStride));
|
2018-07-11 11:45:28 +03:00
|
|
|
|
|
|
|
if (op == TextureHost::UPDATE_IMAGE) {
|
|
|
|
aResources.UpdateImageBuffer(keys[0], descriptor, data);
|
|
|
|
} else {
|
|
|
|
aResources.AddImage(keys[0], descriptor, data);
|
|
|
|
}
|
|
|
|
|
2017-09-20 11:56:09 +03:00
|
|
|
dSurf->Unmap();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-12 18:43:09 +03:00
|
|
|
bool WebRenderBridgeParent::UpdateExternalImage(
|
|
|
|
wr::ExternalImageId aExtId, wr::ImageKey aKey,
|
2018-10-02 20:28:04 +03:00
|
|
|
const ImageIntRect& aDirtyRect, wr::TransactionBuilder& aResources,
|
|
|
|
UniquePtr<ScheduleSharedSurfaceRelease>& aScheduleRelease) {
|
2018-07-12 18:43:09 +03:00
|
|
|
Range<wr::ImageKey> keys(&aKey, 1);
|
|
|
|
// Check if key is obsoleted.
|
|
|
|
if (keys[0].mNamespace != mIdNamespace) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-10-02 20:27:52 +03:00
|
|
|
auto key = wr::AsUint64(aKey);
|
|
|
|
auto it = mSharedSurfaceIds.find(key);
|
|
|
|
if (it == mSharedSurfaceIds.end()) {
|
|
|
|
gfxCriticalNote << "Updating unknown shared surface: " << key;
|
2018-07-12 18:43:09 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-02 20:27:52 +03:00
|
|
|
RefPtr<DataSourceSurface> dSurf;
|
|
|
|
if (it->second == aExtId) {
|
|
|
|
dSurf = SharedSurfacesParent::Get(aExtId);
|
|
|
|
} else {
|
|
|
|
dSurf = SharedSurfacesParent::Acquire(aExtId);
|
|
|
|
}
|
|
|
|
|
2018-07-12 18:43:09 +03:00
|
|
|
if (!dSurf) {
|
|
|
|
gfxCriticalNote << "Shared surface does not exist for extId:"
|
|
|
|
<< wr::AsUint64(aExtId);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-02 20:27:52 +03:00
|
|
|
if (!(it->second == aExtId)) {
|
|
|
|
// We already have a mapping for this image key, so ensure we release the
|
2018-10-02 20:28:04 +03:00
|
|
|
// previous external image ID. This can happen when an image is animated,
|
|
|
|
// and it is changing the external image that the animation points to.
|
|
|
|
if (!aScheduleRelease) {
|
2018-09-28 22:11:15 +03:00
|
|
|
aScheduleRelease = MakeUnique<ScheduleSharedSurfaceRelease>(this);
|
2018-10-02 20:28:04 +03:00
|
|
|
}
|
2018-09-28 22:11:15 +03:00
|
|
|
aScheduleRelease->Add(aKey, it->second);
|
2018-10-02 20:27:52 +03:00
|
|
|
it->second = aExtId;
|
|
|
|
}
|
|
|
|
|
2018-07-12 18:43:09 +03:00
|
|
|
if (!gfxEnv::EnableWebRenderRecording()) {
|
|
|
|
wr::ImageDescriptor descriptor(dSurf->GetSize(), dSurf->Stride(),
|
|
|
|
dSurf->GetFormat());
|
|
|
|
aResources.UpdateExternalImageWithDirtyRect(
|
|
|
|
aKey, descriptor, aExtId, wr::WrExternalImageBufferType::ExternalBuffer,
|
2018-11-16 20:13:26 +03:00
|
|
|
wr::ToDeviceIntRect(aDirtyRect), 0);
|
2018-07-12 18:43:09 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataSourceSurface::ScopedMap map(dSurf, DataSourceSurface::READ);
|
|
|
|
if (!map.IsMapped()) {
|
|
|
|
gfxCriticalNote << "DataSourceSurface failed to map for Image for extId:"
|
|
|
|
<< wr::AsUint64(aExtId);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
IntSize size = dSurf->GetSize();
|
|
|
|
wr::ImageDescriptor descriptor(size, map.GetStride(), dSurf->GetFormat());
|
|
|
|
wr::Vec<uint8_t> data;
|
|
|
|
data.PushBytes(Range<uint8_t>(map.GetData(), size.height * map.GetStride()));
|
|
|
|
aResources.UpdateImageBuffer(keys[0], descriptor, data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-28 22:11:15 +03:00
|
|
|
void WebRenderBridgeParent::ObserveSharedSurfaceRelease(
|
|
|
|
const nsTArray<wr::ExternalImageKeyPair>& aPairs) {
|
|
|
|
if (!mDestroyed) {
|
|
|
|
Unused << SendWrReleasedImages(aPairs);
|
|
|
|
}
|
|
|
|
for (const auto& pair : aPairs) {
|
|
|
|
SharedSurfacesParent::Release(pair.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-14 19:48:55 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvUpdateResources(
|
|
|
|
nsTArray<OpUpdateResource>&& aResourceUpdates,
|
2018-01-12 17:11:28 +03:00
|
|
|
nsTArray<RefCountedShmem>&& aSmallShmems,
|
2019-03-22 21:28:42 +03:00
|
|
|
nsTArray<ipc::Shmem>&& aLargeShmems, const wr::RenderRoot& aRenderRoot) {
|
2017-09-04 14:59:42 +03:00
|
|
|
if (mDestroyed) {
|
2018-10-11 17:41:46 +03:00
|
|
|
wr::IpcResourceUpdateQueue::ReleaseShmems(this, aSmallShmems);
|
|
|
|
wr::IpcResourceUpdateQueue::ReleaseShmems(this, aLargeShmems);
|
2017-09-04 14:59:42 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-05 18:42:50 +03:00
|
|
|
MOZ_RELEASE_ASSERT(aRenderRoot <= wr::kHighestRenderRoot);
|
2019-03-22 21:28:42 +03:00
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
wr::TransactionBuilder txn;
|
2018-09-12 18:30:17 +03:00
|
|
|
txn.SetLowPriority(!IsRootWebRenderBridgeParent());
|
2017-09-14 19:48:55 +03:00
|
|
|
|
2018-10-11 17:41:46 +03:00
|
|
|
bool success =
|
|
|
|
UpdateResources(aResourceUpdates, aSmallShmems, aLargeShmems, txn);
|
|
|
|
wr::IpcResourceUpdateQueue::ReleaseShmems(this, aSmallShmems);
|
|
|
|
wr::IpcResourceUpdateQueue::ReleaseShmems(this, aLargeShmems);
|
|
|
|
|
|
|
|
if (!success) {
|
|
|
|
return IPC_FAIL(this, "Invalid WebRender resource data shmem or address.");
|
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
Api(aRenderRoot)->SendTransaction(txn);
|
2018-01-12 14:24:07 +03:00
|
|
|
|
2017-09-04 14:59:42 +03:00
|
|
|
return IPC_OK();
|
2017-09-04 14:59:26 +03:00
|
|
|
}
|
|
|
|
|
2017-04-26 05:58:50 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvDeleteCompositorAnimations(
|
|
|
|
InfallibleTArray<uint64_t>&& aIds) {
|
2017-04-19 12:54:11 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2018-04-27 17:32:31 +03:00
|
|
|
// Once mWrEpoch has been rendered, we can delete these compositor animations
|
2018-05-30 22:15:35 +03:00
|
|
|
mCompositorAnimationsToDelete.push(
|
|
|
|
CompositorAnimationIdsForEpoch(mWrEpoch, std::move(aIds)));
|
2018-04-27 17:32:31 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebRenderBridgeParent::RemoveEpochDataPriorTo(
|
|
|
|
const wr::Epoch& aRenderedEpoch) {
|
|
|
|
while (!mCompositorAnimationsToDelete.empty()) {
|
2019-01-28 23:11:59 +03:00
|
|
|
if (aRenderedEpoch < mCompositorAnimationsToDelete.front().mEpoch) {
|
2018-04-27 17:32:31 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (uint64_t id : mCompositorAnimationsToDelete.front().mIds) {
|
2019-01-28 23:11:59 +03:00
|
|
|
const auto activeAnim = mActiveAnimations.find(id);
|
|
|
|
if (activeAnim == mActiveAnimations.end()) {
|
2018-04-27 17:32:31 +03:00
|
|
|
NS_ERROR("Tried to delete invalid animation");
|
2019-01-28 23:11:59 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Check if animation delete request is still valid.
|
|
|
|
if (activeAnim->second <= mCompositorAnimationsToDelete.front().mEpoch) {
|
|
|
|
mAnimStorage->ClearById(id);
|
|
|
|
mActiveAnimations.erase(activeAnim);
|
2018-04-27 17:32:31 +03:00
|
|
|
}
|
2017-06-15 10:36:03 +03:00
|
|
|
}
|
2018-04-27 17:32:31 +03:00
|
|
|
mCompositorAnimationsToDelete.pop();
|
2017-04-26 05:58:50 +03:00
|
|
|
}
|
2017-04-19 12:54:11 +03:00
|
|
|
}
|
|
|
|
|
2018-06-26 21:37:31 +03:00
|
|
|
bool WebRenderBridgeParent::IsRootWebRenderBridgeParent() const {
|
|
|
|
return !!mWidget;
|
|
|
|
}
|
|
|
|
|
2017-05-12 20:58:17 +03:00
|
|
|
CompositorBridgeParent* WebRenderBridgeParent::GetRootCompositorBridgeParent()
|
|
|
|
const {
|
2017-04-20 17:38:06 +03:00
|
|
|
if (!mCompositorBridge) {
|
2017-05-12 20:58:17 +03:00
|
|
|
return nullptr;
|
2017-04-20 17:38:06 +03:00
|
|
|
}
|
|
|
|
|
2018-06-26 21:37:31 +03:00
|
|
|
if (IsRootWebRenderBridgeParent()) {
|
2017-04-20 17:38:06 +03:00
|
|
|
// This WebRenderBridgeParent is attached to the root
|
|
|
|
// CompositorBridgeParent.
|
2017-05-12 20:58:17 +03:00
|
|
|
return static_cast<CompositorBridgeParent*>(mCompositorBridge);
|
2017-04-20 17:38:06 +03:00
|
|
|
}
|
|
|
|
|
2017-05-12 20:58:17 +03:00
|
|
|
// Otherwise, this WebRenderBridgeParent is attached to a
|
2019-03-04 00:02:25 +03:00
|
|
|
// ContentCompositorBridgeParent so we have an extra level of
|
2017-05-12 20:58:17 +03:00
|
|
|
// indirection to unravel.
|
|
|
|
CompositorBridgeParent::LayerTreeState* lts =
|
2017-05-28 14:51:53 +03:00
|
|
|
CompositorBridgeParent::GetIndirectShadowTree(GetLayersId());
|
2017-08-23 07:44:22 +03:00
|
|
|
if (!lts) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2017-05-12 20:58:17 +03:00
|
|
|
return lts->mParent;
|
|
|
|
}
|
|
|
|
|
2018-05-01 00:13:39 +03:00
|
|
|
RefPtr<WebRenderBridgeParent>
|
|
|
|
WebRenderBridgeParent::GetRootWebRenderBridgeParent() const {
|
|
|
|
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
|
|
|
|
if (!cbp) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cbp->GetWebRenderBridgeParent();
|
|
|
|
}
|
|
|
|
|
2018-04-10 19:29:56 +03:00
|
|
|
void WebRenderBridgeParent::UpdateAPZFocusState(const FocusTarget& aFocus) {
|
2017-05-12 20:58:17 +03:00
|
|
|
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
|
|
|
|
if (!cbp) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-25 02:06:01 +03:00
|
|
|
LayersId rootLayersId = cbp->RootLayerTreeId();
|
2018-04-10 19:29:56 +03:00
|
|
|
if (RefPtr<APZUpdater> apz = cbp->GetAPZUpdater()) {
|
2019-03-22 21:28:42 +03:00
|
|
|
apz->UpdateFocusState(rootLayersId, WRRootId(GetLayersId(), mRenderRoot),
|
|
|
|
aFocus);
|
2018-04-10 19:29:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-10 19:30:01 +03:00
|
|
|
void WebRenderBridgeParent::UpdateAPZScrollData(const wr::Epoch& aEpoch,
|
2019-03-22 21:28:42 +03:00
|
|
|
WebRenderScrollData&& aData,
|
|
|
|
wr::RenderRoot aRenderRoot) {
|
2018-04-10 19:29:56 +03:00
|
|
|
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
|
|
|
|
if (!cbp) {
|
2017-04-20 17:38:06 +03:00
|
|
|
return;
|
|
|
|
}
|
2018-04-10 19:29:56 +03:00
|
|
|
LayersId rootLayersId = cbp->RootLayerTreeId();
|
2018-03-29 01:36:42 +03:00
|
|
|
if (RefPtr<APZUpdater> apz = cbp->GetAPZUpdater()) {
|
2019-03-22 21:28:42 +03:00
|
|
|
apz->UpdateScrollDataAndTreeState(
|
|
|
|
WRRootId(rootLayersId, wr::RenderRoot::Default),
|
|
|
|
WRRootId(GetLayersId(), RenderRootForExternal(aRenderRoot)), aEpoch,
|
|
|
|
std::move(aData));
|
2017-04-20 17:38:06 +03:00
|
|
|
}
|
2016-12-30 00:51:32 +03:00
|
|
|
}
|
|
|
|
|
2018-05-12 04:18:22 +03:00
|
|
|
void WebRenderBridgeParent::UpdateAPZScrollOffsets(
|
2019-03-22 21:28:42 +03:00
|
|
|
ScrollUpdatesMap&& aUpdates, uint32_t aPaintSequenceNumber,
|
|
|
|
wr::RenderRoot aRenderRoot) {
|
2018-05-12 04:18:22 +03:00
|
|
|
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
|
|
|
|
if (!cbp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
LayersId rootLayersId = cbp->RootLayerTreeId();
|
|
|
|
if (RefPtr<APZUpdater> apz = cbp->GetAPZUpdater()) {
|
2019-03-22 21:28:42 +03:00
|
|
|
apz->UpdateScrollOffsets(
|
|
|
|
WRRootId(rootLayersId, wr::RenderRoot::Default),
|
|
|
|
WRRootId(GetLayersId(), RenderRootForExternal(aRenderRoot)),
|
|
|
|
std::move(aUpdates), aPaintSequenceNumber);
|
2018-05-12 04:18:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-17 00:39:26 +03:00
|
|
|
void WebRenderBridgeParent::SetAPZSampleTime() {
|
2017-05-12 20:58:20 +03:00
|
|
|
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
|
|
|
|
if (!cbp) {
|
2018-04-17 00:39:26 +03:00
|
|
|
return;
|
2017-05-12 20:58:20 +03:00
|
|
|
}
|
2018-03-06 18:25:37 +03:00
|
|
|
if (RefPtr<APZSampler> apz = cbp->GetAPZSampler()) {
|
2017-06-28 03:29:05 +03:00
|
|
|
TimeStamp animationTime = cbp->GetTestingTimeStamp().valueOr(
|
|
|
|
mCompositorScheduler->GetLastComposeTime());
|
2017-05-12 20:58:20 +03:00
|
|
|
TimeDuration frameInterval = cbp->GetVsyncInterval();
|
|
|
|
// As with the non-webrender codepath in AsyncCompositionManager, we want to
|
|
|
|
// use the timestamp for the next vsync when advancing animations.
|
|
|
|
if (frameInterval != TimeDuration::Forever()) {
|
|
|
|
animationTime += frameInterval;
|
|
|
|
}
|
2018-04-17 00:39:26 +03:00
|
|
|
apz->SetSampleTime(animationTime);
|
2017-05-12 20:58:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
bool WebRenderBridgeParent::SetDisplayList(
|
2019-03-28 19:45:12 +03:00
|
|
|
wr::RenderRoot aRenderRoot, const LayoutDeviceRect& aRect,
|
2019-03-22 21:28:42 +03:00
|
|
|
const wr::LayoutSize& aContentSize, ipc::ByteBuf&& aDL,
|
|
|
|
const wr::BuiltDisplayListDescriptor& aDLDesc,
|
|
|
|
const nsTArray<OpUpdateResource>& aResourceUpdates,
|
|
|
|
const nsTArray<RefCountedShmem>& aSmallShmems,
|
|
|
|
const nsTArray<ipc::Shmem>& aLargeShmems, const TimeStamp& aTxnStartTime,
|
2019-03-22 21:29:04 +03:00
|
|
|
wr::TransactionBuilder& aTxn, wr::Epoch aWrEpoch, bool aValidTransaction,
|
|
|
|
bool aObserveLayersUpdate) {
|
2019-03-22 21:28:42 +03:00
|
|
|
if (NS_WARN_IF(!UpdateResources(aResourceUpdates, aSmallShmems, aLargeShmems,
|
|
|
|
aTxn))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
wr::Vec<uint8_t> dlData(std::move(aDL));
|
|
|
|
|
|
|
|
if (aValidTransaction) {
|
|
|
|
if (IsRootWebRenderBridgeParent()) {
|
|
|
|
if (aRenderRoot != wr::RenderRoot::Default) {
|
|
|
|
MutexAutoLock lock(mRenderRootRectMutex);
|
2019-03-28 19:46:35 +03:00
|
|
|
mRenderRootRects[aRenderRoot] = ViewAs<ScreenPixel>(
|
|
|
|
aRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
2019-03-22 21:28:42 +03:00
|
|
|
}
|
|
|
|
LayoutDeviceIntSize widgetSize = mWidget->GetClientSize();
|
2019-04-21 05:00:11 +03:00
|
|
|
LayoutDeviceIntRect rect;
|
|
|
|
if (gfxPrefs::WebRenderSplitRenderRoots()) {
|
|
|
|
rect = RoundedToInt(aRect);
|
|
|
|
rect.SetWidth(
|
|
|
|
std::max(0, std::min(widgetSize.width - rect.X(), rect.Width())));
|
|
|
|
rect.SetHeight(
|
|
|
|
std::max(0, std::min(widgetSize.height - rect.Y(), rect.Height())));
|
|
|
|
} else {
|
|
|
|
// XXX: If we can't have multiple documents, just use the
|
|
|
|
// pre-document- splitting behavior of directly applying the client
|
|
|
|
// size. This is a speculative and temporary attempt to address bug
|
|
|
|
// 1538540, as an incorrect rect supplied to SetDocumentView can cause
|
|
|
|
// us to not build a frame and potentially render with stale texture
|
|
|
|
// cache items.
|
|
|
|
rect = LayoutDeviceIntRect(LayoutDeviceIntPoint(), widgetSize);
|
|
|
|
}
|
2019-04-25 16:02:47 +03:00
|
|
|
aTxn.SetDocumentView(rect);
|
2019-03-22 21:28:42 +03:00
|
|
|
}
|
|
|
|
gfx::Color clearColor(0.f, 0.f, 0.f, 0.f);
|
|
|
|
aTxn.SetDisplayList(clearColor, aWrEpoch,
|
2019-03-28 19:45:12 +03:00
|
|
|
wr::ToLayoutSize(RoundedToInt(aRect).Size()),
|
2019-03-28 19:38:01 +03:00
|
|
|
mPipelineId, aContentSize, aDLDesc, dlData);
|
2019-03-22 21:28:42 +03:00
|
|
|
|
|
|
|
if (aObserveLayersUpdate) {
|
|
|
|
aTxn.Notify(wr::Checkpoint::SceneBuilt,
|
|
|
|
MakeUnique<ScheduleObserveLayersUpdate>(
|
|
|
|
mCompositorBridge, GetLayersId(),
|
|
|
|
mChildLayersObserverEpoch, true));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsRootWebRenderBridgeParent()) {
|
|
|
|
aTxn.Notify(
|
|
|
|
wr::Checkpoint::SceneBuilt,
|
|
|
|
MakeUnique<SceneBuiltNotification>(this, aWrEpoch, aTxnStartTime));
|
|
|
|
}
|
|
|
|
|
2019-03-22 21:29:04 +03:00
|
|
|
Api(aRenderRoot)->SendTransaction(aTxn);
|
2019-03-22 21:28:42 +03:00
|
|
|
|
|
|
|
// We will schedule generating a frame after the scene
|
|
|
|
// build is done, so we don't need to do it here.
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-09-04 14:59:26 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetDisplayList(
|
2019-03-22 21:28:42 +03:00
|
|
|
nsTArray<RenderRootDisplayListData>&& aDisplayLists,
|
2017-09-04 14:59:26 +03:00
|
|
|
InfallibleTArray<OpDestroy>&& aToDestroy, const uint64_t& aFwdTransactionId,
|
2019-03-22 21:28:42 +03:00
|
|
|
const TransactionId& aTransactionId, const wr::IdNamespace& aIdNamespace,
|
2018-12-08 02:28:03 +03:00
|
|
|
const bool& aContainsSVGGroup, const VsyncId& aVsyncId,
|
2019-01-03 22:43:04 +03:00
|
|
|
const TimeStamp& aVsyncStartTime, const TimeStamp& aRefreshStartTime,
|
|
|
|
const TimeStamp& aTxnStartTime, const nsCString& aTxnURL,
|
|
|
|
const TimeStamp& aFwdTime) {
|
2017-06-05 09:41:21 +03:00
|
|
|
if (mDestroyed) {
|
2017-09-04 14:59:26 +03:00
|
|
|
for (const auto& op : aToDestroy) {
|
|
|
|
DestroyActor(op);
|
|
|
|
}
|
2017-06-05 09:41:21 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
2017-09-04 14:59:26 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
// Guard against malicious content processes
|
|
|
|
MOZ_RELEASE_ASSERT(aDisplayLists.Length() > 0);
|
|
|
|
for (auto& displayList : aDisplayLists) {
|
2019-04-05 18:42:50 +03:00
|
|
|
MOZ_RELEASE_ASSERT(displayList.mRenderRoot <= wr::kHighestRenderRoot);
|
2019-03-22 21:28:42 +03:00
|
|
|
}
|
|
|
|
|
2018-12-19 12:03:27 +03:00
|
|
|
if (!IsRootWebRenderBridgeParent()) {
|
|
|
|
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::URL, aTxnURL);
|
|
|
|
}
|
|
|
|
|
2019-01-18 18:40:15 +03:00
|
|
|
AUTO_PROFILER_TRACING("Paint", "SetDisplayList", GRAPHICS);
|
2017-09-04 14:59:26 +03:00
|
|
|
UpdateFwdTransactionId(aFwdTransactionId);
|
|
|
|
|
|
|
|
// This ensures that destroy operations are always processed. It is not safe
|
|
|
|
// to early-return from RecvDPEnd without doing so.
|
|
|
|
AutoWebRenderBridgeParentAsyncMessageSender autoAsyncMessageSender(
|
|
|
|
this, &aToDestroy);
|
|
|
|
|
2018-04-10 19:29:56 +03:00
|
|
|
wr::Epoch wrEpoch = GetNextWrEpoch();
|
2017-09-20 11:56:09 +03:00
|
|
|
|
|
|
|
mAsyncImageManager->SetCompositionTime(TimeStamp::Now());
|
2018-01-12 14:24:03 +03:00
|
|
|
|
2018-03-06 22:20:56 +03:00
|
|
|
mReceivedDisplayList = true;
|
2019-03-22 21:28:42 +03:00
|
|
|
bool observeLayersUpdate = ShouldParentObserveEpoch();
|
2018-03-06 22:20:56 +03:00
|
|
|
|
2019-03-22 21:29:04 +03:00
|
|
|
// The IsFirstPaint() flag should be the same for all the non-empty
|
|
|
|
// scrolldata across all the renderroot display lists in a given
|
|
|
|
// transaction. We assert this below. So we can read the flag from any one
|
|
|
|
// of them.
|
|
|
|
Maybe<size_t> firstScrollDataIndex;
|
2019-03-22 21:28:42 +03:00
|
|
|
for (size_t i = 1; i < aDisplayLists.Length(); i++) {
|
2019-03-22 21:29:04 +03:00
|
|
|
auto& scrollData = aDisplayLists[i].mScrollData;
|
|
|
|
if (scrollData) {
|
|
|
|
if (firstScrollDataIndex.isNothing()) {
|
|
|
|
firstScrollDataIndex = Some(i);
|
|
|
|
if (scrollData && scrollData->IsFirstPaint()) {
|
|
|
|
mIsFirstPaint = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
auto firstNonEmpty = aDisplayLists[*firstScrollDataIndex].mScrollData;
|
|
|
|
// Ensure the flag is the same on all of them.
|
|
|
|
MOZ_RELEASE_ASSERT(scrollData->IsFirstPaint() ==
|
|
|
|
firstNonEmpty->IsFirstPaint());
|
|
|
|
}
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
}
|
2018-10-19 16:48:04 +03:00
|
|
|
|
2018-04-10 19:30:01 +03:00
|
|
|
// aScrollData is moved into this function but that is not reflected by the
|
|
|
|
// function signature due to the way the IPDL generator works. We remove the
|
|
|
|
// const so that we can move this structure all the way to the desired
|
|
|
|
// destination.
|
|
|
|
// Also note that this needs to happen before the display list transaction is
|
|
|
|
// sent to WebRender, so that the UpdateHitTestingTree call is guaranteed to
|
|
|
|
// be in the updater queue at the time that the scene swap completes.
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto& displayList : aDisplayLists) {
|
2019-03-22 21:29:04 +03:00
|
|
|
if (displayList.mScrollData) {
|
|
|
|
UpdateAPZScrollData(wrEpoch, std::move(displayList.mScrollData.ref()),
|
|
|
|
displayList.mRenderRoot);
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
}
|
2019-03-22 02:15:42 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
bool validTransaction = aIdNamespace == mIdNamespace;
|
2019-03-22 02:15:42 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::RenderRootArray<wr::TransactionBuilder> txns;
|
|
|
|
wr::RenderRootArray<Maybe<wr::AutoTransactionSender>> senders;
|
|
|
|
for (auto& displayList : aDisplayLists) {
|
|
|
|
MOZ_ASSERT(displayList.mRenderRoot == wr::RenderRoot::Default ||
|
|
|
|
IsRootWebRenderBridgeParent());
|
2019-03-22 21:29:04 +03:00
|
|
|
auto renderRoot = displayList.mRenderRoot;
|
|
|
|
auto& txn = txns[renderRoot];
|
|
|
|
|
|
|
|
txn.SetLowPriority(!IsRootWebRenderBridgeParent());
|
|
|
|
if (validTransaction) {
|
|
|
|
senders[renderRoot].emplace(Api(renderRoot), &txn);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_WARN_IF(!ProcessWebRenderParentCommands(displayList.mCommands, txn,
|
|
|
|
renderRoot))) {
|
|
|
|
return IPC_FAIL(this, "Invalid parent command found");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (displayList.mDL &&
|
|
|
|
!SetDisplayList(renderRoot, displayList.mRect, displayList.mContentSize,
|
|
|
|
std::move(displayList.mDL.ref()), displayList.mDLDesc,
|
|
|
|
displayList.mResourceUpdates, displayList.mSmallShmems,
|
|
|
|
displayList.mLargeShmems, aTxnStartTime, txn, wrEpoch,
|
|
|
|
validTransaction, observeLayersUpdate)) {
|
2019-03-22 21:28:42 +03:00
|
|
|
return IPC_FAIL(this, "Failed call to SetDisplayList");
|
2019-01-08 22:35:46 +03:00
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
}
|
2018-11-16 08:26:10 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
if (!validTransaction && observeLayersUpdate) {
|
2018-09-21 19:47:18 +03:00
|
|
|
mCompositorBridge->ObserveLayersUpdate(GetLayersId(),
|
|
|
|
mChildLayersObserverEpoch, true);
|
2017-09-20 11:56:09 +03:00
|
|
|
}
|
|
|
|
|
2018-12-08 02:28:03 +03:00
|
|
|
HoldPendingTransactionId(wrEpoch, aTransactionId, aContainsSVGGroup, aVsyncId,
|
2019-01-03 22:43:04 +03:00
|
|
|
aVsyncStartTime, aRefreshStartTime, aTxnStartTime,
|
|
|
|
aTxnURL, aFwdTime, mIsFirstPaint);
|
2018-10-19 16:48:04 +03:00
|
|
|
mIsFirstPaint = false;
|
2017-09-04 14:59:26 +03:00
|
|
|
|
2018-08-21 15:29:09 +03:00
|
|
|
if (!validTransaction) {
|
2017-09-04 14:59:26 +03:00
|
|
|
// Pretend we composited since someone is wating for this event,
|
|
|
|
// though DisplayList was not pushed to webrender.
|
2018-07-27 16:42:30 +03:00
|
|
|
if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) {
|
|
|
|
TimeStamp now = TimeStamp::Now();
|
2018-12-08 02:28:41 +03:00
|
|
|
cbp->NotifyPipelineRendered(mPipelineId, wrEpoch, VsyncId(), now, now,
|
|
|
|
now);
|
2018-07-27 16:42:30 +03:00
|
|
|
}
|
2017-09-04 14:59:26 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto& displayList : aDisplayLists) {
|
|
|
|
wr::IpcResourceUpdateQueue::ReleaseShmems(this, displayList.mSmallShmems);
|
|
|
|
wr::IpcResourceUpdateQueue::ReleaseShmems(this, displayList.mLargeShmems);
|
|
|
|
}
|
|
|
|
|
2016-11-21 18:16:11 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-10-12 04:13:10 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvEmptyTransaction(
|
2019-03-22 21:28:42 +03:00
|
|
|
const FocusTarget& aFocusTarget, const uint32_t& aPaintSequenceNumber,
|
|
|
|
nsTArray<RenderRootUpdates>&& aRenderRootUpdates,
|
2017-10-12 04:13:10 +03:00
|
|
|
InfallibleTArray<OpDestroy>&& aToDestroy, const uint64_t& aFwdTransactionId,
|
2019-03-22 21:28:42 +03:00
|
|
|
const TransactionId& aTransactionId, const wr::IdNamespace& aIdNamespace,
|
2019-01-03 22:43:04 +03:00
|
|
|
const VsyncId& aVsyncId, const TimeStamp& aVsyncStartTime,
|
|
|
|
const TimeStamp& aRefreshStartTime, const TimeStamp& aTxnStartTime,
|
|
|
|
const nsCString& aTxnURL, const TimeStamp& aFwdTime) {
|
2017-10-12 04:13:10 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
for (const auto& op : aToDestroy) {
|
|
|
|
DestroyActor(op);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
// Guard against malicious content processes
|
|
|
|
for (auto& update : aRenderRootUpdates) {
|
2019-04-05 18:42:50 +03:00
|
|
|
MOZ_RELEASE_ASSERT(update.mRenderRoot <= wr::kHighestRenderRoot);
|
2019-03-22 21:28:42 +03:00
|
|
|
}
|
|
|
|
|
2018-12-19 12:03:27 +03:00
|
|
|
if (!IsRootWebRenderBridgeParent()) {
|
|
|
|
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::URL, aTxnURL);
|
|
|
|
}
|
|
|
|
|
2019-01-18 18:40:15 +03:00
|
|
|
AUTO_PROFILER_TRACING("Paint", "EmptyTransaction", GRAPHICS);
|
2017-10-12 04:13:10 +03:00
|
|
|
UpdateFwdTransactionId(aFwdTransactionId);
|
|
|
|
|
|
|
|
// This ensures that destroy operations are always processed. It is not safe
|
|
|
|
// to early-return without doing so.
|
|
|
|
AutoWebRenderBridgeParentAsyncMessageSender autoAsyncMessageSender(
|
|
|
|
this, &aToDestroy);
|
|
|
|
|
2019-03-27 14:16:52 +03:00
|
|
|
wr::RenderRootArray<bool> scheduleComposite;
|
2017-10-12 04:13:10 +03:00
|
|
|
|
2018-04-10 19:29:56 +03:00
|
|
|
UpdateAPZFocusState(aFocusTarget);
|
2018-11-26 10:08:49 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::RenderRootArray<Maybe<wr::TransactionBuilder>> txns;
|
|
|
|
for (auto& update : aRenderRootUpdates) {
|
|
|
|
MOZ_ASSERT(update.mRenderRoot == wr::RenderRoot::Default ||
|
|
|
|
IsRootWebRenderBridgeParent());
|
|
|
|
|
|
|
|
if (!update.mScrollUpdates.empty()) {
|
|
|
|
UpdateAPZScrollOffsets(std::move(update.mScrollUpdates),
|
|
|
|
aPaintSequenceNumber, update.mRenderRoot);
|
|
|
|
}
|
|
|
|
|
|
|
|
txns[update.mRenderRoot].emplace();
|
|
|
|
txns[update.mRenderRoot]->SetLowPriority(!IsRootWebRenderBridgeParent());
|
|
|
|
}
|
2019-03-22 11:52:44 +03:00
|
|
|
|
2018-11-26 10:08:49 +03:00
|
|
|
// Update WrEpoch for UpdateResources() and ProcessWebRenderParentCommands().
|
|
|
|
// WrEpoch is used to manage ExternalImages lifetimes in
|
|
|
|
// AsyncImagePipelineManager.
|
|
|
|
Unused << GetNextWrEpoch();
|
2018-10-11 17:41:46 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto& update : aRenderRootUpdates) {
|
|
|
|
if (!UpdateResources(update.mResourceUpdates, update.mSmallShmems,
|
|
|
|
update.mLargeShmems, *txns[update.mRenderRoot])) {
|
|
|
|
return IPC_FAIL(this, "Failed to deserialize resource updates");
|
|
|
|
}
|
2018-10-11 17:41:46 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
bool compositionTimeSet = false;
|
|
|
|
for (auto& update : aRenderRootUpdates) {
|
|
|
|
if (!update.mCommands.IsEmpty()) {
|
|
|
|
if (!compositionTimeSet) {
|
|
|
|
mAsyncImageManager->SetCompositionTime(TimeStamp::Now());
|
|
|
|
compositionTimeSet = true;
|
|
|
|
}
|
|
|
|
if (!ProcessWebRenderParentCommands(update.mCommands,
|
|
|
|
*txns[update.mRenderRoot],
|
|
|
|
update.mRenderRoot)) {
|
|
|
|
return IPC_FAIL(this, "Invalid parent command found");
|
|
|
|
}
|
2019-03-22 06:15:14 +03:00
|
|
|
}
|
2018-11-26 10:08:49 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
if (ShouldParentObserveEpoch()) {
|
|
|
|
txns[update.mRenderRoot]->Notify(wr::Checkpoint::SceneBuilt,
|
|
|
|
MakeUnique<ScheduleObserveLayersUpdate>(
|
|
|
|
mCompositorBridge, GetLayersId(),
|
|
|
|
mChildLayersObserverEpoch, true));
|
|
|
|
}
|
2019-03-22 06:15:14 +03:00
|
|
|
}
|
2019-03-22 11:52:44 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
bool rollbackEpoch = true;
|
|
|
|
for (auto& update : aRenderRootUpdates) {
|
|
|
|
auto& txn = *txns[update.mRenderRoot];
|
|
|
|
|
|
|
|
// Even when txn.IsResourceUpdatesEmpty() is true, there could be resource
|
|
|
|
// updates. It is handled by WebRenderTextureHostWrapper. In this case
|
|
|
|
// txn.IsRenderedFrameInvalidated() becomes true.
|
|
|
|
if (!txn.IsResourceUpdatesEmpty() || txn.IsRenderedFrameInvalidated()) {
|
|
|
|
// There are resource updates, then we update Epoch of transaction.
|
|
|
|
txn.UpdateEpoch(mPipelineId, mWrEpoch);
|
|
|
|
scheduleComposite[update.mRenderRoot] = true;
|
|
|
|
rollbackEpoch = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rollbackEpoch) {
|
2018-11-26 10:08:49 +03:00
|
|
|
// If TransactionBuilder does not have resource updates nor display list,
|
|
|
|
// ScheduleGenerateFrame is not triggered via SceneBuilder and there is no
|
|
|
|
// need to update WrEpoch.
|
|
|
|
// Then we want to rollback WrEpoch. See Bug 1490117.
|
|
|
|
RollbackWrEpoch();
|
2018-05-15 15:49:34 +03:00
|
|
|
}
|
2018-01-12 14:24:03 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
bool scheduleAnyComposite = false;
|
2018-05-15 15:49:34 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto renderRoot : wr::kRenderRoots) {
|
|
|
|
if (txns[renderRoot] && !txns[renderRoot]->IsEmpty()) {
|
|
|
|
Api(renderRoot)->SendTransaction(*txns[renderRoot]);
|
|
|
|
}
|
|
|
|
if (scheduleComposite[renderRoot]) {
|
|
|
|
scheduleAnyComposite = true;
|
|
|
|
}
|
2019-03-22 11:52:44 +03:00
|
|
|
}
|
2019-03-22 06:15:14 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
// If we are going to kick off a new composite as a result of this
|
|
|
|
// transaction, or if there are already composite-triggering pending
|
|
|
|
// transactions inflight, then set sendDidComposite to false because we will
|
|
|
|
// send the DidComposite message after the composite occurs.
|
|
|
|
// If there are no pending transactions and we're not going to do a
|
|
|
|
// composite, then we leave sendDidComposite as true so we just send
|
|
|
|
// the DidComposite notification now.
|
|
|
|
bool sendDidComposite =
|
|
|
|
!scheduleAnyComposite && mPendingTransactionIds.empty();
|
|
|
|
|
2018-08-15 08:13:49 +03:00
|
|
|
// Only register a value for CONTENT_FRAME_TIME telemetry if we actually drew
|
|
|
|
// something. It is for consistency with disabling WebRender.
|
2018-12-08 02:28:03 +03:00
|
|
|
HoldPendingTransactionId(mWrEpoch, aTransactionId, false, aVsyncId,
|
2019-01-03 22:43:04 +03:00
|
|
|
aVsyncStartTime, aRefreshStartTime, aTxnStartTime,
|
|
|
|
aTxnURL, aFwdTime,
|
2018-10-19 16:48:04 +03:00
|
|
|
/* aIsFirstPaint */ false,
|
2019-03-22 21:28:42 +03:00
|
|
|
/* aUseForTelemetry */ scheduleAnyComposite);
|
|
|
|
|
|
|
|
for (auto renderRoot : wr::kRenderRoots) {
|
|
|
|
if (scheduleComposite[renderRoot]) {
|
|
|
|
mAsyncImageManager->SetWillGenerateFrame(renderRoot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scheduleAnyComposite) {
|
|
|
|
ScheduleGenerateFrame(Nothing());
|
2018-05-15 15:49:34 +03:00
|
|
|
} else if (sendDidComposite) {
|
2018-07-27 16:42:30 +03:00
|
|
|
// The only thing in the pending transaction id queue should be the entry
|
|
|
|
// we just added, and now we're going to pretend we rendered it
|
|
|
|
MOZ_ASSERT(mPendingTransactionIds.size() == 1);
|
|
|
|
if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) {
|
|
|
|
TimeStamp now = TimeStamp::Now();
|
2018-12-08 02:28:41 +03:00
|
|
|
cbp->NotifyPipelineRendered(mPipelineId, mWrEpoch, VsyncId(), now, now,
|
|
|
|
now);
|
2018-07-27 16:42:30 +03:00
|
|
|
}
|
2017-11-15 02:00:57 +03:00
|
|
|
}
|
2018-01-12 14:24:03 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto& update : aRenderRootUpdates) {
|
|
|
|
wr::IpcResourceUpdateQueue::ReleaseShmems(this, update.mSmallShmems);
|
|
|
|
wr::IpcResourceUpdateQueue::ReleaseShmems(this, update.mLargeShmems);
|
|
|
|
}
|
2017-10-12 04:13:10 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-10-02 23:49:55 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetFocusTarget(
|
|
|
|
const FocusTarget& aFocusTarget) {
|
2018-04-10 19:29:56 +03:00
|
|
|
UpdateAPZFocusState(aFocusTarget);
|
2017-10-02 23:49:55 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-06-15 07:38:22 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvParentCommands(
|
2019-03-22 21:28:42 +03:00
|
|
|
nsTArray<WebRenderParentCommand>&& aCommands,
|
|
|
|
const wr::RenderRoot& aRenderRoot) {
|
2017-06-15 07:38:22 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2018-05-08 15:49:44 +03:00
|
|
|
wr::TransactionBuilder txn;
|
2018-09-12 18:30:17 +03:00
|
|
|
txn.SetLowPriority(!IsRootWebRenderBridgeParent());
|
2019-03-22 21:28:42 +03:00
|
|
|
if (!ProcessWebRenderParentCommands(aCommands, txn, aRenderRoot)) {
|
2018-09-06 05:36:10 +03:00
|
|
|
return IPC_FAIL(this, "Invalid parent command found");
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
|
|
|
|
Api(aRenderRoot)->SendTransaction(txn);
|
2017-06-15 07:38:22 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
2016-12-05 07:15:02 +03:00
|
|
|
|
2018-05-08 15:49:44 +03:00
|
|
|
bool WebRenderBridgeParent::ProcessWebRenderParentCommands(
|
|
|
|
const InfallibleTArray<WebRenderParentCommand>& aCommands,
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::TransactionBuilder& aTxn, wr::RenderRoot aRenderRoot) {
|
2018-09-26 05:45:30 +03:00
|
|
|
// Transaction for async image pipeline that uses ImageBridge always need to
|
|
|
|
// be non low priority.
|
|
|
|
wr::TransactionBuilder txnForImageBridge;
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::AutoTransactionSender sender(Api(aRenderRoot), &txnForImageBridge);
|
2018-09-26 05:45:30 +03:00
|
|
|
|
2017-03-03 00:33:03 +03:00
|
|
|
for (InfallibleTArray<WebRenderParentCommand>::index_type i = 0;
|
|
|
|
i < aCommands.Length(); ++i) {
|
|
|
|
const WebRenderParentCommand& cmd = aCommands[i];
|
2016-11-18 11:07:02 +03:00
|
|
|
switch (cmd.type()) {
|
2018-04-12 16:13:06 +03:00
|
|
|
case WebRenderParentCommand::TOpAddPipelineIdForCompositable: {
|
|
|
|
const OpAddPipelineIdForCompositable& op =
|
|
|
|
cmd.get_OpAddPipelineIdForCompositable();
|
|
|
|
AddPipelineIdForCompositable(op.pipelineId(), op.handle(), op.isAsync(),
|
2019-03-22 21:28:42 +03:00
|
|
|
aTxn, txnForImageBridge, aRenderRoot);
|
2018-04-12 16:13:06 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WebRenderParentCommand::TOpRemovePipelineIdForCompositable: {
|
|
|
|
const OpRemovePipelineIdForCompositable& op =
|
|
|
|
cmd.get_OpRemovePipelineIdForCompositable();
|
2019-03-22 21:28:42 +03:00
|
|
|
RemovePipelineIdForCompositable(op.pipelineId(), aTxn, aRenderRoot);
|
2018-04-12 16:13:06 +03:00
|
|
|
break;
|
|
|
|
}
|
2018-07-06 15:25:33 +03:00
|
|
|
case WebRenderParentCommand::TOpReleaseTextureOfImage: {
|
|
|
|
const OpReleaseTextureOfImage& op = cmd.get_OpReleaseTextureOfImage();
|
|
|
|
ReleaseTextureOfImage(op.key());
|
|
|
|
break;
|
|
|
|
}
|
2017-06-02 10:11:34 +03:00
|
|
|
case WebRenderParentCommand::TOpUpdateAsyncImagePipeline: {
|
|
|
|
const OpUpdateAsyncImagePipeline& op =
|
|
|
|
cmd.get_OpUpdateAsyncImagePipeline();
|
2017-07-25 11:54:36 +03:00
|
|
|
mAsyncImageManager->UpdateAsyncImagePipeline(
|
2018-04-12 16:13:06 +03:00
|
|
|
op.pipelineId(), op.scBounds(), op.scTransform(), op.scaleToSize(),
|
|
|
|
op.filter(), op.mixBlendMode());
|
2019-03-22 21:28:42 +03:00
|
|
|
mAsyncImageManager->ApplyAsyncImageForPipeline(
|
|
|
|
op.pipelineId(), aTxn, txnForImageBridge,
|
|
|
|
RenderRootForExternal(aRenderRoot));
|
2018-07-19 01:51:37 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WebRenderParentCommand::TOpUpdatedAsyncImagePipeline: {
|
|
|
|
const OpUpdatedAsyncImagePipeline& op =
|
|
|
|
cmd.get_OpUpdatedAsyncImagePipeline();
|
2019-03-22 21:28:42 +03:00
|
|
|
mAsyncImageManager->ApplyAsyncImageForPipeline(
|
|
|
|
op.pipelineId(), aTxn, txnForImageBridge,
|
|
|
|
RenderRootForExternal(aRenderRoot));
|
2016-12-05 07:15:02 +03:00
|
|
|
break;
|
|
|
|
}
|
2017-03-03 00:33:03 +03:00
|
|
|
case WebRenderParentCommand::TCompositableOperation: {
|
2016-12-07 02:34:54 +03:00
|
|
|
if (!ReceiveCompositableUpdate(cmd.get_CompositableOperation())) {
|
2016-12-05 07:15:02 +03:00
|
|
|
NS_ERROR("ReceiveCompositableUpdate failed");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-03-28 12:11:03 +03:00
|
|
|
case WebRenderParentCommand::TOpAddCompositorAnimations: {
|
|
|
|
const OpAddCompositorAnimations& op =
|
|
|
|
cmd.get_OpAddCompositorAnimations();
|
2018-05-30 22:15:35 +03:00
|
|
|
CompositorAnimations data(std::move(op.data()));
|
2018-09-06 05:36:10 +03:00
|
|
|
// AnimationHelper::GetNextCompositorAnimationsId() encodes the child
|
|
|
|
// process PID in the upper 32 bits of the id, verify that this is as
|
|
|
|
// expected.
|
|
|
|
if ((data.id() >> 32) != (uint64_t)OtherPid()) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-28 12:11:03 +03:00
|
|
|
if (data.animations().Length()) {
|
2019-03-22 21:28:42 +03:00
|
|
|
mAnimStorage->SetAnimations(data.id(), data.animations(),
|
|
|
|
RenderRootForExternal(aRenderRoot));
|
2019-01-28 23:11:59 +03:00
|
|
|
const auto activeAnim = mActiveAnimations.find(data.id());
|
|
|
|
if (activeAnim == mActiveAnimations.end()) {
|
|
|
|
mActiveAnimations.emplace(data.id(), mWrEpoch);
|
|
|
|
} else {
|
|
|
|
// Update wr::Epoch if the animation already exists.
|
|
|
|
activeAnim->second = mWrEpoch;
|
|
|
|
}
|
2017-03-28 12:11:03 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-03-02 04:36:27 +03:00
|
|
|
default: {
|
|
|
|
// other commands are handle on the child
|
2017-02-16 21:23:22 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-11-18 11:07:02 +03:00
|
|
|
}
|
|
|
|
}
|
2018-09-06 05:36:10 +03:00
|
|
|
return true;
|
2017-06-15 07:38:22 +03:00
|
|
|
}
|
|
|
|
|
2018-05-28 18:29:52 +03:00
|
|
|
void WebRenderBridgeParent::FlushSceneBuilds() {
|
|
|
|
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
|
|
|
|
2018-07-10 15:49:21 +03:00
|
|
|
// Since we are sending transactions through the scene builder thread, we need
|
|
|
|
// to block until all the inflight transactions have been processed. This
|
|
|
|
// flush message blocks until all previously sent scenes have been built
|
|
|
|
// and received by the render backend thread.
|
2019-03-22 21:28:42 +03:00
|
|
|
Api(wr::RenderRoot::Default)->FlushSceneBuilder();
|
2018-07-10 15:49:21 +03:00
|
|
|
// The post-swap hook for async-scene-building calls the
|
|
|
|
// ScheduleRenderOnCompositorThread function from the scene builder thread,
|
|
|
|
// which then triggers a call to ScheduleGenerateFrame() on the compositor
|
|
|
|
// thread. But since *this* function is running on the compositor thread,
|
|
|
|
// that scheduling will not happen until this call stack unwinds (or we
|
|
|
|
// could spin a nested event loop, but that's more messy). Instead, we
|
|
|
|
// simulate it ourselves by calling ScheduleGenerateFrame() directly.
|
|
|
|
// Note also that the post-swap hook will run and do another
|
|
|
|
// ScheduleGenerateFrame() after we unwind here, so we will end up with an
|
|
|
|
// extra render/composite that is probably avoidable, but in practice we
|
|
|
|
// shouldn't be calling this function all that much in production so this
|
|
|
|
// is probably fine. If it becomes an issue we can add more state tracking
|
|
|
|
// machinery to optimize it away.
|
2019-03-22 21:28:42 +03:00
|
|
|
ScheduleGenerateFrameAllRenderRoots();
|
2018-05-28 18:29:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebRenderBridgeParent::FlushFrameGeneration() {
|
|
|
|
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
2018-06-26 21:37:31 +03:00
|
|
|
MOZ_ASSERT(IsRootWebRenderBridgeParent()); // This function is only useful on
|
|
|
|
// the root WRBP
|
2018-05-28 18:29:52 +03:00
|
|
|
|
|
|
|
// This forces a new GenerateFrame transaction to be sent to the render
|
|
|
|
// backend thread, if one is pending. This doesn't block on any other threads.
|
2018-08-10 02:10:11 +03:00
|
|
|
if (mCompositorScheduler->NeedsComposite()) {
|
|
|
|
mCompositorScheduler->CancelCurrentCompositeTask();
|
|
|
|
// Update timestamp of scheduler for APZ and animation.
|
|
|
|
mCompositorScheduler->UpdateLastComposeTime();
|
2018-12-08 02:28:41 +03:00
|
|
|
MaybeGenerateFrame(VsyncId(), /* aForceGenerateFrame */ true);
|
2018-08-10 02:10:11 +03:00
|
|
|
}
|
2018-05-28 18:29:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebRenderBridgeParent::FlushFramePresentation() {
|
|
|
|
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
|
|
|
|
|
|
|
// This sends a message to the render backend thread to send a message
|
|
|
|
// to the renderer thread, and waits for that message to be processed. So
|
|
|
|
// this effectively blocks on the render backend and renderer threads,
|
|
|
|
// following the same codepath that WebRender takes to render and composite
|
|
|
|
// a frame.
|
2019-03-22 21:28:42 +03:00
|
|
|
Api(wr::RenderRoot::Default)->WaitFlushed();
|
2018-05-28 18:29:52 +03:00
|
|
|
}
|
|
|
|
|
2017-09-04 14:59:26 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvGetSnapshot(
|
|
|
|
PTextureParent* aTexture) {
|
2016-11-28 04:21:33 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2017-04-05 17:12:11 +03:00
|
|
|
MOZ_ASSERT(!mPaused);
|
2016-11-28 05:39:42 +03:00
|
|
|
|
2018-04-18 23:44:03 +03:00
|
|
|
// This function should only get called in the root WRBP. If this function
|
|
|
|
// gets called in a non-root WRBP, we will set mForceRendering in this WRBP
|
|
|
|
// but it will have no effect because CompositeToTarget (which reads the
|
|
|
|
// flag) only gets invoked in the root WRBP. So we assert that this is the
|
|
|
|
// root WRBP (i.e. has a non-null mWidget) to catch violations of this rule.
|
2018-06-26 21:37:31 +03:00
|
|
|
MOZ_ASSERT(IsRootWebRenderBridgeParent());
|
2018-04-18 23:44:03 +03:00
|
|
|
|
2016-11-28 05:39:42 +03:00
|
|
|
RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
|
|
|
|
if (!texture) {
|
|
|
|
// We kill the content process rather than have it continue with an invalid
|
|
|
|
// snapshot, that may be too harsh and we could decide to return some sort
|
|
|
|
// of error to the child process and let it deal with it...
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX Add other TextureHost supports.
|
|
|
|
// Only BufferTextureHost is supported now.
|
|
|
|
BufferTextureHost* bufferTexture = texture->AsBufferTextureHost();
|
|
|
|
if (!bufferTexture) {
|
|
|
|
// We kill the content process rather than have it continue with an invalid
|
|
|
|
// snapshot, that may be too harsh and we could decide to return some sort
|
|
|
|
// of error to the child process and let it deal with it...
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
2018-06-26 00:37:35 +03:00
|
|
|
TimeStamp start = TimeStamp::Now();
|
2016-11-28 05:39:42 +03:00
|
|
|
MOZ_ASSERT(bufferTexture->GetBufferDescriptor().type() ==
|
|
|
|
BufferDescriptor::TRGBDescriptor);
|
2016-12-04 11:53:28 +03:00
|
|
|
DebugOnly<uint32_t> stride = ImageDataSerializer::GetRGBStride(
|
|
|
|
bufferTexture->GetBufferDescriptor().get_RGBDescriptor());
|
2016-12-02 21:39:40 +03:00
|
|
|
uint8_t* buffer = bufferTexture->GetBuffer();
|
|
|
|
IntSize size = bufferTexture->GetSize();
|
2016-11-28 05:39:42 +03:00
|
|
|
|
2016-12-02 21:39:40 +03:00
|
|
|
// We only support B8G8R8A8 for now.
|
|
|
|
MOZ_ASSERT(buffer);
|
|
|
|
MOZ_ASSERT(bufferTexture->GetFormat() == SurfaceFormat::B8G8R8A8);
|
|
|
|
uint32_t buffer_size = size.width * size.height * 4;
|
2016-11-19 03:10:53 +03:00
|
|
|
|
2016-12-10 12:30:49 +03:00
|
|
|
// Assert the stride of the buffer is what webrender expects
|
2016-12-02 21:39:40 +03:00
|
|
|
MOZ_ASSERT((uint32_t)(size.width * 4) == stride);
|
2016-11-19 03:10:53 +03:00
|
|
|
|
2018-05-24 23:16:00 +03:00
|
|
|
FlushSceneBuilds();
|
|
|
|
FlushFrameGeneration();
|
2019-03-22 21:28:42 +03:00
|
|
|
Api(wr::RenderRoot::Default)
|
|
|
|
->Readback(start, size, Range<uint8_t>(buffer, buffer_size));
|
2016-11-19 03:10:53 +03:00
|
|
|
|
2016-11-18 16:56:47 +03:00
|
|
|
return IPC_OK();
|
2016-11-16 16:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-04-12 16:13:06 +03:00
|
|
|
void WebRenderBridgeParent::AddPipelineIdForCompositable(
|
|
|
|
const wr::PipelineId& aPipelineId, const CompositableHandle& aHandle,
|
2018-09-26 05:45:30 +03:00
|
|
|
const bool& aAsync, wr::TransactionBuilder& aTxn,
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::TransactionBuilder& aTxnForImageBridge,
|
|
|
|
const wr::RenderRoot& aRenderRoot) {
|
2016-11-28 04:21:33 +03:00
|
|
|
if (mDestroyed) {
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2016-11-28 04:21:33 +03:00
|
|
|
}
|
2017-01-19 02:46:21 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
auto& asyncCompositables = mAsyncCompositables[aRenderRoot];
|
|
|
|
|
|
|
|
MOZ_ASSERT(asyncCompositables.find(wr::AsUint64(aPipelineId)) ==
|
|
|
|
asyncCompositables.end());
|
2016-11-24 09:48:01 +03:00
|
|
|
|
2017-08-03 08:55:13 +03:00
|
|
|
RefPtr<CompositableHost> host;
|
|
|
|
if (aAsync) {
|
|
|
|
RefPtr<ImageBridgeParent> imageBridge =
|
|
|
|
ImageBridgeParent::GetInstance(OtherPid());
|
|
|
|
if (!imageBridge) {
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2017-08-03 08:55:13 +03:00
|
|
|
}
|
|
|
|
host = imageBridge->FindCompositable(aHandle);
|
|
|
|
} else {
|
|
|
|
host = FindCompositable(aHandle);
|
2017-01-05 18:03:17 +03:00
|
|
|
}
|
|
|
|
if (!host) {
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2016-11-24 09:48:01 +03:00
|
|
|
}
|
2017-11-03 10:38:34 +03:00
|
|
|
|
2017-04-27 19:34:54 +03:00
|
|
|
WebRenderImageHost* wrHost = host->AsWebRenderImageHost();
|
2017-11-03 10:38:34 +03:00
|
|
|
MOZ_ASSERT(wrHost);
|
|
|
|
if (!wrHost) {
|
|
|
|
gfxCriticalNote
|
|
|
|
<< "Incompatible CompositableHost at WebRenderBridgeParent.";
|
|
|
|
}
|
|
|
|
|
2017-04-27 19:34:54 +03:00
|
|
|
if (!wrHost) {
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2016-11-24 09:48:01 +03:00
|
|
|
}
|
|
|
|
|
2017-05-16 08:18:54 +03:00
|
|
|
wrHost->SetWrBridge(this);
|
2019-03-22 21:28:42 +03:00
|
|
|
asyncCompositables.emplace(wr::AsUint64(aPipelineId), wrHost);
|
|
|
|
mAsyncImageManager->AddAsyncImagePipeline(aPipelineId, wrHost,
|
|
|
|
RenderRootForExternal(aRenderRoot));
|
2017-02-10 18:16:47 +03:00
|
|
|
|
2018-07-19 01:51:37 +03:00
|
|
|
// If this is being called from WebRenderBridgeParent::RecvSetDisplayList,
|
|
|
|
// then aTxn might contain a display list that references pipelines that
|
|
|
|
// we just added to the async image manager.
|
|
|
|
// If we send the display list alone then WR will not yet have the content for
|
|
|
|
// the pipelines and so it will emit errors; the SetEmptyDisplayList call
|
|
|
|
// below ensure that we provide its content to WR as part of the same
|
|
|
|
// transaction.
|
2018-09-26 05:45:30 +03:00
|
|
|
mAsyncImageManager->SetEmptyDisplayList(aPipelineId, aTxn,
|
|
|
|
aTxnForImageBridge);
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2016-12-08 04:52:24 +03:00
|
|
|
}
|
|
|
|
|
2018-04-30 16:35:41 +03:00
|
|
|
void WebRenderBridgeParent::RemovePipelineIdForCompositable(
|
2019-03-22 21:28:42 +03:00
|
|
|
const wr::PipelineId& aPipelineId, wr::TransactionBuilder& aTxn,
|
|
|
|
wr::RenderRoot aRenderRoot) {
|
2017-06-02 10:11:34 +03:00
|
|
|
if (mDestroyed) {
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
auto& asyncCompositables = mAsyncCompositables[aRenderRoot];
|
|
|
|
|
|
|
|
auto it = asyncCompositables.find(wr::AsUint64(aPipelineId));
|
|
|
|
if (it == asyncCompositables.end()) {
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
2018-07-10 05:06:08 +03:00
|
|
|
RefPtr<WebRenderImageHost>& wrHost = it->second;
|
2017-06-30 04:06:11 +03:00
|
|
|
|
2019-02-23 02:59:53 +03:00
|
|
|
wrHost->ClearWrBridge(this);
|
2018-04-30 16:35:41 +03:00
|
|
|
mAsyncImageManager->RemoveAsyncImagePipeline(aPipelineId, aTxn);
|
|
|
|
aTxn.RemovePipeline(aPipelineId);
|
2019-03-22 21:28:42 +03:00
|
|
|
asyncCompositables.erase(wr::AsUint64(aPipelineId));
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
|
|
|
|
2018-10-02 20:27:52 +03:00
|
|
|
void WebRenderBridgeParent::DeleteImage(const ImageKey& aKey,
|
|
|
|
wr::TransactionBuilder& aUpdates) {
|
2016-12-08 04:52:24 +03:00
|
|
|
if (mDestroyed) {
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2016-12-08 04:52:24 +03:00
|
|
|
}
|
2017-11-03 10:38:34 +03:00
|
|
|
|
2018-10-02 20:27:52 +03:00
|
|
|
auto it = mSharedSurfaceIds.find(wr::AsUint64(aKey));
|
|
|
|
if (it != mSharedSurfaceIds.end()) {
|
|
|
|
mAsyncImageManager->HoldExternalImage(mPipelineId, mWrEpoch, it->second);
|
|
|
|
mSharedSurfaceIds.erase(it);
|
2016-12-08 04:52:24 +03:00
|
|
|
}
|
2018-10-02 20:27:52 +03:00
|
|
|
|
|
|
|
aUpdates.DeleteImage(aKey);
|
2016-11-24 09:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-07-06 15:25:33 +03:00
|
|
|
void WebRenderBridgeParent::ReleaseTextureOfImage(const wr::ImageKey& aKey) {
|
2016-11-28 04:21:33 +03:00
|
|
|
if (mDestroyed) {
|
2018-04-12 16:13:06 +03:00
|
|
|
return;
|
2016-11-28 04:21:33 +03:00
|
|
|
}
|
2017-10-30 20:10:29 +03:00
|
|
|
|
2018-07-06 15:25:33 +03:00
|
|
|
uint64_t id = wr::AsUint64(aKey);
|
|
|
|
CompositableTextureHostRef texture;
|
|
|
|
WebRenderTextureHost* wrTexture = nullptr;
|
2018-04-23 14:57:15 +03:00
|
|
|
|
2018-07-10 05:06:08 +03:00
|
|
|
auto it = mTextureHosts.find(id);
|
|
|
|
if (it != mTextureHosts.end()) {
|
|
|
|
wrTexture = (*it).second->AsWebRenderTextureHost();
|
2017-04-27 19:34:54 +03:00
|
|
|
}
|
2018-07-06 15:25:33 +03:00
|
|
|
if (wrTexture) {
|
|
|
|
mAsyncImageManager->HoldExternalImage(mPipelineId, mWrEpoch, wrTexture);
|
|
|
|
}
|
2018-07-10 05:06:08 +03:00
|
|
|
mTextureHosts.erase(id);
|
2016-11-24 09:48:01 +03:00
|
|
|
}
|
|
|
|
|
2018-07-30 16:24:50 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetLayersObserverEpoch(
|
|
|
|
const LayersObserverEpoch& aChildEpoch) {
|
2017-06-05 09:41:21 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2018-07-30 16:24:50 +03:00
|
|
|
mChildLayersObserverEpoch = aChildEpoch;
|
2016-11-30 05:59:14 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvClearCachedResources() {
|
2017-06-05 09:41:21 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2017-07-11 03:13:15 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto renderRoot : wr::kRenderRoots) {
|
|
|
|
if (renderRoot == wr::RenderRoot::Default ||
|
|
|
|
(IsRootWebRenderBridgeParent() &&
|
|
|
|
gfxPrefs::WebRenderSplitRenderRoots())) {
|
|
|
|
// Clear resources
|
|
|
|
wr::TransactionBuilder txn;
|
|
|
|
txn.SetLowPriority(true);
|
|
|
|
txn.ClearDisplayList(GetNextWrEpoch(), mPipelineId);
|
|
|
|
txn.Notify(wr::Checkpoint::SceneBuilt,
|
|
|
|
MakeUnique<ScheduleObserveLayersUpdate>(
|
|
|
|
mCompositorBridge, GetLayersId(),
|
|
|
|
mChildLayersObserverEpoch, false));
|
|
|
|
|
|
|
|
Api(renderRoot)->SendTransaction(txn);
|
|
|
|
}
|
|
|
|
}
|
2017-11-30 15:38:47 +03:00
|
|
|
// Schedule generate frame to clean up Pipeline
|
2019-03-22 21:28:42 +03:00
|
|
|
|
|
|
|
ScheduleGenerateFrameAllRenderRoots();
|
|
|
|
|
2017-07-11 03:13:15 +03:00
|
|
|
// Remove animations.
|
2018-07-07 03:30:50 +03:00
|
|
|
for (const auto& id : mActiveAnimations) {
|
2019-01-28 23:11:59 +03:00
|
|
|
mAnimStorage->ClearById(id.first);
|
2017-07-11 03:13:15 +03:00
|
|
|
}
|
|
|
|
mActiveAnimations.clear();
|
2018-04-27 17:32:31 +03:00
|
|
|
std::queue<CompositorAnimationIdsForEpoch>().swap(
|
|
|
|
mCompositorAnimationsToDelete); // clear queue
|
2016-11-30 05:59:14 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-06-30 04:06:11 +03:00
|
|
|
wr::Epoch WebRenderBridgeParent::UpdateWebRender(
|
2019-03-22 21:28:42 +03:00
|
|
|
CompositorVsyncScheduler* aScheduler,
|
|
|
|
nsTArray<RefPtr<wr::WebRenderAPI>>&& aApis,
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager* aImageMgr,
|
2018-07-03 02:43:17 +03:00
|
|
|
CompositorAnimationStorage* aAnimStorage,
|
|
|
|
const TextureFactoryIdentifier& aTextureFactoryIdentifier) {
|
2018-06-26 21:37:31 +03:00
|
|
|
MOZ_ASSERT(!IsRootWebRenderBridgeParent());
|
2017-06-30 04:06:11 +03:00
|
|
|
MOZ_ASSERT(aScheduler);
|
2019-03-22 21:28:42 +03:00
|
|
|
MOZ_ASSERT(!aApis.IsEmpty());
|
2017-07-25 11:54:36 +03:00
|
|
|
MOZ_ASSERT(aImageMgr);
|
2017-06-30 04:06:11 +03:00
|
|
|
MOZ_ASSERT(aAnimStorage);
|
|
|
|
|
|
|
|
if (mDestroyed) {
|
2018-07-27 16:42:30 +03:00
|
|
|
return mWrEpoch;
|
2017-06-30 04:06:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update id name space to identify obsoleted keys.
|
|
|
|
// Since usage of invalid keys could cause crash in webrender.
|
2019-03-22 21:28:42 +03:00
|
|
|
mIdNamespace = aApis[0]->GetNamespace();
|
2017-06-30 04:06:11 +03:00
|
|
|
// XXX Remove it when webrender supports sharing/moving Keys between different
|
|
|
|
// webrender instances.
|
|
|
|
// XXX It requests client to update/reallocate webrender related resources,
|
|
|
|
// but parent side does not wait end of the update.
|
|
|
|
// The code could become simpler if we could serialise old keys deallocation
|
|
|
|
// and new keys allocation. But we do not do it, it is because client side
|
|
|
|
// deallocate old layers/webrender keys after new layers/webrender keys
|
|
|
|
// allocation. Without client side's layout refactoring, we could not finish
|
|
|
|
// all old layers/webrender keys removals before new layer/webrender keys
|
|
|
|
// allocation. In future, we could address the problem.
|
2018-07-03 02:43:17 +03:00
|
|
|
Unused << SendWrUpdated(mIdNamespace, aTextureFactoryIdentifier);
|
2017-06-30 04:06:11 +03:00
|
|
|
CompositorBridgeParentBase* cBridge = mCompositorBridge;
|
|
|
|
// XXX Stop to clear resources if webreder supports resources sharing between
|
|
|
|
// different webrender instances.
|
|
|
|
ClearResources();
|
|
|
|
mCompositorBridge = cBridge;
|
|
|
|
mCompositorScheduler = aScheduler;
|
2019-04-05 18:42:50 +03:00
|
|
|
for (auto& api : aApis) {
|
|
|
|
mApis[api->GetRenderRoot()] = api;
|
|
|
|
}
|
2017-07-25 11:54:36 +03:00
|
|
|
mAsyncImageManager = aImageMgr;
|
2017-06-30 04:06:11 +03:00
|
|
|
mAnimStorage = aAnimStorage;
|
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
// Register pipeline to updated AsyncImageManager.
|
2018-11-19 06:15:55 +03:00
|
|
|
mAsyncImageManager->AddPipeline(mPipelineId, this);
|
2018-07-27 16:42:30 +03:00
|
|
|
|
|
|
|
return GetNextWrEpoch(); // Update webrender epoch
|
2017-06-30 04:06:11 +03:00
|
|
|
}
|
|
|
|
|
2018-02-02 16:57:35 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvScheduleComposite() {
|
2019-03-22 21:28:42 +03:00
|
|
|
ScheduleGenerateFrameAllRenderRoots();
|
2018-10-15 14:28:01 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebRenderBridgeParent::ScheduleForcedGenerateFrame() {
|
2017-04-10 09:58:29 +03:00
|
|
|
if (mDestroyed) {
|
2018-10-15 14:28:01 +03:00
|
|
|
return;
|
2017-04-10 09:58:29 +03:00
|
|
|
}
|
2018-10-10 06:20:23 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto renderRoot : wr::kRenderRoots) {
|
|
|
|
if (renderRoot == wr::RenderRoot::Default ||
|
|
|
|
(IsRootWebRenderBridgeParent() &&
|
|
|
|
gfxPrefs::WebRenderSplitRenderRoots())) {
|
|
|
|
wr::TransactionBuilder fastTxn(/* aUseSceneBuilderThread */ false);
|
|
|
|
fastTxn.InvalidateRenderedFrame();
|
|
|
|
Api(renderRoot)->SendTransaction(fastTxn);
|
|
|
|
}
|
|
|
|
}
|
2018-10-10 06:20:23 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
ScheduleGenerateFrameAllRenderRoots();
|
2017-04-10 09:58:29 +03:00
|
|
|
}
|
|
|
|
|
2018-01-26 18:09:30 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvCapture() {
|
|
|
|
if (!mDestroyed) {
|
2019-03-22 21:28:42 +03:00
|
|
|
Api(wr::RenderRoot::Default)->Capture();
|
2018-01-26 18:09:30 +03:00
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2018-05-28 18:29:52 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSyncWithCompositor() {
|
|
|
|
FlushSceneBuilds();
|
|
|
|
if (RefPtr<WebRenderBridgeParent> root = GetRootWebRenderBridgeParent()) {
|
|
|
|
root->FlushFrameGeneration();
|
|
|
|
}
|
|
|
|
FlushFramePresentation();
|
|
|
|
// Finally, we force the AsyncImagePipelineManager to handle all the
|
|
|
|
// pipeline updates produced in the last step, so that it frees any
|
|
|
|
// unneeded textures. Then we can return from this sync IPC call knowing
|
|
|
|
// that we've done everything we can to flush stuff on the compositor.
|
|
|
|
mAsyncImageManager->ProcessPipelineUpdates();
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-05-28 14:51:51 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetConfirmedTargetAPZC(
|
2019-03-22 21:28:42 +03:00
|
|
|
const uint64_t& aBlockId, nsTArray<SLGuidAndRenderRoot>&& aTargets) {
|
2019-03-08 23:00:37 +03:00
|
|
|
for (size_t i = 0; i < aTargets.Length(); i++) {
|
2019-03-22 21:28:42 +03:00
|
|
|
// Guard against bad data from hijacked child processes
|
|
|
|
if (aTargets[i].mRenderRoot > wr::kHighestRenderRoot ||
|
|
|
|
(!gfxPrefs::WebRenderSplitRenderRoots() &&
|
|
|
|
aTargets[i].mRenderRoot != wr::RenderRoot::Default)) {
|
|
|
|
NS_ERROR(
|
|
|
|
"Unexpected render root in RecvSetConfirmedTargetAPZC; dropping "
|
|
|
|
"message...");
|
|
|
|
return IPC_FAIL(this, "Bad render root");
|
|
|
|
}
|
|
|
|
if (aTargets[i].mScrollableLayerGuid.mLayersId != GetLayersId()) {
|
2019-03-08 23:00:37 +03:00
|
|
|
NS_ERROR(
|
|
|
|
"Unexpected layers id in RecvSetConfirmedTargetAPZC; dropping "
|
|
|
|
"message...");
|
|
|
|
return IPC_FAIL(this, "Bad layers id");
|
|
|
|
}
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
|
2017-06-05 09:41:21 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2017-05-28 14:51:53 +03:00
|
|
|
mCompositorBridge->SetConfirmedTargetAPZC(GetLayersId(), aBlockId, aTargets);
|
2017-05-28 14:51:51 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-06-28 03:29:06 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetTestSampleTime(
|
|
|
|
const TimeStamp& aTime) {
|
|
|
|
if (!mCompositorBridge->SetTestSampleTime(GetLayersId(), aTime)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvLeaveTestMode() {
|
|
|
|
mCompositorBridge->LeaveTestMode(GetLayersId());
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2018-07-31 00:13:15 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvGetAnimationValue(
|
|
|
|
const uint64_t& aCompositorAnimationsId, OMTAValue* aValue) {
|
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(mAnimStorage);
|
|
|
|
if (RefPtr<WebRenderBridgeParent> root = GetRootWebRenderBridgeParent()) {
|
|
|
|
root->AdvanceAnimations();
|
|
|
|
} else {
|
|
|
|
AdvanceAnimations();
|
|
|
|
}
|
|
|
|
|
|
|
|
*aValue = mAnimStorage->GetOMTAValue(aCompositorAnimationsId);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetAsyncScrollOffset(
|
|
|
|
const ScrollableLayerGuid::ViewID& aScrollId, const float& aX,
|
2017-05-28 14:48:36 +03:00
|
|
|
const float& aY) {
|
2017-06-05 09:41:21 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
mCompositorBridge->SetTestAsyncScrollOffset(
|
|
|
|
WRRootId(GetLayersId(), mRenderRoot), aScrollId, CSSPoint(aX, aY));
|
2017-05-28 14:48:36 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetAsyncZoom(
|
|
|
|
const ScrollableLayerGuid::ViewID& aScrollId, const float& aZoom) {
|
2017-06-05 09:41:21 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
mCompositorBridge->SetTestAsyncZoom(WRRootId(GetLayersId(), mRenderRoot),
|
|
|
|
aScrollId,
|
2018-03-06 18:25:37 +03:00
|
|
|
LayerToParentLayerScale(aZoom));
|
2017-05-28 14:48:36 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvFlushApzRepaints() {
|
2017-06-05 09:41:21 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
mCompositorBridge->FlushApzRepaints(WRRootId(GetLayersId(), mRenderRoot));
|
2017-05-28 14:48:36 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-06-05 05:29:35 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvGetAPZTestData(
|
|
|
|
APZTestData* aOutData) {
|
2019-03-22 21:28:42 +03:00
|
|
|
mCompositorBridge->GetAPZTestData(WRRootId(GetLayersId(), mRenderRoot),
|
|
|
|
aOutData);
|
2017-06-05 05:29:35 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2016-11-22 17:22:54 +03:00
|
|
|
void WebRenderBridgeParent::ActorDestroy(ActorDestroyReason aWhy) { Destroy(); }
|
|
|
|
|
2017-06-28 03:29:05 +03:00
|
|
|
bool WebRenderBridgeParent::AdvanceAnimations() {
|
|
|
|
if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) {
|
2018-04-23 00:27:19 +03:00
|
|
|
Maybe<TimeStamp> testingTimeStamp = cbp->GetTestingTimeStamp();
|
|
|
|
if (testingTimeStamp) {
|
|
|
|
// If we are on testing refresh mode, use the testing time stamp. And
|
|
|
|
// also we don't update mPreviousFrameTimeStamp since unlike normal
|
|
|
|
// refresh mode, on the testing mode animations on the compositor are
|
|
|
|
// synchronously composed, so we don't need to worry about the time gap
|
|
|
|
// between the main thread and compositor thread.
|
2018-05-08 09:48:27 +03:00
|
|
|
return AnimationHelper::SampleAnimations(mAnimStorage, *testingTimeStamp,
|
|
|
|
*testingTimeStamp);
|
2018-04-23 00:27:19 +03:00
|
|
|
}
|
2017-06-28 03:29:05 +03:00
|
|
|
}
|
2017-06-29 23:44:00 +03:00
|
|
|
|
2018-04-23 00:27:19 +03:00
|
|
|
TimeStamp lastComposeTime = mCompositorScheduler->GetLastComposeTime();
|
2018-05-08 09:48:27 +03:00
|
|
|
const bool isAnimating = AnimationHelper::SampleAnimations(
|
|
|
|
mAnimStorage, mPreviousFrameTimeStamp, lastComposeTime);
|
2017-06-29 23:44:00 +03:00
|
|
|
|
|
|
|
// Reset the previous time stamp if we don't already have any running
|
|
|
|
// animations to avoid using the time which is far behind for newly
|
|
|
|
// started animations.
|
2018-05-08 09:58:54 +03:00
|
|
|
mPreviousFrameTimeStamp = isAnimating ? lastComposeTime : TimeStamp();
|
2018-05-08 09:48:27 +03:00
|
|
|
|
|
|
|
return isAnimating;
|
2017-06-28 03:29:05 +03:00
|
|
|
}
|
|
|
|
|
2017-06-28 02:20:36 +03:00
|
|
|
bool WebRenderBridgeParent::SampleAnimations(
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::RenderRootArray<nsTArray<wr::WrOpacityProperty>>& aOpacityArrays,
|
|
|
|
wr::RenderRootArray<nsTArray<wr::WrTransformProperty>>& aTransformArrays) {
|
2018-05-08 09:48:27 +03:00
|
|
|
const bool isAnimating = AdvanceAnimations();
|
2017-04-12 11:40:48 +03:00
|
|
|
|
|
|
|
// return the animated data if has
|
2017-06-15 10:36:03 +03:00
|
|
|
if (mAnimStorage->AnimatedValueCount()) {
|
|
|
|
for (auto iter = mAnimStorage->ConstAnimatedValueTableIter(); !iter.Done();
|
2017-04-12 11:40:48 +03:00
|
|
|
iter.Next()) {
|
|
|
|
AnimatedValue* value = iter.UserData();
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::RenderRoot renderRoot = mAnimStorage->AnimationRenderRoot(iter.Key());
|
|
|
|
auto& transformArray = aTransformArrays[renderRoot];
|
|
|
|
auto& opacityArray = aOpacityArrays[renderRoot];
|
2019-04-11 15:37:06 +03:00
|
|
|
if (value->Is<AnimationTransform>()) {
|
2019-03-22 21:28:42 +03:00
|
|
|
transformArray.AppendElement(wr::ToWrTransformProperty(
|
2019-04-11 15:37:06 +03:00
|
|
|
iter.Key(), value->Transform().mTransformInDevSpace));
|
|
|
|
} else if (value->Is<float>()) {
|
2019-03-22 21:28:42 +03:00
|
|
|
opacityArray.AppendElement(
|
2019-04-11 15:37:06 +03:00
|
|
|
wr::ToWrOpacityProperty(iter.Key(), value->Opacity()));
|
2017-04-12 11:40:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-08 09:48:27 +03:00
|
|
|
|
|
|
|
return isAnimating;
|
2017-04-12 11:40:48 +03:00
|
|
|
}
|
|
|
|
|
2018-11-29 21:30:06 +03:00
|
|
|
void WebRenderBridgeParent::CompositeIfNeeded() {
|
|
|
|
if (mSkippedComposite) {
|
|
|
|
mSkippedComposite = false;
|
2018-12-20 22:33:21 +03:00
|
|
|
CompositeToTarget(mSkippedCompositeId, nullptr, nullptr);
|
2018-11-29 21:30:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 02:28:03 +03:00
|
|
|
void WebRenderBridgeParent::CompositeToTarget(VsyncId aId,
|
|
|
|
gfx::DrawTarget* aTarget,
|
2016-11-22 05:56:38 +03:00
|
|
|
const gfx::IntRect* aRect) {
|
2018-04-18 23:44:03 +03:00
|
|
|
// This function should only get called in the root WRBP
|
2018-06-26 21:37:31 +03:00
|
|
|
MOZ_ASSERT(IsRootWebRenderBridgeParent());
|
2018-04-18 23:44:03 +03:00
|
|
|
|
2018-02-02 18:48:25 +03:00
|
|
|
// The two arguments are part of the CompositorVsyncSchedulerOwner API but in
|
|
|
|
// this implementation they should never be non-null.
|
|
|
|
MOZ_ASSERT(aTarget == nullptr);
|
|
|
|
MOZ_ASSERT(aRect == nullptr);
|
|
|
|
|
2019-01-18 18:40:15 +03:00
|
|
|
AUTO_PROFILER_TRACING("Paint", "CompositeToTarget", GRAPHICS);
|
2018-03-06 22:20:56 +03:00
|
|
|
if (mPaused || !mReceivedDisplayList) {
|
2018-05-03 09:57:19 +03:00
|
|
|
mPreviousFrameTimeStamp = TimeStamp();
|
2017-04-05 17:12:11 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-04-12 11:40:48 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
if (mSkippedComposite || wr::RenderThread::Get()->TooManyPendingFrames(
|
|
|
|
Api(wr::RenderRoot::Default)->GetId())) {
|
2017-05-19 03:21:38 +03:00
|
|
|
// Render thread is busy, try next time.
|
2019-01-25 08:09:46 +03:00
|
|
|
mSkippedComposite = true;
|
|
|
|
mSkippedCompositeId = aId;
|
2018-05-03 09:57:19 +03:00
|
|
|
mPreviousFrameTimeStamp = TimeStamp();
|
2018-11-16 05:13:56 +03:00
|
|
|
|
|
|
|
// Record that we skipped presenting a frame for
|
|
|
|
// all pending transactions that have finished scene building.
|
|
|
|
for (auto& id : mPendingTransactionIds) {
|
|
|
|
if (id.mSceneBuiltTime) {
|
|
|
|
id.mSkippedComposites++;
|
|
|
|
}
|
|
|
|
}
|
2017-05-19 03:21:38 +03:00
|
|
|
return;
|
|
|
|
}
|
2018-12-08 02:28:41 +03:00
|
|
|
MaybeGenerateFrame(aId, /* aForceGenerateFrame */ false);
|
2018-08-10 02:10:11 +03:00
|
|
|
}
|
2017-05-19 03:21:38 +03:00
|
|
|
|
2018-10-16 03:33:51 +03:00
|
|
|
TimeDuration WebRenderBridgeParent::GetVsyncInterval() const {
|
|
|
|
// This function should only get called in the root WRBP
|
|
|
|
MOZ_ASSERT(IsRootWebRenderBridgeParent());
|
|
|
|
if (CompositorBridgeParent* cbp = GetRootCompositorBridgeParent()) {
|
|
|
|
return cbp->GetVsyncInterval();
|
|
|
|
}
|
|
|
|
return TimeDuration();
|
|
|
|
}
|
|
|
|
|
2018-12-08 02:28:41 +03:00
|
|
|
void WebRenderBridgeParent::MaybeGenerateFrame(VsyncId aId,
|
|
|
|
bool aForceGenerateFrame) {
|
2018-09-20 11:47:05 +03:00
|
|
|
// This function should only get called in the root WRBP
|
|
|
|
MOZ_ASSERT(IsRootWebRenderBridgeParent());
|
|
|
|
|
2018-06-25 17:55:26 +03:00
|
|
|
TimeStamp start = TimeStamp::Now();
|
|
|
|
mAsyncImageManager->SetCompositionTime(start);
|
2018-05-08 15:47:02 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::RenderRootArray<Maybe<wr::TransactionBuilder>> fastTxns;
|
2018-08-07 13:12:06 +03:00
|
|
|
// Handle transaction that is related to DisplayList.
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::RenderRootArray<Maybe<wr::TransactionBuilder>> sceneBuilderTxns;
|
|
|
|
wr::RenderRootArray<Maybe<wr::AutoTransactionSender>> senders;
|
|
|
|
for (auto& api : mApis) {
|
2019-04-05 18:42:50 +03:00
|
|
|
if (!api) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
auto renderRoot = api->GetRenderRoot();
|
|
|
|
// Ensure GenerateFrame is handled on the render backend thread rather
|
|
|
|
// than going through the scene builder thread. That way we continue
|
|
|
|
// generating frames with the old scene even during slow scene builds.
|
|
|
|
fastTxns[renderRoot].emplace(false /* useSceneBuilderThread */);
|
|
|
|
sceneBuilderTxns[renderRoot].emplace();
|
|
|
|
senders[renderRoot].emplace(api, sceneBuilderTxns[renderRoot].ptr());
|
|
|
|
}
|
2018-08-07 13:12:06 +03:00
|
|
|
|
|
|
|
// Adding and updating wr::ImageKeys of ImageHosts that uses ImageBridge are
|
|
|
|
// done without using transaction of scene builder thread. With it, updating
|
|
|
|
// of video frame becomes faster.
|
2019-03-22 21:28:42 +03:00
|
|
|
mAsyncImageManager->ApplyAsyncImagesOfImageBridge(sceneBuilderTxns, fastTxns);
|
2017-06-02 10:11:34 +03:00
|
|
|
|
2017-11-30 15:38:47 +03:00
|
|
|
if (!mAsyncImageManager->GetCompositeUntilTime().IsNull()) {
|
|
|
|
// Trigger another CompositeToTarget() call because there might be another
|
|
|
|
// frame that we want to generate after this one.
|
|
|
|
// It will check if we actually want to generate the frame or not.
|
|
|
|
mCompositorScheduler->ScheduleComposition();
|
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
uint8_t framesGenerated = 0;
|
|
|
|
wr::RenderRootArray<bool> generateFrame;
|
|
|
|
for (auto& api : mApis) {
|
2019-04-05 18:42:50 +03:00
|
|
|
if (!api) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
auto renderRoot = api->GetRenderRoot();
|
|
|
|
generateFrame[renderRoot] =
|
|
|
|
mAsyncImageManager->GetAndResetWillGenerateFrame(renderRoot) ||
|
|
|
|
!fastTxns[renderRoot]->IsEmpty() || aForceGenerateFrame;
|
|
|
|
if (generateFrame[renderRoot]) {
|
|
|
|
framesGenerated++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (framesGenerated == 0) {
|
2017-11-30 15:38:47 +03:00
|
|
|
// Could skip generating frame now.
|
2018-05-03 09:57:19 +03:00
|
|
|
mPreviousFrameTimeStamp = TimeStamp();
|
2017-11-30 15:38:47 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::RenderRootArray<nsTArray<wr::WrOpacityProperty>> opacityArrays;
|
|
|
|
wr::RenderRootArray<nsTArray<wr::WrTransformProperty>> transformArrays;
|
2017-11-30 15:38:47 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
if (SampleAnimations(opacityArrays, transformArrays)) {
|
|
|
|
// TODO we should have a better way of assessing whether we need a content
|
|
|
|
// or a chrome frame generation.
|
|
|
|
ScheduleGenerateFrameAllRenderRoots();
|
2017-04-12 11:40:48 +03:00
|
|
|
}
|
2018-04-11 22:28:00 +03:00
|
|
|
// We do this even if the arrays are empty, because it will clear out any
|
2018-04-17 00:39:26 +03:00
|
|
|
// previous properties store on the WR side, which is desirable.
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto& api : mApis) {
|
2019-04-05 18:42:50 +03:00
|
|
|
if (!api) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
auto renderRoot = api->GetRenderRoot();
|
|
|
|
fastTxns[renderRoot]->UpdateDynamicProperties(opacityArrays[renderRoot],
|
|
|
|
transformArrays[renderRoot]);
|
|
|
|
}
|
2017-04-17 17:22:47 +03:00
|
|
|
|
2018-04-17 00:39:26 +03:00
|
|
|
SetAPZSampleTime();
|
2017-05-23 17:50:42 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::RenderThread::Get()->IncPendingFrameCount(
|
|
|
|
Api(wr::RenderRoot::Default)->GetId(), aId, start, framesGenerated);
|
2017-07-24 03:22:20 +03:00
|
|
|
|
2017-07-28 02:05:56 +03:00
|
|
|
#if defined(ENABLE_FRAME_LATENCY_LOG)
|
|
|
|
auto startTime = TimeStamp::Now();
|
2019-03-22 21:28:42 +03:00
|
|
|
Api(wr::RenderRoot::Default)->SetFrameStartTime(startTime);
|
2017-07-28 02:05:56 +03:00
|
|
|
#endif
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
MOZ_ASSERT(framesGenerated > 0);
|
2019-04-16 01:34:13 +03:00
|
|
|
wr::RenderRootArray<wr::TransactionBuilder*> generateFrameTxns;
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto& api : mApis) {
|
2019-04-05 18:42:50 +03:00
|
|
|
if (!api) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
auto renderRoot = api->GetRenderRoot();
|
|
|
|
if (generateFrame[renderRoot]) {
|
|
|
|
fastTxns[renderRoot]->GenerateFrame();
|
2019-04-16 01:34:13 +03:00
|
|
|
generateFrameTxns[renderRoot] = fastTxns[renderRoot].ptr();
|
2019-03-22 21:28:42 +03:00
|
|
|
}
|
|
|
|
}
|
2019-04-16 01:34:13 +03:00
|
|
|
wr::WebRenderAPI::SendTransactions(mApis, generateFrameTxns);
|
|
|
|
|
2018-12-21 01:43:01 +03:00
|
|
|
mMostRecentComposite = TimeStamp::Now();
|
2016-11-22 05:56:38 +03:00
|
|
|
}
|
|
|
|
|
2018-04-10 19:29:56 +03:00
|
|
|
void WebRenderBridgeParent::HoldPendingTransactionId(
|
2018-04-20 22:13:06 +03:00
|
|
|
const wr::Epoch& aWrEpoch, TransactionId aTransactionId,
|
2018-12-08 02:28:03 +03:00
|
|
|
bool aContainsSVGGroup, const VsyncId& aVsyncId,
|
2019-01-03 22:43:04 +03:00
|
|
|
const TimeStamp& aVsyncStartTime, const TimeStamp& aRefreshStartTime,
|
|
|
|
const TimeStamp& aTxnStartTime, const nsCString& aTxnURL,
|
|
|
|
const TimeStamp& aFwdTime, const bool aIsFirstPaint,
|
|
|
|
const bool aUseForTelemetry) {
|
2018-02-09 21:41:18 +03:00
|
|
|
MOZ_ASSERT(aTransactionId > LastPendingTransactionId());
|
2018-11-16 05:13:56 +03:00
|
|
|
mPendingTransactionIds.push_back(PendingTransactionId(
|
2019-01-03 22:43:04 +03:00
|
|
|
aWrEpoch, aTransactionId, aContainsSVGGroup, aVsyncId, aVsyncStartTime,
|
|
|
|
aRefreshStartTime, aTxnStartTime, aTxnURL, aFwdTime, aIsFirstPaint,
|
|
|
|
aUseForTelemetry));
|
2017-02-24 06:22:59 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
already_AddRefed<wr::WebRenderAPI>
|
2019-03-28 19:46:35 +03:00
|
|
|
WebRenderBridgeParent::GetWebRenderAPIAtPoint(const ScreenPoint& aPoint) {
|
2019-03-22 21:28:42 +03:00
|
|
|
MutexAutoLock lock(mRenderRootRectMutex);
|
|
|
|
for (auto renderRoot : wr::kNonDefaultRenderRoots) {
|
|
|
|
if (mRenderRootRects[renderRoot].Contains(aPoint)) {
|
|
|
|
return do_AddRef(Api(renderRoot));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return do_AddRef(Api(wr::RenderRoot::Default));
|
|
|
|
}
|
|
|
|
|
2017-02-24 06:22:59 +03:00
|
|
|
TransactionId WebRenderBridgeParent::LastPendingTransactionId() {
|
2018-04-20 22:13:06 +03:00
|
|
|
TransactionId id{0};
|
2017-02-24 06:22:59 +03:00
|
|
|
if (!mPendingTransactionIds.empty()) {
|
|
|
|
id = mPendingTransactionIds.back().mId;
|
|
|
|
}
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2018-11-16 05:13:56 +03:00
|
|
|
void WebRenderBridgeParent::NotifySceneBuiltForEpoch(
|
|
|
|
const wr::Epoch& aEpoch, const TimeStamp& aEndTime) {
|
|
|
|
for (auto& id : mPendingTransactionIds) {
|
|
|
|
if (id.mEpoch.mHandle == aEpoch.mHandle) {
|
|
|
|
id.mSceneBuiltTime = aEndTime;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-21 01:52:07 +03:00
|
|
|
void WebRenderBridgeParent::NotifyDidSceneBuild(
|
2019-04-16 01:34:13 +03:00
|
|
|
const nsTArray<wr::RenderRoot>& aRenderRoots,
|
|
|
|
RefPtr<wr::WebRenderPipelineInfo> aInfo) {
|
2018-12-21 01:52:07 +03:00
|
|
|
MOZ_ASSERT(IsRootWebRenderBridgeParent());
|
2018-12-21 01:43:01 +03:00
|
|
|
if (!mCompositorScheduler) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-16 01:34:13 +03:00
|
|
|
for (auto renderRoot : aRenderRoots) {
|
|
|
|
mAsyncImageManager->SetWillGenerateFrame(renderRoot);
|
|
|
|
}
|
2018-12-21 01:43:01 +03:00
|
|
|
|
|
|
|
// If the scheduler has a composite more recent than our last composite (which
|
|
|
|
// we missed), and we're within the threshold ms of the last vsync, then
|
|
|
|
// kick of a late composite.
|
|
|
|
TimeStamp lastVsync = mCompositorScheduler->GetLastVsyncTime();
|
2018-12-21 01:52:07 +03:00
|
|
|
VsyncId lastVsyncId = mCompositorScheduler->GetLastVsyncId();
|
|
|
|
if (lastVsyncId == VsyncId() || !mMostRecentComposite ||
|
|
|
|
mMostRecentComposite >= lastVsync ||
|
|
|
|
((TimeStamp::Now() - lastVsync).ToMilliseconds() >
|
2018-12-21 01:43:01 +03:00
|
|
|
gfxPrefs::WebRenderLateSceneBuildThreshold())) {
|
|
|
|
mCompositorScheduler->ScheduleComposition();
|
2018-12-21 01:52:07 +03:00
|
|
|
return;
|
2018-12-21 01:43:01 +03:00
|
|
|
}
|
2018-12-21 01:52:07 +03:00
|
|
|
|
|
|
|
// Look through all the pipelines contained within the built scene
|
|
|
|
// and check which vsync they initiated from.
|
|
|
|
auto info = aInfo->Raw();
|
|
|
|
for (uintptr_t i = 0; i < info.epochs.length; i++) {
|
|
|
|
auto epoch = info.epochs.data[i];
|
|
|
|
|
|
|
|
WebRenderBridgeParent* wrBridge = this;
|
|
|
|
if (!(epoch.pipeline_id == PipelineId())) {
|
|
|
|
wrBridge = mAsyncImageManager->GetWrBridge(epoch.pipeline_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wrBridge) {
|
|
|
|
VsyncId startId = wrBridge->GetVsyncIdForEpoch(epoch.epoch);
|
|
|
|
// If any of the pipelines started building on the current vsync (i.e
|
|
|
|
// we did all of display list building and scene building within the
|
|
|
|
// threshold), then don't do an early composite.
|
|
|
|
if (startId == lastVsyncId) {
|
|
|
|
mCompositorScheduler->ScheduleComposition();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CompositeToTarget(mCompositorScheduler->GetLastVsyncId(), nullptr, nullptr);
|
2018-12-21 01:43:01 +03:00
|
|
|
}
|
|
|
|
|
2018-11-16 05:13:56 +03:00
|
|
|
TransactionId WebRenderBridgeParent::FlushTransactionIdsForEpoch(
|
2018-12-08 02:28:41 +03:00
|
|
|
const wr::Epoch& aEpoch, const VsyncId& aCompositeStartId,
|
|
|
|
const TimeStamp& aCompositeStartTime, const TimeStamp& aRenderStartTime,
|
|
|
|
const TimeStamp& aEndTime, UiCompositorControllerParent* aUiController,
|
|
|
|
wr::RendererStats* aStats, nsTArray<FrameStats>* aOutputStats) {
|
2018-04-20 22:13:06 +03:00
|
|
|
TransactionId id{0};
|
2017-02-24 06:22:59 +03:00
|
|
|
while (!mPendingTransactionIds.empty()) {
|
2018-08-15 08:13:24 +03:00
|
|
|
const auto& transactionId = mPendingTransactionIds.front();
|
|
|
|
|
|
|
|
if (aEpoch.mHandle < transactionId.mEpoch.mHandle) {
|
2017-02-24 06:22:59 +03:00
|
|
|
break;
|
|
|
|
}
|
2018-06-26 21:43:14 +03:00
|
|
|
|
2018-08-15 08:13:49 +03:00
|
|
|
if (!IsRootWebRenderBridgeParent() && !mVsyncRate.IsZero() &&
|
|
|
|
transactionId.mUseForTelemetry) {
|
2019-01-07 06:14:28 +03:00
|
|
|
auto fullPaintTime =
|
|
|
|
transactionId.mSceneBuiltTime
|
|
|
|
? transactionId.mSceneBuiltTime - transactionId.mTxnStartTime
|
|
|
|
: TimeDuration::FromMilliseconds(0);
|
|
|
|
|
|
|
|
int32_t contentFrameTime = RecordContentFrameTime(
|
|
|
|
transactionId.mVsyncId, transactionId.mVsyncStartTime,
|
|
|
|
transactionId.mTxnStartTime, aCompositeStartId, aEndTime,
|
|
|
|
fullPaintTime, mVsyncRate, transactionId.mContainsSVGGroup, true,
|
|
|
|
aStats);
|
|
|
|
if (contentFrameTime > 200) {
|
2018-12-12 23:27:06 +03:00
|
|
|
aOutputStats->AppendElement(FrameStats(
|
|
|
|
transactionId.mId, aCompositeStartTime, aRenderStartTime, aEndTime,
|
2019-01-07 06:14:28 +03:00
|
|
|
contentFrameTime,
|
2018-12-12 23:27:06 +03:00
|
|
|
aStats ? (double(aStats->resource_upload_time) / 1000000.0) : 0.0,
|
|
|
|
aStats ? (double(aStats->gpu_cache_upload_time) / 1000000.0) : 0.0,
|
|
|
|
transactionId.mTxnStartTime, transactionId.mRefreshStartTime,
|
|
|
|
transactionId.mFwdTime, transactionId.mSceneBuiltTime,
|
|
|
|
transactionId.mSkippedComposites, transactionId.mTxnURL));
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::RenderThread::Get()->NotifySlowFrame(
|
|
|
|
Api(wr::RenderRoot::Default)->GetId());
|
2018-12-12 23:27:06 +03:00
|
|
|
}
|
2018-06-26 21:43:14 +03:00
|
|
|
}
|
|
|
|
|
2017-07-28 02:05:56 +03:00
|
|
|
#if defined(ENABLE_FRAME_LATENCY_LOG)
|
2018-08-15 08:13:24 +03:00
|
|
|
if (transactionId.mRefreshStartTime) {
|
|
|
|
int32_t latencyMs =
|
|
|
|
lround((aEndTime - transactionId.mRefreshStartTime).ToMilliseconds());
|
2017-08-11 04:57:21 +03:00
|
|
|
printf_stderr(
|
|
|
|
"From transaction start to end of generate frame latencyMs %d this "
|
|
|
|
"%p\n",
|
|
|
|
latencyMs, this);
|
|
|
|
}
|
2018-08-15 08:13:24 +03:00
|
|
|
if (transactionId.mFwdTime) {
|
|
|
|
int32_t latencyMs =
|
|
|
|
lround((aEndTime - transactionId.mFwdTime).ToMilliseconds());
|
2017-08-11 04:57:21 +03:00
|
|
|
printf_stderr(
|
|
|
|
"From forwarding transaction to end of generate frame latencyMs %d "
|
|
|
|
"this %p\n",
|
|
|
|
latencyMs, this);
|
2017-07-28 02:05:56 +03:00
|
|
|
}
|
|
|
|
#endif
|
2018-10-19 16:48:04 +03:00
|
|
|
|
|
|
|
if (aUiController && transactionId.mIsFirstPaint) {
|
|
|
|
aUiController->NotifyFirstPaint();
|
|
|
|
}
|
|
|
|
|
2018-08-15 08:13:24 +03:00
|
|
|
id = transactionId.mId;
|
2018-11-16 05:13:56 +03:00
|
|
|
mPendingTransactionIds.pop_front();
|
2017-02-24 06:22:59 +03:00
|
|
|
}
|
|
|
|
return id;
|
2017-01-06 21:10:15 +03:00
|
|
|
}
|
|
|
|
|
2017-05-28 14:51:53 +03:00
|
|
|
LayersId WebRenderBridgeParent::GetLayersId() const {
|
2018-03-25 02:06:01 +03:00
|
|
|
return wr::AsLayersId(mPipelineId);
|
2017-05-28 14:51:53 +03:00
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
void WebRenderBridgeParent::ScheduleGenerateFrameAllRenderRoots() {
|
|
|
|
if (mCompositorScheduler) {
|
|
|
|
mAsyncImageManager->SetWillGenerateFrameAllRenderRoots();
|
|
|
|
mCompositorScheduler->ScheduleComposition();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebRenderBridgeParent::ScheduleGenerateFrame(
|
|
|
|
const Maybe<wr::RenderRoot>& aRenderRoot) {
|
2019-03-22 06:15:14 +03:00
|
|
|
if (mCompositorScheduler) {
|
2019-03-22 21:28:42 +03:00
|
|
|
if (aRenderRoot.isSome()) {
|
|
|
|
mAsyncImageManager->SetWillGenerateFrame(*aRenderRoot);
|
|
|
|
}
|
2017-02-27 03:27:04 +03:00
|
|
|
mCompositorScheduler->ScheduleComposition();
|
|
|
|
}
|
2016-11-22 05:56:38 +03:00
|
|
|
}
|
|
|
|
|
2019-04-16 01:34:13 +03:00
|
|
|
void WebRenderBridgeParent::ScheduleGenerateFrame(
|
2019-04-17 18:12:10 +03:00
|
|
|
const wr::RenderRootSet& aRenderRoots) {
|
2019-04-16 01:34:13 +03:00
|
|
|
if (mCompositorScheduler) {
|
2019-04-17 18:12:10 +03:00
|
|
|
if (aRenderRoots.isEmpty()) {
|
2019-04-16 01:34:13 +03:00
|
|
|
mAsyncImageManager->SetWillGenerateFrameAllRenderRoots();
|
|
|
|
}
|
2019-04-17 18:12:10 +03:00
|
|
|
for (auto it = aRenderRoots.begin(); it != aRenderRoots.end(); ++it) {
|
|
|
|
mAsyncImageManager->SetWillGenerateFrame(*it);
|
2019-04-16 01:34:13 +03:00
|
|
|
}
|
|
|
|
mCompositorScheduler->ScheduleComposition();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-28 11:47:08 +03:00
|
|
|
void WebRenderBridgeParent::FlushRendering(bool aWaitForPresent) {
|
2017-06-02 02:07:59 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-17 18:34:31 +03:00
|
|
|
// This gets called during e.g. window resizes, so we need to flush the
|
|
|
|
// scene (which has the display list at the new window size).
|
|
|
|
FlushSceneBuilds();
|
2018-05-28 18:29:52 +03:00
|
|
|
FlushFrameGeneration();
|
2018-07-28 11:47:08 +03:00
|
|
|
if (aWaitForPresent) {
|
|
|
|
FlushFramePresentation();
|
2018-02-02 18:48:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
void WebRenderBridgeParent::Pause() {
|
2018-06-26 21:37:31 +03:00
|
|
|
MOZ_ASSERT(IsRootWebRenderBridgeParent());
|
2017-04-05 17:12:11 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2018-06-26 21:37:31 +03:00
|
|
|
if (!IsRootWebRenderBridgeParent() || mDestroyed) {
|
2017-04-05 17:12:11 +03:00
|
|
|
return;
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
|
|
|
|
Api(wr::RenderRoot::Default)->Pause();
|
2017-04-05 17:12:11 +03:00
|
|
|
#endif
|
|
|
|
mPaused = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebRenderBridgeParent::Resume() {
|
2018-06-26 21:37:31 +03:00
|
|
|
MOZ_ASSERT(IsRootWebRenderBridgeParent());
|
2017-04-05 17:12:11 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2018-06-26 21:37:31 +03:00
|
|
|
if (!IsRootWebRenderBridgeParent() || mDestroyed) {
|
2017-04-05 17:12:11 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
if (!Api(wr::RenderRoot::Default)->Resume()) {
|
2017-04-05 17:12:11 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
mPaused = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-11-22 17:22:54 +03:00
|
|
|
void WebRenderBridgeParent::ClearResources() {
|
2019-04-05 18:42:50 +03:00
|
|
|
if (!mApis[wr::RenderRoot::Default]) {
|
2017-05-17 03:28:20 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-10 19:29:56 +03:00
|
|
|
wr::Epoch wrEpoch = GetNextWrEpoch();
|
2018-03-06 22:20:56 +03:00
|
|
|
mReceivedDisplayList = false;
|
2019-03-22 11:52:44 +03:00
|
|
|
// Schedule generate frame to clean up Pipeline
|
2019-03-22 21:28:42 +03:00
|
|
|
ScheduleGenerateFrameAllRenderRoots();
|
|
|
|
|
2017-08-16 04:09:35 +03:00
|
|
|
// WrFontKeys and WrImageKeys are deleted during WebRenderAPI destruction.
|
2018-07-10 05:06:08 +03:00
|
|
|
for (const auto& entry : mTextureHosts) {
|
|
|
|
WebRenderTextureHost* wrTexture = entry.second->AsWebRenderTextureHost();
|
2018-07-06 15:25:33 +03:00
|
|
|
MOZ_ASSERT(wrTexture);
|
|
|
|
if (wrTexture) {
|
|
|
|
mAsyncImageManager->HoldExternalImage(mPipelineId, wrEpoch, wrTexture);
|
|
|
|
}
|
2017-04-27 19:34:54 +03:00
|
|
|
}
|
2018-07-10 05:06:08 +03:00
|
|
|
mTextureHosts.clear();
|
2019-03-22 21:28:42 +03:00
|
|
|
|
2018-07-10 05:06:08 +03:00
|
|
|
for (const auto& entry : mSharedSurfaceIds) {
|
2018-10-02 20:27:52 +03:00
|
|
|
mAsyncImageManager->HoldExternalImage(mPipelineId, mWrEpoch, entry.second);
|
2018-04-23 14:57:15 +03:00
|
|
|
}
|
2018-07-10 05:06:08 +03:00
|
|
|
mSharedSurfaceIds.clear();
|
2017-06-02 10:11:34 +03:00
|
|
|
|
2018-04-10 19:29:56 +03:00
|
|
|
mAsyncImageManager->RemovePipeline(mPipelineId, wrEpoch);
|
2018-01-12 14:24:07 +03:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
for (auto& api : mApis) {
|
2019-04-05 18:42:50 +03:00
|
|
|
if (!api) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-22 21:28:42 +03:00
|
|
|
wr::TransactionBuilder txn;
|
|
|
|
txn.SetLowPriority(true);
|
|
|
|
txn.ClearDisplayList(wrEpoch, mPipelineId);
|
|
|
|
|
|
|
|
auto renderRoot = api->GetRenderRoot();
|
|
|
|
for (const auto& entry : mAsyncCompositables[renderRoot]) {
|
|
|
|
wr::PipelineId pipelineId = wr::AsPipelineId(entry.first);
|
|
|
|
RefPtr<WebRenderImageHost> host = entry.second;
|
|
|
|
host->ClearWrBridge(this);
|
|
|
|
mAsyncImageManager->RemoveAsyncImagePipeline(pipelineId, txn);
|
|
|
|
txn.RemovePipeline(pipelineId);
|
|
|
|
}
|
|
|
|
mAsyncCompositables[renderRoot].clear();
|
|
|
|
txn.RemovePipeline(mPipelineId);
|
|
|
|
api->SendTransaction(txn);
|
|
|
|
}
|
2016-11-24 11:53:17 +03:00
|
|
|
|
2018-07-07 03:30:50 +03:00
|
|
|
for (const auto& id : mActiveAnimations) {
|
2019-01-28 23:11:59 +03:00
|
|
|
mAnimStorage->ClearById(id.first);
|
2017-06-15 10:36:03 +03:00
|
|
|
}
|
|
|
|
mActiveAnimations.clear();
|
2018-04-27 17:32:31 +03:00
|
|
|
std::queue<CompositorAnimationIdsForEpoch>().swap(
|
|
|
|
mCompositorAnimationsToDelete); // clear queue
|
2017-06-15 10:36:03 +03:00
|
|
|
|
2018-06-26 21:37:31 +03:00
|
|
|
if (IsRootWebRenderBridgeParent()) {
|
2016-11-22 17:22:54 +03:00
|
|
|
mCompositorScheduler->Destroy();
|
|
|
|
}
|
2018-06-02 19:15:15 +03:00
|
|
|
|
2017-06-15 10:36:03 +03:00
|
|
|
mAnimStorage = nullptr;
|
2017-02-27 03:27:04 +03:00
|
|
|
mCompositorScheduler = nullptr;
|
2017-08-09 15:46:25 +03:00
|
|
|
mAsyncImageManager = nullptr;
|
2019-04-05 18:42:50 +03:00
|
|
|
for (auto& api : mApis) {
|
|
|
|
api = nullptr;
|
|
|
|
}
|
2016-11-30 05:59:14 +03:00
|
|
|
mCompositorBridge = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebRenderBridgeParent::ShouldParentObserveEpoch() {
|
2018-07-30 16:24:50 +03:00
|
|
|
if (mParentLayersObserverEpoch == mChildLayersObserverEpoch) {
|
2016-11-30 05:59:14 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-30 16:24:50 +03:00
|
|
|
mParentLayersObserverEpoch = mChildLayersObserverEpoch;
|
2016-11-30 05:59:14 +03:00
|
|
|
return true;
|
2016-11-22 17:22:54 +03:00
|
|
|
}
|
|
|
|
|
2016-11-30 13:57:26 +03:00
|
|
|
void WebRenderBridgeParent::SendAsyncMessage(
|
|
|
|
const InfallibleTArray<AsyncParentMessageData>& aMessage) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
|
|
|
}
|
|
|
|
|
2016-12-07 13:02:04 +03:00
|
|
|
void WebRenderBridgeParent::SendPendingAsyncMessages() {
|
|
|
|
MOZ_ASSERT(mCompositorBridge);
|
|
|
|
mCompositorBridge->SendPendingAsyncMessages();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebRenderBridgeParent::SetAboutToSendAsyncMessages() {
|
|
|
|
MOZ_ASSERT(mCompositorBridge);
|
|
|
|
mCompositorBridge->SetAboutToSendAsyncMessages();
|
|
|
|
}
|
|
|
|
|
2016-11-30 13:57:26 +03:00
|
|
|
void WebRenderBridgeParent::NotifyNotUsed(PTextureParent* aTexture,
|
|
|
|
uint64_t aTransactionId) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
|
|
|
}
|
|
|
|
|
|
|
|
base::ProcessId WebRenderBridgeParent::GetChildProcessId() {
|
|
|
|
return OtherPid();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebRenderBridgeParent::IsSameProcess() const {
|
|
|
|
return OtherPid() == base::GetCurrentProcId();
|
|
|
|
}
|
|
|
|
|
2017-01-18 21:47:27 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvNewCompositable(
|
|
|
|
const CompositableHandle& aHandle, const TextureInfo& aInfo) {
|
2017-06-05 09:41:21 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
Bug 1354411 - Rebuild CompositorSessions if WebRender is disabled r=kats
When WebRender creation is failed, WebRender is disabled in gecko. There is a case that WebRenderBridgeParents exist when WebRender is disabled. To handle this, gecko needs to rebuild all CompositorSessions.
There is also a problem related to gfxVars::UseWebRender on compositor thread. If e10s is enabled, but no-gpu process(default on linux and mac), gfxVars::UseWebRender change is soon notified by compositor thread tasks. If WebRender creation failure happens at 2nd WebRender creation, several WebRenderBridgeParents for 1st WebRender could exist. IPC messages from WebRenderLayerManager are normally async, then there is a chance that the WebRenderBridgeParents receive the messages after the gfxVars::UseWebRender change. Further the gfxVars::UseWebRender change in content process could be delayed than WebRenderBridgeParents, then content process does not have a way to stop sending PWebRenderBridge IPC until the change of gfxVars::UseWebRender is received. WebRenderBridgeParent related tasks handle the message, but some tasks are done based on gfxVars::UseWebRender. At this time, gfxVars::UseWebRender returned false on compositor thread, then it cause unexpected result for WebRenderBridgeParent and WebRender. To addres this inconsistent situation, WebRenderBridgeParent related tasks on compositor thread stop to use gfxVars::UseWebRender.
2017-08-04 08:36:41 +03:00
|
|
|
if (!AddCompositable(aHandle, aInfo, /* aUseWebRender */ true)) {
|
2017-01-18 21:47:27 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2016-11-30 13:57:26 +03:00
|
|
|
}
|
|
|
|
|
2017-01-18 21:47:27 +03:00
|
|
|
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvReleaseCompositable(
|
|
|
|
const CompositableHandle& aHandle) {
|
2017-06-05 09:41:21 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2017-01-18 21:47:27 +03:00
|
|
|
ReleaseCompositable(aHandle);
|
|
|
|
return IPC_OK();
|
2016-11-30 13:57:26 +03:00
|
|
|
}
|
|
|
|
|
2017-01-18 22:50:00 +03:00
|
|
|
TextureFactoryIdentifier WebRenderBridgeParent::GetTextureFactoryIdentifier() {
|
2019-04-05 18:42:50 +03:00
|
|
|
MOZ_ASSERT(!!mApis[wr::RenderRoot::Default]);
|
2017-01-18 22:50:00 +03:00
|
|
|
|
2017-01-22 07:24:52 +03:00
|
|
|
return TextureFactoryIdentifier(
|
2019-03-22 21:28:42 +03:00
|
|
|
LayersBackend::LAYERS_WR, XRE_GetProcessType(),
|
|
|
|
Api(wr::RenderRoot::Default)->GetMaxTextureSize(), false,
|
|
|
|
Api(wr::RenderRoot::Default)->GetUseANGLE(),
|
|
|
|
Api(wr::RenderRoot::Default)->GetUseDComp(), false, false, false,
|
|
|
|
Api(wr::RenderRoot::Default)->GetSyncHandle());
|
2017-01-18 22:50:00 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-07-24 15:20:22 +03:00
|
|
|
wr::Epoch WebRenderBridgeParent::GetNextWrEpoch() {
|
2018-04-10 19:29:56 +03:00
|
|
|
MOZ_RELEASE_ASSERT(mWrEpoch.mHandle != UINT32_MAX);
|
|
|
|
mWrEpoch.mHandle++;
|
|
|
|
return mWrEpoch;
|
2017-07-24 15:20:22 +03:00
|
|
|
}
|
|
|
|
|
2018-11-26 10:08:49 +03:00
|
|
|
void WebRenderBridgeParent::RollbackWrEpoch() {
|
|
|
|
MOZ_RELEASE_ASSERT(mWrEpoch.mHandle != 0);
|
|
|
|
mWrEpoch.mHandle--;
|
|
|
|
}
|
|
|
|
|
2017-07-31 07:00:06 +03:00
|
|
|
void WebRenderBridgeParent::ExtractImageCompositeNotifications(
|
|
|
|
nsTArray<ImageCompositeNotificationInfo>* aNotifications) {
|
2018-06-26 21:37:31 +03:00
|
|
|
MOZ_ASSERT(IsRootWebRenderBridgeParent());
|
2017-08-09 15:46:25 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
2017-07-31 07:00:06 +03:00
|
|
|
mAsyncImageManager->FlushImageNotifications(aNotifications);
|
|
|
|
}
|
|
|
|
|
2016-11-16 16:54:51 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|