blob: c0e246fa15a68b8982b0ebc4b6acc170c985aea2 [file] [log] [blame]
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001/*
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
Mathias Agopiand0566bc2011-11-17 17:49:17 -080017#include <gui/IDisplayEventConnection.h>
Mathias Agopian801ea092017-03-06 15:05:04 -080018
19#include <private/gui/BitTube.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080020
21namespace android {
Mathias Agopiand0566bc2011-11-17 17:49:17 -080022
Dan Stoza2d191c32017-04-03 13:27:12 -070023namespace { // Anonymous
24
25enum class Tag : uint32_t {
Dan Stoza6b698e42017-04-03 13:09:08 -070026 STEAL_RECEIVE_CHANNEL = IBinder::FIRST_CALL_TRANSACTION,
27 SET_VSYNC_RATE,
Dan Stoza2d191c32017-04-03 13:27:12 -070028 REQUEST_NEXT_VSYNC,
Alec Mouribe617542020-08-05 12:50:03 -070029 LAST = REQUEST_NEXT_VSYNC,
Dan Stoza6b698e42017-04-03 13:09:08 -070030};
Mathias Agopiand0566bc2011-11-17 17:49:17 -080031
Dan Stoza2d191c32017-04-03 13:27:12 -070032} // Anonymous namespace
33
34class BpDisplayEventConnection : public SafeBpInterface<IDisplayEventConnection> {
Mathias Agopiand0566bc2011-11-17 17:49:17 -080035public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070036 explicit BpDisplayEventConnection(const sp<IBinder>& impl)
Dan Stoza2d191c32017-04-03 13:27:12 -070037 : SafeBpInterface<IDisplayEventConnection>(impl, "BpDisplayEventConnection") {}
Mathias Agopiand0566bc2011-11-17 17:49:17 -080038
Dan Stozae1c599b2017-03-30 16:37:19 -070039 ~BpDisplayEventConnection() override;
Dan Stozad723bd72014-11-18 10:24:03 -080040
Dan Stoza6b698e42017-04-03 13:09:08 -070041 status_t stealReceiveChannel(gui::BitTube* outChannel) override {
Dan Stoza2d191c32017-04-03 13:27:12 -070042 return callRemote<decltype(
43 &IDisplayEventConnection::stealReceiveChannel)>(Tag::STEAL_RECEIVE_CHANNEL,
44 outChannel);
Mathias Agopiand0566bc2011-11-17 17:49:17 -080045 }
Mathias Agopian478ae5e2011-12-06 17:22:19 -080046
Dan Stozae1c599b2017-03-30 16:37:19 -070047 status_t setVsyncRate(uint32_t count) override {
Dan Stoza2d191c32017-04-03 13:27:12 -070048 return callRemote<decltype(&IDisplayEventConnection::setVsyncRate)>(Tag::SET_VSYNC_RATE,
49 count);
Mathias Agopian478ae5e2011-12-06 17:22:19 -080050 }
51
Dan Stozae1c599b2017-03-30 16:37:19 -070052 void requestNextVsync() override {
Dan Stoza2d191c32017-04-03 13:27:12 -070053 callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>(
54 Tag::REQUEST_NEXT_VSYNC);
Mathias Agopian478ae5e2011-12-06 17:22:19 -080055 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -080056};
57
Dan Stozaa5f61dd2017-03-30 16:09:13 -070058// Out-of-line virtual method definition to trigger vtable emission in this translation unit (see
59// clang warning -Wweak-vtables)
Dan Stoza2d191c32017-04-03 13:27:12 -070060BpDisplayEventConnection::~BpDisplayEventConnection() = default;
Dan Stozad723bd72014-11-18 10:24:03 -080061
Mathias Agopiand0566bc2011-11-17 17:49:17 -080062IMPLEMENT_META_INTERFACE(DisplayEventConnection, "android.gui.DisplayEventConnection");
63
Dan Stozaa5f61dd2017-03-30 16:09:13 -070064status_t BnDisplayEventConnection::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
65 uint32_t flags) {
Dan Stoza2d191c32017-04-03 13:27:12 -070066 if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) {
67 return BBinder::onTransact(code, data, reply, flags);
Mathias Agopiand0566bc2011-11-17 17:49:17 -080068 }
Dan Stoza2d191c32017-04-03 13:27:12 -070069 auto tag = static_cast<Tag>(code);
70 switch (tag) {
71 case Tag::STEAL_RECEIVE_CHANNEL:
72 return callLocal(data, reply, &IDisplayEventConnection::stealReceiveChannel);
73 case Tag::SET_VSYNC_RATE:
74 return callLocal(data, reply, &IDisplayEventConnection::setVsyncRate);
75 case Tag::REQUEST_NEXT_VSYNC:
76 return callLocalAsync(data, reply, &IDisplayEventConnection::requestNextVsync);
77 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -080078}
79
Dan Stozaa5f61dd2017-03-30 16:09:13 -070080} // namespace android