forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
window_android_compositor.h
83 lines (70 loc) · 3.11 KB
/
window_android_compositor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_ANDROID_WINDOW_ANDROID_COMPOSITOR_H_
#define UI_ANDROID_WINDOW_ANDROID_COMPOSITOR_H_
#include <memory>
#include "base/observer_list_types.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "ui/android/ui_android_export.h"
#include "ui/compositor/compositor_lock.h"
namespace viz {
class SurfaceId;
struct FrameTimingDetails;
}
namespace ui {
class ResourceManager;
// Android interface for compositor-related tasks.
class UI_ANDROID_EXPORT WindowAndroidCompositor {
public:
virtual ~WindowAndroidCompositor() {}
// Ref must be destroyed on same thread as WindowAndroidCompositor.
class ReadbackRef {
public:
virtual ~ReadbackRef() = default;
protected:
ReadbackRef() = default;
};
class FrameSubmissionObserver : public base::CheckedObserver {
public:
virtual void DidSubmitCompositorFrame() {}
};
// While there are outstanding ReadbackRefs, Compositor will attempt to
// ensure any pending viz::CopyOutputRequest in any part of the compositor
// surface tree are fulfilled in a timely manner. `surface_id` corresponds to
// the `Surface` being copied. The GPU contents of this `surface_id` are kept
// alive as long as there is an outstanding `ReadbackRef` for it.
virtual std::unique_ptr<ReadbackRef> TakeReadbackRef(
const viz::SurfaceId& surface_id) = 0;
virtual void RequestCopyOfOutputOnRootLayer(
std::unique_ptr<viz::CopyOutputRequest> request) = 0;
virtual void SetNeedsAnimate() = 0;
virtual ResourceManager& GetResourceManager() = 0;
virtual viz::FrameSinkId GetFrameSinkId() = 0;
virtual void AddChildFrameSink(const viz::FrameSinkId& frame_sink_id) = 0;
virtual void RemoveChildFrameSink(const viz::FrameSinkId& frame_sink_id) = 0;
virtual bool IsDrawingFirstVisibleFrame() const = 0;
virtual void SetVSyncPaused(bool paused) = 0;
virtual void OnUpdateRefreshRate(float refresh_rate) = 0;
virtual void OnUpdateSupportedRefreshRates(
const std::vector<float>& supported_refresh_rates) = 0;
virtual std::unique_ptr<ui::CompositorLock> GetCompositorLock(
base::TimeDelta timeout) = 0;
virtual void OnUpdateOverlayTransform() = 0;
// This parallels
// ui::Compositor::RequestSuccessfulPresentationTimeForNextFrame, which while
// defined in ui is only implemented within content/browser/renderer_host
// which is not visible to other ui code. The majority of ui abstracts away
// ui::Compositor under ui::WindowAndroidCompositor.
using SuccessfulPresentationTimeCallback =
base::OnceCallback<void(const viz::FrameTimingDetails&)>;
virtual void PostRequestSuccessfulPresentationTimeForNextFrame(
SuccessfulPresentationTimeCallback callback) = 0;
virtual void AddFrameSubmissionObserver(
FrameSubmissionObserver* observer) = 0;
virtual void RemoveFrameSubmissionObserver(
FrameSubmissionObserver* observer) = 0;
};
} // namespace ui
#endif // UI_ANDROID_WINDOW_ANDROID_COMPOSITOR_H_