• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "vsync_connection_proxy.h"
17 #include "graphic_common.h"
18 
19 namespace OHOS {
20 namespace Rosen {
VSyncConnectionProxy(const sptr<IRemoteObject> & impl)21 VSyncConnectionProxy::VSyncConnectionProxy(const sptr<IRemoteObject>& impl)
22     : IRemoteProxy<IVSyncConnection>(impl)
23 {
24 }
25 
RequestNextVSync()26 VsyncError VSyncConnectionProxy::RequestNextVSync()
27 {
28     MessageOption opt;
29     MessageParcel arg;
30     MessageParcel ret;
31 
32     arg.WriteInterfaceToken(GetDescriptor());
33     int res = Remote()->SendRequest(IVSYNC_CONNECTION_REQUEST_NEXT_VSYNC, arg, ret, opt);
34     if (res != NO_ERROR) {
35         return VSYNC_ERROR_BINDER_ERROR;
36     }
37     return VSYNC_ERROR_OK;
38 }
39 
GetReceiveFd(int32_t & fd)40 VsyncError VSyncConnectionProxy::GetReceiveFd(int32_t &fd)
41 {
42     MessageOption opt;
43     MessageParcel arg;
44     MessageParcel ret;
45 
46     arg.WriteInterfaceToken(GetDescriptor());
47     int res = Remote()->SendRequest(IVSYNC_CONNECTION_GET_RECEIVE_FD, arg, ret, opt);
48     if (res != NO_ERROR) {
49         return VSYNC_ERROR_BINDER_ERROR;
50     }
51     fd = ret.ReadFileDescriptor();
52     return VSYNC_ERROR_OK;
53 }
54 
SetVSyncRate(int32_t rate)55 VsyncError VSyncConnectionProxy::SetVSyncRate(int32_t rate)
56 {
57     if (rate <= 0) {
58         return VSYNC_ERROR_INVALID_ARGUMENTS;
59     }
60     MessageOption opt;
61     MessageParcel arg;
62     MessageParcel ret;
63 
64     arg.WriteInterfaceToken(GetDescriptor());
65     arg.WriteInt32(rate);
66     int res = Remote()->SendRequest(IVSYNC_CONNECTION_SET_RATE, arg, ret, opt);
67     if (res != NO_ERROR) {
68         return VSYNC_ERROR_BINDER_ERROR;
69     }
70     return VSYNC_ERROR_OK;
71 }
72 } // namespace Vsync
73 } // namespace OHOS
74