2016-07-01 11:15:16 +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 "InProcessCompositorWidget.h"
|
2017-10-12 19:03:35 +03:00
|
|
|
|
|
|
|
#include "mozilla/VsyncDispatcher.h"
|
2016-07-01 11:15:16 +03:00
|
|
|
#include "nsBaseWidget.h"
|
2016-07-01 11:15:16 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
2016-07-01 11:15:16 +03:00
|
|
|
// Platforms with no OOP compositor process support use
|
|
|
|
// InProcessCompositorWidget by default.
|
2016-07-01 11:15:16 +03:00
|
|
|
#if !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
|
2019-02-26 01:13:48 +03:00
|
|
|
/* static */
|
|
|
|
RefPtr<CompositorWidget> CompositorWidget::CreateLocal(
|
2017-01-13 01:29:42 +03:00
|
|
|
const CompositorWidgetInitData& aInitData,
|
|
|
|
const layers::CompositorOptions& aOptions, nsIWidget* aWidget) {
|
2021-02-04 01:10:24 +03:00
|
|
|
// We're getting crashes from storing a NULL mWidget, and this is the
|
|
|
|
// only remaining explanation that doesn't involve memory corruption,
|
2021-03-10 03:45:49 +03:00
|
|
|
// so placing a release assert here. For even more sanity-checking, we
|
|
|
|
// do it after the static_cast.
|
|
|
|
nsBaseWidget* widget = static_cast<nsBaseWidget*>(aWidget);
|
|
|
|
MOZ_RELEASE_ASSERT(widget);
|
|
|
|
return new InProcessCompositorWidget(aOptions, widget);
|
2016-07-01 11:15:16 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-13 01:29:42 +03:00
|
|
|
InProcessCompositorWidget::InProcessCompositorWidget(
|
|
|
|
const layers::CompositorOptions& aOptions, nsBaseWidget* aWidget)
|
2021-03-10 03:45:49 +03:00
|
|
|
: CompositorWidget(aOptions),
|
|
|
|
mWidget(aWidget),
|
|
|
|
mCanary(CANARY_VALUE),
|
|
|
|
mWidgetSanity(aWidget) {
|
2020-12-10 19:24:24 +03:00
|
|
|
// The only method of construction that is used outside of unit tests is
|
|
|
|
// ::CreateLocal, above. That method of construction asserts that mWidget
|
|
|
|
// is not assigned a NULL value. And yet mWidget is NULL in some crash
|
|
|
|
// reports that involve other class methods. Adding a release assert here
|
|
|
|
// will give us the earliest possible notification that we're headed for
|
|
|
|
// a crash.
|
|
|
|
MOZ_RELEASE_ASSERT(mWidget);
|
|
|
|
}
|
2016-07-01 11:15:16 +03:00
|
|
|
|
2016-11-08 05:16:52 +03:00
|
|
|
bool InProcessCompositorWidget::PreRender(WidgetRenderingContext* aContext) {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-11-08 05:16:52 +03:00
|
|
|
return mWidget->PreRender(aContext);
|
2016-07-01 11:15:16 +03:00
|
|
|
}
|
|
|
|
|
2016-11-08 05:16:52 +03:00
|
|
|
void InProcessCompositorWidget::PostRender(WidgetRenderingContext* aContext) {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-11-08 05:16:52 +03:00
|
|
|
mWidget->PostRender(aContext);
|
2016-07-01 11:15:16 +03:00
|
|
|
}
|
|
|
|
|
2019-08-25 20:10:52 +03:00
|
|
|
RefPtr<layers::NativeLayerRoot>
|
|
|
|
InProcessCompositorWidget::GetNativeLayerRoot() {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2019-08-25 20:10:52 +03:00
|
|
|
return mWidget->GetNativeLayerRoot();
|
|
|
|
}
|
|
|
|
|
2016-07-01 11:15:16 +03:00
|
|
|
already_AddRefed<gfx::DrawTarget>
|
|
|
|
InProcessCompositorWidget::StartRemoteDrawing() {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
return mWidget->StartRemoteDrawing();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<gfx::DrawTarget>
|
|
|
|
InProcessCompositorWidget::StartRemoteDrawingInRegion(
|
2021-02-24 21:34:52 +03:00
|
|
|
const LayoutDeviceIntRegion& aInvalidRegion,
|
|
|
|
layers::BufferMode* aBufferMode) {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
return mWidget->StartRemoteDrawingInRegion(aInvalidRegion, aBufferMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InProcessCompositorWidget::EndRemoteDrawing() {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
mWidget->EndRemoteDrawing();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InProcessCompositorWidget::EndRemoteDrawingInRegion(
|
2019-08-20 01:40:39 +03:00
|
|
|
gfx::DrawTarget* aDrawTarget, const LayoutDeviceIntRegion& aInvalidRegion) {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
mWidget->EndRemoteDrawingInRegion(aDrawTarget, aInvalidRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InProcessCompositorWidget::CleanupRemoteDrawing() {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
mWidget->CleanupRemoteDrawing();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InProcessCompositorWidget::CleanupWindowEffects() {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
mWidget->CleanupWindowEffects();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InProcessCompositorWidget::InitCompositor(
|
|
|
|
layers::Compositor* aCompositor) {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
return mWidget->InitCompositor(aCompositor);
|
|
|
|
}
|
|
|
|
|
|
|
|
LayoutDeviceIntSize InProcessCompositorWidget::GetClientSize() {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
return mWidget->GetClientSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InProcessCompositorWidget::GetGLFrameBufferFormat() {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
return mWidget->GetGLFrameBufferFormat();
|
|
|
|
}
|
|
|
|
|
|
|
|
uintptr_t InProcessCompositorWidget::GetWidgetKey() {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-07-01 11:15:16 +03:00
|
|
|
return reinterpret_cast<uintptr_t>(mWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIWidget* InProcessCompositorWidget::RealWidget() { return mWidget; }
|
|
|
|
|
2016-07-19 21:56:07 +03:00
|
|
|
void InProcessCompositorWidget::ObserveVsync(VsyncObserver* aObserver) {
|
2021-03-10 03:45:49 +03:00
|
|
|
CheckWidgetSanity();
|
2016-09-30 11:23:52 +03:00
|
|
|
if (RefPtr<CompositorVsyncDispatcher> cvd =
|
|
|
|
mWidget->GetCompositorVsyncDispatcher()) {
|
|
|
|
cvd->SetCompositorVsyncObserver(aObserver);
|
|
|
|
}
|
2016-07-01 11:15:16 +03:00
|
|
|
}
|
|
|
|
|
2021-03-10 03:45:49 +03:00
|
|
|
const char* InProcessCompositorWidget::CANARY_VALUE =
|
|
|
|
reinterpret_cast<char*>(0x1a1a1a1a);
|
|
|
|
|
|
|
|
void InProcessCompositorWidget::CheckWidgetSanity() {
|
|
|
|
MOZ_RELEASE_ASSERT(mWidgetSanity == mWidget);
|
|
|
|
MOZ_RELEASE_ASSERT(mCanary == CANARY_VALUE);
|
|
|
|
}
|
|
|
|
|
2016-07-01 11:15:16 +03:00
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|