blob: 52d9540eeb5049d3ceac87bd9cb743ec6da96a7d [file] [log] [blame]
Prabir Pradhan48f8cb92021-08-26 14:05:36 -07001/*
2 * Copyright 2021 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#define LOG_TAG "DisplayInfo"
18
19#include <binder/Parcel.h>
20#include <gui/DisplayInfo.h>
21#include <private/gui/ParcelUtils.h>
22
23#include <log/log.h>
24
25namespace android::gui {
26
27// --- DisplayInfo ---
28
29status_t DisplayInfo::readFromParcel(const android::Parcel* parcel) {
30 if (parcel == nullptr) {
31 ALOGE("%s: Null parcel", __func__);
32 return BAD_VALUE;
33 }
34
35 float dsdx, dtdx, tx, dtdy, dsdy, ty;
36 SAFE_PARCEL(parcel->readInt32, &displayId);
37 SAFE_PARCEL(parcel->readInt32, &logicalWidth);
38 SAFE_PARCEL(parcel->readInt32, &logicalHeight);
39 SAFE_PARCEL(parcel->readFloat, &dsdx);
40 SAFE_PARCEL(parcel->readFloat, &dtdx);
41 SAFE_PARCEL(parcel->readFloat, &tx);
42 SAFE_PARCEL(parcel->readFloat, &dtdy);
43 SAFE_PARCEL(parcel->readFloat, &dsdy);
44 SAFE_PARCEL(parcel->readFloat, &ty);
45
46 transform.set({dsdx, dtdx, tx, dtdy, dsdy, ty, 0, 0, 1});
47
48 return OK;
49}
50
51status_t DisplayInfo::writeToParcel(android::Parcel* parcel) const {
52 if (parcel == nullptr) {
53 ALOGE("%s: Null parcel", __func__);
54 return BAD_VALUE;
55 }
56
57 SAFE_PARCEL(parcel->writeInt32, displayId);
58 SAFE_PARCEL(parcel->writeInt32, logicalWidth);
59 SAFE_PARCEL(parcel->writeInt32, logicalHeight);
60 SAFE_PARCEL(parcel->writeFloat, transform.dsdx());
61 SAFE_PARCEL(parcel->writeFloat, transform.dtdx());
62 SAFE_PARCEL(parcel->writeFloat, transform.tx());
63 SAFE_PARCEL(parcel->writeFloat, transform.dtdy());
64 SAFE_PARCEL(parcel->writeFloat, transform.dsdy());
65 SAFE_PARCEL(parcel->writeFloat, transform.ty());
66
67 return OK;
68}
69
70} // namespace android::gui