gecko-dev/widget/windows/CompositorWidgetParent.h
Chris Martin cebb0d2c6c Bug 1604412 - Clarify purpose of PlatformCompositorWidgetDelegate r=sotaro
PlatformCompositorWidgetDelegate was meant to be a pure virtual base
class for all the functions that nsWindow could call that would
either go to an in-process compositor widget or an OMTC widget.

By that definition, it does not seem like CompositorWidgetParent should
be a subclass, since nsWindow cannot directly call its methods and
currently CompositorWidgetParent has several "do nothing"
implementations of the interface methods because they don't really
belong.

This changeset remedies this by refactoring CompositorWidgetParent so
it is no longer an implementor of PlatformCompositorWidgetDelegate. Now
the only implementors are CompositorWidgetChild and InProcessWin-
CompositorWidget, which makes sense because they are both directly
called through the nsWindow delegate.

It also eliminates some of the methods that seem like they don't belong
in PlatformCompositorWidgetDelegate.

Differential Revision: https://phabricator.services.mozilla.com/D57429

--HG--
extra : moz-landing-system : lando
2020-01-08 18:36:30 +00:00

90 lines
3.1 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 widget_windows_CompositorWidgetParent_h
#define widget_windows_CompositorWidgetParent_h
#include "WinCompositorWidget.h"
#include "mozilla/Maybe.h"
#include "mozilla/widget/PCompositorWidgetParent.h"
namespace mozilla {
namespace widget {
class CompositorWidgetParent final : public PCompositorWidgetParent,
public WinCompositorWidget {
public:
explicit CompositorWidgetParent(const CompositorWidgetInitData& aInitData,
const layers::CompositorOptions& aOptions);
~CompositorWidgetParent() override;
bool PreRender(WidgetRenderingContext*) override;
void PostRender(WidgetRenderingContext*) override;
already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
void EndRemoteDrawing() override;
bool NeedsToDeferEndRemoteDrawing() override;
LayoutDeviceIntSize GetClientSize() override;
already_AddRefed<gfx::DrawTarget> GetBackBufferDrawTarget(
gfx::DrawTarget* aScreenTarget, const gfx::IntRect& aRect,
bool* aOutIsCleared) override;
already_AddRefed<gfx::SourceSurface> EndBackBufferDrawing() override;
bool InitCompositor(layers::Compositor* aCompositor) override;
bool IsHidden() const override;
bool HasGlass() const override;
mozilla::ipc::IPCResult RecvEnterPresentLock() override;
mozilla::ipc::IPCResult RecvLeavePresentLock() override;
mozilla::ipc::IPCResult RecvUpdateTransparency(
const nsTransparencyMode& aMode) override;
mozilla::ipc::IPCResult RecvClearTransparentWindow() override;
void ActorDestroy(ActorDestroyReason aWhy) override;
nsIWidget* RealWidget() override;
void ObserveVsync(VsyncObserver* aObserver) override;
RefPtr<VsyncObserver> GetVsyncObserver() const override;
// PlatformCompositorWidgetDelegate Overrides
void UpdateCompositorWnd(const HWND aCompositorWnd,
const HWND aParentWnd) override;
void SetRootLayerTreeID(const layers::LayersId& aRootLayerTreeId) override;
private:
bool RedrawTransparentWindow();
// Ensure that a transparent surface exists, then return it.
RefPtr<gfxASurface> EnsureTransparentSurface();
HDC GetWindowSurface();
void FreeWindowSurface(HDC dc);
void CreateTransparentSurface(const gfx::IntSize& aSize);
RefPtr<VsyncObserver> mVsyncObserver;
Maybe<layers::LayersId> mRootLayerTreeID;
HWND mWnd;
gfx::CriticalSection mPresentLock;
// Transparency handling.
mozilla::Mutex mTransparentSurfaceLock;
mozilla::Atomic<nsTransparencyMode, MemoryOrdering::Relaxed>
mTransparencyMode;
RefPtr<gfxASurface> mTransparentSurface;
HDC mMemoryDC;
HDC mCompositeDC;
// Locked back buffer of BasicCompositor
uint8_t* mLockedBackBufferData;
bool mNotDeferEndRemoteDrawing;
};
} // namespace widget
} // namespace mozilla
#endif // widget_windows_CompositorWidgetParent_h