Bug 1764201 Part 3: Remove screen info stuff from gfxPlatform. r=jgilbert,geckoview...
[gecko.git] / gfx / layers / apz / src / SampledAPZCState.h
bloba521eeaf87988dd00d98adf6fc2386fa0becba60
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/. */
7 #ifndef mozilla_layers_SampledAPZCState_h
8 #define mozilla_layers_SampledAPZCState_h
10 #include "FrameMetrics.h"
11 #include "mozilla/Maybe.h"
12 #include "mozilla/ScrollGeneration.h"
14 namespace mozilla {
15 namespace layers {
17 class SampledAPZCState {
18 public:
19 SampledAPZCState();
20 explicit SampledAPZCState(const FrameMetrics& aMetrics);
21 SampledAPZCState(const FrameMetrics& aMetrics,
22 Maybe<CompositionPayload>&& aPayload,
23 APZScrollGeneration aGeneration);
25 bool operator==(const SampledAPZCState& aOther) const;
26 bool operator!=(const SampledAPZCState& aOther) const;
28 CSSRect GetLayoutViewport() const { return mLayoutViewport; }
29 CSSPoint GetVisualScrollOffset() const { return mVisualScrollOffset; }
30 CSSToParentLayerScale GetZoom() const { return mZoom; }
31 Maybe<CompositionPayload> TakeScrollPayload();
32 const APZScrollGeneration& Generation() const { return mGeneration; }
34 void UpdateScrollProperties(const FrameMetrics& aMetrics);
35 void UpdateScrollPropertiesWithRelativeDelta(const FrameMetrics& aMetrics,
36 const CSSPoint& aRelativeDelta);
38 void UpdateZoomProperties(const FrameMetrics& aMetrics);
40 /**
41 * Re-clamp mVisualScrollOffset to the scroll range specified by the provided
42 * metrics. This only needs to be called if the scroll offset changes
43 * outside of AsyncPanZoomController::SampleCompositedAsyncTransform().
44 * It also recalculates mLayoutViewport so that it continues to enclose
45 * the visual viewport. This only needs to be called if the
46 * layout viewport changes outside of SampleCompositedAsyncTransform().
48 void ClampVisualScrollOffset(const FrameMetrics& aMetrics);
50 void ZoomBy(float aScale);
52 private:
53 // These variables cache the layout viewport, scroll offset, and zoom stored
54 // in |Metrics()| at the time this class was constructed.
55 CSSRect mLayoutViewport;
56 CSSPoint mVisualScrollOffset;
57 CSSToParentLayerScale mZoom;
58 // An optional payload that rides along with the sampled state.
59 Maybe<CompositionPayload> mScrollPayload;
60 APZScrollGeneration mGeneration;
62 void RemoveFractionalAsyncDelta();
63 // A handy wrapper to call
64 // FrameMetrics::KeepLayoutViewportEnclosingVisualViewport with this
65 // SampledAPZCState and the given |aMetrics|.
66 void KeepLayoutViewportEnclosingVisualViewport(const FrameMetrics& aMetrics);
69 } // namespace layers
70 } // namespace mozilla
72 #endif // mozilla_layers_SampledAPZCState_h