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
|
|
|
|
2016-10-03 19:26:00 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
|
|
|
|
#include "mozilla/widget/AndroidCompositorWidget.h"
|
|
|
|
#endif
|
|
|
|
|
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)
|
2016-07-01 11:15:16 +03:00
|
|
|
/* static */ RefPtr<CompositorWidget> CompositorWidget::CreateLocal(
|
2017-01-13 01:29:42 +03:00
|
|
|
const CompositorWidgetInitData& aInitData,
|
|
|
|
const layers::CompositorOptions& aOptions, nsIWidget* aWidget) {
|
2016-07-01 11:15:16 +03:00
|
|
|
MOZ_ASSERT(aWidget);
|
2016-10-03 19:26:00 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2017-01-13 01:29:42 +03:00
|
|
|
return new AndroidCompositorWidget(aOptions,
|
|
|
|
static_cast<nsBaseWidget*>(aWidget));
|
2016-10-03 19:26:00 +03:00
|
|
|
#else
|
2017-01-13 01:29:42 +03:00
|
|
|
return new InProcessCompositorWidget(aOptions,
|
|
|
|
static_cast<nsBaseWidget*>(aWidget));
|
2016-10-03 19:26:00 +03:00
|
|
|
#endif
|
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)
|
|
|
|
: CompositorWidget(aOptions), mWidget(aWidget) {}
|
2016-07-01 11:15:16 +03:00
|
|
|
|
2016-11-08 05:16:52 +03:00
|
|
|
bool InProcessCompositorWidget::PreRender(WidgetRenderingContext* aContext) {
|
|
|
|
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) {
|
|
|
|
mWidget->PostRender(aContext);
|
2016-07-01 11:15:16 +03:00
|
|
|
}
|
|
|
|
|
2016-11-08 05:16:52 +03:00
|
|
|
void InProcessCompositorWidget::DrawWindowUnderlay(
|
|
|
|
WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) {
|
|
|
|
mWidget->DrawWindowUnderlay(aContext, aRect);
|
2016-07-01 11:15:16 +03:00
|
|
|
}
|
|
|
|
|
2016-11-08 05:16:52 +03:00
|
|
|
void InProcessCompositorWidget::DrawWindowOverlay(
|
|
|
|
WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) {
|
|
|
|
mWidget->DrawWindowOverlay(aContext, aRect);
|
2016-07-01 11:15:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<gfx::DrawTarget>
|
|
|
|
InProcessCompositorWidget::StartRemoteDrawing() {
|
|
|
|
return mWidget->StartRemoteDrawing();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<gfx::DrawTarget>
|
|
|
|
InProcessCompositorWidget::StartRemoteDrawingInRegion(
|
|
|
|
LayoutDeviceIntRegion& aInvalidRegion, layers::BufferMode* aBufferMode) {
|
|
|
|
return mWidget->StartRemoteDrawingInRegion(aInvalidRegion, aBufferMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InProcessCompositorWidget::EndRemoteDrawing() {
|
|
|
|
mWidget->EndRemoteDrawing();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InProcessCompositorWidget::EndRemoteDrawingInRegion(
|
|
|
|
gfx::DrawTarget* aDrawTarget, LayoutDeviceIntRegion& aInvalidRegion) {
|
|
|
|
mWidget->EndRemoteDrawingInRegion(aDrawTarget, aInvalidRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InProcessCompositorWidget::CleanupRemoteDrawing() {
|
|
|
|
mWidget->CleanupRemoteDrawing();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InProcessCompositorWidget::CleanupWindowEffects() {
|
|
|
|
mWidget->CleanupWindowEffects();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InProcessCompositorWidget::InitCompositor(
|
|
|
|
layers::Compositor* aCompositor) {
|
|
|
|
return mWidget->InitCompositor(aCompositor);
|
|
|
|
}
|
|
|
|
|
|
|
|
LayoutDeviceIntSize InProcessCompositorWidget::GetClientSize() {
|
|
|
|
return mWidget->GetClientSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InProcessCompositorWidget::GetGLFrameBufferFormat() {
|
|
|
|
return mWidget->GetGLFrameBufferFormat();
|
|
|
|
}
|
|
|
|
|
|
|
|
uintptr_t InProcessCompositorWidget::GetWidgetKey() {
|
|
|
|
return reinterpret_cast<uintptr_t>(mWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIWidget* InProcessCompositorWidget::RealWidget() { return mWidget; }
|
|
|
|
|
2016-07-19 21:56:07 +03:00
|
|
|
void InProcessCompositorWidget::ObserveVsync(VsyncObserver* aObserver) {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|