blob: 80429765be2976356a86e23ef0aca3984b6ed597 [file] [log] [blame]
Sally Qief006582024-10-11 13:23:09 -07001/*
2 * Copyright (C) 2024 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#include "include/gui/DisplayLuts.h"
18#include <gui/DisplayLuts.h>
19#include <private/gui/ParcelUtils.h>
20
21namespace android::gui {
22
23status_t DisplayLuts::Entry::readFromParcel(const android::Parcel* parcel) {
24 if (parcel == nullptr) {
25 ALOGE("%s: Null parcel", __func__);
26 return BAD_VALUE;
27 }
28
29 SAFE_PARCEL(parcel->readInt32, &dimension);
30 SAFE_PARCEL(parcel->readInt32, &size);
31 SAFE_PARCEL(parcel->readInt32, &samplingKey);
32
33 return OK;
34}
35
36status_t DisplayLuts::Entry::writeToParcel(android::Parcel* parcel) const {
37 if (parcel == nullptr) {
38 ALOGE("%s: Null parcel", __func__);
39 return BAD_VALUE;
40 }
41
42 SAFE_PARCEL(parcel->writeInt32, dimension);
43 SAFE_PARCEL(parcel->writeInt32, size);
44 SAFE_PARCEL(parcel->writeInt32, samplingKey);
45
46 return OK;
47}
48
49status_t DisplayLuts::readFromParcel(const android::Parcel* parcel) {
50 if (parcel == nullptr) {
51 ALOGE("%s: Null parcel", __func__);
52 return BAD_VALUE;
53 }
54
55 SAFE_PARCEL(parcel->readUniqueFileDescriptor, &fd);
56 SAFE_PARCEL(parcel->readInt32Vector, &offsets);
57 int32_t numLutProperties;
58 SAFE_PARCEL(parcel->readInt32, &numLutProperties);
59 lutProperties.reserve(numLutProperties);
60 for (int32_t i = 0; i < numLutProperties; i++) {
61 lutProperties.push_back({});
62 SAFE_PARCEL(lutProperties.back().readFromParcel, parcel);
63 }
64 return OK;
65}
66
67status_t DisplayLuts::writeToParcel(android::Parcel* parcel) const {
68 if (parcel == nullptr) {
69 ALOGE("%s: Null parcel", __func__);
70 return BAD_VALUE;
71 }
72
73 SAFE_PARCEL(parcel->writeUniqueFileDescriptor, fd);
74 SAFE_PARCEL(parcel->writeInt32Vector, offsets);
75 SAFE_PARCEL(parcel->writeInt32, static_cast<int32_t>(lutProperties.size()));
76 for (auto& entry : lutProperties) {
77 SAFE_PARCEL(entry.writeToParcel, parcel);
78 }
79 return OK;
80}
81} // namespace android::gui