mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 14:30:43 +00:00
Bug 1306083 - 1. Use AndroidCompositorWidget to access GeckoLayerClient; r=kats
Add AndroidCompositorWidget to act as the intermediary between gfx code and GeckoLayerClient, in place of AndroidBridge. AndroidCompositorWidget currently inherits from InProcessCompositorWidget, but when Android eventually supports OOP compositing, it will be made to inherit from CompositorWidget directly.
This commit is contained in:
parent
829aa6173a
commit
3587a0edd6
@ -41,7 +41,7 @@
|
||||
#include "gfxPrefs.h"
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
# include <android/log.h>
|
||||
# include "AndroidBridge.h"
|
||||
# include "mozilla/widget/AndroidCompositorWidget.h"
|
||||
#endif
|
||||
#include "GeckoProfiler.h"
|
||||
#include "FrameUniformityData.h"
|
||||
@ -1618,7 +1618,12 @@ AsyncCompositionManager::SetFirstPaintViewport(const LayerIntPoint& aOffset,
|
||||
const CSSRect& aCssPageRect)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
AndroidBridge::Bridge()->SetFirstPaintViewport(aOffset, aZoom, aCssPageRect);
|
||||
widget::AndroidCompositorWidget* widget =
|
||||
mLayerManager->GetCompositor()->GetWidget()->AsAndroid();
|
||||
if (!widget) {
|
||||
return;
|
||||
}
|
||||
widget->SetFirstPaintViewport(aOffset, aZoom, aCssPageRect);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1626,7 +1631,12 @@ void
|
||||
AsyncCompositionManager::SetPageRect(const CSSRect& aCssPageRect)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
AndroidBridge::Bridge()->SetPageRect(aCssPageRect);
|
||||
widget::AndroidCompositorWidget* widget =
|
||||
mLayerManager->GetCompositor()->GetWidget()->AsAndroid();
|
||||
if (!widget) {
|
||||
return;
|
||||
}
|
||||
widget->SetPageRect(aCssPageRect);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1640,13 +1650,14 @@ AsyncCompositionManager::SyncViewportInfo(const LayerIntRect& aDisplayPort,
|
||||
ScreenMargin& aFixedLayerMargins)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
AndroidBridge::Bridge()->SyncViewportInfo(aDisplayPort,
|
||||
aDisplayResolution,
|
||||
aLayersUpdated,
|
||||
aPaintSyncId,
|
||||
aScrollRect,
|
||||
aScale,
|
||||
aFixedLayerMargins);
|
||||
widget::AndroidCompositorWidget* widget =
|
||||
mLayerManager->GetCompositor()->GetWidget()->AsAndroid();
|
||||
if (!widget) {
|
||||
return;
|
||||
}
|
||||
widget->SyncViewportInfo(
|
||||
aDisplayPort, aDisplayResolution, aLayersUpdated, aPaintSyncId,
|
||||
aScrollRect, aScale, aFixedLayerMargins);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1661,10 +1672,14 @@ AsyncCompositionManager::SyncFrameMetrics(const ParentLayerPoint& aScrollOffset,
|
||||
ScreenMargin& aFixedLayerMargins)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
AndroidBridge::Bridge()->SyncFrameMetrics(aScrollOffset, aZoom, aCssPageRect,
|
||||
aDisplayPort, aPaintedResolution,
|
||||
aLayersUpdated, aPaintSyncId,
|
||||
aFixedLayerMargins);
|
||||
widget::AndroidCompositorWidget* widget =
|
||||
mLayerManager->GetCompositor()->GetWidget()->AsAndroid();
|
||||
if (!widget) {
|
||||
return;
|
||||
}
|
||||
widget->SyncFrameMetrics(
|
||||
aScrollOffset, aZoom, aCssPageRect, aDisplayPort, aPaintedResolution,
|
||||
aLayersUpdated, aPaintSyncId, aFixedLayerMargins);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ namespace widget {
|
||||
|
||||
class WinCompositorWidget;
|
||||
class X11CompositorWidget;
|
||||
class AndroidCompositorWidget;
|
||||
class CompositorWidgetInitData;
|
||||
|
||||
// Gecko widgets usually need to communicate with the CompositorWidget with
|
||||
@ -249,6 +250,9 @@ public:
|
||||
virtual X11CompositorWidget* AsX11() {
|
||||
return nullptr;
|
||||
}
|
||||
virtual AndroidCompositorWidget* AsAndroid() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the platform-specific delegate for the widget, if any.
|
||||
|
@ -5,6 +5,10 @@
|
||||
#include "InProcessCompositorWidget.h"
|
||||
#include "nsBaseWidget.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
|
||||
#include "mozilla/widget/AndroidCompositorWidget.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
@ -15,7 +19,11 @@ namespace widget {
|
||||
CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget)
|
||||
{
|
||||
MOZ_ASSERT(aWidget);
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
return new AndroidCompositorWidget(static_cast<nsBaseWidget*>(aWidget));
|
||||
#else
|
||||
return new InProcessCompositorWidget(static_cast<nsBaseWidget*>(aWidget));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
108
widget/android/AndroidCompositorWidget.cpp
Normal file
108
widget/android/AndroidCompositorWidget.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=2 et tw=80 : */
|
||||
/* 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 "AndroidCompositorWidget.h"
|
||||
#include "nsWindow.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
void
|
||||
AndroidCompositorWidget::SetFirstPaintViewport(const LayerIntPoint& aOffset,
|
||||
const CSSToLayerScale& aZoom,
|
||||
const CSSRect& aCssPageRect)
|
||||
{
|
||||
auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient();
|
||||
if (!layerClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
layerClient->SetFirstPaintViewport(
|
||||
float(aOffset.x), float(aOffset.y), aZoom.scale, aCssPageRect.x,
|
||||
aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||
}
|
||||
|
||||
void
|
||||
AndroidCompositorWidget::SetPageRect(const CSSRect& aCssPageRect)
|
||||
{
|
||||
auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient();
|
||||
if (!layerClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
layerClient->SetPageRect(aCssPageRect.x, aCssPageRect.y,
|
||||
aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||
}
|
||||
|
||||
void
|
||||
AndroidCompositorWidget::SyncViewportInfo(const LayerIntRect& aDisplayPort,
|
||||
const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated,
|
||||
int32_t aPaintSyncId,
|
||||
ParentLayerRect& aScrollRect,
|
||||
CSSToParentLayerScale& aScale,
|
||||
ScreenMargin& aFixedLayerMargins)
|
||||
{
|
||||
auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient();
|
||||
if (!layerClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
java::ViewTransform::LocalRef viewTransform = layerClient->SyncViewportInfo(
|
||||
aDisplayPort.x, aDisplayPort.y, aDisplayPort.width,
|
||||
aDisplayPort.height, aDisplayResolution.scale, aLayersUpdated,
|
||||
aPaintSyncId);
|
||||
|
||||
MOZ_ASSERT(viewTransform, "No view transform object!");
|
||||
|
||||
aScrollRect = ParentLayerRect(
|
||||
viewTransform->X(), viewTransform->Y(),
|
||||
viewTransform->Width(), viewTransform->Height());
|
||||
|
||||
aScale.scale = viewTransform->Scale();
|
||||
|
||||
aFixedLayerMargins.top = viewTransform->FixedLayerMarginTop();
|
||||
aFixedLayerMargins.right = viewTransform->FixedLayerMarginRight();
|
||||
aFixedLayerMargins.bottom = viewTransform->FixedLayerMarginBottom();
|
||||
aFixedLayerMargins.left = viewTransform->FixedLayerMarginLeft();
|
||||
}
|
||||
|
||||
void
|
||||
AndroidCompositorWidget::SyncFrameMetrics(const ParentLayerPoint& aScrollOffset,
|
||||
const CSSToParentLayerScale& aZoom,
|
||||
const CSSRect& aCssPageRect,
|
||||
const CSSRect& aDisplayPort,
|
||||
const CSSToLayerScale& aPaintedResolution,
|
||||
bool aLayersUpdated,
|
||||
int32_t aPaintSyncId,
|
||||
ScreenMargin& aFixedLayerMargins)
|
||||
{
|
||||
auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient();
|
||||
if (!layerClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
// convert the displayport rect from document-relative CSS pixels to
|
||||
// document-relative device pixels
|
||||
LayerIntRect dp = gfx::RoundedToInt(aDisplayPort * aPaintedResolution);
|
||||
|
||||
java::ViewTransform::LocalRef viewTransform = layerClient->SyncFrameMetrics(
|
||||
aScrollOffset.x, aScrollOffset.y, aZoom.scale,
|
||||
aCssPageRect.x, aCssPageRect.y,
|
||||
aCssPageRect.XMost(), aCssPageRect.YMost(),
|
||||
dp.x, dp.y, dp.width, dp.height,
|
||||
aPaintedResolution.scale, aLayersUpdated, aPaintSyncId);
|
||||
|
||||
MOZ_ASSERT(viewTransform, "No view transform object!");
|
||||
|
||||
aFixedLayerMargins.top = viewTransform->FixedLayerMarginTop();
|
||||
aFixedLayerMargins.right = viewTransform->FixedLayerMarginRight();
|
||||
aFixedLayerMargins.bottom = viewTransform->FixedLayerMarginBottom();
|
||||
aFixedLayerMargins.left = viewTransform->FixedLayerMarginLeft();
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
54
widget/android/AndroidCompositorWidget.h
Normal file
54
widget/android/AndroidCompositorWidget.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* 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/. */
|
||||
|
||||
#ifndef mozilla_widget_AndroidCompositorWidget_h
|
||||
#define mozilla_widget_AndroidCompositorWidget_h
|
||||
|
||||
#include "mozilla/widget/InProcessCompositorWidget.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
/**
|
||||
* AndroidCompositorWidget inherits from InProcessCompositorWidget because
|
||||
* Android does not support OOP compositing yet. Once it does,
|
||||
* AndroidCompositorWidget will be made to inherit from CompositorWidget
|
||||
* instead.
|
||||
*/
|
||||
class AndroidCompositorWidget final : public InProcessCompositorWidget
|
||||
{
|
||||
public:
|
||||
using InProcessCompositorWidget::InProcessCompositorWidget;
|
||||
|
||||
AndroidCompositorWidget* AsAndroid() override { return this; }
|
||||
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset,
|
||||
const CSSToLayerScale& aZoom,
|
||||
const CSSRect& aCssPageRect);
|
||||
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort,
|
||||
const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated,
|
||||
int32_t aPaintSyncId,
|
||||
ParentLayerRect& aScrollRect,
|
||||
CSSToParentLayerScale& aScale,
|
||||
ScreenMargin& aFixedLayerMargins);
|
||||
|
||||
void SyncFrameMetrics(const ParentLayerPoint& aScrollOffset,
|
||||
const CSSToParentLayerScale& aZoom,
|
||||
const CSSRect& aCssPageRect,
|
||||
const CSSRect& aDisplayPort,
|
||||
const CSSToLayerScale& aPaintedResolution,
|
||||
bool aLayersUpdated,
|
||||
int32_t aPaintSyncId,
|
||||
ScreenMargin& aFixedLayerMargins);
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_widget_AndroidCompositorWidget_h
|
@ -24,9 +24,14 @@ EXPORTS += [
|
||||
'GeneratedJNIWrappers.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.widget += [
|
||||
'AndroidCompositorWidget.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'AndroidAlerts.cpp',
|
||||
'AndroidBridge.cpp',
|
||||
'AndroidCompositorWidget.cpp',
|
||||
'AndroidContentController.cpp',
|
||||
'AndroidJavaWrappers.cpp',
|
||||
'AndroidJNI.cpp',
|
||||
|
@ -3619,3 +3619,12 @@ nsWindow::GetCompositorBridgeParent() const
|
||||
{
|
||||
return mCompositorSession ? mCompositorSession->GetInProcessBridge() : nullptr;
|
||||
}
|
||||
|
||||
jni::DependentRef<java::GeckoLayerClient>
|
||||
nsWindow::GetLayerClient()
|
||||
{
|
||||
if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) {
|
||||
return lvs->GetLayerClient().Get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -226,6 +226,8 @@ public:
|
||||
|
||||
CompositorBridgeParent* GetCompositorBridgeParent() const;
|
||||
|
||||
mozilla::jni::DependentRef<mozilla::java::GeckoLayerClient> GetLayerClient();
|
||||
|
||||
protected:
|
||||
void BringToFront();
|
||||
nsWindow *FindTopLevel();
|
||||
|
Loading…
x
Reference in New Issue
Block a user