mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1737722. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D145721
This commit is contained in:
parent
b88de56b32
commit
24843e3503
@ -12,6 +12,7 @@
|
||||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
#include "nsDebug.h" // for NS_ASSERTION
|
||||
#include "nsIXULRuntime.h" // for FissionAutostart
|
||||
#include "mozilla/gfx/Matrix.h"
|
||||
|
||||
#define APZCTM_LOG(...) \
|
||||
MOZ_LOG(APZCTreeManager::sLog, LogLevel::Debug, (__VA_ARGS__))
|
||||
@ -22,6 +23,53 @@ namespace layers {
|
||||
using mozilla::gfx::CompositorHitTestFlags;
|
||||
using mozilla::gfx::CompositorHitTestInvisibleToHit;
|
||||
|
||||
static bool CheckCloseToIdentity(const gfx::Matrix4x4& aMatrix) {
|
||||
// We allow a factor of 1/2048 in the multiply part of the matrix, so that if
|
||||
// we multiply by a point on a screen of size 2048 we would be off by at most
|
||||
// 1 pixel approximately.
|
||||
const float multiplyEps = 1 / 2048.f;
|
||||
// We allow 1 pixel in the translate part of the matrix.
|
||||
const float translateEps = 1.f;
|
||||
|
||||
if (!FuzzyEqualsAdditive(aMatrix._11, 1.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._12, 0.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._13, 0.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._14, 0.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._21, 0.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._22, 1.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._23, 0.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._24, 0.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._31, 0.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._32, 0.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._33, 1.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._34, 0.f, multiplyEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._41, 0.f, translateEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._42, 0.f, translateEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._43, 0.f, translateEps) ||
|
||||
!FuzzyEqualsAdditive(aMatrix._44, 1.f, multiplyEps)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Checks that within the constraints of floating point math we can invert it
|
||||
// reasonably enough that multiplying by the computed inverse is close to the
|
||||
// identity.
|
||||
static bool CheckInvertibleWithFinitePrecision(const gfx::Matrix4x4& aMatrix) {
|
||||
auto inverse = aMatrix.MaybeInverse();
|
||||
if (inverse.isNothing()) {
|
||||
// Should we return false?
|
||||
return true;
|
||||
}
|
||||
if (!CheckCloseToIdentity(aMatrix * *inverse)) {
|
||||
return false;
|
||||
}
|
||||
if (!CheckCloseToIdentity(*inverse * aMatrix)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
IAPZHitTester::HitTestResult WRHitTester::GetAPZCAtPoint(
|
||||
const ScreenPoint& aHitTestPoint,
|
||||
const RecursiveMutexAutoLock& aProofOfTreeLock) {
|
||||
@ -96,6 +144,19 @@ IAPZHitTester::HitTestResult WRHitTester::GetAPZCAtPoint(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!CheckInvertibleWithFinitePrecision(
|
||||
mTreeManager->GetScreenToApzcTransform(node->GetApzc())
|
||||
.ToUnknownMatrix())) {
|
||||
APZCTM_LOG("skipping due to check inverse accuracy\n");
|
||||
continue;
|
||||
}
|
||||
if (!CheckInvertibleWithFinitePrecision(
|
||||
mTreeManager->GetApzcToGeckoTransform(node->GetApzc())
|
||||
.ToUnknownMatrix())) {
|
||||
APZCTM_LOG("skipping due to check inverse accuracy\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
APZCTM_LOG("selecting as chosen result.\n");
|
||||
chosenResult = Some(result);
|
||||
hit.mTargetApzc = node->GetApzc();
|
||||
|
Loading…
Reference in New Issue
Block a user