1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_layers_APZPublicUtils_h 8 #define mozilla_layers_APZPublicUtils_h 9 10 // This file is for APZ-related utilities that need to be consumed from outside 11 // of gfx/layers. For internal utilities, prefer APZUtils.h. 12 13 #include <stdint.h> 14 #include <utility> 15 #include "ScrollAnimationBezierPhysics.h" 16 #include "Units.h" 17 #include "mozilla/DefineEnum.h" 18 #include "mozilla/ScrollOrigin.h" 19 #include "mozilla/gfx/Point.h" 20 21 namespace mozilla { 22 23 namespace layers { 24 25 struct FrameMetrics; 26 27 // clang-format off 28 MOZ_DEFINE_ENUM_CLASS_WITH_BASE(APZWheelAction, uint8_t, ( 29 Scroll, 30 PinchZoom 31 )) 32 // clang-format on 33 34 namespace apz { 35 36 /** 37 * Initializes the global state used in AsyncPanZoomController. 38 * This is normally called when it is first needed in the constructor 39 * of APZCTreeManager, but can be called manually to force it to be 40 * initialized earlier. 41 */ 42 void InitializeGlobalState(); 43 44 /** 45 * See AsyncPanZoomController::CalculatePendingDisplayPort. This 46 * function simply delegates to that one, so that non-layers code 47 * never needs to include AsyncPanZoomController.h 48 */ 49 const ScreenMargin CalculatePendingDisplayPort( 50 const FrameMetrics& aFrameMetrics, const ParentLayerPoint& aVelocity); 51 52 /** 53 * Returns a width and height multiplier, each of which is a power of two 54 * between 1 and 8 inclusive. The multiplier is chosen based on the provided 55 * base size, such that multiplier is larger when the base size is larger. 56 * The exact details are somewhat arbitrary and tuned by hand. 57 * This function is intended to only be used with WebRender, because that is 58 * the codepath that wants to use a larger displayport alignment, because 59 * moving the displayport is relatively expensive with WebRender. 60 */ 61 gfx::IntSize GetDisplayportAlignmentMultiplier(const ScreenSize& aBaseSize); 62 63 /** 64 * Calculate the physics parameters for smooth scroll animations for the 65 * given origin, based on pref values. 66 */ 67 ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin( 68 ScrollOrigin aOrigin); 69 70 } // namespace apz 71 72 } // namespace layers 73 } // namespace mozilla 74 75 #endif // mozilla_layers_APZPublicUtils_h 76