Backed out 6 changesets (bug 1630912) for build bustages on gfxAndroidPlatform.cpp. CLOSED TREE

Backed out changeset 21dc02bc12b9 (bug 1630912)
Backed out changeset 08a6a1f1c4c7 (bug 1630912)
Backed out changeset 108b1a07929b (bug 1630912)
Backed out changeset e202ddeb4e40 (bug 1630912)
Backed out changeset f7d9852a3d09 (bug 1630912)
Backed out changeset e6cd2ceab183 (bug 1630912)
This commit is contained in:
Razvan Maries 2020-05-05 09:04:37 +03:00
Родитель 6754211292
Коммит 2632be905a
15 изменённых файлов: 25 добавлений и 895 удалений

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

@ -15,6 +15,8 @@
#include "VsyncSource.h"
class SoftwareDisplay final : public mozilla::gfx::VsyncSource::Display {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SoftwareDisplay)
public:
SoftwareDisplay();
void EnableVsync() override;
@ -26,9 +28,8 @@ class SoftwareDisplay final : public mozilla::gfx::VsyncSource::Display {
void ScheduleNextVsync(mozilla::TimeStamp aVsyncTimestamp);
void Shutdown() override;
virtual ~SoftwareDisplay();
private:
virtual ~SoftwareDisplay();
mozilla::TimeDuration mVsyncRate;
// Use a chromium thread because nsITimers* fire on the main thread
base::Thread* mVsyncThread;

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

@ -47,20 +47,6 @@ void VsyncSource::DeregisterCompositorVsyncDispatcher(
aCompositorVsyncDispatcher);
}
void VsyncSource::AddGenericObserver(VsyncObserver* aObserver) {
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
GetGlobalDisplay().AddGenericObserver(aObserver);
}
void VsyncSource::RemoveGenericObserver(VsyncObserver* aObserver) {
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
GetGlobalDisplay().RemoveGenericObserver(aObserver);
}
void VsyncSource::MoveListenersToNewSource(
const RefPtr<VsyncSource>& aNewSource) {
GetGlobalDisplay().MoveListenersToNewSource(aNewSource);
@ -100,39 +86,14 @@ void VsyncSource::Display::NotifyVsync(TimeStamp aVsyncTimestamp) {
return;
}
// If the task posted to the main thread from the last NotifyVsync call
// hasn't been processed yet, then don't send another one. Otherwise we might
// end up flooding the main thread.
bool dispatchToMainThread =
(mLastVsyncIdSentToMainThread == mLastMainThreadProcessedVsyncId);
mVsyncId = mVsyncId.Next();
const VsyncEvent event(mVsyncId, aVsyncTimestamp);
VsyncEvent event(mVsyncId, aVsyncTimestamp);
for (size_t i = 0; i < mEnabledCompositorVsyncDispatchers.Length(); i++) {
mEnabledCompositorVsyncDispatchers[i]->NotifyVsync(event);
}
mRefreshTimerVsyncDispatcher->NotifyVsync(event);
if (dispatchToMainThread) {
mLastVsyncIdSentToMainThread = mVsyncId;
NS_DispatchToMainThread(NewRunnableMethod<VsyncEvent>(
"VsyncSource::Display::NotifyGenericObservers", this,
&VsyncSource::Display::NotifyGenericObservers, event));
}
}
void VsyncSource::Display::NotifyGenericObservers(VsyncEvent aEvent) {
MOZ_ASSERT(NS_IsMainThread());
for (size_t i = 0; i < mGenericObservers.Length(); i++) {
mGenericObservers[i]->NotifyVsync(aEvent);
}
{ // Scope lock
MutexAutoLock lock(mDispatcherLock);
mLastMainThreadProcessedVsyncId = aEvent.mId;
}
}
TimeDuration VsyncSource::Display::GetVsyncRate() {
@ -192,22 +153,6 @@ void VsyncSource::Display::DisableCompositorVsyncDispatcher(
UpdateVsyncStatus();
}
void VsyncSource::Display::AddGenericObserver(VsyncObserver* aObserver) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aObserver);
mGenericObservers.AppendElement(aObserver);
UpdateVsyncStatus();
}
void VsyncSource::Display::RemoveGenericObserver(VsyncObserver* aObserver) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aObserver);
mGenericObservers.RemoveElement(aObserver);
UpdateVsyncStatus();
}
void VsyncSource::Display::MoveListenersToNewSource(
const RefPtr<VsyncSource>& aNewSource) {
MOZ_ASSERT(NS_IsMainThread());
@ -218,7 +163,6 @@ void VsyncSource::Display::MoveListenersToNewSource(
std::move(mRegisteredCompositorVsyncDispatchers));
aNewDisplay.mEnabledCompositorVsyncDispatchers.AppendElements(
std::move(mEnabledCompositorVsyncDispatchers));
aNewDisplay.mGenericObservers.AppendElements(std::move(mGenericObservers));
for (size_t i = 0;
i < aNewDisplay.mRegisteredCompositorVsyncDispatchers.Length(); i++) {
@ -248,7 +192,7 @@ void VsyncSource::Display::UpdateVsyncStatus() {
{ // scope lock
MutexAutoLock lock(mDispatcherLock);
enableVsync = !mEnabledCompositorVsyncDispatchers.IsEmpty() ||
mRefreshTimerNeedsVsync || !mGenericObservers.IsEmpty();
mRefreshTimerNeedsVsync;
}
if (enableVsync) {

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

@ -16,8 +16,6 @@
namespace mozilla {
class RefreshTimerVsyncDispatcher;
class CompositorVsyncDispatcher;
class VsyncObserver;
struct VsyncEvent;
class VsyncIdType {};
typedef layers::BaseTransactionId<VsyncIdType> VsyncId;
@ -35,9 +33,9 @@ class VsyncSource {
public:
// Controls vsync unique to each display and unique on each platform
class Display {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Display)
public:
Display();
virtual ~Display();
// Notified when this display's vsync occurs, on the vsync thread
// The aVsyncTimestamp should normalize to the Vsync time that just occured
@ -49,7 +47,6 @@ class VsyncSource {
// Large parts of Gecko assume TimeStamps should not be in the future such
// as animations
virtual void NotifyVsync(TimeStamp aVsyncTimestamp);
void NotifyGenericObservers(VsyncEvent aEvent);
RefPtr<RefreshTimerVsyncDispatcher> GetRefreshTimerVsyncDispatcher();
@ -61,9 +58,6 @@ class VsyncSource {
CompositorVsyncDispatcher* aCompositorVsyncDispatcher);
void DisableCompositorVsyncDispatcher(
CompositorVsyncDispatcher* aCompositorVsyncDispatcher);
void AddGenericObserver(VsyncObserver* aObserver);
void RemoveGenericObserver(VsyncObserver* aObserver);
void MoveListenersToNewSource(const RefPtr<VsyncSource>& aNewSource);
void NotifyRefreshTimerVsyncStatus(bool aEnable);
virtual TimeDuration GetVsyncRate();
@ -74,9 +68,6 @@ class VsyncSource {
virtual bool IsVsyncEnabled() = 0;
virtual void Shutdown() = 0;
protected:
virtual ~Display();
private:
void UpdateVsyncStatus();
@ -87,11 +78,7 @@ class VsyncSource {
nsTArray<RefPtr<CompositorVsyncDispatcher>>
mRegisteredCompositorVsyncDispatchers;
RefPtr<RefreshTimerVsyncDispatcher> mRefreshTimerVsyncDispatcher;
nsTArray<RefPtr<VsyncObserver>>
mGenericObservers; // can only be touched from the main thread
VsyncId mVsyncId;
VsyncId mLastVsyncIdSentToMainThread; // hold mDispatcherLock to touch
VsyncId mLastMainThreadProcessedVsyncId; // hold mDispatcherLock to touch
};
void EnableCompositorVsyncDispatcher(
@ -103,14 +90,6 @@ class VsyncSource {
void DeregisterCompositorVsyncDispatcher(
CompositorVsyncDispatcher* aCompositorVsyncDispatcher);
// Add and remove a generic observer for vsync. Note that keeping an observer
// registered means vsync will keep firing, which may impact power usage. So
// this is intended only for "short term" vsync observers. These methods must
// be called on the parent process main thread, and the observer will likewise
// be notified on the parent process main thread.
void AddGenericObserver(VsyncObserver* aObserver);
void RemoveGenericObserver(VsyncObserver* aObserver);
void MoveListenersToNewSource(const RefPtr<VsyncSource>& aNewSource);
RefPtr<RefreshTimerVsyncDispatcher> GetRefreshTimerVsyncDispatcher();

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

@ -275,8 +275,6 @@ bool gfxAndroidPlatform::RequiresLinearZoom() {
class AndroidVsyncSource final : public VsyncSource {
public:
AndroidVsyncSource() : mGlobalDisplay(new Display()) {}
class JavaVsyncSupport final
: public java::VsyncSource::Natives<JavaVsyncSupport> {
public:
@ -346,11 +344,13 @@ class AndroidVsyncSource final : public VsyncSource {
Display& GetGlobalDisplay() final { return GetDisplayInstance(); }
private:
virtual ~AndroidVsyncSource() = default;
private:
RefPtr<Display> mGlobalDisplay;
static Display& GetDisplayInstance() { return *mGlobalDisplay; }
static Display& GetDisplayInstance() {
static Display globalDisplay;
return globalDisplay;
}
};
already_AddRefed<mozilla::gfx::VsyncSource>

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

@ -500,6 +500,8 @@ class GtkVsyncSource final : public VsyncSource {
virtual Display& GetGlobalDisplay() override { return *mGlobalDisplay; }
class GLXDisplay final : public VsyncSource::Display {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GLXDisplay)
public:
GLXDisplay()
: mGLContext(nullptr),

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

@ -361,9 +361,9 @@ static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink,
class OSXVsyncSource final : public VsyncSource {
public:
OSXVsyncSource() : mGlobalDisplay(new OSXDisplay()) {}
OSXVsyncSource() {}
Display& GetGlobalDisplay() override { return *mGlobalDisplay; }
Display& GetGlobalDisplay() override { return mGlobalDisplay; }
class OSXDisplay final : public VsyncSource::Display {
public:
@ -507,7 +507,7 @@ class OSXVsyncSource final : public VsyncSource {
private:
virtual ~OSXVsyncSource() = default;
RefPtr<OSXDisplay> mGlobalDisplay;
OSXDisplay mGlobalDisplay;
}; // OSXVsyncSource
static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink,

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

@ -1622,6 +1622,7 @@ bool gfxWindowsPlatform::DwmCompositionEnabled() {
class D3DVsyncSource final : public VsyncSource {
public:
class D3DVsyncDisplay final : public VsyncSource::Display {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(D3DVsyncDisplay)
public:
D3DVsyncDisplay()
: mPrevVsync(TimeStamp::Now()),
@ -1866,9 +1867,10 @@ class D3DVsyncSource final : public VsyncSource {
}
} // end for
}
virtual ~D3DVsyncDisplay() { MOZ_ASSERT(NS_IsMainThread()); }
private:
virtual ~D3DVsyncDisplay() { MOZ_ASSERT(NS_IsMainThread()); }
bool IsInVsyncThread() {
return mVsyncThread->thread_id() == PlatformThread::CurrentId();
}

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

@ -571,11 +571,6 @@
value: @IS_NOT_NIGHTLY_BUILD@
mirror: always
- name: apz.windows.use_direct_manipulation
type: RelaxedAtomicBool
value: false
mirror: always
- name: apz.x_skate_highmem_adjust
type: AtomicFloat
value: 0.0f

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

@ -51,6 +51,8 @@ class WaylandVsyncSource final : public gfx::VsyncSource {
struct WaylandFrameCallbackContext;
class WaylandDisplay final : public mozilla::gfx::VsyncSource::Display {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WaylandDisplay);
public:
explicit WaylandDisplay(MozContainer* container);

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

@ -1,636 +0,0 @@
/* -*- 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/. */
#include "DirectManipulationOwner.h"
#include "nsWindow.h"
#include "InputData.h"
#include "mozilla/TimeStamp.h"
// Direct Manipulation is only defined for Win8 and newer.
#if defined(_WIN32_WINNT)
# undef _WIN32_WINNT
# define _WIN32_WINNT _WIN32_WINNT_WIN8
#endif // defined(_WIN32_WINNT)
#if defined(NTDDI_VERSION)
# undef NTDDI_VERSION
# define NTDDI_VERSION NTDDI_WIN8
#endif // defined(NTDDI_VERSION)
#include "directmanipulation.h"
namespace mozilla {
namespace widget {
class DManipEventHandler : public IDirectManipulationViewportEventHandler,
public IDirectManipulationInteractionEventHandler {
public:
typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
friend class DirectManipulationOwner;
NS_INLINE_DECL_REFCOUNTING(DManipEventHandler)
STDMETHODIMP QueryInterface(REFIID, void**) override;
friend class DirectManipulationOwner;
explicit DManipEventHandler(nsWindow* aWindow,
DirectManipulationOwner* aOwner,
const LayoutDeviceIntRect& aBounds);
HRESULT STDMETHODCALLTYPE OnViewportStatusChanged(
IDirectManipulationViewport* viewport, DIRECTMANIPULATION_STATUS current,
DIRECTMANIPULATION_STATUS previous) override;
HRESULT STDMETHODCALLTYPE
OnViewportUpdated(IDirectManipulationViewport* viewport) override;
HRESULT STDMETHODCALLTYPE
OnContentUpdated(IDirectManipulationViewport* viewport,
IDirectManipulationContent* content) override;
HRESULT STDMETHODCALLTYPE
OnInteraction(IDirectManipulationViewport2* viewport,
DIRECTMANIPULATION_INTERACTION_TYPE interaction) override;
void Update();
class VObserver final : public mozilla::VsyncObserver {
public:
bool NotifyVsync(const mozilla::VsyncEvent& aVsync) override {
if (mOwner) {
mOwner->Update();
}
return true;
}
explicit VObserver(DManipEventHandler* aOwner) : mOwner(aOwner) {}
void ClearOwner() { mOwner = nullptr; }
private:
virtual ~VObserver() {}
DManipEventHandler* mOwner;
};
enum class State { eNone, ePanning, eInertia, ePinching };
void TransitionToState(State aNewState);
enum class Phase { eStart, eMiddle, eEnd };
void SendPinch(Phase aPhase, float aScale);
void SendPan(Phase aPhase, float x, float y, bool aIsInertia);
private:
virtual ~DManipEventHandler() = default;
nsWindow* mWindow;
DirectManipulationOwner* mOwner;
RefPtr<VObserver> mObserver;
float mLastScale;
float mLastXOffset;
float mLastYOffset;
LayoutDeviceIntRect mBounds;
bool mShouldSendPanStart;
State mState = State::eNone;
};
DManipEventHandler::DManipEventHandler(nsWindow* aWindow,
DirectManipulationOwner* aOwner,
const LayoutDeviceIntRect& aBounds)
: mWindow(aWindow),
mOwner(aOwner),
mLastScale(1.f),
mLastXOffset(0.f),
mLastYOffset(0.f),
mBounds(aBounds),
mShouldSendPanStart(false) {}
STDMETHODIMP
DManipEventHandler::QueryInterface(REFIID iid, void** ppv) {
const IID IID_IDirectManipulationViewportEventHandler =
__uuidof(IDirectManipulationViewportEventHandler);
const IID IID_IDirectManipulationInteractionEventHandler =
__uuidof(IDirectManipulationInteractionEventHandler);
if ((IID_IUnknown == iid) ||
(IID_IDirectManipulationViewportEventHandler == iid)) {
*ppv = static_cast<IDirectManipulationViewportEventHandler*>(this);
AddRef();
return S_OK;
}
if (IID_IDirectManipulationInteractionEventHandler == iid) {
*ppv = static_cast<IDirectManipulationInteractionEventHandler*>(this);
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
HRESULT
DManipEventHandler::OnViewportStatusChanged(
IDirectManipulationViewport* viewport, DIRECTMANIPULATION_STATUS current,
DIRECTMANIPULATION_STATUS previous) {
if (current == previous) {
return S_OK;
}
if (current == DIRECTMANIPULATION_INERTIA) {
if (previous != DIRECTMANIPULATION_RUNNING || mState != State::ePanning) {
// xxx transition to none?
return S_OK;
}
TransitionToState(State::eInertia);
}
if (current == DIRECTMANIPULATION_RUNNING) {
// INERTIA -> RUNNING, should start a new sequence.
if (previous == DIRECTMANIPULATION_INERTIA) {
TransitionToState(State::eNone);
}
}
if (current != DIRECTMANIPULATION_ENABLED &&
current != DIRECTMANIPULATION_READY) {
return S_OK;
}
// A session has ended, reset the transform.
if (mLastScale != 1.f || mLastXOffset != 0.f || mLastYOffset != 0.f) {
HRESULT hr =
viewport->ZoomToRect(0, 0, mBounds.width, mBounds.height, false);
if (!SUCCEEDED(hr)) {
NS_WARNING("ZoomToRect failed");
}
}
mLastScale = 1.f;
mLastXOffset = 0.f;
mLastYOffset = 0.f;
TransitionToState(State::eNone);
return S_OK;
}
HRESULT
DManipEventHandler::OnViewportUpdated(IDirectManipulationViewport* viewport) {
return S_OK;
}
void DManipEventHandler::TransitionToState(State aNewState) {
if (mState == aNewState) {
return;
}
State prevState = mState;
mState = aNewState;
// End the previous sequence.
switch (prevState) {
case State::ePanning: {
// ePanning -> eNone, ePinching: PanEnd
// ePanning -> eInertia: we don't want to end the current scroll sequence.
if (aNewState != State::eInertia) {
SendPan(Phase::eEnd, 0.f, 0.f, false);
}
break;
}
case State::eInertia: {
// eInertia -> *: MomentumEnd
SendPan(Phase::eEnd, 0.f, 0.f, true);
break;
}
case State::ePinching: {
MOZ_ASSERT(aNewState == State::eNone);
// ePinching -> eNone: PinchEnd. ePinching should only transition to
// eNone.
SendPinch(Phase::eEnd, 0.f);
break;
}
case State::eNone: {
// eNone -> *: no cleanup is needed.
break;
}
default:
MOZ_ASSERT(false);
}
// Start the new sequence.
switch (aNewState) {
case State::ePanning: {
// eInertia, eNone -> ePanning: PanStart.
// We're being called from OnContentUpdated, it has the coords we need to
// pass to SendPan(Phase::eStart), so set mShouldSendPanStart and when we
// return OnContentUpdated will check it and call SendPan(Phase::eStart).
mShouldSendPanStart = true;
break;
}
case State::eInertia: {
// Only ePanning can transition to eInertia.
MOZ_ASSERT(prevState == State::ePanning);
SendPan(Phase::eStart, 0.f, 0.f, true);
break;
}
case State::ePinching: {
// * -> ePinching: PinchStart.
// Pinch gesture may begin with some scroll events.
SendPinch(Phase::eStart, 0.f);
break;
}
case State::eNone: {
// * -> eNone: only cleanup is needed.
break;
}
default:
MOZ_ASSERT(false);
}
}
HRESULT
DManipEventHandler::OnContentUpdated(IDirectManipulationViewport* viewport,
IDirectManipulationContent* content) {
float transform[6];
HRESULT hr = content->GetContentTransform(transform, ARRAYSIZE(transform));
if (!SUCCEEDED(hr)) {
NS_WARNING("GetContentTransform failed");
return S_OK;
}
float windowScale = mWindow ? mWindow->GetDefaultScale().scale : 1.f;
float scale = transform[0];
float xoffset = transform[4] * windowScale;
float yoffset = transform[5] * windowScale;
// Not different from last time.
if (FuzzyEqualsMultiplicative(scale, mLastScale) && xoffset == mLastXOffset &&
yoffset == mLastYOffset) {
return S_OK;
}
// Consider this is a Scroll when scale factor equals 1.0.
if (FuzzyEqualsMultiplicative(scale, 1.f)) {
if (mState == State::eNone || mState == State::eInertia) {
TransitionToState(State::ePanning);
}
} else {
// Pinch gesture may begin with some scroll events.
TransitionToState(State::ePinching);
}
if (mState == State::ePanning) {
if (mShouldSendPanStart) {
SendPan(Phase::eStart, mLastXOffset - xoffset, mLastYOffset - yoffset,
false);
mShouldSendPanStart = false;
} else {
SendPan(Phase::eMiddle, mLastXOffset - xoffset, mLastYOffset - yoffset,
false);
}
} else if (mState == State::eInertia) {
SendPan(Phase::eMiddle, mLastXOffset - xoffset, mLastYOffset - yoffset,
true);
} else if (mState == State::ePinching) {
SendPinch(Phase::eMiddle, scale);
}
mLastScale = scale;
mLastXOffset = xoffset;
mLastYOffset = yoffset;
return S_OK;
}
HRESULT
DManipEventHandler::OnInteraction(
IDirectManipulationViewport2* viewport,
DIRECTMANIPULATION_INTERACTION_TYPE interaction) {
if (interaction == DIRECTMANIPULATION_INTERACTION_BEGIN) {
if (!mObserver) {
mObserver = new VObserver(this);
}
gfxWindowsPlatform::GetPlatform()->GetHardwareVsync()->AddGenericObserver(
mObserver);
}
if (mObserver && interaction == DIRECTMANIPULATION_INTERACTION_END) {
gfxWindowsPlatform::GetPlatform()
->GetHardwareVsync()
->RemoveGenericObserver(mObserver);
}
return S_OK;
}
void DManipEventHandler::Update() {
if (mOwner) {
mOwner->Update();
}
}
void DirectManipulationOwner::Update() {
if (mDmUpdateManager) {
mDmUpdateManager->Update(nullptr);
}
}
DirectManipulationOwner::DirectManipulationOwner(nsWindow* aWindow)
: mWindow(aWindow) {}
DirectManipulationOwner::~DirectManipulationOwner() { Destroy(); }
void DManipEventHandler::SendPinch(Phase aPhase, float aScale) {
PinchGestureInput::PinchGestureType pinchGestureType =
PinchGestureInput::PINCHGESTURE_SCALE;
switch (aPhase) {
case Phase::eStart:
pinchGestureType = PinchGestureInput::PINCHGESTURE_START;
break;
case Phase::eMiddle:
pinchGestureType = PinchGestureInput::PINCHGESTURE_SCALE;
break;
case Phase::eEnd:
pinchGestureType = PinchGestureInput::PINCHGESTURE_END;
break;
default:
MOZ_ASSERT_UNREACHABLE("handle all enum values");
}
PRIntervalTime eventIntervalTime = PR_IntervalNow();
TimeStamp eventTimeStamp = TimeStamp::Now();
Modifiers mods =
MODIFIER_NONE; // xxx should we get getting key state for this?
ExternalPoint screenOffset = ViewAs<ExternalPixel>(
mWindow->WidgetToScreenOffset(),
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent);
POINT cursor_pos;
::GetCursorPos(&cursor_pos);
ScreenPoint position = {(float)cursor_pos.x, (float)cursor_pos.y};
PinchGestureInput event{
pinchGestureType,
eventIntervalTime,
eventTimeStamp,
screenOffset,
position,
100.0 * ((aPhase != Phase::eMiddle) ? 1.f : aScale),
100.0 * ((aPhase != Phase::eMiddle) ? 1.f : mLastScale),
mods};
if (pinchGestureType == PinchGestureInput::PINCHGESTURE_END) {
event.mFocusPoint = PinchGestureInput::BothFingersLifted<ScreenPixel>();
}
if (mWindow) {
mWindow->SendAnAPZEvent(event);
}
}
void DManipEventHandler::SendPan(Phase aPhase, float x, float y,
bool aIsInertia) {
PanGestureInput::PanGestureType panGestureType =
PanGestureInput::PANGESTURE_PAN;
if (aIsInertia) {
switch (aPhase) {
case Phase::eStart:
panGestureType = PanGestureInput::PANGESTURE_MOMENTUMSTART;
break;
case Phase::eMiddle:
panGestureType = PanGestureInput::PANGESTURE_MOMENTUMPAN;
break;
case Phase::eEnd:
panGestureType = PanGestureInput::PANGESTURE_MOMENTUMEND;
break;
default:
MOZ_ASSERT_UNREACHABLE("handle all enum values");
}
} else {
switch (aPhase) {
case Phase::eStart:
panGestureType = PanGestureInput::PANGESTURE_START;
break;
case Phase::eMiddle:
panGestureType = PanGestureInput::PANGESTURE_PAN;
break;
case Phase::eEnd:
panGestureType = PanGestureInput::PANGESTURE_END;
break;
default:
MOZ_ASSERT_UNREACHABLE("handle all enum values");
}
}
PRIntervalTime eventIntervalTime = PR_IntervalNow();
TimeStamp eventTimeStamp = TimeStamp::Now();
Modifiers mods = MODIFIER_NONE;
POINT cursor_pos;
::GetCursorPos(&cursor_pos);
ScreenPoint position = {(float)cursor_pos.x, (float)cursor_pos.y};
PanGestureInput event{panGestureType, eventIntervalTime, eventTimeStamp,
position, ScreenPoint(x, y), mods};
if (mWindow) {
mWindow->SendAnAPZEvent(event);
}
}
void DirectManipulationOwner::Init(const LayoutDeviceIntRect& aBounds) {
HRESULT hr = CoCreateInstance(
CLSID_DirectManipulationManager, nullptr, CLSCTX_INPROC_SERVER,
IID_IDirectManipulationManager, getter_AddRefs(mDmManager));
if (!SUCCEEDED(hr)) {
NS_WARNING("CoCreateInstance(CLSID_DirectManipulationManager failed");
mDmManager = nullptr;
return;
}
hr = mDmManager->GetUpdateManager(IID_IDirectManipulationUpdateManager,
getter_AddRefs(mDmUpdateManager));
if (!SUCCEEDED(hr)) {
NS_WARNING("GetUpdateManager failed");
mDmManager = nullptr;
mDmUpdateManager = nullptr;
return;
}
HWND wnd = static_cast<HWND>(mWindow->GetNativeData(NS_NATIVE_WINDOW));
hr = mDmManager->CreateViewport(nullptr, wnd, IID_IDirectManipulationViewport,
getter_AddRefs(mDmViewport));
if (!SUCCEEDED(hr)) {
NS_WARNING("CreateViewport failed");
mDmManager = nullptr;
mDmUpdateManager = nullptr;
mDmViewport = nullptr;
return;
}
DIRECTMANIPULATION_CONFIGURATION configuration =
DIRECTMANIPULATION_CONFIGURATION_INTERACTION |
DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_X |
DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_Y |
DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_INERTIA |
DIRECTMANIPULATION_CONFIGURATION_RAILS_X |
DIRECTMANIPULATION_CONFIGURATION_RAILS_Y;
if (StaticPrefs::apz_allow_zooming()) {
configuration |= DIRECTMANIPULATION_CONFIGURATION_SCALING;
}
hr = mDmViewport->ActivateConfiguration(configuration);
if (!SUCCEEDED(hr)) {
NS_WARNING("ActivateConfiguration failed");
mDmManager = nullptr;
mDmUpdateManager = nullptr;
mDmViewport = nullptr;
return;
}
hr = mDmViewport->SetViewportOptions(
DIRECTMANIPULATION_VIEWPORT_OPTIONS_MANUALUPDATE);
if (!SUCCEEDED(hr)) {
NS_WARNING("SetViewportOptions failed");
mDmManager = nullptr;
mDmUpdateManager = nullptr;
mDmViewport = nullptr;
return;
}
mDmHandler = new DManipEventHandler(mWindow, this, aBounds);
hr = mDmViewport->AddEventHandler(wnd, mDmHandler.get(),
&mDmViewportHandlerCookie);
if (!SUCCEEDED(hr)) {
NS_WARNING("AddEventHandler failed");
mDmManager = nullptr;
mDmUpdateManager = nullptr;
mDmViewport = nullptr;
mDmHandler = nullptr;
return;
}
RECT rect = {0, 0, aBounds.Width(), aBounds.Height()};
hr = mDmViewport->SetViewportRect(&rect);
if (!SUCCEEDED(hr)) {
NS_WARNING("SetViewportRect failed");
mDmManager = nullptr;
mDmUpdateManager = nullptr;
mDmViewport = nullptr;
mDmHandler = nullptr;
return;
}
hr = mDmManager->Activate(wnd);
if (!SUCCEEDED(hr)) {
NS_WARNING("manager Activate failed");
mDmManager = nullptr;
mDmUpdateManager = nullptr;
mDmViewport = nullptr;
mDmHandler = nullptr;
return;
}
hr = mDmViewport->Enable();
if (!SUCCEEDED(hr)) {
NS_WARNING("mDmViewport->Enable failed");
mDmManager = nullptr;
mDmUpdateManager = nullptr;
mDmViewport = nullptr;
mDmHandler = nullptr;
return;
}
hr = mDmUpdateManager->Update(nullptr);
if (!SUCCEEDED(hr)) {
NS_WARNING("mDmUpdateManager->Update failed");
mDmManager = nullptr;
mDmUpdateManager = nullptr;
mDmViewport = nullptr;
mDmHandler = nullptr;
return;
}
}
void DirectManipulationOwner::ResizeViewport(
const LayoutDeviceIntRect& aBounds) {
if (mDmHandler) {
mDmHandler->mBounds = aBounds;
}
if (mDmViewport) {
RECT rect = {0, 0, aBounds.Width(), aBounds.Height()};
HRESULT hr = mDmViewport->SetViewportRect(&rect);
if (!SUCCEEDED(hr)) {
NS_WARNING("SetViewportRect failed");
}
}
}
void DirectManipulationOwner::Destroy() {
if (mDmHandler) {
mDmHandler->mWindow = nullptr;
mDmHandler->mOwner = nullptr;
if (mDmHandler->mObserver) {
gfxWindowsPlatform::GetPlatform()
->GetHardwareVsync()
->RemoveGenericObserver(mDmHandler->mObserver);
mDmHandler->mObserver->ClearOwner();
mDmHandler->mObserver = nullptr;
}
}
HRESULT hr;
if (mDmViewport) {
hr = mDmViewport->Stop();
if (!SUCCEEDED(hr)) {
NS_WARNING("mDmViewport->Stop() failed");
}
hr = mDmViewport->Disable();
if (!SUCCEEDED(hr)) {
NS_WARNING("mDmViewport->Disable() failed");
}
hr = mDmViewport->RemoveEventHandler(mDmViewportHandlerCookie);
if (!SUCCEEDED(hr)) {
NS_WARNING("mDmViewport->RemoveEventHandler() failed");
}
hr = mDmViewport->Abandon();
if (!SUCCEEDED(hr)) {
NS_WARNING("mDmViewport->Abandon() failed");
}
}
HWND wnd = static_cast<HWND>(mWindow->GetNativeData(NS_NATIVE_WINDOW));
if (mDmManager) {
hr = mDmManager->Deactivate(wnd);
if (!SUCCEEDED(hr)) {
NS_WARNING("mDmManager->Deactivate() failed");
}
}
mDmHandler = nullptr;
mDmViewport = nullptr;
mDmUpdateManager = nullptr;
mDmManager = nullptr;
mWindow = nullptr;
}
void DirectManipulationOwner::SetContact(UINT aContactId) {
if (mDmViewport) {
mDmViewport->SetContact(aContactId);
}
}
} // namespace widget
} // namespace mozilla

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

@ -1,48 +0,0 @@
/* -*- 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 DirectManipulationOwner_h__
#define DirectManipulationOwner_h__
#include "Units.h"
#include "WinDef.h"
class nsWindow;
class IDirectManipulationManager;
class IDirectManipulationUpdateManager;
class IDirectManipulationViewport;
namespace mozilla {
namespace widget {
class DManipEventHandler;
class DirectManipulationOwner {
public:
typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
explicit DirectManipulationOwner(nsWindow* aWindow);
~DirectManipulationOwner();
void Init(const LayoutDeviceIntRect& aBounds);
void ResizeViewport(const LayoutDeviceIntRect& aBounds);
void Destroy();
void SetContact(UINT aContactId);
void Update();
private:
nsWindow* mWindow;
DWORD mDmViewportHandlerCookie;
RefPtr<IDirectManipulationManager> mDmManager;
RefPtr<IDirectManipulationUpdateManager> mDmUpdateManager;
RefPtr<IDirectManipulationViewport> mDmViewport;
RefPtr<DManipEventHandler> mDmHandler;
};
} // namespace widget
} // namespace mozilla
#endif // #ifndef DirectManipulationOwner_h__

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

@ -106,11 +106,6 @@ SOURCES += [
'WinMouseScrollHandler.cpp',
]
# These files redefine the winsdk api version macro and we don't want it to leak to other files.
SOURCES += [
'DirectManipulationOwner.cpp',
]
# Needs INITGUID and we don't allow INITGUID in unified sources since bug 970429.
SOURCES += [
'InputDeviceUtils.cpp',

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

@ -65,7 +65,6 @@
#include "mozilla/MiscEvents.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/ipc/MessageChannel.h"
#include <algorithm>
@ -213,9 +212,6 @@
#include "mozilla/Telemetry.h"
#include "mozilla/plugins/PluginProcessParent.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "mozilla/layers/IAPZCTreeManager.h"
#include "DirectManipulationOwner.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -716,72 +712,6 @@ static bool ShouldCacheTitleBarInfo(nsWindowType aWindowType,
!nsUXThemeData::sTitlebarInfoPopulatedAero);
}
void nsWindow::SendAnAPZEvent(InputData& aEvent) {
APZEventResult result;
if (mAPZC) {
result = mAPZC->InputBridge()->ReceiveInputEvent(aEvent);
}
if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
return;
}
MOZ_ASSERT(aEvent.mInputType == PANGESTURE_INPUT ||
aEvent.mInputType == PINCHGESTURE_INPUT);
if (aEvent.mInputType == PANGESTURE_INPUT) {
PanGestureInput& panInput = aEvent.AsPanGestureInput();
WidgetWheelEvent event = panInput.ToWidgetWheelEvent(this);
ProcessUntransformedAPZEvent(&event, result);
return;
}
PinchGestureInput& pinchInput = aEvent.AsPinchGestureInput();
WidgetWheelEvent event = pinchInput.ToWidgetWheelEvent(this);
ProcessUntransformedAPZEvent(&event, result);
}
void nsWindow::RecreateDirectManipulationIfNeeded() {
DestroyDirectManipulation();
if (mWindowType != eWindowType_toplevel && mWindowType != eWindowType_popup) {
return;
}
if (!StaticPrefs::apz_windows_use_direct_manipulation() ||
StaticPrefs::apz_windows_force_disable_direct_manipulation()) {
return;
}
if (!IsWin10OrLater()) {
// Chrome source said the Windows Direct Manipulation implementation had
// important bugs until Windows 10 (although IE on Windows 8.1 seems to use
// Direct Manipulation).
return;
}
mDmOwner = MakeUnique<DirectManipulationOwner>(this);
LayoutDeviceIntRect bounds(mBounds.X(), mBounds.Y(), mBounds.Width(),
GetHeight(mBounds.Height()));
mDmOwner->Init(bounds);
}
void nsWindow::ResizeDirectManipulationViewport() {
if (mDmOwner) {
LayoutDeviceIntRect bounds(mBounds.X(), mBounds.Y(), mBounds.Width(),
GetHeight(mBounds.Height()));
mDmOwner->ResizeViewport(bounds);
}
}
void nsWindow::DestroyDirectManipulation() {
if (mDmOwner) {
mDmOwner->Destroy();
mDmOwner.reset();
}
}
// Create the proper widget
nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
const LayoutDeviceIntRect& aRect,
@ -985,9 +915,6 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
::PostMessage(mWnd, MOZ_WM_STARTA11Y, 0, 0);
}
}
RecreateDirectManipulationIfNeeded();
return NS_OK;
}
@ -1005,8 +932,6 @@ void nsWindow::Destroy() {
// deleted.
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
DestroyDirectManipulation();
/**
* On windows the LayerManagerOGL destructor wants the widget to be around for
* cleanup. It also would like to have the HWND intact, so we nullptr it here.
@ -1302,7 +1227,6 @@ void nsWindow::SetParent(nsIWidget* aNewParent) {
if (mWnd) {
// If we have no parent, SetParent should return the desktop.
VERIFY(::SetParent(mWnd, nullptr));
RecreateDirectManipulationIfNeeded();
}
}
@ -1317,7 +1241,6 @@ void nsWindow::ReparentNativeWidget(nsIWidget* aNewParent) {
NS_ASSERTION(newParent, "Parent widget has a null native window handle");
if (newParent && mWnd) {
::SetParent(mWnd, newParent);
RecreateDirectManipulationIfNeeded();
}
}
@ -1895,8 +1818,6 @@ void nsWindow::Move(double aX, double aY) {
}
SetThemeRegion();
ResizeDirectManipulationViewport();
}
NotifyRollupGeometryChange();
}
@ -1943,8 +1864,6 @@ void nsWindow::Resize(double aWidth, double aHeight, bool aRepaint) {
ChangedDPI();
}
SetThemeRegion();
ResizeDirectManipulationViewport();
}
if (aRepaint) Invalidate();
@ -2003,8 +1922,6 @@ void nsWindow::Resize(double aX, double aY, double aWidth, double aHeight,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
SetThemeRegion();
ResizeDirectManipulationViewport();
}
if (aRepaint) Invalidate();
@ -3584,7 +3501,6 @@ void nsWindow::SetNativeData(uint32_t aDataType, uintptr_t aVal) {
? mWnd
: WinUtils::GetTopLevelHWND(mWnd);
SetChildStyleAndParent(childHwnd, parentHwnd);
RecreateDirectManipulationIfNeeded();
break;
}
default:
@ -5691,17 +5607,6 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
}
break;
case DM_POINTERHITTEST:
if (mDmOwner) {
UINT contactId = GET_POINTERID_WPARAM(wParam);
POINTER_INPUT_TYPE pointerType;
if (mPointerEvents.GetPointerType(contactId, &pointerType) &&
pointerType == PT_TOUCHPAD) {
mDmOwner->SetContact(contactId);
}
}
break;
case WM_LBUTTONDBLCLK:
result = DispatchMouseEvent(eMouseDoubleClick, wParam, lParam, false,
MouseButton::eLeft, MOUSE_INPUT_SOURCE());

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

@ -30,7 +30,6 @@
#include "mozilla/TimeStamp.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/dom/MouseEventBinding.h"
#include "mozilla/UniquePtr.h"
#include "nsMargin.h"
#include "nsRegionFwd.h"
@ -63,7 +62,6 @@ namespace widget {
class NativeKey;
class InProcessWinCompositorWidget;
struct MSGResult;
class DirectManipulationOwner;
} // namespace widget
} // namespace mozilla
@ -111,8 +109,6 @@ class nsWindow final : public nsWindowBase {
friend class nsWindowGfx;
void SendAnAPZEvent(mozilla::InputData& aEvent);
// nsWindowBase
virtual void InitEvent(mozilla::WidgetGUIEvent& aEvent,
LayoutDeviceIntPoint* aPoint = nullptr) override;
@ -568,10 +564,6 @@ class nsWindow final : public nsWindowBase {
void CreateCompositor() override;
void RequestFxrOutput();
void RecreateDirectManipulationIfNeeded();
void ResizeDirectManipulationViewport();
void DestroyDirectManipulation();
protected:
nsCOMPtr<nsIWidget> mParent;
nsIntSize mLastSize;
@ -736,8 +728,6 @@ class nsWindow final : public nsWindowBase {
// When true, used to indicate an async call to RequestFxrOutput to the GPU
// process after the Compositor is created
bool mRequestFxrOutputPending;
mozilla::UniquePtr<mozilla::widget::DirectManipulationOwner> mDmOwner;
};
#endif // Window_h__

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

@ -15,11 +15,10 @@
# define TOUCH_FEEDBACK_NONE 0x3
enum {
PT_POINTER = 0x00000001, // Generic pointer
PT_TOUCH = 0x00000002, // Touch
PT_PEN = 0x00000003, // Pen
PT_MOUSE = 0x00000004, // Mouse
PT_TOUCHPAD = 0x00000005, // Touch pad
PT_POINTER = 0x00000001, // Generic pointer
PT_TOUCH = 0x00000002, // Touch
PT_PEN = 0x00000003, // Pen
PT_MOUSE = 0x00000004, // Mouse
};
typedef DWORD POINTER_INPUT_TYPE;