diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
commit | 9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /gfx/layers/apz/public/APZPublicUtils.h | |
parent | Initial commit. (diff) | |
download | thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/layers/apz/public/APZPublicUtils.h')
-rw-r--r-- | gfx/layers/apz/public/APZPublicUtils.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/gfx/layers/apz/public/APZPublicUtils.h b/gfx/layers/apz/public/APZPublicUtils.h new file mode 100644 index 0000000000..6433008b4c --- /dev/null +++ b/gfx/layers/apz/public/APZPublicUtils.h @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 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/. */ + +#ifndef mozilla_layers_APZPublicUtils_h +#define mozilla_layers_APZPublicUtils_h + +// This file is for APZ-related utilities that need to be consumed from outside +// of gfx/layers. For internal utilities, prefer APZUtils.h. + +#include <stdint.h> +#include <utility> +#include "ScrollAnimationBezierPhysics.h" +#include "Units.h" +#include "mozilla/DefineEnum.h" +#include "mozilla/ScrollOrigin.h" +#include "mozilla/gfx/Point.h" +#include "mozilla/ScrollTypes.h" + +namespace mozilla { + +namespace layers { + +struct FrameMetrics; + +// clang-format off +MOZ_DEFINE_ENUM_CLASS_WITH_BASE(APZWheelAction, uint8_t, ( + Scroll, + PinchZoom +)) +// clang-format on + +namespace apz { + +/** + * Initializes the global state used in AsyncPanZoomController. + * This is normally called when it is first needed in the constructor + * of APZCTreeManager, but can be called manually to force it to be + * initialized earlier. + */ +void InitializeGlobalState(); + +/** + * See AsyncPanZoomController::CalculatePendingDisplayPort. This + * function simply delegates to that one, so that non-layers code + * never needs to include AsyncPanZoomController.h + */ +const ScreenMargin CalculatePendingDisplayPort( + const FrameMetrics& aFrameMetrics, const ParentLayerPoint& aVelocity); + +/** + * Returns a width and height multiplier, each of which is a power of two + * between 1 and 8 inclusive. The multiplier is chosen based on the provided + * base size, such that multiplier is larger when the base size is larger. + * The exact details are somewhat arbitrary and tuned by hand. + * This function is intended to only be used with WebRender, because that is + * the codepath that wants to use a larger displayport alignment, because + * moving the displayport is relatively expensive with WebRender. + */ +gfx::IntSize GetDisplayportAlignmentMultiplier(const ScreenSize& aBaseSize); + +/** + * Calculate the physics parameters for smooth scroll animations for the + * given origin, based on pref values. + */ +ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin( + ScrollOrigin aOrigin); + +/** + * Calculate if the scrolling should be instant or smooth based based on + * preferences and the origin + */ +ScrollMode GetScrollModeForOrigin(ScrollOrigin origin); + +} // namespace apz + +} // namespace layers +} // namespace mozilla + +#endif // mozilla_layers_APZPublicUtils_h |