Move CompositorWidget construction out of nsIWidget. (bug 1281998 part 5, r=jimm)

This commit is contained in:
David Anderson 2016-07-01 01:15:16 -07:00
Родитель f0edea202e
Коммит 6562af780a
16 изменённых файлов: 107 добавлений и 47 удалений

Просмотреть файл

@ -6,6 +6,7 @@
#include "CompositorSession.h" #include "CompositorSession.h"
#include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/widget/PlatformWidgetTypes.h"
#include "base/process_util.h" #include "base/process_util.h"
namespace mozilla { namespace mozilla {
@ -73,7 +74,10 @@ InProcessCompositorSession::InProcessCompositorSession(nsIWidget* aWidget,
bool aUseExternalSurfaceSize, bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize) const gfx::IntSize& aSurfaceSize)
{ {
mCompositorWidget = aWidget->NewCompositorWidget(); CompositorWidgetInitData initData;
aWidget->GetCompositorWidgetInitData(&initData);
mCompositorWidget = CompositorWidget::CreateLocal(initData, aWidget);
mCompositorBridgeParent = new CompositorBridgeParent( mCompositorBridgeParent = new CompositorBridgeParent(
mCompositorWidget, mCompositorWidget,
aScale, aScale,

Просмотреть файл

@ -34,6 +34,7 @@ class CompositorSession
{ {
friend class gfx::GPUProcessManager; friend class gfx::GPUProcessManager;
protected:
typedef widget::CompositorWidget CompositorWidget; typedef widget::CompositorWidget CompositorWidget;
public: public:

Просмотреть файл

@ -29,6 +29,7 @@ class SourceSurface;
namespace widget { namespace widget {
class WinCompositorWidget; class WinCompositorWidget;
class CompositorWidgetInitData;
/** /**
* Access to a widget from the compositor is restricted to these methods. * Access to a widget from the compositor is restricted to these methods.
@ -38,6 +39,12 @@ class CompositorWidget
public: public:
NS_INLINE_DECL_REFCOUNTING(mozilla::widget::CompositorWidget) NS_INLINE_DECL_REFCOUNTING(mozilla::widget::CompositorWidget)
/**
* Create an in-process compositor widget. aWidget may be ignored if the
* platform does not require it.
*/
static RefPtr<CompositorWidget> CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget);
/** /**
* Called before rendering using OMTC. Returns false when the widget is * Called before rendering using OMTC. Returns false when the widget is
* not ready to be rendered (for example while the window is closed). * not ready to be rendered (for example while the window is closed).

Просмотреть файл

@ -3,10 +3,22 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "InProcessCompositorWidget.h" #include "InProcessCompositorWidget.h"
#include "nsBaseWidget.h"
namespace mozilla { namespace mozilla {
namespace widget { namespace widget {
// Platforms with no OOP compositor process support use
// InProcessCompositorWidget by default.
#if !defined(XP_WIN)
/* static */ RefPtr<CompositorWidget>
CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget)
{
MOZ_ASSERT(aWidget);
return new InProcessCompositorWidget(static_cast<nsBaseWidget*>(aWidget));
}
#endif
InProcessCompositorWidget::InProcessCompositorWidget(nsBaseWidget* aWidget) InProcessCompositorWidget::InProcessCompositorWidget(nsBaseWidget* aWidget)
: mWidget(aWidget) : mWidget(aWidget)
{ {

Просмотреть файл

@ -0,0 +1,18 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=99: */
/* 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/. */
// This file is a stub, for platforms that do not yet support out-of-process
// compositing or do not need specialized types to do so.
namespace mozilla {
namespace widget {
struct CompositorWidgetInitData
{
};
} // namespace widget
} // namespace mozilla

Просмотреть файл

@ -279,12 +279,6 @@ protected:
virtual nsresult NotifyIMEInternal( virtual nsresult NotifyIMEInternal(
const IMENotification& aIMENotification) override; const IMENotification& aIMENotification) override;
// PuppetWidgets do not create compositors.
widget::CompositorWidget* NewCompositorWidget() override {
MOZ_ASSERT_UNREACHABLE("PuppetWidgets should not have widget proxies");
return nullptr;
}
private: private:
nsresult Paint(); nsresult Paint();

Просмотреть файл

@ -353,10 +353,6 @@ public:
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) override; NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) override;
CompositorWidget* NewCompositorWidget() override {
return nullptr;
}
protected: protected:
virtual ~nsCocoaWindow(); virtual ~nsCocoaWindow();

Просмотреть файл

@ -242,6 +242,15 @@ LOCAL_INCLUDES += [
'/widget', '/widget',
] ]
if toolkit == 'windows':
IPDL_SOURCES = [
'windows/PlatformWidgetTypes.ipdlh',
]
else:
IPDL_SOURCES = [
'PlatformWidgetTypes.ipdlh',
]
widget_dir = toolkit widget_dir = toolkit
if widget_dir in ('gtk3', 'gtk2'): if widget_dir in ('gtk3', 'gtk2'):
# gtk3 shares includes with gtk2 # gtk3 shares includes with gtk2

Просмотреть файл

@ -72,7 +72,6 @@
#endif #endif
#include "gfxConfig.h" #include "gfxConfig.h"
#include "mozilla/layers/CompositorSession.h" #include "mozilla/layers/CompositorSession.h"
#include "InProcessCompositorWidget.h"
#ifdef DEBUG #ifdef DEBUG
#include "nsIObserver.h" #include "nsIObserver.h"
@ -1415,12 +1414,6 @@ nsBaseWidget::GetGLFrameBufferFormat()
return LOCAL_GL_RGBA; return LOCAL_GL_RGBA;
} }
mozilla::widget::CompositorWidget*
nsBaseWidget::NewCompositorWidget()
{
return new mozilla::widget::InProcessCompositorWidget(this);
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// Destroy the window // Destroy the window

Просмотреть файл

@ -354,8 +354,6 @@ public:
void Shutdown(); void Shutdown();
virtual mozilla::widget::CompositorWidget* NewCompositorWidget() override;
protected: protected:
// These are methods for CompositorWidgetWrapper, and should only be // These are methods for CompositorWidgetWrapper, and should only be
// accessed from that class. Derived widgets can choose which methods to // accessed from that class. Derived widgets can choose which methods to

Просмотреть файл

@ -66,6 +66,7 @@ namespace widget {
class TextEventDispatcher; class TextEventDispatcher;
class TextEventDispatcherListener; class TextEventDispatcherListener;
class CompositorWidget; class CompositorWidget;
class CompositorWidgetInitData;
} // namespace widget } // namespace widget
} // namespace mozilla } // namespace mozilla
@ -1627,8 +1628,10 @@ class nsIWidget : public nsISupports
virtual void StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) = 0; virtual void StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) = 0;
// Return a new CompositorWidget for this widget. // If this widget supports out-of-process compositing, it can override
virtual mozilla::widget::CompositorWidget* NewCompositorWidget() = 0; // this method to provide additional information to the compositor.
virtual void GetCompositorWidgetInitData(mozilla::widget::CompositorWidgetInitData* aInitData)
{}
private: private:
class LongTapInfo class LongTapInfo

Просмотреть файл

@ -0,0 +1,23 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=99: */
/* 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/. */
// This file is a stub, for platforms that do not yet support out-of-process
// compositing or do not need specialized types to do so.
using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
namespace mozilla {
namespace widget {
struct CompositorWidgetInitData
{
WindowsHandle hWnd;
uintptr_t widgetKey;
int32_t transparencyMode;
};
} // namespace widget
} // namespace mozilla

Просмотреть файл

@ -7,20 +7,25 @@
#include "nsWindow.h" #include "nsWindow.h"
#include "VsyncDispatcher.h" #include "VsyncDispatcher.h"
#include "mozilla/gfx/Point.h" #include "mozilla/gfx/Point.h"
#include "mozilla/widget/PlatformWidgetTypes.h"
namespace mozilla { namespace mozilla {
namespace widget { namespace widget {
using namespace mozilla::gfx; using namespace mozilla::gfx;
WinCompositorWidget::WinCompositorWidget(HWND aWnd, /* static */ RefPtr<CompositorWidget>
uintptr_t aWidgetKey, CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget)
nsTransparencyMode aMode, {
return new WinCompositorWidget(aInitData, static_cast<nsWindow*>(aWidget));
}
WinCompositorWidget::WinCompositorWidget(const CompositorWidgetInitData& aInitData,
nsWindow* aWindow) nsWindow* aWindow)
: mWindow(aWindow), : mWindow(aWindow),
mWidgetKey(aWidgetKey), mWidgetKey(aInitData.widgetKey()),
mWnd(aWnd), mWnd(reinterpret_cast<HWND>(aInitData.hWnd())),
mTransparencyMode(aMode), mTransparencyMode(static_cast<nsTransparencyMode>(aInitData.transparencyMode())),
mMemoryDC(nullptr), mMemoryDC(nullptr),
mCompositeDC(nullptr), mCompositeDC(nullptr),
mLockedBackBufferData(nullptr) mLockedBackBufferData(nullptr)

Просмотреть файл

@ -21,9 +21,7 @@ namespace widget {
class WinCompositorWidget: public CompositorWidget class WinCompositorWidget: public CompositorWidget
{ {
public: public:
WinCompositorWidget(HWND aWnd, WinCompositorWidget(const CompositorWidgetInitData& aInitData,
uintptr_t aWidgetKey,
nsTransparencyMode aMode,
nsWindow* aWindow = nullptr); nsWindow* aWindow = nullptr);
bool PreRender(layers::LayerManagerComposite*) override; bool PreRender(layers::LayerManagerComposite*) override;

Просмотреть файл

@ -136,6 +136,7 @@
#include "mozilla/TextEvents.h" // For WidgetKeyboardEvent #include "mozilla/TextEvents.h" // For WidgetKeyboardEvent
#include "mozilla/TextEventDispatcherListener.h" #include "mozilla/TextEventDispatcherListener.h"
#include "mozilla/widget/WinNativeEventData.h" #include "mozilla/widget/WinNativeEventData.h"
#include "mozilla/widget/PlatformWidgetTypes.h"
#include "nsThemeConstants.h" #include "nsThemeConstants.h"
#include "nsBidiKeyboard.h" #include "nsBidiKeyboard.h"
#include "nsThemeConstants.h" #include "nsThemeConstants.h"
@ -3621,11 +3622,11 @@ nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager,
// Ensure we have a widget proxy even if we're not using the compositor, // Ensure we have a widget proxy even if we're not using the compositor,
// since all our transparent window handling lives there. // since all our transparent window handling lives there.
mCompositorWidget = new WinCompositorWidget( CompositorWidgetInitData initData(
mWnd, reinterpret_cast<uintptr_t>(mWnd),
reinterpret_cast<uintptr_t>(this), reinterpret_cast<uintptr_t>(static_cast<nsIWidget*>(this)),
mTransparencyMode, mTransparencyMode);
this); mCompositorWidget = new WinCompositorWidget(initData, this);
mLayerManager = CreateBasicLayerManager(); mLayerManager = CreateBasicLayerManager();
} }
@ -3686,16 +3687,6 @@ nsWindow::OnDefaultButtonLoaded(const LayoutDeviceIntRect& aButtonRect)
return NS_OK; return NS_OK;
} }
mozilla::widget::CompositorWidget*
nsWindow::NewCompositorWidget()
{
return new WinCompositorWidget(
mWnd,
reinterpret_cast<uintptr_t>(this),
mTransparencyMode,
this);
}
mozilla::widget::WinCompositorWidget* mozilla::widget::WinCompositorWidget*
nsWindow::GetCompositorWidget() nsWindow::GetCompositorWidget()
{ {
@ -7825,3 +7816,11 @@ DWORD ChildWindow::WindowStyle()
VERIFY_WINDOW_STYLE(style); VERIFY_WINDOW_STYLE(style);
return style; return style;
} }
void
nsWindow::GetCompositorWidgetInitData(mozilla::widget::CompositorWidgetInitData* aInitData)
{
aInitData->hWnd() = reinterpret_cast<uintptr_t>(mWnd);
aInitData->widgetKey() = reinterpret_cast<uintptr_t>(static_cast<nsIWidget*>(this));
aInitData->transparencyMode() = mTransparencyMode;
}

Просмотреть файл

@ -312,7 +312,7 @@ public:
const mozilla::NativeEventData& aKeyEventData, const mozilla::NativeEventData& aKeyEventData,
nsIKeyEventInPluginCallback* aCallback) override; nsIKeyEventInPluginCallback* aCallback) override;
mozilla::widget::CompositorWidget* NewCompositorWidget() override; void GetCompositorWidgetInitData(mozilla::widget::CompositorWidgetInitData* aInitData) override;
protected: protected:
virtual ~nsWindow(); virtual ~nsWindow();