Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ |
| 6 | #define UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ |
| 7 | |
Jonathan Ross | 4ee1006 | 2022-12-20 14:39:57 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 10 | #include "base/memory/raw_ptr.h" |
Lei Zhang | 8f2f80a | 2022-11-03 18:36:09 | [diff] [blame] | 11 | #include "base/memory/scoped_refptr.h" |
Peter Kasting | 809cfe7 | 2020-08-04 00:56:13 | [diff] [blame] | 12 | #include "base/numerics/safe_conversions.h" |
Jonathan Ross | be6a070 | 2021-02-23 01:01:56 | [diff] [blame] | 13 | #include "base/time/time.h" |
Fady Samuel | dba483c | 2018-05-30 04:42:35 | [diff] [blame] | 14 | #include "cc/layers/deadline_policy.h" |
Fady Samuel | ac325ce | 2018-06-01 15:23:27 | [diff] [blame] | 15 | #include "components/viz/client/frame_evictor.h" |
Eric Karl | b6d3d74d | 2019-07-17 21:43:47 | [diff] [blame] | 16 | #include "components/viz/common/frame_sinks/begin_frame_args.h" |
danakj | f20f450 | 2017-09-26 17:13:31 | [diff] [blame] | 17 | #include "components/viz/common/frame_sinks/copy_output_request.h" |
Daniel Libby | 58389b7 | 2019-06-11 20:03:43 | [diff] [blame] | 18 | #include "components/viz/common/frame_timing_details_map.h" |
Fady Samuel | 4f7f0fb3 | 2017-07-28 15:33:37 | [diff] [blame] | 19 | #include "components/viz/common/resources/returned_resource.h" |
Jonathan Ross | 4ee1006 | 2022-12-20 14:39:57 | [diff] [blame] | 20 | #include "components/viz/common/surfaces/surface_id.h" |
Fady Samuel | 1a21156e | 2017-07-13 04:57:29 | [diff] [blame] | 21 | #include "components/viz/common/surfaces/surface_info.h" |
Fady Samuel | bac0f1a | 2017-08-02 15:54:02 | [diff] [blame] | 22 | #include "components/viz/host/host_frame_sink_client.h" |
Jonathan Ross | 95bab10 | 2022-10-14 14:10:24 | [diff] [blame] | 23 | #include "third_party/blink/public/common/page/content_to_visible_time_reporter.h" |
| 24 | #include "third_party/blink/public/mojom/widget/record_content_to_visible_time_request.mojom.h" |
Peilin Wang | 1187e4e8 | 2025-02-10 08:53:29 | [diff] [blame] | 25 | #include "ui/android/browser_controls_offset_tag_definitions.h" |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 26 | #include "ui/android/ui_android_export.h" |
Peilin Wang | a1e9e2ea | 2024-05-14 14:44:59 | [diff] [blame] | 27 | #include "ui/android/window_android_compositor.h" |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 28 | |
Bo Liu | 6ee5d039 | 2023-01-30 20:30:27 | [diff] [blame] | 29 | namespace cc::slim { |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 30 | class SurfaceLayer; |
Bo Liu | 6ee5d039 | 2023-01-30 20:30:27 | [diff] [blame] | 31 | } |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 32 | |
kylechar | a090016 | 2017-07-14 17:35:25 | [diff] [blame] | 33 | namespace viz { |
kylechar | a090016 | 2017-07-14 17:35:25 | [diff] [blame] | 34 | class HostFrameSinkManager; |
| 35 | } // namespace viz |
| 36 | |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 37 | namespace ui { |
| 38 | class ViewAndroid; |
| 39 | class WindowAndroidCompositor; |
| 40 | |
| 41 | class UI_ANDROID_EXPORT DelegatedFrameHostAndroid |
Eric Karl | b6d3d74d | 2019-07-17 21:43:47 | [diff] [blame] | 42 | : public viz::HostFrameSinkClient, |
Fady Samuel | ac325ce | 2018-06-01 15:23:27 | [diff] [blame] | 43 | public viz::FrameEvictorClient { |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 44 | public: |
Peilin Wang | a1e9e2ea | 2024-05-14 14:44:59 | [diff] [blame] | 45 | class Client : public WindowAndroidCompositor::FrameSubmissionObserver { |
eseckler | 8c15fc3 | 2016-12-20 20:22:20 | [diff] [blame] | 46 | public: |
Peilin Wang | a1e9e2ea | 2024-05-14 14:44:59 | [diff] [blame] | 47 | ~Client() override {} |
Jonathan Ross | be6a070 | 2021-02-23 01:01:56 | [diff] [blame] | 48 | virtual void OnFrameTokenChanged(uint32_t frame_token, |
| 49 | base::TimeTicks activation_time) = 0; |
Saman Sami | 4580e632 | 2018-10-21 03:46:59 | [diff] [blame] | 50 | virtual void WasEvicted() = 0; |
Alexander Cooper | f11d8fb | 2021-04-07 01:54:36 | [diff] [blame] | 51 | virtual void OnSurfaceIdChanged() = 0; |
Jonathan Ross | 4ee1006 | 2022-12-20 14:39:57 | [diff] [blame] | 52 | virtual std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() |
| 53 | const = 0; |
eseckler | 8c15fc3 | 2016-12-20 20:22:20 | [diff] [blame] | 54 | }; |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 55 | |
| 56 | DelegatedFrameHostAndroid(ViewAndroid* view, |
kylechar | a090016 | 2017-07-14 17:35:25 | [diff] [blame] | 57 | viz::HostFrameSinkManager* host_frame_sink_manager, |
xlai | 9351829f | 2017-01-27 18:39:13 | [diff] [blame] | 58 | Client* client, |
Eric Karl | b6d3d74d | 2019-07-17 21:43:47 | [diff] [blame] | 59 | const viz::FrameSinkId& frame_sink_id); |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 60 | |
Peter Boström | c8c1235 | 2021-09-21 23:37:15 | [diff] [blame] | 61 | DelegatedFrameHostAndroid(const DelegatedFrameHostAndroid&) = delete; |
| 62 | DelegatedFrameHostAndroid& operator=(const DelegatedFrameHostAndroid&) = |
| 63 | delete; |
| 64 | |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 65 | ~DelegatedFrameHostAndroid() override; |
| 66 | |
Bo Liu | 140aa0c | 2020-09-14 14:09:56 | [diff] [blame] | 67 | static int64_t TimeDeltaToFrames(base::TimeDelta delta) { |
| 68 | return base::ClampRound<int64_t>(delta / |
| 69 | viz::BeginFrameArgs::DefaultInterval()); |
| 70 | } |
| 71 | |
Fady Samuel | 99ec37a | 2018-07-16 21:43:47 | [diff] [blame] | 72 | // Wait up to 5 seconds for the first frame to be produced. Having Android |
| 73 | // display a placeholder for a longer period of time is preferable to drawing |
| 74 | // nothing, and the first frame can take a while on low-end systems. |
| 75 | static constexpr base::TimeDelta FirstFrameTimeout() { |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame] | 76 | return base::Seconds(5); |
Fady Samuel | 99ec37a | 2018-07-16 21:43:47 | [diff] [blame] | 77 | } |
Peter Kasting | 809cfe7 | 2020-08-04 00:56:13 | [diff] [blame] | 78 | static int64_t FirstFrameTimeoutFrames() { |
Bo Liu | 140aa0c | 2020-09-14 14:09:56 | [diff] [blame] | 79 | return TimeDeltaToFrames(FirstFrameTimeout()); |
Fady Samuel | 99ec37a | 2018-07-16 21:43:47 | [diff] [blame] | 80 | } |
| 81 | |
Jonathan Ross | d8f29e2e | 2021-05-21 15:30:19 | [diff] [blame] | 82 | // Wait up to 175 milliseconds for a frame of the correct size to be produced. |
| 83 | // Android OS will only wait 200 milliseconds, so we limit this to make sure |
| 84 | // that Viz is able to produce the latest frame from the Browser before the OS |
| 85 | // stops waiting. Otherwise a rotated version of the previous frame will be |
| 86 | // displayed with a large black region where there is no content yet. |
Fady Samuel | 99ec37a | 2018-07-16 21:43:47 | [diff] [blame] | 87 | static constexpr base::TimeDelta ResizeTimeout() { |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame] | 88 | return base::Milliseconds(175); |
Fady Samuel | 99ec37a | 2018-07-16 21:43:47 | [diff] [blame] | 89 | } |
Peter Kasting | 809cfe7 | 2020-08-04 00:56:13 | [diff] [blame] | 90 | static int64_t ResizeTimeoutFrames() { |
Bo Liu | 140aa0c | 2020-09-14 14:09:56 | [diff] [blame] | 91 | return TimeDeltaToFrames(ResizeTimeout()); |
Fady Samuel | 99ec37a | 2018-07-16 21:43:47 | [diff] [blame] | 92 | } |
| 93 | |
Jonathan Ross | 61ec6534 | 2021-12-14 23:01:40 | [diff] [blame] | 94 | void ClearFallbackSurfaceForCommitPending(); |
akaba | f2624f2 | 2018-08-21 17:11:01 | [diff] [blame] | 95 | // Advances the fallback surface to the first surface after navigation. This |
| 96 | // ensures that stale surfaces are not presented to the user for an indefinite |
| 97 | // period of time. |
| 98 | void ResetFallbackToFirstNavigationSurface(); |
| 99 | |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 100 | bool HasDelegatedContent() const; |
| 101 | |
Bo Liu | fe8fa98 | 2023-05-10 00:51:43 | [diff] [blame] | 102 | const cc::slim::SurfaceLayer* content_layer() const { |
Bo Liu | 6ee5d039 | 2023-01-30 20:30:27 | [diff] [blame] | 103 | return content_layer_.get(); |
| 104 | } |
Fady Samuel | bcac6f0 | 2018-07-11 02:02:42 | [diff] [blame] | 105 | |
Fady Samuel | 0c2f5b8 | 2018-07-19 00:33:46 | [diff] [blame] | 106 | const viz::FrameSinkId& GetFrameSinkId() const; |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 107 | |
Yuri Wiitala | b9ad27a | 2017-09-06 19:13:50 | [diff] [blame] | 108 | // Should only be called when the host has a content layer. Use this for one- |
Piotr Bialecki | 95d8f62 | 2021-07-29 18:58:44 | [diff] [blame] | 109 | // off screen capture, not for video. Always provides ResultFormat::RGBA, |
| 110 | // ResultDestination::kSystemMemory CopyOutputResults. |
William Liu | 6dcb0eb | 2023-08-08 17:38:23 | [diff] [blame] | 111 | // `capture_exact_surface_id` indicates if the `CopyOutputRequest` will be |
| 112 | // issued against a specific surface or not. |
Yuri Wiitala | 419ed0f | 2018-02-22 23:21:38 | [diff] [blame] | 113 | void CopyFromCompositingSurface( |
| 114 | const gfx::Rect& src_subrect, |
| 115 | const gfx::Size& output_size, |
William Liu | 6dcb0eb | 2023-08-08 17:38:23 | [diff] [blame] | 116 | base::OnceCallback<void(const SkBitmap&)> callback, |
Aldo Culquicondor | edee2d29 | 2025-02-12 18:27:38 | [diff] [blame] | 117 | bool capture_exact_surface_id, |
Aldo Culquicondor | aee41bb | 2025-05-05 20:03:11 | [diff] [blame] | 118 | base::TimeDelta ipc_delay); |
Yuri Wiitala | 419ed0f | 2018-02-22 23:21:38 | [diff] [blame] | 119 | bool CanCopyFromCompositingSurface() const; |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 120 | |
danakj | 1120f4c | 2016-09-15 02:05:32 | [diff] [blame] | 121 | void CompositorFrameSinkChanged(); |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 122 | |
enne | a487a27 | 2016-09-30 19:56:18 | [diff] [blame] | 123 | // Called when this DFH is attached/detached from a parent browser compositor |
| 124 | // and needs to be attached to the surface hierarchy. |
staraz | aa23111 | 2017-02-07 17:53:24 | [diff] [blame] | 125 | void AttachToCompositor(WindowAndroidCompositor* compositor); |
| 126 | void DetachFromCompositor(); |
enne | a487a27 | 2016-09-30 19:56:18 | [diff] [blame] | 127 | |
Fady Samuel | ac325ce | 2018-06-01 15:23:27 | [diff] [blame] | 128 | bool IsPrimarySurfaceEvicted() const; |
| 129 | bool HasSavedFrame() const; |
| 130 | void WasHidden(); |
| 131 | void WasShown(const viz::LocalSurfaceId& local_surface_id, |
Vasiliy Telezhnikov | 03d42b52 | 2020-06-29 14:40:59 | [diff] [blame] | 132 | const gfx::Size& size_in_pixels, |
Jonathan Ross | 95bab10 | 2022-10-14 14:10:24 | [diff] [blame] | 133 | bool is_fullscreen, |
| 134 | blink::mojom::RecordContentToVisibleTimeRequestPtr |
| 135 | content_to_visible_time_request); |
Saman Sami | 1bbd1469 | 2018-10-19 22:27:30 | [diff] [blame] | 136 | void EmbedSurface(const viz::LocalSurfaceId& new_local_surface_id, |
| 137 | const gfx::Size& new_size_in_pixels, |
Vasiliy Telezhnikov | 03d42b52 | 2020-06-29 14:40:59 | [diff] [blame] | 138 | cc::DeadlinePolicy deadline_policy, |
Vasiliy Telezhnikov | 2bef50f | 2020-07-10 19:19:31 | [diff] [blame] | 139 | bool is_fullscreen); |
Eric Karl | baa55ff3 | 2018-01-18 00:46:11 | [diff] [blame] | 140 | |
Jonathan Ross | 95bab10 | 2022-10-14 14:10:24 | [diff] [blame] | 141 | // Called to request the presentation time for the next frame or cancel any |
| 142 | // requests when the RenderWidget's visibility state is not changing. If the |
| 143 | // visibility state is changing call WasHidden or WasShown instead. |
Mohsen Izadi | cc48229 | 2023-02-01 16:18:57 | [diff] [blame] | 144 | void RequestSuccessfulPresentationTimeForNextFrame( |
Jonathan Ross | 95bab10 | 2022-10-14 14:10:24 | [diff] [blame] | 145 | blink::mojom::RecordContentToVisibleTimeRequestPtr |
| 146 | content_to_visible_time_request); |
Mohsen Izadi | cc48229 | 2023-02-01 16:18:57 | [diff] [blame] | 147 | void CancelSuccessfulPresentationTimeRequest(); |
Jonathan Ross | 95bab10 | 2022-10-14 14:10:24 | [diff] [blame] | 148 | |
Eric Karl | baa55ff3 | 2018-01-18 00:46:11 | [diff] [blame] | 149 | // Returns the ID for the current Surface. Returns an invalid ID if no |
| 150 | // surface exists (!HasDelegatedContent()). |
Fady Samuel | 120c7e2 | 2018-07-20 05:19:28 | [diff] [blame] | 151 | viz::SurfaceId SurfaceId() const; |
Saman Sami | 1bbd1469 | 2018-10-19 22:27:30 | [diff] [blame] | 152 | |
Saman Sami | f03a9dba | 2018-09-24 18:05:07 | [diff] [blame] | 153 | bool HasPrimarySurface() const; |
Xu Xing | 9ef5a88 | 2018-08-21 00:11:20 | [diff] [blame] | 154 | bool HasFallbackSurface() const; |
Eric Karl | baa55ff3 | 2018-01-18 00:46:11 | [diff] [blame] | 155 | |
Saman Sami | 26a1fcd | 2018-04-10 17:12:21 | [diff] [blame] | 156 | void TakeFallbackContentFrom(DelegatedFrameHostAndroid* other); |
| 157 | |
Jonathan Ross | 865a12d | 2020-12-16 22:33:00 | [diff] [blame] | 158 | // Called when navigation has completed, and this DelegatedFrameHost is |
| 159 | // visible. A new Surface will have been embedded at this point. If navigation |
| 160 | // is done while hidden, this will be called upon becoming visible. |
Eric Karl | db7eb24 | 2018-05-16 17:16:59 | [diff] [blame] | 161 | void DidNavigate(); |
William Liu | f88840b | 2023-07-20 18:27:13 | [diff] [blame] | 162 | |
Jonathan Ross | 865a12d | 2020-12-16 22:33:00 | [diff] [blame] | 163 | // Navigation to a different page than the current one has begun. This is |
| 164 | // called regardless of the visibility of the page. Caches the current |
| 165 | // LocalSurfaceId information so that old content can be evicted if |
| 166 | // navigation fails to complete. |
William Liu | f88840b | 2023-07-20 18:27:13 | [diff] [blame] | 167 | void DidNavigateMainFramePreCommit(); |
| 168 | |
| 169 | // Called when the page has just entered BFCache. |
| 170 | void DidEnterBackForwardCache(); |
Eric Karl | db7eb24 | 2018-05-16 17:16:59 | [diff] [blame] | 171 | |
William Liu | d130bd4 | 2025-02-11 15:42:20 | [diff] [blame] | 172 | // Called when the page was activated from BFCache. |
| 173 | void ActivatedOrEvictedFromBackForwardCache(); |
| 174 | |
Vladimir Levin | 16c09ed | 2023-04-21 14:23:41 | [diff] [blame] | 175 | viz::SurfaceId GetFallbackSurfaceIdForTesting() const; |
| 176 | |
William Liu | f88840b | 2023-07-20 18:27:13 | [diff] [blame] | 177 | viz::SurfaceId GetCurrentSurfaceIdForTesting() const; |
| 178 | |
| 179 | viz::SurfaceId GetPreNavigationSurfaceIdForTesting() const { |
| 180 | return GetPreNavigationSurfaceId(); |
| 181 | } |
| 182 | |
William Liu | 2ad0173 | 2023-11-20 21:31:11 | [diff] [blame] | 183 | viz::SurfaceId GetFirstSurfaceIdAfterNavigationForTesting() const; |
| 184 | |
William Liu | d130bd4 | 2025-02-11 15:42:20 | [diff] [blame] | 185 | viz::SurfaceId GetBFCacheFallbackSurfaceIdForTesting() const; |
| 186 | |
Khushal Sagar | 402d1c9f | 2023-11-15 22:21:48 | [diff] [blame] | 187 | void SetIsFrameSinkIdOwner(bool is_owner); |
| 188 | |
Peilin Wang | 1187e4e8 | 2025-02-10 08:53:29 | [diff] [blame] | 189 | void RegisterOffsetTags( |
| 190 | const BrowserControlsOffsetTagDefinitions& tag_definitions); |
| 191 | void UnregisterOffsetTags(const cc::BrowserControlsOffsetTags& tags); |
Peilin Wang | 95929bc0 | 2024-06-06 17:13:46 | [diff] [blame] | 192 | |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 193 | private: |
kylechar | 055c210 | 2020-07-13 19:58:15 | [diff] [blame] | 194 | // FrameEvictorClient implementation. |
Jonathan Ross | 579e74c1 | 2023-02-23 15:45:59 | [diff] [blame] | 195 | void EvictDelegatedFrame( |
| 196 | const std::vector<viz::SurfaceId>& surface_ids) override; |
Eliot Courtney | f760a821 | 2024-04-26 01:35:21 | [diff] [blame] | 197 | viz::FrameEvictorClient::EvictIds CollectSurfaceIdsForEviction() |
| 198 | const override; |
Jonathan Ross | 579e74c1 | 2023-02-23 15:45:59 | [diff] [blame] | 199 | viz::SurfaceId GetCurrentSurfaceId() const override; |
| 200 | viz::SurfaceId GetPreNavigationSurfaceId() const override; |
kylechar | 055c210 | 2020-07-13 19:58:15 | [diff] [blame] | 201 | |
Fady Samuel | bac0f1a | 2017-08-02 15:54:02 | [diff] [blame] | 202 | // viz::HostFrameSinkClient implementation. |
Fady Samuel | 5b7fb8e | 2017-08-08 16:58:22 | [diff] [blame] | 203 | void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override; |
Jonathan Ross | be6a070 | 2021-02-23 01:01:56 | [diff] [blame] | 204 | void OnFrameTokenChanged(uint32_t frame_token, |
| 205 | base::TimeTicks activation_time) override; |
Fady Samuel | bac0f1a | 2017-08-02 15:54:02 | [diff] [blame] | 206 | |
Eric Karl | 5479bee | 2018-08-24 23:10:28 | [diff] [blame] | 207 | void ProcessCopyOutputRequest( |
| 208 | std::unique_ptr<viz::CopyOutputRequest> request); |
| 209 | |
Alexander Cooper | f11d8fb | 2021-04-07 01:54:36 | [diff] [blame] | 210 | void SetLocalSurfaceId(const viz::LocalSurfaceId& local_surface_id); |
| 211 | |
Jonathan Ross | 95bab10 | 2022-10-14 14:10:24 | [diff] [blame] | 212 | // We cannot guarantee to be attached to `registered_parent_compositor_` when |
Mohsen Izadi | cc48229 | 2023-02-01 16:18:57 | [diff] [blame] | 213 | // either WasShown or RequestSuccessfulPresentationTimeForNextFrame is called. |
| 214 | // In such cases we enqueue the request and attempt again to send it once the |
Jonathan Ross | 95bab10 | 2022-10-14 14:10:24 | [diff] [blame] | 215 | // compositor has been attached. |
Mohsen Izadi | cc48229 | 2023-02-01 16:18:57 | [diff] [blame] | 216 | void PostRequestSuccessfulPresentationTimeForNextFrame( |
Jonathan Ross | 95bab10 | 2022-10-14 14:10:24 | [diff] [blame] | 217 | blink::mojom::RecordContentToVisibleTimeRequestPtr |
| 218 | content_to_visible_time_request); |
| 219 | |
Eliot Courtney | 57bed97e | 2024-11-15 15:51:38 | [diff] [blame] | 220 | void UpdateCaptureKeepAlive(); |
| 221 | void ReleaseCaptureKeepAlive(); |
| 222 | |
Fady Samuel | d5c2618 | 2017-07-12 02:43:33 | [diff] [blame] | 223 | const viz::FrameSinkId frame_sink_id_; |
fsamuel | b6acafa | 2016-10-04 03:21:52 | [diff] [blame] | 224 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 225 | raw_ptr<ViewAndroid> view_; |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 226 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 227 | const raw_ptr<viz::HostFrameSinkManager> host_frame_sink_manager_; |
| 228 | raw_ptr<WindowAndroidCompositor> registered_parent_compositor_ = nullptr; |
| 229 | raw_ptr<Client> client_; |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 230 | |
Bo Liu | 6ee5d039 | 2023-01-30 20:30:27 | [diff] [blame] | 231 | scoped_refptr<cc::slim::SurfaceLayer> content_layer_; |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 232 | |
Eric Karl | db7eb24 | 2018-05-16 17:16:59 | [diff] [blame] | 233 | // Whether we've received a frame from the renderer since navigating. |
Fady Samuel | dba483c | 2018-05-30 04:42:35 | [diff] [blame] | 234 | // Only used when surface synchronization is on. |
akaba | f2624f2 | 2018-08-21 17:11:01 | [diff] [blame] | 235 | viz::LocalSurfaceId first_local_surface_id_after_navigation_; |
William Liu | f88840b | 2023-07-20 18:27:13 | [diff] [blame] | 236 | |
Jonathan Ross | 865a12d | 2020-12-16 22:33:00 | [diff] [blame] | 237 | // While navigating we have no active |local_surface_id_|. Track the one from |
| 238 | // before a navigation, because if the navigation fails to complete, we will |
William Liu | f88840b | 2023-07-20 18:27:13 | [diff] [blame] | 239 | // need to evict its surface. If the old page enters BFCache, this id is used |
| 240 | // to restore `local_surface_id_`. |
Jonathan Ross | 865a12d | 2020-12-16 22:33:00 | [diff] [blame] | 241 | viz::LocalSurfaceId pre_navigation_local_surface_id_; |
Fady Samuel | dba483c | 2018-05-30 04:42:35 | [diff] [blame] | 242 | |
William Liu | f88840b | 2023-07-20 18:27:13 | [diff] [blame] | 243 | // The fallback ID for BFCache restore. It is set when `this` enters the |
| 244 | // BFCache and is cleared when resize-while-hidden (which supplies with a |
| 245 | // latest fallback ID) or after it is used in `EmbedSurface`. |
| 246 | viz::LocalSurfaceId bfcache_fallback_; |
| 247 | |
Saman Sami | 1bbd1469 | 2018-10-19 22:27:30 | [diff] [blame] | 248 | // The LocalSurfaceId of the currently embedded surface. If surface sync is |
| 249 | // on, this surface is not necessarily active. |
William Liu | f88840b | 2023-07-20 18:27:13 | [diff] [blame] | 250 | // |
Alison Gale | c5ea1859 | 2024-04-16 16:08:51 | [diff] [blame] | 251 | // TODO(crbug.com/40274223): this value is a copy of what the browser |
William Liu | f88840b | 2023-07-20 18:27:13 | [diff] [blame] | 252 | // wants to embed. The source of truth is stored else where. We should |
| 253 | // consider de-dup this ID. |
Saman Sami | 1bbd1469 | 2018-10-19 22:27:30 | [diff] [blame] | 254 | viz::LocalSurfaceId local_surface_id_; |
Eric Karl | db7eb24 | 2018-05-16 17:16:59 | [diff] [blame] | 255 | |
Fady Samuel | ac325ce | 2018-06-01 15:23:27 | [diff] [blame] | 256 | // The size of the above surface (updated at the same time). |
Saman Sami | 1bbd1469 | 2018-10-19 22:27:30 | [diff] [blame] | 257 | gfx::Size surface_size_in_pixels_; |
Fady Samuel | ac325ce | 2018-06-01 15:23:27 | [diff] [blame] | 258 | |
Jonathan Ross | 95bab10 | 2022-10-14 14:10:24 | [diff] [blame] | 259 | // If `registered_parent_compositor_` is not attached when we receive a |
| 260 | // request, we save it and attempt again to send it once the compositor has |
| 261 | // been attached. |
| 262 | blink::mojom::RecordContentToVisibleTimeRequestPtr |
| 263 | content_to_visible_time_request_; |
| 264 | blink::ContentToVisibleTimeReporter content_to_visible_time_recorder_; |
| 265 | |
Fady Samuel | ac325ce | 2018-06-01 15:23:27 | [diff] [blame] | 266 | std::unique_ptr<viz::FrameEvictor> frame_evictor_; |
Khushal Sagar | 402d1c9f | 2023-11-15 22:21:48 | [diff] [blame] | 267 | |
Eliot Courtney | 57bed97e | 2024-11-15 15:51:38 | [diff] [blame] | 268 | // If the tab is backgrounded (not visible in the UI), then make sure that the |
| 269 | // surface is kept alive. This is required for e.g. capture of surfaces during |
| 270 | // tab sharing to work. We do this for tabs visible in the UI as well, which |
| 271 | // is redundant, but shouldn't hurt anything. |
| 272 | ui::WindowAndroidCompositor::ScopedKeepSurfaceAliveCallback |
| 273 | capture_keep_alive_callback_; |
| 274 | |
Khushal Sagar | 402d1c9f | 2023-11-15 22:21:48 | [diff] [blame] | 275 | // Speculative RenderWidgetHostViews can start with a FrameSinkId owned by the |
| 276 | // currently committed RenderWidgetHostView. Ownership is transferred when the |
| 277 | // navigation is committed. This bit tracks whether this |
| 278 | // DelegatedFrameHostAndroid owns its FrameSinkId. |
| 279 | bool owns_frame_sink_id_ = false; |
khushalsagar | a693aa7 | 2016-08-16 22:18:06 | [diff] [blame] | 280 | }; |
| 281 | |
| 282 | } // namespace ui |
| 283 | |
| 284 | #endif // UI_ANDROID_DELEGATED_FRAME_HOST_ANDROID_H_ |