1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <binder/IInterface.h>
20#include <binder/SafeInterface.h>
21
22#include <utils/Errors.h>
23
24#include <cstdint>
25
26namespace android {
27
28namespace gui {
29class BitTube;
30} // namespace gui
31
32class IDisplayEventConnection : public IInterface {
33public:
34    DECLARE_META_INTERFACE(DisplayEventConnection)
35
36    /*
37     * stealReceiveChannel() returns a BitTube to receive events from. Only the receive file
38     * descriptor of outChannel will be initialized, and this effectively "steals" the receive
39     * channel from the remote end (such that the remote end can only use its send channel).
40     */
41    virtual status_t stealReceiveChannel(gui::BitTube* outChannel) = 0;
42
43    /*
44     * setVsyncRate() sets the vsync event delivery rate. A value of 1 returns every vsync event.
45     * A value of 2 returns every other event, etc. A value of 0 returns no event unless
46     * requestNextVsync() has been called.
47     */
48    virtual status_t setVsyncRate(uint32_t count) = 0;
49
50    /*
51     * requestNextVsync() schedules the next vsync event. It has no effect if the vsync rate is > 0.
52     */
53    virtual void requestNextVsync() = 0; // Asynchronous
54};
55
56class BnDisplayEventConnection : public SafeBnInterface<IDisplayEventConnection> {
57public:
58    BnDisplayEventConnection()
59          : SafeBnInterface<IDisplayEventConnection>("BnDisplayEventConnection") {}
60
61    status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply,
62                        uint32_t flags = 0) override;
63};
64
65} // namespace android
66